/*
/*
 * Copyright (c) 2024 Augur AI, Inc.
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
 * If a copy of the MPL was not distributed with this file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 
 * Copyright (c) 2024 Augur AI, Inc.
 *
 * This file is licensed under the Augur AI Proprietary License.
 *
 * Attribution:
 * This work is based on code from https://github.com/hofstadter-io/hof, licensed under the Apache License 2.0.
 */

/*
This package manages the #hof: _ configuration
and the various @<hof>() attributes
*/
package hof

// #hof: ...
type Hof struct {
	// label from containing value in CUE
	Label string

	// path to containing value in CUE
	Path  string

	// Semantic hof datamodel api-version for compat
	APIVersion string

	// #hof: metadata: ...
	Metadata  Metadata

	// #hof: <feature>: ...
	// @<feature>(<name>) can be shorthand with no-name implying label?
	Datamodel Datamodel
	Gen       Gen
	Flow      Flow
	Chat      Chat

	// any extra config, set by users
	Extra map[string]any
}

// Common Metadata
type Metadata struct {
	// A unique ID as @id(string) generated by hof
	ID       string `json:"id"`

	// Given name for the value
	Name     string

	// arbitrary key=string data
	Labels map[string]string

	// CUE import path / package
	// only needs to be set if importing elsewhere
	Package string
}

// hof/datamodel configuration
type Datamodel struct {
	// Root for datamodel features
	// This acts as the entrypoint
	// the other fields determine behavior
	Root bool

	// index, pivot, level, hierachy, node?
	Node bool

	// Enable snapshots and history in .hof/dm/...
	History bool

	// create an Ordered<Label> list in parent data
	// where elements are from CUE iteration of fields
	Ordered bool

	// treat as a cue value
	// nesting stops here and the whole
	// value is tracked as a singular value
	// support incomplete values & schemas
	Cue     bool

	// Semantic version for value
	Version string

}

// hof/gen configuration 
// #hof: gen: "name"
// @gen(name)
type Gen struct {
	Root    bool
	Name    string
	Creator bool
}

/*
  hof/flow configuration
  this has more shorthands
	@flow() | @flow(name)
	@task(op) | @task(op,name)
*/
type Flow struct {
	Root bool
	Name string
	Task string

	// middleware related
	Pool  Pool
	Print Print
}

/*
	hof/flow configuration
	@pool(<name>[,num])
  @pool(name,3) // create pool of 3
  @pool(name)   // take from pool
*/
type Pool struct {
	Name   string
	Number int

	Make   bool
	Take   bool
}

type Print struct {
	Level   int
	Before  bool
	Message string
	Path    string
}

/*
  hof/chat configuration
*/
type Chat struct {
	Root  bool
	Name  string
	Extra string
}
