File tree 4 files changed +36
-7
lines changed
app/components/pubs/PubEditor
packages/contracts/src/resources
4 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ describe("createPubRecursive", () => {
86
86
[ `${ community . slug } :title` ] : "test title" ,
87
87
} ,
88
88
} ,
89
+ formSlug : pubTypes [ "Minimal Pub" ] . defaultForm . slug ,
89
90
trx,
90
91
} ) ;
91
92
expect ( result ) . toMatchObject ( expected ) ;
@@ -124,7 +125,7 @@ describe("updatePub", () => {
124
125
} ,
125
126
] ) ( "$name" , async ( { loginUser, userRole, expected } ) => {
126
127
const { seedCommunity } = await import ( "~/prisma/seed/seedCommunity" ) ;
127
- const { community, pubs, users } = await seedCommunity ( {
128
+ const { community, pubs, users, pubTypes } = await seedCommunity ( {
128
129
community : {
129
130
name : "test" ,
130
131
slug : "test-actions-create-pub" ,
@@ -176,6 +177,7 @@ describe("updatePub", () => {
176
177
} ,
177
178
continueOnValidationError : false ,
178
179
deleted : [ ] ,
180
+ formSlug : pubTypes [ "Minimal Pub" ] . defaultForm . slug ,
179
181
} ) ;
180
182
expect ( result ) . toMatchObject ( expected ) ;
181
183
} ) ;
Original file line number Diff line number Diff line change @@ -20,8 +20,29 @@ Pg.types.setTypeParser(int8TypeId, (val: any) => {
20
20
21
21
const kyselyLogger =
22
22
env . LOG_LEVEL === "debug" && env . KYSELY_DEBUG === "true"
23
- ? ( { query : { sql, parameters } , ...event } : LogEvent ) =>
24
- logger . debug ( { event } , "Kysely query:\n%s; --Parameters: %o" , sql , parameters )
23
+ ? ( { query : { sql, parameters } , ...event } : LogEvent ) => {
24
+ const params = parameters . map ( ( p ) => {
25
+ if ( p === null ) {
26
+ return "null" ;
27
+ }
28
+ if ( p instanceof Date ) {
29
+ return `'${ p . toISOString ( ) } '` ;
30
+ }
31
+ if ( typeof p === "object" ) {
32
+ const stringified = `'${ JSON . stringify ( p ) } '` ;
33
+ if ( Array . isArray ( p ) ) {
34
+ return "ARRAY " + stringified ;
35
+ }
36
+ return stringified ;
37
+ }
38
+ return `'${ p } '` ;
39
+ } ) ;
40
+ logger . debug (
41
+ { event } ,
42
+ "Kysely query:\n%s" ,
43
+ sql . replaceAll ( / \$ [ 0 - 9 ] + / g, ( ) => params . shift ( ) ! )
44
+ ) ;
45
+ }
25
46
: undefined ;
26
47
27
48
const tablesWithUpdateAt = databaseTables
Original file line number Diff line number Diff line change @@ -443,7 +443,10 @@ type PubFieldsByName<PF> = {
443
443
} ;
444
444
445
445
type PubTypesByName < PT , PF > = {
446
- [ K in keyof PT ] : Omit < PubTypes , "name" > & { name : K } & { fields : PubFieldsByName < PF > } ;
446
+ [ K in keyof PT ] : Omit < PubTypes , "name" > & { name : K } & {
447
+ fields : PubFieldsByName < PF > ;
448
+ defaultForm : { slug : string } ;
449
+ } ;
447
450
} ;
448
451
449
452
type UsersBySlug < U extends UsersInitializer > = {
@@ -841,6 +844,9 @@ export async function seedCommunity<
841
844
] as const ;
842
845
} )
843
846
) ,
847
+ defaultForm : {
848
+ slug : `${ slugifyString ( pubType . name ) } -default-editor` ,
849
+ } ,
844
850
} ,
845
851
] )
846
852
) as PubTypesByName < PT , PF > ;
@@ -850,11 +856,11 @@ export async function seedCommunity<
850
856
insertForm (
851
857
{ ...pubType , fields : Object . values ( pubType . fields ) } ,
852
858
`${ pubType . name } Editor (Default)` ,
853
- ` ${ slugifyString ( pubType . name ) } -default-editor` ,
859
+ pubType . defaultForm . slug ,
854
860
communityId ,
855
861
true ,
856
862
trx
857
- ) . execute ( )
863
+ ) . executeTakeFirst ( )
858
864
)
859
865
) ;
860
866
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export type CreatePubRequestBody = z.infer<typeof CreatePubRequestBody>;
78
78
79
79
// TODO: there has to be a better way to allow the API requests to include nulls in json fields
80
80
export const CreatePubRequestBodyWithNulls = commonPubFields . extend ( {
81
- id : z . string ( ) . optional ( ) ,
81
+ id : pubsIdSchema . optional ( ) ,
82
82
values : z . record (
83
83
z . union ( [
84
84
jsonSchema . or ( z . date ( ) ) ,
You can’t perform that action at this time.
0 commit comments