@omnibase/core-js 0.6.0 → 0.7.1

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.
@@ -60,31 +60,20 @@ var CheckoutManager = class {
60
60
  * @throws {ValidationError} When required parameters are missing or invalid
61
61
  *
62
62
  * @example
63
- * Creating a checkout session (mode is auto-detected):
64
63
  * ```typescript
65
64
  * const session = await checkoutManager.createSession({
66
- * price_id: 'price_one_time_product',
65
+ * price_id: 'price_monthly_pro',
67
66
  * success_url: 'https://app.com/success',
68
67
  * cancel_url: 'https://app.com/cancel'
69
68
  * });
70
69
  *
71
70
  * // Redirect to Stripe checkout
72
- * window.location.href = session.data.url;
73
- * ```
74
- *
75
- * @example
76
- * Checkout with session tracking:
77
- * ```typescript
78
- * const session = await checkoutManager.createSession({
79
- * price_id: 'price_monthly_plan',
80
- * success_url: 'https://app.com/dashboard?session_id={CHECKOUT_SESSION_ID}',
81
- * cancel_url: 'https://app.com/pricing',
82
- * });
83
- *
84
- * console.log(`Session created: ${session.data.sessionId}`);
71
+ * if (session.data?.url) {
72
+ * window.location.href = session.data.url;
73
+ * }
85
74
  * ```
86
75
  *
87
- * @since 1.0.0
76
+ * @since 0.6.0
88
77
  * @group Checkout
89
78
  */
90
79
  async createSession(options) {
@@ -305,7 +294,7 @@ var PortalManager = class {
305
294
  /**
306
295
  * Initialize the portal manager
307
296
  *
308
- * @param paymentHandler - Payment handler instance for API communication
297
+ * @param omnibaseClient - OmnibaseClient instance for API communication
309
298
  *
310
299
  * @group Portal
311
300
  */
@@ -332,32 +321,18 @@ var PortalManager = class {
332
321
  * @throws {ValidationError} When required parameters are missing or invalid
333
322
  *
334
323
  * @example
335
- * Basic portal creation:
336
324
  * ```typescript
337
325
  * const portal = await portalManager.create({
338
326
  * return_url: 'https://myapp.com/account/billing'
339
327
  * });
340
328
  *
341
329
  * // Redirect user to portal
342
- * window.location.href = portal.data.url;
343
- * ```
344
- *
345
- * @example
346
- * With error handling:
347
- * ```typescript
348
- * try {
349
- * const portal = await portalManager.create({
350
- * return_url: window.location.origin + '/billing'
351
- * });
352
- *
330
+ * if (portal.data?.url) {
353
331
  * window.location.href = portal.data.url;
354
- * } catch (error) {
355
- * console.error('Failed to create portal session:', error);
356
- * showErrorMessage('Unable to access billing portal. Please try again.');
357
332
  * }
358
333
  * ```
359
334
  *
360
- * @since 1.0.0
335
+ * @since 0.6.0
361
336
  * @group Portal
362
337
  */
363
338
  async create(options) {
@@ -387,7 +362,7 @@ var UsageManager = class {
387
362
  /**
388
363
  * Initialize the usage manager
389
364
  *
390
- * @param paymentHandler - Payment handler instance for API communication
365
+ * @param omnibaseClient - OmnibaseClient instance for API communication
391
366
  *
392
367
  * @group Usage
393
368
  */
@@ -416,7 +391,6 @@ var UsageManager = class {
416
391
  * @throws {ValidationError} When required parameters are missing or invalid
417
392
  *
418
393
  * @example
419
- * API call tracking:
420
394
  * ```typescript
421
395
  * // Record each API call
422
396
  * await usageManager.recordUsage({
@@ -425,37 +399,7 @@ var UsageManager = class {
425
399
  * });
426
400
  * ```
427
401
  *
428
- * @example
429
- * Batch usage recording:
430
- * ```typescript
431
- * // Record multiple operations at once
432
- * const usageEvents = [
433
- * { meter_event_name: 'compute_hours', value: '0.5' },
434
- * { meter_event_name: 'storage_gb', value: '10' },
435
- * { meter_event_name: 'api_calls', value: '50' }
436
- * ];
437
- *
438
- * for (const event of usageEvents) {
439
- * await usageManager.recordUsage(event);
440
- * }
441
- * ```
442
- *
443
- * @example
444
- * With error handling:
445
- * ```typescript
446
- * try {
447
- * await usageManager.recordUsage({
448
- * meter_event_name: 'file_uploads',
449
- * value: String(uploadedFiles.length)
450
- * });
451
- * } catch (error) {
452
- * console.error('Failed to record usage:', error);
453
- * // Usage recording failure shouldn't block user operations
454
- * // but should be logged for billing accuracy
455
- * }
456
- * ```
457
- *
458
- * @since 1.0.0
402
+ * @since 0.6.0
459
403
  * @group Usage
460
404
  */
461
405
  async recordUsage(options) {
@@ -480,20 +424,20 @@ var UsageManager = class {
480
424
  // src/payments/handler.ts
481
425
  var PaymentHandler = class {
482
426
  /**
483
- * Initialize the payment handler with API configuration
427
+ * Initialize the payment handler with OmnibaseClient
484
428
  *
485
- * Creates a new payment handler instance that will communicate with
486
- * the specified API endpoint. The handler automatically handles
487
- * request formatting and authentication headers.
429
+ * Creates a new payment handler instance with access to all payment
430
+ * operations including checkout, configuration, portal, and usage tracking.
431
+ * The handler uses the provided OmnibaseClient for API communication.
488
432
  *
489
- * @param apiUrl - Base URL for the payment API endpoint
433
+ * @param omnibaseClient - OmnibaseClient instance for API communication
490
434
  *
491
435
  * @example
492
436
  * ```typescript
493
- * const paymentHandler = new PaymentHandler('https://api.myapp.com');
437
+ * const paymentHandler = new PaymentHandler(omnibaseClient);
494
438
  * ```
495
439
  *
496
- * @since 1.0.0
440
+ * @since 0.6.0
497
441
  * @group Client
498
442
  */
499
443
  constructor(omnibaseClient) {
@@ -512,10 +456,14 @@ var PaymentHandler = class {
512
456
  * @example
513
457
  * ```typescript
514
458
  * const session = await paymentHandler.checkout.createSession({
515
- * price_id: 'price_monthly',
459
+ * price_id: 'price_monthly_pro',
516
460
  * success_url: window.location.origin + '/success',
517
461
  * cancel_url: window.location.origin + '/pricing'
518
462
  * });
463
+ *
464
+ * if (session.data?.url) {
465
+ * window.location.href = session.data.url;
466
+ * }
519
467
  * ```
520
468
  */
521
469
  checkout;