@myapihq/sdk 2.4.1 → 2.4.2

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/src/payments.ts DELETED
@@ -1,98 +0,0 @@
1
- import { request } from './client';
2
- import { PAYMENTS_BASE as BASE_URL } from './config';
3
- import type { Exposes } from './exposes';
4
-
5
- // Backend: my-payments-api T0 (BYO Stripe) per
6
- // myapi-hq/internal/routes/payments/. T1 (Connect Express) is deferred —
7
- // connect with tier 't1' returns 501. The webhook receiver is public
8
- // (Stripe signs it); it is listed here for parity but has no SDK function.
9
- export const EXPOSES: Exposes = [
10
- 'POST /payments/orgs/{org_id}/connect',
11
- 'GET /payments/orgs/{org_id}/connect',
12
- 'POST /payments/orgs/{org_id}/charges',
13
- 'GET /payments/orgs/{org_id}/charges',
14
- 'GET /payments/orgs/{org_id}/charges/{id}',
15
- 'POST /payments/orgs/{org_id}/charges/{id}/refund',
16
- 'POST /payments/webhook/{org_id}',
17
- ];
18
-
19
- // Connection status — the org's Stripe link. T0 takes no platform fee, so
20
- // `application_fee_bps` is 0.
21
- export interface ConnectStatus {
22
- connected?: boolean;
23
- tier: string;
24
- stripe_account_id: string;
25
- onboarding_status: string;
26
- application_fee_bps?: number;
27
- }
28
-
29
- // Charge billing interval. Absent = a one-off payment.
30
- export type ChargeInterval = 'month' | 'year';
31
-
32
- // A charge — mirrors the backend's `chargeView`.
33
- export interface Charge {
34
- id: string;
35
- amount_cents: number;
36
- currency: string;
37
- every?: ChargeInterval;
38
- description?: string;
39
- customer_email?: string;
40
- status: string;
41
- created_at: string;
42
- succeeded_at?: string;
43
- refunded_at?: string;
44
- }
45
-
46
- // CreateCharge returns a hosted Stripe Checkout URL the agent pastes into
47
- // its frontend — not a completed payment.
48
- export interface CreateChargeResponse {
49
- payment_id: string;
50
- checkout_url: string;
51
- status: string;
52
- }
53
-
54
- export interface CreateChargePayload {
55
- amount_cents: number; // required, > 0
56
- currency?: string; // defaults to 'usd' server-side
57
- email?: string; // pre-fills the Checkout customer
58
- description?: string; // shows on the Checkout line item
59
- every?: ChargeInterval; // present = a subscription
60
- success_url?: string;
61
- cancel_url?: string;
62
- }
63
-
64
- // connect links the org's own Stripe account (T0 — BYO secret key). The
65
- // key is validated live against Stripe and stored encrypted; it never
66
- // touches MyAPI Postgres or a log line. Pass a 't1' tier to see the
67
- // 501 T1_DEFERRED path.
68
- export async function connect(apiKey: string, orgId: string, stripeSecretKey: string, tier: 't0' | 't1' = 't0'): Promise<ConnectStatus> {
69
- return request('POST', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/connect`, apiKey, {
70
- tier,
71
- stripe_secret_key: stripeSecretKey,
72
- });
73
- }
74
-
75
- // getConnect reads the org's connection status. Returns { connected: false } when no Stripe is linked (no longer a 404).
76
- // when the org has not connected Stripe.
77
- export async function getConnect(apiKey: string, orgId: string): Promise<ConnectStatus> {
78
- return request('GET', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/connect`, apiKey);
79
- }
80
-
81
- // createCharge opens a Stripe Checkout Session on the org's connected
82
- // account. `every` makes it a subscription; otherwise a one-off payment.
83
- export async function createCharge(apiKey: string, orgId: string, payload: CreateChargePayload): Promise<CreateChargeResponse> {
84
- return request('POST', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/charges`, apiKey, payload);
85
- }
86
-
87
- export async function listCharges(apiKey: string, orgId: string): Promise<Charge[]> {
88
- return request('GET', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/charges`, apiKey);
89
- }
90
-
91
- export async function getCharge(apiKey: string, orgId: string, chargeId: string): Promise<Charge> {
92
- return request('GET', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/charges/${encodeURIComponent(chargeId)}`, apiKey);
93
- }
94
-
95
- // refundCharge issues a full refund (v1 — partial refunds out of scope).
96
- export async function refundCharge(apiKey: string, orgId: string, chargeId: string): Promise<{ id: string; status: string }> {
97
- return request('POST', `${BASE_URL}/payments/orgs/${encodeURIComponent(orgId)}/charges/${encodeURIComponent(chargeId)}/refund`, apiKey);
98
- }
package/src/people.ts DELETED
@@ -1,84 +0,0 @@
1
- // Scaffolded from schema by scripts/scaffold-sdk.js — DO NOT remove the
2
- // EXPOSES array (the coverage tool verifies it against the live schema).
3
- // Types and function names ARE editable; re-running the scaffolder against
4
- // a service whose config has been changed will diff vs. existing file
5
- // (use --dry-run to inspect).
6
-
7
- import { request } from './client';
8
- import { PEOPLE_BASE as BASE_URL } from './config';
9
- import type { Exposes } from './exposes';
10
-
11
- import type { SearchFilter } from './audience';
12
-
13
- export const EXPOSES: Exposes = [
14
- 'POST /people/orgs/{org_id}/search',
15
- 'GET /people/orgs/{org_id}/{person_id}',
16
- ];
17
-
18
- export interface Location {
19
- city?: string;
20
- region?: string;
21
- country?: string; // ISO 3166-1 alpha-2
22
- }
23
-
24
- // Goldfox-sourced person row. The data model is crawl-derived signals over
25
- // scraped contact pages; rich on quality tiers and behavioral booleans,
26
- // thin on legacy CRM fields (no title / function / industry as response
27
- // columns — many of those moved to filterable inputs only).
28
- export interface Person {
29
- id: string;
30
- full_name: string;
31
- first_name?: string;
32
- last_name?: string;
33
- email?: string;
34
- email_type?: string; // corporate | freemail | role_based | other_corporate
35
- link_confidence?: number; // 0..1 — 1.0 = email-domain match (definitive)
36
- location: Location;
37
- company_id: string;
38
- company: PersonCompany;
39
- }
40
-
41
- // Person.company embeds the same shape returned by /company/search results.
42
- // PersonCompany is an alias for Company — the company sub-object on a person
43
- // row is identical to a standalone company row.
44
- export interface PersonCompany {
45
- id: string;
46
- domain?: string;
47
- name: string;
48
- general_phone?: string;
49
- address?: string;
50
- is_registered_entity: boolean;
51
- confidence: 'high' | 'low' | 'very_low';
52
- country?: string;
53
- country_consistent: boolean;
54
- tld_class?: string; // cctld | generic | vanity | low_trust | other
55
- has_careers_page: boolean;
56
- has_investors_page: boolean;
57
- has_shop_page: boolean;
58
- has_blog: boolean;
59
- has_c_level: boolean;
60
- has_decision_maker: boolean;
61
- headcount_lower_bound: number;
62
- org_breadth: number;
63
- source_count: number;
64
- subdomain_variety: number;
65
- multilingual: boolean;
66
- language_count: number;
67
- location?: Location;
68
- }
69
-
70
- export interface PeopleSearchResult {
71
- people: Person[];
72
- total: number;
73
- limit: number;
74
- offset: number;
75
- has_more: boolean;
76
- }
77
-
78
- export async function searchPeople(apiKey: string, orgId: string, filter: SearchFilter): Promise<PeopleSearchResult> {
79
- return request('POST', `${BASE_URL}/people/orgs/${encodeURIComponent(orgId)}/search`, apiKey, filter);
80
- }
81
-
82
- export async function getPerson(apiKey: string, orgId: string, personId: string): Promise<Person> {
83
- return request('GET', `${BASE_URL}/people/orgs/${encodeURIComponent(orgId)}/${encodeURIComponent(personId)}`, apiKey);
84
- }
package/src/pixel.ts DELETED
@@ -1,80 +0,0 @@
1
- import { request } from './client';
2
- import { PIXEL_BASE as BASE_URL } from './config';
3
- import type { Exposes } from './exposes';
4
-
5
- export const EXPOSES: Exposes = [
6
- 'GET /pixel/orgs/{org_id}/interactions',
7
- 'GET /pixel/orgs/{org_id}/visits',
8
- 'GET /pixel/orgs/{org_id}/events',
9
- 'GET /pixel/orgs/{org_id}/identity/{pixel_id}',
10
- 'GET /pixel/orgs/{org_id}/audience/get_geo_sample',
11
- ];
12
-
13
-
14
-
15
- export interface InteractionsResponse {
16
- interactions: (Visit | PixelEvent)[];
17
- total_visits: number;
18
- total_events: number;
19
- limit: number;
20
- offset: number;
21
- }
22
- export interface Visit { type: 'visit'; pixel_id: string; from_url: string; to_url: string; ts: string }
23
- export interface PixelEvent { type: 'event'; pixel_id: string; event_type: 'sent' | 'open' | 'click' | 'page_visit'; url?: string; campaign_id?: string; ts: string }
24
-
25
- export async function getInteractions(apiKey: string, orgId: string, params: {
26
- website?: string;
27
- domain?: string;
28
- campaign_id?: string;
29
- from?: string;
30
- to?: string;
31
- limit?: number;
32
- offset?: number;
33
- }): Promise<InteractionsResponse> {
34
- const qs = new URLSearchParams();
35
- for (const [key, val] of Object.entries(params)) {
36
- if (val !== undefined && val !== null) {
37
- qs.set(key, String(val));
38
- }
39
- }
40
- const queryString = qs.toString();
41
- const url = `${BASE_URL}/pixel/orgs/${encodeURIComponent(orgId)}/interactions${queryString ? `?${queryString}` : ''}`;
42
- return request('GET', url, apiKey);
43
- }
44
-
45
- export async function getVisits(apiKey: string, orgId: string, params: { website: string; from?: string; to?: string; limit?: number; offset?: number }): Promise<{ visits: Visit[]; total: number; limit: number; offset: number }> {
46
- const qs = new URLSearchParams();
47
- for (const [key, val] of Object.entries(params)) {
48
- if (val !== undefined && val !== null) {
49
- qs.set(key, String(val));
50
- }
51
- }
52
- const queryString = qs.toString();
53
- const url = `${BASE_URL}/pixel/orgs/${encodeURIComponent(orgId)}/visits${queryString ? `?${queryString}` : ''}`;
54
- return request('GET', url, apiKey);
55
- }
56
-
57
- export async function getEvents(apiKey: string, orgId: string, params: { campaign_id?: string; domain?: string; from?: string; to?: string; limit?: number; offset?: number }): Promise<{ events: PixelEvent[]; total: number; limit: number; offset: number }> {
58
- const qs = new URLSearchParams();
59
- for (const [key, val] of Object.entries(params)) {
60
- if (val !== undefined && val !== null) {
61
- qs.set(key, String(val));
62
- }
63
- }
64
- const queryString = qs.toString();
65
- const url = `${BASE_URL}/pixel/orgs/${encodeURIComponent(orgId)}/events${queryString ? `?${queryString}` : ''}`;
66
- return request('GET', url, apiKey);
67
- }
68
-
69
- // getIdentity resolves a pixel's identity graph. `website` is required —
70
- // the backend scopes the lookup to a domain the org owns.
71
- export async function getIdentity(apiKey: string, orgId: string, pixelId: string, website: string): Promise<{ uuid: string; is_resolved: boolean; nodes: Record<string, { type: string; probability: number }>; latency_ms: number }> {
72
- return request('GET', `${BASE_URL}/pixel/orgs/${encodeURIComponent(orgId)}/identity/${encodeURIComponent(pixelId)}?website=${encodeURIComponent(website)}`, apiKey);
73
- }
74
-
75
- // Sample of geographic distribution of the org's pixel audience. Backend
76
- // returns whatever shape it wants; we type as record-of-unknowns and let
77
- // callers print or destructure as needed.
78
- export async function getGeoSample(apiKey: string, orgId: string): Promise<Record<string, unknown>> {
79
- return request('GET', `${BASE_URL}/pixel/orgs/${encodeURIComponent(orgId)}/audience/get_geo_sample`, apiKey);
80
- }
package/src/queue.ts DELETED
@@ -1,115 +0,0 @@
1
- import { request } from './client';
2
- import { QUEUE_BASE as BASE_URL } from './config';
3
- import type { Exposes } from './exposes';
4
-
5
- // Backend: my-queue-api per myapi-hq/internal/routes/queue/. A durable
6
- // HTTP-consumer job queue — each named queue POSTs its jobs to a configured
7
- // consumer_url, with retry/backoff to max_attempts, a concurrency cap, and a
8
- // dependency DAG (a job with unsucceeded depends_on starts blocked).
9
- export const EXPOSES: Exposes = [
10
- 'POST /queue/orgs/{org_id}/queues',
11
- 'GET /queue/orgs/{org_id}/queues',
12
- 'GET /queue/orgs/{org_id}/queues/{name}',
13
- 'DELETE /queue/orgs/{org_id}/queues/{name}',
14
- 'POST /queue/orgs/{org_id}/queues/{name}/jobs',
15
- 'GET /queue/orgs/{org_id}/queues/{name}/jobs',
16
- 'GET /queue/orgs/{org_id}/jobs/{id}',
17
- ];
18
-
19
- export interface Queue {
20
- id: string;
21
- org_id: string;
22
- name: string;
23
- consumer_url: string;
24
- max_attempts: number;
25
- max_concurrency: number;
26
- created_at: string;
27
- }
28
-
29
- // A job that exhausts max_attempts goes straight to `dead` — there is no
30
- // separate `failed` state.
31
- export type JobStatus = 'pending' | 'blocked' | 'running' | 'succeeded' | 'dead';
32
-
33
- export interface Job {
34
- id: string;
35
- queue_id: string;
36
- org_id: string;
37
- payload: unknown;
38
- status: JobStatus;
39
- attempt: number;
40
- max_attempts: number;
41
- not_before: string;
42
- depends_on: string[];
43
- dedup_key?: string;
44
- last_error?: string;
45
- started_at?: string;
46
- created_at: string;
47
- updated_at: string;
48
- }
49
-
50
- export interface CreateQueueOptions {
51
- name: string;
52
- consumerUrl: string;
53
- maxAttempts?: number;
54
- maxConcurrency?: number;
55
- }
56
-
57
- export interface EnqueueOptions {
58
- payload?: unknown;
59
- dedupKey?: string;
60
- delaySeconds?: number;
61
- // Job ids this job waits on. Immutable — the DAG is declared at enqueue.
62
- // Same shape as task.create's depends_on.
63
- dependsOn?: string[];
64
- }
65
-
66
- function queuesBase(orgId: string): string {
67
- return `${BASE_URL}/queue/orgs/${encodeURIComponent(orgId)}/queues`;
68
- }
69
-
70
- // createQueue registers a named queue with its retry + concurrency policy
71
- // and the HTTP consumer that runs its jobs.
72
- export async function createQueue(apiKey: string, orgId: string, opts: CreateQueueOptions): Promise<Queue> {
73
- const body: Record<string, unknown> = { name: opts.name, consumer_url: opts.consumerUrl };
74
- if (opts.maxAttempts !== undefined) body.max_attempts = opts.maxAttempts;
75
- if (opts.maxConcurrency !== undefined) body.max_concurrency = opts.maxConcurrency;
76
- return request('POST', queuesBase(orgId), apiKey, body);
77
- }
78
-
79
- export async function listQueues(apiKey: string, orgId: string): Promise<Queue[]> {
80
- const res = await request<{ queues?: Queue[] }>('GET', queuesBase(orgId), apiKey);
81
- return res?.queues ?? [];
82
- }
83
-
84
- export async function getQueue(apiKey: string, orgId: string, name: string): Promise<Queue> {
85
- return request('GET', `${queuesBase(orgId)}/${encodeURIComponent(name)}`, apiKey);
86
- }
87
-
88
- export async function deleteQueue(apiKey: string, orgId: string, name: string): Promise<void> {
89
- return request('DELETE', `${queuesBase(orgId)}/${encodeURIComponent(name)}`, apiKey);
90
- }
91
-
92
- // enqueueJob is idempotent on (queue, dedup_key). A job with unsucceeded
93
- // depends_on starts blocked.
94
- export async function enqueueJob(apiKey: string, orgId: string, name: string, opts: EnqueueOptions = {}): Promise<Job> {
95
- const body: Record<string, unknown> = {};
96
- if (opts.payload !== undefined) body.payload = opts.payload;
97
- if (opts.dedupKey !== undefined) body.dedup_key = opts.dedupKey;
98
- if (opts.delaySeconds !== undefined) body.delay_seconds = opts.delaySeconds;
99
- if (opts.dependsOn !== undefined) body.depends_on = opts.dependsOn;
100
- return request('POST', `${queuesBase(orgId)}/${encodeURIComponent(name)}/jobs`, apiKey, body);
101
- }
102
-
103
- // listJobs lists a queue's jobs, newest first. `limit` is 1-200.
104
- export async function listJobs(apiKey: string, orgId: string, name: string, opts: { status?: string; limit?: number } = {}): Promise<Job[]> {
105
- const q = new URLSearchParams();
106
- if (opts.status) q.set('status', opts.status);
107
- if (opts.limit !== undefined) q.set('limit', String(opts.limit));
108
- const qs = q.toString();
109
- const res = await request<{ jobs?: Job[] }>('GET', `${queuesBase(orgId)}/${encodeURIComponent(name)}/jobs${qs ? `?${qs}` : ''}`, apiKey);
110
- return res?.jobs ?? [];
111
- }
112
-
113
- export async function getJob(apiKey: string, orgId: string, jobId: string): Promise<Job> {
114
- return request('GET', `${BASE_URL}/queue/orgs/${encodeURIComponent(orgId)}/jobs/${encodeURIComponent(jobId)}`, apiKey);
115
- }