@particle-academy/hubspot-js 0.1.0 → 0.3.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 +61 -0
- package/README.md +53 -0
- package/dist/{chunk-Q7XEYLRH.js → chunk-6HO2IP5Q.js} +4 -3
- package/dist/chunk-6HO2IP5Q.js.map +1 -0
- package/dist/flow.cjs +2 -1
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.js +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -4
- package/dist/chunk-Q7XEYLRH.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,65 @@ The four packages share one version, because they are generated from one
|
|
|
7
7
|
`provider/` definition and a version that meant something different in each
|
|
8
8
|
would be a version nobody could reason about.
|
|
9
9
|
|
|
10
|
+
## [0.3.0] — 2026-08-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **The README now says how to SET THIS CONNECTOR UP**, in the package itself.
|
|
15
|
+
|
|
16
|
+
Until now it explained what the four packages are, what they cost and why the
|
|
17
|
+
repo is generated — and said nothing about credentials, scopes, sandboxes or
|
|
18
|
+
operations. Somebody who installed it could not learn from it which credentials
|
|
19
|
+
a connection needs, where a human GETS them, which scopes to request, or what
|
|
20
|
+
the connector can actually do. All of that was already in the definition; the
|
|
21
|
+
one document a consumer reads was the one that omitted everything actionable.
|
|
22
|
+
|
|
23
|
+
The new **Setting it up** section carries:
|
|
24
|
+
|
|
25
|
+
- every credential, with the text saying where the value comes from, whether it
|
|
26
|
+
is **per installation** or **per connected account**, and whether it is secret;
|
|
27
|
+
- the OAuth authorize and token URLs and the exact scopes, verbatim;
|
|
28
|
+
- the access-token lifetime, and where refresh tokens ROTATE, the two things a
|
|
29
|
+
host must not do — retry a failed refresh, or refresh concurrently — because a
|
|
30
|
+
replay revokes the entire grant and nothing in the failure says why;
|
|
31
|
+
- the estate in this provider's own terms, including the cases where a
|
|
32
|
+
successful-looking run reaches nobody, or reaches the real one;
|
|
33
|
+
- every action and trigger with its method, path, inputs, and whether it is safe
|
|
34
|
+
to replay;
|
|
35
|
+
- a trigger's provider-side setup, which nobody can derive from anything else.
|
|
36
|
+
|
|
37
|
+
It is **generated from `provider/manifest.json`**, so it cannot drift from what
|
|
38
|
+
the packages do — which is the point at a few hundred providers, where a
|
|
39
|
+
hand-written setup section is a few hundred documents going quietly stale.
|
|
40
|
+
|
|
41
|
+
No code changed. This release exists because a registry and an installing agent
|
|
42
|
+
read the PUBLISHED artifact, and the artifact carried the old README.
|
|
43
|
+
|
|
44
|
+
## [0.2.0] — 2026-08-24
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- **`@particle-academy/hubspot-ui` is now an OPTIONAL PEER dependency of `@particle-academy/hubspot-js`, not a hard one.**
|
|
49
|
+
|
|
50
|
+
`./flow` needs it; nothing else does. It was a hard dependency, and because
|
|
51
|
+
`@particle-academy/hubspot-ui` itself peer-depends on `fancy-flow` — which npm 7+ installs
|
|
52
|
+
automatically — `npm install @particle-academy/hubspot-js` pulled the **entire flow engine**
|
|
53
|
+
onto disk for a consumer who only wanted to call the API. Roughly **18 MB
|
|
54
|
+
became 874 KB**, and the package works exactly as before:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { hubspot… } from "@particle-academy/hubspot-js";
|
|
58
|
+
// an injected transport, no flow engine anywhere
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**This is breaking if you use `@particle-academy/hubspot-js/flow`.** Add `@particle-academy/hubspot-ui` to your own
|
|
62
|
+
dependencies — it was always being installed for you, and now it is declared.
|
|
63
|
+
Everything importing only the main entry point is unaffected.
|
|
64
|
+
|
|
65
|
+
The fix is on this edge rather than on `@particle-academy/hubspot-ui` → `fancy-flow`: the ui package
|
|
66
|
+
genuinely requires fancy-flow, since it calls `defineConnectorKind`, and marking
|
|
67
|
+
that peer optional would be a lie about what it needs.
|
|
68
|
+
|
|
10
69
|
## [0.1.0] — 2026-08-20
|
|
11
70
|
|
|
12
71
|
First release. Provider four, and the first that is not a static credential.
|
|
@@ -68,3 +127,5 @@ which softens the common case and does nothing for a contact created without
|
|
|
68
127
|
one.
|
|
69
128
|
|
|
70
129
|
[0.1.0]: https://github.com/Fancy-Friends/hubspot/releases/tag/v0.1.0
|
|
130
|
+
[0.2.0]: https://github.com/Fancy-Friends/hubspot/releases/tag/v0.2.0
|
|
131
|
+
[0.3.0]: https://github.com/Fancy-Friends/hubspot/releases/tag/v0.3.0
|
package/README.md
CHANGED
|
@@ -27,6 +27,59 @@ dependencies.
|
|
|
27
27
|
subject to the kit's full approval bar, and one per provider is hundreds of
|
|
28
28
|
dependencies nobody is tracking.
|
|
29
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 HubSpot 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
|
+
| **App client ID** | per installation | not secret | From your HubSpot app's Auth tab. ONE value for the whole installation -- the same app serves every connected account. |
|
|
43
|
+
| **App client secret** | per installation | **secret** | From the same Auth tab. Used to exchange the code and to refresh; never sent with an API request. |
|
|
44
|
+
| **Access token** | per connected account | **secret** | Obtained by the host's OAuth exchange, PER CONNECTED ACCOUNT. Expires after 30 minutes -- a host that does not refresh will work all afternoon and be broken by morning. |
|
|
45
|
+
| **Refresh token** *(optional)* | per connected account | **secret** | Also per account. Does not expire, so it is the credential worth protecting most: it mints access tokens indefinitely until the install is revoked. |
|
|
46
|
+
|
|
47
|
+
### Authorising
|
|
48
|
+
|
|
49
|
+
HubSpot 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://app.hubspot.com/oauth/authorize
|
|
52
|
+
- **Token URL** — https://api.hubapi.com/oauth/v1/token
|
|
53
|
+
- **Scopes** — `crm.objects.contacts.write`
|
|
54
|
+
- **Access token lifetime** — 1800 seconds (30 minutes). A host that never refreshes works all afternoon and is broken by morning.
|
|
55
|
+
|
|
56
|
+
The refresh tokens do **not** rotate: the same one is reusable, so a refresh may safely be retried and may run concurrently. Stated rather than assumed, because the opposite — a provider that spends the token and revokes the grant on a replay — looks identical until it happens.
|
|
57
|
+
|
|
58
|
+
### The estate
|
|
59
|
+
|
|
60
|
+
HubSpot has a test estate on the same host, reached with credentials from a SEPARATE test account you register. Selecting sandbox mode uses those credentials.
|
|
61
|
+
|
|
62
|
+
> HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you create from the developer account, with its own portal id, its own data and its own OAuth install. Same API host, different account -- so the credential is different and the URL is not. Test accounts expire if unused and carry reduced limits, which is why they are a place to test rather than a place to build against.
|
|
63
|
+
|
|
64
|
+
## What it can do
|
|
65
|
+
|
|
66
|
+
### Actions
|
|
67
|
+
|
|
68
|
+
#### `contact_create` — Create contact
|
|
69
|
+
|
|
70
|
+
Create a contact in HubSpot.
|
|
71
|
+
|
|
72
|
+
`POST /crm/v3/objects/contacts` · **unsafe to replay** — a retried durable run does it TWICE
|
|
73
|
+
|
|
74
|
+
| Input | Required | What it is |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `email` | yes | HubSpot de-duplicates contacts on email within an account. A contact created without one cannot be de-duplicated, and a retry will make a second. |
|
|
77
|
+
| `firstName` | no | First name |
|
|
78
|
+
| `lastName` | no | Last name |
|
|
79
|
+
| `company` | no | Company |
|
|
80
|
+
| `phone` | no | Phone |
|
|
81
|
+
| `lifecycleStage` | no | HubSpot's own stage names. A value it does not recognise is refused at write time, not at setup. |
|
|
82
|
+
|
|
30
83
|
## Run it before you have credentials
|
|
31
84
|
|
|
32
85
|
Every operation ships a **faker**, whether or not HubSpot has a sandbox. Set a
|
|
@@ -90,7 +90,8 @@ function nestFields(flat) {
|
|
|
90
90
|
let node = out;
|
|
91
91
|
while (parts.length > 1) {
|
|
92
92
|
const key = parts.shift();
|
|
93
|
-
|
|
93
|
+
const wantsArray = /^\d+$/.test(parts[0] ?? "");
|
|
94
|
+
if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
|
|
94
95
|
node = node[key];
|
|
95
96
|
}
|
|
96
97
|
node[parts[0]] = value;
|
|
@@ -99,5 +100,5 @@ function nestFields(flat) {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker };
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-6HO2IP5Q.js.map
|
|
104
|
+
//# sourceMappingURL=chunk-6HO2IP5Q.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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,CAAA;AAAA,IACjB;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,CAAC,CAAW,CAAA,GAAI,KAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,GAAA;AACT","file":"chunk-6HO2IP5Q.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 // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\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
CHANGED
|
@@ -94,7 +94,8 @@ function nestFields(flat) {
|
|
|
94
94
|
let node = out;
|
|
95
95
|
while (parts.length > 1) {
|
|
96
96
|
const key = parts.shift();
|
|
97
|
-
|
|
97
|
+
const wantsArray = /^\d+$/.test(parts[0] ?? "");
|
|
98
|
+
if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
|
|
98
99
|
node = node[key];
|
|
99
100
|
}
|
|
100
101
|
node[parts[0]] = value;
|
package/dist/flow.cjs.map
CHANGED
|
@@ -1 +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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AQ;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,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"]}
|
|
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,MAAA,CAAO,SAAS,CAAA,GAAI,IAAA;AAAA,M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,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,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 // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\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"]}
|
package/dist/flow.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -92,7 +92,8 @@ function nestFields(flat) {
|
|
|
92
92
|
let node = out;
|
|
93
93
|
while (parts.length > 1) {
|
|
94
94
|
const key = parts.shift();
|
|
95
|
-
|
|
95
|
+
const wantsArray = /^\d+$/.test(parts[0] ?? "");
|
|
96
|
+
if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
|
|
96
97
|
node = node[key];
|
|
97
98
|
}
|
|
98
99
|
node[parts[0]] = value;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +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,OAA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O,GAAA;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 -- 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[par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,GAAG,CAAA;AAC5B,IAAA,IAAI,IAAA,GAAO,GAAA;AAEX,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACvB,MAAA,MAAM,GAAA,GAAM,MAAM,KAAA,EAAM;AAMxB,MAAA,MAAM,aAAa,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,KAAK,EAAE,CAAA;AAE9C,MAAA,IAAI,OAAO,IAAA,CAAK,GAAG,CAAA,KAAM,YAAY,IAAA,CAAK,GAAG,CAAA,KAAM,IAAA,OAAW,GAAG,CAAA,GAAI,UAAA,GAAa,KAAK,EAAC;AACxF,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":"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 -- 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 // A NUMERIC segment is an array index: `dateRanges.0.startDate` has to\n // become `[{startDate}]`, not `{\"0\": {startDate}}`. PHP produced the\n // array by accident (its integer-keyed arrays serialise as JSON lists)\n // and the other two produced an object, which the provider rejects as\n // the wrong type. The parity suite is what caught the disagreement.\n const wantsArray = /^\\d+$/.test(parts[0] ?? \"\");\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = wantsArray ? [] : {};\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/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker } from './chunk-
|
|
1
|
+
export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker } from './chunk-6HO2IP5Q.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-academy/hubspot-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
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
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,15 +48,18 @@
|
|
|
48
48
|
"prepublishOnly": "tsup"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@particle-academy/fancy-connector-core": ">=0.3.1 <2.0"
|
|
52
|
-
"@particle-academy/hubspot-ui": "0.1.0"
|
|
51
|
+
"@particle-academy/fancy-connector-core": ">=0.3.1 <2.0"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
|
-
"@particle-academy/fancy-flow": ">=0.47.1 <2.0"
|
|
54
|
+
"@particle-academy/fancy-flow": ">=0.47.1 <2.0",
|
|
55
|
+
"@particle-academy/hubspot-ui": "0.3.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@particle-academy/fancy-flow": {
|
|
59
59
|
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"@particle-academy/hubspot-ui": {
|
|
62
|
+
"optional": true
|
|
60
63
|
}
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
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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A,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"]}
|