Highly ambitious ATProtocol AppView service and sdks
at main 61 lines 2.5 kB view raw
1/** 2 * Simple Docker-style name generator for slices 3 * Generates names in the format: adjective-noun 4 */ 5 6const adjectives = [ 7 "awesome", "blazing", "brilliant", "clever", "cool", 8 "dazzling", "dynamic", "elegant", "epic", "fast", 9 "fearless", "friendly", "gentle", "happy", "jolly", 10 "kind", "lively", "mighty", "nimble", "peaceful", 11 "quick", "radiant", "serene", "sharp", "smooth", 12 "stellar", "swift", "tender", "vibrant", "wise", 13 "zen", "cosmic", "digital", "quantum", "cyber", 14 "neon", "pixel", "sonic", "turbo", "ultra" 15]; 16 17const nouns = [ 18 "slice", "wave", "spark", "pulse", "stream", 19 "beacon", "bridge", "cloud", "comet", "crystal", 20 "delta", "echo", "flame", "galaxy", "harbor", 21 "horizon", "iris", "jet", "lens", "meteor", 22 "nexus", "orbit", "phoenix", "prism", "quasar", 23 "ray", "sphere", "star", "storm", "tide", 24 "vertex", "vortex", "zen", "zone", "arc", 25 "beam", "core", "drift", "edge", "flux" 26]; 27 28/** 29 * Generates a random slice name in the format: adjective-noun-xxxx 30 * @param separator The separator to use between words (default: "-") 31 * @returns A randomly generated name with 4-digit suffix 32 */ 33export function generateSliceName(separator: string = "-"): string { 34 const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]; 35 const noun = nouns[Math.floor(Math.random() * nouns.length)]; 36 const randomSuffix = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); 37 return `${adjective}${separator}${noun}${separator}${randomSuffix}`; 38} 39 40/** 41 * Generates a unique slice name with a random number suffix 42 * @param separator The separator to use between words (default: "-") 43 * @returns A randomly generated name with number suffix 44 */ 45export function generateUniqueSliceName(separator: string = "-"): string { 46 const baseName = generateSliceName(separator); 47 const randomNum = Math.floor(Math.random() * 9999); 48 return `${baseName}${separator}${randomNum}`; 49} 50 51/** 52 * Generates a unique random domain name 53 * @returns A unique domain in the format: network.slices.adjective-noun-xxxx 54 */ 55export function generateDomain(): string { 56 // Generate a completely random domain, independent of slice name 57 const adjective = adjectives[Math.floor(Math.random() * adjectives.length)]; 58 const noun = nouns[Math.floor(Math.random() * nouns.length)]; 59 const randomSuffix = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); 60 return `network.slices.${adjective}-${noun}-${randomSuffix}`; 61}