@mmailaender/convex-creem 0.1.0
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/LICENSE +201 -0
- package/README.md +1176 -0
- package/dist/client/helpers.d.ts +17 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +43 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/index.d.ts +1041 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1068 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/parsers.d.ts +45 -0
- package/dist/client/parsers.d.ts.map +1 -0
- package/dist/client/parsers.js +138 -0
- package/dist/client/parsers.js.map +1 -0
- package/dist/client/polyfill.d.ts +2 -0
- package/dist/client/polyfill.d.ts.map +1 -0
- package/dist/client/polyfill.js +3 -0
- package/dist/client/polyfill.js.map +1 -0
- package/dist/component/_generated/api.d.ts +36 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +542 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +3 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/lib.d.ts +1005 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/component/lib.js +647 -0
- package/dist/component/lib.js.map +1 -0
- package/dist/component/schema.d.ts +191 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +104 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/util.d.ts +61 -0
- package/dist/component/util.d.ts.map +1 -0
- package/dist/component/util.js +142 -0
- package/dist/component/util.js.map +1 -0
- package/dist/core/catalog.d.ts +18 -0
- package/dist/core/catalog.d.ts.map +1 -0
- package/dist/core/catalog.js +82 -0
- package/dist/core/catalog.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/markdown.d.ts +12 -0
- package/dist/core/markdown.d.ts.map +1 -0
- package/dist/core/markdown.js +26 -0
- package/dist/core/markdown.js.map +1 -0
- package/dist/core/payments.d.ts +11 -0
- package/dist/core/payments.d.ts.map +1 -0
- package/dist/core/payments.js +27 -0
- package/dist/core/payments.js.map +1 -0
- package/dist/core/pendingCheckout.d.ts +15 -0
- package/dist/core/pendingCheckout.d.ts.map +1 -0
- package/dist/core/pendingCheckout.js +40 -0
- package/dist/core/pendingCheckout.js.map +1 -0
- package/dist/core/resolver.d.ts +11 -0
- package/dist/core/resolver.d.ts.map +1 -0
- package/dist/core/resolver.js +106 -0
- package/dist/core/resolver.js.map +1 -0
- package/dist/core/selectors.d.ts +12 -0
- package/dist/core/selectors.d.ts.map +1 -0
- package/dist/core/selectors.js +18 -0
- package/dist/core/selectors.js.map +1 -0
- package/dist/core/subscriptionUpdate.d.ts +20 -0
- package/dist/core/subscriptionUpdate.d.ts.map +1 -0
- package/dist/core/subscriptionUpdate.js +64 -0
- package/dist/core/subscriptionUpdate.js.map +1 -0
- package/dist/core/types.d.ts +170 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +15 -0
- package/dist/core/types.js.map +1 -0
- package/dist/design-system/colors/color-utils.d.ts +10 -0
- package/dist/design-system/colors/color-utils.d.ts.map +1 -0
- package/dist/design-system/colors/color-utils.js +91 -0
- package/dist/design-system/colors/color-utils.js.map +1 -0
- package/dist/design-system/colors/config.d.ts +33 -0
- package/dist/design-system/colors/config.d.ts.map +1 -0
- package/dist/design-system/colors/config.js +224 -0
- package/dist/design-system/colors/config.js.map +1 -0
- package/dist/design-system/colors/index.d.ts +3 -0
- package/dist/design-system/colors/index.d.ts.map +1 -0
- package/dist/design-system/colors/index.js +3 -0
- package/dist/design-system/colors/index.js.map +1 -0
- package/dist/design-system/rounded/config.d.ts +31 -0
- package/dist/design-system/rounded/config.d.ts.map +1 -0
- package/dist/design-system/rounded/config.js +76 -0
- package/dist/design-system/rounded/config.js.map +1 -0
- package/dist/design-system/rounded/index.d.ts +2 -0
- package/dist/design-system/rounded/index.d.ts.map +1 -0
- package/dist/design-system/rounded/index.js +2 -0
- package/dist/design-system/rounded/index.js.map +1 -0
- package/dist/design-system/typography/config.d.ts +55 -0
- package/dist/design-system/typography/config.d.ts.map +1 -0
- package/dist/design-system/typography/config.js +308 -0
- package/dist/design-system/typography/config.js.map +1 -0
- package/dist/design-system/typography/index.d.ts +3 -0
- package/dist/design-system/typography/index.d.ts.map +1 -0
- package/dist/design-system/typography/index.js +3 -0
- package/dist/design-system/typography/index.js.map +1 -0
- package/dist/design-system/typography/tokens.d.ts +23 -0
- package/dist/design-system/typography/tokens.d.ts.map +1 -0
- package/dist/design-system/typography/tokens.js +99 -0
- package/dist/design-system/typography/tokens.js.map +1 -0
- package/dist/react/hooks/useCheckoutSuccessParams.d.ts +2 -0
- package/dist/react/hooks/useCheckoutSuccessParams.d.ts.map +1 -0
- package/dist/react/hooks/useCheckoutSuccessParams.js +5 -0
- package/dist/react/hooks/useCheckoutSuccessParams.js.map +1 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +22 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/primitives/BillingGate.d.ts +8 -0
- package/dist/react/primitives/BillingGate.d.ts.map +1 -0
- package/dist/react/primitives/BillingGate.js +13 -0
- package/dist/react/primitives/BillingGate.js.map +1 -0
- package/dist/react/primitives/BillingToggle.d.ts +8 -0
- package/dist/react/primitives/BillingToggle.d.ts.map +1 -0
- package/dist/react/primitives/BillingToggle.js +12 -0
- package/dist/react/primitives/BillingToggle.js.map +1 -0
- package/dist/react/primitives/CheckoutButton.d.ts +11 -0
- package/dist/react/primitives/CheckoutButton.d.ts.map +1 -0
- package/dist/react/primitives/CheckoutButton.js +21 -0
- package/dist/react/primitives/CheckoutButton.js.map +1 -0
- package/dist/react/primitives/CheckoutSuccessSummary.d.ts +7 -0
- package/dist/react/primitives/CheckoutSuccessSummary.d.ts.map +1 -0
- package/dist/react/primitives/CheckoutSuccessSummary.js +11 -0
- package/dist/react/primitives/CheckoutSuccessSummary.js.map +1 -0
- package/dist/react/primitives/CustomerPortalButton.d.ts +8 -0
- package/dist/react/primitives/CustomerPortalButton.d.ts.map +1 -0
- package/dist/react/primitives/CustomerPortalButton.js +21 -0
- package/dist/react/primitives/CustomerPortalButton.js.map +1 -0
- package/dist/react/primitives/NumberInput.d.ts +11 -0
- package/dist/react/primitives/NumberInput.d.ts.map +1 -0
- package/dist/react/primitives/NumberInput.js +18 -0
- package/dist/react/primitives/NumberInput.js.map +1 -0
- package/dist/react/primitives/OneTimeCheckoutButton.d.ts +11 -0
- package/dist/react/primitives/OneTimeCheckoutButton.d.ts.map +1 -0
- package/dist/react/primitives/OneTimeCheckoutButton.js +4 -0
- package/dist/react/primitives/OneTimeCheckoutButton.js.map +1 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.d.ts +6 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.d.ts.map +1 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.js +11 -0
- package/dist/react/primitives/OneTimePaymentStatusBadge.js.map +1 -0
- package/dist/react/primitives/PaymentWarningBanner.d.ts +7 -0
- package/dist/react/primitives/PaymentWarningBanner.d.ts.map +1 -0
- package/dist/react/primitives/PaymentWarningBanner.js +18 -0
- package/dist/react/primitives/PaymentWarningBanner.js.map +1 -0
- package/dist/react/primitives/PricingCard.d.ts +37 -0
- package/dist/react/primitives/PricingCard.d.ts.map +1 -0
- package/dist/react/primitives/PricingCard.js +125 -0
- package/dist/react/primitives/PricingCard.js.map +1 -0
- package/dist/react/primitives/PricingSection.d.ts +39 -0
- package/dist/react/primitives/PricingSection.d.ts.map +1 -0
- package/dist/react/primitives/PricingSection.js +24 -0
- package/dist/react/primitives/PricingSection.js.map +1 -0
- package/dist/react/primitives/ScheduledChangeBanner.d.ts +8 -0
- package/dist/react/primitives/ScheduledChangeBanner.d.ts.map +1 -0
- package/dist/react/primitives/ScheduledChangeBanner.js +13 -0
- package/dist/react/primitives/ScheduledChangeBanner.js.map +1 -0
- package/dist/react/primitives/SegmentControl.d.ts +11 -0
- package/dist/react/primitives/SegmentControl.d.ts.map +1 -0
- package/dist/react/primitives/SegmentControl.js +8 -0
- package/dist/react/primitives/SegmentControl.js.map +1 -0
- package/dist/react/primitives/SegmentGroup.d.ts +14 -0
- package/dist/react/primitives/SegmentGroup.d.ts.map +1 -0
- package/dist/react/primitives/SegmentGroup.js +11 -0
- package/dist/react/primitives/SegmentGroup.js.map +1 -0
- package/dist/react/primitives/TrialLimitBanner.d.ts +7 -0
- package/dist/react/primitives/TrialLimitBanner.d.ts.map +1 -0
- package/dist/react/primitives/TrialLimitBanner.js +14 -0
- package/dist/react/primitives/TrialLimitBanner.js.map +1 -0
- package/dist/react/shared.d.ts +28 -0
- package/dist/react/shared.d.ts.map +1 -0
- package/dist/react/shared.js +109 -0
- package/dist/react/shared.js.map +1 -0
- package/dist/react/widgets/BillingPortal.d.ts +9 -0
- package/dist/react/widgets/BillingPortal.d.ts.map +1 -0
- package/dist/react/widgets/BillingPortal.js +30 -0
- package/dist/react/widgets/BillingPortal.js.map +1 -0
- package/dist/react/widgets/ProductItem.d.ts +8 -0
- package/dist/react/widgets/ProductItem.d.ts.map +1 -0
- package/dist/react/widgets/ProductItem.js +14 -0
- package/dist/react/widgets/ProductItem.js.map +1 -0
- package/dist/react/widgets/ProductRoot.d.ts +16 -0
- package/dist/react/widgets/ProductRoot.d.ts.map +1 -0
- package/dist/react/widgets/ProductRoot.js +171 -0
- package/dist/react/widgets/ProductRoot.js.map +1 -0
- package/dist/react/widgets/SubscriptionItem.d.ts +27 -0
- package/dist/react/widgets/SubscriptionItem.d.ts.map +1 -0
- package/dist/react/widgets/SubscriptionItem.js +32 -0
- package/dist/react/widgets/SubscriptionItem.js.map +1 -0
- package/dist/react/widgets/SubscriptionRoot.d.ts +16 -0
- package/dist/react/widgets/SubscriptionRoot.d.ts.map +1 -0
- package/dist/react/widgets/SubscriptionRoot.js +405 -0
- package/dist/react/widgets/SubscriptionRoot.js.map +1 -0
- package/dist/react/widgets/index.d.ts +19 -0
- package/dist/react/widgets/index.d.ts.map +1 -0
- package/dist/react/widgets/index.js +16 -0
- package/dist/react/widgets/index.js.map +1 -0
- package/dist/react/widgets/productGroupContext.d.ts +6 -0
- package/dist/react/widgets/productGroupContext.d.ts.map +1 -0
- package/dist/react/widgets/productGroupContext.js +3 -0
- package/dist/react/widgets/productGroupContext.js.map +1 -0
- package/dist/react/widgets/subscriptionContext.d.ts +6 -0
- package/dist/react/widgets/subscriptionContext.d.ts.map +1 -0
- package/dist/react/widgets/subscriptionContext.js +3 -0
- package/dist/react/widgets/subscriptionContext.js.map +1 -0
- package/dist/react/widgets/types.d.ts +171 -0
- package/dist/react/widgets/types.d.ts.map +1 -0
- package/dist/react/widgets/types.js +2 -0
- package/dist/react/widgets/types.js.map +1 -0
- package/dist/svelte/index.d.ts +22 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +20 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/primitives/BillingGate.svelte +28 -0
- package/dist/svelte/primitives/BillingToggle.svelte +27 -0
- package/dist/svelte/primitives/CheckoutButton.svelte +60 -0
- package/dist/svelte/primitives/CheckoutSuccessSummary.svelte +34 -0
- package/dist/svelte/primitives/CustomerPortalButton.svelte +60 -0
- package/dist/svelte/primitives/NumberInput.svelte +71 -0
- package/dist/svelte/primitives/OneTimeCheckoutButton.svelte +37 -0
- package/dist/svelte/primitives/OneTimePaymentStatusBadge.svelte +20 -0
- package/dist/svelte/primitives/PaymentWarningBanner.svelte +30 -0
- package/dist/svelte/primitives/PricingCard.svelte +356 -0
- package/dist/svelte/primitives/PricingSection.svelte +121 -0
- package/dist/svelte/primitives/ScheduledChangeBanner.svelte +46 -0
- package/dist/svelte/primitives/SegmentControl.svelte +38 -0
- package/dist/svelte/primitives/SegmentGroup.svelte +52 -0
- package/dist/svelte/primitives/TrialLimitBanner.svelte +32 -0
- package/dist/svelte/primitives/shared.d.ts +13 -0
- package/dist/svelte/primitives/shared.d.ts.map +1 -0
- package/dist/svelte/primitives/shared.js +87 -0
- package/dist/svelte/primitives/shared.js.map +1 -0
- package/dist/svelte/widgets/BillingPortal.svelte +55 -0
- package/dist/svelte/widgets/Product.svelte +35 -0
- package/dist/svelte/widgets/ProductRoot.svelte +428 -0
- package/dist/svelte/widgets/Subscription.svelte +52 -0
- package/dist/svelte/widgets/SubscriptionRoot.svelte +690 -0
- package/dist/svelte/widgets/index.d.ts +19 -0
- package/dist/svelte/widgets/index.d.ts.map +1 -0
- package/dist/svelte/widgets/index.js +16 -0
- package/dist/svelte/widgets/index.js.map +1 -0
- package/dist/svelte/widgets/productGroupContext.d.ts +6 -0
- package/dist/svelte/widgets/productGroupContext.d.ts.map +1 -0
- package/dist/svelte/widgets/productGroupContext.js +2 -0
- package/dist/svelte/widgets/productGroupContext.js.map +1 -0
- package/dist/svelte/widgets/subscriptionContext.d.ts +6 -0
- package/dist/svelte/widgets/subscriptionContext.d.ts.map +1 -0
- package/dist/svelte/widgets/subscriptionContext.js +2 -0
- package/dist/svelte/widgets/subscriptionContext.js.map +1 -0
- package/dist/svelte/widgets/types.d.ts +171 -0
- package/dist/svelte/widgets/types.d.ts.map +1 -0
- package/dist/svelte/widgets/types.js +2 -0
- package/dist/svelte/widgets/types.js.map +1 -0
- package/package.json +182 -0
- package/src/client/helpers.test.ts +139 -0
- package/src/client/helpers.ts +51 -0
- package/src/client/index.test.ts +1554 -0
- package/src/client/index.ts +1504 -0
- package/src/client/parsers.test.ts +1017 -0
- package/src/client/parsers.ts +182 -0
- package/src/client/polyfill.ts +2 -0
- package/src/component/_generated/api.ts +52 -0
- package/src/component/_generated/component.ts +619 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +3 -0
- package/src/component/lib.test.ts +1359 -0
- package/src/component/lib.ts +726 -0
- package/src/component/schema.ts +112 -0
- package/src/component/util.test.ts +281 -0
- package/src/component/util.ts +228 -0
- package/src/core/catalog.test.ts +212 -0
- package/src/core/catalog.ts +119 -0
- package/src/core/index.ts +8 -0
- package/src/core/markdown.test.ts +43 -0
- package/src/core/markdown.ts +26 -0
- package/src/core/payments.test.ts +69 -0
- package/src/core/payments.ts +33 -0
- package/src/core/pendingCheckout.test.ts +44 -0
- package/src/core/pendingCheckout.ts +40 -0
- package/src/core/resolver.test.ts +283 -0
- package/src/core/resolver.ts +160 -0
- package/src/core/selectors.test.ts +119 -0
- package/src/core/selectors.ts +35 -0
- package/src/core/subscriptionUpdate.test.ts +164 -0
- package/src/core/subscriptionUpdate.ts +102 -0
- package/src/core/types.ts +220 -0
- package/src/design-system/README.md +40 -0
- package/src/design-system/base.css +27 -0
- package/src/design-system/colors/color-utils.ts +110 -0
- package/src/design-system/colors/config.ts +282 -0
- package/src/design-system/colors/index.ts +2 -0
- package/src/design-system/colors/utilities.css +2328 -0
- package/src/design-system/components/badges.css +65 -0
- package/src/design-system/components/buttons.css +256 -0
- package/src/design-system/components/dialog.css +218 -0
- package/src/design-system/components/icon-buttons.css +115 -0
- package/src/design-system/components/inputs.css +94 -0
- package/src/design-system/components/links.css +53 -0
- package/src/design-system/components/prose.css +67 -0
- package/src/design-system/components/segment-control.css +303 -0
- package/src/design-system/index.css +21 -0
- package/src/design-system/rounded/config.ts +91 -0
- package/src/design-system/rounded/index.ts +1 -0
- package/src/design-system/rounded/utilities.css +37 -0
- package/src/design-system/typography/config.ts +340 -0
- package/src/design-system/typography/index.ts +2 -0
- package/src/design-system/typography/tokens.ts +148 -0
- package/src/design-system/typography/utilities.css +728 -0
- package/src/library.css +20 -0
- package/src/react/hooks/useCheckoutSuccessParams.ts +7 -0
- package/src/react/index.tsx +47 -0
- package/src/react/primitives/BillingGate.tsx +26 -0
- package/src/react/primitives/BillingToggle.tsx +29 -0
- package/src/react/primitives/CheckoutButton.tsx +47 -0
- package/src/react/primitives/CheckoutSuccessSummary.tsx +36 -0
- package/src/react/primitives/CustomerPortalButton.tsx +50 -0
- package/src/react/primitives/NumberInput.tsx +83 -0
- package/src/react/primitives/OneTimeCheckoutButton.tsx +27 -0
- package/src/react/primitives/OneTimePaymentStatusBadge.tsx +18 -0
- package/src/react/primitives/PaymentWarningBanner.tsx +33 -0
- package/src/react/primitives/PricingCard.tsx +421 -0
- package/src/react/primitives/PricingSection.tsx +129 -0
- package/src/react/primitives/ScheduledChangeBanner.tsx +52 -0
- package/src/react/primitives/SegmentControl.tsx +32 -0
- package/src/react/primitives/SegmentGroup.tsx +53 -0
- package/src/react/primitives/TrialLimitBanner.tsx +32 -0
- package/src/react/shared.ts +138 -0
- package/src/react/widgets/BillingPortal.tsx +56 -0
- package/src/react/widgets/ProductItem.tsx +26 -0
- package/src/react/widgets/ProductRoot.tsx +441 -0
- package/src/react/widgets/SubscriptionItem.tsx +71 -0
- package/src/react/widgets/SubscriptionRoot.tsx +759 -0
- package/src/react/widgets/index.ts +36 -0
- package/src/react/widgets/productGroupContext.ts +10 -0
- package/src/react/widgets/subscriptionContext.ts +10 -0
- package/src/react/widgets/types.ts +179 -0
- package/src/svelte/index.ts +43 -0
- package/src/svelte/primitives/BillingGate.svelte +28 -0
- package/src/svelte/primitives/BillingToggle.svelte +27 -0
- package/src/svelte/primitives/CheckoutButton.svelte +60 -0
- package/src/svelte/primitives/CheckoutSuccessSummary.svelte +34 -0
- package/src/svelte/primitives/CustomerPortalButton.svelte +60 -0
- package/src/svelte/primitives/NumberInput.svelte +71 -0
- package/src/svelte/primitives/OneTimeCheckoutButton.svelte +37 -0
- package/src/svelte/primitives/OneTimePaymentStatusBadge.svelte +20 -0
- package/src/svelte/primitives/PaymentWarningBanner.svelte +30 -0
- package/src/svelte/primitives/PricingCard.svelte +356 -0
- package/src/svelte/primitives/PricingSection.svelte +121 -0
- package/src/svelte/primitives/ScheduledChangeBanner.svelte +46 -0
- package/src/svelte/primitives/SegmentControl.svelte +38 -0
- package/src/svelte/primitives/SegmentGroup.svelte +52 -0
- package/src/svelte/primitives/TrialLimitBanner.svelte +32 -0
- package/src/svelte/primitives/shared.ts +113 -0
- package/src/svelte/svelte.d.ts +6 -0
- package/src/svelte/widgets/BillingPortal.svelte +55 -0
- package/src/svelte/widgets/Product.svelte +35 -0
- package/src/svelte/widgets/ProductRoot.svelte +428 -0
- package/src/svelte/widgets/Subscription.svelte +52 -0
- package/src/svelte/widgets/SubscriptionRoot.svelte +690 -0
- package/src/svelte/widgets/index.ts +36 -0
- package/src/svelte/widgets/productGroupContext.ts +7 -0
- package/src/svelte/widgets/subscriptionContext.ts +7 -0
- package/src/svelte/widgets/types.ts +179 -0
- package/src/tailwind.css +6 -0
- package/src/test.ts +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/svelte/widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,yBAAyB,MAAM,2BAA2B,CAAC;AAClE,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,oBAAoB,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAElE,eAAO,MAAM,YAAY,EAAE,OAAO,yBAAyB,GAAG;IAC5D,IAAI,EAAE,OAAO,yBAAyB,CAAC;IACvC,IAAI,EAAE,OAAO,yBAAyB,CAAC;IACvC,mDAAmD;IACnD,KAAK,EAAE,OAAO,yBAAyB,CAAC;CAKxC,CAAC;AAEH,eAAO,MAAM,OAAO,EAAE,OAAO,oBAAoB,GAAG;IAClD,IAAI,EAAE,OAAO,oBAAoB,CAAC;IAClC,IAAI,EAAE,OAAO,oBAAoB,CAAC;IAClC,8CAA8C;IAC9C,KAAK,EAAE,OAAO,oBAAoB,CAAC;CAKnC,CAAC;AAEH,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import SubscriptionItemComponent from "./Subscription.svelte";
|
|
2
|
+
import SubscriptionRootComponent from "./SubscriptionRoot.svelte";
|
|
3
|
+
import ProductItemComponent from "./Product.svelte";
|
|
4
|
+
import ProductRootComponent from "./ProductRoot.svelte";
|
|
5
|
+
export { default as BillingPortal } from "./BillingPortal.svelte";
|
|
6
|
+
export const Subscription = Object.assign(SubscriptionItemComponent, {
|
|
7
|
+
Root: SubscriptionRootComponent,
|
|
8
|
+
Item: SubscriptionItemComponent,
|
|
9
|
+
Group: SubscriptionRootComponent,
|
|
10
|
+
});
|
|
11
|
+
export const Product = Object.assign(ProductItemComponent, {
|
|
12
|
+
Root: ProductRootComponent,
|
|
13
|
+
Item: ProductItemComponent,
|
|
14
|
+
Group: ProductRootComponent,
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/svelte/widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,yBAAyB,MAAM,2BAA2B,CAAC;AAClE,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,oBAAoB,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,CAAC,MAAM,YAAY,GAKrB,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE;IAC3C,IAAI,EAAE,yBAAyB;IAC/B,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,yBAAyB;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAKhB,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE;IACtC,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,KAAK,EAAE,oBAAoB;CAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ProductItemRegistration } from "./types.js";
|
|
2
|
+
export type ProductGroupContextValue = {
|
|
3
|
+
registerItem: (item: ProductItemRegistration) => () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const PRODUCT_GROUP_CONTEXT_KEY: unique symbol;
|
|
6
|
+
//# sourceMappingURL=productGroupContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productGroupContext.d.ts","sourceRoot":"","sources":["../../../src/svelte/widgets/productGroupContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,MAAM,IAAI,CAAC;CAC7D,CAAC;AAEF,eAAO,MAAM,yBAAyB,eAAwC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productGroupContext.js","sourceRoot":"","sources":["../../../src/svelte/widgets/productGroupContext.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SubscriptionPlanRegistration } from "./types.js";
|
|
2
|
+
export type SubscriptionContextValue = {
|
|
3
|
+
registerPlan: (plan: SubscriptionPlanRegistration) => () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare const SUBSCRIPTION_CONTEXT_KEY: unique symbol;
|
|
6
|
+
//# sourceMappingURL=subscriptionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionContext.d.ts","sourceRoot":"","sources":["../../../src/svelte/widgets/subscriptionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,CAAC,IAAI,EAAE,4BAA4B,KAAK,MAAM,IAAI,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,wBAAwB,eAAuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionContext.js","sourceRoot":"","sources":["../../../src/svelte/widgets/subscriptionContext.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { FunctionReference } from "convex/server";
|
|
2
|
+
import type { BillingSnapshot, RecurringCycle } from "../../core/types.js";
|
|
3
|
+
export type { CheckoutIntent } from "../../core/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* UI-side permission flags for billing widgets.
|
|
6
|
+
* Controls which buttons are enabled/visible. This is **cosmetic gating only** —
|
|
7
|
+
* enforce real permissions server-side in your Convex functions.
|
|
8
|
+
*
|
|
9
|
+
* When a permission is `false`, the corresponding button renders as disabled.
|
|
10
|
+
* When omitted or `undefined`, all actions default to enabled.
|
|
11
|
+
*/
|
|
12
|
+
export type BillingPermissions = {
|
|
13
|
+
/** Allow creating new checkouts (subscribe / buy buttons). */
|
|
14
|
+
canCheckout?: boolean;
|
|
15
|
+
/** Allow switching plans or billing intervals. */
|
|
16
|
+
canChangeSubscription?: boolean;
|
|
17
|
+
/** Allow cancelling the active subscription. */
|
|
18
|
+
canCancelSubscription?: boolean;
|
|
19
|
+
/** Allow resuming a paused or scheduled-cancel subscription. */
|
|
20
|
+
canResumeSubscription?: boolean;
|
|
21
|
+
/** Allow changing the seat count on seat-based plans. */
|
|
22
|
+
canUpdateSeats?: boolean;
|
|
23
|
+
/** Allow opening the Creem customer billing portal. */
|
|
24
|
+
canAccessPortal?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Backend function references for connected billing widgets.
|
|
28
|
+
* Created once in your layout/page and passed to `<Subscription.Root>`, `<Product.Root>`, and `<BillingPortal>`.
|
|
29
|
+
*
|
|
30
|
+
* All references point to Convex functions generated by `creem.api({ resolve })`
|
|
31
|
+
* or your own custom wrappers.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const billingApi: ConnectedBillingApi = {
|
|
36
|
+
* uiModel: api.billing.uiModel,
|
|
37
|
+
* checkouts: { create: api.billing.checkoutsCreate },
|
|
38
|
+
* subscriptions: {
|
|
39
|
+
* update: api.billing.subscriptionsUpdate,
|
|
40
|
+
* cancel: api.billing.subscriptionsCancel,
|
|
41
|
+
* resume: api.billing.subscriptionsResume,
|
|
42
|
+
* },
|
|
43
|
+
* customers: { portalUrl: api.billing.customersPortalUrl },
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export type ConnectedBillingApi = {
|
|
48
|
+
/** Query that returns the `ConnectedBillingModel` — called by all widgets to load billing state. */
|
|
49
|
+
uiModel: FunctionReference<"query">;
|
|
50
|
+
/** Checkout actions. */
|
|
51
|
+
checkouts: {
|
|
52
|
+
/** Create a checkout session and return `{ url }`. */
|
|
53
|
+
create: FunctionReference<"action">;
|
|
54
|
+
};
|
|
55
|
+
/** Subscription mutation references. All optional — omit to hide the corresponding UI controls. */
|
|
56
|
+
subscriptions?: {
|
|
57
|
+
/** Plan switch or seat update mutation. */
|
|
58
|
+
update?: FunctionReference<"mutation">;
|
|
59
|
+
/** Cancel subscription mutation. */
|
|
60
|
+
cancel?: FunctionReference<"mutation">;
|
|
61
|
+
/** Resume paused/scheduled-cancel subscription mutation. */
|
|
62
|
+
resume?: FunctionReference<"mutation">;
|
|
63
|
+
};
|
|
64
|
+
/** Customer actions. */
|
|
65
|
+
customers?: {
|
|
66
|
+
/** Action that returns `{ url }` for the Creem billing portal. */
|
|
67
|
+
portalUrl?: FunctionReference<"action">;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/** Product data as returned by the billing model query. Mirrors the Convex DB product schema. */
|
|
71
|
+
export type ConnectedProduct = {
|
|
72
|
+
id: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
price?: number;
|
|
76
|
+
currency?: string;
|
|
77
|
+
billingType?: string;
|
|
78
|
+
billingPeriod?: string;
|
|
79
|
+
status?: string;
|
|
80
|
+
taxMode?: string;
|
|
81
|
+
taxCategory?: string;
|
|
82
|
+
imageUrl?: string;
|
|
83
|
+
features?: Array<{
|
|
84
|
+
id: string;
|
|
85
|
+
description: string;
|
|
86
|
+
}>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Complete billing state returned by the `uiModel` query.
|
|
90
|
+
* Consumed internally by all connected widgets — you typically don't need to access this directly.
|
|
91
|
+
*/
|
|
92
|
+
export type ConnectedBillingModel = {
|
|
93
|
+
/** Authenticated user info, or `null` when unauthenticated (public pricing page). */
|
|
94
|
+
user: {
|
|
95
|
+
_id: string;
|
|
96
|
+
email: string;
|
|
97
|
+
isFree?: boolean;
|
|
98
|
+
isTrialing?: boolean;
|
|
99
|
+
trialEnd?: string | null;
|
|
100
|
+
} | null;
|
|
101
|
+
/** Resolved billing state (plan, status, available actions). `null` when unauthenticated. */
|
|
102
|
+
billingSnapshot: BillingSnapshot | null;
|
|
103
|
+
/** All synced products from the Creem dashboard. */
|
|
104
|
+
allProducts: ConnectedProduct[];
|
|
105
|
+
/** Product IDs the entity has purchased (one-time orders). */
|
|
106
|
+
ownedProductIds: string[];
|
|
107
|
+
/** Product ID of the current subscription, or `null`. */
|
|
108
|
+
subscriptionProductId: string | null;
|
|
109
|
+
/** All active subscriptions with full details. */
|
|
110
|
+
activeSubscriptions?: Array<{
|
|
111
|
+
id: string;
|
|
112
|
+
productId: string;
|
|
113
|
+
status: string;
|
|
114
|
+
cancelAtPeriodEnd: boolean;
|
|
115
|
+
currentPeriodEnd: string | null;
|
|
116
|
+
currentPeriodStart: string;
|
|
117
|
+
seats: number | null;
|
|
118
|
+
recurringInterval: string | null;
|
|
119
|
+
trialEnd?: string | null;
|
|
120
|
+
}>;
|
|
121
|
+
/** Whether this entity has a Creem customer record (needed for billing portal). */
|
|
122
|
+
hasCreemCustomer?: boolean;
|
|
123
|
+
/** Reserved for future billing policy data. */
|
|
124
|
+
policy?: unknown;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Plan type for `<Subscription.Item>`.
|
|
128
|
+
* - `"free"` — free tier, no checkout
|
|
129
|
+
* - `"single"` — standard paid plan (flat pricing)
|
|
130
|
+
* - `"seat-based"` — per-seat pricing with optional seat picker
|
|
131
|
+
* - `"enterprise"` — "Contact sales" CTA, no checkout
|
|
132
|
+
*/
|
|
133
|
+
export type SubscriptionPlanType = "free" | "single" | "seat-based" | "enterprise";
|
|
134
|
+
export type SubscriptionPlanRegistration = {
|
|
135
|
+
planId: string;
|
|
136
|
+
type: SubscriptionPlanType;
|
|
137
|
+
title?: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
contactUrl?: string;
|
|
140
|
+
recommended?: boolean;
|
|
141
|
+
productIds?: Partial<Record<RecurringCycle, string>>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Product type for `<Product.Item>`.
|
|
145
|
+
* - `"one-time"` — purchased once, shows "Owned" badge after purchase
|
|
146
|
+
* - `"recurring"` — can be purchased multiple times (consumable), no "Owned" badge
|
|
147
|
+
*/
|
|
148
|
+
export type ProductType = "one-time" | "recurring";
|
|
149
|
+
/**
|
|
150
|
+
* Upgrade path rule for `<Product.Root transition={[...]}>`.
|
|
151
|
+
* - `"direct"` — checkout uses the target product directly
|
|
152
|
+
* - `"via_product"` — checkout uses a dedicated upgrade product (delta pricing)
|
|
153
|
+
*/
|
|
154
|
+
export type Transition = {
|
|
155
|
+
from: string;
|
|
156
|
+
to: string;
|
|
157
|
+
kind: "direct";
|
|
158
|
+
} | {
|
|
159
|
+
from: string;
|
|
160
|
+
to: string;
|
|
161
|
+
kind: "via_product";
|
|
162
|
+
/** Creem product ID for the upgrade (e.g. a delta-priced "Basic → Premium" product). */
|
|
163
|
+
viaProductId: string;
|
|
164
|
+
};
|
|
165
|
+
export type ProductItemRegistration = {
|
|
166
|
+
productId: string;
|
|
167
|
+
type: ProductType;
|
|
168
|
+
title?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/svelte/widgets/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/svelte/widgets/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mmailaender/convex-creem",
|
|
3
|
+
"description": "A Creem component for Convex.",
|
|
4
|
+
"repository": "github:mmailaender/convex-creem",
|
|
5
|
+
"homepage": "https://github.com/mmailaender/convex-creem#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/mmailaender/convex-creem/issues"
|
|
8
|
+
},
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"convex",
|
|
13
|
+
"component",
|
|
14
|
+
"creem",
|
|
15
|
+
"stripe",
|
|
16
|
+
"subscription",
|
|
17
|
+
"billing",
|
|
18
|
+
"payments",
|
|
19
|
+
"checkout"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./src/client/polyfill.ts",
|
|
24
|
+
"./dist/client/polyfill.js"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"exports": {
|
|
31
|
+
"./package.json": "./package.json",
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/client/index.d.ts",
|
|
34
|
+
"default": "./dist/client/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./react": {
|
|
37
|
+
"types": "./dist/react/index.d.ts",
|
|
38
|
+
"default": "./dist/react/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./svelte": {
|
|
41
|
+
"types": "./dist/svelte/index.d.ts",
|
|
42
|
+
"svelte": "./dist/svelte/index.js",
|
|
43
|
+
"default": "./dist/svelte/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./styles": "./src/library.css",
|
|
46
|
+
"./test": "./src/test.ts",
|
|
47
|
+
"./_generated/component.js": {
|
|
48
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./convex.config": {
|
|
51
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
52
|
+
"default": "./dist/component/convex.config.js"
|
|
53
|
+
},
|
|
54
|
+
"./convex.config.js": {
|
|
55
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
56
|
+
"default": "./dist/component/convex.config.js"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@ark-ui/react": "^5.31.0",
|
|
61
|
+
"@ark-ui/svelte": "^5.16.0",
|
|
62
|
+
"convex": "^1.29.0",
|
|
63
|
+
"convex-svelte": "^0.0.12",
|
|
64
|
+
"creem": "^1.3.6",
|
|
65
|
+
"react": "^18 || ^19",
|
|
66
|
+
"react-dom": "^18 || ^19",
|
|
67
|
+
"svelte": "^5"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"@ark-ui/react": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@ark-ui/svelte": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"convex-svelte": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"react": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"react-dom": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"svelte": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@ark-ui/react": "^5.31.0",
|
|
91
|
+
"@ark-ui/svelte": "^5.16.0",
|
|
92
|
+
"@arethetypeswrong/cli": "0.18.2",
|
|
93
|
+
"@convex-dev/eslint-plugin": "1.1.1",
|
|
94
|
+
"@edge-runtime/vm": "5.0.0",
|
|
95
|
+
"@eslint/eslintrc": "3.3.4",
|
|
96
|
+
"@eslint/js": "9.39.2",
|
|
97
|
+
"@lucide/svelte": "^0.575.0",
|
|
98
|
+
"@radix-ui/react-dialog": "1.1.15",
|
|
99
|
+
"@radix-ui/react-icons": "1.3.2",
|
|
100
|
+
"@radix-ui/react-separator": "1.1.8",
|
|
101
|
+
"@radix-ui/react-slot": "1.2.4",
|
|
102
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
103
|
+
"@tailwindcss/postcss": "4.2.1",
|
|
104
|
+
"@tailwindcss/vite": "4.2.1",
|
|
105
|
+
"@tanstack/react-table": "8.21.3",
|
|
106
|
+
"@types/node": "20.19.35",
|
|
107
|
+
"@types/react": "19.2.14",
|
|
108
|
+
"@types/react-dom": "19.2.3",
|
|
109
|
+
"@vitejs/plugin-react": "5.1.4",
|
|
110
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
111
|
+
"autoprefixer": "10.4.27",
|
|
112
|
+
"chokidar-cli": "3.0.0",
|
|
113
|
+
"class-variance-authority": "0.7.1",
|
|
114
|
+
"clsx": "2.1.1",
|
|
115
|
+
"concurrently": "^9.2.1",
|
|
116
|
+
"convex": "1.32.0",
|
|
117
|
+
"convex-helpers": "0.1.114",
|
|
118
|
+
"convex-svelte": "^0.0.12",
|
|
119
|
+
"convex-test": "0.0.41",
|
|
120
|
+
"cpy-cli": "7.0.0",
|
|
121
|
+
"creem": "^1.3.6",
|
|
122
|
+
"eslint": "9.39.3",
|
|
123
|
+
"eslint-plugin-react": "7.37.5",
|
|
124
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
125
|
+
"eslint-plugin-react-refresh": "0.5.2",
|
|
126
|
+
"eslint-plugin-svelte": "^3.15.0",
|
|
127
|
+
"globals": "17.3.0",
|
|
128
|
+
"jsdom": "^28.1.0",
|
|
129
|
+
"lucide-react": "0.575.0",
|
|
130
|
+
"next-themes": "0.4.6",
|
|
131
|
+
"path-exists-cli": "2.0.0",
|
|
132
|
+
"pkg-pr-new": "0.0.65",
|
|
133
|
+
"postcss": "8.5.6",
|
|
134
|
+
"prettier": "3.8.1",
|
|
135
|
+
"react": "19.2.4",
|
|
136
|
+
"react-dom": "19.2.4",
|
|
137
|
+
"remeda": "2.33.6",
|
|
138
|
+
"svelte-eslint-parser": "^1.5.1",
|
|
139
|
+
"tailwind-merge": "3.5.0",
|
|
140
|
+
"tailwindcss": "4.2.1",
|
|
141
|
+
"tw-animate-css": "1.4.0",
|
|
142
|
+
"typescript": "5.9.3",
|
|
143
|
+
"typescript-eslint": "8.56.1",
|
|
144
|
+
"use-debounce": "10.1.0",
|
|
145
|
+
"vite": "7.3.1",
|
|
146
|
+
"vitest": "4.0.18",
|
|
147
|
+
"wrangler": "4.69.0"
|
|
148
|
+
},
|
|
149
|
+
"types": "./dist/client/index.d.ts",
|
|
150
|
+
"module": "./dist/client/index.js",
|
|
151
|
+
"dependencies": {
|
|
152
|
+
"@fontsource/inter": "^5.2.8",
|
|
153
|
+
"buffer": "^6.0.3",
|
|
154
|
+
"convex-helpers": "^0.1.63",
|
|
155
|
+
"marked": "^17.0.3",
|
|
156
|
+
"remeda": "^2.20.2",
|
|
157
|
+
"standardwebhooks": "^1.0.0"
|
|
158
|
+
},
|
|
159
|
+
"scripts": {
|
|
160
|
+
"dev:react": "concurrently --kill-others --prefix-colors 'blue,yellow,magenta' --names 'frontend,backend,build' 'pnpm dev:frontend:react' 'pnpm dev:backend' 'pnpm dev:build'",
|
|
161
|
+
"dev:svelte": "concurrently --kill-others --prefix-colors 'blue,yellow,magenta' --names 'frontend,backend,build' 'pnpm dev:frontend:svelte' 'pnpm dev:backend' 'pnpm dev:build'",
|
|
162
|
+
"dev:backend": "convex dev --typecheck-components",
|
|
163
|
+
"dev:frontend:react": "cd example-react && vite --clearScreen false",
|
|
164
|
+
"dev:frontend:svelte": "vite --clearScreen false --config example-svelte/vite.config.ts",
|
|
165
|
+
"dev:build": "chokidar 'tsconfig*.json' 'src/**/*.ts' 'src/**/*.tsx' 'src/**/*.svelte' -i '**/*.test.ts' -i '**/*.test.tsx' -c 'npx convex codegen --component-dir ./src/component && pnpm build' --initial",
|
|
166
|
+
"predev": "convex dev --skip-push",
|
|
167
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
168
|
+
"build": "tsc --project ./tsconfig.build.json && cpy '**/*.svelte' '../../dist/svelte/' --cwd=src/svelte",
|
|
169
|
+
"typecheck": "tsc --noEmit && tsc -p example-react && tsc -p example-svelte",
|
|
170
|
+
"format": "prettier --write .",
|
|
171
|
+
"lint": "eslint .",
|
|
172
|
+
"all": "concurrently --kill-others --prefix-colors 'blue,yellow,magenta,cyan' --names 'frontend,backend,build,test' 'pnpm dev:frontend' 'pnpm dev:backend' 'pnpm dev:build' 'pnpm test:watch'",
|
|
173
|
+
"test": "vitest run --typecheck",
|
|
174
|
+
"test:watch": "vitest --typecheck --clearScreen false",
|
|
175
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
176
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
177
|
+
"preversion": "pnpm clean && pnpm ci && pnpm run build && concurrently --kill-others --names 'test,lint,typecheck' --prefix-colors 'blue,yellow,magenta' 'pnpm test' 'pnpm lint' 'pnpm typecheck'",
|
|
178
|
+
"alpha": "pnpm version prerelease --preid alpha && pnpm publish --tag alpha && git push --follow-tags",
|
|
179
|
+
"release": "pnpm version patch && pnpm publish && git push --follow-tags",
|
|
180
|
+
"version": "vim -c 'normal o' -c 'normal o## '$npm_package_version CHANGELOG.md && prettier -w CHANGELOG.md && git add CHANGELOG.md"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
getEntityId,
|
|
4
|
+
lowerCaseHeaders,
|
|
5
|
+
toHex,
|
|
6
|
+
constantTimeEqual,
|
|
7
|
+
normalizeSignature,
|
|
8
|
+
} from "./helpers.js";
|
|
9
|
+
|
|
10
|
+
describe("getEntityId", () => {
|
|
11
|
+
it("returns a string value directly", () => {
|
|
12
|
+
expect(getEntityId("user_123")).toBe("user_123");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns null for null/undefined", () => {
|
|
16
|
+
expect(getEntityId(null)).toBeNull();
|
|
17
|
+
expect(getEntityId(undefined)).toBeNull();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("extracts id from an object with a string id", () => {
|
|
21
|
+
expect(getEntityId({ id: "cust_abc" })).toBe("cust_abc");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns null for an object with a non-string id", () => {
|
|
25
|
+
expect(getEntityId({ id: 42 })).toBeNull();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("returns null for an object without id", () => {
|
|
29
|
+
expect(getEntityId({ name: "test" })).toBeNull();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("returns null for non-object non-string values", () => {
|
|
33
|
+
expect(getEntityId(42)).toBeNull();
|
|
34
|
+
expect(getEntityId(true)).toBeNull();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("returns empty string if value is empty string", () => {
|
|
38
|
+
expect(getEntityId("")).toBe("");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("lowerCaseHeaders", () => {
|
|
43
|
+
it("lowercases all header keys", () => {
|
|
44
|
+
const result = lowerCaseHeaders({
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
"X-Custom-Header": "value",
|
|
47
|
+
});
|
|
48
|
+
expect(result).toEqual({
|
|
49
|
+
"content-type": "application/json",
|
|
50
|
+
"x-custom-header": "value",
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("preserves header values", () => {
|
|
55
|
+
const result = lowerCaseHeaders({ "Webhook-Signature": "ABC123" });
|
|
56
|
+
expect(result["webhook-signature"]).toBe("ABC123");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("handles empty object", () => {
|
|
60
|
+
expect(lowerCaseHeaders({})).toEqual({});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("handles already-lowercase keys", () => {
|
|
64
|
+
const result = lowerCaseHeaders({ "webhook-id": "123" });
|
|
65
|
+
expect(result["webhook-id"]).toBe("123");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("toHex", () => {
|
|
70
|
+
it("converts bytes to hex string", () => {
|
|
71
|
+
expect(toHex(new Uint8Array([0, 1, 15, 16, 255]))).toBe("00010f10ff");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("returns empty string for empty array", () => {
|
|
75
|
+
expect(toHex(new Uint8Array([]))).toBe("");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("pads single-digit hex values", () => {
|
|
79
|
+
expect(toHex(new Uint8Array([0]))).toBe("00");
|
|
80
|
+
expect(toHex(new Uint8Array([5]))).toBe("05");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("constantTimeEqual", () => {
|
|
85
|
+
it("returns true for identical strings", () => {
|
|
86
|
+
expect(constantTimeEqual("abc", "abc")).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("returns false for different strings of same length", () => {
|
|
90
|
+
expect(constantTimeEqual("abc", "abd")).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("returns false for different lengths", () => {
|
|
94
|
+
expect(constantTimeEqual("ab", "abc")).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("returns true for empty strings", () => {
|
|
98
|
+
expect(constantTimeEqual("", "")).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("returns false when one is empty", () => {
|
|
102
|
+
expect(constantTimeEqual("", "a")).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("handles long hex strings (typical HMAC comparison)", () => {
|
|
106
|
+
const sig =
|
|
107
|
+
"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2";
|
|
108
|
+
expect(constantTimeEqual(sig, sig)).toBe(true);
|
|
109
|
+
const tampered = sig.slice(0, -1) + "0";
|
|
110
|
+
expect(constantTimeEqual(sig, tampered)).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("normalizeSignature", () => {
|
|
115
|
+
it("strips sha256= prefix and lowercases", () => {
|
|
116
|
+
expect(normalizeSignature("sha256=ABCDEF")).toBe("abcdef");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("lowercases when no prefix", () => {
|
|
120
|
+
expect(normalizeSignature("ABCDEF")).toBe("abcdef");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("trims whitespace", () => {
|
|
124
|
+
expect(normalizeSignature(" sha256=ABC ")).toBe("abc");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("handles empty string", () => {
|
|
128
|
+
expect(normalizeSignature("")).toBe("");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("handles sha256= prefix with mixed case hex", () => {
|
|
132
|
+
expect(normalizeSignature("sha256=aAbBcC")).toBe("aabbcc");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("does not strip sha256 without = sign", () => {
|
|
136
|
+
// "sha256abc" should NOT strip anything — the prefix is "sha256="
|
|
137
|
+
expect(normalizeSignature("sha256abc")).toBe("sha256abc");
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure utility functions extracted from the Creem client.
|
|
3
|
+
* No external dependencies — fully unit-testable.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Extract an entity ID from a string or `{ id: string }` object. Returns `null` if the value is not a valid entity reference. */
|
|
7
|
+
export const getEntityId = (value: unknown): string | null => {
|
|
8
|
+
if (typeof value === "string") {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
if (value && typeof value === "object" && "id" in value) {
|
|
12
|
+
const id = (value as { id?: unknown }).id;
|
|
13
|
+
if (typeof id === "string") {
|
|
14
|
+
return id;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Lowercase all header keys in a record (for case-insensitive header lookup). */
|
|
21
|
+
export const lowerCaseHeaders = (headers: Record<string, string>) =>
|
|
22
|
+
Object.fromEntries(
|
|
23
|
+
Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/** Convert a `Uint8Array` to a lowercase hex string. */
|
|
27
|
+
export const toHex = (bytes: Uint8Array) =>
|
|
28
|
+
Array.from(bytes)
|
|
29
|
+
.map((value) => value.toString(16).padStart(2, "0"))
|
|
30
|
+
.join("");
|
|
31
|
+
|
|
32
|
+
/** Constant-time string comparison to prevent timing attacks on signature verification. */
|
|
33
|
+
export const constantTimeEqual = (a: string, b: string) => {
|
|
34
|
+
if (a.length !== b.length) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
let result = 0;
|
|
38
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
39
|
+
result |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
40
|
+
}
|
|
41
|
+
return result === 0;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Strip the `sha256=` prefix from a webhook signature and lowercase it for comparison. */
|
|
45
|
+
export const normalizeSignature = (signature: string) => {
|
|
46
|
+
const trimmed = signature.trim();
|
|
47
|
+
if (trimmed.startsWith("sha256=")) {
|
|
48
|
+
return trimmed.slice("sha256=".length).toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
return trimmed.toLowerCase();
|
|
51
|
+
};
|