pecunia-core 0.1.4 → 0.1.6
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/api/index.d.mts +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +2 -115
- package/dist/errors/index.d.mts +1 -1
- package/dist/{get-payment-tables-0kpYs4ZQ.mjs → get-payment-tables-BoXNGJyi.mjs} +1135 -1151
- package/dist/{index-CRH0tJ5D.d.mts → index-DRbFIWcM.d.mts} +1 -17
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs +1 -1
- package/package.json +1 -1
package/dist/api/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as useMiddleware, i as optionsMiddleware, n as createPaymentEndpoint, r as createPecuniaMiddleware, t as PaymentMiddleware } from "../index-
|
|
1
|
+
import { a as useMiddleware, i as optionsMiddleware, n as createPaymentEndpoint, r as createPecuniaMiddleware, t as PaymentMiddleware } from "../index-DRbFIWcM.mjs";
|
|
2
2
|
export { PaymentMiddleware, createPaymentEndpoint, createPecuniaMiddleware, optionsMiddleware, useMiddleware };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { At as RequestState, Dt as getCurrentDBAdapterAsyncLocalStorage, Et as getCurrentAdapter, Ft as hasRequestState, It as runWithRequestState, Lt as getCurrentAuthContext, Mt as defineRequestState, Nt as getCurrentRequestState, Ot as runWithAdapter, Pt as getRequestStateAsyncLocalStorage, Rt as getCurrentPaymentContextAsyncLocalStorage, jt as RequestStateWeakMap, kt as runWithTransaction, zt as runWithEndpointContext } from "../index-
|
|
1
|
+
import { At as RequestState, Dt as getCurrentDBAdapterAsyncLocalStorage, Et as getCurrentAdapter, Ft as hasRequestState, It as runWithRequestState, Lt as getCurrentAuthContext, Mt as defineRequestState, Nt as getCurrentRequestState, Ot as runWithAdapter, Pt as getRequestStateAsyncLocalStorage, Rt as getCurrentPaymentContextAsyncLocalStorage, jt as RequestStateWeakMap, kt as runWithTransaction, zt as runWithEndpointContext } from "../index-DRbFIWcM.mjs";
|
|
2
2
|
export { RequestState, RequestStateWeakMap, defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentDBAdapterAsyncLocalStorage, getCurrentPaymentContextAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as KyselyDatabaseDialectType, Ct as initGetFieldAttributes, St as initGetFieldName, Tt as initGetDefaultFieldName, _t as discountSchema, at as getPaymentTables, bt as initGetModelName, ct as Subscription, dt as sharedDeletableSchema, ft as Product, gt as Discount, ht as priceSchema, lt as subscriptionSchema, mt as Price, ot as deepmerge, pt as productSchema, st as withApplyDefault, ut as sharedCoreSchema, vt as Customer, wt as initGetDefaultModelName, xt as initGetIdField, yt as customerSchema } from "../index-
|
|
1
|
+
import { $t as KyselyDatabaseDialectType, Ct as initGetFieldAttributes, St as initGetFieldName, Tt as initGetDefaultFieldName, _t as discountSchema, at as getPaymentTables, bt as initGetModelName, ct as Subscription, dt as sharedDeletableSchema, ft as Product, gt as Discount, ht as priceSchema, lt as subscriptionSchema, mt as Price, ot as deepmerge, pt as productSchema, st as withApplyDefault, ut as sharedCoreSchema, vt as Customer, wt as initGetDefaultModelName, xt as initGetIdField, yt as customerSchema } from "../index-DRbFIWcM.mjs";
|
|
2
2
|
export { Customer, Discount, KyselyDatabaseDialectType, Price, Product, Subscription, customerSchema, deepmerge, discountSchema, getPaymentTables, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName, priceSchema, productSchema, sharedCoreSchema, sharedDeletableSchema, subscriptionSchema, withApplyDefault };
|
package/dist/db/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { a as
|
|
1
|
+
import "../errors-vpD21Iku.mjs";
|
|
2
|
+
import { a as productSchema, c as customerSchema, d as initGetModelName, f as initGetFieldAttributes, h as initGetDefaultModelName, i as subscriptionSchema, l as sharedCoreSchema, m as initGetDefaultFieldName, n as deepmerge, o as priceSchema, p as initGetIdField, r as withApplyDefault, s as discountSchema, t as getPaymentTables, u as sharedDeletableSchema } from "../get-payment-tables-BoXNGJyi.mjs";
|
|
3
3
|
import "../generate-id-D3ZvbbXn.mjs";
|
|
4
|
-
import z$1, { z } from "zod";
|
|
5
4
|
|
|
6
5
|
//#region src/db/attributes/get-field-name.ts
|
|
7
6
|
const initGetFieldName = ({ schema, usePlural }) => {
|
|
@@ -31,117 +30,5 @@ const initGetFieldName = ({ schema, usePlural }) => {
|
|
|
31
30
|
return getFieldName;
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/db/schema/shared.ts
|
|
36
|
-
const sharedCoreSchema = z$1.object({
|
|
37
|
-
id: z$1.uuid("id"),
|
|
38
|
-
createdAt: z$1.date().default(() => /* @__PURE__ */ new Date()),
|
|
39
|
-
updatedAt: z$1.date().default(() => /* @__PURE__ */ new Date())
|
|
40
|
-
});
|
|
41
|
-
const sharedDeletableSchema = z$1.object({
|
|
42
|
-
deleted: z$1.boolean().default(false),
|
|
43
|
-
deletedAt: z$1.coerce.date().optional()
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/db/schema/customer.ts
|
|
48
|
-
const customerSchema = sharedCoreSchema.extend({
|
|
49
|
-
phoneNumber: z$1.string().max(15),
|
|
50
|
-
firstName: z$1.string().max(50),
|
|
51
|
-
paymentMethodId: z$1.string().optional(),
|
|
52
|
-
lastName: z$1.string().max(50),
|
|
53
|
-
email: z$1.email().max(255)
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/db/schema/discount.ts
|
|
58
|
-
const discountSchema = sharedCoreSchema.extend(sharedDeletableSchema.shape).extend({
|
|
59
|
-
code: z.string().max(50),
|
|
60
|
-
name: z.string().max(255).optional(),
|
|
61
|
-
description: z.string().optional(),
|
|
62
|
-
type: z.enum(DiscountType).default(DiscountType.PERCENTAGE),
|
|
63
|
-
value: z.number().positive().min(0),
|
|
64
|
-
currency: z.enum(Currency).optional(),
|
|
65
|
-
active: z.boolean().default(true),
|
|
66
|
-
startsAt: z.coerce.date().optional(),
|
|
67
|
-
endsAt: z.coerce.date().optional(),
|
|
68
|
-
maxUses: z.number().int().positive().optional(),
|
|
69
|
-
maxUsesPerCustomer: z.number().int().positive().optional(),
|
|
70
|
-
timesUsed: z.number().int().nonnegative().default(0),
|
|
71
|
-
minimumAmount: z.number().positive().optional(),
|
|
72
|
-
minimumAmountCurrency: z.enum(Currency).optional(),
|
|
73
|
-
maximumDiscountAmount: z.number().positive().optional(),
|
|
74
|
-
maximumDiscountAmountCurrency: z.enum(Currency).optional(),
|
|
75
|
-
durationInMonths: z.number().int().positive().optional(),
|
|
76
|
-
appliesToProductIds: z.array(z.uuid()).default([]),
|
|
77
|
-
appliesToPriceIds: z.array(z.uuid()).default([]),
|
|
78
|
-
appliesToCustomerIds: z.array(z.uuid()).default([]),
|
|
79
|
-
appliesToAllProducts: z.boolean().default(false),
|
|
80
|
-
appliesToAllPrices: z.boolean().default(false),
|
|
81
|
-
appliesToAllCustomers: z.boolean().default(true),
|
|
82
|
-
firstTimeCustomerOnly: z.boolean().default(false),
|
|
83
|
-
metadata: z.record(z.string(), z.union([z.string(), z.number()])).optional()
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/db/schema/price.ts
|
|
88
|
-
const priceSchema = sharedCoreSchema.extend(sharedDeletableSchema.shape).extend({
|
|
89
|
-
productId: z.uuid().optional(),
|
|
90
|
-
unitAmount: z.number().default(0),
|
|
91
|
-
currency: z.enum(Currency).default(Currency.KES),
|
|
92
|
-
type: z.enum(PriceType).default(PriceType.ONE_TIME),
|
|
93
|
-
pricingModel: z.enum(PricingModel).default(PricingModel.FLAT),
|
|
94
|
-
billingInterval: z.enum(BillingInterval).default(BillingInterval.MONTH),
|
|
95
|
-
billingIntervalCount: z.number().min(1).default(1),
|
|
96
|
-
trialPeriodDays: z.number().min(0).default(0),
|
|
97
|
-
usageAggregation: z.enum(UsageAggregation).optional(),
|
|
98
|
-
active: z.boolean().default(true),
|
|
99
|
-
metadata: z.record(z.string(), z.union([z.string(), z.number()])).optional()
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/db/schema/product.ts
|
|
104
|
-
const productSchema = sharedCoreSchema.extend(sharedDeletableSchema.shape).extend({
|
|
105
|
-
type: z$1.enum(ProductType),
|
|
106
|
-
name: z$1.string().max(255),
|
|
107
|
-
description: z$1.string().optional(),
|
|
108
|
-
images: z$1.array(z$1.string()).default([]),
|
|
109
|
-
defaultPriceId: z$1.uuid().optional(),
|
|
110
|
-
marketing_features: z$1.array(z$1.object({ name: z$1.string() })).optional(),
|
|
111
|
-
package_dimensions: z$1.object({
|
|
112
|
-
height: z$1.number(),
|
|
113
|
-
length: z$1.number(),
|
|
114
|
-
weight: z$1.number(),
|
|
115
|
-
width: z$1.number()
|
|
116
|
-
}).optional(),
|
|
117
|
-
shippable: z$1.boolean().optional(),
|
|
118
|
-
url: z$1.url().optional(),
|
|
119
|
-
active: z$1.boolean().default(true),
|
|
120
|
-
metadata: z$1.record(z$1.string(), z$1.union([z$1.string(), z$1.number()])).optional()
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/db/schema/subscription.ts
|
|
125
|
-
const subscriptionSchema = sharedCoreSchema.extend(sharedDeletableSchema.shape).extend({
|
|
126
|
-
customerId: z.uuid(),
|
|
127
|
-
paymentMethodId: z.uuid().optional(),
|
|
128
|
-
discountId: z.uuid().optional(),
|
|
129
|
-
discountEndsAt: z.coerce.date().optional(),
|
|
130
|
-
status: z.enum(SubscriptionStatus).default(SubscriptionStatus.INCOMPLETE),
|
|
131
|
-
currentBillingPeriodStart: z.coerce.date(),
|
|
132
|
-
currentBillingPeriodEnd: z.coerce.date(),
|
|
133
|
-
currentTrialStart: z.coerce.date().optional(),
|
|
134
|
-
currentTrialEnd: z.coerce.date().optional(),
|
|
135
|
-
cancelAtPeriodEnd: z.boolean().default(false),
|
|
136
|
-
canceledAt: z.coerce.date().optional(),
|
|
137
|
-
cancelAt: z.coerce.date().optional(),
|
|
138
|
-
daysUntilDue: z.number().min(0).default(0),
|
|
139
|
-
proration: z.enum(ProrationBehavior).default(ProrationBehavior.CREATE_PRORATIONS),
|
|
140
|
-
collectionMethod: z.enum(CollectionMethod).default(CollectionMethod.SEND_INVOICE),
|
|
141
|
-
metadata: z.record(z.string(), z.union([z.string(), z.number()])).optional(),
|
|
142
|
-
subscriptionStartedAt: z.coerce.date(),
|
|
143
|
-
subscriptionEndedAt: z.coerce.date().optional()
|
|
144
|
-
});
|
|
145
|
-
|
|
146
33
|
//#endregion
|
|
147
34
|
export { customerSchema, deepmerge, discountSchema, getPaymentTables, initGetDefaultFieldName, initGetDefaultModelName, initGetFieldAttributes, initGetFieldName, initGetIdField, initGetModelName, priceSchema, productSchema, sharedCoreSchema, sharedDeletableSchema, subscriptionSchema, withApplyDefault };
|
package/dist/errors/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { it as createProviderError, nt as PecuniaError, rt as ValidationError, tt as ApiError } from "../index-
|
|
1
|
+
import { it as createProviderError, nt as PecuniaError, rt as ValidationError, tt as ApiError } from "../index-DRbFIWcM.mjs";
|
|
2
2
|
export { ApiError, PecuniaError, ValidationError, createProviderError };
|