autumn-js 0.0.83 → 0.0.92-beta.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.
- package/dist/libraries/backend/better-auth.d.mts +764 -4
- package/dist/libraries/backend/better-auth.d.ts +764 -4
- package/dist/libraries/backend/better-auth.js +341 -19184
- package/dist/libraries/backend/better-auth.mjs +232 -19135
- package/dist/libraries/backend/{chunk-XGB3TDIC.mjs → chunk-6DZX6EAA.mjs} +0 -5
- package/dist/libraries/backend/{chunk-J3QM5KFT.mjs → chunk-7QSJB2C5.mjs} +1 -1
- package/dist/libraries/backend/{chunk-UJQBHXII.mjs → chunk-FCEB2GBS.mjs} +1 -1
- package/dist/libraries/backend/{chunk-A46IKTLH.mjs → chunk-JPNRDMMC.mjs} +1 -1
- package/dist/libraries/backend/{chunk-52OTZ4SQ.mjs → chunk-NTFR7Z2G.mjs} +8 -8
- package/dist/libraries/backend/{chunk-DG3FZZQH.mjs → chunk-U7335VZS.mjs} +1 -1
- package/dist/libraries/backend/{chunk-VCEQ3QBX.mjs → chunk-V6M7KRGN.mjs} +57 -0
- package/dist/libraries/backend/{chunk-WDRHQJKV.mjs → chunk-VFTHGJ5N.mjs} +1 -1
- package/dist/libraries/backend/constants.mjs +1 -1
- package/dist/libraries/backend/convex.d.mts +10 -0
- package/dist/libraries/backend/convex.d.ts +10 -0
- package/dist/libraries/backend/convex.js +1045 -0
- package/dist/libraries/backend/convex.mjs +80 -0
- package/dist/libraries/backend/express.d.mts +2 -1
- package/dist/libraries/backend/express.d.ts +2 -1
- package/dist/libraries/backend/express.js +57 -0
- package/dist/libraries/backend/express.mjs +8 -8
- package/dist/libraries/backend/fastify.js +57 -0
- package/dist/libraries/backend/fastify.mjs +8 -8
- package/dist/libraries/backend/hono.js +57 -0
- package/dist/libraries/backend/hono.mjs +8 -8
- package/dist/libraries/backend/next.js +59 -2
- package/dist/libraries/backend/next.mjs +8 -8
- package/dist/libraries/backend/react-router.js +57 -0
- package/dist/libraries/backend/react-router.mjs +8 -8
- package/dist/libraries/backend/{referralTypes-BZ4WOVK5.d.ts → referralTypes-BAYl5TR1.d.ts} +101 -36
- package/dist/libraries/backend/{referralTypes-C6ao6j-_.d.mts → referralTypes-ecz_wESO.d.mts} +101 -36
- package/dist/libraries/backend/remix_dep.js +57 -0
- package/dist/libraries/backend/remix_dep.mjs +8 -8
- package/dist/libraries/backend/routes/backendRouter.js +57 -0
- package/dist/libraries/backend/routes/backendRouter.mjs +8 -8
- package/dist/libraries/backend/routes/entityRoutes.js +57 -0
- package/dist/libraries/backend/routes/entityRoutes.mjs +4 -4
- package/dist/libraries/backend/routes/genRoutes.js +57 -0
- package/dist/libraries/backend/routes/genRoutes.mjs +4 -4
- package/dist/libraries/backend/routes/productRoutes.js +57 -0
- package/dist/libraries/backend/routes/productRoutes.mjs +4 -4
- package/dist/libraries/backend/routes/referralRoutes.js +57 -0
- package/dist/libraries/backend/routes/referralRoutes.mjs +4 -4
- package/dist/libraries/backend/schemas/zod.d.mts +208 -0
- package/dist/libraries/backend/schemas/zod.d.ts +208 -0
- package/dist/libraries/backend/schemas/zod.js +100 -0
- package/dist/libraries/backend/schemas/zod.mjs +69 -0
- package/dist/libraries/backend/supabase.js +57 -0
- package/dist/libraries/backend/supabase.mjs +8 -8
- package/dist/libraries/backend/tanstack.js +57 -0
- package/dist/libraries/backend/tanstack.mjs +8 -8
- package/dist/libraries/backend/utils/backendRes.js +57 -0
- package/dist/libraries/backend/utils/backendRes.mjs +2 -2
- package/dist/libraries/backend/utils/logBackendErrors.mjs +1 -1
- package/dist/libraries/backend/utils/secretKeyCheck.mjs +1 -1
- package/dist/libraries/backend/utils/withAuth.d.mts +2 -1
- package/dist/libraries/backend/utils/withAuth.d.ts +2 -1
- package/dist/libraries/backend/utils/withAuth.js +57 -0
- package/dist/libraries/backend/utils/withAuth.mjs +3 -3
- package/dist/libraries/react/AutumnContext.d.mts +7 -6
- package/dist/libraries/react/AutumnContext.d.ts +7 -6
- package/dist/libraries/react/AutumnContext.js +59 -4
- package/dist/libraries/react/AutumnContext.mjs +2 -2
- package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -7
- package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -7
- package/dist/libraries/react/BaseAutumnProvider.js +149 -32
- package/dist/libraries/react/BaseAutumnProvider.mjs +7 -7
- package/dist/libraries/react/{ReactAutumnClient-DS-MPWXt.d.ts → ReactAutumnClient-BTNcA_3b.d.ts} +59 -11
- package/dist/libraries/react/{ReactAutumnClient-Cj2h9TXJ.d.mts → ReactAutumnClient-BiipnfQn.d.mts} +59 -11
- package/dist/libraries/react/ReactAutumnProvider.d.mts +3 -3
- package/dist/libraries/react/ReactAutumnProvider.d.ts +3 -3
- package/dist/libraries/react/ReactAutumnProvider.js +160 -46
- package/dist/libraries/react/ReactAutumnProvider.mjs +8 -8
- package/dist/libraries/react/{chunk-JFXBUWKA.mjs → chunk-3JJC2VU5.mjs} +22 -5
- package/dist/libraries/react/{chunk-CQMTU2M4.mjs → chunk-3WP2MI55.mjs} +25 -6
- package/dist/libraries/react/{chunk-6ULRUGQO.mjs → chunk-4AYEAAQU.mjs} +2 -2
- package/dist/libraries/react/{chunk-UO2PX7P3.mjs → chunk-67Y4DFV2.mjs} +14 -17
- package/dist/libraries/react/{chunk-EWMKQDQ6.mjs → chunk-6JOSRG5Z.mjs} +2 -2
- package/dist/libraries/react/{chunk-JOY6LN3M.mjs → chunk-CHQRTGXF.mjs} +25 -7
- package/dist/libraries/react/{chunk-KVGD37VB.mjs → chunk-G3XBGOHR.mjs} +4 -6
- package/dist/libraries/react/{chunk-S4VDT54B.mjs → chunk-GK75OJJJ.mjs} +2 -2
- package/dist/libraries/react/{chunk-MH2YTNJL.mjs → chunk-ITN754AD.mjs} +3 -5
- package/dist/libraries/react/{chunk-Z7MRLSU3.mjs → chunk-LKBUMRHE.mjs} +9 -9
- package/dist/libraries/react/{chunk-UDRQNZZS.mjs → chunk-QAHVMSK4.mjs} +57 -0
- package/dist/libraries/react/{chunk-SCT4E6YW.mjs → chunk-SJAAUTL2.mjs} +2 -2
- package/dist/libraries/react/{chunk-L55GLFAX.mjs → chunk-TBKIB6DH.mjs} +2 -2
- package/dist/libraries/react/{chunk-GEIECHWI.mjs → chunk-TINC2IR4.mjs} +24 -14
- package/dist/libraries/react/{chunk-OWFX3JFF.mjs → chunk-WVKYZYFT.mjs} +14 -0
- package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -5
- package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -5
- package/dist/libraries/react/client/ReactAutumnClient.js +57 -0
- package/dist/libraries/react/client/ReactAutumnClient.mjs +1 -1
- package/dist/libraries/react/client/clientCompMethods.d.mts +6 -5
- package/dist/libraries/react/client/clientCompMethods.d.ts +6 -5
- package/dist/libraries/react/client/clientCusMethods.d.mts +6 -5
- package/dist/libraries/react/client/clientCusMethods.d.ts +6 -5
- package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -5
- package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -5
- package/dist/libraries/react/client/clientGenMethods.d.mts +6 -5
- package/dist/libraries/react/client/clientGenMethods.d.ts +6 -5
- package/dist/libraries/react/client/clientProdMethods.d.mts +6 -5
- package/dist/libraries/react/client/clientProdMethods.d.ts +6 -5
- package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -4
- package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -4
- package/dist/libraries/react/client/types/clientGenTypes.d.mts +136 -41
- package/dist/libraries/react/client/types/clientGenTypes.d.ts +136 -41
- package/dist/libraries/react/client/types/clientGenTypes.js +62 -0
- package/dist/libraries/react/client/types/clientGenTypes.mjs +52 -0
- package/dist/libraries/react/client/types/clientReferralTypes.d.mts +17 -5
- package/dist/libraries/react/client/types/clientReferralTypes.d.ts +17 -5
- package/dist/libraries/react/client/types/clientReferralTypes.js +20 -0
- package/dist/libraries/react/client/types/clientReferralTypes.mjs +13 -0
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.mts +2 -1
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.ts +2 -1
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.js +164 -29
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.mjs +17 -17
- package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.mts +2 -1
- package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.ts +2 -1
- package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.mts +2 -1
- package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.ts +2 -1
- package/dist/libraries/react/components/check-dialog/lib/check-content.d.mts +2 -1
- package/dist/libraries/react/components/check-dialog/lib/check-content.d.ts +2 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +2 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +2 -1
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +163 -30
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +17 -17
- package/dist/libraries/react/components/ui/button.d.mts +1 -1
- package/dist/libraries/react/components/ui/button.d.ts +1 -1
- package/dist/libraries/react/{cusTypes-CO4FwQ_s.d.ts → cusTypes-Bf1qr9iE.d.mts} +29 -9
- package/dist/libraries/react/{cusTypes-CO4FwQ_s.d.mts → cusTypes-Bf1qr9iE.d.ts} +29 -9
- package/dist/libraries/react/{entTypes-DPTZOorv.d.mts → entTypes-CscyyE1A.d.mts} +1 -1
- package/dist/libraries/react/{entTypes-UxZ5bRqE.d.ts → entTypes-O8YXxhrA.d.ts} +1 -1
- package/dist/libraries/react/hooks/handleAllowed.d.mts +4 -3
- package/dist/libraries/react/hooks/handleAllowed.d.ts +4 -3
- package/dist/libraries/react/hooks/handleAllowed.js +22 -5
- package/dist/libraries/react/hooks/handleAllowed.mjs +1 -1
- package/dist/libraries/react/hooks/useAutumn.d.mts +6 -5
- package/dist/libraries/react/hooks/useAutumn.d.ts +6 -5
- package/dist/libraries/react/hooks/useAutumn.js +105 -13
- package/dist/libraries/react/hooks/useAutumn.mjs +5 -5
- package/dist/libraries/react/hooks/useAutumnBase.d.mts +9 -8
- package/dist/libraries/react/hooks/useAutumnBase.d.ts +9 -8
- package/dist/libraries/react/hooks/useAutumnBase.js +105 -13
- package/dist/libraries/react/hooks/useAutumnBase.mjs +4 -4
- package/dist/libraries/react/hooks/useCustomer.d.mts +7 -5
- package/dist/libraries/react/hooks/useCustomer.d.ts +7 -5
- package/dist/libraries/react/hooks/useCustomer.js +148 -29
- package/dist/libraries/react/hooks/useCustomer.mjs +7 -7
- package/dist/libraries/react/hooks/useCustomerBase.d.mts +8 -4
- package/dist/libraries/react/hooks/useCustomerBase.d.ts +8 -4
- package/dist/libraries/react/hooks/useCustomerBase.js +148 -29
- package/dist/libraries/react/hooks/useCustomerBase.mjs +6 -6
- package/dist/libraries/react/hooks/useEntity.d.mts +7 -5
- package/dist/libraries/react/hooks/useEntity.d.ts +7 -5
- package/dist/libraries/react/hooks/useEntity.js +127 -18
- package/dist/libraries/react/hooks/useEntity.mjs +7 -7
- package/dist/libraries/react/hooks/useEntityBase.d.mts +7 -7
- package/dist/libraries/react/hooks/useEntityBase.d.ts +7 -7
- package/dist/libraries/react/hooks/useEntityBase.js +127 -18
- package/dist/libraries/react/hooks/useEntityBase.mjs +6 -6
- package/dist/libraries/react/hooks/usePricingTable.d.mts +2 -1
- package/dist/libraries/react/hooks/usePricingTable.d.ts +2 -1
- package/dist/libraries/react/hooks/usePricingTable.js +82 -9
- package/dist/libraries/react/hooks/usePricingTable.mjs +4 -4
- package/dist/libraries/react/hooks/usePricingTableBase.d.mts +7 -6
- package/dist/libraries/react/hooks/usePricingTableBase.d.ts +7 -6
- package/dist/libraries/react/hooks/usePricingTableBase.js +82 -9
- package/dist/libraries/react/hooks/usePricingTableBase.mjs +3 -3
- package/dist/libraries/react/hooks/useProductsBase.js +59 -4
- package/dist/libraries/react/hooks/useProductsBase.mjs +2 -2
- package/dist/libraries/react/index.d.mts +611 -0
- package/dist/libraries/react/index.d.ts +168 -57
- package/dist/libraries/react/index.js +175 -72
- package/dist/libraries/react/index.mjs +175 -72
- package/dist/libraries/react/{response-Z4Yeokd8.d.ts → response-BHqAAnND.d.ts} +21 -5
- package/dist/libraries/react/{response-CxtkXvb4.d.mts → response-CDZ_R5pb.d.mts} +21 -5
- package/dist/libraries/react/utils/inject-styles.js +14 -0
- package/dist/libraries/react/utils/inject-styles.mjs +1 -1
- package/dist/next/{AutumnProvider-DPcEuE_Q.d.ts → AutumnProvider-DtLqoQp6.d.mts} +28 -9
- package/dist/next/{AutumnProvider-DPcEuE_Q.d.mts → AutumnProvider-DtLqoQp6.d.ts} +28 -9
- package/dist/next/AutumnProvider.d.mts +2 -1
- package/dist/next/AutumnProvider.d.ts +2 -1
- package/dist/next/client/NextAutumnClient.d.mts +60 -10
- package/dist/next/client/NextAutumnClient.d.ts +60 -10
- package/dist/next/client/NextAutumnProvider.d.mts +2 -1
- package/dist/next/client/NextAutumnProvider.d.ts +2 -1
- package/dist/next/client/clientEntTypes-BFkleT6a.d.mts +22 -0
- package/dist/next/client/clientEntTypes-BFkleT6a.d.ts +22 -0
- package/dist/next/client/clientGenTypes-B28imYzT.d.mts +195 -0
- package/dist/next/client/clientGenTypes-D46edNj5.d.ts +195 -0
- package/dist/next/client/clientUtils.d.mts +3 -2
- package/dist/next/client/clientUtils.d.ts +3 -2
- package/dist/next/client/{cusTypes-CJI8rdlY.d.mts → cusTypes-CGXuXu_Y.d.mts} +29 -9
- package/dist/next/client/{cusTypes-CJI8rdlY.d.ts → cusTypes-CGXuXu_Y.d.ts} +29 -9
- package/dist/next/client/{entTypes-okM0aeOM.d.mts → entTypes-CJx3GLTt.d.mts} +1 -1
- package/dist/next/client/{entTypes-CqHWTcCX.d.ts → entTypes-qYfQsZ9u.d.ts} +1 -1
- package/dist/next/client/hooks/useAutumn.d.mts +6 -4
- package/dist/next/client/hooks/useAutumn.d.ts +6 -4
- package/dist/next/client/hooks/useCustomer.d.mts +26 -4
- package/dist/next/client/hooks/useCustomer.d.ts +26 -4
- package/dist/next/client/hooks/useCustomer.js +3 -1
- package/dist/next/client/hooks/useCustomer.mjs +3 -1
- package/dist/next/client/hooks/useEntity.d.mts +7 -5
- package/dist/next/client/hooks/useEntity.d.ts +7 -5
- package/dist/next/client/hooks/usePricingTable.d.mts +2 -1
- package/dist/next/client/hooks/usePricingTable.d.ts +2 -1
- package/dist/next/client/types.d.mts +3 -2
- package/dist/next/client/types.d.ts +3 -2
- package/dist/next/index.d.mts +221 -65
- package/dist/next/index.d.ts +221 -65
- package/dist/next/server/auth/withNextAuth.d.mts +2 -1
- package/dist/next/server/auth/withNextAuth.d.ts +2 -1
- package/dist/next/server/componentActions.d.mts +2 -1
- package/dist/next/server/componentActions.d.ts +2 -1
- package/dist/next/server/cusActions.d.mts +93 -38
- package/dist/next/server/cusActions.d.ts +93 -38
- package/dist/next/server/{cusTypes-DuSwXVmp.d.mts → cusTypes-H4mqijcm.d.mts} +28 -8
- package/dist/next/server/{cusTypes-DuSwXVmp.d.ts → cusTypes-H4mqijcm.d.ts} +28 -8
- package/dist/next/server/genActions.d.mts +44 -49
- package/dist/next/server/genActions.d.ts +44 -49
- package/dist/sdk/index.d.mts +123 -29
- package/dist/sdk/index.d.ts +123 -29
- package/dist/sdk/index.js +60 -9
- package/dist/sdk/index.mjs +57 -10
- package/dist/styles/global.css +42 -4
- package/dist/utils/encryptUtils.js +57 -0
- package/dist/utils/encryptUtils.mjs +57 -0
- package/package.json +33 -4
- package/tsup.config.ts +1 -22
- package/components.json +0 -21
- package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.css +0 -1271
- package/dist/libraries/react/components/pricing-table/pricing-table-synced.css +0 -1271
- package/dist/next/client/clientGenTypes-CAv4hwb4.d.ts +0 -108
- package/dist/next/client/clientGenTypes-Dlpw9wy_.d.mts +0 -108
- package/dist/next/client/clientReferralTypes-C9JiOk2s.d.mts +0 -20
- package/dist/next/client/clientReferralTypes-C9JiOk2s.d.ts +0 -20
- package/dist/next/server/clientEntTypes-BOVTwIKv.d.mts +0 -14
- package/dist/next/server/clientEntTypes-BOVTwIKv.d.ts +0 -14
- package/postcss.config.js +0 -25
- package/publish.sh +0 -18
- package/scripts/css-transform-plugin.js +0 -28
- package/scripts/post-build.js +0 -91
- package/scripts/sync-registry.ts +0 -190
- package/tailwind.config.ts +0 -96
- package/tsup.dev.config.ts +0 -199
|
@@ -546,6 +546,63 @@ var Autumn = class {
|
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
+
// src/sdk/general/genTypes.ts
|
|
550
|
+
var import_zod = require("zod");
|
|
551
|
+
var AttachParamsSchema = import_zod.z.object({
|
|
552
|
+
customer_id: import_zod.z.string(),
|
|
553
|
+
product_id: import_zod.z.string().optional(),
|
|
554
|
+
entity_id: import_zod.z.string().optional(),
|
|
555
|
+
options: import_zod.z.array(import_zod.z.object({
|
|
556
|
+
feature_id: import_zod.z.string(),
|
|
557
|
+
quantity: import_zod.z.number()
|
|
558
|
+
})).optional(),
|
|
559
|
+
product_ids: import_zod.z.array(import_zod.z.string()).optional(),
|
|
560
|
+
// If set, will attach multiple products to the customer (cannot be used with product_id)
|
|
561
|
+
free_trial: import_zod.z.boolean().optional(),
|
|
562
|
+
// Default is true -- if set to false, will bypass product free trial
|
|
563
|
+
success_url: import_zod.z.string().optional(),
|
|
564
|
+
// Passed to Stripe
|
|
565
|
+
metadata: import_zod.z.record(import_zod.z.string()).optional(),
|
|
566
|
+
// Passed to Stripe
|
|
567
|
+
force_checkout: import_zod.z.boolean().optional(),
|
|
568
|
+
// Default is false -- if set to true, will force the customer to checkout (not allowed for upgrades / downgrades)
|
|
569
|
+
customer_data: import_zod.z.any().optional(),
|
|
570
|
+
entity_data: import_zod.z.any().optional(),
|
|
571
|
+
checkout_session_params: import_zod.z.record(import_zod.z.any()).optional(),
|
|
572
|
+
// Passed to Stripe
|
|
573
|
+
reward: import_zod.z.string().optional()
|
|
574
|
+
});
|
|
575
|
+
var AttachResultSchema = import_zod.z.object({
|
|
576
|
+
checkout_url: import_zod.z.string().optional(),
|
|
577
|
+
customer_id: import_zod.z.string(),
|
|
578
|
+
product_ids: import_zod.z.array(import_zod.z.string()),
|
|
579
|
+
code: import_zod.z.string(),
|
|
580
|
+
message: import_zod.z.string(),
|
|
581
|
+
customer_data: import_zod.z.any().optional()
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
// src/sdk/customers/cusEnums.ts
|
|
585
|
+
var import_zod2 = require("zod");
|
|
586
|
+
var CustomerExpandEnum = import_zod2.z.enum([
|
|
587
|
+
"invoices",
|
|
588
|
+
"rewards",
|
|
589
|
+
"trials_used",
|
|
590
|
+
"entities",
|
|
591
|
+
"referrals",
|
|
592
|
+
"payment_method"
|
|
593
|
+
]);
|
|
594
|
+
|
|
595
|
+
// src/sdk/customers/cusTypes.ts
|
|
596
|
+
var import_zod3 = require("zod");
|
|
597
|
+
var CreateCustomerParamsSchema = import_zod3.z.object({
|
|
598
|
+
id: import_zod3.z.string().nullish(),
|
|
599
|
+
email: import_zod3.z.string().nullish(),
|
|
600
|
+
name: import_zod3.z.string().nullish(),
|
|
601
|
+
fingerprint: import_zod3.z.string().nullish(),
|
|
602
|
+
metadata: import_zod3.z.record(import_zod3.z.any()).optional(),
|
|
603
|
+
expand: import_zod3.z.array(CustomerExpandEnum).optional()
|
|
604
|
+
});
|
|
605
|
+
|
|
549
606
|
// src/libraries/react/errorUtils/logFetchError.ts
|
|
550
607
|
var logFetchError = ({
|
|
551
608
|
method,
|
|
@@ -870,12 +927,10 @@ var AutumnContext = (0, import_react2.createContext)({
|
|
|
870
927
|
});
|
|
871
928
|
var useAutumnContext = ({
|
|
872
929
|
AutumnContext: AutumnContext2,
|
|
873
|
-
name
|
|
930
|
+
name,
|
|
931
|
+
errorIfNotInitialized = true
|
|
874
932
|
}) => {
|
|
875
933
|
const context = (0, import_react2.useContext)(AutumnContext2);
|
|
876
|
-
if (!context.initialized) {
|
|
877
|
-
throw new Error(`${name} must be used within <AutumnProvider />`);
|
|
878
|
-
}
|
|
879
934
|
return context;
|
|
880
935
|
};
|
|
881
936
|
|
|
@@ -925,6 +980,15 @@ var mergeProductDetails = (products, productDetails) => {
|
|
|
925
980
|
...overrideItems2 || []
|
|
926
981
|
];
|
|
927
982
|
}
|
|
983
|
+
if (!overrideItems2 || overrideItems2.length === 0) {
|
|
984
|
+
overrideItems2 = [
|
|
985
|
+
{
|
|
986
|
+
display: {
|
|
987
|
+
primary_text: ""
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
];
|
|
991
|
+
}
|
|
928
992
|
mergedProducts.push({
|
|
929
993
|
display: {
|
|
930
994
|
name: overrideDetails.name,
|
|
@@ -1027,15 +1091,23 @@ var mergeProductDetails = (products, productDetails) => {
|
|
|
1027
1091
|
}
|
|
1028
1092
|
return mergedProducts;
|
|
1029
1093
|
};
|
|
1094
|
+
var defaultSWRConfig = {
|
|
1095
|
+
refreshInterval: 0
|
|
1096
|
+
};
|
|
1030
1097
|
var usePricingTableBase = ({
|
|
1031
1098
|
AutumnContext: AutumnContext2,
|
|
1032
|
-
params
|
|
1099
|
+
params,
|
|
1100
|
+
authClient
|
|
1033
1101
|
}) => {
|
|
1034
|
-
const context = useAutumnContext({
|
|
1102
|
+
const context = useAutumnContext({
|
|
1103
|
+
AutumnContext: AutumnContext2,
|
|
1104
|
+
name: "usePricingTable",
|
|
1105
|
+
errorIfNotInitialized: !authClient
|
|
1106
|
+
});
|
|
1107
|
+
const client = authClient ? authClient.autumn : context.client;
|
|
1035
1108
|
const fetcher = async () => {
|
|
1036
1109
|
try {
|
|
1037
|
-
|
|
1038
|
-
const { data: data2, error: error2 } = await context.client.products.list();
|
|
1110
|
+
const { data: data2, error: error2 } = await client.products.list();
|
|
1039
1111
|
if (error2) throw error2;
|
|
1040
1112
|
return data2?.list || [];
|
|
1041
1113
|
} catch (error2) {
|
|
@@ -1047,7 +1119,8 @@ var usePricingTableBase = ({
|
|
|
1047
1119
|
};
|
|
1048
1120
|
const { data, error, mutate } = (0, import_swr.default)(
|
|
1049
1121
|
"pricing-table",
|
|
1050
|
-
fetcher
|
|
1122
|
+
fetcher,
|
|
1123
|
+
{ ...defaultSWRConfig }
|
|
1051
1124
|
);
|
|
1052
1125
|
return {
|
|
1053
1126
|
products: mergeProductDetails(data || [], params?.productDetails),
|
|
@@ -1060,13 +1133,20 @@ var usePricingTableBase = ({
|
|
|
1060
1133
|
|
|
1061
1134
|
// src/libraries/react/hooks/useAutumnBase.tsx
|
|
1062
1135
|
var useAutumnBase = ({
|
|
1063
|
-
AutumnContext: AutumnContext2
|
|
1136
|
+
AutumnContext: AutumnContext2,
|
|
1137
|
+
authClient
|
|
1064
1138
|
}) => {
|
|
1065
|
-
const context = useAutumnContext({
|
|
1139
|
+
const context = useAutumnContext({
|
|
1140
|
+
AutumnContext: AutumnContext2,
|
|
1141
|
+
name: "useAutumn",
|
|
1142
|
+
errorIfNotInitialized: !authClient
|
|
1143
|
+
});
|
|
1066
1144
|
const { attachDialog, paywallDialog } = context;
|
|
1067
|
-
const client = context.client;
|
|
1145
|
+
const client = authClient ? authClient.autumn : context.client;
|
|
1146
|
+
const authClientExists = !!authClient;
|
|
1068
1147
|
const { refetch: refetchPricingTable } = usePricingTableBase({
|
|
1069
|
-
AutumnContext: AutumnContext2
|
|
1148
|
+
AutumnContext: AutumnContext2,
|
|
1149
|
+
authClient
|
|
1070
1150
|
});
|
|
1071
1151
|
let {
|
|
1072
1152
|
open: attachOpen,
|
|
@@ -1122,6 +1202,12 @@ var useAutumnBase = ({
|
|
|
1122
1202
|
const attach = async (params) => {
|
|
1123
1203
|
const { dialog, openInNewTab } = params;
|
|
1124
1204
|
let finalDialog = dialog;
|
|
1205
|
+
if (dialog && authClientExists) {
|
|
1206
|
+
console.error(
|
|
1207
|
+
"[Autumn] Attach dialog cannot be used with better auth plugin. To use this, please switch to <AutumnProvider /> and autumnHandler. Learn more here: https://docs.useautumn.com/quickstart/quickstart"
|
|
1208
|
+
);
|
|
1209
|
+
return void 0;
|
|
1210
|
+
}
|
|
1125
1211
|
if (finalDialog && !attachOpen) {
|
|
1126
1212
|
setAttachComponent(finalDialog);
|
|
1127
1213
|
return await attachWithDialog(params);
|
|
@@ -1137,6 +1223,12 @@ var useAutumnBase = ({
|
|
|
1137
1223
|
};
|
|
1138
1224
|
const check = async (params) => {
|
|
1139
1225
|
let { dialog, withPreview } = params;
|
|
1226
|
+
if (dialog && authClientExists) {
|
|
1227
|
+
console.error(
|
|
1228
|
+
"[Autumn] Check dialog cannot be used with better auth plugin. To use this, please switch to <AutumnProvider /> and autumnHandler. Learn more here: https://docs.useautumn.com/quickstart/quickstart"
|
|
1229
|
+
);
|
|
1230
|
+
return void 0;
|
|
1231
|
+
}
|
|
1140
1232
|
if (dialog) {
|
|
1141
1233
|
setPaywallComponent(dialog);
|
|
1142
1234
|
}
|
|
@@ -1222,9 +1314,13 @@ var getCusFeature = ({
|
|
|
1222
1314
|
featureId,
|
|
1223
1315
|
requiredBalance = 1
|
|
1224
1316
|
}) => {
|
|
1225
|
-
let creditSchema = Object.values(customer.features).find(
|
|
1317
|
+
let creditSchema = Object.values(customer.features).find(
|
|
1318
|
+
(f) => f.credit_schema && f.credit_schema.some((c) => c.feature_id === featureId)
|
|
1319
|
+
);
|
|
1226
1320
|
if (creditSchema) {
|
|
1227
|
-
let schemaItem = creditSchema.credit_schema?.find(
|
|
1321
|
+
let schemaItem = creditSchema.credit_schema?.find(
|
|
1322
|
+
(c) => c.feature_id === featureId
|
|
1323
|
+
);
|
|
1228
1324
|
return {
|
|
1229
1325
|
feature: creditSchema,
|
|
1230
1326
|
requiredBalance: schemaItem.credit_amount * requiredBalance
|
|
@@ -1235,14 +1331,27 @@ var getCusFeature = ({
|
|
|
1235
1331
|
requiredBalance
|
|
1236
1332
|
};
|
|
1237
1333
|
};
|
|
1238
|
-
var handleFeatureAllowed = ({
|
|
1239
|
-
|
|
1334
|
+
var handleFeatureAllowed = ({
|
|
1335
|
+
customer,
|
|
1336
|
+
params
|
|
1337
|
+
}) => {
|
|
1338
|
+
let { cusFeature, requiredBalance } = getCusFeature({
|
|
1339
|
+
customer,
|
|
1340
|
+
featureId: params.featureId
|
|
1341
|
+
});
|
|
1240
1342
|
if (!cusFeature) return false;
|
|
1241
1343
|
if (cusFeature.type == "static") return true;
|
|
1242
1344
|
if (cusFeature.unlimited || cusFeature.overage_allowed) return true;
|
|
1345
|
+
if (cusFeature.usage_limit) {
|
|
1346
|
+
let extraUsage = (cusFeature.usage_limit || 0) - (cusFeature.included_usage || 0);
|
|
1347
|
+
return (cusFeature.balance || 0) + extraUsage >= requiredBalance;
|
|
1348
|
+
}
|
|
1243
1349
|
return (cusFeature.balance || 0) >= requiredBalance;
|
|
1244
1350
|
};
|
|
1245
|
-
var handleAllowed = ({
|
|
1351
|
+
var handleAllowed = ({
|
|
1352
|
+
customer,
|
|
1353
|
+
params
|
|
1354
|
+
}) => {
|
|
1246
1355
|
if (!customer) return false;
|
|
1247
1356
|
if (!params.featureId && !params.productId) {
|
|
1248
1357
|
throw new Error("allowed() requires either featureId or productId");
|
|
@@ -1276,10 +1385,17 @@ var useCustomerBase = ({
|
|
|
1276
1385
|
}) => {
|
|
1277
1386
|
const queryKey = ["customer", params?.expand];
|
|
1278
1387
|
let context;
|
|
1388
|
+
let authClientExists = !!params?.authClient;
|
|
1279
1389
|
if (AutumnContext2) {
|
|
1280
|
-
context = useAutumnContext({
|
|
1390
|
+
context = useAutumnContext({
|
|
1391
|
+
AutumnContext: AutumnContext2,
|
|
1392
|
+
name: "useCustomer",
|
|
1393
|
+
errorIfNotInitialized: !authClientExists
|
|
1394
|
+
});
|
|
1281
1395
|
}
|
|
1282
|
-
if (
|
|
1396
|
+
if (authClientExists) {
|
|
1397
|
+
client = params?.authClient?.autumn;
|
|
1398
|
+
} else if (!client) {
|
|
1283
1399
|
client = context.client;
|
|
1284
1400
|
}
|
|
1285
1401
|
const fetchCustomer = async () => {
|
|
@@ -1295,18 +1411,21 @@ var useCustomerBase = ({
|
|
|
1295
1411
|
}
|
|
1296
1412
|
return data;
|
|
1297
1413
|
};
|
|
1298
|
-
const {
|
|
1414
|
+
const {
|
|
1415
|
+
data: customer,
|
|
1416
|
+
error,
|
|
1417
|
+
isLoading,
|
|
1418
|
+
mutate
|
|
1419
|
+
} = (0, import_swr2.default)(queryKey, fetchCustomer, {
|
|
1299
1420
|
fallbackData: null,
|
|
1300
|
-
|
|
1301
|
-
if (error2.code == "entity_not_found") {
|
|
1302
|
-
return false;
|
|
1303
|
-
}
|
|
1304
|
-
return true;
|
|
1305
|
-
}
|
|
1421
|
+
...params?.swrConfig
|
|
1306
1422
|
});
|
|
1307
1423
|
let autumnFunctions = emptyDefaultFunctions;
|
|
1308
|
-
if (AutumnContext2) {
|
|
1309
|
-
autumnFunctions = useAutumnBase({
|
|
1424
|
+
if (AutumnContext2 || params?.authClient) {
|
|
1425
|
+
autumnFunctions = useAutumnBase({
|
|
1426
|
+
AutumnContext: AutumnContext2,
|
|
1427
|
+
authClient: params?.authClient
|
|
1428
|
+
});
|
|
1310
1429
|
}
|
|
1311
1430
|
return {
|
|
1312
1431
|
customer: error ? null : customer,
|
|
@@ -6854,6 +6973,20 @@ var spinnerStyles = {
|
|
|
6854
6973
|
color: "rgb(161 161 170)",
|
|
6855
6974
|
animation: "spin 1s linear infinite"
|
|
6856
6975
|
};
|
|
6976
|
+
if (typeof document !== "undefined") {
|
|
6977
|
+
const styleId = "au-spinner-keyframes";
|
|
6978
|
+
if (!document.getElementById(styleId)) {
|
|
6979
|
+
const style = document.createElement("style");
|
|
6980
|
+
style.id = styleId;
|
|
6981
|
+
style.textContent = `
|
|
6982
|
+
@keyframes spin {
|
|
6983
|
+
from { transform: rotate(0deg); }
|
|
6984
|
+
to { transform: rotate(360deg); }
|
|
6985
|
+
}
|
|
6986
|
+
`;
|
|
6987
|
+
document.head.appendChild(style);
|
|
6988
|
+
}
|
|
6989
|
+
}
|
|
6857
6990
|
|
|
6858
6991
|
// src/libraries/react/components/pricing-table/pricing-table-synced.tsx
|
|
6859
6992
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
@@ -7056,7 +7189,7 @@ var PricingCard = ({
|
|
|
7056
7189
|
{
|
|
7057
7190
|
recommended: productDisplay?.recommend_text ? true : false,
|
|
7058
7191
|
...buttonProps,
|
|
7059
|
-
children: buttonText
|
|
7192
|
+
children: productDisplay?.button_text || buttonText
|
|
7060
7193
|
}
|
|
7061
7194
|
)
|
|
7062
7195
|
}
|
|
@@ -9,32 +9,32 @@ import {
|
|
|
9
9
|
PricingTableContainer,
|
|
10
10
|
RecommendedBadge,
|
|
11
11
|
usePricingTableContext
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-BCMBFJ7E.mjs";
|
|
14
|
-
import "../../chunk-QBBE72EF.mjs";
|
|
12
|
+
} from "../../chunk-LKBUMRHE.mjs";
|
|
15
13
|
import "../../chunk-27OTS3Q5.mjs";
|
|
14
|
+
import "../../chunk-QBBE72EF.mjs";
|
|
16
15
|
import "../../chunk-MY2ODATB.mjs";
|
|
16
|
+
import "../../chunk-BCMBFJ7E.mjs";
|
|
17
17
|
import "../../chunk-P2O4LZFD.mjs";
|
|
18
18
|
import "../../chunk-5FZ7IV6P.mjs";
|
|
19
19
|
import "../../chunk-CMO5LYYU.mjs";
|
|
20
20
|
import "../../chunk-FPI3PLEL.mjs";
|
|
21
21
|
import "../../chunk-FEFGYFXQ.mjs";
|
|
22
|
-
import "../../chunk-
|
|
23
|
-
import "../../chunk-
|
|
24
|
-
import "../../chunk-
|
|
25
|
-
import "../../chunk-
|
|
22
|
+
import "../../chunk-WVKYZYFT.mjs";
|
|
23
|
+
import "../../chunk-4AYEAAQU.mjs";
|
|
24
|
+
import "../../chunk-SJAAUTL2.mjs";
|
|
25
|
+
import "../../chunk-TBKIB6DH.mjs";
|
|
26
|
+
import "../../chunk-GK75OJJJ.mjs";
|
|
26
27
|
import "../../chunk-4J6OC4ZQ.mjs";
|
|
27
|
-
import "../../chunk-
|
|
28
|
-
import "../../chunk-
|
|
29
|
-
import "../../chunk-
|
|
30
|
-
import "../../chunk-
|
|
28
|
+
import "../../chunk-6JOSRG5Z.mjs";
|
|
29
|
+
import "../../chunk-67Y4DFV2.mjs";
|
|
30
|
+
import "../../chunk-G3XBGOHR.mjs";
|
|
31
|
+
import "../../chunk-TINC2IR4.mjs";
|
|
31
32
|
import "../../chunk-4QPHNIQ7.mjs";
|
|
32
|
-
import "../../chunk-
|
|
33
|
-
import "../../chunk-
|
|
34
|
-
import "../../chunk-
|
|
35
|
-
import "../../chunk-
|
|
36
|
-
import "../../chunk-
|
|
37
|
-
import "../../chunk-UDRQNZZS.mjs";
|
|
33
|
+
import "../../chunk-3JJC2VU5.mjs";
|
|
34
|
+
import "../../chunk-3WP2MI55.mjs";
|
|
35
|
+
import "../../chunk-CHQRTGXF.mjs";
|
|
36
|
+
import "../../chunk-ITN754AD.mjs";
|
|
37
|
+
import "../../chunk-QAHVMSK4.mjs";
|
|
38
38
|
import "../../chunk-YUV2Y2RW.mjs";
|
|
39
39
|
import "../../chunk-3EYF7OI5.mjs";
|
|
40
40
|
import "../../chunk-JVCOY7ZL.mjs";
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
|
-
variant?: "
|
|
6
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
7
7
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
|
-
variant?: "
|
|
6
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
7
7
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
declare const Infinite = "inf";
|
|
2
4
|
declare enum FreeTrialDuration {
|
|
3
5
|
Day = "day"
|
|
@@ -28,6 +30,7 @@ interface CheckFeatureResult extends CoreCustomerFeature {
|
|
|
28
30
|
entity_id?: string;
|
|
29
31
|
required_balance: number;
|
|
30
32
|
code: string;
|
|
33
|
+
usage_limit?: number;
|
|
31
34
|
preview?: CheckFeaturePreview;
|
|
32
35
|
}
|
|
33
36
|
interface CheckFeaturePreview {
|
|
@@ -152,6 +155,7 @@ interface CoreCustomerFeature {
|
|
|
152
155
|
included_usage?: number;
|
|
153
156
|
next_reset_at?: number | null;
|
|
154
157
|
overage_allowed?: boolean;
|
|
158
|
+
usage_limit?: number;
|
|
155
159
|
breakdown?: {
|
|
156
160
|
interval: ProductItemInterval;
|
|
157
161
|
balance?: number;
|
|
@@ -203,14 +207,29 @@ interface CustomerData {
|
|
|
203
207
|
email?: string;
|
|
204
208
|
fingerprint?: string;
|
|
205
209
|
}
|
|
206
|
-
|
|
207
|
-
id
|
|
208
|
-
email
|
|
209
|
-
name
|
|
210
|
-
fingerprint
|
|
211
|
-
metadata
|
|
212
|
-
expand
|
|
213
|
-
}
|
|
210
|
+
declare const CreateCustomerParamsSchema: z.ZodObject<{
|
|
211
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
212
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
213
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
214
|
+
fingerprint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
215
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
216
|
+
expand: z.ZodOptional<z.ZodArray<z.ZodEnum<["invoices", "rewards", "trials_used", "entities", "referrals", "payment_method"]>, "many">>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
name?: string | null | undefined;
|
|
219
|
+
id?: string | null | undefined;
|
|
220
|
+
email?: string | null | undefined;
|
|
221
|
+
fingerprint?: string | null | undefined;
|
|
222
|
+
metadata?: Record<string, any> | undefined;
|
|
223
|
+
expand?: ("invoices" | "rewards" | "trials_used" | "entities" | "referrals" | "payment_method")[] | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
name?: string | null | undefined;
|
|
226
|
+
id?: string | null | undefined;
|
|
227
|
+
email?: string | null | undefined;
|
|
228
|
+
fingerprint?: string | null | undefined;
|
|
229
|
+
metadata?: Record<string, any> | undefined;
|
|
230
|
+
expand?: ("invoices" | "rewards" | "trials_used" | "entities" | "referrals" | "payment_method")[] | undefined;
|
|
231
|
+
}>;
|
|
232
|
+
type CreateCustomerParams = z.infer<typeof CreateCustomerParamsSchema>;
|
|
214
233
|
interface BillingPortalResult {
|
|
215
234
|
customer_id: string;
|
|
216
235
|
url: string;
|
|
@@ -222,6 +241,7 @@ interface CustomerInvoice {
|
|
|
222
241
|
total: number;
|
|
223
242
|
currency: string;
|
|
224
243
|
created_at: number;
|
|
244
|
+
hosted_invoice_url: string;
|
|
225
245
|
}
|
|
226
246
|
|
|
227
|
-
export type { BillingPortalResult as B, CustomerData as C, Product as P, CreateCustomerParams as a, Customer as b, CustomerExpandOption as c, CustomerProduct as d, CustomerFeature as e, CustomerInvoice as f, CheckProductPreview as g,
|
|
247
|
+
export type { BillingPortalResult as B, CustomerData as C, Product as P, CreateCustomerParams as a, Customer as b, CustomerExpandOption as c, CustomerProduct as d, CustomerFeature as e, CustomerInvoice as f, CheckProductPreview as g, ProductItem as h, CheckFeaturePreview as i, CheckFeatureResult as j, CheckProductResult as k, ProductScenario as l };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
declare const Infinite = "inf";
|
|
2
4
|
declare enum FreeTrialDuration {
|
|
3
5
|
Day = "day"
|
|
@@ -28,6 +30,7 @@ interface CheckFeatureResult extends CoreCustomerFeature {
|
|
|
28
30
|
entity_id?: string;
|
|
29
31
|
required_balance: number;
|
|
30
32
|
code: string;
|
|
33
|
+
usage_limit?: number;
|
|
31
34
|
preview?: CheckFeaturePreview;
|
|
32
35
|
}
|
|
33
36
|
interface CheckFeaturePreview {
|
|
@@ -152,6 +155,7 @@ interface CoreCustomerFeature {
|
|
|
152
155
|
included_usage?: number;
|
|
153
156
|
next_reset_at?: number | null;
|
|
154
157
|
overage_allowed?: boolean;
|
|
158
|
+
usage_limit?: number;
|
|
155
159
|
breakdown?: {
|
|
156
160
|
interval: ProductItemInterval;
|
|
157
161
|
balance?: number;
|
|
@@ -203,14 +207,29 @@ interface CustomerData {
|
|
|
203
207
|
email?: string;
|
|
204
208
|
fingerprint?: string;
|
|
205
209
|
}
|
|
206
|
-
|
|
207
|
-
id
|
|
208
|
-
email
|
|
209
|
-
name
|
|
210
|
-
fingerprint
|
|
211
|
-
metadata
|
|
212
|
-
expand
|
|
213
|
-
}
|
|
210
|
+
declare const CreateCustomerParamsSchema: z.ZodObject<{
|
|
211
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
212
|
+
email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
213
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
214
|
+
fingerprint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
215
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
216
|
+
expand: z.ZodOptional<z.ZodArray<z.ZodEnum<["invoices", "rewards", "trials_used", "entities", "referrals", "payment_method"]>, "many">>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
name?: string | null | undefined;
|
|
219
|
+
id?: string | null | undefined;
|
|
220
|
+
email?: string | null | undefined;
|
|
221
|
+
fingerprint?: string | null | undefined;
|
|
222
|
+
metadata?: Record<string, any> | undefined;
|
|
223
|
+
expand?: ("invoices" | "rewards" | "trials_used" | "entities" | "referrals" | "payment_method")[] | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
name?: string | null | undefined;
|
|
226
|
+
id?: string | null | undefined;
|
|
227
|
+
email?: string | null | undefined;
|
|
228
|
+
fingerprint?: string | null | undefined;
|
|
229
|
+
metadata?: Record<string, any> | undefined;
|
|
230
|
+
expand?: ("invoices" | "rewards" | "trials_used" | "entities" | "referrals" | "payment_method")[] | undefined;
|
|
231
|
+
}>;
|
|
232
|
+
type CreateCustomerParams = z.infer<typeof CreateCustomerParamsSchema>;
|
|
214
233
|
interface BillingPortalResult {
|
|
215
234
|
customer_id: string;
|
|
216
235
|
url: string;
|
|
@@ -222,6 +241,7 @@ interface CustomerInvoice {
|
|
|
222
241
|
total: number;
|
|
223
242
|
currency: string;
|
|
224
243
|
created_at: number;
|
|
244
|
+
hosted_invoice_url: string;
|
|
225
245
|
}
|
|
226
246
|
|
|
227
|
-
export type { BillingPortalResult as B, CustomerData as C, Product as P, CreateCustomerParams as a, Customer as b, CustomerExpandOption as c, CustomerProduct as d, CustomerFeature as e, CustomerInvoice as f, CheckProductPreview as g,
|
|
247
|
+
export type { BillingPortalResult as B, CustomerData as C, Product as P, CreateCustomerParams as a, Customer as b, CustomerExpandOption as c, CustomerProduct as d, CustomerFeature as e, CustomerInvoice as f, CheckProductPreview as g, ProductItem as h, CheckFeaturePreview as i, CheckFeatureResult as j, CheckProductResult as k, ProductScenario as l };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice } from './cusTypes-
|
|
1
|
+
import { d as CustomerProduct, e as CustomerFeature, f as CustomerInvoice } from './cusTypes-Bf1qr9iE.mjs';
|
|
2
2
|
|
|
3
3
|
interface DeleteEntityResult {
|
|
4
4
|
success: boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { b as Customer } from '../cusTypes-
|
|
2
|
-
import { E as Entity } from '../entTypes-
|
|
1
|
+
import { b as Customer } from '../cusTypes-Bf1qr9iE.mjs';
|
|
2
|
+
import { E as Entity } from '../entTypes-CscyyE1A.mjs';
|
|
3
|
+
import 'zod';
|
|
3
4
|
|
|
4
5
|
interface AllowedParams {
|
|
5
6
|
featureId?: string;
|
|
6
7
|
productId?: string;
|
|
7
8
|
requiredBalance?: number;
|
|
8
9
|
}
|
|
9
|
-
declare const handleAllowed: ({ customer, params }: {
|
|
10
|
+
declare const handleAllowed: ({ customer, params, }: {
|
|
10
11
|
customer: Customer | Entity | null;
|
|
11
12
|
params: AllowedParams;
|
|
12
13
|
}) => boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { b as Customer } from '../cusTypes-
|
|
2
|
-
import { E as Entity } from '../entTypes-
|
|
1
|
+
import { b as Customer } from '../cusTypes-Bf1qr9iE.js';
|
|
2
|
+
import { E as Entity } from '../entTypes-O8YXxhrA.js';
|
|
3
|
+
import 'zod';
|
|
3
4
|
|
|
4
5
|
interface AllowedParams {
|
|
5
6
|
featureId?: string;
|
|
6
7
|
productId?: string;
|
|
7
8
|
requiredBalance?: number;
|
|
8
9
|
}
|
|
9
|
-
declare const handleAllowed: ({ customer, params }: {
|
|
10
|
+
declare const handleAllowed: ({ customer, params, }: {
|
|
10
11
|
customer: Customer | Entity | null;
|
|
11
12
|
params: AllowedParams;
|
|
12
13
|
}) => boolean;
|
|
@@ -30,9 +30,13 @@ var getCusFeature = ({
|
|
|
30
30
|
featureId,
|
|
31
31
|
requiredBalance = 1
|
|
32
32
|
}) => {
|
|
33
|
-
let creditSchema = Object.values(customer.features).find(
|
|
33
|
+
let creditSchema = Object.values(customer.features).find(
|
|
34
|
+
(f) => f.credit_schema && f.credit_schema.some((c) => c.feature_id === featureId)
|
|
35
|
+
);
|
|
34
36
|
if (creditSchema) {
|
|
35
|
-
let schemaItem = creditSchema.credit_schema?.find(
|
|
37
|
+
let schemaItem = creditSchema.credit_schema?.find(
|
|
38
|
+
(c) => c.feature_id === featureId
|
|
39
|
+
);
|
|
36
40
|
return {
|
|
37
41
|
feature: creditSchema,
|
|
38
42
|
requiredBalance: schemaItem.credit_amount * requiredBalance
|
|
@@ -43,14 +47,27 @@ var getCusFeature = ({
|
|
|
43
47
|
requiredBalance
|
|
44
48
|
};
|
|
45
49
|
};
|
|
46
|
-
var handleFeatureAllowed = ({
|
|
47
|
-
|
|
50
|
+
var handleFeatureAllowed = ({
|
|
51
|
+
customer,
|
|
52
|
+
params
|
|
53
|
+
}) => {
|
|
54
|
+
let { cusFeature, requiredBalance } = getCusFeature({
|
|
55
|
+
customer,
|
|
56
|
+
featureId: params.featureId
|
|
57
|
+
});
|
|
48
58
|
if (!cusFeature) return false;
|
|
49
59
|
if (cusFeature.type == "static") return true;
|
|
50
60
|
if (cusFeature.unlimited || cusFeature.overage_allowed) return true;
|
|
61
|
+
if (cusFeature.usage_limit) {
|
|
62
|
+
let extraUsage = (cusFeature.usage_limit || 0) - (cusFeature.included_usage || 0);
|
|
63
|
+
return (cusFeature.balance || 0) + extraUsage >= requiredBalance;
|
|
64
|
+
}
|
|
51
65
|
return (cusFeature.balance || 0) >= requiredBalance;
|
|
52
66
|
};
|
|
53
|
-
var handleAllowed = ({
|
|
67
|
+
var handleAllowed = ({
|
|
68
|
+
customer,
|
|
69
|
+
params
|
|
70
|
+
}) => {
|
|
54
71
|
if (!customer) return false;
|
|
55
72
|
if (!params.featureId && !params.productId) {
|
|
56
73
|
throw new Error("allowed() requires either featureId or productId");
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { B as BillingPortalResult } from '../cusTypes-CO4FwQ_s.mjs';
|
|
1
|
+
import { A as AutumnPromise, b as CheckResult, T as TrackResult, C as CancelResult, S as SetupPaymentResult } from '../response-CDZ_R5pb.mjs';
|
|
2
|
+
import { B as BillingPortalResult } from '../cusTypes-Bf1qr9iE.mjs';
|
|
4
3
|
import { AttachParams, CheckParams, TrackParams, CancelParams, OpenBillingPortalParams, SetupPaymentParams } from '../client/types/clientGenTypes.mjs';
|
|
5
|
-
import '
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '../error-DHbclCVh.mjs';
|
|
6
|
+
import 'react';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @deprecated The functions exported from this hook can now be found in useCustomer
|
|
9
10
|
*/
|
|
10
11
|
declare const useAutumn: () => {
|
|
11
|
-
attach: (params: AttachParams) => Promise<
|
|
12
|
+
attach: (params: AttachParams) => Promise<any>;
|
|
12
13
|
check: (params: CheckParams) => AutumnPromise<CheckResult>;
|
|
13
14
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
14
15
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { B as BillingPortalResult } from '../cusTypes-CO4FwQ_s.js';
|
|
1
|
+
import { A as AutumnPromise, b as CheckResult, T as TrackResult, C as CancelResult, S as SetupPaymentResult } from '../response-BHqAAnND.js';
|
|
2
|
+
import { B as BillingPortalResult } from '../cusTypes-Bf1qr9iE.js';
|
|
4
3
|
import { AttachParams, CheckParams, TrackParams, CancelParams, OpenBillingPortalParams, SetupPaymentParams } from '../client/types/clientGenTypes.js';
|
|
5
|
-
import '
|
|
4
|
+
import 'zod';
|
|
5
|
+
import '../error-DHbclCVh.js';
|
|
6
|
+
import 'react';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @deprecated The functions exported from this hook can now be found in useCustomer
|
|
9
10
|
*/
|
|
10
11
|
declare const useAutumn: () => {
|
|
11
|
-
attach: (params: AttachParams) => Promise<
|
|
12
|
+
attach: (params: AttachParams) => Promise<any>;
|
|
12
13
|
check: (params: CheckParams) => AutumnPromise<CheckResult>;
|
|
13
14
|
track: (params: TrackParams) => AutumnPromise<TrackResult>;
|
|
14
15
|
cancel: (params: CancelParams) => AutumnPromise<CancelResult>;
|