@strimz/shared-types 0.7.0 → 0.8.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/dist/index.cjs CHANGED
@@ -1047,8 +1047,208 @@ var notificationListResponseSchema = zod.z.object({
1047
1047
  var markNotificationsReadResponseSchema = zod.z.object({
1048
1048
  lastReadAt: isoTimestampSchema
1049
1049
  });
1050
+ var paymentCurrencies = paymentCurrencySchema.options;
1051
+ var currencyAmountsShape = {
1052
+ USDC: tokenAmountSchema,
1053
+ EURC: tokenAmountSchema
1054
+ };
1055
+ var currencyAmountsSchema = zod.z.object(currencyAmountsShape).strict();
1056
+ function countsByStatusSchema(statuses) {
1057
+ const shape = Object.fromEntries(statuses.options.map((s) => [s, uintSchema]));
1058
+ return zod.z.object(shape).strict();
1059
+ }
1060
+ var moneySchema = zod.z.object({
1061
+ count: uintSchema,
1062
+ amount: currencyAmountsSchema
1063
+ });
1064
+ var volumeWindowSchema = zod.z.object({
1065
+ count: uintSchema,
1066
+ gross: currencyAmountsSchema,
1067
+ fees: currencyAmountsSchema,
1068
+ net: currencyAmountsSchema
1069
+ });
1070
+ var statsSummarySchema = zod.z.object({
1071
+ mode: modeSchema,
1072
+ generatedAt: isoTimestampSchema,
1073
+ volume: zod.z.object({
1074
+ last7d: volumeWindowSchema,
1075
+ last30d: volumeWindowSchema,
1076
+ allTime: volumeWindowSchema
1077
+ }),
1078
+ paymentSessions: zod.z.object({
1079
+ total: uintSchema,
1080
+ byStatus: countsByStatusSchema(paymentSessionStatusSchema),
1081
+ confirmed: moneySchema
1082
+ }),
1083
+ invoices: zod.z.object({
1084
+ byStatus: countsByStatusSchema(invoiceStatusSchema),
1085
+ outstanding: moneySchema,
1086
+ overdue: moneySchema,
1087
+ paidLast30d: moneySchema
1088
+ }),
1089
+ refunds: zod.z.object({
1090
+ byStatus: countsByStatusSchema(refundStatusSchema),
1091
+ completed: moneySchema
1092
+ }),
1093
+ subscriptions: zod.z.object({
1094
+ total: uintSchema,
1095
+ byStatus: countsByStatusSchema(subscriptionStatusSchema)
1096
+ }),
1097
+ customers: zod.z.object({
1098
+ total: uintSchema
1099
+ })
1100
+ });
1101
+ var STATS_VOLUME_MAX_DAYS = 366;
1102
+ var STATS_VOLUME_DEFAULT_DAYS = 30;
1103
+ function resolveStatsVolumeRange(query, now = Date.now()) {
1104
+ const to = query.to ? new Date(query.to) : new Date(now);
1105
+ const from = query.from ? new Date(query.from) : new Date(to.getTime() - STATS_VOLUME_DEFAULT_DAYS * 864e5);
1106
+ return { from, to };
1107
+ }
1108
+ var statsVolumeQuerySchema = zod.z.object({
1109
+ from: isoTimestampSchema.optional(),
1110
+ to: isoTimestampSchema.optional()
1111
+ }).strict().superRefine((q, ctx) => {
1112
+ const { from, to } = resolveStatsVolumeRange(q);
1113
+ if (from.getTime() > to.getTime()) {
1114
+ ctx.addIssue({
1115
+ code: zod.z.ZodIssueCode.custom,
1116
+ message: "from must not be after to",
1117
+ path: ["from"]
1118
+ });
1119
+ } else if (to.getTime() - from.getTime() > STATS_VOLUME_MAX_DAYS * 864e5) {
1120
+ ctx.addIssue({
1121
+ code: zod.z.ZodIssueCode.custom,
1122
+ message: `from and to must be at most ${STATS_VOLUME_MAX_DAYS} days apart`,
1123
+ path: ["to"]
1124
+ });
1125
+ }
1126
+ });
1127
+ var dayKeySchema = zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "must be a YYYY-MM-DD day");
1128
+ var statsVolumeDaySchema = zod.z.object({
1129
+ day: dayKeySchema,
1130
+ currency: paymentCurrencySchema,
1131
+ count: uintSchema,
1132
+ gross: tokenAmountSchema,
1133
+ fees: tokenAmountSchema,
1134
+ net: tokenAmountSchema
1135
+ });
1136
+ var statsVolumeSchema = zod.z.object({
1137
+ from: isoTimestampSchema,
1138
+ to: isoTimestampSchema,
1139
+ data: zod.z.array(statsVolumeDaySchema)
1140
+ });
1141
+ var statsMrrSchema = zod.z.object({
1142
+ mrr: currencyAmountsSchema,
1143
+ activeSubscribers: uintSchema
1144
+ });
1145
+ var statsLtvQuerySchema = zod.z.object({
1146
+ currency: paymentCurrencySchema,
1147
+ limit: zod.z.coerce.number().int().min(1).max(100).default(25),
1148
+ cursor: zod.z.string().min(1).max(200).optional()
1149
+ }).strict();
1150
+ var statsLtvRowSchema = zod.z.object({
1151
+ customerId: idSchema,
1152
+ totalSpend: tokenAmountSchema,
1153
+ transactionCount: uintSchema
1154
+ });
1155
+ var statsLtvSchema = zod.z.object({
1156
+ currency: paymentCurrencySchema,
1157
+ data: zod.z.array(statsLtvRowSchema),
1158
+ nextCursor: zod.z.string().nullable(),
1159
+ hasMore: zod.z.boolean()
1160
+ });
1161
+ var forecastConfidenceSchema = zod.z.enum(["low", "medium", "high"]);
1162
+ var forecastSchema = zod.z.object({
1163
+ confidence: forecastConfidenceSchema,
1164
+ last90DayRevenue: tokenAmountSchema,
1165
+ next30: tokenAmountSchema,
1166
+ next60: tokenAmountSchema,
1167
+ next90: tokenAmountSchema
1168
+ });
1169
+ var forecastByCurrencyShape = {
1170
+ USDC: forecastSchema,
1171
+ EURC: forecastSchema
1172
+ };
1173
+ var statsForecastSchema = zod.z.object({
1174
+ byCurrency: zod.z.object(forecastByCurrencyShape).strict()
1175
+ });
1176
+ var adminStatsModeQuerySchema = zod.z.object({
1177
+ mode: modeSchema.default("live")
1178
+ }).strict();
1179
+ var adminOverviewSchema = zod.z.object({
1180
+ mode: modeSchema,
1181
+ merchants: zod.z.object({
1182
+ total: uintSchema,
1183
+ byStatus: zod.z.record(zod.z.string(), uintSchema),
1184
+ last30dSignups: uintSchema
1185
+ }),
1186
+ volume: zod.z.object({
1187
+ lifetime: currencyAmountsSchema,
1188
+ lifetimeFees: currencyAmountsSchema,
1189
+ last30d: currencyAmountsSchema,
1190
+ confirmedSessions: uintSchema
1191
+ }),
1192
+ subscriptions: zod.z.object({
1193
+ active: uintSchema,
1194
+ mrr: currencyAmountsSchema
1195
+ })
1196
+ });
1197
+ var adminMerchantStatsSchema = zod.z.object({
1198
+ mode: modeSchema,
1199
+ confirmedPayments: uintSchema,
1200
+ activeSubscriptions: uintSchema,
1201
+ lifetimeVolume: currencyAmountsSchema,
1202
+ last30dVolume: currencyAmountsSchema
1203
+ });
1204
+ var adminVolumeQuerySchema = zod.z.object({
1205
+ from: isoTimestampSchema.optional(),
1206
+ to: isoTimestampSchema.optional(),
1207
+ mode: modeSchema.default("live")
1208
+ }).strict();
1209
+ var adminVolumeDaySchema = zod.z.object({
1210
+ day: dayKeySchema,
1211
+ currency: paymentCurrencySchema,
1212
+ volume: tokenAmountSchema,
1213
+ fees: tokenAmountSchema,
1214
+ count: uintSchema
1215
+ });
1216
+ var adminVolumeSeriesSchema = zod.z.object({
1217
+ mode: modeSchema,
1218
+ from: isoTimestampSchema,
1219
+ to: isoTimestampSchema,
1220
+ data: zod.z.array(adminVolumeDaySchema)
1221
+ });
1222
+ var adminTopMerchantsQuerySchema = zod.z.object({
1223
+ currency: paymentCurrencySchema,
1224
+ mode: modeSchema.default("live"),
1225
+ limit: zod.z.coerce.number().int().min(1).max(50).default(10)
1226
+ }).strict();
1227
+ var adminTopMerchantSchema = zod.z.object({
1228
+ merchantId: idSchema,
1229
+ businessName: zod.z.string().nullable(),
1230
+ email: zod.z.string(),
1231
+ volume: tokenAmountSchema,
1232
+ transactionCount: uintSchema
1233
+ });
1234
+ var adminTopMerchantsSchema = zod.z.object({
1235
+ mode: modeSchema,
1236
+ currency: paymentCurrencySchema,
1237
+ data: zod.z.array(adminTopMerchantSchema)
1238
+ });
1050
1239
 
1051
1240
  exports.DEFAULT_MERCHANT_EMAIL_PREFS = DEFAULT_MERCHANT_EMAIL_PREFS;
1241
+ exports.STATS_VOLUME_DEFAULT_DAYS = STATS_VOLUME_DEFAULT_DAYS;
1242
+ exports.STATS_VOLUME_MAX_DAYS = STATS_VOLUME_MAX_DAYS;
1243
+ exports.adminMerchantStatsSchema = adminMerchantStatsSchema;
1244
+ exports.adminOverviewSchema = adminOverviewSchema;
1245
+ exports.adminStatsModeQuerySchema = adminStatsModeQuerySchema;
1246
+ exports.adminTopMerchantSchema = adminTopMerchantSchema;
1247
+ exports.adminTopMerchantsQuerySchema = adminTopMerchantsQuerySchema;
1248
+ exports.adminTopMerchantsSchema = adminTopMerchantsSchema;
1249
+ exports.adminVolumeDaySchema = adminVolumeDaySchema;
1250
+ exports.adminVolumeQuerySchema = adminVolumeQuerySchema;
1251
+ exports.adminVolumeSeriesSchema = adminVolumeSeriesSchema;
1052
1252
  exports.agentActionExecutedEventSchema = agentActionExecutedEventSchema;
1053
1253
  exports.agentActionOutcomeSchema = agentActionOutcomeSchema;
1054
1254
  exports.agentActionTypeSchema = agentActionTypeSchema;
@@ -1095,10 +1295,13 @@ exports.createSubscriptionInputSchema = createSubscriptionInputSchema;
1095
1295
  exports.createSubscriptionPlanInputSchema = createSubscriptionPlanInputSchema;
1096
1296
  exports.createWebhookEndpointInputSchema = createWebhookEndpointInputSchema;
1097
1297
  exports.createWebhookEndpointOutputSchema = createWebhookEndpointOutputSchema;
1298
+ exports.currencyAmountsSchema = currencyAmountsSchema;
1098
1299
  exports.customerSchema = customerSchema;
1099
1300
  exports.emailSchema = emailSchema;
1100
1301
  exports.evmAddressSchema = evmAddressSchema;
1101
1302
  exports.evmTxHashSchema = evmTxHashSchema;
1303
+ exports.forecastConfidenceSchema = forecastConfidenceSchema;
1304
+ exports.forecastSchema = forecastSchema;
1102
1305
  exports.httpUrlSchema = httpUrlSchema;
1103
1306
  exports.httpsUrlSchema = httpsUrlSchema;
1104
1307
  exports.idSchema = idSchema;
@@ -1124,6 +1327,7 @@ exports.merchantStatusSchema = merchantStatusSchema;
1124
1327
  exports.merchantTierSchema = merchantTierSchema;
1125
1328
  exports.metadataSchema = metadataSchema;
1126
1329
  exports.modeSchema = modeSchema;
1330
+ exports.moneySchema = moneySchema;
1127
1331
  exports.notificationKindSchema = notificationKindSchema;
1128
1332
  exports.notificationListResponseSchema = notificationListResponseSchema;
1129
1333
  exports.notificationSchema = notificationSchema;
@@ -1131,6 +1335,7 @@ exports.onboardMerchantInputSchema = onboardMerchantInputSchema;
1131
1335
  exports.paginationInputSchema = paginationInputSchema;
1132
1336
  exports.paymentCompletedEventSchema = paymentCompletedEventSchema;
1133
1337
  exports.paymentCreatedEventSchema = paymentCreatedEventSchema;
1338
+ exports.paymentCurrencies = paymentCurrencies;
1134
1339
  exports.paymentCurrencySchema = paymentCurrencySchema;
1135
1340
  exports.paymentFailedEventSchema = paymentFailedEventSchema;
1136
1341
  exports.paymentSessionSchema = paymentSessionSchema;
@@ -1144,7 +1349,17 @@ exports.refundSchema = refundSchema;
1144
1349
  exports.refundSigningInstructionsSchema = refundSigningInstructionsSchema;
1145
1350
  exports.refundStatusSchema = refundStatusSchema;
1146
1351
  exports.replayDeliveryInputSchema = replayDeliveryInputSchema;
1352
+ exports.resolveStatsVolumeRange = resolveStatsVolumeRange;
1147
1353
  exports.rotateApiKeyInputSchema = rotateApiKeyInputSchema;
1354
+ exports.statsForecastSchema = statsForecastSchema;
1355
+ exports.statsLtvQuerySchema = statsLtvQuerySchema;
1356
+ exports.statsLtvRowSchema = statsLtvRowSchema;
1357
+ exports.statsLtvSchema = statsLtvSchema;
1358
+ exports.statsMrrSchema = statsMrrSchema;
1359
+ exports.statsSummarySchema = statsSummarySchema;
1360
+ exports.statsVolumeDaySchema = statsVolumeDaySchema;
1361
+ exports.statsVolumeQuerySchema = statsVolumeQuerySchema;
1362
+ exports.statsVolumeSchema = statsVolumeSchema;
1148
1363
  exports.storefrontCheckoutInputSchema = storefrontCheckoutInputSchema;
1149
1364
  exports.storefrontCheckoutResponseSchema = storefrontCheckoutResponseSchema;
1150
1365
  exports.storefrontProductSchema = storefrontProductSchema;
@@ -1182,6 +1397,7 @@ exports.uintSchema = uintSchema;
1182
1397
  exports.updateAgentConfigInputSchema = updateAgentConfigInputSchema;
1183
1398
  exports.updateMerchantInputSchema = updateMerchantInputSchema;
1184
1399
  exports.upsertCustomerInputSchema = upsertCustomerInputSchema;
1400
+ exports.volumeWindowSchema = volumeWindowSchema;
1185
1401
  exports.webhookDeliveryDetailSchema = webhookDeliveryDetailSchema;
1186
1402
  exports.webhookDeliverySchema = webhookDeliverySchema;
1187
1403
  exports.webhookDeliveryStatusSchema = webhookDeliveryStatusSchema;