|
1 | 1 | import type {Token} from './string';
|
2 | 2 | import type {StringTemplate, Template, ObjectTemplate, ArrayTemplate, MapTemplate} from './structured/types';
|
| 3 | +import {TemplateJson} from './structured/TemplateJson'; |
3 | 4 |
|
4 | 5 | // ============================================================================
|
5 | 6 | // String Pattern Templates (from README examples)
|
@@ -1088,6 +1089,143 @@ export const allExamples: Template = [
|
1088 | 1089 | performanceTest,
|
1089 | 1090 | mixedTypes,
|
1090 | 1091 | loadTestUser,
|
1091 |
| - tree(), |
1092 |
| - comment(), |
| 1092 | + tree, |
| 1093 | + comment, |
1093 | 1094 | ];
|
| 1095 | + |
| 1096 | +// ============================================================================ |
| 1097 | +// Helper Methods for Easy Random JSON Generation |
| 1098 | +// ============================================================================ |
| 1099 | + |
| 1100 | +/** |
| 1101 | + * Generate a random user profile with comprehensive details. |
| 1102 | + * @returns Random user profile object |
| 1103 | + */ |
| 1104 | +export const genUser = () => TemplateJson.gen(userProfile); |
| 1105 | + |
| 1106 | +/** |
| 1107 | + * Generate a basic user object with essential information. |
| 1108 | + * @returns Random basic user object |
| 1109 | + */ |
| 1110 | +export const genUserBasic = () => TemplateJson.gen(userBasic); |
| 1111 | + |
| 1112 | +/** |
| 1113 | + * Generate a random address object with street, city, state, etc. |
| 1114 | + * @returns Random address object |
| 1115 | + */ |
| 1116 | +export const genAddress = () => TemplateJson.gen(address); |
| 1117 | + |
| 1118 | +/** |
| 1119 | + * Generate a random product with details like name, price, category. |
| 1120 | + * @returns Random product object |
| 1121 | + */ |
| 1122 | +export const genProduct = () => TemplateJson.gen(product); |
| 1123 | + |
| 1124 | +/** |
| 1125 | + * Generate a random order with items, customer info, and totals. |
| 1126 | + * @returns Random order object |
| 1127 | + */ |
| 1128 | +export const genOrder = () => TemplateJson.gen(order); |
| 1129 | + |
| 1130 | +/** |
| 1131 | + * Generate a random financial transaction. |
| 1132 | + * @returns Random transaction object |
| 1133 | + */ |
| 1134 | +export const genTransaction = () => TemplateJson.gen(transaction); |
| 1135 | + |
| 1136 | +/** |
| 1137 | + * Generate a random bank account information. |
| 1138 | + * @returns Random bank account object |
| 1139 | + */ |
| 1140 | +export const genBankAccount = () => TemplateJson.gen(bankAccount); |
| 1141 | + |
| 1142 | +/** |
| 1143 | + * Generate a random social media post. |
| 1144 | + * @returns Random social post object |
| 1145 | + */ |
| 1146 | +export const genSocialPost = () => TemplateJson.gen(socialPost); |
| 1147 | + |
| 1148 | +/** |
| 1149 | + * Generate a random social media profile. |
| 1150 | + * @returns Random social profile object |
| 1151 | + */ |
| 1152 | +export const genSocialProfile = () => TemplateJson.gen(socialProfile); |
| 1153 | + |
| 1154 | +/** |
| 1155 | + * Generate a random location with coordinates and details. |
| 1156 | + * @returns Random location object |
| 1157 | + */ |
| 1158 | +export const genLocation = () => TemplateJson.gen(location); |
| 1159 | + |
| 1160 | +/** |
| 1161 | + * Generate a random API response with data array. |
| 1162 | + * @returns Random API response object |
| 1163 | + */ |
| 1164 | +export const genApiResponse = () => TemplateJson.gen(apiResponse); |
| 1165 | + |
| 1166 | +/** |
| 1167 | + * Generate a detailed API response with comprehensive metadata. |
| 1168 | + * @returns Random detailed API response object |
| 1169 | + */ |
| 1170 | +export const genApiResponseDetailed = () => TemplateJson.gen(apiResponseDetailed); |
| 1171 | + |
| 1172 | +/** |
| 1173 | + * Generate a random service configuration. |
| 1174 | + * @returns Random service config object |
| 1175 | + */ |
| 1176 | +export const genServiceConfig = () => TemplateJson.gen(serviceConfig); |
| 1177 | + |
| 1178 | +/** |
| 1179 | + * Generate a random medical patient record. |
| 1180 | + * @returns Random patient object |
| 1181 | + */ |
| 1182 | +export const genPatient = () => TemplateJson.gen(patient); |
| 1183 | + |
| 1184 | +/** |
| 1185 | + * Generate a comprehensive medical record. |
| 1186 | + * @returns Random medical record object |
| 1187 | + */ |
| 1188 | +export const genMedicalRecord = () => TemplateJson.gen(medicalRecord); |
| 1189 | + |
| 1190 | +/** |
| 1191 | + * Generate a random student profile. |
| 1192 | + * @returns Random student object |
| 1193 | + */ |
| 1194 | +export const genStudent = () => TemplateJson.gen(student); |
| 1195 | + |
| 1196 | +/** |
| 1197 | + * Generate a random course information. |
| 1198 | + * @returns Random course object |
| 1199 | + */ |
| 1200 | +export const genCourse = () => TemplateJson.gen(course); |
| 1201 | + |
| 1202 | +/** |
| 1203 | + * Generate a random IoT sensor reading. |
| 1204 | + * @returns Random sensor reading object |
| 1205 | + */ |
| 1206 | +export const genSensorReading = () => TemplateJson.gen(sensorReading); |
| 1207 | + |
| 1208 | +/** |
| 1209 | + * Generate a random IoT device profile. |
| 1210 | + * @returns Random IoT device object |
| 1211 | + */ |
| 1212 | +export const genIotDevice = () => TemplateJson.gen(iotDevice); |
| 1213 | + |
| 1214 | +/** |
| 1215 | + * Generate a random log entry for monitoring. |
| 1216 | + * @returns Random log entry object |
| 1217 | + */ |
| 1218 | +export const genLogEntry = () => TemplateJson.gen(logEntry); |
| 1219 | + |
| 1220 | +/** |
| 1221 | + * Generate random metric data for monitoring. |
| 1222 | + * @returns Random metric data object |
| 1223 | + */ |
| 1224 | +export const genMetricData = () => TemplateJson.gen(metricData); |
| 1225 | + |
| 1226 | +/** |
| 1227 | + * Generate a random example from any of the available templates. |
| 1228 | + * Uses the 'or' pattern to randomly select from all templates. |
| 1229 | + * @returns Random example data from any template |
| 1230 | + */ |
| 1231 | +export const genRandomExample = () => TemplateJson.gen(allExamples); |
0 commit comments