( ctx context.Context, mod dagql.ObjectResult[*Module], objDef *ObjectTypeDef, metadata *Function, )
| 44 | } |
| 45 | |
| 46 | func NewModFunction( |
| 47 | ctx context.Context, |
| 48 | mod dagql.ObjectResult[*Module], |
| 49 | objDef *ObjectTypeDef, |
| 50 | metadata *Function, |
| 51 | ) (*ModuleFunction, error) { |
| 52 | modInst := NewUserMod(mod) |
| 53 | returnType, ok, err := modInst.ModTypeFor(ctx, metadata.ReturnType.Self(), true) |
| 54 | if err != nil { |
| 55 | return nil, fmt.Errorf("get mod type for function %q return type: %w", metadata.Name, err) |
| 56 | } |
| 57 | if !ok { |
| 58 | return nil, fmt.Errorf("find mod type for function %q return type: %q", metadata.Name, metadata.ReturnType.Self().ToType()) |
| 59 | } |
| 60 | |
| 61 | argTypes := make(map[string]*UserModFunctionArg, len(metadata.Args)) |
| 62 | for _, argMetadataRes := range metadata.Args { |
| 63 | argMetadata := argMetadataRes.Self() |
| 64 | argModType, ok, err := modInst.ModTypeFor(ctx, argMetadata.TypeDef.Self(), true) |
| 65 | if err != nil { |
| 66 | return nil, fmt.Errorf("get mod type for function %q arg %q type: %w", metadata.Name, argMetadata.Name, err) |
| 67 | } |
| 68 | if !ok { |
| 69 | return nil, fmt.Errorf("find mod type for function %q arg %q type: %q", metadata.Name, argMetadata.Name, argMetadata.TypeDef.Self().ToType()) |
| 70 | } |
| 71 | argTypes[argMetadata.Name] = &UserModFunctionArg{ |
| 72 | metadata: argMetadata, |
| 73 | modType: argModType, |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | return &ModuleFunction{ |
| 78 | mod: mod, |
| 79 | objDef: objDef, |
| 80 | metadata: metadata, |
| 81 | returnType: returnType, |
| 82 | args: argTypes, |
| 83 | }, nil |
| 84 | } |
| 85 | |
| 86 | type CallOpts struct { |
| 87 | Inputs []CallInput |
no test coverage detected