realitydb 2.0.0 → 2.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 +80 -21
- package/dist/index.js +338 -58
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Mpingo Systems Ltd (Eddy Mkwambe)
|
|
6
|
+
Licensed Work: RealityDB Sandbox
|
|
7
|
+
The Licensed Work is (c) 2026 Mpingo Systems Ltd
|
|
8
|
+
Additional Use Grant: You may make use of the Licensed Work, provided that
|
|
9
|
+
you do not use the Licensed Work for a Synthetic Data
|
|
10
|
+
Service, SQL Learning Service, or Database Simulation
|
|
11
|
+
Service.
|
|
12
|
+
|
|
13
|
+
A "Synthetic Data Service" is a commercial offering
|
|
14
|
+
that allows third parties to access the functionality
|
|
15
|
+
of the Licensed Work by generating synthetic database
|
|
16
|
+
records, test data, or simulation environments.
|
|
17
|
+
|
|
18
|
+
A "SQL Learning Service" is a commercial offering that
|
|
19
|
+
allows third parties to practice SQL queries against
|
|
20
|
+
auto-graded challenges using functionality substantially
|
|
21
|
+
derived from the Licensed Work.
|
|
22
|
+
|
|
23
|
+
A "Database Simulation Service" is a commercial offering
|
|
24
|
+
that allows third parties to create or access simulated
|
|
25
|
+
database environments with lifecycle-coherent data using
|
|
26
|
+
functionality substantially derived from the Licensed Work.
|
|
27
|
+
|
|
28
|
+
You may use the Licensed Work for internal testing,
|
|
29
|
+
development, education, research, and any non-competing
|
|
30
|
+
commercial purpose without restriction.
|
|
31
|
+
|
|
32
|
+
Change Date: March 31, 2030
|
|
33
|
+
Change License: Apache License, Version 2.0
|
|
34
|
+
|
|
35
|
+
For information about alternative licensing arrangements for the Licensed Work,
|
|
36
|
+
please contact: licensing@realitydb.dev
|
|
37
|
+
|
|
38
|
+
Notice
|
|
39
|
+
|
|
40
|
+
Business Source License 1.1 (the "License")
|
|
41
|
+
|
|
42
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
43
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
44
|
+
Licensor may make an Additional Use Grant, above, permitting limited production
|
|
45
|
+
use.
|
|
46
|
+
|
|
47
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
48
|
+
available distribution of a specific version of the Licensed Work under this
|
|
49
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
50
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
51
|
+
above terminate.
|
|
52
|
+
|
|
53
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
54
|
+
currently in effect as described in this License, you must purchase a
|
|
55
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
56
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
57
|
+
|
|
58
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
59
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
60
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
61
|
+
for each version of the Licensed Work released by Licensor.
|
|
62
|
+
|
|
63
|
+
You must conspicuously display this License on each original or modified copy
|
|
64
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
65
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
66
|
+
License apply to your use of that work.
|
|
67
|
+
|
|
68
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
69
|
+
terminate your rights under this License for the current and all other
|
|
70
|
+
versions of the Licensed Work.
|
|
71
|
+
|
|
72
|
+
This License does not grant you any right in any trademark or logo of
|
|
73
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
74
|
+
Licensor as expressly required by this License).
|
|
75
|
+
|
|
76
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
77
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
78
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
79
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
80
|
+
TITLE.
|
package/dist/index.js
CHANGED
|
@@ -23297,23 +23297,42 @@ function escapeCsvField(value) {
|
|
|
23297
23297
|
// ../../packages/generators/dist/exporters/sql.js
|
|
23298
23298
|
var import_promises3 = require("fs/promises");
|
|
23299
23299
|
var import_node_path3 = require("path");
|
|
23300
|
-
async function exportToSql(dataset, outputDir, tableOrder) {
|
|
23300
|
+
async function exportToSql(dataset, outputDir, tableOrder, options) {
|
|
23301
23301
|
await (0, import_promises3.mkdir)(outputDir, { recursive: true });
|
|
23302
|
+
const batchSize = options?.batchSize ?? 50;
|
|
23302
23303
|
const lines = [];
|
|
23303
|
-
lines.push("--
|
|
23304
|
+
lines.push("-- =================================================================");
|
|
23305
|
+
lines.push("-- Generated by RealityDB");
|
|
23306
|
+
if (options?.templateName) {
|
|
23307
|
+
lines.push(`-- Template: ${options.templateName}`);
|
|
23308
|
+
}
|
|
23304
23309
|
lines.push(`-- Seed: ${dataset.seed}`);
|
|
23305
23310
|
lines.push(`-- Generated at: ${dataset.generatedAt}`);
|
|
23311
|
+
lines.push("-- =================================================================");
|
|
23312
|
+
lines.push("");
|
|
23313
|
+
if (options?.ddl) {
|
|
23314
|
+
lines.push("-- --- SCHEMA ---------------------------------------------------------");
|
|
23315
|
+
lines.push("");
|
|
23316
|
+
lines.push(options.ddl);
|
|
23317
|
+
lines.push("");
|
|
23318
|
+
}
|
|
23319
|
+
lines.push("-- --- DATA -----------------------------------------------------------");
|
|
23306
23320
|
lines.push("");
|
|
23307
23321
|
for (const tableName of tableOrder) {
|
|
23308
23322
|
const table = dataset.tables.get(tableName);
|
|
23309
23323
|
if (!table || table.rows.length === 0)
|
|
23310
23324
|
continue;
|
|
23311
23325
|
const quotedColumns = table.columns.map((c) => `"${c}"`).join(", ");
|
|
23312
|
-
for (
|
|
23313
|
-
const
|
|
23314
|
-
|
|
23326
|
+
for (let i = 0; i < table.rows.length; i += batchSize) {
|
|
23327
|
+
const batch = table.rows.slice(i, i + batchSize);
|
|
23328
|
+
const valueRows = batch.map((row) => {
|
|
23329
|
+
const values = table.columns.map((col) => escapeSqlValue(row[col])).join(", ");
|
|
23330
|
+
return ` (${values})`;
|
|
23331
|
+
});
|
|
23332
|
+
lines.push(`INSERT INTO "${tableName}" (${quotedColumns}) VALUES`);
|
|
23333
|
+
lines.push(valueRows.join(",\n") + ";");
|
|
23334
|
+
lines.push("");
|
|
23315
23335
|
}
|
|
23316
|
-
lines.push("");
|
|
23317
23336
|
}
|
|
23318
23337
|
const filePath = (0, import_node_path3.join)(outputDir, "seed.sql");
|
|
23319
23338
|
await (0, import_promises3.writeFile)(filePath, lines.join("\n"), "utf-8");
|
|
@@ -24692,10 +24711,10 @@ function exportRealityPack(dataset, plan, schema, options) {
|
|
|
24692
24711
|
}))
|
|
24693
24712
|
};
|
|
24694
24713
|
const packDataset = { tables: {} };
|
|
24695
|
-
for (const [tableName, table] of dataset.tables) {
|
|
24714
|
+
for (const [tableName, table] of Array.from(dataset.tables.entries())) {
|
|
24696
24715
|
packDataset.tables[tableName] = {
|
|
24697
|
-
columns: table.columns,
|
|
24698
|
-
rows: table.rows,
|
|
24716
|
+
columns: [...table.columns],
|
|
24717
|
+
rows: table.rows.map((row) => ({ ...row })),
|
|
24699
24718
|
rowCount: table.rowCount
|
|
24700
24719
|
};
|
|
24701
24720
|
}
|
|
@@ -27940,8 +27959,8 @@ function getSimulationProfile(name) {
|
|
|
27940
27959
|
var saasTemplate = {
|
|
27941
27960
|
name: "saas",
|
|
27942
27961
|
version: "2.0",
|
|
27943
|
-
description: "SaaS
|
|
27944
|
-
targetTables: ["organizations", "users", "plans", "subscriptions", "invoices", "payments"],
|
|
27962
|
+
description: "SaaS platform with 10 tables: organizations, users, plans, features, plan_features, subscriptions, invoices, payments, sessions, events",
|
|
27963
|
+
targetTables: ["organizations", "users", "plans", "features", "plan_features", "subscriptions", "invoices", "payments", "sessions", "events"],
|
|
27945
27964
|
tableConfigs: /* @__PURE__ */ new Map([
|
|
27946
27965
|
["organizations", {
|
|
27947
27966
|
tableName: "organizations",
|
|
@@ -28098,7 +28117,7 @@ var saasTemplate = {
|
|
|
28098
28117
|
{
|
|
28099
28118
|
columnName: "trial_ends_at",
|
|
28100
28119
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28101
|
-
description: "Nullable \
|
|
28120
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for non-trial subscriptions"
|
|
28102
28121
|
},
|
|
28103
28122
|
{
|
|
28104
28123
|
columnName: "current_period_start",
|
|
@@ -28116,7 +28135,7 @@ var saasTemplate = {
|
|
|
28116
28135
|
{
|
|
28117
28136
|
columnName: "canceled_at",
|
|
28118
28137
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28119
|
-
description: "Nullable \
|
|
28138
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D should be null for active/trialing subscriptions"
|
|
28120
28139
|
}
|
|
28121
28140
|
]
|
|
28122
28141
|
}],
|
|
@@ -28157,7 +28176,7 @@ var saasTemplate = {
|
|
|
28157
28176
|
{
|
|
28158
28177
|
columnName: "paid_at",
|
|
28159
28178
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28160
|
-
description: "Nullable \
|
|
28179
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for unpaid invoices"
|
|
28161
28180
|
},
|
|
28162
28181
|
{
|
|
28163
28182
|
columnName: "created_at",
|
|
@@ -28214,7 +28233,7 @@ var saasTemplate = {
|
|
|
28214
28233
|
weights: [0.35, 0.3, 0.2, 0.15]
|
|
28215
28234
|
}
|
|
28216
28235
|
},
|
|
28217
|
-
description: "Nullable \
|
|
28236
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for successful payments"
|
|
28218
28237
|
},
|
|
28219
28238
|
{
|
|
28220
28239
|
columnName: "paid_at",
|
|
@@ -28222,6 +28241,50 @@ var saasTemplate = {
|
|
|
28222
28241
|
strategy: { kind: "timestamp", options: { mode: "past" } }
|
|
28223
28242
|
}
|
|
28224
28243
|
]
|
|
28244
|
+
}],
|
|
28245
|
+
["features", {
|
|
28246
|
+
tableName: "features",
|
|
28247
|
+
matchPattern: ["features", "*feature*"],
|
|
28248
|
+
rowCountMultiplier: 0.02,
|
|
28249
|
+
columnOverrides: [
|
|
28250
|
+
{ columnName: "name", strategy: { kind: "text", options: { mode: "short" } } },
|
|
28251
|
+
{ columnName: "category", strategy: { kind: "enum", options: { values: ["core", "analytics", "security", "integration"], weights: [0.35, 0.25, 0.2, 0.2] } } },
|
|
28252
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28253
|
+
]
|
|
28254
|
+
}],
|
|
28255
|
+
["plan_features", {
|
|
28256
|
+
tableName: "plan_features",
|
|
28257
|
+
matchPattern: ["plan_features", "*plan_feature*"],
|
|
28258
|
+
rowCountMultiplier: 0.06,
|
|
28259
|
+
columnOverrides: [
|
|
28260
|
+
{ columnName: "enabled", strategy: { kind: "boolean" } },
|
|
28261
|
+
{ columnName: "limit_value", strategy: { kind: "integer", options: { min: 0, max: 1e4 } } },
|
|
28262
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28263
|
+
]
|
|
28264
|
+
}],
|
|
28265
|
+
["sessions", {
|
|
28266
|
+
tableName: "sessions",
|
|
28267
|
+
matchPattern: ["sessions", "*session*"],
|
|
28268
|
+
rowCountMultiplier: 8,
|
|
28269
|
+
columnOverrides: [
|
|
28270
|
+
{ columnName: "started_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
28271
|
+
{ columnName: "ended_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
28272
|
+
{ columnName: "duration_seconds", strategy: { kind: "integer", options: { min: 10, max: 14400 } } },
|
|
28273
|
+
{ columnName: "ip_address", strategy: { kind: "text", options: { mode: "short" } } },
|
|
28274
|
+
{ columnName: "user_agent", strategy: { kind: "text" } },
|
|
28275
|
+
{ columnName: "country", strategy: { kind: "enum", options: { values: ["US", "UK", "CA", "DE", "FR", "AU", "IN", "BR"], weights: [0.5, 0.1, 0.08, 0.06, 0.05, 0.04, 0.04, 0.03] } } },
|
|
28276
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28277
|
+
]
|
|
28278
|
+
}],
|
|
28279
|
+
["events", {
|
|
28280
|
+
tableName: "events",
|
|
28281
|
+
matchPattern: ["events", "*event*"],
|
|
28282
|
+
rowCountMultiplier: 10,
|
|
28283
|
+
columnOverrides: [
|
|
28284
|
+
{ columnName: "event_type", strategy: { kind: "enum", options: { values: ["page_view", "button_click", "api_call", "feature_use", "error", "search"], weights: [0.4, 0.2, 0.15, 0.12, 0.05, 0.08] } } },
|
|
28285
|
+
{ columnName: "event_name", strategy: { kind: "text", options: { mode: "short" } } },
|
|
28286
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "recent" } } }
|
|
28287
|
+
]
|
|
28225
28288
|
}]
|
|
28226
28289
|
])
|
|
28227
28290
|
};
|
|
@@ -28230,8 +28293,8 @@ var saasTemplate = {
|
|
|
28230
28293
|
var ecommerceTemplate = {
|
|
28231
28294
|
name: "ecommerce",
|
|
28232
28295
|
version: "2.0",
|
|
28233
|
-
description: "E-commerce
|
|
28234
|
-
targetTables: ["customers", "categories", "products", "orders", "order_items", "reviews"],
|
|
28296
|
+
description: "E-commerce platform with 12 tables: customers, categories, products, orders, order_items, reviews, sessions, cart_items, payments, refunds, shipments, disputes",
|
|
28297
|
+
targetTables: ["customers", "categories", "products", "orders", "order_items", "reviews", "sessions", "cart_items", "payments", "refunds", "shipments", "disputes"],
|
|
28235
28298
|
tableConfigs: /* @__PURE__ */ new Map([
|
|
28236
28299
|
["customers", {
|
|
28237
28300
|
tableName: "customers",
|
|
@@ -28340,7 +28403,7 @@ var ecommerceTemplate = {
|
|
|
28340
28403
|
{
|
|
28341
28404
|
columnName: "compare_at_price_cents",
|
|
28342
28405
|
strategy: { kind: "money", options: { min: 0, max: 2e5 } },
|
|
28343
|
-
description: "Nullable \
|
|
28406
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D original price before discount"
|
|
28344
28407
|
},
|
|
28345
28408
|
{
|
|
28346
28409
|
columnName: "brand",
|
|
@@ -28426,13 +28489,13 @@ var ecommerceTemplate = {
|
|
|
28426
28489
|
columnName: "shipped_at",
|
|
28427
28490
|
matchPattern: ["shipped_at", "ship_date"],
|
|
28428
28491
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28429
|
-
description: "Nullable \
|
|
28492
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for pending/processing orders"
|
|
28430
28493
|
},
|
|
28431
28494
|
{
|
|
28432
28495
|
columnName: "delivered_at",
|
|
28433
28496
|
matchPattern: ["delivered_at", "delivery_date"],
|
|
28434
28497
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28435
|
-
description: "Nullable \
|
|
28498
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for non-delivered orders"
|
|
28436
28499
|
}
|
|
28437
28500
|
]
|
|
28438
28501
|
}],
|
|
@@ -28484,6 +28547,76 @@ var ecommerceTemplate = {
|
|
|
28484
28547
|
strategy: { kind: "timestamp", options: { mode: "past" } }
|
|
28485
28548
|
}
|
|
28486
28549
|
]
|
|
28550
|
+
}],
|
|
28551
|
+
["sessions", {
|
|
28552
|
+
tableName: "sessions",
|
|
28553
|
+
matchPattern: ["sessions", "*session*"],
|
|
28554
|
+
rowCountMultiplier: 8,
|
|
28555
|
+
columnOverrides: [
|
|
28556
|
+
{ columnName: "started_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
28557
|
+
{ columnName: "ended_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
28558
|
+
{ columnName: "page_count", strategy: { kind: "integer", options: { min: 1, max: 50 } } },
|
|
28559
|
+
{ columnName: "device_type", strategy: { kind: "enum", options: { values: ["desktop", "mobile", "tablet"], weights: [0.45, 0.4, 0.15] } } },
|
|
28560
|
+
{ columnName: "utm_source", strategy: { kind: "enum", options: { values: ["direct", "google", "email", "facebook", "organic"], weights: [0.35, 0.25, 0.15, 0.1, 0.15] } } },
|
|
28561
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28562
|
+
]
|
|
28563
|
+
}],
|
|
28564
|
+
["cart_items", {
|
|
28565
|
+
tableName: "cart_items",
|
|
28566
|
+
matchPattern: ["cart_items", "*cart*"],
|
|
28567
|
+
rowCountMultiplier: 8,
|
|
28568
|
+
columnOverrides: [
|
|
28569
|
+
{ columnName: "quantity", strategy: { kind: "integer", options: { min: 1, max: 5 } } },
|
|
28570
|
+
{ columnName: "price_cents", strategy: { kind: "integer", options: { min: 499, max: 99999 } } },
|
|
28571
|
+
{ columnName: "added_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
28572
|
+
{ columnName: "converted", strategy: { kind: "boolean" } },
|
|
28573
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28574
|
+
]
|
|
28575
|
+
}],
|
|
28576
|
+
["payments", {
|
|
28577
|
+
tableName: "payments",
|
|
28578
|
+
matchPattern: ["payments", "*payment*"],
|
|
28579
|
+
rowCountMultiplier: 3,
|
|
28580
|
+
columnOverrides: [
|
|
28581
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 499, max: 2e5 } } },
|
|
28582
|
+
{ columnName: "method", strategy: { kind: "enum", options: { values: ["credit_card", "debit_card", "paypal", "apple_pay", "klarna"], weights: [0.55, 0.15, 0.15, 0.1, 0.05] } } },
|
|
28583
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["succeeded", "failed", "pending", "refunded"], weights: [0.8, 0.12, 0.03, 0.05] } } },
|
|
28584
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28585
|
+
]
|
|
28586
|
+
}],
|
|
28587
|
+
["refunds", {
|
|
28588
|
+
tableName: "refunds",
|
|
28589
|
+
matchPattern: ["refunds", "*refund*"],
|
|
28590
|
+
rowCountMultiplier: 0.4,
|
|
28591
|
+
columnOverrides: [
|
|
28592
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 499, max: 1e5 } } },
|
|
28593
|
+
{ columnName: "reason", strategy: { kind: "enum", options: { values: ["defective", "wrong_item", "changed_mind", "late_delivery", "duplicate"], weights: [0.25, 0.2, 0.3, 0.15, 0.1] } } },
|
|
28594
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["processed", "pending", "denied"], weights: [0.7, 0.2, 0.1] } } },
|
|
28595
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28596
|
+
]
|
|
28597
|
+
}],
|
|
28598
|
+
["shipments", {
|
|
28599
|
+
tableName: "shipments",
|
|
28600
|
+
matchPattern: ["shipments", "*shipment*"],
|
|
28601
|
+
rowCountMultiplier: 3,
|
|
28602
|
+
columnOverrides: [
|
|
28603
|
+
{ columnName: "carrier", strategy: { kind: "enum", options: { values: ["fedex", "ups", "usps", "dhl"], weights: [0.3, 0.3, 0.25, 0.15] } } },
|
|
28604
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["delivered", "in_transit", "out_for_delivery", "exception", "label_created"], weights: [0.5, 0.25, 0.1, 0.1, 0.05] } } },
|
|
28605
|
+
{ columnName: "shipped_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
28606
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28607
|
+
]
|
|
28608
|
+
}],
|
|
28609
|
+
["disputes", {
|
|
28610
|
+
tableName: "disputes",
|
|
28611
|
+
matchPattern: ["disputes", "*dispute*"],
|
|
28612
|
+
rowCountMultiplier: 0.05,
|
|
28613
|
+
columnOverrides: [
|
|
28614
|
+
{ columnName: "reason", strategy: { kind: "enum", options: { values: ["fraud", "not_received", "not_as_described", "duplicate", "other"], weights: [0.2, 0.3, 0.25, 0.1, 0.15] } } },
|
|
28615
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["open", "under_review", "won", "lost"], weights: [0.15, 0.25, 0.35, 0.25] } } },
|
|
28616
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 499, max: 5e4 } } },
|
|
28617
|
+
{ columnName: "evidence_submitted", strategy: { kind: "boolean" } },
|
|
28618
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
28619
|
+
]
|
|
28487
28620
|
}]
|
|
28488
28621
|
])
|
|
28489
28622
|
};
|
|
@@ -28492,7 +28625,7 @@ var ecommerceTemplate = {
|
|
|
28492
28625
|
var educationTemplate = {
|
|
28493
28626
|
name: "education",
|
|
28494
28627
|
version: "2.0",
|
|
28495
|
-
description: "K-12 school system with teachers, classes, students, grades,
|
|
28628
|
+
description: "K-12 school system with 6 tables: teachers, classes, students, enrollments, grades, attendance",
|
|
28496
28629
|
targetTables: ["teachers", "classes", "students", "enrollments", "grades", "attendance"],
|
|
28497
28630
|
tableConfigs: /* @__PURE__ */ new Map([
|
|
28498
28631
|
["teachers", {
|
|
@@ -28762,8 +28895,8 @@ var educationTemplate = {
|
|
|
28762
28895
|
var fintechTemplate = {
|
|
28763
28896
|
name: "fintech",
|
|
28764
28897
|
version: "2.0",
|
|
28765
|
-
description: "Financial
|
|
28766
|
-
targetTables: ["accounts", "transactions", "fraud_alerts", "settlements", "chargebacks"],
|
|
28898
|
+
description: "Financial platform with 10 tables: accounts, transactions, transfers, cards, authorizations, settlements, fraud_alerts, fraud_investigations, chargebacks, compliance_checks",
|
|
28899
|
+
targetTables: ["accounts", "transactions", "fraud_alerts", "settlements", "chargebacks", "transfers", "cards", "authorizations", "fraud_investigations", "compliance_checks"],
|
|
28767
28900
|
tableConfigs: /* @__PURE__ */ new Map([
|
|
28768
28901
|
["accounts", {
|
|
28769
28902
|
tableName: "accounts",
|
|
@@ -28831,7 +28964,7 @@ var fintechTemplate = {
|
|
|
28831
28964
|
{
|
|
28832
28965
|
columnName: "closed_at",
|
|
28833
28966
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28834
|
-
description: "Nullable \
|
|
28967
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for active accounts"
|
|
28835
28968
|
}
|
|
28836
28969
|
]
|
|
28837
28970
|
}],
|
|
@@ -28952,7 +29085,7 @@ var fintechTemplate = {
|
|
|
28952
29085
|
{
|
|
28953
29086
|
columnName: "resolved_at",
|
|
28954
29087
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28955
|
-
description: "Nullable \
|
|
29088
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for open/investigating alerts"
|
|
28956
29089
|
}
|
|
28957
29090
|
]
|
|
28958
29091
|
}],
|
|
@@ -28988,7 +29121,7 @@ var fintechTemplate = {
|
|
|
28988
29121
|
{
|
|
28989
29122
|
columnName: "settled_at",
|
|
28990
29123
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
28991
|
-
description: "Nullable \
|
|
29124
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for pending settlements"
|
|
28992
29125
|
},
|
|
28993
29126
|
{
|
|
28994
29127
|
columnName: "created_at",
|
|
@@ -29032,9 +29165,70 @@ var fintechTemplate = {
|
|
|
29032
29165
|
{
|
|
29033
29166
|
columnName: "resolved_at",
|
|
29034
29167
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
29035
|
-
description: "Nullable \
|
|
29168
|
+
description: "Nullable \xC3\u0192\xC2\xA2\xC3\xA2\xE2\u20AC\u0161\xC2\xAC\xC3\xA2\xE2\u201A\xAC\xC2\x9D null for open/under_review chargebacks"
|
|
29036
29169
|
}
|
|
29037
29170
|
]
|
|
29171
|
+
}],
|
|
29172
|
+
["transfers", {
|
|
29173
|
+
tableName: "transfers",
|
|
29174
|
+
matchPattern: ["transfers", "*transfer*"],
|
|
29175
|
+
rowCountMultiplier: 5,
|
|
29176
|
+
columnOverrides: [
|
|
29177
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 100, max: 5e6 } } },
|
|
29178
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["completed", "pending", "failed", "cancelled"], weights: [0.75, 0.12, 0.08, 0.05] } } },
|
|
29179
|
+
{ columnName: "reference", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29180
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29181
|
+
]
|
|
29182
|
+
}],
|
|
29183
|
+
["cards", {
|
|
29184
|
+
tableName: "cards",
|
|
29185
|
+
matchPattern: ["cards", "*card*"],
|
|
29186
|
+
rowCountMultiplier: 2.5,
|
|
29187
|
+
columnOverrides: [
|
|
29188
|
+
{ columnName: "card_number_last_four", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29189
|
+
{ columnName: "card_type", strategy: { kind: "enum", options: { values: ["debit", "credit"], weights: [0.6, 0.4] } } },
|
|
29190
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["active", "blocked", "expired", "cancelled"], weights: [0.75, 0.08, 0.12, 0.05] } } },
|
|
29191
|
+
{ columnName: "daily_limit_cents", strategy: { kind: "integer", options: { min: 5e4, max: 1e6 } } },
|
|
29192
|
+
{ columnName: "expires_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29193
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29194
|
+
]
|
|
29195
|
+
}],
|
|
29196
|
+
["authorizations", {
|
|
29197
|
+
tableName: "authorizations",
|
|
29198
|
+
matchPattern: ["authorizations", "*authorization*", "*auth*"],
|
|
29199
|
+
rowCountMultiplier: 8,
|
|
29200
|
+
columnOverrides: [
|
|
29201
|
+
{ columnName: "merchant_name", strategy: { kind: "company_name" } },
|
|
29202
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 100, max: 5e5 } } },
|
|
29203
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["approved", "declined", "reversed"], weights: [0.85, 0.1, 0.05] } } },
|
|
29204
|
+
{ columnName: "decline_reason", strategy: { kind: "enum", options: { values: ["insufficient_funds", "card_blocked", "suspicious_activity", "expired_card", "limit_exceeded"], weights: [0.3, 0.2, 0.25, 0.1, 0.15] } } },
|
|
29205
|
+
{ columnName: "authorized_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29206
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29207
|
+
]
|
|
29208
|
+
}],
|
|
29209
|
+
["fraud_investigations", {
|
|
29210
|
+
tableName: "fraud_investigations",
|
|
29211
|
+
matchPattern: ["fraud_investigations", "*investigation*"],
|
|
29212
|
+
rowCountMultiplier: 0.2,
|
|
29213
|
+
columnOverrides: [
|
|
29214
|
+
{ columnName: "investigator_notes", strategy: { kind: "text" } },
|
|
29215
|
+
{ columnName: "outcome", strategy: { kind: "enum", options: { values: ["confirmed_fraud", "false_positive", "inconclusive"], weights: [0.3, 0.5, 0.2] } } },
|
|
29216
|
+
{ columnName: "amount_recovered_cents", strategy: { kind: "integer", options: { min: 0, max: 5e5 } } },
|
|
29217
|
+
{ columnName: "closed_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29218
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29219
|
+
]
|
|
29220
|
+
}],
|
|
29221
|
+
["compliance_checks", {
|
|
29222
|
+
tableName: "compliance_checks",
|
|
29223
|
+
matchPattern: ["compliance_checks", "*compliance*"],
|
|
29224
|
+
rowCountMultiplier: 2,
|
|
29225
|
+
columnOverrides: [
|
|
29226
|
+
{ columnName: "check_type", strategy: { kind: "enum", options: { values: ["kyc_verification", "aml_screening", "pep_check", "sanctions_check"], weights: [0.35, 0.3, 0.2, 0.15] } } },
|
|
29227
|
+
{ columnName: "result", strategy: { kind: "enum", options: { values: ["pass", "fail", "review_needed"], weights: [0.7, 0.1, 0.2] } } },
|
|
29228
|
+
{ columnName: "notes", strategy: { kind: "text" } },
|
|
29229
|
+
{ columnName: "performed_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29230
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29231
|
+
]
|
|
29038
29232
|
}]
|
|
29039
29233
|
])
|
|
29040
29234
|
};
|
|
@@ -29043,8 +29237,8 @@ var fintechTemplate = {
|
|
|
29043
29237
|
var healthcareTemplate = {
|
|
29044
29238
|
name: "healthcare",
|
|
29045
29239
|
version: "2.0",
|
|
29046
|
-
description: "Healthcare
|
|
29047
|
-
targetTables: ["patients", "providers", "encounters", "diagnoses", "billing", "medications", "vitals"],
|
|
29240
|
+
description: "Healthcare network with 13 tables: patients, providers, encounters, diagnoses, procedures, prescriptions, lab_orders, lab_results, vitals, billing, medications, insurance_claims, claim_payments",
|
|
29241
|
+
targetTables: ["patients", "providers", "encounters", "diagnoses", "billing", "medications", "vitals", "procedures", "prescriptions", "lab_orders", "lab_results", "insurance_claims", "claim_payments"],
|
|
29048
29242
|
tableConfigs: /* @__PURE__ */ new Map([
|
|
29049
29243
|
["patients", {
|
|
29050
29244
|
tableName: "patients",
|
|
@@ -29204,12 +29398,12 @@ var healthcareTemplate = {
|
|
|
29204
29398
|
{
|
|
29205
29399
|
columnName: "checked_in_at",
|
|
29206
29400
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
29207
|
-
description: "Nullable \
|
|
29401
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for scheduled/canceled encounters"
|
|
29208
29402
|
},
|
|
29209
29403
|
{
|
|
29210
29404
|
columnName: "discharged_at",
|
|
29211
29405
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
29212
|
-
description: "Nullable \
|
|
29406
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for non-completed encounters"
|
|
29213
29407
|
}
|
|
29214
29408
|
]
|
|
29215
29409
|
}],
|
|
@@ -29308,7 +29502,7 @@ var healthcareTemplate = {
|
|
|
29308
29502
|
{
|
|
29309
29503
|
columnName: "paid_at",
|
|
29310
29504
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
29311
|
-
description: "Nullable \
|
|
29505
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for unpaid bills"
|
|
29312
29506
|
}
|
|
29313
29507
|
]
|
|
29314
29508
|
}],
|
|
@@ -29363,7 +29557,7 @@ var healthcareTemplate = {
|
|
|
29363
29557
|
{
|
|
29364
29558
|
columnName: "end_date",
|
|
29365
29559
|
strategy: { kind: "timestamp", options: { mode: "past" } },
|
|
29366
|
-
description: "Nullable \
|
|
29560
|
+
description: "Nullable \xC3\xA2\xE2\u201A\xAC\xE2\u20AC\x9D null for ongoing medications"
|
|
29367
29561
|
},
|
|
29368
29562
|
{
|
|
29369
29563
|
columnName: "status",
|
|
@@ -29411,6 +29605,85 @@ var healthcareTemplate = {
|
|
|
29411
29605
|
strategy: { kind: "timestamp", options: { mode: "past" } }
|
|
29412
29606
|
}
|
|
29413
29607
|
]
|
|
29608
|
+
}],
|
|
29609
|
+
["procedures", {
|
|
29610
|
+
tableName: "procedures",
|
|
29611
|
+
matchPattern: ["procedures", "*procedure*"],
|
|
29612
|
+
rowCountMultiplier: 5,
|
|
29613
|
+
columnOverrides: [
|
|
29614
|
+
{ columnName: "cpt_code", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29615
|
+
{ columnName: "procedure_name", strategy: { kind: "text" } },
|
|
29616
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["completed", "scheduled", "cancelled"], weights: [0.7, 0.2, 0.1] } } },
|
|
29617
|
+
{ columnName: "performed_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29618
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29619
|
+
]
|
|
29620
|
+
}],
|
|
29621
|
+
["prescriptions", {
|
|
29622
|
+
tableName: "prescriptions",
|
|
29623
|
+
matchPattern: ["prescriptions", "*prescription*"],
|
|
29624
|
+
rowCountMultiplier: 8,
|
|
29625
|
+
columnOverrides: [
|
|
29626
|
+
{ columnName: "dosage", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29627
|
+
{ columnName: "frequency", strategy: { kind: "enum", options: { values: ["once_daily", "twice_daily", "three_times_daily", "as_needed", "weekly"], weights: [0.35, 0.25, 0.15, 0.15, 0.1] } } },
|
|
29628
|
+
{ columnName: "duration_days", strategy: { kind: "integer", options: { min: 5, max: 365 } } },
|
|
29629
|
+
{ columnName: "refills_remaining", strategy: { kind: "integer", options: { min: 0, max: 12 } } },
|
|
29630
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["active", "completed", "cancelled", "expired"], weights: [0.45, 0.3, 0.1, 0.15] } } },
|
|
29631
|
+
{ columnName: "prescribed_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29632
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29633
|
+
]
|
|
29634
|
+
}],
|
|
29635
|
+
["lab_orders", {
|
|
29636
|
+
tableName: "lab_orders",
|
|
29637
|
+
matchPattern: ["lab_orders", "*lab_order*"],
|
|
29638
|
+
rowCountMultiplier: 4,
|
|
29639
|
+
columnOverrides: [
|
|
29640
|
+
{ columnName: "test_name", strategy: { kind: "text" } },
|
|
29641
|
+
{ columnName: "priority", strategy: { kind: "enum", options: { values: ["routine", "urgent", "stat"], weights: [0.7, 0.2, 0.1] } } },
|
|
29642
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["ordered", "collected", "resulted", "cancelled"], weights: [0.15, 0.1, 0.65, 0.1] } } },
|
|
29643
|
+
{ columnName: "ordered_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29644
|
+
{ columnName: "resulted_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29645
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29646
|
+
]
|
|
29647
|
+
}],
|
|
29648
|
+
["lab_results", {
|
|
29649
|
+
tableName: "lab_results",
|
|
29650
|
+
matchPattern: ["lab_results", "*lab_result*"],
|
|
29651
|
+
rowCountMultiplier: 10,
|
|
29652
|
+
columnOverrides: [
|
|
29653
|
+
{ columnName: "component", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29654
|
+
{ columnName: "value", strategy: { kind: "float", options: { min: 0.1, max: 500 } } },
|
|
29655
|
+
{ columnName: "unit", strategy: { kind: "enum", options: { values: ["mg/dL", "mmol/L", "g/dL", "mEq/L", "U/L", "ng/mL", "cells/uL"], weights: [0.2, 0.15, 0.15, 0.15, 0.15, 0.1, 0.1] } } },
|
|
29656
|
+
{ columnName: "reference_range", strategy: { kind: "text", options: { mode: "short" } } },
|
|
29657
|
+
{ columnName: "abnormal_flag", strategy: { kind: "enum", options: { values: ["normal", "low", "high", "critical"], weights: [0.65, 0.15, 0.15, 0.05] } } },
|
|
29658
|
+
{ columnName: "resulted_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29659
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29660
|
+
]
|
|
29661
|
+
}],
|
|
29662
|
+
["insurance_claims", {
|
|
29663
|
+
tableName: "insurance_claims",
|
|
29664
|
+
matchPattern: ["insurance_claims", "*claim*"],
|
|
29665
|
+
rowCountMultiplier: 6,
|
|
29666
|
+
columnOverrides: [
|
|
29667
|
+
{ columnName: "total_charges_cents", strategy: { kind: "integer", options: { min: 5e3, max: 5e5 } } },
|
|
29668
|
+
{ columnName: "allowed_amount_cents", strategy: { kind: "integer", options: { min: 3e3, max: 4e5 } } },
|
|
29669
|
+
{ columnName: "patient_responsibility_cents", strategy: { kind: "integer", options: { min: 0, max: 1e5 } } },
|
|
29670
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["submitted", "adjudicated", "paid", "denied", "appealed"], weights: [0.15, 0.1, 0.55, 0.12, 0.08] } } },
|
|
29671
|
+
{ columnName: "submitted_at", strategy: { kind: "timestamp", options: { mode: "past" } } },
|
|
29672
|
+
{ columnName: "paid_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29673
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29674
|
+
]
|
|
29675
|
+
}],
|
|
29676
|
+
["claim_payments", {
|
|
29677
|
+
tableName: "claim_payments",
|
|
29678
|
+
matchPattern: ["claim_payments", "*claim_payment*"],
|
|
29679
|
+
rowCountMultiplier: 4,
|
|
29680
|
+
columnOverrides: [
|
|
29681
|
+
{ columnName: "amount_cents", strategy: { kind: "integer", options: { min: 1e3, max: 4e5 } } },
|
|
29682
|
+
{ columnName: "payment_method", strategy: { kind: "enum", options: { values: ["eft", "check", "wire"], weights: [0.7, 0.2, 0.1] } } },
|
|
29683
|
+
{ columnName: "status", strategy: { kind: "enum", options: { values: ["processed", "pending", "failed"], weights: [0.8, 0.12, 0.08] } } },
|
|
29684
|
+
{ columnName: "paid_at", strategy: { kind: "timestamp", options: { mode: "recent" } } },
|
|
29685
|
+
{ columnName: "created_at", strategy: { kind: "timestamp", options: { mode: "past" } } }
|
|
29686
|
+
]
|
|
29414
29687
|
}]
|
|
29415
29688
|
])
|
|
29416
29689
|
};
|
|
@@ -30095,8 +30368,9 @@ function buildGenerationPlan(schema, config, timelineConfig) {
|
|
|
30095
30368
|
for (const fk of schema.foreignKeys) {
|
|
30096
30369
|
fkBySource.set(`${fk.sourceTable}.${fk.sourceColumn}`, fk);
|
|
30097
30370
|
}
|
|
30371
|
+
const templateTargetSet = template ? new Set(template.targetTables) : null;
|
|
30098
30372
|
const tables = schema.tables.map((table) => {
|
|
30099
|
-
const tableForeignKeys = schema.foreignKeys.filter((fk) => fk.sourceTable === table.name);
|
|
30373
|
+
const tableForeignKeys = schema.foreignKeys.filter((fk) => fk.sourceTable === table.name && (!templateTargetSet || templateTargetSet.has(fk.targetTable)));
|
|
30100
30374
|
const dependencies = tableForeignKeys.map((fk) => fk.targetTable);
|
|
30101
30375
|
const uniqueDeps = [...new Set(dependencies)];
|
|
30102
30376
|
const tableConfig = template && registry && templateLookupName ? registry.matchTable(templateLookupName, table.name) : null;
|
|
@@ -30162,7 +30436,7 @@ function buildGenerationPlan(schema, config, timelineConfig) {
|
|
|
30162
30436
|
isUnique: column.isUnique
|
|
30163
30437
|
};
|
|
30164
30438
|
const fk = fkBySource.get(`${table.name}.${column.name}`);
|
|
30165
|
-
if (fk) {
|
|
30439
|
+
if (fk && (!templateTargetSet || templateTargetSet.has(fk.targetTable))) {
|
|
30166
30440
|
columnPlan.strategy = { kind: "foreign_key" };
|
|
30167
30441
|
const ref = {
|
|
30168
30442
|
referencedTable: fk.targetTable,
|
|
@@ -30192,7 +30466,7 @@ function buildGenerationPlan(schema, config, timelineConfig) {
|
|
|
30192
30466
|
});
|
|
30193
30467
|
}
|
|
30194
30468
|
}
|
|
30195
|
-
const rowCount = tableConfig?.rowCountMultiplier ? Math.round(defaultRowCount * tableConfig.rowCountMultiplier) : defaultRowCount;
|
|
30469
|
+
const rowCount = tableConfig?.rowCountMultiplier ? Math.max(1, Math.round(defaultRowCount * tableConfig.rowCountMultiplier)) : defaultRowCount;
|
|
30196
30470
|
const enabled = template ? tableConfig !== null : true;
|
|
30197
30471
|
const tablePlan = {
|
|
30198
30472
|
tableName: table.name,
|
|
@@ -30207,26 +30481,17 @@ function buildGenerationPlan(schema, config, timelineConfig) {
|
|
|
30207
30481
|
return tablePlan;
|
|
30208
30482
|
});
|
|
30209
30483
|
if (template) {
|
|
30210
|
-
const
|
|
30211
|
-
|
|
30212
|
-
|
|
30213
|
-
|
|
30214
|
-
for (const tablePlan of tables) {
|
|
30215
|
-
if (tablePlan.enabled) {
|
|
30216
|
-
for (const dep of tablePlan.dependencies) {
|
|
30217
|
-
if (!enabledSet.has(dep)) {
|
|
30218
|
-
enabledSet.add(dep);
|
|
30219
|
-
const depPlan = tables.find((t) => t.tableName === dep);
|
|
30220
|
-
if (depPlan && !depPlan.enabled) {
|
|
30221
|
-
depPlan.enabled = true;
|
|
30222
|
-
changed = true;
|
|
30223
|
-
}
|
|
30224
|
-
}
|
|
30225
|
-
}
|
|
30226
|
-
}
|
|
30484
|
+
const targetSet = new Set(template.targetTables);
|
|
30485
|
+
for (const tablePlan of tables) {
|
|
30486
|
+
if (tablePlan.enabled && !targetSet.has(tablePlan.tableName)) {
|
|
30487
|
+
tablePlan.enabled = false;
|
|
30227
30488
|
}
|
|
30228
30489
|
}
|
|
30229
30490
|
}
|
|
30491
|
+
const enabledNames = new Set(tables.filter((t) => t.enabled).map((t) => t.tableName));
|
|
30492
|
+
const filteredTableOrder = tableOrder.filter((name) => enabledNames.has(name));
|
|
30493
|
+
tableOrder.length = 0;
|
|
30494
|
+
tableOrder.push(...filteredTableOrder);
|
|
30230
30495
|
if (timelineConfig?.enabled) {
|
|
30231
30496
|
const temporalConstraints = resolveTemporalConstraints(schema, schema.foreignKeys, config.template);
|
|
30232
30497
|
for (const tablePlan of tables) {
|
|
@@ -31485,9 +31750,22 @@ async function exportDataset(config, options) {
|
|
|
31485
31750
|
case "csv":
|
|
31486
31751
|
files = await exportToCsv(dataset, outputDir);
|
|
31487
31752
|
break;
|
|
31488
|
-
case "sql":
|
|
31489
|
-
|
|
31753
|
+
case "sql": {
|
|
31754
|
+
const templateTableSet = new Set(plan.tableOrder);
|
|
31755
|
+
const scopedSchema = {
|
|
31756
|
+
...schema,
|
|
31757
|
+
tables: schema.tables.filter((t) => templateTableSet.has(t.name)),
|
|
31758
|
+
foreignKeys: schema.foreignKeys.filter((fk) => templateTableSet.has(fk.sourceTable) && templateTableSet.has(fk.targetTable))
|
|
31759
|
+
};
|
|
31760
|
+
scopedSchema.tableCount = scopedSchema.tables.length;
|
|
31761
|
+
scopedSchema.foreignKeyCount = scopedSchema.foreignKeys.length;
|
|
31762
|
+
files = await exportToSql(dataset, outputDir, plan.tableOrder, {
|
|
31763
|
+
ddl: generateCreateTableDDL(scopedSchema),
|
|
31764
|
+
batchSize: options?.batchSize ?? 50,
|
|
31765
|
+
templateName: plan.config.templateName
|
|
31766
|
+
});
|
|
31490
31767
|
break;
|
|
31768
|
+
}
|
|
31491
31769
|
default:
|
|
31492
31770
|
throw new Error(`Unknown export format: "${format}". Supported: json, csv, sql`);
|
|
31493
31771
|
}
|
|
@@ -33366,6 +33644,7 @@ async function exportCommand(options) {
|
|
|
33366
33644
|
console.log("");
|
|
33367
33645
|
console.log("Generating dataset...");
|
|
33368
33646
|
}
|
|
33647
|
+
const batchSize = options.batchSize ? parseInt(options.batchSize, 10) : void 0;
|
|
33369
33648
|
const result = await exportDataset(config, {
|
|
33370
33649
|
format,
|
|
33371
33650
|
outputDir,
|
|
@@ -33375,7 +33654,8 @@ async function exportCommand(options) {
|
|
|
33375
33654
|
timeline,
|
|
33376
33655
|
scenarios: scenario,
|
|
33377
33656
|
scenarioIntensity,
|
|
33378
|
-
scenarioSchedule: options.scenarioSchedule
|
|
33657
|
+
scenarioSchedule: options.scenarioSchedule,
|
|
33658
|
+
batchSize
|
|
33379
33659
|
});
|
|
33380
33660
|
const durationMs = Math.round(performance.now() - start);
|
|
33381
33661
|
if (options.ci) {
|
|
@@ -35863,7 +36143,7 @@ async function simulateWebhooksCommand(options) {
|
|
|
35863
36143
|
}
|
|
35864
36144
|
|
|
35865
36145
|
// src/cli.ts
|
|
35866
|
-
var VERSION17 = "2.0.
|
|
36146
|
+
var VERSION17 = "2.0.1";
|
|
35867
36147
|
function run(argv) {
|
|
35868
36148
|
const program2 = new Command();
|
|
35869
36149
|
program2.name("realitydb").description("RealityDB -- Developer Reality Platform").version(VERSION17).option("--config <path>", "Path to config file").option("--ci", "CI mode: JSON output, no prompts, proper exit codes", false).option("--verbose", "Enable verbose output", false);
|
|
@@ -35886,7 +36166,7 @@ function run(argv) {
|
|
|
35886
36166
|
const opts = program2.opts();
|
|
35887
36167
|
await resetCommand({ ...cmdOpts, ci: opts.ci, configPath: opts.config });
|
|
35888
36168
|
});
|
|
35889
|
-
program2.command("export").description("Export generated data").option("--format <format>", "Output format (json|csv|sql)", "json").option("--output <dir>", "Output directory", "./.realitydb").option("--records <count>", "Number of records per table").option("--seed <number>", "Random seed for reproducibility").option("--template <name>", "Template to use").option("--timeline <duration>", 'Timeline duration (e.g., "12-months", "1-year")').option("--scenario <names>", "Scenarios to apply (comma-separated)").option("--scenario-intensity <level>", "Scenario intensity (low|medium|high)", "medium").option("--scenario-schedule <schedule>", 'Timeline-scheduled scenarios (e.g., "fraud-spike:month-6,churn-spike:month-9")').action(async (cmdOpts) => {
|
|
36169
|
+
program2.command("export").description("Export generated data").option("--format <format>", "Output format (json|csv|sql)", "json").option("--output <dir>", "Output directory", "./.realitydb").option("--records <count>", "Number of records per table").option("--seed <number>", "Random seed for reproducibility").option("--template <name>", "Template to use").option("--timeline <duration>", 'Timeline duration (e.g., "12-months", "1-year")').option("--scenario <names>", "Scenarios to apply (comma-separated)").option("--scenario-intensity <level>", "Scenario intensity (low|medium|high)", "medium").option("--scenario-schedule <schedule>", 'Timeline-scheduled scenarios (e.g., "fraud-spike:month-6,churn-spike:month-9")').option("--batch-size <number>", "Rows per INSERT statement for SQL format (default: 50)").action(async (cmdOpts) => {
|
|
35890
36170
|
const opts = program2.opts();
|
|
35891
36171
|
await exportCommand({ ...cmdOpts, ci: opts.ci, configPath: opts.config });
|
|
35892
36172
|
});
|