-
Notifications
You must be signed in to change notification settings - Fork 736
/
Copy pathschemas.js
155 lines (127 loc) · 4.49 KB
/
schemas.js
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import utils from "@/utils/index.js";
import yaml from "yaml";
async function dbSchemasGenerate({context,data}) {
/* ;; DB:SCHEMAS::GENERATE
make {DRD} -> db {schemas} ;; specify that for auth tables, password not hashed ! for mockup
out : ["db"]
*/
const { pm } = data
const { prd, frd, fjmd, drd } = pm
// const {text , attachments} = details
const messages = [
{
"role": "system",
"content": `- you are a genius Product Manager and DB designer
- your role is to make the database schemas for the provided app in development's MVP
- your DB schemas should be comprehensive and cover EVERYTHING required by the app MVP, and nothing more - no shiny secondary features, but nothing less than 100% comprehensive for every single expected functionality in production
- your answer should be in ~SQL-like format meant for Postgres, in this format :
\`\`\`yaml
[TableName]:
- name: [columnName]
type: [ js-parseable types like String, Number, Boolean ...]
unique: [true || false]
nullable: [true || false]
default?: [...]
primaryKey?: [...]
foreignKey?: [{table : [...] , column : []}]
- [...]
[...]
\`\`\`
- use a \`uid\` approach whenever possible rather than incremented Ids ; and make them normal strings !
very important :
> avoid any postgres-hardcoded methods ie. for generating UIDs etc... ; logic for that stuff will come from nodejs functions !
> do not generate UUIDs inside postgres ! that stuff will come from nodejs functions !
- your current role is to make use of the provided task and analysis in order to design a perfect DB schemas for the app's MVP
try to outdo yourself by thinking of what might be omitted,
and design super critically in order to make a comprehensive work for this app's MVP DB schemas
---
> note : if auth functionalities are present, use an architecture that will be compatible with a simple jwt auth system, which is very simply user and/or email strings(s) and password hash string !
> very important : for the current purpose of the DB Schemas design, the environment will be a mock prototype environment
do not bother with security details etc, have the DB schema requirements for the mock prototype
> if some ie. media entry types requires some path (ie. images, media, ...), assume usage of urls not local
> aim for it to work on any default light postgres without any extra configs or plugins !
---
use snake_case for any naming you do
---
give a final, super comprehensive answer in strict, parseable YAML format,
which will be perfectly ready for production and pushed to prod to thousands of users instantly and work flawlessly
your reply should start with : "\`\`\`yaml" and end with "\`\`\`"
you will be tipped $99999 + major company shares for nailing it perfectly off the bat
you are a genius`
},
{
"role": "user",
"content": `\`\`\`PRD:product-requirements-document
${prd}
\`\`\``
},
/*{
"role": "user",
"content": `\`\`\`FRD:features-requirements-document
${yaml.stringify(frd)}
\`\`\``
},
{
"role": "user",
"content": `\`\`\`FJMD:features-journeys-map-document
${yaml.stringify(fjmd)}
\`\`\``
},*/
{
"role": "user",
"content": `\`\`\`DRD:database-requirements-document
${drd}
\`\`\``
},
{
"role": "user",
"content": `Design the DB schemas in a comprehensive answer
it is expected to be very comprehensive and detailed ; in a VALID PARSEABLE YAML format
very important :
- avoid any postgres-hardcoded methods ie. for generating UIDs etc... make them normal strings
- logic for that stuff will come from nodejs functions !
- only use basic primitives like numbers, strings, json, etc ... no uuid types or special types etc
- very important : only use basic primitives like numbers, strings, json, etc ... no uuid types or any special types etc ! very basic primitives only !
you're a genius`
},
]
const schemas = (
await context.run({
id: "op:LLM::GEN",
context: {
...context, // {streams , project}
operation: {
key: "db.schemas",
meta: {
name: "DB Schemas",
desc: "db tables schemas",
},
},
},
data: {
model: process.env.LOCAL_INFERENCE_MODEL,//`gpt-4o`,
messages,
preparser: `backticks`,
parser: `yaml`,
}
})
).generated
await context.run({
id: "op:PROJECT::STATE:UPDATE",
context,
data: {
operation: {
id: "db:schemas",
},
type: `end`,
content: {
key: "db.schemas",
data: schemas,
},
}
})
return { db : { schemas } }
}
export default {
"DB:SCHEMAS::GENERATE": dbSchemasGenerate,
}