Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

compiler refactor #7

Open
tafseer-khan opened this issue Jul 26, 2023 · 0 comments
Open

compiler refactor #7

tafseer-khan opened this issue Jul 26, 2023 · 0 comments

Comments

@tafseer-khan
Copy link
Contributor

Add something along the lines of:

import (
	projectSchema "github.com/taubyte/go-project-schema/project"
)

type compileObject struct {
	Get     func(string) (local []string, global []string)
	Compile magicFunc
	Indexer indexerFunc
}

type app struct {
	id   string
	name string
}

type appContext struct {
	compiler compiler
	app      *app
}

type indexable interface {
	Index(f indexerFunc, appObject map[string]interface{}) error
}

type subCompiler interface {
	indexable
	// compilable
}

func (c compiler) Application(id, name string) indexable {
	return &appContext{
		compiler: c,
		app: &app{
			id:   id,
			name: name,
		},
	}
}

func (a *appContext) Index(f indexerFunc, appObject map[string]interface{}) error {
	return f(a.app.id, a.app.name, a.compiler.project, appObject, a.compiler.index)
}

func (c *compiler) Index(f indexerFunc, appObject map[string]interface{}) error {
	return f("", "", c.project, appObject, c.index)
}

type indexerFunc func(appID string, appName string, project projectSchema.Project, obj map[string]interface{}, urlIndex map[string]interface{}) error

type magicFunc func(name string, app string, p projectSchema.Project) (_id string, ReturnMap map[string]interface{}, err error)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant