@chatarmin/os 1.5.8 → 1.5.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.
- package/README.md +5 -122
- package/dist/companies/client.d.ts +8 -0
- package/dist/companies/client.d.ts.map +1 -0
- package/dist/companies/client.js +8 -0
- package/dist/companies/index.d.ts +3 -0
- package/dist/companies/index.d.ts.map +1 -0
- package/dist/companies/index.js +1 -0
- package/dist/companies/types.d.ts +66 -0
- package/dist/companies/types.d.ts.map +1 -0
- package/dist/companies/types.js +1 -0
- package/dist/index.d.ts +341 -244
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +191 -133
- package/package.json +2 -4
- package/CHANGELOG.md +0 -21
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,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAMpB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,M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;;;;;;;;;;;;;;;;;;;QAKtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA8BG;0BACe,MAAM,WAAW,cAAc;;;;;MASpD;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyFG;IACG,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CA8E3D;AAGD,YAAY,EAAE,SAAS,EAAE,CAAA;AAGzB,eAAe,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TRPCClientError, createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
2
2
|
import superjson from "superjson";
|
|
3
|
-
import {
|
|
4
|
-
import { bindFeaturesListForProduct } from "./features-list-for-product.js";
|
|
3
|
+
import { createCompaniesClient, } from "./companies";
|
|
5
4
|
const INSPECT_SYMBOL = Symbol.for("nodejs.util.inspect.custom");
|
|
6
5
|
export class ChatarminOSError extends Error {
|
|
7
6
|
details;
|
|
@@ -172,10 +171,13 @@ export class ChatarminOS {
|
|
|
172
171
|
* @example
|
|
173
172
|
* ```typescript
|
|
174
173
|
* // Look up a company by your org ID
|
|
175
|
-
* const company = await os.companies.
|
|
174
|
+
* const company = await os.companies.get({
|
|
176
175
|
* externalOrgId: 'org_abc123'
|
|
177
176
|
* })
|
|
178
177
|
*
|
|
178
|
+
* // Route support mail to the assigned CSM
|
|
179
|
+
* const csmEmail = company?.assignees.csm?.email
|
|
180
|
+
*
|
|
179
181
|
* // Create a new company
|
|
180
182
|
* const newCompany = await os.companies.create({
|
|
181
183
|
* name: 'Acme Inc',
|
|
@@ -186,118 +188,7 @@ export class ChatarminOS {
|
|
|
186
188
|
* ```
|
|
187
189
|
*/
|
|
188
190
|
get companies() {
|
|
189
|
-
|
|
190
|
-
const call = this.call.bind(this);
|
|
191
|
-
return {
|
|
192
|
-
/**
|
|
193
|
-
* List companies linked to your product.
|
|
194
|
-
*
|
|
195
|
-
* Use cursor pagination to iterate through all linked companies.
|
|
196
|
-
*/
|
|
197
|
-
listLinked: (input) => call("companies.listLinked", () => client.companies.listLinked.query(input ?? {})),
|
|
198
|
-
/**
|
|
199
|
-
* Look up a company by their external organization ID in your product.
|
|
200
|
-
*
|
|
201
|
-
* Use this to resolve your product's org ID to a ChatarminOS company.
|
|
202
|
-
* Returns `null` if no company is linked with this external ID.
|
|
203
|
-
*
|
|
204
|
-
* @param input - The lookup parameters
|
|
205
|
-
* @param input.externalOrgId - Your product's organization ID
|
|
206
|
-
* @returns The company if found, or `null`
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* const company = await os.companies.getByProductLink({
|
|
211
|
-
* externalOrgId: 'org_abc123'
|
|
212
|
-
* })
|
|
213
|
-
*
|
|
214
|
-
* if (company) {
|
|
215
|
-
* console.log(`Found: ${company.name}`)
|
|
216
|
-
* } else {
|
|
217
|
-
* console.log('Company not linked yet')
|
|
218
|
-
* }
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
getByProductLink: (input) => call("companies.getByProductLink", () => client.companies.getByProductLink.query(input)),
|
|
222
|
-
/**
|
|
223
|
-
* Create a new company and link it to your product.
|
|
224
|
-
*
|
|
225
|
-
* This creates a company in ChatarminOS and automatically links it
|
|
226
|
-
* to your product using the provided external organization ID.
|
|
227
|
-
*
|
|
228
|
-
* @param input - Company creation parameters
|
|
229
|
-
* @returns The created company with ID and short ID
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* const company = await os.companies.create({
|
|
234
|
-
* name: 'Acme Inc',
|
|
235
|
-
* domain: 'acme.com',
|
|
236
|
-
* externalOrgId: 'org_abc123',
|
|
237
|
-
* contactEmail: 'admin@acme.com',
|
|
238
|
-
* contactName: 'John Doe'
|
|
239
|
-
* })
|
|
240
|
-
*
|
|
241
|
-
* console.log(company.id) // UUID
|
|
242
|
-
* console.log(company.shortId) // e.g., "acme-inc"
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
create: (input) => call("companies.create", () => client.companies.createWithLink.mutate(input)),
|
|
246
|
-
/**
|
|
247
|
-
* Update company metadata.
|
|
248
|
-
*
|
|
249
|
-
* Used for backfilling data like historical created_at dates.
|
|
250
|
-
*
|
|
251
|
-
* @param input - Update parameters
|
|
252
|
-
* @returns Whether the update was applied
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```typescript
|
|
256
|
-
* await os.companies.update({
|
|
257
|
-
* companyId: 'uuid-here',
|
|
258
|
-
* createdAt: '2023-01-15T10:30:00.000Z'
|
|
259
|
-
* })
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
update: (input) => call("companies.update", () => client.companies.updateCompany.mutate(input)),
|
|
263
|
-
/**
|
|
264
|
-
* Smart link - intelligently find and link a company using hints.
|
|
265
|
-
*
|
|
266
|
-
* This method attempts to find an existing company in ChatarminOS
|
|
267
|
-
* that matches the provided hints (domain, name, emails). If found
|
|
268
|
-
* with sufficient confidence, it automatically creates a link.
|
|
269
|
-
*
|
|
270
|
-
* **Matching priority:**
|
|
271
|
-
* 1. Domain match (95% confidence)
|
|
272
|
-
* 2. Name match (up to 80% confidence)
|
|
273
|
-
* 3. Email domain match (70% confidence)
|
|
274
|
-
*
|
|
275
|
-
* @param input - Smart link parameters
|
|
276
|
-
* @returns Result with status and company info if linked
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
* ```typescript
|
|
280
|
-
* const result = await os.companies.smartLink({
|
|
281
|
-
* externalOrgId: 'org_abc123',
|
|
282
|
-
* hints: {
|
|
283
|
-
* companyName: 'Acme Inc',
|
|
284
|
-
* domain: 'acme.com',
|
|
285
|
-
* emails: ['john@acme.com']
|
|
286
|
-
* },
|
|
287
|
-
* minConfidence: 0.7
|
|
288
|
-
* })
|
|
289
|
-
*
|
|
290
|
-
* if (result.status === 'linked') {
|
|
291
|
-
* console.log(`Linked to ${result.customerName}`)
|
|
292
|
-
* } else if (result.status === 'suggestions') {
|
|
293
|
-
* console.log('Possible matches:', result.suggestions)
|
|
294
|
-
* }
|
|
295
|
-
* ```
|
|
296
|
-
*
|
|
297
|
-
* @experimental This API may change in future versions
|
|
298
|
-
*/
|
|
299
|
-
smartLink: (input) => call("companies.smartLink", () => client.companies.smartLink.mutate(input)),
|
|
300
|
-
};
|
|
191
|
+
return createCompaniesClient(this.client, this.call.bind(this));
|
|
301
192
|
}
|
|
302
193
|
// ==========================================================================
|
|
303
194
|
// Contacts
|
|
@@ -407,7 +298,29 @@ export class ChatarminOS {
|
|
|
407
298
|
// ==========================================================================
|
|
408
299
|
// Features
|
|
409
300
|
// ==========================================================================
|
|
410
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Feature access and entitlement operations.
|
|
303
|
+
*
|
|
304
|
+
* Check what features a company has access to and their current usage.
|
|
305
|
+
* Features are defined in ChatarminOS and assigned via subscription tiers.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* // Check if company can use a feature
|
|
310
|
+
* const access = await os.features.check({
|
|
311
|
+
* companyId: company.id,
|
|
312
|
+
* featureCode: 'ai_credit'
|
|
313
|
+
* })
|
|
314
|
+
*
|
|
315
|
+
* if (access.canUse) {
|
|
316
|
+
* // Feature is available
|
|
317
|
+
* console.log(`Remaining: ${access.remaining}`)
|
|
318
|
+
* } else {
|
|
319
|
+
* // Feature is disabled or limit reached
|
|
320
|
+
* console.log('Upgrade required')
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
411
324
|
get features() {
|
|
412
325
|
const client = this.client;
|
|
413
326
|
const call = this.call.bind(this);
|
|
@@ -487,7 +400,6 @@ export class ChatarminOS {
|
|
|
487
400
|
const params = typeof input === "string" ? { companyId: input } : input;
|
|
488
401
|
return client.features.getAccess.query(params);
|
|
489
402
|
}),
|
|
490
|
-
listForProduct: bindFeaturesListForProduct(call, client),
|
|
491
403
|
/**
|
|
492
404
|
* Update feature access for a company with partial config merge.
|
|
493
405
|
*
|
|
@@ -618,7 +530,164 @@ export class ChatarminOS {
|
|
|
618
530
|
* ```
|
|
619
531
|
*/
|
|
620
532
|
get billing() {
|
|
621
|
-
|
|
533
|
+
const client = this.client;
|
|
534
|
+
const call = this.call.bind(this);
|
|
535
|
+
return {
|
|
536
|
+
/**
|
|
537
|
+
* Set usage to an absolute value.
|
|
538
|
+
*
|
|
539
|
+
* Use this for corrections when you know what the total usage SHOULD be.
|
|
540
|
+
* Creates a snapshot for audit trail. The delta (difference) is calculated
|
|
541
|
+
* automatically and synced to Stripe.
|
|
542
|
+
*
|
|
543
|
+
* @param input - Set usage parameters
|
|
544
|
+
* @returns Result with previous and new usage values
|
|
545
|
+
*
|
|
546
|
+
* @example Correct usage to 100 (was 150)
|
|
547
|
+
* ```typescript
|
|
548
|
+
* const result = await os.billing.setUsage({
|
|
549
|
+
* companyId: 'comp_xxx',
|
|
550
|
+
* featureCode: 'ai_credit',
|
|
551
|
+
* absoluteValue: 100,
|
|
552
|
+
* reason: 'Corrected after customer support review',
|
|
553
|
+
* performedBy: 'admin@company.com'
|
|
554
|
+
* })
|
|
555
|
+
*
|
|
556
|
+
* console.log({
|
|
557
|
+
* previousUsage: result.previousUsage, // 150
|
|
558
|
+
* currentUsage: result.currentUsage, // 100
|
|
559
|
+
* delta: result.delta // -50
|
|
560
|
+
* })
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
setUsage: (input) => call("billing.setUsage", () => client.billing.setUsage.mutate({
|
|
564
|
+
...input,
|
|
565
|
+
source: "api",
|
|
566
|
+
})),
|
|
567
|
+
/**
|
|
568
|
+
* Get usage event history for a feature.
|
|
569
|
+
*
|
|
570
|
+
* Returns the history of usage events including increments, sets,
|
|
571
|
+
* and adjustments. Useful for auditing and debugging.
|
|
572
|
+
*
|
|
573
|
+
* @param companyId - Company ID
|
|
574
|
+
* @param featureCode - Feature code to get history for
|
|
575
|
+
* @param options - Query options
|
|
576
|
+
* @returns Array of usage events
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* const history = await os.billing.getUsageHistory(
|
|
581
|
+
* 'comp_xxx',
|
|
582
|
+
* 'ai_credit',
|
|
583
|
+
* { limit: 20, eventType: 'adjustment' }
|
|
584
|
+
* )
|
|
585
|
+
*
|
|
586
|
+
* for (const event of history) {
|
|
587
|
+
* console.log(`${event.event_type}: ${event.quantity} at ${event.event_time}`)
|
|
588
|
+
* if (event.adjustment_reason) {
|
|
589
|
+
* console.log(` Reason: ${event.adjustment_reason}`)
|
|
590
|
+
* }
|
|
591
|
+
* }
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
getUsageHistory: (companyId, featureCode, options) => call("billing.getUsageHistory", () => client.billing.getUsageHistory.query({
|
|
595
|
+
companyId,
|
|
596
|
+
featureCode,
|
|
597
|
+
...options,
|
|
598
|
+
})),
|
|
599
|
+
/**
|
|
600
|
+
* Claim a subscription from a completed Stripe Checkout Session.
|
|
601
|
+
*
|
|
602
|
+
* Use this after a user completes Stripe checkout in your product.
|
|
603
|
+
* This links the subscription and customer to the company in OS.
|
|
604
|
+
*
|
|
605
|
+
* @param input - Claim parameters
|
|
606
|
+
* @returns Result with subscription ID and claim status
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* // In your Stripe checkout success handler:
|
|
611
|
+
* const result = await os.billing.claimCheckout({
|
|
612
|
+
* companyId: company.id,
|
|
613
|
+
* checkoutSessionId: session.id // From Stripe callback
|
|
614
|
+
* })
|
|
615
|
+
*
|
|
616
|
+
* if (result.alreadyClaimed) {
|
|
617
|
+
* console.log('Subscription was already claimed')
|
|
618
|
+
* } else {
|
|
619
|
+
* console.log(`Claimed subscription: ${result.subscriptionId}`)
|
|
620
|
+
* }
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
623
|
+
claimCheckout: (input) => call("billing.claimCheckout", () => client.billing.claimCheckout.mutate(input)),
|
|
624
|
+
/**
|
|
625
|
+
* Link an existing Stripe subscription to a company.
|
|
626
|
+
*
|
|
627
|
+
* Use this when you create subscriptions on your product's Stripe
|
|
628
|
+
* account and want OS to track them. Optionally applies tier features.
|
|
629
|
+
*
|
|
630
|
+
* @param input - Link parameters
|
|
631
|
+
* @returns Result with subscription ID, link status, and features applied
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* // After creating subscription on your Stripe account:
|
|
636
|
+
* const result = await os.billing.linkSubscription({
|
|
637
|
+
* companyId: company.id,
|
|
638
|
+
* stripeSubscriptionId: 'sub_xxx',
|
|
639
|
+
* stripeCustomerId: 'cus_xxx', // Optional
|
|
640
|
+
* tierCode: 'pro', // Apply tier features
|
|
641
|
+
* displayName: 'Pro Plan'
|
|
642
|
+
* })
|
|
643
|
+
*
|
|
644
|
+
* console.log({
|
|
645
|
+
* subscriptionId: result.subscriptionId,
|
|
646
|
+
* isNew: !result.alreadyLinked,
|
|
647
|
+
* featuresApplied: result.featuresApplied
|
|
648
|
+
* })
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
linkSubscription: (input) => call("billing.linkSubscription", () => client.billing.linkSubscription.mutate(input)),
|
|
652
|
+
/**
|
|
653
|
+
* Get billing status for a company.
|
|
654
|
+
*
|
|
655
|
+
* Quick check for subscription status, active features, and
|
|
656
|
+
* billing profile information.
|
|
657
|
+
*
|
|
658
|
+
* @param companyId - Company ID to check
|
|
659
|
+
* @returns Billing status overview
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* const status = await os.billing.getStatus(company.id)
|
|
664
|
+
*
|
|
665
|
+
* console.log({
|
|
666
|
+
* hasBilling: status.hasBillingProfile,
|
|
667
|
+
* subscriptions: status.activeSubscriptions.length,
|
|
668
|
+
* features: status.enabledFeaturesCount
|
|
669
|
+
* })
|
|
670
|
+
*
|
|
671
|
+
* // Check active tier
|
|
672
|
+
* if (status.activeSubscriptions[0]?.tier) {
|
|
673
|
+
* console.log(`Current tier: ${status.activeSubscriptions[0].tier.name}`)
|
|
674
|
+
* }
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
getStatus: (companyId) => call("billing.getStatus", () => client.billing.getStatus.query({ companyId })),
|
|
678
|
+
/**
|
|
679
|
+
* Sync billing profile, subscriptions, and feature access from Stripe.
|
|
680
|
+
*/
|
|
681
|
+
syncCompanyFromStripe: (input) => call("billing.syncCompanyFromStripe", () => client.billing.syncCompanyFromStripe.mutate(input)),
|
|
682
|
+
/**
|
|
683
|
+
* Relink billing profile to a new Stripe customer (destructive).
|
|
684
|
+
*/
|
|
685
|
+
relinkBillingProfile: (input) => call("billing.relinkBillingProfile", () => client.billing.relinkBillingProfile.mutate(input)),
|
|
686
|
+
/**
|
|
687
|
+
* Ensure a feature is linked to an active Stripe subscription item.
|
|
688
|
+
*/
|
|
689
|
+
ensureFeatureSubscription: (input) => call("billing.ensureFeatureSubscription", () => client.billing.ensureFeatureSubscription.mutate(input)),
|
|
690
|
+
};
|
|
622
691
|
}
|
|
623
692
|
// ==========================================================================
|
|
624
693
|
// Links
|
|
@@ -1027,35 +1096,24 @@ export class ChatarminOS {
|
|
|
1027
1096
|
*
|
|
1028
1097
|
* if (result.linkStatus === 'already_linked') {
|
|
1029
1098
|
* console.log('Welcome back!')
|
|
1030
|
-
* } else if (result.linkStatus === 'linked') {
|
|
1031
|
-
* console.log('Found existing company, linked!')
|
|
1032
1099
|
* } else {
|
|
1033
1100
|
* console.log('New company created!')
|
|
1034
1101
|
* }
|
|
1035
1102
|
* ```
|
|
1036
1103
|
*/
|
|
1037
1104
|
async onboard(input) {
|
|
1038
|
-
// Step 1: Smart link or create company
|
|
1039
1105
|
let companyId;
|
|
1040
1106
|
let companyName;
|
|
1041
1107
|
let linkStatus;
|
|
1042
|
-
const
|
|
1108
|
+
const existing = await this.companies.get({
|
|
1043
1109
|
externalOrgId: input.externalOrgId,
|
|
1044
|
-
label: input.label,
|
|
1045
|
-
hints: input.hints ?? {},
|
|
1046
1110
|
});
|
|
1047
|
-
if (
|
|
1048
|
-
companyId =
|
|
1049
|
-
companyName =
|
|
1111
|
+
if (existing) {
|
|
1112
|
+
companyId = existing.id;
|
|
1113
|
+
companyName = existing.name;
|
|
1050
1114
|
linkStatus = "already_linked";
|
|
1051
1115
|
}
|
|
1052
|
-
else if (smartLinkResult.status === "linked") {
|
|
1053
|
-
companyId = smartLinkResult.customerId;
|
|
1054
|
-
companyName = smartLinkResult.customerName;
|
|
1055
|
-
linkStatus = "linked";
|
|
1056
|
-
}
|
|
1057
1116
|
else {
|
|
1058
|
-
// No match found - create new company
|
|
1059
1117
|
const newCompany = await this.companies.create({
|
|
1060
1118
|
name: input.hints?.companyName ?? `Company ${input.externalOrgId}`,
|
|
1061
1119
|
domain: input.hints?.domain,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatarmin/os",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"description": "Type-safe SDK for ChatarminOS - Customer & Subscription Management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
-
"README.md"
|
|
21
|
-
"CHANGELOG.md"
|
|
20
|
+
"README.md"
|
|
22
21
|
],
|
|
23
22
|
"scripts": {
|
|
24
23
|
"build": "tsc --skipLibCheck",
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
"directory": "packages/sdk"
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
51
|
-
"@chatarmin/contracts": "workspace:^0.1.5",
|
|
52
50
|
"@trpc/client": "^11.0.0-rc.718",
|
|
53
51
|
"superjson": "^2.2.2"
|
|
54
52
|
},
|
package/CHANGELOG.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `@chatarmin/os` are documented here. The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
-
|
|
5
|
-
## Unreleased
|
|
6
|
-
|
|
7
|
-
### Changed
|
|
8
|
-
|
|
9
|
-
- **Expanded feature `billing` object** (`features.listAccess` / `getAccess` with `includeBillingDetails`, and `billing.getDashboardContext`): `stripeSubscriptionItemId` is only on the parent row, not repeated under `billing`. Use `row.stripeSubscriptionItemId` together with `row.billing` for period and price fields.
|
|
10
|
-
- **Types**: `FeatureBillingDetails` is an alias of `BillingDashboardFeatureBilling` (Stripe period/price/status on the nested `billing` object; line item id stays on the row). `FeatureAccessListItem` is the portable row type for `features.listAccess` (avoids TS2742 in emitted `.d.ts` from tRPC inference into internal API paths).
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
|
|
14
|
-
- **`billing.getDashboardContext({ externalOrgId })`** — Single-call billing/usage context for a tenant: `companyId`, `productLinkId`, ordered feature rows with `remaining`, `canUse`, optional Stripe `billing`, and `billingDegraded` when subscription item linkage is missing. See SDK README “Dashboard context migration”.
|
|
15
|
-
- **`features.listForProduct(input?)`** — Feature definition catalog for the API key’s product (no `companyId`). Documented in SDK README.
|
|
16
|
-
|
|
17
|
-
### Migration
|
|
18
|
-
|
|
19
|
-
- For dashboards, prefer `billing.getDashboardContext` + `features.listForProduct` instead of chaining `companies.getByProductLink` + `features.listAccess` and hardcoding `featureCode` lists. Older methods remain available.
|
|
20
|
-
|
|
21
|
-
Product PRD (repo): `docs/prds/2026-03-23-product-sdk-dashboard-context.md`.
|