@rljson/edge 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.de.md +181 -0
- package/README.md +174 -2
- package/dist/README.de.md +181 -0
- package/dist/README.md +175 -0
- package/dist/car-world/bom-builder.d.ts +57 -0
- package/dist/car-world/brands.d.ts +17 -0
- package/dist/car-world/car-world.d.ts +135 -0
- package/dist/car-world/catalog-generator.d.ts +99 -0
- package/dist/car-world/generate-car-world.d.ts +16 -0
- package/dist/car-world/plan.d.ts +130 -0
- package/dist/car-world/prices.d.ts +32 -0
- package/dist/car-world/scene-builder.d.ts +40 -0
- package/dist/car-world/table-cfgs.d.ts +22 -0
- package/dist/car-world/workshops.d.ts +39 -0
- package/dist/config/config.d.ts +177 -0
- package/dist/config/presets.d.ts +13 -0
- package/dist/core/emitter.d.ts +71 -0
- package/dist/core/estimate.d.ts +33 -0
- package/dist/core/pick.d.ts +69 -0
- package/dist/core/sink.d.ts +49 -0
- package/dist/dictionaries/cad.d.ts +13 -0
- package/dist/dictionaries/manufacturers.d.ts +21 -0
- package/dist/dictionaries/parts.d.ts +29 -0
- package/dist/dictionaries/people.d.ts +4 -0
- package/dist/dictionaries/places.d.ts +27 -0
- package/dist/dictionaries/vehicles.d.ts +22 -0
- package/dist/edge.d.ts +62 -0
- package/dist/edge.js +11334 -0
- package/dist/edge.js.map +1 -0
- package/dist/edge_version.d.ts +2 -0
- package/dist/example.d.ts +7 -0
- package/dist/index.d.ts +23 -0
- package/dist/src/example.ts +69 -0
- package/package.json +57 -3
|
@@ -0,0 +1,7 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// @license
|
|
2
|
+
// Copyright (c) 2025 Rljson
|
|
3
|
+
//
|
|
4
|
+
// Use of this source code is governed by terms that can be
|
|
5
|
+
// found in the LICENSE file in the root of this package.
|
|
6
|
+
|
|
7
|
+
import { Edge } from './edge.ts';
|
|
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}`);
|
|
15
|
+
|
|
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
|
+
};
|
|
44
|
+
|
|
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}`);
|
|
56
|
+
};
|
|
57
|
+
|
|
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,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/edge",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Example Data Generator",
|
|
5
|
+
"homepage": "https://github.com/rljson/edge",
|
|
6
|
+
"bugs": "https://github.com/rljson/edge/issues",
|
|
7
|
+
"private": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.14.0"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/rljson/edge.git"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/edge.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@rljson/dna-rljson": "^0.2.0",
|
|
27
|
+
"@tssuite/helix-js": "^0.3.0",
|
|
28
|
+
"@types/node": "^26.6.4",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^8.71.1",
|
|
30
|
+
"@typescript-eslint/parser": "^8.71.1",
|
|
31
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
32
|
+
"cross-env": "^10.1.0",
|
|
33
|
+
"eslint": "^10.12.0",
|
|
34
|
+
"eslint-plugin-jsdoc": "^65.1.0",
|
|
35
|
+
"eslint-plugin-tsdoc": "^0.5.4",
|
|
36
|
+
"globals": "^17.13.0",
|
|
37
|
+
"jsdoc": "^4.0.5",
|
|
38
|
+
"read-pkg": "^10.1.0",
|
|
39
|
+
"typescript": "~6.0.3",
|
|
40
|
+
"typescript-eslint": "^8.71.1",
|
|
41
|
+
"vite": "^8.3.2",
|
|
42
|
+
"vite-node": "^6.0.0",
|
|
43
|
+
"vite-plugin-dts": "^5.1.2",
|
|
44
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
45
|
+
"vitest": "^5.0.3",
|
|
46
|
+
"vitest-dom": "^0.1.1"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@rljson/hash": "^0.0.19",
|
|
50
|
+
"@rljson/json": "^0.0.23",
|
|
51
|
+
"@rljson/rljson": "^0.0.84"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "pnpm test && pnpm vite build && tsc && node scripts/copy-readme-to-dist.js",
|
|
55
|
+
"test": "pnpm vitest run --coverage && pnpm run lint",
|
|
56
|
+
"prebuild": "pnpm test",
|
|
57
|
+
"lint": "pnpm eslint",
|
|
58
|
+
"updateGoldens": "cross-env UPDATE_GOLDENS=true pnpm test"
|
|
59
|
+
}
|
|
6
60
|
}
|