File tree Expand file tree Collapse file tree 6 files changed +51
-2
lines changed Expand file tree Collapse file tree 6 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -15,4 +15,6 @@ module default {
15
15
)
16
16
)
17
17
);
18
+
19
+ scalar type RichText extending json ;
18
20
}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ module default {
37
37
rewrite insert , update using (.endDate if .status = Engagement:: Status.InDevelopment else .initialEndDate);
38
38
};
39
39
40
- description: json ;
40
+ description: RichText ;
41
41
}
42
42
43
43
type LanguageEngagement extending Engagement {
Original file line number Diff line number Diff line change
1
+ CREATE MIGRATION m1wmrb3grzq5y55y5c447noyxdw26fcpatlu46n5f6ffh572opam6a
2
+ ONTO m1r3t2ku2jysgjliaq54y7saj4tuxecilnajoxgwa2blsb3p64svzq
3
+ {
4
+ CREATE SCALAR TYPE default :: RichText EXTENDING std :: json ;
5
+ ALTER TYPE default :: Engagement {
6
+ ALTER PROPERTY description {
7
+ SET TYPE default :: RichText;
8
+ };
9
+ };
10
+ ALTER TYPE default :: Post {
11
+ ALTER PROPERTY body {
12
+ SET TYPE default :: RichText;
13
+ };
14
+ };
15
+ };
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ module default {
14
14
15
15
required type : Post:: Type;
16
16
required shareability: Post:: Shareability;
17
- required body: json ;
17
+ required body: RichText ;
18
18
19
19
single property sensitivity := .container[is Project:: ContextAware].sensitivity;
20
20
single property isMember := .container[is Project:: ContextAware].isMember;
Original file line number Diff line number Diff line change
1
+ import { RichTextCodec } from './rich-text.codec' ;
1
2
import { LuxonCalendarDateCodec , LuxonDateTimeCodec } from './temporal.codec' ;
2
3
import { ScalarCodecClass } from './type.util' ;
3
4
import { OurUUIDCodec } from './uuid.codec' ;
@@ -9,4 +10,5 @@ export const codecs: readonly ScalarCodecClass[] = [
9
10
OurUUIDCodec ,
10
11
LuxonDateTimeCodec ,
11
12
LuxonCalendarDateCodec ,
13
+ RichTextCodec ,
12
14
] ;
Original file line number Diff line number Diff line change
1
+ import { InvalidArgumentError } from 'edgedb' ;
2
+ import { JSONCodec } from 'edgedb/dist/codecs/json.js' ;
3
+ import { ReadBuffer , WriteBuffer } from 'edgedb/dist/primitives/buffer.js' ;
4
+ import { RichTextDocument } from '~/common/rich-text.scalar' ;
5
+ import { ScalarInfo } from './type.util' ;
6
+
7
+ export class RichTextCodec extends JSONCodec {
8
+ static info : ScalarInfo = {
9
+ module : 'default' ,
10
+ type : 'RichText' ,
11
+ ts : RichTextDocument . name ,
12
+ path : '~/common' ,
13
+ } ;
14
+ tsType = RichTextDocument . name ;
15
+ importedType = true ;
16
+
17
+ encode ( buf : WriteBuffer , object : unknown ) {
18
+ if ( ! ( object instanceof RichTextDocument ) ) {
19
+ throw new InvalidArgumentError (
20
+ `a RichTextDocument was expected, got "${ String ( object ) } "` ,
21
+ ) ;
22
+ }
23
+ super . encode ( buf , object ) ;
24
+ }
25
+
26
+ decode ( buf : ReadBuffer ) : RichTextDocument {
27
+ const doc = super . decode ( buf ) ;
28
+ return RichTextDocument . from ( doc ) ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments