pecunia-core 0.1.7 → 0.1.9

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/db/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
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-nzw0kf4A.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-DVwV2nP-.mjs";
3
3
  import "../generate-id-D3ZvbbXn.mjs";
4
4
 
5
5
  //#region src/db/attributes/get-field-name.ts
@@ -1082,6 +1082,151 @@ const getPaymentTables = (options) => {
1082
1082
  value: 0
1083
1083
  }]
1084
1084
  },
1085
+ payment_method: {
1086
+ modelName: "payment_method",
1087
+ order: 2,
1088
+ fields: {
1089
+ id: {
1090
+ type: "uuid",
1091
+ fieldName: "id",
1092
+ required: true,
1093
+ sortable: true,
1094
+ input: false,
1095
+ returned: true,
1096
+ unique: true,
1097
+ validator: { output: z.uuid() }
1098
+ },
1099
+ customerId: {
1100
+ type: "uuid",
1101
+ fieldName: "customer_id",
1102
+ required: true,
1103
+ sortable: true,
1104
+ index: true,
1105
+ validator: {
1106
+ input: z.uuid(),
1107
+ output: z.uuid()
1108
+ },
1109
+ references: {
1110
+ model: "customer",
1111
+ field: "id",
1112
+ onDelete: "cascade"
1113
+ }
1114
+ },
1115
+ provider: {
1116
+ type: "string",
1117
+ fieldName: "payment_provider",
1118
+ required: true,
1119
+ sortable: true,
1120
+ defaultValue: PaymentProviders.MPESA,
1121
+ validator: {
1122
+ input: z.enum(PaymentProviders).default(PaymentProviders.MPESA),
1123
+ output: z.enum(PaymentProviders)
1124
+ },
1125
+ index: true
1126
+ },
1127
+ phone: {
1128
+ type: "string",
1129
+ fieldName: "phone_number",
1130
+ required: true,
1131
+ sortable: true,
1132
+ validator: {
1133
+ input: z.string().max(15),
1134
+ output: z.string().max(15)
1135
+ }
1136
+ },
1137
+ isActive: {
1138
+ type: "boolean",
1139
+ fieldName: "is_active",
1140
+ required: true,
1141
+ sortable: true,
1142
+ defaultValue: true,
1143
+ validator: {
1144
+ input: z.boolean().default(true),
1145
+ output: z.boolean()
1146
+ },
1147
+ index: true
1148
+ },
1149
+ idempotencyKey: {
1150
+ type: "string",
1151
+ fieldName: "idempotency_key",
1152
+ required: false,
1153
+ sortable: true,
1154
+ unique: true,
1155
+ validator: {
1156
+ input: z.string().max(255).optional(),
1157
+ output: z.string().max(255).optional()
1158
+ },
1159
+ index: true
1160
+ },
1161
+ metadata: {
1162
+ type: "json",
1163
+ fieldName: "metadata",
1164
+ required: false,
1165
+ validator: {
1166
+ input: z.record(z.string(), z.union([
1167
+ z.string(),
1168
+ z.number(),
1169
+ z.boolean()
1170
+ ])).optional(),
1171
+ output: z.record(z.string(), z.union([
1172
+ z.string(),
1173
+ z.number(),
1174
+ z.boolean()
1175
+ ])).optional()
1176
+ }
1177
+ },
1178
+ createdAt: {
1179
+ type: "date",
1180
+ fieldName: "created_at",
1181
+ required: true,
1182
+ defaultValue: () => /* @__PURE__ */ new Date(),
1183
+ sortable: true,
1184
+ input: false,
1185
+ returned: true,
1186
+ validator: { output: z.date() }
1187
+ },
1188
+ updatedAt: {
1189
+ type: "date",
1190
+ fieldName: "updated_at",
1191
+ required: true,
1192
+ defaultValue: () => /* @__PURE__ */ new Date(),
1193
+ sortable: true,
1194
+ input: false,
1195
+ returned: true,
1196
+ onUpdate: () => /* @__PURE__ */ new Date(),
1197
+ validator: { output: z.date() }
1198
+ }
1199
+ },
1200
+ constraints: {
1201
+ unique: [{
1202
+ name: "payment_methods_customer_phone_provider_unique",
1203
+ fields: [
1204
+ "customerId",
1205
+ "phone",
1206
+ "provider"
1207
+ ]
1208
+ }],
1209
+ indexes: [{
1210
+ name: "payment_methods_customer_active_idx",
1211
+ fields: ["customerId", "isActive"]
1212
+ }, {
1213
+ name: "payment_methods_provider_phone_idx",
1214
+ fields: ["provider", "phone"]
1215
+ }]
1216
+ },
1217
+ relations: {
1218
+ customer: {
1219
+ kind: "one",
1220
+ model: "customer",
1221
+ foreignKey: "customerId"
1222
+ },
1223
+ subscriptions: {
1224
+ kind: "many",
1225
+ model: "subscription",
1226
+ foreignKey: "paymentMethodId"
1227
+ }
1228
+ }
1229
+ },
1085
1230
  customer: {
1086
1231
  modelName: "customer",
1087
1232
  order: 1,
@@ -1132,8 +1277,8 @@ const getPaymentTables = (options) => {
1132
1277
  sortable: true,
1133
1278
  unique: true,
1134
1279
  validator: {
1135
- input: z.string().email().max(255),
1136
- output: z.string().email().max(255)
1280
+ input: z.email().max(255),
1281
+ output: z.email().max(255)
1137
1282
  }
1138
1283
  },
1139
1284
  defaultPaymentMethodId: {
@@ -1661,7 +1806,7 @@ const getPaymentTables = (options) => {
1661
1806
  required: true,
1662
1807
  sortable: true,
1663
1808
  validator: {
1664
- input: z.string().email().max(255),
1809
+ input: z.email().max(255),
1665
1810
  output: z.string()
1666
1811
  },
1667
1812
  index: true
@@ -2734,7 +2879,7 @@ const getPaymentTables = (options) => {
2734
2879
  required: true,
2735
2880
  sortable: true,
2736
2881
  validator: {
2737
- input: z.string().email().max(255),
2882
+ input: z.email().max(255),
2738
2883
  output: z.string()
2739
2884
  }
2740
2885
  },
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { a as defineRequestState, c as hasRequestState, d as getCurrentPaymentCo
2
2
  import { t as getAsyncLocalStorage } from "./async_hooks-D8vqDJIk.mjs";
3
3
  import { i as useMiddleware, n as createPecuniaMiddleware, r as optionsMiddleware, t as createPaymentEndpoint } from "./api-BlJV5ZQo.mjs";
4
4
  import { A as UsageAggregation, C as ScheduleStatus, D as TransactionStatus, E as SubscriptionStatus, M as WebHookEventStatus, N as statusCodes, O as TransactionType, P as ErrorType, S as ProrationBehavior, T as ScheduledTaskType, _ as PaymentIntentStatus, a as AccountType, b as PricingModel, c as BillingInterval, d as CollectionMethod, f as Currency, g as LedgerEntryType, h as InvoiceStatus, i as createProviderError, j as WebHookDeliveryTrigger, k as UsageAction, l as CheckoutSessionMode, m as ERROR_REGISTRY, n as PecuniaError, o as Actor, p as DiscountType, r as ValidationError, s as AuditAction, t as ApiError, u as CheckoutSessionStatus, v as PaymentProviders, w as ScheduledTaskStatus, x as ProductType, y as PriceType } from "./errors-vpD21Iku.mjs";
5
- 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-nzw0kf4A.mjs";
5
+ 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-DVwV2nP-.mjs";
6
6
  import { t as generateId } from "./generate-id-D3ZvbbXn.mjs";
7
7
  import { initGetFieldName } from "./db/index.mjs";
8
8
  import { a as shouldPublishLog, c as env, d as isDevelopment, f as isProduction, i as logger, l as getBooleanEnvVar, m as nodeENV, n as createLogger, o as getColorDepth, p as isTest, r as levels, s as ENV, t as TTY_COLORS, u as getEnvVar } from "./env-ChlcfGdT.mjs";
@@ -2,7 +2,7 @@ import { f as runWithEndpointContext } from "../context-COLduJme.mjs";
2
2
  import "../async_hooks-D8vqDJIk.mjs";
3
3
  import { i as useMiddleware } from "../api-BlJV5ZQo.mjs";
4
4
  import { P as ErrorType, n as PecuniaError } from "../errors-vpD21Iku.mjs";
5
- import { d as initGetModelName, f as initGetFieldAttributes, h as initGetDefaultModelName, m as initGetDefaultFieldName, p as initGetIdField, r as withApplyDefault, t as getPaymentTables } from "../get-payment-tables-nzw0kf4A.mjs";
5
+ import { d as initGetModelName, f as initGetFieldAttributes, h as initGetDefaultModelName, m as initGetDefaultFieldName, p as initGetIdField, r as withApplyDefault, t as getPaymentTables } from "../get-payment-tables-DVwV2nP-.mjs";
6
6
  import "../generate-id-D3ZvbbXn.mjs";
7
7
  import "../env-ChlcfGdT.mjs";
8
8
  import { n as safeJSONParse } from "../utils-BtfYqMRX.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pecunia-core",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",