-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
123 lines (104 loc) · 4.52 KB
/
data.js
File metadata and controls
123 lines (104 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { ID } from 'node-appwrite';
const CATEGORIES = ['electronics', 'clothing', 'books', 'food', 'toys', 'home', 'sports', 'beauty'];
const BRANDS = [
'Nimbus', 'Vector', 'Harbor', 'Tessera', 'Monolith', 'Kaleido', 'Drift', 'Forge',
'Lumen', 'Orbit', 'Parallax', 'Quanta', 'Rift', 'Solace', 'Tundra', 'Vantage'
];
const ADJECTIVES = [
'Premium', 'Compact', 'Wireless', 'Rugged', 'Ultra-light', 'Handcrafted',
'Organic', 'Heavy-duty', 'Smart', 'Eco-friendly', 'Vintage', 'Ergonomic',
'Portable', 'Professional', 'Classic', 'Modern', 'Travel', 'Performance'
];
const NOUNS = {
electronics: ['Headphones', 'Keyboard', 'Monitor', 'Router', 'Webcam', 'Speaker', 'Drone', 'Charger'],
clothing: ['Jacket', 'Jeans', 'Sneakers', 'T-Shirt', 'Hoodie', 'Cap', 'Scarf', 'Socks'],
books: ['Novel', 'Cookbook', 'Biography', 'Atlas', 'Anthology', 'Memoir', 'Journal', 'Guide'],
food: ['Coffee Beans', 'Olive Oil', 'Hot Sauce', 'Granola', 'Tea Sampler', 'Chocolate Bar', 'Pasta', 'Honey'],
toys: ['Puzzle', 'Building Set', 'Action Figure', 'Board Game', 'Plush Toy', 'RC Car', 'Kite', 'Yo-Yo'],
home: ['Lamp', 'Blender', 'Cutting Board', 'Throw Pillow', 'Rug', 'Vase', 'Shelf', 'Kettle'],
sports: ['Yoga Mat', 'Dumbbell', 'Tennis Racket', 'Water Bottle', 'Cycling Helmet', 'Running Shoes', 'Resistance Band', 'Backpack'],
beauty: ['Moisturizer', 'Lipstick', 'Serum', 'Shampoo', 'Facial Mask', 'Perfume', 'Hair Brush', 'Sunscreen']
};
const DESCRIPTORS = [
'engineered for daily use with a minimalist finish',
'built from recycled materials without compromising durability',
'tested across extreme conditions by an independent lab',
'balanced for comfort over long sessions',
'limited run with hand-numbered packaging',
'ships carbon-neutral from a family-owned workshop',
'designed alongside professional athletes',
'refined over three prototype generations before release',
'compatible with the latest industry standards',
'covered by a ten year manufacturer warranty',
'sourced from certified sustainable suppliers',
'developed with input from a community of early backers'
];
const TLDS = ['com', 'io', 'co', 'shop', 'store', 'net'];
function pick(arr, rng) {
return arr[Math.floor(rng() * arr.length)];
}
function makeRng(seed) {
let s = seed >>> 0;
return () => {
s = (s * 1664525 + 1013904223) >>> 0;
return s / 0x100000000;
};
}
function pad(n, width) {
return String(n).padStart(width, '0');
}
function generateRow(index) {
const rng = makeRng(index + 1);
const category = pick(CATEGORIES, rng);
const noun = pick(NOUNS[category], rng);
const adjective = pick(ADJECTIVES, rng);
const brand = pick(BRANDS, rng);
const descriptor = pick(DESCRIPTORS, rng);
const name = `${brand} ${adjective} ${noun}`;
const sku = `${category.slice(0, 3).toUpperCase()}-${brand.slice(0, 3).toUpperCase()}-${pad(index, 6)}`;
const price = Math.round((5 + rng() * 495) * 100) / 100;
const stock = Math.floor(rng() * 500);
const inStock = stock > 0;
const rating = Math.round((2 + rng() * 3) * 10) / 10;
const reviewCount = Math.floor(rng() * 8000);
const brandSlug = brand.toLowerCase();
const tld = pick(TLDS, rng);
const manufacturerEmail = `support+${sku.toLowerCase()}@${brandSlug}.${tld}`;
const manufacturerUrl = `https://${brandSlug}.${tld}/products/${sku.toLowerCase()}`;
const daysAgo = Math.floor(rng() * 1460);
const releasedAt = new Date(Date.now() - daysAgo * 86_400_000).toISOString();
const ipA = 10 + Math.floor(rng() * 240);
const ipB = Math.floor(rng() * 256);
const ipC = Math.floor(rng() * 256);
const ipD = 1 + Math.floor(rng() * 254);
const warehouseIp = `${ipA}.${ipB}.${ipC}.${ipD}`;
const description = `${name} is ${descriptor}. Each unit in the ${category} line is inspected before dispatch.`;
const tagPool = [adjective.toLowerCase(), brandSlug, category, noun.toLowerCase().replace(/\s+/g, '-')];
const tags = Array.from(new Set(tagPool)).slice(0, 4);
return {
$id: ID.unique(),
name,
description,
sku,
category,
brand,
price,
stock,
inStock,
rating,
reviewCount,
manufacturerEmail,
manufacturerUrl,
releasedAt,
warehouseIp,
tags
};
}
export function generateRows(total) {
const rows = new Array(total);
for (let i = 0; i < total; i++) {
rows[i] = generateRow(i);
}
return rows;
}
export { CATEGORIES };