@meghjs/cli 0.5.3 → 0.5.5
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/dist/generators/auth-files.d.ts +37 -0
- package/dist/generators/auth-files.js +198 -0
- package/dist/generators/auth.d.ts +26 -0
- package/dist/generators/auth.js +542 -0
- package/dist/generators/make.d.ts +8 -0
- package/dist/generators/make.js +12 -0
- package/dist/generators/migration-schema.d.ts +5 -0
- package/dist/generators/migration-schema.js +17 -0
- package/dist/generators/scaffold.d.ts +76 -0
- package/dist/generators/scaffold.js +353 -0
- package/dist/program.js +125 -3
- package/dist/templates/cascade.d.ts +37 -0
- package/dist/templates/cascade.js +87 -0
- package/dist/templates/catalog/common.d.ts +1 -0
- package/dist/templates/catalog/common.js +63 -0
- package/dist/templates/catalog/construction.d.ts +1 -0
- package/dist/templates/catalog/construction.js +138 -0
- package/dist/templates/catalog/crm.d.ts +1 -0
- package/dist/templates/catalog/crm.js +81 -0
- package/dist/templates/catalog/ecommerce.d.ts +1 -0
- package/dist/templates/catalog/ecommerce.js +143 -0
- package/dist/templates/catalog/education.d.ts +1 -0
- package/dist/templates/catalog/education.js +80 -0
- package/dist/templates/catalog/hr.d.ts +1 -0
- package/dist/templates/catalog/hr.js +83 -0
- package/dist/templates/catalog/logistics.d.ts +1 -0
- package/dist/templates/catalog/logistics.js +60 -0
- package/dist/templates/catalog/marketing.d.ts +1 -0
- package/dist/templates/catalog/marketing.js +104 -0
- package/dist/templates/catalog/medical.d.ts +1 -0
- package/dist/templates/catalog/medical.js +147 -0
- package/dist/templates/catalog/pos.d.ts +1 -0
- package/dist/templates/catalog/pos.js +110 -0
- package/dist/templates/catalog/real-estate.d.ts +1 -0
- package/dist/templates/catalog/real-estate.js +171 -0
- package/dist/templates/fields.d.ts +64 -0
- package/dist/templates/fields.js +331 -0
- package/dist/templates/index.d.ts +27 -0
- package/dist/templates/index.js +175 -0
- package/dist/templates/migration.d.ts +7 -0
- package/dist/templates/migration.js +80 -0
- package/dist/templates/template.d.ts +37 -0
- package/dist/templates/template.js +36 -0
- package/dist/utils/dialect.d.ts +8 -0
- package/dist/utils/dialect.js +57 -0
- package/package.json +17 -5
- package/readme.md +26 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cascadeEdges = cascadeEdges;
|
|
4
|
+
exports.limitCascadePaths = limitCascadePaths;
|
|
5
|
+
const CASCADING = new Set(["cascade", "set null", "set default"]);
|
|
6
|
+
/** The cascading foreign keys of the tables the migrations leave. */
|
|
7
|
+
function cascadeEdges(schema) {
|
|
8
|
+
const edges = [];
|
|
9
|
+
for (const table of schema.values()) {
|
|
10
|
+
for (const column of table.columns) {
|
|
11
|
+
const ref = column.references;
|
|
12
|
+
if (ref?.onDelete && CASCADING.has(ref.onDelete))
|
|
13
|
+
edges.push({ from: ref.table, to: table.name });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return edges;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Walk the new tables' foreign keys (in the order given, ownership first:
|
|
20
|
+
* CASCADE before SET NULL) and drop the action of each one SQL Server would
|
|
21
|
+
* refuse. Returns the tables' fields, changed where needed.
|
|
22
|
+
*/
|
|
23
|
+
function limitCascadePaths(existing, tables) {
|
|
24
|
+
const graph = new Map();
|
|
25
|
+
const add = (e) => {
|
|
26
|
+
if (!graph.has(e.from))
|
|
27
|
+
graph.set(e.from, new Set());
|
|
28
|
+
graph.get(e.from).add(e.to);
|
|
29
|
+
};
|
|
30
|
+
existing.forEach(add);
|
|
31
|
+
const walk = (start, next) => {
|
|
32
|
+
const seen = new Set([start]);
|
|
33
|
+
const queue = [start];
|
|
34
|
+
while (queue.length) {
|
|
35
|
+
for (const n of next(queue.shift())) {
|
|
36
|
+
if (!seen.has(n)) {
|
|
37
|
+
seen.add(n);
|
|
38
|
+
queue.push(n);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return seen;
|
|
43
|
+
};
|
|
44
|
+
const descendants = (node) => walk(node, (n) => graph.get(n) ?? []);
|
|
45
|
+
const ancestors = (node) => walk(node, (n) => [...graph].filter(([, tos]) => tos.has(n)).map(([from]) => from));
|
|
46
|
+
/** Why SQL Server would refuse `from → to`, or undefined. */
|
|
47
|
+
const conflict = (from, to) => {
|
|
48
|
+
if (from === to)
|
|
49
|
+
return "it references its own table";
|
|
50
|
+
if (descendants(to).has(from))
|
|
51
|
+
return "it would form a cycle of cascading deletes";
|
|
52
|
+
const below = descendants(to);
|
|
53
|
+
for (const a of ancestors(from)) {
|
|
54
|
+
for (const b of descendants(a)) {
|
|
55
|
+
if (below.has(b))
|
|
56
|
+
return `"${a}" would reach "${b}" through two cascade paths`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
};
|
|
61
|
+
const fields = new Map(tables.map(({ table, fields: list }) => [table, list.map((f) => ({ ...f }))]));
|
|
62
|
+
// Every CASCADE (a row owned by its parent) is placed before any SET NULL
|
|
63
|
+
// (a looser link), each in the order given.
|
|
64
|
+
const candidates = tables
|
|
65
|
+
.flatMap(({ table }) => fields.get(table).map((f, i) => ({ table, f, i })))
|
|
66
|
+
.filter(({ f }) => f.references?.onDelete && CASCADING.has(f.references.onDelete));
|
|
67
|
+
const order = candidates.map((c, n) => ({ ...c, n })).sort((x, y) => rank(x.f) - rank(y.f) || x.n - y.n);
|
|
68
|
+
const dropped = [];
|
|
69
|
+
for (const { table, f, i } of order) {
|
|
70
|
+
const from = f.references.table;
|
|
71
|
+
const reason = conflict(from, table);
|
|
72
|
+
if (!reason) {
|
|
73
|
+
add({ from, to: table });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
fields.get(table)[i] = {
|
|
77
|
+
...f,
|
|
78
|
+
nullable: f.nullable || f.references.onDelete === "set null",
|
|
79
|
+
references: { table: from },
|
|
80
|
+
comment: "no ON DELETE action: SQL Server allows one cascade path between tables",
|
|
81
|
+
};
|
|
82
|
+
dropped.push({ table, column: f.name, reason });
|
|
83
|
+
}
|
|
84
|
+
return { fields, dropped };
|
|
85
|
+
}
|
|
86
|
+
/** CASCADE (ownership) is kept before SET NULL. */
|
|
87
|
+
const rank = (f) => (f.references?.onDelete === "cascade" ? 0 : 1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const common: import("../template").Domain;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.common = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
exports.common = (0, template_1.domain)("common", "Common", "Users, roles, categories and other tables most apps share", [
|
|
6
|
+
[
|
|
7
|
+
"user",
|
|
8
|
+
"An account that signs in",
|
|
9
|
+
["name", "email:unique", "password", "email_verified_at", "remember_token", "is_active", "last_login_at"],
|
|
10
|
+
{ softDeletes: true },
|
|
11
|
+
],
|
|
12
|
+
["role", "A named set of permissions", ["name:string(64):unique", "slug:string(64):unique", "description"]],
|
|
13
|
+
[
|
|
14
|
+
"permission",
|
|
15
|
+
"One thing a role may do, e.g. posts.create",
|
|
16
|
+
["name:string(128):unique", "group?:string(64)", "description"],
|
|
17
|
+
],
|
|
18
|
+
["user_role", "Which roles each user has", ["user_id:cascade", "role_id:cascade"], { pivot: true }],
|
|
19
|
+
[
|
|
20
|
+
"role_permission",
|
|
21
|
+
"Which permissions each role has",
|
|
22
|
+
["role_id:cascade", "permission_id:cascade"],
|
|
23
|
+
{ pivot: true },
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"category",
|
|
27
|
+
"A nestable category",
|
|
28
|
+
["parent_id:foreign(categories):nullOnDelete", "name", "slug", "description", "image", "sort_order", "is_active"],
|
|
29
|
+
],
|
|
30
|
+
["tag", "A free-form label", ["name:string(64)", "slug:string(64):unique"]],
|
|
31
|
+
[
|
|
32
|
+
"address",
|
|
33
|
+
"A postal address of any record (addressable_type + addressable_id)",
|
|
34
|
+
["addressable_type:string(64):index", "addressable_id:integer:index", "label?:string(64)", "address", "geo", "is_default:boolean:default(false)"],
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"attachment",
|
|
38
|
+
"An uploaded file of any record (attachable_type + attachable_id)",
|
|
39
|
+
[
|
|
40
|
+
"attachable_type:string(64):index",
|
|
41
|
+
"attachable_id:integer:index",
|
|
42
|
+
"name",
|
|
43
|
+
"path:string(2048)",
|
|
44
|
+
"disk:string(32):default(local)",
|
|
45
|
+
"mime_type?:string(128)",
|
|
46
|
+
"size:integer:default(0)",
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
"api_key",
|
|
51
|
+
"An API key of a user; only its SHA-256 hash is stored",
|
|
52
|
+
[
|
|
53
|
+
"user_id:cascade",
|
|
54
|
+
"name:string(100)",
|
|
55
|
+
"prefix:string(16):index",
|
|
56
|
+
"key_hash:string(64):unique",
|
|
57
|
+
"last_used_at?:timestamp",
|
|
58
|
+
"expires_at?:timestamp",
|
|
59
|
+
"revoked_at?:timestamp",
|
|
60
|
+
],
|
|
61
|
+
],
|
|
62
|
+
["setting", "An application setting", ["name:string(128):unique", "value?:text", "group?:string(64)"]],
|
|
63
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const construction: import("../template").Domain;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.construction = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
exports.construction = (0, template_1.domain)("construction", "Construction", "Building projects: sites, contractors, work orders, materials and budgets", [
|
|
6
|
+
["client", "The client a project is built for", ["name", "company?:string", "email?", "phone", "address?"]],
|
|
7
|
+
[
|
|
8
|
+
"project",
|
|
9
|
+
"A construction project",
|
|
10
|
+
[
|
|
11
|
+
"client_id:nullOnDelete",
|
|
12
|
+
"manager_id:foreign(users):nullOnDelete",
|
|
13
|
+
"name",
|
|
14
|
+
"code",
|
|
15
|
+
"description",
|
|
16
|
+
"status:in(planning|active|on_hold|completed|cancelled)",
|
|
17
|
+
"budget?:money",
|
|
18
|
+
"start_date?:date",
|
|
19
|
+
"end_date?:date",
|
|
20
|
+
"address?",
|
|
21
|
+
],
|
|
22
|
+
{ softDeletes: true },
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"site",
|
|
26
|
+
"A site of a project",
|
|
27
|
+
["project_id:cascade", "supervisor_id:foreign(users):nullOnDelete", "name", "address", "geo", "is_active"],
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"contractor",
|
|
31
|
+
"A contractor or subcontractor",
|
|
32
|
+
[
|
|
33
|
+
"name",
|
|
34
|
+
"company?:string",
|
|
35
|
+
"trade?:string(64)",
|
|
36
|
+
"email?",
|
|
37
|
+
"phone",
|
|
38
|
+
"license_number?:string(64)",
|
|
39
|
+
"address?",
|
|
40
|
+
"rating",
|
|
41
|
+
"is_active",
|
|
42
|
+
],
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"work_order",
|
|
46
|
+
"A piece of work on a project",
|
|
47
|
+
[
|
|
48
|
+
"project_id:cascade",
|
|
49
|
+
"site_id:nullOnDelete",
|
|
50
|
+
"contractor_id:nullOnDelete",
|
|
51
|
+
"assigned_to_id:foreign(users):nullOnDelete",
|
|
52
|
+
"title",
|
|
53
|
+
"description",
|
|
54
|
+
"priority",
|
|
55
|
+
"status:in(open|in_progress|on_hold|completed|cancelled)",
|
|
56
|
+
"due_date",
|
|
57
|
+
"completed_at?:timestamp",
|
|
58
|
+
"estimated_cost?:money",
|
|
59
|
+
"actual_cost?:money",
|
|
60
|
+
],
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"material",
|
|
64
|
+
"A building material kept in stock",
|
|
65
|
+
[
|
|
66
|
+
"name",
|
|
67
|
+
"sku",
|
|
68
|
+
"unit:string(16)",
|
|
69
|
+
"unit_cost:money",
|
|
70
|
+
"quantity_on_hand:decimal(12,3):default(0)",
|
|
71
|
+
"reorder_level?:decimal(12,3)",
|
|
72
|
+
"supplier?:string",
|
|
73
|
+
],
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"equipment",
|
|
77
|
+
"A machine or tool",
|
|
78
|
+
[
|
|
79
|
+
"site_id:nullOnDelete",
|
|
80
|
+
"name",
|
|
81
|
+
"code",
|
|
82
|
+
"category?:string(64)",
|
|
83
|
+
"serial_number?:string(128)",
|
|
84
|
+
"status:in(available|in_use|maintenance|retired)",
|
|
85
|
+
"purchase_date?:date",
|
|
86
|
+
"purchase_cost?:money",
|
|
87
|
+
],
|
|
88
|
+
{ table: "equipment" },
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
"timesheet",
|
|
92
|
+
"Hours a worker spent on a project",
|
|
93
|
+
[
|
|
94
|
+
"user_id:cascade",
|
|
95
|
+
"project_id:cascade",
|
|
96
|
+
"work_order_id:nullOnDelete",
|
|
97
|
+
"date",
|
|
98
|
+
"hours:decimal(5,2)",
|
|
99
|
+
"overtime_hours:decimal(5,2):default(0)",
|
|
100
|
+
"status:in(draft|submitted|approved|rejected)",
|
|
101
|
+
"notes",
|
|
102
|
+
],
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"inspection",
|
|
106
|
+
"A site or safety inspection",
|
|
107
|
+
[
|
|
108
|
+
"project_id:cascade",
|
|
109
|
+
"site_id:nullOnDelete",
|
|
110
|
+
"inspector_name:string",
|
|
111
|
+
"type",
|
|
112
|
+
"scheduled_at?:timestamp",
|
|
113
|
+
"inspected_at?:timestamp",
|
|
114
|
+
"result:in(pending|passed|failed|conditional)",
|
|
115
|
+
"notes",
|
|
116
|
+
],
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
"change_order",
|
|
120
|
+
"A change to a project's scope, cost or schedule",
|
|
121
|
+
[
|
|
122
|
+
"project_id:cascade",
|
|
123
|
+
"requested_by_id:foreign(users):nullOnDelete",
|
|
124
|
+
"number:string(32):unique",
|
|
125
|
+
"title",
|
|
126
|
+
"description",
|
|
127
|
+
"amount",
|
|
128
|
+
"days_impact:integer:default(0)",
|
|
129
|
+
"status:in(draft|submitted|approved|rejected)",
|
|
130
|
+
"approved_at?:timestamp",
|
|
131
|
+
],
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
"budget_item",
|
|
135
|
+
"A budget line of a project",
|
|
136
|
+
["project_id:cascade", "category:string(64)", "description", "budgeted_amount:money", "actual_amount:money:default(0)", "notes"],
|
|
137
|
+
],
|
|
138
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const crm: import("../template").Domain;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crm = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
exports.crm = (0, template_1.domain)("crm", "CRM", "Accounts, contacts, deal pipelines and activities", [
|
|
6
|
+
[
|
|
7
|
+
"account",
|
|
8
|
+
"A company you sell to",
|
|
9
|
+
[
|
|
10
|
+
"owner_id:foreign(users):nullOnDelete",
|
|
11
|
+
"name",
|
|
12
|
+
"industry?:string(64)",
|
|
13
|
+
"website",
|
|
14
|
+
"phone",
|
|
15
|
+
"email?",
|
|
16
|
+
"address?",
|
|
17
|
+
"annual_revenue?:money",
|
|
18
|
+
"employee_count?:integer",
|
|
19
|
+
"status:in(prospect|customer|partner|inactive)",
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"contact",
|
|
24
|
+
"A person at an account",
|
|
25
|
+
[
|
|
26
|
+
"account_id:nullOnDelete",
|
|
27
|
+
"owner_id:foreign(users):nullOnDelete",
|
|
28
|
+
"person",
|
|
29
|
+
"email",
|
|
30
|
+
"phone",
|
|
31
|
+
"job_title?:string(128)",
|
|
32
|
+
"notes",
|
|
33
|
+
],
|
|
34
|
+
],
|
|
35
|
+
["pipeline", "A sales pipeline", ["name", "is_default:boolean:default(false)", "sort_order"]],
|
|
36
|
+
[
|
|
37
|
+
"pipeline_stage",
|
|
38
|
+
"A stage of a pipeline",
|
|
39
|
+
[
|
|
40
|
+
"pipeline_id:cascade",
|
|
41
|
+
"name",
|
|
42
|
+
"probability:integer:default(0)",
|
|
43
|
+
"sort_order",
|
|
44
|
+
"is_won:boolean:default(false)",
|
|
45
|
+
"is_lost:boolean:default(false)",
|
|
46
|
+
],
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
"deal",
|
|
50
|
+
"A sales opportunity",
|
|
51
|
+
[
|
|
52
|
+
"account_id:nullOnDelete",
|
|
53
|
+
"contact_id:nullOnDelete",
|
|
54
|
+
"pipeline_id:restrict",
|
|
55
|
+
"pipeline_stage_id:restrict",
|
|
56
|
+
"owner_id:foreign(users):nullOnDelete",
|
|
57
|
+
"title",
|
|
58
|
+
"amount:default(0)",
|
|
59
|
+
"currency",
|
|
60
|
+
"expected_close_date?:date",
|
|
61
|
+
"status:in(open|won|lost)",
|
|
62
|
+
"closed_at?:timestamp",
|
|
63
|
+
"lost_reason?:string(500)",
|
|
64
|
+
],
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"activity",
|
|
68
|
+
"A call, email, meeting, task or note",
|
|
69
|
+
[
|
|
70
|
+
"user_id:nullOnDelete",
|
|
71
|
+
"account_id:nullOnDelete",
|
|
72
|
+
"contact_id:nullOnDelete",
|
|
73
|
+
"deal_id:nullOnDelete",
|
|
74
|
+
"type:in(call|email|meeting|task|note)",
|
|
75
|
+
"subject:string",
|
|
76
|
+
"description",
|
|
77
|
+
"due_at?:timestamp",
|
|
78
|
+
"completed_at?:timestamp",
|
|
79
|
+
],
|
|
80
|
+
],
|
|
81
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ecommerce: import("../template").Domain;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ecommerce = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
exports.ecommerce = (0, template_1.domain)("ecommerce", "E-commerce", "An online store: catalog, carts, orders and payments", [
|
|
6
|
+
["brand", "A product brand", ["name", "slug", "logo", "description", "website", "is_active"]],
|
|
7
|
+
[
|
|
8
|
+
"product",
|
|
9
|
+
"A product in the catalog",
|
|
10
|
+
[
|
|
11
|
+
"category_id:nullOnDelete",
|
|
12
|
+
"brand_id:nullOnDelete",
|
|
13
|
+
"name",
|
|
14
|
+
"slug",
|
|
15
|
+
"sku",
|
|
16
|
+
"description",
|
|
17
|
+
"price",
|
|
18
|
+
"compare_at_price?:money",
|
|
19
|
+
"cost",
|
|
20
|
+
"stock",
|
|
21
|
+
"weight",
|
|
22
|
+
"status:in(draft|active|archived)",
|
|
23
|
+
"is_featured",
|
|
24
|
+
],
|
|
25
|
+
{ softDeletes: true },
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
"product_variant",
|
|
29
|
+
"A size, color or other option of a product",
|
|
30
|
+
["product_id:cascade", "sku", "name", "price", "stock", "options?:json", "image"],
|
|
31
|
+
],
|
|
32
|
+
["product_tag", "Which tags each product has", ["product_id:cascade", "tag_id:cascade"], { pivot: true }],
|
|
33
|
+
[
|
|
34
|
+
"customer",
|
|
35
|
+
"A shopper",
|
|
36
|
+
["user_id:nullOnDelete", "person", "email:unique", "phone", "accepts_marketing:boolean:default(false)"],
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"cart",
|
|
40
|
+
"A shopping cart",
|
|
41
|
+
["customer_id:nullOnDelete", "session_id?:string(128):index", "currency", "status:in(active|converted|abandoned)"],
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"cart_item",
|
|
45
|
+
"A product in a cart",
|
|
46
|
+
["cart_id:cascade", "product_id:cascade", "product_variant_id:nullOnDelete", "quantity", "price"],
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
"coupon",
|
|
50
|
+
"A discount code",
|
|
51
|
+
[
|
|
52
|
+
"code",
|
|
53
|
+
"description",
|
|
54
|
+
"discount_type:in(percent|fixed)",
|
|
55
|
+
"value:money",
|
|
56
|
+
"min_order_amount?:money",
|
|
57
|
+
"max_uses?:integer",
|
|
58
|
+
"used_count:integer:default(0)",
|
|
59
|
+
"starts_at",
|
|
60
|
+
"ends_at",
|
|
61
|
+
"is_active",
|
|
62
|
+
],
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
"order",
|
|
66
|
+
"A placed order",
|
|
67
|
+
[
|
|
68
|
+
"customer_id:nullOnDelete",
|
|
69
|
+
"coupon_id:nullOnDelete",
|
|
70
|
+
"number:string(32):unique",
|
|
71
|
+
"status:in(pending|paid|processing|shipped|delivered|cancelled|refunded)",
|
|
72
|
+
"subtotal",
|
|
73
|
+
"discount",
|
|
74
|
+
"tax",
|
|
75
|
+
"shipping_total:money:default(0)",
|
|
76
|
+
"total",
|
|
77
|
+
"currency",
|
|
78
|
+
"shipping_address?:json",
|
|
79
|
+
"billing_address?:json",
|
|
80
|
+
"placed_at?:timestamp",
|
|
81
|
+
"notes",
|
|
82
|
+
],
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
"order_item",
|
|
86
|
+
"A line of an order; name, sku and price are copied from the product",
|
|
87
|
+
[
|
|
88
|
+
"order_id:cascade",
|
|
89
|
+
"product_id:nullOnDelete",
|
|
90
|
+
"product_variant_id:nullOnDelete",
|
|
91
|
+
"name",
|
|
92
|
+
"sku?:string(64)",
|
|
93
|
+
"quantity",
|
|
94
|
+
"price",
|
|
95
|
+
"discount",
|
|
96
|
+
"total",
|
|
97
|
+
],
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"payment",
|
|
101
|
+
"A payment for an order",
|
|
102
|
+
[
|
|
103
|
+
"order_id:cascade",
|
|
104
|
+
"method:string(32)",
|
|
105
|
+
"provider?:string(64)",
|
|
106
|
+
"transaction_id?:string(128):index",
|
|
107
|
+
"amount",
|
|
108
|
+
"currency",
|
|
109
|
+
"status:in(pending|completed|failed|refunded)",
|
|
110
|
+
"paid_at",
|
|
111
|
+
],
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"shipment",
|
|
115
|
+
"A shipment of an order",
|
|
116
|
+
[
|
|
117
|
+
"order_id:cascade",
|
|
118
|
+
"carrier?:string(64)",
|
|
119
|
+
"tracking_number?:string(128)",
|
|
120
|
+
"status:in(pending|shipped|in_transit|delivered|returned)",
|
|
121
|
+
"shipped_at?:timestamp",
|
|
122
|
+
"delivered_at?:timestamp",
|
|
123
|
+
],
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
"review",
|
|
127
|
+
"A customer's review of a product",
|
|
128
|
+
[
|
|
129
|
+
"product_id:cascade",
|
|
130
|
+
"customer_id:nullOnDelete",
|
|
131
|
+
"rating",
|
|
132
|
+
"title?:string",
|
|
133
|
+
"comment?:text",
|
|
134
|
+
"is_approved:boolean:default(false)",
|
|
135
|
+
],
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
"wishlist",
|
|
139
|
+
"A product a customer saved for later",
|
|
140
|
+
["customer_id:cascade", "product_id:cascade"],
|
|
141
|
+
{ unique: [["customer_id", "product_id"]] },
|
|
142
|
+
],
|
|
143
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const education: import("../template").Domain;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.education = void 0;
|
|
4
|
+
const template_1 = require("../template");
|
|
5
|
+
exports.education = (0, template_1.domain)("education", "Education", "Schools and courses: students, teachers, enrollments and grades", [
|
|
6
|
+
[
|
|
7
|
+
"teacher",
|
|
8
|
+
"A teacher or instructor",
|
|
9
|
+
[
|
|
10
|
+
"user_id:nullOnDelete",
|
|
11
|
+
"staff_number:string(32):unique",
|
|
12
|
+
"person",
|
|
13
|
+
"email:unique",
|
|
14
|
+
"phone",
|
|
15
|
+
"specialization?:string",
|
|
16
|
+
"hire_date?:date",
|
|
17
|
+
"is_active",
|
|
18
|
+
],
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"student",
|
|
22
|
+
"A student",
|
|
23
|
+
[
|
|
24
|
+
"user_id:nullOnDelete",
|
|
25
|
+
"student_number:string(32):unique",
|
|
26
|
+
"person",
|
|
27
|
+
"email:unique",
|
|
28
|
+
"phone",
|
|
29
|
+
"gender",
|
|
30
|
+
"date_of_birth",
|
|
31
|
+
"admission_date?:date",
|
|
32
|
+
"status:in(active|graduated|suspended|withdrawn)",
|
|
33
|
+
"address?",
|
|
34
|
+
],
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"course",
|
|
38
|
+
"A course or class",
|
|
39
|
+
[
|
|
40
|
+
"teacher_id:nullOnDelete",
|
|
41
|
+
"code",
|
|
42
|
+
"title",
|
|
43
|
+
"description",
|
|
44
|
+
"credits:integer:default(3)",
|
|
45
|
+
"level?:string(32)",
|
|
46
|
+
"capacity?:integer",
|
|
47
|
+
"price?",
|
|
48
|
+
"status:in(draft|published|archived)",
|
|
49
|
+
"starts_at",
|
|
50
|
+
"ends_at",
|
|
51
|
+
],
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"enrollment",
|
|
55
|
+
"A student taking a course",
|
|
56
|
+
[
|
|
57
|
+
"student_id:cascade",
|
|
58
|
+
"course_id:cascade",
|
|
59
|
+
"enrolled_at:timestamp",
|
|
60
|
+
"status:in(enrolled|completed|dropped|failed)",
|
|
61
|
+
"progress:integer:default(0)",
|
|
62
|
+
"completed_at?:timestamp",
|
|
63
|
+
],
|
|
64
|
+
{ unique: [["student_id", "course_id"]] },
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"grade",
|
|
68
|
+
"A score for one assessment of an enrollment",
|
|
69
|
+
[
|
|
70
|
+
"enrollment_id:cascade",
|
|
71
|
+
"assessment:string(128)",
|
|
72
|
+
"score:decimal(6,2)",
|
|
73
|
+
"max_score:decimal(6,2):default(100)",
|
|
74
|
+
"letter?:string(4)",
|
|
75
|
+
"weight?:percent",
|
|
76
|
+
"graded_at?:timestamp",
|
|
77
|
+
"remarks?:text",
|
|
78
|
+
],
|
|
79
|
+
],
|
|
80
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hr: import("../template").Domain;
|