@chatarmin/os 1.8.9 → 1.14.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/README.md +63 -4
- package/dist/billing/client.d.ts.map +1 -1
- package/dist/billing/client.js +1 -0
- package/dist/billing/index.d.ts +2 -1
- package/dist/billing/index.d.ts.map +1 -1
- package/dist/billing/read-types.d.ts +2 -0
- package/dist/billing/read-types.d.ts.map +1 -1
- package/dist/billing/types.d.ts +11 -2
- package/dist/billing/types.d.ts.map +1 -1
- package/dist/billing/usage-breakdown-types.d.ts +50 -0
- package/dist/billing/usage-breakdown-types.d.ts.map +1 -1
- package/dist/companies/client.d.ts.map +1 -1
- package/dist/companies/client.js +4 -0
- package/dist/companies/index.d.ts +1 -1
- package/dist/companies/index.d.ts.map +1 -1
- package/dist/companies/types.d.ts +70 -4
- package/dist/companies/types.d.ts.map +1 -1
- package/dist/deals/client.d.ts +8 -0
- package/dist/deals/client.d.ts.map +1 -0
- package/dist/deals/client.js +6 -0
- package/dist/deals/index.d.ts +3 -0
- package/dist/deals/index.d.ts.map +1 -0
- package/dist/deals/index.js +1 -0
- package/dist/deals/types.d.ts +56 -0
- package/dist/deals/types.d.ts.map +1 -0
- package/dist/deals/types.js +1 -0
- package/dist/features/index.d.ts +1 -1
- package/dist/features/index.d.ts.map +1 -1
- package/dist/features/types.d.ts +17 -0
- package/dist/features/types.d.ts.map +1 -1
- package/dist/index.d.ts +63 -109
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -100
- package/dist/onboard-flow.d.ts +74 -0
- package/dist/onboard-flow.d.ts.map +1 -0
- package/dist/onboard-flow.js +118 -0
- package/dist/onboard-types.d.ts +99 -0
- package/dist/onboard-types.d.ts.map +1 -0
- package/dist/onboard-types.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,16 @@ import type { AppRouter } from "@chatarmin/api/trpc-types";
|
|
|
2
2
|
import { type CompaniesClient } from "./companies/index.js";
|
|
3
3
|
import { type ChannelsClient } from "./channels/index.js";
|
|
4
4
|
import { type BillingClient } from "./billing/index.js";
|
|
5
|
+
import { type DealsClient } from "./deals/index.js";
|
|
5
6
|
import { type FeaturesClient } from "./features/index.js";
|
|
7
|
+
import type { OnboardInput, OnboardResult } from "./onboard-types.js";
|
|
6
8
|
export { webhooks, constructProductWebhookEvent, generateTestWebhookHeaders, OsWebhookSignatureVerificationError, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from "./webhooks/index.js";
|
|
7
9
|
export type { ConstructProductWebhookEventOptions, ProductWebhookEventPayload, ProductWebhookHeaders, VerifiedProductWebhookEvent, } from "./webhooks/index.js";
|
|
8
|
-
export type { CompaniesClient, CompanyAssignee, CompanyAssignees, CreateCompanyInput, CreateCompanyResult, GetCompanyInput, LinkedCompany, ListCompaniesInput, ListCompaniesResult, ListLinkedCompaniesInput, ListLinkedCompaniesResult, ProductCompany, UpdateCompanyResult, } from "./companies/index.js";
|
|
10
|
+
export type { CompaniesClient, CompanyAssignee, CompanyAssignees, CreateCompanyInput, CreateCompanyResult, GetCompanyInput, LinkedCompany, ListCompaniesInput, ListCompaniesResult, ListLinkedCompaniesInput, ListLinkedCompaniesResult, ProductCompany, ApplyFreeOnboardTierInput, ApplyFreeOnboardTierResult, SetupOnboardBillingInput, SetupOnboardBillingResult, UpdateCompanyResult, } from "./companies/index.js";
|
|
9
11
|
export type { ChannelLinkType, ChannelsClient, LinkChannelInput, LinkChannelResult, LinkThreadInput, LinkThreadResult, UpdateChannelLinkInput, UpdateChannelLinkResult, } from "./channels/index.js";
|
|
12
|
+
export type * from "./deals/index.js";
|
|
10
13
|
export type { BillingClient, BillingInvoiceSummary, BillingOverview, BillingProfileSummary, BillingSubscriptionSummary, ClaimCheckoutInput, ClaimCheckoutResult, CreateBillingPortalSessionInput, EnsureFeatureSubscriptionInput, EnsureFeatureSubscriptionResult, GetBillingOverviewInput, GetUsageInput, LinkSubscriptionInput, LinkSubscriptionResult, ListBillingInvoicesOptions, PeriodOffsetRange, RelinkBillingProfileInput, ResolveInvoicePaymentUrlInput, SetUsageInput, SyncCompanyFromStripeInput, SyncCompanyFromStripeResult, UsageAggregate, UsageCycleBucket, UsageCycleSummary, UsagePoint, UsageQueryResult, UsageRecord, UsageSubscriptionItem, UsageResult, } from "./billing/index.js";
|
|
11
|
-
export type { ExternalOrgFeatureAccessItem, FeatureAccessByExternalOrgIdResult, FeatureAccessItem, FeatureBillingDetails, FeatureCheckByExternalOrgIdResult, FeatureCheckInput, FeatureCheckResult, FeatureSetAccessInput, FeatureSetAccessResult, FeaturesClient, ListFeatureAccessInput, } from "./features/index.js";
|
|
14
|
+
export type { ExternalOrgFeatureAccessItem, FeatureAccessByExternalOrgIdResult, FeatureAccessItem, FeatureAccessMode, FeatureBillingDetails, FeatureCheckByExternalOrgIdResult, FeatureCheckInput, FeatureCheckResult, FeatureResolvedAccess, FeatureResolvedAccessSource, FeatureSetAccessInput, FeatureSetAccessResult, FeaturesClient, ListFeatureAccessInput, } from "./features/index.js";
|
|
12
15
|
/**
|
|
13
16
|
* Configuration options for the ChatarminOS SDK client.
|
|
14
17
|
*/
|
|
@@ -101,86 +104,7 @@ export interface BulkContactResult {
|
|
|
101
104
|
isNew: boolean;
|
|
102
105
|
}>;
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
* Input for the unified onboarding flow.
|
|
106
|
-
*/
|
|
107
|
-
export interface OnboardInput {
|
|
108
|
-
/** Your product's unique organization ID for this customer */
|
|
109
|
-
externalOrgId: string;
|
|
110
|
-
/** Display label for the product link (e.g., "Chatarmin CX", "Shopify") */
|
|
111
|
-
label: string;
|
|
112
|
-
/**
|
|
113
|
-
* Company details used when creating a new company via onboard().
|
|
114
|
-
*/
|
|
115
|
-
hints?: {
|
|
116
|
-
/** Company name for new companies */
|
|
117
|
-
companyName?: string;
|
|
118
|
-
/** Domain for new companies */
|
|
119
|
-
domain?: string;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Stripe checkout session ID to claim.
|
|
123
|
-
* Use when user completed Stripe checkout in your product.
|
|
124
|
-
* @example "cs_test_xxxxxxxxxxxxx"
|
|
125
|
-
*/
|
|
126
|
-
checkoutSessionId?: string;
|
|
127
|
-
/**
|
|
128
|
-
* Existing Stripe subscription ID to link.
|
|
129
|
-
* Use when you create subscriptions on your product's Stripe account.
|
|
130
|
-
* @example "sub_xxxxxxxxxxxxx"
|
|
131
|
-
*/
|
|
132
|
-
stripeSubscriptionId?: string;
|
|
133
|
-
/**
|
|
134
|
-
* Stripe customer ID.
|
|
135
|
-
* Will be fetched from subscription if not provided.
|
|
136
|
-
* @example "cus_xxxxxxxxxxxxx"
|
|
137
|
-
*/
|
|
138
|
-
stripeCustomerId?: string;
|
|
139
|
-
/**
|
|
140
|
-
* Tier code to apply features from.
|
|
141
|
-
* Use for free tier signups or to tag linked subscriptions.
|
|
142
|
-
* @example "free" | "pro" | "enterprise"
|
|
143
|
-
*/
|
|
144
|
-
tierCode?: string;
|
|
145
|
-
/** Primary contact email for new companies */
|
|
146
|
-
contactEmail?: string;
|
|
147
|
-
/** Primary contact name for new companies */
|
|
148
|
-
contactName?: string;
|
|
149
|
-
/**
|
|
150
|
-
* Historical created_at timestamp for the company.
|
|
151
|
-
* Only used when creating new companies (not for existing matches).
|
|
152
|
-
* @example "2024-01-15T10:30:00.000Z"
|
|
153
|
-
*/
|
|
154
|
-
createdAt?: string;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Result from the onboarding flow.
|
|
158
|
-
*/
|
|
159
|
-
export interface OnboardResult {
|
|
160
|
-
/** The company ID (either existing or newly created) */
|
|
161
|
-
companyId: string;
|
|
162
|
-
/** The company name */
|
|
163
|
-
companyName: string;
|
|
164
|
-
/**
|
|
165
|
-
* How the company was linked:
|
|
166
|
-
* - `already_linked`: Company was already linked to your product
|
|
167
|
-
* - `created`: New company was created
|
|
168
|
-
*/
|
|
169
|
-
linkStatus: "already_linked" | "created";
|
|
170
|
-
/** Billing status (only present if billing was configured) */
|
|
171
|
-
billingStatus?: {
|
|
172
|
-
/** Subscription ID if created/claimed */
|
|
173
|
-
subscriptionId?: string;
|
|
174
|
-
/** True if subscription was claimed from checkout */
|
|
175
|
-
claimed?: boolean;
|
|
176
|
-
/** True if subscription was linked */
|
|
177
|
-
linked?: boolean;
|
|
178
|
-
/** True if tier features were applied */
|
|
179
|
-
tierApplied?: boolean;
|
|
180
|
-
/** Error message if billing failed (company still linked) */
|
|
181
|
-
error?: string;
|
|
182
|
-
};
|
|
183
|
-
}
|
|
107
|
+
export type { OnboardInput, OnboardResult } from './onboard-types.js';
|
|
184
108
|
/**
|
|
185
109
|
* ChatarminOS SDK Client
|
|
186
110
|
*
|
|
@@ -341,6 +265,7 @@ export declare class ChatarminOS {
|
|
|
341
265
|
name: string | null;
|
|
342
266
|
role: string | null;
|
|
343
267
|
short_id: string | null;
|
|
268
|
+
custom_fields: unknown;
|
|
344
269
|
is_primary: boolean;
|
|
345
270
|
avatar_url: string | null;
|
|
346
271
|
}>;
|
|
@@ -395,9 +320,43 @@ export declare class ChatarminOS {
|
|
|
395
320
|
name: string | null;
|
|
396
321
|
role: string | null;
|
|
397
322
|
short_id: string | null;
|
|
323
|
+
custom_fields: unknown;
|
|
398
324
|
is_primary: boolean;
|
|
399
325
|
avatar_url: string | null;
|
|
400
326
|
}[]>;
|
|
327
|
+
/**
|
|
328
|
+
* Update a contact linked to a company. Identify it by `contactId` or `email`.
|
|
329
|
+
*/
|
|
330
|
+
update: (input: {
|
|
331
|
+
companyId: string;
|
|
332
|
+
contactId?: string;
|
|
333
|
+
email?: string;
|
|
334
|
+
name?: string;
|
|
335
|
+
role?: string;
|
|
336
|
+
isPrimary?: boolean;
|
|
337
|
+
}) => Promise<{
|
|
338
|
+
id: string;
|
|
339
|
+
metadata: unknown;
|
|
340
|
+
created_at: Date;
|
|
341
|
+
updated_at: Date;
|
|
342
|
+
name: string | null;
|
|
343
|
+
role: string | null;
|
|
344
|
+
short_id: string | null;
|
|
345
|
+
custom_fields: unknown;
|
|
346
|
+
is_primary: boolean;
|
|
347
|
+
avatar_url: string | null;
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* Remove a contact from a company. The person is deleted only when no other company uses them.
|
|
351
|
+
*/
|
|
352
|
+
unlink: (input: {
|
|
353
|
+
companyId: string;
|
|
354
|
+
contactId?: string;
|
|
355
|
+
email?: string;
|
|
356
|
+
}) => Promise<{
|
|
357
|
+
unlinked: boolean;
|
|
358
|
+
deleted: boolean;
|
|
359
|
+
}>;
|
|
401
360
|
};
|
|
402
361
|
/**
|
|
403
362
|
* Feature access and entitlement operations.
|
|
@@ -425,6 +384,8 @@ export declare class ChatarminOS {
|
|
|
425
384
|
get features(): FeaturesClient;
|
|
426
385
|
/** Billing, usage tracking, subscriptions, and customer billing surfaces. */
|
|
427
386
|
get billing(): BillingClient;
|
|
387
|
+
/** Deals and commercial churn (`deals.markChurned` is the OS churn SOP). */
|
|
388
|
+
get deals(): DealsClient;
|
|
428
389
|
/**
|
|
429
390
|
* Manual link operations for associating external IDs with companies.
|
|
430
391
|
*
|
|
@@ -484,12 +445,13 @@ export declare class ChatarminOS {
|
|
|
484
445
|
created_at: Date;
|
|
485
446
|
updated_at: Date;
|
|
486
447
|
sync_status: string;
|
|
448
|
+
custom_fields: unknown;
|
|
449
|
+
label: string | null;
|
|
487
450
|
product_id: string;
|
|
488
451
|
external_org_id: string;
|
|
489
452
|
external_user_id: string | null;
|
|
490
453
|
confidence: number | null;
|
|
491
454
|
link_type: string;
|
|
492
|
-
label: string | null;
|
|
493
455
|
external_display_name: string | null;
|
|
494
456
|
billing_profile_id: string | null;
|
|
495
457
|
}>;
|
|
@@ -856,39 +818,33 @@ export declare class ChatarminOS {
|
|
|
856
818
|
}>;
|
|
857
819
|
};
|
|
858
820
|
/**
|
|
859
|
-
*
|
|
860
|
-
*
|
|
861
|
-
* This is the recommended way to onboard new customers. It handles:
|
|
862
|
-
* 1. Smart company matching/creation
|
|
863
|
-
* 2. Product linking
|
|
864
|
-
* 3. Subscription claiming/linking
|
|
865
|
-
* 4. Tier feature application
|
|
821
|
+
* Create or link a company for your product (fast, non-blocking).
|
|
866
822
|
*
|
|
867
|
-
*
|
|
823
|
+
* Handles company matching/creation, product linking, and free-tier billing setup
|
|
824
|
+
* (billing profile, subscription, feature access) when `tierCode: 'free'`.
|
|
825
|
+
* Paid tiers can use `companies.setupOnboardBilling()` after onboard or inline Stripe IDs.
|
|
826
|
+
* Pass `checkoutSessionId` or `stripeSubscriptionId` to claim/link Stripe inline.
|
|
868
827
|
*
|
|
869
|
-
*
|
|
870
|
-
* 2. **Free signup** - Pass `tierCode` only
|
|
871
|
-
* 3. **You create Stripe subscription** - Pass `stripeSubscriptionId` + `tierCode`
|
|
828
|
+
* Billing failures never throw after the company exists; `billingStatus.error` is set instead.
|
|
872
829
|
*
|
|
873
830
|
* @param input - Onboarding parameters
|
|
874
|
-
* @returns Result with company info and billing status
|
|
831
|
+
* @returns Result with company info and optional billing status
|
|
875
832
|
*
|
|
876
|
-
* @example
|
|
833
|
+
* @example CX free signup
|
|
877
834
|
* ```typescript
|
|
878
835
|
* const result = await os.onboard({
|
|
879
836
|
* externalOrgId: 'org_abc123',
|
|
880
|
-
* label: '
|
|
881
|
-
* hints: {
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
* checkoutSessionId: 'cs_test_xxx' // From Stripe callback
|
|
837
|
+
* label: 'Chatarmin CX',
|
|
838
|
+
* hints: { companyName: 'Acme Inc' },
|
|
839
|
+
* contactEmail: 'admin@acme.com',
|
|
840
|
+
* contactName: 'Jane Doe',
|
|
841
|
+
* tierCode: 'free',
|
|
886
842
|
* })
|
|
887
843
|
*
|
|
888
|
-
* // result.billingStatus.
|
|
844
|
+
* // result.billingStatus.tierApplied === true (no Stripe on signup path)
|
|
889
845
|
* ```
|
|
890
846
|
*
|
|
891
|
-
* @example Scenario
|
|
847
|
+
* @example Scenario 1: User completed Stripe checkout
|
|
892
848
|
* ```typescript
|
|
893
849
|
* const result = await os.onboard({
|
|
894
850
|
* externalOrgId: 'org_abc123',
|
|
@@ -897,15 +853,13 @@ export declare class ChatarminOS {
|
|
|
897
853
|
* companyName: 'Acme Inc',
|
|
898
854
|
* domain: 'acme.com'
|
|
899
855
|
* },
|
|
900
|
-
*
|
|
901
|
-
* contactEmail: 'admin@acme.com',
|
|
902
|
-
* contactName: 'John Doe'
|
|
856
|
+
* checkoutSessionId: 'cs_test_xxx' // From Stripe callback
|
|
903
857
|
* })
|
|
904
858
|
*
|
|
905
|
-
* // result.billingStatus.
|
|
859
|
+
* // result.billingStatus.claimed = true
|
|
906
860
|
* ```
|
|
907
861
|
*
|
|
908
|
-
* @example Scenario
|
|
862
|
+
* @example Scenario 2: You create Stripe subscription
|
|
909
863
|
* ```typescript
|
|
910
864
|
* // First, get tier prices
|
|
911
865
|
* const tier = await os.tiers.get('pro')
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAG1D,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAG/E,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,EACnC,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,mCAAmC,EACnC,0BAA0B,EAC1B,qBAAq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;;;;;;;;;;;;;;;;;QAKtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8BG;0BACe,MAAM,WAAW,cAAc;;;;;MASpD;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiFG;IACG,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CAS3D;AAGD,YAAY,EAAE,SAAS,EAAE,CAAA;AAGzB,eAAe,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import superjson from "superjson";
|
|
|
3
3
|
import { createCompaniesClient, } from "./companies/index.js";
|
|
4
4
|
import { createChannelsClient, } from "./channels/index.js";
|
|
5
5
|
import { createBillingClient } from "./billing/index.js";
|
|
6
|
+
import { createDealsClient } from "./deals/index.js";
|
|
6
7
|
import { createFeaturesClient } from "./features/index.js";
|
|
7
8
|
import { webhooks } from "./webhooks/index.js";
|
|
9
|
+
import { runOnboardFlow } from "./onboard-flow.js";
|
|
8
10
|
export { webhooks, constructProductWebhookEvent, generateTestWebhookHeaders, OsWebhookSignatureVerificationError, WEBHOOK_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, } from "./webhooks/index.js";
|
|
9
11
|
const INSPECT_SYMBOL = Symbol.for("nodejs.util.inspect.custom");
|
|
10
12
|
export class ChatarminOSError extends Error {
|
|
@@ -302,6 +304,14 @@ export class ChatarminOS {
|
|
|
302
304
|
* ```
|
|
303
305
|
*/
|
|
304
306
|
list: (companyId, primaryOnly = false) => call("contacts.list", () => client.contacts.listForCompany.query({ companyId, primaryOnly })),
|
|
307
|
+
/**
|
|
308
|
+
* Update a contact linked to a company. Identify it by `contactId` or `email`.
|
|
309
|
+
*/
|
|
310
|
+
update: (input) => call("contacts.update", () => client.contacts.updateForCompany.mutate(input)),
|
|
311
|
+
/**
|
|
312
|
+
* Remove a contact from a company. The person is deleted only when no other company uses them.
|
|
313
|
+
*/
|
|
314
|
+
unlink: (input) => call("contacts.unlink", () => client.contacts.unlinkFromCompany.mutate(input)),
|
|
305
315
|
};
|
|
306
316
|
}
|
|
307
317
|
// ==========================================================================
|
|
@@ -340,6 +350,10 @@ export class ChatarminOS {
|
|
|
340
350
|
get billing() {
|
|
341
351
|
return createBillingClient(this.client, this.call.bind(this));
|
|
342
352
|
}
|
|
353
|
+
/** Deals and commercial churn (`deals.markChurned` is the OS churn SOP). */
|
|
354
|
+
get deals() {
|
|
355
|
+
return createDealsClient(this.client, this.call.bind(this));
|
|
356
|
+
}
|
|
343
357
|
// ==========================================================================
|
|
344
358
|
// Links
|
|
345
359
|
// ==========================================================================
|
|
@@ -663,39 +677,33 @@ export class ChatarminOS {
|
|
|
663
677
|
// Onboarding
|
|
664
678
|
// ==========================================================================
|
|
665
679
|
/**
|
|
666
|
-
*
|
|
680
|
+
* Create or link a company for your product (fast, non-blocking).
|
|
667
681
|
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
* 4. Tier feature application
|
|
682
|
+
* Handles company matching/creation, product linking, and free-tier billing setup
|
|
683
|
+
* (billing profile, subscription, feature access) when `tierCode: 'free'`.
|
|
684
|
+
* Paid tiers can use `companies.setupOnboardBilling()` after onboard or inline Stripe IDs.
|
|
685
|
+
* Pass `checkoutSessionId` or `stripeSubscriptionId` to claim/link Stripe inline.
|
|
673
686
|
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
* 1. **Stripe Checkout completed** - Pass `checkoutSessionId`
|
|
677
|
-
* 2. **Free signup** - Pass `tierCode` only
|
|
678
|
-
* 3. **You create Stripe subscription** - Pass `stripeSubscriptionId` + `tierCode`
|
|
687
|
+
* Billing failures never throw after the company exists; `billingStatus.error` is set instead.
|
|
679
688
|
*
|
|
680
689
|
* @param input - Onboarding parameters
|
|
681
|
-
* @returns Result with company info and billing status
|
|
690
|
+
* @returns Result with company info and optional billing status
|
|
682
691
|
*
|
|
683
|
-
* @example
|
|
692
|
+
* @example CX free signup
|
|
684
693
|
* ```typescript
|
|
685
694
|
* const result = await os.onboard({
|
|
686
695
|
* externalOrgId: 'org_abc123',
|
|
687
|
-
* label: '
|
|
688
|
-
* hints: {
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
* checkoutSessionId: 'cs_test_xxx' // From Stripe callback
|
|
696
|
+
* label: 'Chatarmin CX',
|
|
697
|
+
* hints: { companyName: 'Acme Inc' },
|
|
698
|
+
* contactEmail: 'admin@acme.com',
|
|
699
|
+
* contactName: 'Jane Doe',
|
|
700
|
+
* tierCode: 'free',
|
|
693
701
|
* })
|
|
694
702
|
*
|
|
695
|
-
* // result.billingStatus.
|
|
703
|
+
* // result.billingStatus.tierApplied === true (no Stripe on signup path)
|
|
696
704
|
* ```
|
|
697
705
|
*
|
|
698
|
-
* @example Scenario
|
|
706
|
+
* @example Scenario 1: User completed Stripe checkout
|
|
699
707
|
* ```typescript
|
|
700
708
|
* const result = await os.onboard({
|
|
701
709
|
* externalOrgId: 'org_abc123',
|
|
@@ -704,15 +712,13 @@ export class ChatarminOS {
|
|
|
704
712
|
* companyName: 'Acme Inc',
|
|
705
713
|
* domain: 'acme.com'
|
|
706
714
|
* },
|
|
707
|
-
*
|
|
708
|
-
* contactEmail: 'admin@acme.com',
|
|
709
|
-
* contactName: 'John Doe'
|
|
715
|
+
* checkoutSessionId: 'cs_test_xxx' // From Stripe callback
|
|
710
716
|
* })
|
|
711
717
|
*
|
|
712
|
-
* // result.billingStatus.
|
|
718
|
+
* // result.billingStatus.claimed = true
|
|
713
719
|
* ```
|
|
714
720
|
*
|
|
715
|
-
* @example Scenario
|
|
721
|
+
* @example Scenario 2: You create Stripe subscription
|
|
716
722
|
* ```typescript
|
|
717
723
|
* // First, get tier prices
|
|
718
724
|
* const tier = await os.tiers.get('pro')
|
|
@@ -753,81 +759,13 @@ export class ChatarminOS {
|
|
|
753
759
|
* ```
|
|
754
760
|
*/
|
|
755
761
|
async onboard(input) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
762
|
+
return runOnboardFlow({
|
|
763
|
+
client: this.client,
|
|
764
|
+
billing: this.billing,
|
|
765
|
+
call: this.call.bind(this),
|
|
766
|
+
companies: this.companies,
|
|
767
|
+
input,
|
|
761
768
|
});
|
|
762
|
-
if (existing) {
|
|
763
|
-
companyId = existing.id;
|
|
764
|
-
companyName = existing.name;
|
|
765
|
-
linkStatus = "already_linked";
|
|
766
|
-
}
|
|
767
|
-
else {
|
|
768
|
-
const newCompany = await this.companies.create({
|
|
769
|
-
name: input.hints?.companyName ?? `Company ${input.externalOrgId}`,
|
|
770
|
-
domain: input.hints?.domain,
|
|
771
|
-
externalOrgId: input.externalOrgId,
|
|
772
|
-
label: input.label,
|
|
773
|
-
contactEmail: input.contactEmail,
|
|
774
|
-
contactName: input.contactName,
|
|
775
|
-
createdAt: input.createdAt,
|
|
776
|
-
});
|
|
777
|
-
companyId = newCompany.id;
|
|
778
|
-
companyName = newCompany.name;
|
|
779
|
-
linkStatus = "created";
|
|
780
|
-
}
|
|
781
|
-
// Step 2: Handle billing (non-fatal - don't block company linking)
|
|
782
|
-
let billingStatus;
|
|
783
|
-
try {
|
|
784
|
-
if (input.checkoutSessionId) {
|
|
785
|
-
// Claim subscription from checkout
|
|
786
|
-
const claimResult = await this.billing.claimCheckout({
|
|
787
|
-
companyId,
|
|
788
|
-
checkoutSessionId: input.checkoutSessionId,
|
|
789
|
-
});
|
|
790
|
-
billingStatus = {
|
|
791
|
-
subscriptionId: claimResult.subscriptionId,
|
|
792
|
-
claimed: !claimResult.alreadyClaimed,
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
else if (input.stripeSubscriptionId) {
|
|
796
|
-
// Link existing subscription
|
|
797
|
-
const linkResult = await this.billing.linkSubscription({
|
|
798
|
-
companyId,
|
|
799
|
-
stripeSubscriptionId: input.stripeSubscriptionId,
|
|
800
|
-
stripeCustomerId: input.stripeCustomerId,
|
|
801
|
-
tierCode: input.tierCode,
|
|
802
|
-
});
|
|
803
|
-
billingStatus = {
|
|
804
|
-
subscriptionId: linkResult.subscriptionId,
|
|
805
|
-
linked: !linkResult.alreadyLinked,
|
|
806
|
-
tierApplied: linkResult.tierApplied,
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
else if (input.tierCode) {
|
|
810
|
-
// Just apply tier features (no Stripe)
|
|
811
|
-
const applyResult = await this.tiers.apply(input.tierCode, {
|
|
812
|
-
companyId,
|
|
813
|
-
});
|
|
814
|
-
billingStatus = {
|
|
815
|
-
tierApplied: applyResult.featuresApplied > 0,
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
catch (err) {
|
|
820
|
-
// Billing failed but company is still linked - capture error
|
|
821
|
-
billingStatus = {
|
|
822
|
-
error: err instanceof Error ? err.message : String(err),
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
return {
|
|
826
|
-
companyId,
|
|
827
|
-
companyName,
|
|
828
|
-
linkStatus,
|
|
829
|
-
billingStatus,
|
|
830
|
-
};
|
|
831
769
|
}
|
|
832
770
|
}
|
|
833
771
|
// Default export
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { createTRPCClient } from '@trpc/client';
|
|
2
|
+
import type { AppRouter } from '@chatarmin/api/trpc-types';
|
|
3
|
+
import type { OnboardInput, OnboardResult } from './onboard-types.js';
|
|
4
|
+
type SdkClient = ReturnType<typeof createTRPCClient<AppRouter>>;
|
|
5
|
+
type BillingClient = {
|
|
6
|
+
claimCheckout: (input: {
|
|
7
|
+
companyId: string;
|
|
8
|
+
checkoutSessionId: string;
|
|
9
|
+
externalOrgId?: string;
|
|
10
|
+
productLinkId?: string;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
subscriptionId: string;
|
|
13
|
+
alreadyClaimed?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
linkSubscription: (input: {
|
|
16
|
+
companyId: string;
|
|
17
|
+
stripeSubscriptionId: string;
|
|
18
|
+
stripeCustomerId?: string;
|
|
19
|
+
tierCode?: string;
|
|
20
|
+
externalOrgId?: string;
|
|
21
|
+
productLinkId?: string;
|
|
22
|
+
}) => Promise<{
|
|
23
|
+
subscriptionId: string;
|
|
24
|
+
alreadyLinked?: boolean;
|
|
25
|
+
tierApplied?: boolean;
|
|
26
|
+
featuresApplied?: number;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
type CompaniesClient = {
|
|
30
|
+
setupOnboardBilling: (input: {
|
|
31
|
+
companyId: string;
|
|
32
|
+
externalOrgId?: string;
|
|
33
|
+
tierCode?: string;
|
|
34
|
+
name: string;
|
|
35
|
+
email?: string;
|
|
36
|
+
currency?: string;
|
|
37
|
+
trialPeriodDays?: number | null;
|
|
38
|
+
}) => Promise<{
|
|
39
|
+
billingProfileId?: string;
|
|
40
|
+
stripeCustomerId?: string;
|
|
41
|
+
subscriptionId?: string;
|
|
42
|
+
tierCode: string;
|
|
43
|
+
featuresApplied: number;
|
|
44
|
+
subscriptionCreated: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
export declare function runOnboardFlow(params: {
|
|
48
|
+
client: SdkClient;
|
|
49
|
+
billing: BillingClient;
|
|
50
|
+
companies: CompaniesClient & {
|
|
51
|
+
get: (input: {
|
|
52
|
+
externalOrgId: string;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
} | null>;
|
|
57
|
+
create: (input: {
|
|
58
|
+
name: string;
|
|
59
|
+
domain?: string;
|
|
60
|
+
externalOrgId: string;
|
|
61
|
+
label: string;
|
|
62
|
+
contactEmail?: string;
|
|
63
|
+
contactName?: string;
|
|
64
|
+
createdAt?: string;
|
|
65
|
+
}) => Promise<{
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
call: <T>(operation: string, action: () => Promise<T>) => Promise<T>;
|
|
71
|
+
input: OnboardInput;
|
|
72
|
+
}): Promise<OnboardResult>;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=onboard-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboard-flow.d.ts","sourceRoot":"","sources":["../src/onboard-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAErE,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAA;AAE/D,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE;QACrB,SAAS,EAAE,MAAM,CAAA;QACjB,iBAAiB,EAAE,MAAM,CAAA;QACzB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,KAAK,OAAO,CAAC;QACZ,cAAc,EAAE,MAAM,CAAA;QACtB,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE;QACxB,SAAS,EAAE,MAAM,CAAA;QACjB,oBAAoB,EAAE,MAAM,CAAA;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,KAAK,OAAO,CAAC;QACZ,cAAc,EAAE,MAAM,CAAA;QACtB,aAAa,CAAC,EAAE,OAAO,CAAA;QACvB,WAAW,CAAC,EAAE,OAAO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