@drawbridge/drawbridge-stripe 0.1.2 → 0.1.4

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.js CHANGED
@@ -74,11 +74,8 @@ var require_billing = __commonJS({
74
74
  currency,
75
75
  cadence_data: {
76
76
  billing_cycle: {
77
- type: "month",
78
- interval_count: 1,
79
- month: {
80
- day_of_month: 1
81
- }
77
+ type: process.env.STRIPE_SUBSCRIPTION_INTERVAL,
78
+ interval_count: 1
82
79
  },
83
80
  payer
84
81
  },
@@ -158,6 +155,10 @@ var require_billing = __commonJS({
158
155
  title: customer + ".credit_balance_depleted"
159
156
  });
160
157
  const stripePricingPlanSubscriptionId = (_d = (_c = (_b = (_a = actions == null ? void 0 : actions.data) == null ? void 0 : _a[0]) == null ? void 0 : _b.subscribe) == null ? void 0 : _c.pricing_plan_subscription_details) == null ? void 0 : _d.pricing_plan_subscription;
158
+ if (!stripePricingPlanSubscriptionId) {
159
+ throw new Error("Stripe billing intent did not return a pricing plan subscription ID for customer: " + customer);
160
+ }
161
+ ;
161
162
  return {
162
163
  stripeAlerts: {
163
164
  ai: {
@@ -380,24 +381,24 @@ var require_subscription = __commonJS({
380
381
  proration_behavior: "create_prorations"
381
382
  }
382
383
  );
383
- let entries = (items == null ? void 0 : items.entries) || {};
384
- if ((entries == null ? void 0 : entries.id) && (entries == null ? void 0 : entries.price)) {
385
- ({ id: entries["id"] } = await stripe2.subscriptionItems.update(
386
- entries.id,
384
+ let actions = (items == null ? void 0 : items.actions) || {};
385
+ if ((actions == null ? void 0 : actions.id) && (actions == null ? void 0 : actions.price)) {
386
+ ({ id: actions["id"] } = await stripe2.subscriptionItems.update(
387
+ actions.id,
387
388
  {
388
389
  ...props,
389
- price: entries.price,
390
+ price: actions.price,
390
391
  proration_behavior: "none"
391
392
  }
392
393
  ));
393
394
  } else {
394
- entries = await createItem({
395
+ actions = await createItem({
395
396
  currency: to.currency,
396
397
  interval: to.interval,
397
- limit: to.limits.organization.entries,
398
+ limit: to.limits.organization.actions,
398
399
  metadata,
399
- name: "entries",
400
- overage: to.overages.entries,
400
+ name: "actions",
401
+ overage: to.overages.actions,
401
402
  proration_behavior: "none",
402
403
  subscription: stripeSubscriptionId
403
404
  });
@@ -415,7 +416,7 @@ var require_subscription = __commonJS({
415
416
  price: (_c = plan == null ? void 0 : plan.price) == null ? void 0 : _c.id,
416
417
  product: (_d = plan == null ? void 0 : plan.price) == null ? void 0 : _d.product
417
418
  },
418
- entries
419
+ actions
419
420
  }
420
421
  };
421
422
  } catch (error) {
@@ -431,13 +432,13 @@ var require_subscription = __commonJS({
431
432
  }) => {
432
433
  var _a, _b, _c;
433
434
  try {
434
- const entries = await createItem({
435
+ const actions = await createItem({
435
436
  currency: to.currency,
436
437
  interval: to.interval,
437
- limit: to.limits.organization.entries,
438
+ limit: to.limits.organization.actions,
438
439
  metadata,
439
- name: "entries",
440
- overage: to.overages.entries,
440
+ name: "actions",
441
+ overage: to.overages.actions,
441
442
  proration_behavior: "none"
442
443
  });
443
444
  const subscription = await stripe2.subscriptions.create({
@@ -450,7 +451,7 @@ var require_subscription = __commonJS({
450
451
  discounts: (discounts == null ? void 0 : discounts.length) > 0 ? discounts : "",
451
452
  items: [
452
453
  {
453
- price: entries.price
454
+ price: actions.price
454
455
  }
455
456
  ],
456
457
  metadata
@@ -470,9 +471,9 @@ var require_subscription = __commonJS({
470
471
  price: to == null ? void 0 : to.stripePriceId,
471
472
  product
472
473
  },
473
- entries: {
474
+ actions: {
474
475
  id: (_c = (_b = (_a = subscription == null ? void 0 : subscription.items) == null ? void 0 : _a.data) == null ? void 0 : _b[0]) == null ? void 0 : _c.id,
475
- ...entries
476
+ ...actions
476
477
  }
477
478
  },
478
479
  stripeCustomerId: customer,
@@ -501,33 +502,33 @@ var require_subscription = __commonJS({
501
502
  proration_behavior: "always_invoice"
502
503
  }
503
504
  );
504
- let entries;
505
- if (((_d = (_c = current == null ? void 0 : current.items) == null ? void 0 : _c.entries) == null ? void 0 : _d.id) && ((_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.entries) == null ? void 0 : _f.meter)) {
506
- entries = await createTier({
505
+ let actions;
506
+ if (((_d = (_c = current == null ? void 0 : current.items) == null ? void 0 : _c.actions) == null ? void 0 : _d.id) && ((_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.actions) == null ? void 0 : _f.meter)) {
507
+ actions = await createTier({
507
508
  currency: to.currency,
508
509
  interval: to.interval,
509
- limit: to.limits.organization.entries,
510
+ limit: to.limits.organization.actions,
510
511
  metadata,
511
- meter: current.items.entries.meter,
512
- name: "entries",
513
- overage: to.overages.entries
512
+ meter: current.items.actions.meter,
513
+ name: "actions",
514
+ overage: to.overages.actions
514
515
  });
515
- ({ id: entries["id"] } = await stripe2.subscriptionItems.update(
516
- current.items.entries.id,
516
+ ({ id: actions["id"] } = await stripe2.subscriptionItems.update(
517
+ current.items.actions.id,
517
518
  {
518
519
  ...props,
519
- price: entries == null ? void 0 : entries.price,
520
+ price: actions == null ? void 0 : actions.price,
520
521
  proration_behavior: "none"
521
522
  }
522
523
  ));
523
524
  } else {
524
- entries = await createItem({
525
+ actions = await createItem({
525
526
  currency: to.currency,
526
527
  interval: to.interval,
527
- limit: to.limits.organization.entries,
528
+ limit: to.limits.organization.actions,
528
529
  metadata,
529
- name: "entries",
530
- overage: to.overages.entries,
530
+ name: "actions",
531
+ overage: to.overages.actions,
531
532
  proration_behavior: "none",
532
533
  subscription: stripeSubscriptionId
533
534
  });
@@ -546,9 +547,9 @@ var require_subscription = __commonJS({
546
547
  price: (_g = plan == null ? void 0 : plan.price) == null ? void 0 : _g.id,
547
548
  product: (_h = plan == null ? void 0 : plan.price) == null ? void 0 : _h.product
548
549
  },
549
- entries: {
550
- ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.entries) || {},
551
- ...entries
550
+ actions: {
551
+ ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) || {},
552
+ ...actions
552
553
  }
553
554
  }
554
555
  };
package/dist/index.mjs CHANGED
@@ -80,11 +80,8 @@ var require_billing = __commonJS({
80
80
  currency,
81
81
  cadence_data: {
82
82
  billing_cycle: {
83
- type: "month",
84
- interval_count: 1,
85
- month: {
86
- day_of_month: 1
87
- }
83
+ type: process.env.STRIPE_SUBSCRIPTION_INTERVAL,
84
+ interval_count: 1
88
85
  },
89
86
  payer
90
87
  },
@@ -164,6 +161,10 @@ var require_billing = __commonJS({
164
161
  title: customer + ".credit_balance_depleted"
165
162
  });
166
163
  const stripePricingPlanSubscriptionId = (_d = (_c = (_b = (_a = actions == null ? void 0 : actions.data) == null ? void 0 : _a[0]) == null ? void 0 : _b.subscribe) == null ? void 0 : _c.pricing_plan_subscription_details) == null ? void 0 : _d.pricing_plan_subscription;
164
+ if (!stripePricingPlanSubscriptionId) {
165
+ throw new Error("Stripe billing intent did not return a pricing plan subscription ID for customer: " + customer);
166
+ }
167
+ ;
167
168
  return {
168
169
  stripeAlerts: {
169
170
  ai: {
@@ -386,24 +387,24 @@ var require_subscription = __commonJS({
386
387
  proration_behavior: "create_prorations"
387
388
  }
388
389
  );
389
- let entries = (items == null ? void 0 : items.entries) || {};
390
- if ((entries == null ? void 0 : entries.id) && (entries == null ? void 0 : entries.price)) {
391
- ({ id: entries["id"] } = await stripe.subscriptionItems.update(
392
- entries.id,
390
+ let actions = (items == null ? void 0 : items.actions) || {};
391
+ if ((actions == null ? void 0 : actions.id) && (actions == null ? void 0 : actions.price)) {
392
+ ({ id: actions["id"] } = await stripe.subscriptionItems.update(
393
+ actions.id,
393
394
  {
394
395
  ...props,
395
- price: entries.price,
396
+ price: actions.price,
396
397
  proration_behavior: "none"
397
398
  }
398
399
  ));
399
400
  } else {
400
- entries = await createItem({
401
+ actions = await createItem({
401
402
  currency: to.currency,
402
403
  interval: to.interval,
403
- limit: to.limits.organization.entries,
404
+ limit: to.limits.organization.actions,
404
405
  metadata,
405
- name: "entries",
406
- overage: to.overages.entries,
406
+ name: "actions",
407
+ overage: to.overages.actions,
407
408
  proration_behavior: "none",
408
409
  subscription: stripeSubscriptionId
409
410
  });
@@ -421,7 +422,7 @@ var require_subscription = __commonJS({
421
422
  price: (_c = plan == null ? void 0 : plan.price) == null ? void 0 : _c.id,
422
423
  product: (_d = plan == null ? void 0 : plan.price) == null ? void 0 : _d.product
423
424
  },
424
- entries
425
+ actions
425
426
  }
426
427
  };
427
428
  } catch (error) {
@@ -437,13 +438,13 @@ var require_subscription = __commonJS({
437
438
  }) => {
438
439
  var _a, _b, _c;
439
440
  try {
440
- const entries = await createItem({
441
+ const actions = await createItem({
441
442
  currency: to.currency,
442
443
  interval: to.interval,
443
- limit: to.limits.organization.entries,
444
+ limit: to.limits.organization.actions,
444
445
  metadata,
445
- name: "entries",
446
- overage: to.overages.entries,
446
+ name: "actions",
447
+ overage: to.overages.actions,
447
448
  proration_behavior: "none"
448
449
  });
449
450
  const subscription = await stripe.subscriptions.create({
@@ -456,7 +457,7 @@ var require_subscription = __commonJS({
456
457
  discounts: (discounts == null ? void 0 : discounts.length) > 0 ? discounts : "",
457
458
  items: [
458
459
  {
459
- price: entries.price
460
+ price: actions.price
460
461
  }
461
462
  ],
462
463
  metadata
@@ -476,9 +477,9 @@ var require_subscription = __commonJS({
476
477
  price: to == null ? void 0 : to.stripePriceId,
477
478
  product
478
479
  },
479
- entries: {
480
+ actions: {
480
481
  id: (_c = (_b = (_a = subscription == null ? void 0 : subscription.items) == null ? void 0 : _a.data) == null ? void 0 : _b[0]) == null ? void 0 : _c.id,
481
- ...entries
482
+ ...actions
482
483
  }
483
484
  },
484
485
  stripeCustomerId: customer,
@@ -507,33 +508,33 @@ var require_subscription = __commonJS({
507
508
  proration_behavior: "always_invoice"
508
509
  }
509
510
  );
510
- let entries;
511
- if (((_d = (_c = current == null ? void 0 : current.items) == null ? void 0 : _c.entries) == null ? void 0 : _d.id) && ((_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.entries) == null ? void 0 : _f.meter)) {
512
- entries = await createTier({
511
+ let actions;
512
+ if (((_d = (_c = current == null ? void 0 : current.items) == null ? void 0 : _c.actions) == null ? void 0 : _d.id) && ((_f = (_e = current == null ? void 0 : current.items) == null ? void 0 : _e.actions) == null ? void 0 : _f.meter)) {
513
+ actions = await createTier({
513
514
  currency: to.currency,
514
515
  interval: to.interval,
515
- limit: to.limits.organization.entries,
516
+ limit: to.limits.organization.actions,
516
517
  metadata,
517
- meter: current.items.entries.meter,
518
- name: "entries",
519
- overage: to.overages.entries
518
+ meter: current.items.actions.meter,
519
+ name: "actions",
520
+ overage: to.overages.actions
520
521
  });
521
- ({ id: entries["id"] } = await stripe.subscriptionItems.update(
522
- current.items.entries.id,
522
+ ({ id: actions["id"] } = await stripe.subscriptionItems.update(
523
+ current.items.actions.id,
523
524
  {
524
525
  ...props,
525
- price: entries == null ? void 0 : entries.price,
526
+ price: actions == null ? void 0 : actions.price,
526
527
  proration_behavior: "none"
527
528
  }
528
529
  ));
529
530
  } else {
530
- entries = await createItem({
531
+ actions = await createItem({
531
532
  currency: to.currency,
532
533
  interval: to.interval,
533
- limit: to.limits.organization.entries,
534
+ limit: to.limits.organization.actions,
534
535
  metadata,
535
- name: "entries",
536
- overage: to.overages.entries,
536
+ name: "actions",
537
+ overage: to.overages.actions,
537
538
  proration_behavior: "none",
538
539
  subscription: stripeSubscriptionId
539
540
  });
@@ -552,9 +553,9 @@ var require_subscription = __commonJS({
552
553
  price: (_g = plan == null ? void 0 : plan.price) == null ? void 0 : _g.id,
553
554
  product: (_h = plan == null ? void 0 : plan.price) == null ? void 0 : _h.product
554
555
  },
555
- entries: {
556
- ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.entries) || {},
557
- ...entries
556
+ actions: {
557
+ ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) || {},
558
+ ...actions
558
559
  }
559
560
  }
560
561
  };
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  "build": "tsup ./index.js && npm publish"
25
25
  },
26
26
  "types": "dist/index.d.ts",
27
- "version": "0.1.2"
27
+ "version": "0.1.4"
28
28
  }