@deepintel-ltd/farmpro-contracts 1.5.13 → 1.5.15
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 +623 -0
- package/dist/routes/agents.routes.d.ts.map +1 -1
- package/dist/routes/agents.routes.js +18 -1
- package/dist/routes/auth.routes.d.ts +509 -0
- package/dist/routes/auth.routes.d.ts.map +1 -1
- package/dist/routes/auth.routes.js +26 -2
- package/dist/routes/field-monitoring.routes.d.ts +18 -18
- 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/agents.schemas.d.ts +916 -0
- package/dist/schemas/agents.schemas.d.ts.map +1 -1
- package/dist/schemas/agents.schemas.js +34 -0
- package/dist/schemas/auth.schemas.d.ts +306 -0
- package/dist/schemas/auth.schemas.d.ts.map +1 -1
- package/dist/schemas/auth.schemas.js +26 -0
- package/dist/schemas/field-monitoring.schemas.d.ts +18 -18
- 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.routes.d.ts","sourceRoot":"","sources":["../../src/routes/subscriptions.routes.ts"],"names":[],"mappings":"AAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+J9B,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { initContract } from '@ts-rest/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { subscriptionResponseSchema, subscriptionListResponseSchema, upgradeSubscriptionAttributesSchema, usageTrackingListResponseSchema, tierLimitsResponseSchema, currentUsageResponseSchema, availablePlansResponseSchema, } from '../schemas/subscriptions.schemas';
|
|
4
|
+
import { jsonApiErrorResponseSchema, jsonApiPaginationQuerySchema, } from '../schemas/common.schemas';
|
|
5
|
+
const c = initContract();
|
|
6
|
+
export const subscriptionsRouter = c.router({
|
|
7
|
+
// Get all available subscription plans (public endpoint for landing page)
|
|
8
|
+
getAvailablePlans: {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: '/subscriptions/plans',
|
|
11
|
+
query: z.object({
|
|
12
|
+
'currency': z.enum(['NGN', 'USD']).optional(),
|
|
13
|
+
'country': z.string().optional(), // ISO 3166-1 alpha-2 country code (e.g., 'NG', 'US')
|
|
14
|
+
'farmId': z.string().uuid().optional(), // Optional: use farm location for detection
|
|
15
|
+
}),
|
|
16
|
+
responses: {
|
|
17
|
+
200: availablePlansResponseSchema,
|
|
18
|
+
},
|
|
19
|
+
summary: 'Get available subscription plans',
|
|
20
|
+
description: 'Get all available subscription tiers with pricing and features. Pricing is automatically detected based on location (farm, IP, or explicit hint).',
|
|
21
|
+
},
|
|
22
|
+
// Get current subscription for a farm
|
|
23
|
+
getCurrentSubscription: {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
path: '/farms/:farmId/subscription',
|
|
26
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
27
|
+
responses: {
|
|
28
|
+
200: subscriptionResponseSchema,
|
|
29
|
+
404: jsonApiErrorResponseSchema,
|
|
30
|
+
401: jsonApiErrorResponseSchema,
|
|
31
|
+
},
|
|
32
|
+
summary: 'Get current subscription',
|
|
33
|
+
description: 'Get the current active subscription for a farm',
|
|
34
|
+
},
|
|
35
|
+
// Get subscription by ID
|
|
36
|
+
getSubscription: {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: '/farms/:farmId/subscriptions/:id',
|
|
39
|
+
pathParams: z.object({
|
|
40
|
+
farmId: z.string().uuid(),
|
|
41
|
+
id: z.string().uuid(),
|
|
42
|
+
}),
|
|
43
|
+
responses: {
|
|
44
|
+
200: subscriptionResponseSchema,
|
|
45
|
+
404: jsonApiErrorResponseSchema,
|
|
46
|
+
401: jsonApiErrorResponseSchema,
|
|
47
|
+
},
|
|
48
|
+
summary: 'Get subscription by ID',
|
|
49
|
+
description: 'Get a specific subscription by ID',
|
|
50
|
+
},
|
|
51
|
+
// List all subscriptions for a farm
|
|
52
|
+
listSubscriptions: {
|
|
53
|
+
method: 'GET',
|
|
54
|
+
path: '/farms/:farmId/subscriptions',
|
|
55
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
56
|
+
query: jsonApiPaginationQuerySchema.merge(z.object({
|
|
57
|
+
'filter[status]': z.enum(['active', 'cancelled', 'expired', 'trial']).optional(),
|
|
58
|
+
'filter[tier]': z.enum(['FREE', 'STARTER_PACK', 'COOPERATIVE', 'ENTERPRISE', 'GOVERNMENT']).optional(),
|
|
59
|
+
})),
|
|
60
|
+
responses: {
|
|
61
|
+
200: subscriptionListResponseSchema,
|
|
62
|
+
404: jsonApiErrorResponseSchema,
|
|
63
|
+
401: jsonApiErrorResponseSchema,
|
|
64
|
+
},
|
|
65
|
+
summary: 'List subscriptions',
|
|
66
|
+
description: 'Get all subscriptions for a farm with optional filtering',
|
|
67
|
+
},
|
|
68
|
+
// Upgrade subscription
|
|
69
|
+
upgradeSubscription: {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
path: '/farms/:farmId/subscriptions/upgrade',
|
|
72
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
73
|
+
body: z.object({
|
|
74
|
+
data: z.object({
|
|
75
|
+
type: z.literal('subscriptions'),
|
|
76
|
+
attributes: upgradeSubscriptionAttributesSchema,
|
|
77
|
+
}),
|
|
78
|
+
}),
|
|
79
|
+
responses: {
|
|
80
|
+
200: subscriptionResponseSchema,
|
|
81
|
+
400: jsonApiErrorResponseSchema,
|
|
82
|
+
404: jsonApiErrorResponseSchema,
|
|
83
|
+
401: jsonApiErrorResponseSchema,
|
|
84
|
+
},
|
|
85
|
+
summary: 'Upgrade subscription',
|
|
86
|
+
description: 'Upgrade a farm subscription to a new tier',
|
|
87
|
+
},
|
|
88
|
+
// Cancel subscription
|
|
89
|
+
cancelSubscription: {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
path: '/farms/:farmId/subscriptions/:id/cancel',
|
|
92
|
+
pathParams: z.object({
|
|
93
|
+
farmId: z.string().uuid(),
|
|
94
|
+
id: z.string().uuid(),
|
|
95
|
+
}),
|
|
96
|
+
body: z.object({}).optional(),
|
|
97
|
+
responses: {
|
|
98
|
+
200: subscriptionResponseSchema,
|
|
99
|
+
404: jsonApiErrorResponseSchema,
|
|
100
|
+
401: jsonApiErrorResponseSchema,
|
|
101
|
+
},
|
|
102
|
+
summary: 'Cancel subscription',
|
|
103
|
+
description: 'Cancel an active subscription',
|
|
104
|
+
},
|
|
105
|
+
// Get tier limits
|
|
106
|
+
getTierLimits: {
|
|
107
|
+
method: 'GET',
|
|
108
|
+
path: '/farms/:farmId/subscription/limits',
|
|
109
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
110
|
+
responses: {
|
|
111
|
+
200: z.object({
|
|
112
|
+
data: tierLimitsResponseSchema,
|
|
113
|
+
}),
|
|
114
|
+
404: jsonApiErrorResponseSchema,
|
|
115
|
+
401: jsonApiErrorResponseSchema,
|
|
116
|
+
},
|
|
117
|
+
summary: 'Get tier limits',
|
|
118
|
+
description: 'Get the limits for the current subscription tier',
|
|
119
|
+
},
|
|
120
|
+
// Get usage tracking
|
|
121
|
+
getUsageTracking: {
|
|
122
|
+
method: 'GET',
|
|
123
|
+
path: '/farms/:farmId/subscription/usage',
|
|
124
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
125
|
+
query: z.object({
|
|
126
|
+
'filter[resourceType]': z.string().optional(), // 'ai_image', 'satellite_check', etc.
|
|
127
|
+
'filter[periodStart]': z.string().datetime().optional(),
|
|
128
|
+
}),
|
|
129
|
+
responses: {
|
|
130
|
+
200: usageTrackingListResponseSchema,
|
|
131
|
+
404: jsonApiErrorResponseSchema,
|
|
132
|
+
401: jsonApiErrorResponseSchema,
|
|
133
|
+
},
|
|
134
|
+
summary: 'Get usage tracking',
|
|
135
|
+
description: 'Get usage tracking data for the current subscription period',
|
|
136
|
+
},
|
|
137
|
+
// Get current usage for a specific resource
|
|
138
|
+
getCurrentUsage: {
|
|
139
|
+
method: 'GET',
|
|
140
|
+
path: '/farms/:farmId/subscription/usage/:resourceType',
|
|
141
|
+
pathParams: z.object({
|
|
142
|
+
farmId: z.string().uuid(),
|
|
143
|
+
resourceType: z.string(), // 'ai_image', 'satellite_check', etc.
|
|
144
|
+
}),
|
|
145
|
+
responses: {
|
|
146
|
+
200: z.object({
|
|
147
|
+
data: currentUsageResponseSchema,
|
|
148
|
+
}),
|
|
149
|
+
404: jsonApiErrorResponseSchema,
|
|
150
|
+
401: jsonApiErrorResponseSchema,
|
|
151
|
+
},
|
|
152
|
+
summary: 'Get current usage',
|
|
153
|
+
description: 'Get current usage for a specific resource type in the current period',
|
|
154
|
+
},
|
|
155
|
+
});
|