@rljson/edge 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ /** The version of the `@rljson/edge` package. */
2
+ export declare const edgeVersion = "0.0.1";
package/dist/example.d.ts CHANGED
@@ -1 +1,7 @@
1
- export declare const example: () => void;
1
+ /**
2
+ * Runs the code examples of the README and prints what they produce.
3
+ *
4
+ * test/example.spec.ts runs it and compares the output with a golden file,
5
+ * so the README examples stay in sync with the code.
6
+ */
7
+ export declare const example: () => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1 +1,23 @@
1
- export { Edge } from './edge.ts';
1
+ export { Edge, mergeConfigs } from './edge.ts';
2
+ export type { EStats } from './edge.ts';
3
+ export { edgeDefaults, resolveEdgeConfig } from './config/config.ts';
4
+ export type { EBrandsConfig, ECadConfig, EConfig, ELayersConfig, EPartsConfig, EPricesConfig, EProgress, EResolvedConfig, EResolvedLayers, ERevisionsConfig, ESharing, EWorkshopsConfig, } from './config/config.ts';
5
+ export { edgePresetNames, edgePresets } from './config/presets.ts';
6
+ export type { EPresetName } from './config/presets.ts';
7
+ export { EMemorySink } from './core/sink.ts';
8
+ export type { ESink } from './core/sink.ts';
9
+ export type { EEstimate } from './core/estimate.ts';
10
+ export { carWorldTableKeys } from './car-world/car-world.ts';
11
+ export type { EAddress, EBrand, ECadMeta, ECarWorld, ECarWorldTableKey, EManufacturer, EPart, EPerson, EPrice, EWorkshop, } from './car-world/car-world.ts';
12
+ export { carWorldTableCfgs } from './car-world/table-cfgs.ts';
13
+ export { manufacturers } from './dictionaries/manufacturers.ts';
14
+ export type { EManufacturerEntry } from './dictionaries/manufacturers.ts';
15
+ export { modelsOf, vehicles } from './dictionaries/vehicles.ts';
16
+ export type { EBodyType, EFuel, EVehicleModel, } from './dictionaries/vehicles.ts';
17
+ export { assemblies, materialsOf, standardParts, } from './dictionaries/parts.ts';
18
+ export type { EAssembly, EStandardPart, ESubAssembly, } from './dictionaries/parts.ts';
19
+ export { cadDetails, cadMaterials, cadSystems } from './dictionaries/cad.ts';
20
+ export type { ECadSystem } from './dictionaries/cad.ts';
21
+ export { cities, citiesIn, cityNamed, streets } from './dictionaries/places.ts';
22
+ export type { ECity } from './dictionaries/places.ts';
23
+ export { firstNames, lastNames } from './dictionaries/people.ts';
@@ -6,22 +6,64 @@
6
6
 
7
7
  import { Edge } from './edge.ts';
8
8
 
9
+ // .............................................................................
10
+ /**
11
+ * Prints a line of an example's result.
12
+ * @param text - The line
13
+ */
14
+ const print = (text: string) => console.log(` ${text}`);
9
15
 
10
- export const example = () => {
11
- // Print methods
12
- const l = console.log;
13
- const h1 = (text: string) => l(`${text}`);
14
- const h2 = (text: string) => l(` ${text.split('\n')}`);
15
- const p = (text: string) => l(` ${text}`);
16
+ // .............................................................................
17
+ /** Generates the tiny preset in memory: the first README example */
18
+ const generateExample = async (): Promise<void> => {
19
+ console.log('Generate a world');
20
+ const { world, stats } = await Edge.preset('tiny').generate();
21
+ print(`${stats.cars} cars, ${stats.rowsTotal} rows`);
22
+ print(`${world.manufacturers._data[0].name}`);
23
+ };
24
+
25
+ // .............................................................................
26
+ /** Configures a world and estimates it first: the second README example */
27
+ const configureExample = async (): Promise<void> => {
28
+ console.log('Configure a world');
29
+ const edge = new Edge({
30
+ manufacturers: { count: 2, catalogsPerManufacturer: 2 },
31
+ catalogs: { carsPerCatalog: 20, revisions: { count: 1 } },
32
+ layers: {
33
+ prices: { currencies: ['EUR', 'CHF'], range: { min: 20000, max: 80000 } },
34
+ brands: { modelsPerManufacturer: 3, popularity: 'zipf' },
35
+ workshops: { perCatalog: 4 },
36
+ parts: { depth: 3, fanOut: 2 },
37
+ cad: { depth: 2, fanOut: 3 },
38
+ },
39
+ });
40
+ print(`estimated rows: ${edge.estimate().rowsTotal}`);
41
+ const { stats } = await edge.generate();
42
+ print(`generated rows: ${stats.rowsTotal}`);
43
+ };
16
44
 
17
- // Example
18
- h1('Edge.example');
19
- h2('Returns an instance of the Edge.');
20
- const example = Edge.example;
21
- p(JSON.stringify(example, null, 2));
45
+ // .............................................................................
46
+ /** Streams the rows through a callback: the third README example */
47
+ const streamExample = async (): Promise<void> => {
48
+ console.log('Stream the rows through a callback');
49
+ const rowsPerTable: Record<string, number> = {};
50
+ await Edge.preset('small').run({
51
+ onRow: (table) => {
52
+ rowsPerTable[table] = (rowsPerTable[table] ?? 0) + 1;
53
+ },
54
+ });
55
+ print(`prices: ${rowsPerTable.prices}, parts: ${rowsPerTable.parts}`);
22
56
  };
23
57
 
24
- /*
25
- // Run via "npx vite-node src/example.ts"
26
- example();
27
- */
58
+ // .............................................................................
59
+ /**
60
+ * Runs the code examples of the README and prints what they produce.
61
+ *
62
+ * test/example.spec.ts runs it and compares the output with a golden file,
63
+ * so the README examples stay in sync with the code.
64
+ */
65
+ export const example = async (): Promise<void> => {
66
+ await generateExample();
67
+ await configureExample();
68
+ await streamExample();
69
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/edge",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Example Data Generator",
5
5
  "homepage": "https://github.com/rljson/edge",
6
6
  "bugs": "https://github.com/rljson/edge/issues",
@@ -26,8 +26,8 @@
26
26
  "@rljson/dna-rljson": "^0.2.0",
27
27
  "@tssuite/helix-js": "^0.3.0",
28
28
  "@types/node": "^26.6.4",
29
- "@typescript-eslint/eslint-plugin": "^8.71.0",
30
- "@typescript-eslint/parser": "^8.71.0",
29
+ "@typescript-eslint/eslint-plugin": "^8.71.1",
30
+ "@typescript-eslint/parser": "^8.71.1",
31
31
  "@vitest/coverage-v8": "^5.0.3",
32
32
  "cross-env": "^10.1.0",
33
33
  "eslint": "^10.12.0",
@@ -37,7 +37,7 @@
37
37
  "jsdoc": "^4.0.5",
38
38
  "read-pkg": "^10.1.0",
39
39
  "typescript": "~6.0.3",
40
- "typescript-eslint": "^8.71.0",
40
+ "typescript-eslint": "^8.71.1",
41
41
  "vite": "^8.3.2",
42
42
  "vite-node": "^6.0.0",
43
43
  "vite-plugin-dts": "^5.1.2",