@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
80 lines • 3.89 kB
JavaScript
import { z } from 'zod';
import { BaseResponseSchema } from '../../../core/schemas';
import { NotificationCreateParamsSchema } from '../schemas';
// Create response schemas using BaseResponseSchema directly
const UnknownResponseSchema = BaseResponseSchema(z.unknown());
/**
* Creates the notifications resource methods
* OpenAPI Path: /notifications → notifications.*
* @description Create and manage system notifications for agricultural content and site events
*/
export function createNotificationsResource(executeRequest) {
return {
/**
* Create new notification
* @description Creates a new system notification for agricultural events, alerts, or content updates
* @fullPath api.agrSite.notifications.create
* @service agr-site
* @domain notification-management
* @dataMethod notificationsData.create - returns only the created notification data without metadata
* @discoverable true
* @searchTerms ["notifications", "alerts", "system notifications", "agricultural alerts", "content notifications", "site alerts"]
* @relatedEndpoints ["api.agrSite.settings.list", "api.agrSite.fyxerTranscript.create", "api.agrSite.openSearch.embedding.get"]
* @commonPatterns ["Create notification", "Send alert", "System notification", "Agricultural event notification"]
* @workflow ["notification-management", "alert-processing", "content-notifications", "agricultural-alerts"]
* @prerequisites ["Valid authentication token", "Notification create permissions", "Valid notification data"]
* @nextSteps ["Process notification delivery", "Track notification status"]
* @businessRules ["Agricultural content notifications prioritized", "Rate limited for spam prevention", "Content filtered for relevance"]
* @functionalArea "site-content-and-ai-processing"
* @caching "No caching - immediate notification creation"
* @performance "Fast notification creation with asynchronous delivery"
* @param params Notification creation parameters including content, recipients, and metadata
* @returns Promise<BaseResponse<unknown>> Complete response with created notification details and delivery status
* @example
* ```typescript
* const notification = await client.notifications.create({
* title: 'Crop Update Alert',
* message: 'New agricultural data available for your region',
* type: 'agricultural_update',
* priority: 'high',
* metadata: {
* region: 'midwest',
* crop_type: 'corn',
* season: 'spring_2024'
* }
* });
*
* // Get just the notification data
* const notificationData = await client.notificationsData.create({
* title: 'Weather Alert',
* message: 'Severe weather warning for your farming area'
* });
* ```
*/
create: async (params) => {
return executeRequest({
method: 'POST',
path: '/notifications',
paramsSchema: NotificationCreateParamsSchema,
responseSchema: UnknownResponseSchema,
}, params);
},
};
}
/**
* Creates the notificationsData resource methods (data-only versions)
*/
export function createNotificationsDataResource(notifications) {
return {
/**
* Create notification and return data without response metadata
* @param params Notification creation parameters
* @returns Promise<unknown> Created notification data directly
*/
create: async (params) => {
const response = await notifications.create(params);
return response.data;
},
};
}
//# sourceMappingURL=notifications.js.map