@alevnyacow/nzmt 0.0.22 → 0.0.24
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/bin/cli.js +8 -9
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -101,28 +101,29 @@ function generateStores(lowerCase, upperCase) {
|
|
|
101
101
|
fs.writeFileSync(path.resolve(folder, `${entityName}.store.ts`), [
|
|
102
102
|
"import z from 'zod'",
|
|
103
103
|
"import { Store } from '@alevnyacow/nzmt'",
|
|
104
|
+
config?.paths?.entities ? `import { ${upperCase} } from '${config?.paths?.entities.replace('./src', '@')}/${entityName}'` : undefined,
|
|
104
105
|
"",
|
|
105
106
|
`export const ${lowerCase}StoreMetadata = {`,
|
|
106
107
|
"\tmodels: {",
|
|
107
|
-
"\t\tlist: z.object({ }),",
|
|
108
|
-
"\t\tdetails: z.object({ }),",
|
|
108
|
+
config?.paths?.entities ? `\t\tlist: ${upperCase}.schema,` : "\t\tlist: z.object({ }),",
|
|
109
|
+
config?.paths?.entities ? `\t\tdetails: ${upperCase}.schema,` : "\t\tdetails: z.object({ }),",
|
|
109
110
|
"\t},",
|
|
110
111
|
"",
|
|
111
112
|
"\tsearchPayload: {",
|
|
112
|
-
"\t\tlist: z.object({ }),",
|
|
113
|
-
"\t\tspecific: z.object({ }),",
|
|
113
|
+
config?.paths?.entities ? `\t\tlist: ${upperCase}.schema.omit({ id: true }),` : "\t\tlist: z.object({ }),",
|
|
114
|
+
config?.paths?.entities ? `\t\tspecific: ${upperCase}.schema.pick({ id: true }),` : "\t\tspecific: z.object({ }),",
|
|
114
115
|
"\t},",
|
|
115
116
|
"",
|
|
116
117
|
"\tactionsPayload: {",
|
|
117
|
-
"\t\tcreate: z.object({ }),",
|
|
118
|
-
"\t\tupdate: z.object({ }),",
|
|
118
|
+
config?.paths?.entities ? `\t\tcreate: ${upperCase}.schema.omit({ id: true }),` : "\t\tcreate: z.object({ }),",
|
|
119
|
+
config?.paths?.entities ? `\t\tupdate: ${upperCase}.schema.omit({ id: true }),` : "\t\tupdate: z.object({ }),",
|
|
119
120
|
"\t},",
|
|
120
121
|
"",
|
|
121
122
|
`\tname: '${upperCase}Store'`,
|
|
122
123
|
"} satisfies Store.Metadata",
|
|
123
124
|
"",
|
|
124
125
|
`export type ${upperCase}Store = Store.Contract<typeof ${lowerCase}StoreMetadata>`
|
|
125
|
-
].join('\n'))
|
|
126
|
+
].filter(x => typeof x === 'string').join('\n'))
|
|
126
127
|
|
|
127
128
|
// RAM
|
|
128
129
|
|
|
@@ -254,10 +255,8 @@ function generateStores(lowerCase, upperCase) {
|
|
|
254
255
|
`export * from './${entityName}.store.prisma.ts'`,
|
|
255
256
|
`export * from './${entityName}.store.ram.ts'`
|
|
256
257
|
].join('\n'))
|
|
257
|
-
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
261
260
|
if (command === 'store') {
|
|
262
261
|
var [lowerCase, upperCase] = camelizeVariants(entityName)
|
|
263
262
|
generateStores(lowerCase, upperCase)
|