@drawbridge/drawbridge-stripe 0.1.3 → 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
  },
@@ -384,24 +381,24 @@ var require_subscription = __commonJS({
384
381
  proration_behavior: "create_prorations"
385
382
  }
386
383
  );
387
- let entries = (items == null ? void 0 : items.entries) || {};
388
- if ((entries == null ? void 0 : entries.id) && (entries == null ? void 0 : entries.price)) {
389
- ({ id: entries["id"] } = await stripe2.subscriptionItems.update(
390
- 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,
391
388
  {
392
389
  ...props,
393
- price: entries.price,
390
+ price: actions.price,
394
391
  proration_behavior: "none"
395
392
  }
396
393
  ));
397
394
  } else {
398
- entries = await createItem({
395
+ actions = await createItem({
399
396
  currency: to.currency,
400
397
  interval: to.interval,
401
- limit: to.limits.organization.entries,
398
+ limit: to.limits.organization.actions,
402
399
  metadata,
403
- name: "entries",
404
- overage: to.overages.entries,
400
+ name: "actions",
401
+ overage: to.overages.actions,
405
402
  proration_behavior: "none",
406
403
  subscription: stripeSubscriptionId
407
404
  });
@@ -419,7 +416,7 @@ var require_subscription = __commonJS({
419
416
  price: (_c = plan == null ? void 0 : plan.price) == null ? void 0 : _c.id,
420
417
  product: (_d = plan == null ? void 0 : plan.price) == null ? void 0 : _d.product
421
418
  },
422
- entries
419
+ actions
423
420
  }
424
421
  };
425
422
  } catch (error) {
@@ -435,13 +432,13 @@ var require_subscription = __commonJS({
435
432
  }) => {
436
433
  var _a, _b, _c;
437
434
  try {
438
- const entries = await createItem({
435
+ const actions = await createItem({
439
436
  currency: to.currency,
440
437
  interval: to.interval,
441
- limit: to.limits.organization.entries,
438
+ limit: to.limits.organization.actions,
442
439
  metadata,
443
- name: "entries",
444
- overage: to.overages.entries,
440
+ name: "actions",
441
+ overage: to.overages.actions,
445
442
  proration_behavior: "none"
446
443
  });
447
444
  const subscription = await stripe2.subscriptions.create({
@@ -454,7 +451,7 @@ var require_subscription = __commonJS({
454
451
  discounts: (discounts == null ? void 0 : discounts.length) > 0 ? discounts : "",
455
452
  items: [
456
453
  {
457
- price: entries.price
454
+ price: actions.price
458
455
  }
459
456
  ],
460
457
  metadata
@@ -474,9 +471,9 @@ var require_subscription = __commonJS({
474
471
  price: to == null ? void 0 : to.stripePriceId,
475
472
  product
476
473
  },
477
- entries: {
474
+ actions: {
478
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,
479
- ...entries
476
+ ...actions
480
477
  }
481
478
  },
482
479
  stripeCustomerId: customer,
@@ -505,33 +502,33 @@ var require_subscription = __commonJS({
505
502
  proration_behavior: "always_invoice"
506
503
  }
507
504
  );
508
- let entries;
509
- 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)) {
510
- 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({
511
508
  currency: to.currency,
512
509
  interval: to.interval,
513
- limit: to.limits.organization.entries,
510
+ limit: to.limits.organization.actions,
514
511
  metadata,
515
- meter: current.items.entries.meter,
516
- name: "entries",
517
- overage: to.overages.entries
512
+ meter: current.items.actions.meter,
513
+ name: "actions",
514
+ overage: to.overages.actions
518
515
  });
519
- ({ id: entries["id"] } = await stripe2.subscriptionItems.update(
520
- current.items.entries.id,
516
+ ({ id: actions["id"] } = await stripe2.subscriptionItems.update(
517
+ current.items.actions.id,
521
518
  {
522
519
  ...props,
523
- price: entries == null ? void 0 : entries.price,
520
+ price: actions == null ? void 0 : actions.price,
524
521
  proration_behavior: "none"
525
522
  }
526
523
  ));
527
524
  } else {
528
- entries = await createItem({
525
+ actions = await createItem({
529
526
  currency: to.currency,
530
527
  interval: to.interval,
531
- limit: to.limits.organization.entries,
528
+ limit: to.limits.organization.actions,
532
529
  metadata,
533
- name: "entries",
534
- overage: to.overages.entries,
530
+ name: "actions",
531
+ overage: to.overages.actions,
535
532
  proration_behavior: "none",
536
533
  subscription: stripeSubscriptionId
537
534
  });
@@ -550,9 +547,9 @@ var require_subscription = __commonJS({
550
547
  price: (_g = plan == null ? void 0 : plan.price) == null ? void 0 : _g.id,
551
548
  product: (_h = plan == null ? void 0 : plan.price) == null ? void 0 : _h.product
552
549
  },
553
- entries: {
554
- ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.entries) || {},
555
- ...entries
550
+ actions: {
551
+ ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) || {},
552
+ ...actions
556
553
  }
557
554
  }
558
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
  },
@@ -390,24 +387,24 @@ var require_subscription = __commonJS({
390
387
  proration_behavior: "create_prorations"
391
388
  }
392
389
  );
393
- let entries = (items == null ? void 0 : items.entries) || {};
394
- if ((entries == null ? void 0 : entries.id) && (entries == null ? void 0 : entries.price)) {
395
- ({ id: entries["id"] } = await stripe.subscriptionItems.update(
396
- 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,
397
394
  {
398
395
  ...props,
399
- price: entries.price,
396
+ price: actions.price,
400
397
  proration_behavior: "none"
401
398
  }
402
399
  ));
403
400
  } else {
404
- entries = await createItem({
401
+ actions = await createItem({
405
402
  currency: to.currency,
406
403
  interval: to.interval,
407
- limit: to.limits.organization.entries,
404
+ limit: to.limits.organization.actions,
408
405
  metadata,
409
- name: "entries",
410
- overage: to.overages.entries,
406
+ name: "actions",
407
+ overage: to.overages.actions,
411
408
  proration_behavior: "none",
412
409
  subscription: stripeSubscriptionId
413
410
  });
@@ -425,7 +422,7 @@ var require_subscription = __commonJS({
425
422
  price: (_c = plan == null ? void 0 : plan.price) == null ? void 0 : _c.id,
426
423
  product: (_d = plan == null ? void 0 : plan.price) == null ? void 0 : _d.product
427
424
  },
428
- entries
425
+ actions
429
426
  }
430
427
  };
431
428
  } catch (error) {
@@ -441,13 +438,13 @@ var require_subscription = __commonJS({
441
438
  }) => {
442
439
  var _a, _b, _c;
443
440
  try {
444
- const entries = await createItem({
441
+ const actions = await createItem({
445
442
  currency: to.currency,
446
443
  interval: to.interval,
447
- limit: to.limits.organization.entries,
444
+ limit: to.limits.organization.actions,
448
445
  metadata,
449
- name: "entries",
450
- overage: to.overages.entries,
446
+ name: "actions",
447
+ overage: to.overages.actions,
451
448
  proration_behavior: "none"
452
449
  });
453
450
  const subscription = await stripe.subscriptions.create({
@@ -460,7 +457,7 @@ var require_subscription = __commonJS({
460
457
  discounts: (discounts == null ? void 0 : discounts.length) > 0 ? discounts : "",
461
458
  items: [
462
459
  {
463
- price: entries.price
460
+ price: actions.price
464
461
  }
465
462
  ],
466
463
  metadata
@@ -480,9 +477,9 @@ var require_subscription = __commonJS({
480
477
  price: to == null ? void 0 : to.stripePriceId,
481
478
  product
482
479
  },
483
- entries: {
480
+ actions: {
484
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,
485
- ...entries
482
+ ...actions
486
483
  }
487
484
  },
488
485
  stripeCustomerId: customer,
@@ -511,33 +508,33 @@ var require_subscription = __commonJS({
511
508
  proration_behavior: "always_invoice"
512
509
  }
513
510
  );
514
- let entries;
515
- 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)) {
516
- 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({
517
514
  currency: to.currency,
518
515
  interval: to.interval,
519
- limit: to.limits.organization.entries,
516
+ limit: to.limits.organization.actions,
520
517
  metadata,
521
- meter: current.items.entries.meter,
522
- name: "entries",
523
- overage: to.overages.entries
518
+ meter: current.items.actions.meter,
519
+ name: "actions",
520
+ overage: to.overages.actions
524
521
  });
525
- ({ id: entries["id"] } = await stripe.subscriptionItems.update(
526
- current.items.entries.id,
522
+ ({ id: actions["id"] } = await stripe.subscriptionItems.update(
523
+ current.items.actions.id,
527
524
  {
528
525
  ...props,
529
- price: entries == null ? void 0 : entries.price,
526
+ price: actions == null ? void 0 : actions.price,
530
527
  proration_behavior: "none"
531
528
  }
532
529
  ));
533
530
  } else {
534
- entries = await createItem({
531
+ actions = await createItem({
535
532
  currency: to.currency,
536
533
  interval: to.interval,
537
- limit: to.limits.organization.entries,
534
+ limit: to.limits.organization.actions,
538
535
  metadata,
539
- name: "entries",
540
- overage: to.overages.entries,
536
+ name: "actions",
537
+ overage: to.overages.actions,
541
538
  proration_behavior: "none",
542
539
  subscription: stripeSubscriptionId
543
540
  });
@@ -556,9 +553,9 @@ var require_subscription = __commonJS({
556
553
  price: (_g = plan == null ? void 0 : plan.price) == null ? void 0 : _g.id,
557
554
  product: (_h = plan == null ? void 0 : plan.price) == null ? void 0 : _h.product
558
555
  },
559
- entries: {
560
- ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.entries) || {},
561
- ...entries
556
+ actions: {
557
+ ...((_i = current == null ? void 0 : current.items) == null ? void 0 : _i.actions) || {},
558
+ ...actions
562
559
  }
563
560
  }
564
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.3"
27
+ "version": "0.1.4"
28
28
  }