473 lines
17 KiB
TypeScript
473 lines
17 KiB
TypeScript
|
|
import { createQueryApi } from '@kevisual/query/api';
|
|
const api = {
|
|
"test": {
|
|
/**
|
|
* test route
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.a - {string} arg a
|
|
*/
|
|
"test": {
|
|
"path": "test",
|
|
"key": "test",
|
|
"description": "test route",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"a": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"description": "arg a",
|
|
"type": "string",
|
|
"optional": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"demo": {
|
|
/**
|
|
* First demo route demonstrating string and number parameters
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.username - {string (minLength: 3, maxLength: 20)} The username to be validated, must be between 3 and 20 characters
|
|
* @param data.age - {number (min: 18, max: 100)} The age of the user, must be between 18 and 100
|
|
* @param data.email - {string (format: email)} The email address of the user for notification purposes
|
|
* @param data.count - {integer (max: 9007199254740991, > 0)} The number of items to process, must be a positive integer
|
|
* @param data.name - {string} The display name of the user
|
|
*/
|
|
"d1": {
|
|
"path": "demo",
|
|
"key": "d1",
|
|
"description": "First demo route demonstrating string and number parameters",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"username": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"description": "The username to be validated, must be between 3 and 20 characters",
|
|
"type": "string",
|
|
"minLength": 3,
|
|
"maxLength": 20,
|
|
"optional": true
|
|
},
|
|
"age": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "number",
|
|
"minimum": 18,
|
|
"maximum": 100,
|
|
"description": "The age of the user, must be between 18 and 100"
|
|
},
|
|
"email": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "string",
|
|
"format": "email",
|
|
"pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
|
|
"description": "The email address of the user for notification purposes"
|
|
},
|
|
"count": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 9007199254740991,
|
|
"description": "The number of items to process, must be a positive integer"
|
|
},
|
|
"name": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "string",
|
|
"description": "The display name of the user"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Second demo route for boolean and enum parameters
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.isActive - {boolean} Whether the user account is currently active and accessible
|
|
* @param data.isAdmin - {boolean} Whether the user has administrative privileges
|
|
* @param data.notifications - {boolean} Whether to enable email and push notifications
|
|
* @param data.mode - {"read" | "write" | "execute"} The operation mode for the current session
|
|
* @param data.verified - {boolean} Whether the user email has been verified
|
|
*/
|
|
"d2": {
|
|
"path": "demo",
|
|
"key": "d2",
|
|
"description": "Second demo route for boolean and enum parameters",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"isActive": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "boolean",
|
|
"description": "Whether the user account is currently active and accessible"
|
|
},
|
|
"isAdmin": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "boolean",
|
|
"description": "Whether the user has administrative privileges"
|
|
},
|
|
"notifications": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "boolean",
|
|
"description": "Whether to enable email and push notifications"
|
|
},
|
|
"mode": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "string",
|
|
"enum": [
|
|
"read",
|
|
"write",
|
|
"execute"
|
|
],
|
|
"description": "The operation mode for the current session"
|
|
},
|
|
"verified": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "boolean",
|
|
"description": "Whether the user email has been verified"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Third demo route handling array and optional parameters
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.tags - {array} List of tags associated with the content, between 1 and 10 tags
|
|
* @param data.categories - {array} List of category names for filtering and classification
|
|
* @param data.ids - {array} Array of numeric identifiers for the resources
|
|
* @param data.priority - {number (min: 1, max: 5)} Priority level from 1 to 5, defaults to 3 if not specified
|
|
* @param data.keywords - {array} Keywords for search optimization, up to 20 keywords
|
|
*/
|
|
"d3": {
|
|
"path": "demo",
|
|
"key": "d3",
|
|
"description": "Third demo route handling array and optional parameters",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"tags": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"minItems": 1,
|
|
"maxItems": 10,
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"description": "List of tags associated with the content, between 1 and 10 tags"
|
|
},
|
|
"categories": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"description": "List of category names for filtering and classification"
|
|
},
|
|
"ids": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "array",
|
|
"items": {
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"description": "Array of numeric identifiers for the resources"
|
|
},
|
|
"priority": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"description": "Priority level from 1 to 5, defaults to 3 if not specified",
|
|
"type": "number",
|
|
"minimum": 1,
|
|
"maximum": 5,
|
|
"optional": true
|
|
},
|
|
"keywords": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"maxItems": 20,
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"description": "Keywords for search optimization, up to 20 keywords"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Fourth demo route with nested object parameters
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.user - {object} Complete user profile information
|
|
* @param data.settings - {object} User preference settings
|
|
* @param data.address - {object} Mailing address, optional field
|
|
*/
|
|
"d4": {
|
|
"path": "demo",
|
|
"key": "d4",
|
|
"description": "Fourth demo route with nested object parameters",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"user": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"id": {
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 9007199254740991,
|
|
"description": "Unique identifier for the user"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Full name of the user"
|
|
},
|
|
"contact": {
|
|
"type": "object",
|
|
"properties": {
|
|
"email": {
|
|
"type": "string",
|
|
"format": "email",
|
|
"pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$",
|
|
"description": "Primary email address"
|
|
},
|
|
"phone": {
|
|
"description": "Phone number with country code",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"email"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Contact information for the user"
|
|
}
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"contact"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Complete user profile information"
|
|
},
|
|
"settings": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"theme": {
|
|
"type": "string",
|
|
"enum": [
|
|
"light",
|
|
"dark",
|
|
"auto"
|
|
],
|
|
"description": "UI theme preference"
|
|
},
|
|
"language": {
|
|
"default": "en",
|
|
"description": "Preferred language code",
|
|
"type": "string"
|
|
},
|
|
"timezone": {
|
|
"type": "string",
|
|
"description": "Timezone identifier like America/New_York"
|
|
}
|
|
},
|
|
"required": [
|
|
"theme",
|
|
"language",
|
|
"timezone"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "User preference settings"
|
|
},
|
|
"address": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"description": "Mailing address, optional field",
|
|
"type": "object",
|
|
"properties": {
|
|
"street": {
|
|
"type": "string",
|
|
"description": "Street address line"
|
|
},
|
|
"city": {
|
|
"type": "string",
|
|
"description": "City name"
|
|
},
|
|
"country": {
|
|
"type": "string",
|
|
"description": "Country code or name"
|
|
}
|
|
},
|
|
"required": [
|
|
"street",
|
|
"city",
|
|
"country"
|
|
],
|
|
"additionalProperties": false,
|
|
"optional": true
|
|
}
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Fifth demo route with mixed complex parameters and validation
|
|
*
|
|
* @param data - Request parameters
|
|
* @param data.query - {string (minLength: 1)} Search query string, minimum 1 character required
|
|
* @param data.filters - {object} Advanced search filters configuration
|
|
* @param data.pagination - {object} Pagination settings for query results
|
|
* @param data.includeMetadata - {boolean} Whether to include metadata in response
|
|
* @param data.timeout - {number (min: 1000, max: 30000)} Request timeout in milliseconds, between 1s and 30s
|
|
* @param data.retry - {integer (min: 0, max: 5)} Number of retry attempts on failure
|
|
*/
|
|
"d5": {
|
|
"path": "demo",
|
|
"key": "d5",
|
|
"description": "Fifth demo route with mixed complex parameters and validation",
|
|
"middleware": [],
|
|
"metadata": {
|
|
"args": {
|
|
"query": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"description": "Search query string, minimum 1 character required"
|
|
},
|
|
"filters": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": [
|
|
"all",
|
|
"image",
|
|
"video",
|
|
"audio",
|
|
"document"
|
|
],
|
|
"description": "Content type filter"
|
|
},
|
|
"dateRange": {
|
|
"description": "Date range filter, optional",
|
|
"type": "object",
|
|
"properties": {
|
|
"start": {
|
|
"type": "string",
|
|
"format": "date-time",
|
|
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
|
"description": "Start date in ISO 8601 format"
|
|
},
|
|
"end": {
|
|
"type": "string",
|
|
"format": "date-time",
|
|
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
|
|
"description": "End date in ISO 8601 format"
|
|
}
|
|
},
|
|
"required": [
|
|
"start",
|
|
"end"
|
|
],
|
|
"additionalProperties": false
|
|
},
|
|
"size": {
|
|
"description": "Size filter for media content",
|
|
"type": "string",
|
|
"enum": [
|
|
"small",
|
|
"medium",
|
|
"large",
|
|
"extra-large"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"type"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Advanced search filters configuration"
|
|
},
|
|
"pagination": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"type": "object",
|
|
"properties": {
|
|
"page": {
|
|
"default": 1,
|
|
"description": "Page number starting from 1",
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 9007199254740991
|
|
},
|
|
"limit": {
|
|
"default": 20,
|
|
"description": "Number of items per page, max 100",
|
|
"type": "integer",
|
|
"exclusiveMinimum": 0,
|
|
"maximum": 100
|
|
},
|
|
"sort": {
|
|
"default": "desc",
|
|
"description": "Sort order for results",
|
|
"type": "string",
|
|
"enum": [
|
|
"asc",
|
|
"desc"
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"page",
|
|
"limit",
|
|
"sort"
|
|
],
|
|
"additionalProperties": false,
|
|
"description": "Pagination settings for query results"
|
|
},
|
|
"includeMetadata": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"default": false,
|
|
"description": "Whether to include metadata in response",
|
|
"type": "boolean",
|
|
"optional": true
|
|
},
|
|
"timeout": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"description": "Request timeout in milliseconds, between 1s and 30s",
|
|
"type": "number",
|
|
"minimum": 1000,
|
|
"maximum": 30000,
|
|
"optional": true
|
|
},
|
|
"retry": {
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"default": 3,
|
|
"description": "Number of retry attempts on failure",
|
|
"type": "integer",
|
|
"minimum": 0,
|
|
"maximum": 5,
|
|
"optional": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"router": {
|
|
/**
|
|
* 列出当前应用下的所有的路由信息
|
|
*/
|
|
"list": {
|
|
"path": "router",
|
|
"key": "list",
|
|
"description": "列出当前应用下的所有的路由信息",
|
|
"middleware": []
|
|
}
|
|
}
|
|
} as const;
|
|
const queryApi = createQueryApi({ api });
|
|
export { queryApi };
|