@wefunder/sdk 0.1.0-beta.8 → 0.1.0-beta.9

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.
@@ -2,35 +2,63 @@
2
2
  "manifestVersion": 1,
3
3
  "lang": "JavaScript",
4
4
  "label": "@wefunder/sdk",
5
- "sdkVersion": "0.1.0-beta.8",
5
+ "sdkVersion": "0.1.0-beta.9",
6
6
  "apiVersion": "2025-01-15",
7
7
  "generatedBy": "scripts/build-examples-manifest.mjs",
8
8
  "samples": {
9
+ "createInstallation": "const install = await wf.unwrap(\n wf.raw.createInstallation({\n body: { target_type: \"company\", target_id: \"co_abc123Example\", scopes: [\"read:offerings\", \"read:investments\"] },\n }),\n);\nconsole.log(install.data?.id, install.data?.attributes);",
10
+ "createInstallationToken": "const token = await wf.unwrap(\n wf.raw.createInstallationToken({ path: { external_id: \"ins_9t2xExample\" }, body: { scopes: [\"read:investments\"] } }),\n);\nconsole.log(token.data);",
9
11
  "createIntent": "const { data: intent } = await wf.unwrap(\n wf.raw.createIntent({\n body: {\n action_name: \"syndicates.close_deal\",\n resource_type: \"Club\",\n resource_id: \"syn_example\",\n params: { fundraise_id: 99 },\n // Safe to retry: an existing pending/executed intent with this key is returned instead.\n idempotency_key: \"close-acme-series-a\",\n requested_by_agent: \"My Deal Bot\",\n },\n }),\n);\n// Hand this URL to a human — the action executes only after they approve.\nconsole.log(intent?.attributes?.review_url);",
12
+ "createWebhookEndpoint": "const endpoint = await wf.webhookEndpoints.create({\n url: \"https://yourapp.com/webhooks/wefunder\", // public HTTPS (localhost/private IPs rejected)\n events: [\"offering.opened\", \"investment.executed\", \"investment.changed\"],\n mode: \"live\",\n});\n// Store this now — it's needed by constructEvent() and is never shown again.\nconst signingSecret = endpoint.attributes?.secret;\nconsole.log(endpoint.id, signingSecret);",
10
13
  "createWebhookSubscription": "const subscription = await wf.unwrap(\n wf.raw.createWebhookSubscription({\n path: { campaign_id: 1234 },\n body: {\n target_url: \"https://example.com/wefunder/webhooks\",\n events: [\"investment.confirmed\", \"investment.canceled\"],\n },\n }),\n);\nconsole.log(subscription);",
14
+ "deleteWebhookEndpoint": "const result = await wf.webhookEndpoints.remove(\"whe_8f3ExampleEndpoint00\");\nconsole.log(result.removed); // true",
11
15
  "deleteWebhookSubscription": "await wf.unwrap(wf.raw.deleteWebhookSubscription({ path: { campaign_id: 1234, webhook_id: 56 } }));",
16
+ "followCompany": "const result = await wf.unwrap(wf.raw.followCompany({ path: { company_id: \"co_abc123Example\" } }));\nconsole.log(result);",
12
17
  "getAttributionMe": "const me = await wf.attribution.me();\nconsole.log(me);",
13
18
  "getAttributionStats": "const stats = await wf.unwrap(\n wf.raw.getAttributionStats({\n path: { campaign_id: 1234 },\n query: { start_date: \"2026-01-01\", end_date: \"2026-03-31\", utm_source: \"newsletter\" },\n }),\n);\nconsole.log(stats.data);",
19
+ "getCompany": "const { data: company } = await wf.unwrap(wf.raw.getCompany({ path: { id: \"co_abc123Example\" } }));\nconsole.log(company?.attributes?.name);",
20
+ "getCompanyDisclosures": "const { data: disclosures } = await wf.unwrap(\n wf.raw.getCompanyDisclosures({\n path: { id: \"co_abc123Example\" },\n query: { sections: [\"business\", \"risks\", \"use_of_funds\"] },\n }),\n);\nconsole.log(disclosures?.attributes);",
21
+ "getCompanyPitch": "const { data: pitch } = await wf.unwrap(\n wf.raw.getCompanyPitch({ path: { id: \"co_abc123Example\" }, query: { sections: [\"story\", \"perks\"] } }),\n);\nconsole.log(pitch?.attributes);",
22
+ "getCompanyUpdate": "const { data: update } = await wf.unwrap(\n wf.raw.getCompanyUpdate({ path: { id: \"co_abc123Example\", update_id: \"upd_9t2xExample\" } }),\n);\nconsole.log(update?.attributes?.title);",
14
23
  "getCurrentUser": "const me = await wf.users.me();\nconsole.log(\"Logged in as\", me.id);",
24
+ "getInstallation": "const { data: install } = await wf.unwrap(wf.raw.getInstallation({ path: { external_id: \"ins_9t2xExample\" } }));\nconsole.log(install?.attributes);",
15
25
  "getIntent": "const intent = await wf.intents.get(\"intent_abc123\");\nconsole.log(intent.attributes?.status); // pending | approved | executed | expired | rejected | failed",
16
- "getOffering": "const offering = await wf.offerings.get(\"ofr_QfmTyP8qjfYAvkEgREyL3kLf\");\nconsole.log(offering.attributes?.company_name, offering.attributes?.state);",
26
+ "getInvestment": "const investment = await wf.investments.get(\"inv_8f3kQ2Example\");\nconsole.log(investment.status, investment.amounts?.committed_cents, investment.investor?.id);",
27
+ "getOffering": "const offering = await wf.offerings.get(\"ofr_QfmTyP8qjfYAvkEgREyL3kLf\");\nconsole.log(offering.attributes?.company_name, offering.attributes?.status);",
28
+ "getOfferingStats": "const { data: stats } = await wf.unwrap(\n wf.raw.getOfferingStats({ path: { offering_id: \"ofr_QfmTyP8qjfYAvkEgREyL3kLf\" } }),\n);\nconsole.log(stats);",
17
29
  "getPortfolio": "const summary = await wf.portfolio.get();\nconsole.log(\n summary.attributes?.total_current_value_cents,\n summary.attributes?.return_multiple,\n);",
18
30
  "getSyndicate": "const syndicate = await wf.syndicates.get(42);\nconsole.log(syndicate.attributes?.name, syndicate.attributes?.deal_count);",
19
31
  "getSyndicatePortfolio": "const { data: summary } = await wf.unwrap(\n wf.raw.getSyndicatePortfolio({\n path: { syndicate_id: \"syn_example\" },\n }),\n);\nconsole.log(summary?.attributes?.total_current_value_cents);",
32
+ "getWebhookEndpoint": "const endpoint = await wf.webhookEndpoints.get(\"whe_8f3ExampleEndpoint00\");\nconsole.log(endpoint.attributes?.events, endpoint.attributes?.failing_since);",
20
33
  "getWebhookSubscription": "const subscription = await wf.unwrap(\n wf.raw.getWebhookSubscription({ path: { campaign_id: 1234, webhook_id: 56 } }),\n);\nconsole.log(subscription.data);",
21
34
  "guides/client-credentials": "const wf = await Wefunder.fromClientCredentials({\n clientId: process.env.WEFUNDER_CLIENT_ID!,\n clientSecret: process.env.WEFUNDER_CLIENT_SECRET!,\n scopes: [\"read:public\"],\n});\n\nconsole.log(\"mode:\", wf.mode); // \"live\" or \"test\", from the token prefix\n\n// client_credentials holds only read:public — browse public offerings.\n// (wf.users.me() would throw 403 insufficient_scope: it needs read:profile.)\nfor await (const offering of wf.offerings.all()) {\n console.log(offering.id);\n}",
22
35
  "listActivity": "// Everything my connected apps did to syndicate members, most recent first.\nconst activity = await wf.unwrap(\n wf.raw.listActivity({\n query: { action_pattern: \"syndicates.member.*\", status: \"success\" },\n }),\n);\nfor (const event of activity.data ?? []) {\n console.log(event.attributes?.action, event.attributes?.created_at);\n}",
23
36
  "listAttributedInvestments": "const investments = await wf.unwrap(\n wf.raw.listAttributedInvestments({\n path: { campaign_id: 1234 },\n query: { start_date: \"2026-01-01\", detail_level: \"anonymized\" },\n }),\n);\nfor (const investment of investments.data ?? []) {\n if (\"amount_tier\" in investment) {\n // Anonymized row: opaque tokens + an amount tier, never exact values or PII.\n console.log(investment.investor_token, investment.amount_tier, investment.attribution?.utm_source);\n }\n}",
24
37
  "listAttributionCampaigns": "const campaigns = await wf.unwrap(wf.raw.listAttributionCampaigns());\nconsole.log(campaigns.data);",
25
38
  "listCampaigns": "// Campaigns for companies where the authenticated user is a founder.\nconst page = await wf.campaigns.list();\nfor (const campaign of page.data ?? []) {\n console.log(campaign.id, campaign.attributes?.company_name, campaign.attributes?.amount_raised);\n}\n\n// Or stream every campaign lazily, one page fetched at a time:\nfor await (const campaign of wf.campaigns.all()) {\n console.log(campaign.attributes?.state);\n}",
39
+ "listCompanyQuestions": "const page = await wf.unwrap(\n wf.raw.listCompanyQuestions({\n path: { id: \"co_abc123Example\" },\n query: { q: \"revenue\", unanswered_by_team: true, per_page: 20 },\n }),\n);\nfor (const question of page.data ?? []) console.log(question.id, question.attributes);",
40
+ "listCompanyUpdates": "const page = await wf.unwrap(wf.raw.listCompanyUpdates({ path: { id: \"co_abc123Example\" }, query: { per_page: 10 } }));\nfor (const update of page.data ?? []) console.log(update.id, update.attributes?.title);\nconsole.log(page.meta?.next_cursor);",
26
41
  "listConnectedApps": "const apps = await wf.unwrap(wf.raw.listConnectedApps());\nfor (const app of apps.data ?? []) {\n console.log(app.id, app.attributes?.name);\n}",
42
+ "listEligibleInstallTargets": "const targets = await wf.unwrap(wf.raw.listEligibleInstallTargets({ query: { target_type: \"company\" } }));\nfor (const target of targets.data ?? []) console.log(target);",
43
+ "listFollowedCompanies": "const page = await wf.unwrap(wf.raw.listFollowedCompanies({ query: { per_page: 25 } }));\nfor (const company of page.data ?? []) console.log(company.id);",
44
+ "listInstallations": "const installs = await wf.unwrap(wf.raw.listInstallations());\nfor (const install of installs.data ?? []) console.log(install.id, install.attributes);",
27
45
  "listIntents": "// Which of my proposed actions are still waiting on human approval?\nconst page = await wf.intents.list({ status: \"pending\" });\nfor (const intent of page.data ?? []) {\n console.log(intent.id, intent.attributes?.action, intent.attributes?.review_url);\n}",
28
46
  "listInvestments": "// Auto-paginate the full history lazily:\nfor await (const investment of wf.investments.all()) {\n console.log(investment.id);\n}\n\n// Or grab one page with its meta (next_cursor, etc.):\nconst page = await wf.investments.list();\nconsole.log(page.data?.length, page.meta?.next_cursor);",
47
+ "listMyCompanies": "const companies = await wf.unwrap(wf.raw.listMyCompanies());\nfor (const company of companies.data ?? []) console.log(company.id, company.attributes?.name);",
29
48
  "listOfferings": "// Browse live offerings, sorted. The cursor is opaque and handled for you.\nconst page = await wf.offerings.list({ sort: \"most_raised\" });\nfor (const offering of page.data ?? []) {\n console.log(offering.id, offering.attributes?.company_name);\n}\n\n// Or stream every offering lazily, one page fetched at a time:\nfor await (const offering of wf.offerings.all({ sort: \"newest\" })) {\n console.log(offering.id);\n}",
30
49
  "listPortfolioPositions": "for await (const position of wf.portfolio.positions.all({ status: \"active\" })) {\n console.log(\n position.id,\n position.attributes?.company?.name,\n position.attributes?.current_value_cents,\n );\n}",
31
50
  "listSyndicatePortfolioPositions": "const page = await wf.unwrap(\n wf.raw.listSyndicatePortfolioPositions({\n path: { syndicate_id: \"syn_example\" },\n query: { status: \"active\", per_page: 25 },\n }),\n);\nfor (const position of page.data ?? []) {\n console.log(position.id, position.attributes?.investor_count);\n}",
32
51
  "listSyndicates": "const page = await wf.syndicates.list({ limit: 50 });\nfor (const syndicate of page.data ?? []) {\n console.log(syndicate.id, syndicate.attributes?.name, syndicate.attributes?.member_count);\n}",
52
+ "listWebhookEndpoints": "const { data: endpoints, meta } = await wf.webhookEndpoints.list();\nconsole.log(`${endpoints?.length} of ${meta?.quota} endpoint slots used`);\nfor (const ep of endpoints ?? []) {\n console.log(ep.id, ep.attributes?.url, ep.attributes?.enabled, ep.attributes?.last_delivery_status);\n}",
33
53
  "listWebhookSubscriptions": "const subscriptions = await wf.unwrap(\n wf.raw.listWebhookSubscriptions({ path: { campaign_id: 1234 } }),\n);\nfor (const sub of subscriptions.data ?? []) {\n console.log(sub.id, sub.target_url, sub.events, sub.active);\n}",
34
- "testWebhookSubscription": "const result = await wf.unwrap(\n wf.raw.testWebhookSubscription({ path: { campaign_id: 1234, webhook_id: 56 } }),\n);\nconsole.log(result.data);"
54
+ "previewIntent": "const preview = await wf.unwrap(\n wf.raw.previewIntent({\n body: {\n action_name: \"syndicates.close_deal\",\n resource_type: \"Club\",\n resource_id: \"syn_example\",\n params: { fundraise_id: 99 },\n },\n }),\n);\nconsole.log(preview);",
55
+ "reenableWebhookEndpoint": "const endpoint = await wf.webhookEndpoints.reenable(\"whe_8f3ExampleEndpoint00\");\nconsole.log(endpoint.attributes?.enabled); // true",
56
+ "revokeInstallation": "const result = await wf.unwrap(wf.raw.revokeInstallation({ path: { external_id: \"ins_9t2xExample\" } }));\nconsole.log(result);",
57
+ "rotateWebhookEndpointSecret": "const endpoint = await wf.webhookEndpoints.rotateSecret(\"whe_8f3ExampleEndpoint00\");\nconst newSecret = endpoint.attributes?.secret; // shown once\nconsole.log(newSecret);",
58
+ "searchCompanies": "const results = await wf.unwrap(wf.raw.searchCompanies({ query: { q: \"solar\", limit: 5 } }));\nfor (const hit of results.data ?? []) console.log(hit.id, hit.attributes?.name);",
59
+ "testWebhookEndpoint": "const outcome = await wf.webhookEndpoints.test(\"whe_8f3ExampleEndpoint00\", \"investment.executed\");\nif (outcome.delivered) {\n console.log(`endpoint answered ${outcome.response_code} in ${outcome.duration_ms}ms`);\n} else {\n console.log(`no response: ${outcome.error}`); // timeout | blocked_url | tls_error | connection_failed\n}",
60
+ "testWebhookSubscription": "const result = await wf.unwrap(\n wf.raw.testWebhookSubscription({ path: { campaign_id: 1234, webhook_id: 56 } }),\n);\nconsole.log(result.data);",
61
+ "unfollowCompany": "const result = await wf.unwrap(wf.raw.unfollowCompany({ path: { company_id: \"co_abc123Example\" } }));\nconsole.log(result);",
62
+ "updateWebhookEndpoint": "const endpoint = await wf.webhookEndpoints.update(\"whe_8f3ExampleEndpoint00\", {\n events: [\"offering.opened\", \"offering.closed\", \"investment.executed\"],\n});\nconsole.log(endpoint.attributes?.events);"
35
63
  }
36
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wefunder/sdk",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0-beta.9",
4
4
  "description": "Official TypeScript SDK for the Wefunder API (beta)",
5
5
  "license": "MIT",
6
6
  "type": "module",