@deepintel-ltd/farmpro-contracts 1.5.14 → 1.5.16
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.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/routes/agents.routes.d.ts +3 -3
- package/dist/routes/agents.routes.js +1 -1
- package/dist/routes/auth.routes.d.ts +516 -0
- package/dist/routes/auth.routes.d.ts.map +1 -1
- package/dist/routes/auth.routes.js +26 -2
- package/dist/routes/index.d.ts +6 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +4 -0
- package/dist/routes/payments.routes.d.ts +1851 -0
- package/dist/routes/payments.routes.d.ts.map +1 -0
- package/dist/routes/payments.routes.js +91 -0
- package/dist/routes/subscriptions.routes.d.ts +3151 -0
- package/dist/routes/subscriptions.routes.d.ts.map +1 -0
- package/dist/routes/subscriptions.routes.js +155 -0
- package/dist/schemas/auth.schemas.d.ts +314 -0
- package/dist/schemas/auth.schemas.d.ts.map +1 -1
- package/dist/schemas/auth.schemas.js +27 -0
- package/dist/schemas/payments.schemas.d.ts +822 -0
- package/dist/schemas/payments.schemas.d.ts.map +1 -0
- package/dist/schemas/payments.schemas.js +105 -0
- package/dist/schemas/subscriptions.schemas.d.ts +1344 -0
- package/dist/schemas/subscriptions.schemas.d.ts.map +1 -0
- package/dist/schemas/subscriptions.schemas.js +150 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/subscriptions.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AAGH,eAAO,MAAM,sBAAsB,gFAMjC,CAAC;AAGH,eAAO,MAAM,wBAAwB,wDAKnC,CAAC;AAGH,eAAO,MAAM,kBAAkB,yDAK7B,CAAC;AAGH,eAAO,MA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C,CAAC;AAE1E,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAC9F,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAChG,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAClE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AACtE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { timestampsSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema, } from './common.schemas';
|
|
3
|
+
import { paymentGatewaySchema, paymentCurrencySchema } from './payments.schemas';
|
|
4
|
+
/**
|
|
5
|
+
* Subscription schemas - JSON:API compliant
|
|
6
|
+
*/
|
|
7
|
+
// Subscription tier enum
|
|
8
|
+
export const subscriptionTierSchema = z.enum([
|
|
9
|
+
'FREE',
|
|
10
|
+
'STARTER_PACK',
|
|
11
|
+
'COOPERATIVE',
|
|
12
|
+
'ENTERPRISE',
|
|
13
|
+
'GOVERNMENT',
|
|
14
|
+
]);
|
|
15
|
+
// Subscription status enum
|
|
16
|
+
export const subscriptionStatusSchema = z.enum([
|
|
17
|
+
'active',
|
|
18
|
+
'cancelled',
|
|
19
|
+
'expired',
|
|
20
|
+
'trial',
|
|
21
|
+
]);
|
|
22
|
+
// Billing cycle enum
|
|
23
|
+
export const billingCycleSchema = z.enum([
|
|
24
|
+
'monthly',
|
|
25
|
+
'annual',
|
|
26
|
+
'bi_annual',
|
|
27
|
+
'custom',
|
|
28
|
+
]);
|
|
29
|
+
// Satellite frequency enum
|
|
30
|
+
export const satelliteFrequencySchema = z.enum(['monthly', 'weekly', 'daily']);
|
|
31
|
+
// Re-export payment gateway and currency schemas from payments to avoid duplication
|
|
32
|
+
// Subscription attributes schema (for JSON:API attributes object)
|
|
33
|
+
export const subscriptionAttributesSchema = z.object({
|
|
34
|
+
tier: subscriptionTierSchema,
|
|
35
|
+
status: subscriptionStatusSchema,
|
|
36
|
+
amount: z.number().nullable().optional(),
|
|
37
|
+
currency: paymentCurrencySchema,
|
|
38
|
+
billingCycle: billingCycleSchema.nullable().optional(),
|
|
39
|
+
currentPeriodStart: z.string().datetime(),
|
|
40
|
+
currentPeriodEnd: z.string().datetime(),
|
|
41
|
+
cancelledAt: z.string().datetime().nullable().optional(),
|
|
42
|
+
paymentGateway: paymentGatewaySchema.nullable().optional(),
|
|
43
|
+
gatewaySubscriptionId: z.string().nullable().optional(),
|
|
44
|
+
maxFields: z.number().int().nullable().optional(),
|
|
45
|
+
maxAiImagesPerMonth: z.number().int().nullable().optional(),
|
|
46
|
+
satelliteFrequency: satelliteFrequencySchema.nullable().optional(),
|
|
47
|
+
}).merge(timestampsSchema);
|
|
48
|
+
// Subscription attributes for creation (input)
|
|
49
|
+
export const createSubscriptionAttributesSchema = z.object({
|
|
50
|
+
tier: subscriptionTierSchema,
|
|
51
|
+
amount: z.number().positive().optional(),
|
|
52
|
+
currency: paymentCurrencySchema.default('NGN'),
|
|
53
|
+
billingCycle: billingCycleSchema.optional(),
|
|
54
|
+
paymentGateway: paymentGatewaySchema.optional(),
|
|
55
|
+
gatewaySubscriptionId: z.string().optional(),
|
|
56
|
+
});
|
|
57
|
+
// Subscription attributes for upgrade (input)
|
|
58
|
+
export const upgradeSubscriptionAttributesSchema = z.object({
|
|
59
|
+
tier: subscriptionTierSchema,
|
|
60
|
+
amount: z.number().positive(),
|
|
61
|
+
currency: paymentCurrencySchema.default('NGN'),
|
|
62
|
+
billingCycle: billingCycleSchema,
|
|
63
|
+
paymentGateway: paymentGatewaySchema.optional(),
|
|
64
|
+
gatewaySubscriptionId: z.string().optional(),
|
|
65
|
+
});
|
|
66
|
+
// Subscription resource schema (JSON:API resource object)
|
|
67
|
+
export const subscriptionResourceSchema = z.object({
|
|
68
|
+
type: z.literal('subscriptions'),
|
|
69
|
+
id: z.string().uuid(),
|
|
70
|
+
attributes: subscriptionAttributesSchema,
|
|
71
|
+
});
|
|
72
|
+
// Subscription response schema (single)
|
|
73
|
+
export const subscriptionResponseSchema = jsonApiSingleResponseSchema(subscriptionResourceSchema);
|
|
74
|
+
// Subscription list response schema
|
|
75
|
+
export const subscriptionListResponseSchema = jsonApiCollectionResponseSchema(subscriptionResourceSchema);
|
|
76
|
+
// Usage tracking attributes schema
|
|
77
|
+
export const usageTrackingAttributesSchema = z.object({
|
|
78
|
+
resourceType: z.string(), // 'ai_image', 'satellite_check', 'sms_alert'
|
|
79
|
+
count: z.number().int().nonnegative(),
|
|
80
|
+
periodStart: z.string().datetime(),
|
|
81
|
+
periodEnd: z.string().datetime(),
|
|
82
|
+
}).merge(timestampsSchema);
|
|
83
|
+
// Usage tracking resource schema
|
|
84
|
+
export const usageTrackingResourceSchema = z.object({
|
|
85
|
+
type: z.literal('usage-tracking'),
|
|
86
|
+
id: z.string().uuid(),
|
|
87
|
+
attributes: usageTrackingAttributesSchema,
|
|
88
|
+
});
|
|
89
|
+
// Usage tracking response schema
|
|
90
|
+
export const usageTrackingResponseSchema = jsonApiSingleResponseSchema(usageTrackingResourceSchema);
|
|
91
|
+
// Usage tracking list response schema
|
|
92
|
+
export const usageTrackingListResponseSchema = jsonApiCollectionResponseSchema(usageTrackingResourceSchema);
|
|
93
|
+
// Tier limits response schema
|
|
94
|
+
export const tierLimitsResponseSchema = z.object({
|
|
95
|
+
maxFields: z.number().int().nullable(),
|
|
96
|
+
maxAiImagesPerMonth: z.number().int().nullable(),
|
|
97
|
+
satelliteFrequency: satelliteFrequencySchema,
|
|
98
|
+
});
|
|
99
|
+
// Current usage response schema
|
|
100
|
+
export const currentUsageResponseSchema = z.object({
|
|
101
|
+
resourceType: z.string(),
|
|
102
|
+
count: z.number().int().nonnegative(),
|
|
103
|
+
limit: z.number().int().nullable(),
|
|
104
|
+
periodStart: z.string().datetime(),
|
|
105
|
+
periodEnd: z.string().datetime(),
|
|
106
|
+
});
|
|
107
|
+
// Available subscription plan schema (for landing page)
|
|
108
|
+
export const availablePlanSchema = z.object({
|
|
109
|
+
tier: subscriptionTierSchema,
|
|
110
|
+
name: z.string(), // Display name (e.g., "Starter Pack")
|
|
111
|
+
description: z.string(), // Short description
|
|
112
|
+
pricing: z.object({
|
|
113
|
+
monthly: z.object({
|
|
114
|
+
ngn: z.number().nullable(), // NGN amount, null for FREE or custom pricing
|
|
115
|
+
usd: z.number().nullable(), // USD amount, null for FREE or custom pricing
|
|
116
|
+
}).nullable(), // null if monthly not available
|
|
117
|
+
annual: z.object({
|
|
118
|
+
ngn: z.number().nullable(), // NGN amount, null for FREE or custom pricing
|
|
119
|
+
usd: z.number().nullable(), // USD amount, null for FREE or custom pricing
|
|
120
|
+
}).nullable(), // null if annual not available
|
|
121
|
+
custom: z.boolean(), // true if pricing is custom (COOPERATIVE, ENTERPRISE, GOVERNMENT)
|
|
122
|
+
}),
|
|
123
|
+
features: z.object({
|
|
124
|
+
maxFields: z.number().int().nullable(), // null = unlimited
|
|
125
|
+
maxAiImagesPerMonth: z.number().int().nullable(), // null = unlimited
|
|
126
|
+
satelliteFrequency: satelliteFrequencySchema.nullable(),
|
|
127
|
+
agronomicsAdvisor: z.boolean(),
|
|
128
|
+
agronomicsAdvisorLimit: z.number().int().nullable(), // null = unlimited
|
|
129
|
+
weatherAlerts: z.boolean(),
|
|
130
|
+
weatherAlertsLimit: z.number().int().nullable(), // null = unlimited
|
|
131
|
+
apiAccess: z.boolean(),
|
|
132
|
+
whiteLabel: z.boolean(),
|
|
133
|
+
cooperativeTools: z.boolean(),
|
|
134
|
+
extensionWorkerUI: z.boolean(),
|
|
135
|
+
meDashboard: z.boolean(),
|
|
136
|
+
support: z.enum(['community', 'email', 'phone', 'dedicated']),
|
|
137
|
+
}),
|
|
138
|
+
popular: z.boolean().optional(), // Mark popular/recommended plan
|
|
139
|
+
});
|
|
140
|
+
// Available plans response schema
|
|
141
|
+
export const availablePlansResponseSchema = z.object({
|
|
142
|
+
data: z.array(availablePlanSchema),
|
|
143
|
+
meta: z.object({
|
|
144
|
+
detectedLocation: z.object({
|
|
145
|
+
country: z.string(), // ISO 3166-1 alpha-2 country code
|
|
146
|
+
countryName: z.string(),
|
|
147
|
+
currency: z.enum(['NGN', 'USD']),
|
|
148
|
+
}),
|
|
149
|
+
}).optional(), // Optional: location detection metadata
|
|
150
|
+
});
|