@@ -16,7 +16,9 @@ import type {
1616 ExpressionPatternOperation ,
1717 GraphNode ,
1818 GraphRef ,
19+ GraphRefAll ,
1920 GraphRefDefault ,
21+ GraphRefNamed ,
2022 GraphRefSpecific ,
2123 Ordering ,
2224 Path ,
@@ -28,10 +30,13 @@ import type {
2830 PatternBgp ,
2931 PatternBind ,
3032 PatternFilter ,
33+ PatternGraph ,
3134 PatternGroup ,
3235 PatternMinus ,
36+ PatternOptional ,
3337 PatternService ,
3438 PatternUnion ,
39+ PatternValues ,
3540 PropertyPathChain ,
3641 Quads ,
3742 Query ,
@@ -62,6 +67,7 @@ import type {
6267 UpdateOperationLoad ,
6368 UpdateOperationModify ,
6469 UpdateOperationMove ,
70+ ValuePatternRow ,
6571 Wildcard ,
6672} from './RoundTripTypes' ;
6773
@@ -78,7 +84,7 @@ export class TraqulaFactory extends CoreFactory {
7884 } ;
7985 }
8086
81- public baseDecl ( loc : SourceLocation , img1 : string , value : TermIriFull ) : ContextDefinitionBaseDecl {
87+ public baseDecl ( loc : SourceLocation , value : TermIriFull ) : ContextDefinitionBaseDecl {
8288 return {
8389 type : 'contextDef' ,
8490 contextType : 'base' ,
@@ -186,6 +192,22 @@ export class TraqulaFactory extends CoreFactory {
186192 } ;
187193 }
188194
195+ public expressionFunctionCall < Args extends Expression [ ] > (
196+ functionOp : TermIri ,
197+ args : Args ,
198+ distinct : boolean ,
199+ loc : SourceLocation ,
200+ ) : ExpressionFunctionCall & { args : Args } {
201+ return {
202+ type : 'expression' ,
203+ expressionType : 'functionCall' ,
204+ function : functionOp ,
205+ args,
206+ distinct,
207+ loc,
208+ } ;
209+ }
210+
189211 public expressionPatternOperation < Args extends Pattern [ ] > (
190212 operator : string ,
191213 args : Args ,
@@ -231,6 +253,22 @@ export class TraqulaFactory extends CoreFactory {
231253 return { type : 'pattern' , patternType : 'bgp' , triples, loc } ;
232254 }
233255
256+ public patternGroup ( patterns : Pattern [ ] , loc : SourceLocation ) : PatternGroup {
257+ return { type : 'pattern' , patternType : 'group' , patterns, loc } ;
258+ }
259+
260+ public patternGraph ( name : TermIri | TermVariable , patterns : Pattern [ ] , loc : SourceLocation ) : PatternGraph {
261+ return { type : 'pattern' , patternType : 'graph' , name, patterns, loc } ;
262+ }
263+
264+ public patternOptional ( patterns : Pattern [ ] , loc : SourceLocation ) : PatternOptional {
265+ return { type : 'pattern' , patternType : 'optional' , patterns, loc } ;
266+ }
267+
268+ public patternValues ( values : ValuePatternRow [ ] , loc : SourceLocation ) : PatternValues {
269+ return { type : 'pattern' , patternType : 'values' , values, loc } ;
270+ }
271+
234272 public patternFilter ( expression : Expression , loc : SourceLocation ) : PatternFilter {
235273 return {
236274 type : 'pattern' ,
@@ -288,6 +326,39 @@ export class TraqulaFactory extends CoreFactory {
288326 } ;
289327 }
290328
329+ public graphRefSpecific ( graph : TermIri , loc : SourceLocation ) : GraphRefSpecific {
330+ return {
331+ type : 'graphRef' ,
332+ graphRefType : 'specific' ,
333+ graph,
334+ loc,
335+ } ;
336+ }
337+
338+ public graphRefDefault ( loc : SourceLocation ) : GraphRefDefault {
339+ return {
340+ type : 'graphRef' ,
341+ graphRefType : 'default' ,
342+ loc,
343+ } ;
344+ }
345+
346+ public graphRefNamed ( loc : SourceLocation ) : GraphRefNamed {
347+ return {
348+ type : 'graphRef' ,
349+ graphRefType : 'named' ,
350+ loc,
351+ } ;
352+ }
353+
354+ public graphRefAll ( loc : SourceLocation ) : GraphRefAll {
355+ return {
356+ type : 'graphRef' ,
357+ graphRefType : 'all' ,
358+ loc,
359+ } ;
360+ }
361+
291362 public deGroupSingle ( group : PatternGroup & Pattern ) : Pattern {
292363 if ( group . patterns . length === 1 ) {
293364 return group . patterns [ 0 ] ;
@@ -504,12 +575,22 @@ export class TraqulaFactory extends CoreFactory {
504575 } ;
505576 }
506577
507- private updateOperationClearDrop < T extends 'clear' | 'drop' | 'create' , Dest extends GraphRef > (
508- operationType : T ,
578+ public updateOperationClearDrop ( operationType : 'clear' , silent : boolean , destination : GraphRef , loc : SourceLocation ) :
579+ UpdateOperationClear ;
580+ public updateOperationClearDrop ( operationType : 'drop' , silent : boolean , destination : GraphRef , loc : SourceLocation ) :
581+ UpdateOperationDrop ;
582+ public updateOperationClearDrop (
583+ operationType : 'clear' | 'drop' ,
509584 silent : boolean ,
510- destination : Dest ,
585+ destination : GraphRef ,
586+ loc : SourceLocation
587+ ) : UpdateOperationClear | UpdateOperationDrop ;
588+ public updateOperationClearDrop (
589+ operationType : 'clear' | 'drop' ,
590+ silent : boolean ,
591+ destination : GraphRef ,
511592 loc : SourceLocation ,
512- ) : Omit < UpdateOperationDrop , 'destination' | 'operationType' > & { operationType : T ; destination : Dest } {
593+ ) : UpdateOperationClear | UpdateOperationDrop {
513594 return {
514595 type : 'updateOperation' ,
515596 operationType,
@@ -540,16 +621,50 @@ export class TraqulaFactory extends CoreFactory {
540621 silent : boolean ,
541622 loc : SourceLocation ,
542623 ) : UpdateOperationCreate {
543- return this . updateOperationClearDrop ( 'create' , silent , destination , loc ) ;
624+ return {
625+ type : 'updateOperation' ,
626+ operationType : 'create' ,
627+ silent,
628+ destination,
629+ loc,
630+ } ;
544631 }
545632
546- private updateOperationAddMoveCopy < T extends 'add' | 'move' | 'copy' > (
547- operationType : T ,
633+ public updateOperationAddMoveCopy (
634+ operationType : 'add' ,
635+ source : GraphRefDefault | GraphRefSpecific ,
636+ destination : GraphRefDefault | GraphRefSpecific ,
637+ silent : boolean ,
638+ loc : SourceLocation ,
639+ ) : UpdateOperationAdd ;
640+ public updateOperationAddMoveCopy (
641+ operationType : 'move' ,
642+ source : GraphRefDefault | GraphRefSpecific ,
643+ destination : GraphRefDefault | GraphRefSpecific ,
644+ silent : boolean ,
645+ loc : SourceLocation ,
646+ ) : UpdateOperationMove ;
647+ public updateOperationAddMoveCopy (
648+ operationType : 'copy' ,
649+ source : GraphRefDefault | GraphRefSpecific ,
650+ destination : GraphRefDefault | GraphRefSpecific ,
651+ silent : boolean ,
652+ loc : SourceLocation ,
653+ ) : UpdateOperationCopy ;
654+ public updateOperationAddMoveCopy (
655+ operationType : 'add' | 'move' | 'copy' ,
656+ source : GraphRefDefault | GraphRefSpecific ,
657+ destination : GraphRefDefault | GraphRefSpecific ,
658+ silent : boolean ,
659+ loc : SourceLocation ,
660+ ) : UpdateOperationAdd | UpdateOperationMove | UpdateOperationCopy ;
661+ public updateOperationAddMoveCopy (
662+ operationType : 'add' | 'move' | 'copy' ,
548663 source : GraphRefDefault | GraphRefSpecific ,
549664 destination : GraphRefDefault | GraphRefSpecific ,
550665 silent : boolean ,
551666 loc : SourceLocation ,
552- ) : Omit < UpdateOperationAdd , 'operationType' > & { operationType : T } {
667+ ) : UpdateOperationAdd | UpdateOperationMove | UpdateOperationCopy {
553668 return {
554669 type : 'updateOperation' ,
555670 operationType,
@@ -587,39 +702,55 @@ export class TraqulaFactory extends CoreFactory {
587702 return this . updateOperationAddMoveCopy ( 'copy' , source , destination , silent , loc ) ;
588703 }
589704
590- private updateOperationInsertDeleteDelWhere < T extends 'insertdata' | 'deletedata' | 'deletewhere' > (
591- operationType : T ,
705+ public updateOperationInsDelDataWhere ( operationType : 'insertdata' , data : Quads [ ] , loc : SourceLocation ) :
706+ UpdateOperationInsertData ;
707+ public updateOperationInsDelDataWhere ( operationType : 'deletedata' , data : Quads [ ] , loc : SourceLocation ) :
708+ UpdateOperationDeleteData ;
709+ public updateOperationInsDelDataWhere ( operationType : 'deletewhere' , data : Quads [ ] , loc : SourceLocation ) :
710+ UpdateOperationDeleteWhere ;
711+ public updateOperationInsDelDataWhere (
712+ operationType : 'insertdata' | 'deletedata' | 'deletewhere' ,
592713 data : Quads [ ] ,
593714 loc : SourceLocation ,
594- ) : Omit < UpdateOperationInsertData , 'operationType' > & { operationType : T } {
595- return { type : 'updateOperation' , operationType, data, loc } ;
715+ ) : UpdateOperationInsertData | UpdateOperationDeleteData | UpdateOperationDeleteWhere ;
716+ public updateOperationInsDelDataWhere (
717+ operationType : 'insertdata' | 'deletedata' | 'deletewhere' ,
718+ data : Quads [ ] ,
719+ loc : SourceLocation ,
720+ ) : UpdateOperationInsertData | UpdateOperationDeleteData | UpdateOperationDeleteWhere {
721+ return {
722+ type : 'updateOperation' ,
723+ operationType,
724+ data,
725+ loc,
726+ } ;
596727 }
597728
598729 public updateOperationInsertData ( data : Quads [ ] , loc : SourceLocation ) : UpdateOperationInsertData {
599- return this . updateOperationInsertDeleteDelWhere ( 'insertdata' , data , loc ) ;
730+ return this . updateOperationInsDelDataWhere ( 'insertdata' , data , loc ) ;
600731 }
601732
602733 public updateOperationDeleteData ( data : Quads [ ] , loc : SourceLocation ) : UpdateOperationDeleteData {
603- return this . updateOperationInsertDeleteDelWhere ( 'deletedata' , data , loc ) ;
734+ return this . updateOperationInsDelDataWhere ( 'deletedata' , data , loc ) ;
604735 }
605736
606737 public updateOperationDeleteWhere ( data : Quads [ ] , loc : SourceLocation ) : UpdateOperationDeleteWhere {
607- return this . updateOperationInsertDeleteDelWhere ( 'deletewhere' , data , loc ) ;
738+ return this . updateOperationInsDelDataWhere ( 'deletewhere' , data , loc ) ;
608739 }
609740
610741 public updateOperationModify (
611742 loc : SourceLocation ,
612- insert : Quads [ ] ,
613- del : Quads [ ] ,
743+ insert : Quads [ ] | undefined ,
744+ del : Quads [ ] | undefined ,
614745 where : Pattern [ ] ,
615746 from : DatasetClauses ,
616747 graph ?: TermIri | undefined ,
617748 ) : UpdateOperationModify {
618749 return {
619750 type : 'updateOperation' ,
620751 operationType : 'modify' ,
621- insert,
622- delete : del ,
752+ insert : insert ?? [ ] ,
753+ delete : del ?? [ ] ,
623754 graph,
624755 where,
625756 from,
0 commit comments