@stackbe/sdk 0.6.3 → 0.6.5

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/dist/index.d.ts CHANGED
@@ -251,6 +251,94 @@ interface SessionResponse {
251
251
  /** Feature entitlements */
252
252
  entitlements?: Record<string, boolean | number | string>;
253
253
  }
254
+ interface OrganizationMember {
255
+ id: string;
256
+ customerId: string;
257
+ email: string;
258
+ role: 'owner' | 'admin' | 'member';
259
+ invitedAt: string;
260
+ acceptedAt?: string;
261
+ }
262
+ interface Organization {
263
+ id: string;
264
+ appId: string;
265
+ name: string;
266
+ slug: string;
267
+ logoUrl?: string;
268
+ members: OrganizationMember[];
269
+ memberCount: number;
270
+ createdAt: string;
271
+ updatedAt: string;
272
+ }
273
+ interface CreateOrganizationOptions {
274
+ /** Organization name */
275
+ name: string;
276
+ /** Customer ID to set as owner */
277
+ ownerId: string;
278
+ /** Optional logo URL */
279
+ logoUrl?: string;
280
+ }
281
+ interface UpdateOrganizationOptions {
282
+ /** New organization name */
283
+ name?: string;
284
+ /** New logo URL */
285
+ logoUrl?: string;
286
+ }
287
+ interface AddMemberOptions {
288
+ /** Customer ID to add */
289
+ customerId: string;
290
+ /** Role for the member */
291
+ role?: 'admin' | 'member';
292
+ }
293
+ interface InviteMemberOptions {
294
+ /** Email to invite */
295
+ email: string;
296
+ /** Role for the invited member */
297
+ role?: 'admin' | 'member';
298
+ }
299
+ interface OrganizationInvite {
300
+ id: string;
301
+ organizationId: string;
302
+ email: string;
303
+ role: 'admin' | 'member';
304
+ status: 'pending' | 'accepted' | 'cancelled';
305
+ sentAt: string;
306
+ }
307
+ interface Plan {
308
+ id: string;
309
+ name: string;
310
+ slug: string;
311
+ description?: string;
312
+ priceCents: number;
313
+ currency: string;
314
+ interval: 'month' | 'year';
315
+ trialDays?: number;
316
+ entitlements: Record<string, boolean | number | string>;
317
+ status: 'active' | 'archived';
318
+ requirePaymentMethod: boolean;
319
+ productId: string;
320
+ product?: Product;
321
+ createdAt: string;
322
+ updatedAt: string;
323
+ }
324
+ interface Product {
325
+ id: string;
326
+ name: string;
327
+ slug: string;
328
+ description?: string;
329
+ appId: string;
330
+ plans?: Plan[];
331
+ createdAt: string;
332
+ updatedAt: string;
333
+ }
334
+ interface ListPlansOptions {
335
+ /** Filter by product ID */
336
+ productId?: string;
337
+ }
338
+ interface ListProductsOptions {
339
+ /** Filter by app ID (defaults to SDK appId) */
340
+ appId?: string;
341
+ }
254
342
  interface CreateCheckoutOptions {
255
343
  /** Customer ID or email */
256
344
  customer: string | {
@@ -1050,6 +1138,243 @@ declare class AuthClient {
1050
1138
  isAuthenticated(sessionToken: string): Promise<boolean>;
1051
1139
  }
1052
1140
 
1141
+ declare class OrganizationsClient {
1142
+ private http;
1143
+ private appId;
1144
+ constructor(http: HttpClient, appId: string);
1145
+ /**
1146
+ * Create a new organization with a customer as owner.
1147
+ * Use this for B2B signup flows where you provision everything server-side.
1148
+ *
1149
+ * @example
1150
+ * ```typescript
1151
+ * const customer = await stackbe.customers.getOrCreate({ email: 'user@company.com' });
1152
+ * const org = await stackbe.organizations.create({
1153
+ * name: 'Acme Corp',
1154
+ * ownerId: customer.id
1155
+ * });
1156
+ * ```
1157
+ */
1158
+ create(options: CreateOrganizationOptions): Promise<Organization>;
1159
+ /**
1160
+ * List all organizations for this app.
1161
+ *
1162
+ * @example
1163
+ * ```typescript
1164
+ * const orgs = await stackbe.organizations.list();
1165
+ * ```
1166
+ */
1167
+ list(options?: {
1168
+ limit?: number;
1169
+ offset?: number;
1170
+ search?: string;
1171
+ }): Promise<Organization[]>;
1172
+ /**
1173
+ * Get an organization by ID.
1174
+ *
1175
+ * @example
1176
+ * ```typescript
1177
+ * const org = await stackbe.organizations.get('org_123');
1178
+ * ```
1179
+ */
1180
+ get(orgId: string): Promise<Organization>;
1181
+ /**
1182
+ * Update an organization.
1183
+ *
1184
+ * @example
1185
+ * ```typescript
1186
+ * const org = await stackbe.organizations.update('org_123', {
1187
+ * name: 'New Name'
1188
+ * });
1189
+ * ```
1190
+ */
1191
+ update(orgId: string, options: UpdateOrganizationOptions): Promise<Organization>;
1192
+ /**
1193
+ * Delete an organization.
1194
+ * Note: Organizations with active subscriptions cannot be deleted.
1195
+ *
1196
+ * @example
1197
+ * ```typescript
1198
+ * await stackbe.organizations.delete('org_123');
1199
+ * ```
1200
+ */
1201
+ delete(orgId: string): Promise<void>;
1202
+ /**
1203
+ * Add a customer as a member of an organization.
1204
+ *
1205
+ * @example
1206
+ * ```typescript
1207
+ * await stackbe.organizations.addMember('org_123', {
1208
+ * customerId: 'cust_456',
1209
+ * role: 'member'
1210
+ * });
1211
+ * ```
1212
+ */
1213
+ addMember(orgId: string, options: AddMemberOptions): Promise<OrganizationMember>;
1214
+ /**
1215
+ * Remove a member from an organization.
1216
+ *
1217
+ * @example
1218
+ * ```typescript
1219
+ * await stackbe.organizations.removeMember('org_123', 'member_456');
1220
+ * ```
1221
+ */
1222
+ removeMember(orgId: string, memberId: string): Promise<void>;
1223
+ /**
1224
+ * Update a member's role.
1225
+ *
1226
+ * @example
1227
+ * ```typescript
1228
+ * await stackbe.organizations.updateMember('org_123', 'member_456', {
1229
+ * role: 'admin'
1230
+ * });
1231
+ * ```
1232
+ */
1233
+ updateMember(orgId: string, memberId: string, options: {
1234
+ role: 'admin' | 'member';
1235
+ }): Promise<OrganizationMember>;
1236
+ /**
1237
+ * Send an invite to join an organization.
1238
+ *
1239
+ * @example
1240
+ * ```typescript
1241
+ * await stackbe.organizations.invite('org_123', {
1242
+ * email: 'newuser@company.com',
1243
+ * role: 'member'
1244
+ * });
1245
+ * ```
1246
+ */
1247
+ invite(orgId: string, options: InviteMemberOptions): Promise<OrganizationInvite>;
1248
+ /**
1249
+ * List pending invites for an organization.
1250
+ *
1251
+ * @example
1252
+ * ```typescript
1253
+ * const invites = await stackbe.organizations.listInvites('org_123');
1254
+ * ```
1255
+ */
1256
+ listInvites(orgId: string): Promise<OrganizationInvite[]>;
1257
+ /**
1258
+ * Cancel a pending invite.
1259
+ *
1260
+ * @example
1261
+ * ```typescript
1262
+ * await stackbe.organizations.cancelInvite('org_123', 'invite_456');
1263
+ * ```
1264
+ */
1265
+ cancelInvite(orgId: string, inviteId: string): Promise<void>;
1266
+ }
1267
+
1268
+ /**
1269
+ * Client for managing plans and products.
1270
+ * Use this to list available pricing plans for display in your pricing page.
1271
+ *
1272
+ * @example
1273
+ * ```typescript
1274
+ * // List all plans
1275
+ * const plans = await stackbe.plans.list();
1276
+ *
1277
+ * // List plans for a specific product
1278
+ * const plans = await stackbe.plans.list({ productId: 'prod_123' });
1279
+ *
1280
+ * // Get a specific plan
1281
+ * const plan = await stackbe.plans.get('plan_123');
1282
+ *
1283
+ * // List products
1284
+ * const products = await stackbe.products.list();
1285
+ * ```
1286
+ */
1287
+ declare class PlansClient {
1288
+ private readonly http;
1289
+ constructor(http: HttpClient);
1290
+ /**
1291
+ * List all plans for the app.
1292
+ *
1293
+ * @example
1294
+ * ```typescript
1295
+ * // List all plans
1296
+ * const plans = await stackbe.plans.list();
1297
+ *
1298
+ * // Filter by product
1299
+ * const plans = await stackbe.plans.list({ productId: 'prod_123' });
1300
+ *
1301
+ * // Display in pricing page
1302
+ * plans.forEach(plan => {
1303
+ * console.log(`${plan.name}: $${plan.priceCents / 100}/${plan.interval}`);
1304
+ * });
1305
+ * ```
1306
+ */
1307
+ list(options?: ListPlansOptions): Promise<Plan[]>;
1308
+ /**
1309
+ * Get a plan by ID.
1310
+ *
1311
+ * @example
1312
+ * ```typescript
1313
+ * const plan = await stackbe.plans.get('plan_123');
1314
+ * console.log(plan.name, plan.priceCents, plan.entitlements);
1315
+ * ```
1316
+ */
1317
+ get(planId: string): Promise<Plan>;
1318
+ /**
1319
+ * Get active plans only (excludes archived plans).
1320
+ *
1321
+ * @example
1322
+ * ```typescript
1323
+ * const activePlans = await stackbe.plans.getActive();
1324
+ * ```
1325
+ */
1326
+ getActive(options?: ListPlansOptions): Promise<Plan[]>;
1327
+ /**
1328
+ * Get plans sorted by price (ascending).
1329
+ *
1330
+ * @example
1331
+ * ```typescript
1332
+ * const plans = await stackbe.plans.listByPrice();
1333
+ * // [Free, Starter, Pro, Enterprise]
1334
+ * ```
1335
+ */
1336
+ listByPrice(options?: ListPlansOptions): Promise<Plan[]>;
1337
+ }
1338
+ /**
1339
+ * Client for managing products.
1340
+ *
1341
+ * @example
1342
+ * ```typescript
1343
+ * // List all products
1344
+ * const products = await stackbe.products.list();
1345
+ *
1346
+ * // Get a specific product
1347
+ * const product = await stackbe.products.get('prod_123');
1348
+ * ```
1349
+ */
1350
+ declare class ProductsClient {
1351
+ private readonly http;
1352
+ private readonly appId;
1353
+ constructor(http: HttpClient, appId: string);
1354
+ /**
1355
+ * List all products for the app.
1356
+ *
1357
+ * @example
1358
+ * ```typescript
1359
+ * const products = await stackbe.products.list();
1360
+ * products.forEach(product => {
1361
+ * console.log(product.name, product.plans?.length, 'plans');
1362
+ * });
1363
+ * ```
1364
+ */
1365
+ list(options?: ListProductsOptions): Promise<Product[]>;
1366
+ /**
1367
+ * Get a product by ID.
1368
+ *
1369
+ * @example
1370
+ * ```typescript
1371
+ * const product = await stackbe.products.get('prod_123');
1372
+ * console.log(product.name, product.description);
1373
+ * ```
1374
+ */
1375
+ get(productId: string): Promise<Product>;
1376
+ }
1377
+
1053
1378
  declare class StackBE {
1054
1379
  private http;
1055
1380
  private appId;
@@ -1065,6 +1390,12 @@ declare class StackBE {
1065
1390
  readonly subscriptions: SubscriptionsClient;
1066
1391
  /** Customer authentication (magic links) */
1067
1392
  readonly auth: AuthClient;
1393
+ /** Organization management (B2B multi-user) */
1394
+ readonly organizations: OrganizationsClient;
1395
+ /** Pricing plans */
1396
+ readonly plans: PlansClient;
1397
+ /** Products */
1398
+ readonly products: ProductsClient;
1068
1399
  /**
1069
1400
  * Create a new StackBE client.
1070
1401
  *
@@ -1165,4 +1496,4 @@ declare class StackBE {
1165
1496
  }): (req: any, res: any, next: any) => Promise<any>;
1166
1497
  }
1167
1498
 
1168
- export { type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type Customer, type CustomerCreatedEvent, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EntitlementsClient, type EntitlementsResponse, type MagicLinkOptions, type MagicLinkResponse, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
1499
+ export { type AddMemberOptions, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EntitlementsClient, type EntitlementsResponse, type InviteMemberOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
package/dist/index.js CHANGED
@@ -24,6 +24,9 @@ __export(index_exports, {
24
24
  CheckoutClient: () => CheckoutClient,
25
25
  CustomersClient: () => CustomersClient,
26
26
  EntitlementsClient: () => EntitlementsClient,
27
+ OrganizationsClient: () => OrganizationsClient,
28
+ PlansClient: () => PlansClient,
29
+ ProductsClient: () => ProductsClient,
27
30
  StackBE: () => StackBE,
28
31
  StackBEError: () => StackBEError,
29
32
  SubscriptionsClient: () => SubscriptionsClient,
@@ -1156,6 +1159,285 @@ var AuthClient = class {
1156
1159
  }
1157
1160
  };
1158
1161
 
1162
+ // src/organizations.ts
1163
+ var OrganizationsClient = class {
1164
+ constructor(http, appId) {
1165
+ this.http = http;
1166
+ this.appId = appId;
1167
+ }
1168
+ /**
1169
+ * Create a new organization with a customer as owner.
1170
+ * Use this for B2B signup flows where you provision everything server-side.
1171
+ *
1172
+ * @example
1173
+ * ```typescript
1174
+ * const customer = await stackbe.customers.getOrCreate({ email: 'user@company.com' });
1175
+ * const org = await stackbe.organizations.create({
1176
+ * name: 'Acme Corp',
1177
+ * ownerId: customer.id
1178
+ * });
1179
+ * ```
1180
+ */
1181
+ async create(options) {
1182
+ return this.http.post(
1183
+ `/v1/apps/${this.appId}/admin/organizations`,
1184
+ options
1185
+ );
1186
+ }
1187
+ /**
1188
+ * List all organizations for this app.
1189
+ *
1190
+ * @example
1191
+ * ```typescript
1192
+ * const orgs = await stackbe.organizations.list();
1193
+ * ```
1194
+ */
1195
+ async list(options) {
1196
+ const params = new URLSearchParams();
1197
+ if (options?.limit) params.set("limit", String(options.limit));
1198
+ if (options?.offset) params.set("offset", String(options.offset));
1199
+ if (options?.search) params.set("search", options.search);
1200
+ const query = params.toString();
1201
+ const path = `/v1/apps/${this.appId}/admin/organizations${query ? `?${query}` : ""}`;
1202
+ return this.http.get(path);
1203
+ }
1204
+ /**
1205
+ * Get an organization by ID.
1206
+ *
1207
+ * @example
1208
+ * ```typescript
1209
+ * const org = await stackbe.organizations.get('org_123');
1210
+ * ```
1211
+ */
1212
+ async get(orgId) {
1213
+ return this.http.get(
1214
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}`
1215
+ );
1216
+ }
1217
+ /**
1218
+ * Update an organization.
1219
+ *
1220
+ * @example
1221
+ * ```typescript
1222
+ * const org = await stackbe.organizations.update('org_123', {
1223
+ * name: 'New Name'
1224
+ * });
1225
+ * ```
1226
+ */
1227
+ async update(orgId, options) {
1228
+ return this.http.patch(
1229
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}`,
1230
+ options
1231
+ );
1232
+ }
1233
+ /**
1234
+ * Delete an organization.
1235
+ * Note: Organizations with active subscriptions cannot be deleted.
1236
+ *
1237
+ * @example
1238
+ * ```typescript
1239
+ * await stackbe.organizations.delete('org_123');
1240
+ * ```
1241
+ */
1242
+ async delete(orgId) {
1243
+ return this.http.delete(
1244
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}`
1245
+ );
1246
+ }
1247
+ /**
1248
+ * Add a customer as a member of an organization.
1249
+ *
1250
+ * @example
1251
+ * ```typescript
1252
+ * await stackbe.organizations.addMember('org_123', {
1253
+ * customerId: 'cust_456',
1254
+ * role: 'member'
1255
+ * });
1256
+ * ```
1257
+ */
1258
+ async addMember(orgId, options) {
1259
+ return this.http.post(
1260
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members`,
1261
+ options
1262
+ );
1263
+ }
1264
+ /**
1265
+ * Remove a member from an organization.
1266
+ *
1267
+ * @example
1268
+ * ```typescript
1269
+ * await stackbe.organizations.removeMember('org_123', 'member_456');
1270
+ * ```
1271
+ */
1272
+ async removeMember(orgId, memberId) {
1273
+ return this.http.delete(
1274
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/${memberId}`
1275
+ );
1276
+ }
1277
+ /**
1278
+ * Update a member's role.
1279
+ *
1280
+ * @example
1281
+ * ```typescript
1282
+ * await stackbe.organizations.updateMember('org_123', 'member_456', {
1283
+ * role: 'admin'
1284
+ * });
1285
+ * ```
1286
+ */
1287
+ async updateMember(orgId, memberId, options) {
1288
+ return this.http.patch(
1289
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/members/${memberId}`,
1290
+ options
1291
+ );
1292
+ }
1293
+ /**
1294
+ * Send an invite to join an organization.
1295
+ *
1296
+ * @example
1297
+ * ```typescript
1298
+ * await stackbe.organizations.invite('org_123', {
1299
+ * email: 'newuser@company.com',
1300
+ * role: 'member'
1301
+ * });
1302
+ * ```
1303
+ */
1304
+ async invite(orgId, options) {
1305
+ return this.http.post(
1306
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`,
1307
+ options
1308
+ );
1309
+ }
1310
+ /**
1311
+ * List pending invites for an organization.
1312
+ *
1313
+ * @example
1314
+ * ```typescript
1315
+ * const invites = await stackbe.organizations.listInvites('org_123');
1316
+ * ```
1317
+ */
1318
+ async listInvites(orgId) {
1319
+ return this.http.get(
1320
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites`
1321
+ );
1322
+ }
1323
+ /**
1324
+ * Cancel a pending invite.
1325
+ *
1326
+ * @example
1327
+ * ```typescript
1328
+ * await stackbe.organizations.cancelInvite('org_123', 'invite_456');
1329
+ * ```
1330
+ */
1331
+ async cancelInvite(orgId, inviteId) {
1332
+ return this.http.delete(
1333
+ `/v1/apps/${this.appId}/admin/organizations/${orgId}/invites/${inviteId}`
1334
+ );
1335
+ }
1336
+ };
1337
+
1338
+ // src/plans.ts
1339
+ var PlansClient = class {
1340
+ constructor(http) {
1341
+ this.http = http;
1342
+ }
1343
+ /**
1344
+ * List all plans for the app.
1345
+ *
1346
+ * @example
1347
+ * ```typescript
1348
+ * // List all plans
1349
+ * const plans = await stackbe.plans.list();
1350
+ *
1351
+ * // Filter by product
1352
+ * const plans = await stackbe.plans.list({ productId: 'prod_123' });
1353
+ *
1354
+ * // Display in pricing page
1355
+ * plans.forEach(plan => {
1356
+ * console.log(`${plan.name}: $${plan.priceCents / 100}/${plan.interval}`);
1357
+ * });
1358
+ * ```
1359
+ */
1360
+ async list(options) {
1361
+ const params = new URLSearchParams();
1362
+ if (options?.productId) {
1363
+ params.set("productId", options.productId);
1364
+ }
1365
+ const query = params.toString();
1366
+ return this.http.get(`/v1/plans${query ? `?${query}` : ""}`);
1367
+ }
1368
+ /**
1369
+ * Get a plan by ID.
1370
+ *
1371
+ * @example
1372
+ * ```typescript
1373
+ * const plan = await stackbe.plans.get('plan_123');
1374
+ * console.log(plan.name, plan.priceCents, plan.entitlements);
1375
+ * ```
1376
+ */
1377
+ async get(planId) {
1378
+ return this.http.get(`/v1/plans/${planId}`);
1379
+ }
1380
+ /**
1381
+ * Get active plans only (excludes archived plans).
1382
+ *
1383
+ * @example
1384
+ * ```typescript
1385
+ * const activePlans = await stackbe.plans.getActive();
1386
+ * ```
1387
+ */
1388
+ async getActive(options) {
1389
+ const plans = await this.list(options);
1390
+ return plans.filter((p) => p.status === "active");
1391
+ }
1392
+ /**
1393
+ * Get plans sorted by price (ascending).
1394
+ *
1395
+ * @example
1396
+ * ```typescript
1397
+ * const plans = await stackbe.plans.listByPrice();
1398
+ * // [Free, Starter, Pro, Enterprise]
1399
+ * ```
1400
+ */
1401
+ async listByPrice(options) {
1402
+ const plans = await this.getActive(options);
1403
+ return plans.sort((a, b) => a.priceCents - b.priceCents);
1404
+ }
1405
+ };
1406
+ var ProductsClient = class {
1407
+ constructor(http, appId) {
1408
+ this.http = http;
1409
+ this.appId = appId;
1410
+ }
1411
+ /**
1412
+ * List all products for the app.
1413
+ *
1414
+ * @example
1415
+ * ```typescript
1416
+ * const products = await stackbe.products.list();
1417
+ * products.forEach(product => {
1418
+ * console.log(product.name, product.plans?.length, 'plans');
1419
+ * });
1420
+ * ```
1421
+ */
1422
+ async list(options) {
1423
+ const params = new URLSearchParams();
1424
+ params.set("appId", options?.appId ?? this.appId);
1425
+ return this.http.get(`/v1/products?${params.toString()}`);
1426
+ }
1427
+ /**
1428
+ * Get a product by ID.
1429
+ *
1430
+ * @example
1431
+ * ```typescript
1432
+ * const product = await stackbe.products.get('prod_123');
1433
+ * console.log(product.name, product.description);
1434
+ * ```
1435
+ */
1436
+ async get(productId) {
1437
+ return this.http.get(`/v1/products/${productId}`);
1438
+ }
1439
+ };
1440
+
1159
1441
  // src/client.ts
1160
1442
  var DEFAULT_BASE_URL = "https://api.stackbe.io";
1161
1443
  var DEFAULT_TIMEOUT = 3e4;
@@ -1215,6 +1497,9 @@ var StackBE = class {
1215
1497
  sessionCacheTTL: config.sessionCacheTTL,
1216
1498
  devCallbackUrl: config.devCallbackUrl
1217
1499
  });
1500
+ this.organizations = new OrganizationsClient(this.http, config.appId);
1501
+ this.plans = new PlansClient(this.http);
1502
+ this.products = new ProductsClient(this.http, config.appId);
1218
1503
  }
1219
1504
  /**
1220
1505
  * Create a middleware for Express that tracks usage automatically.
@@ -1352,6 +1637,9 @@ var StackBE = class {
1352
1637
  CheckoutClient,
1353
1638
  CustomersClient,
1354
1639
  EntitlementsClient,
1640
+ OrganizationsClient,
1641
+ PlansClient,
1642
+ ProductsClient,
1355
1643
  StackBE,
1356
1644
  StackBEError,
1357
1645
  SubscriptionsClient,