actions

package
v0.0.0-...-646b7d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

package Actions was created to house all Action code. Actions are code which is run as part of a Bot. A Bot is triggered usually at the loading time of a Task, when a change is made to the Task's data, or when the Task is "Done".

Anyone ought to be able to write code which is used as an Action. The whole point of Actions is that they are a way to infinitely extend the functionality of Polyapp. You can use Actions to validate data, calculate values based on values currently present on screen, respond to a button press, or even get information from a third party and store it in the form. You receive the current state of the data on a user's screen, information about the request and response, and this package also includes tools to translate the murky Data into regular Go structs.

Actions are configurable by setting BotStaticData when designing a Task.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionAPICall

func ActionAPICall(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionAPICall This Task helps you integrate a Task with an external API. To use it, first use this Task's "Configure API Call" Subtask to set up your call to the external API and verify that you can call it successfully.

Then use the listed "Bot ID To Use" and "Bot Static Data To Use" in the Task with which you wish to integrate.

func ActionBrowserActionOpenURL

func ActionBrowserActionOpenURL(d *common.Data, response *common.POSTResponse) error

ActionBrowserActionOpenURL opens a new tab with the URL field.

func ActionConfigureAPICall

func ActionConfigureAPICall(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionConfigureAPICall. Integrating with an external API requires a few steps: (1) Call the API, perhaps with specific headers or authentication information; (2) Store the API response; (3) Do something with the API response. This Task allows you to configure an API call.

This func may verify the data and can return a validation error. TODO do this.

If "Test" (bool) is set to true, then set it to false and make an API request based on the configuration provided. Refresh the page when done.

func ActionCopyTaskByDataID

func ActionCopyTaskByDataID(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCopyTaskByDataID copies a Data and its children. It also assumes that Data works with ActionEditTask and it generates a new Task, Schema, and UX for that Data.

func ActionCreateChartFromData

func ActionCreateChartFromData(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCreateChartFromData creates a new Chart which reflects information available in Data.

func ActionCreateCover

func ActionCreateCover(data *common.Data, response *common.POSTResponse) error

ActionCreateCover creates a Cover, which is a UI element comprising an Image and some text overlaying that image. This is based on the zEKYTPojAIxhu6K2hedp Schema. Run this continuously.

func ActionCreateDashboard

func ActionCreateDashboard(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCreateDashboard creates a Dashboard for use as a home page or other way to reach other pages in Polyapp.

func ActionCreateSurvey

func ActionCreateSurvey(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCreateSurvey Surveys are public or private forms whose goals are different from regular Tasks in a few key ways: - Accessed via a link: Respondents should be able to click a link to start the survey. - Users may all be new to Polyapp: Public - facing surveys shouldn't require people to sign in or be issued security credentials to access the survey unless the survey creator desires that functionality. - Branded: Respondents who click on a survey link expect to see something to indicate the next page is owned by the company who sent them the survey. This might include a specific theme, brand colors, and/or a logo. - Users are less incentivized to finish: Almost all surveys are for the benefit of the person issuing the survey, whereas Polyapp's Tasks assume you intrinsically want to finish the Task because it is part of your job. We need to provide them with incentives to start the survey, incentivize them to keep going, and give them an appropriate reward when they are done. - Confidential: Each survey response should be hidden from the other people taking the survey. Polyapp is designed to grant access to all results of a Task, so security around surveys needs to be tightened.

This Task is an excellent way to create such surveys.

func ActionCreateTableFromData

func ActionCreateTableFromData(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCreateTableFromData creates a table containing all of the Data in a Schema and stores it into the Table HTML field.

func ActionCreateTheme

func ActionCreateTheme(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionCreateTheme A theme stylizes Polyapp with your preferred colors, lets you set a logo into the address bar, and generally lets you control the look and feel of the application.

func ActionDeleteAdmin

func ActionDeleteAdmin(data *common.Data) error

ActionDeleteAdmin deletes a document from a non-Data collection from the Database. After deletion there is no way to recover the deleted document.

Warning: there is no access control which prevents someone from deleting documents from every collection.

func ActionDeleteData

func ActionDeleteData(data *common.Data, request *common.POSTRequest) error

ActionDeleteData deletes a Data document from the database. After deletion there is no way to recover the deleted data. This will also delete any child documents (documents referenced by this document). For instance, if you have an Edit Task Data document and you delete it, it would delete itself and all of the Fields documents and all of the Subtasks documents associated with the Edit Task Data document.

func ActionDoneTracking

func ActionDoneTracking(data *common.Data, request *common.POSTRequest) error

ActionDoneTracking is triggered when a Task is Done.

func ActionEditAWebsite

func ActionEditAWebsite(data *common.Data, request *common.POSTRequest) error

ActionEditAWebsite interprets the contents of this Task as a website builder and overwrites the existing website with this Task's data.

This Action replaces "ActionEditWebsiteContent". TODO try to eliminate a lot of this code by using func DataIntoStructure

func ActionEditChartCreate

func ActionEditChartCreate(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionEditChartCreate creates a new Chart when you are done editing the existing chart.

func ActionEditChartLoad

func ActionEditChartLoad(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionEditChartLoad makes sure each field has one or more filters attached and that those filters make sense. It also populates the list of possible Field Names.

func ActionEditChartPreview

func ActionEditChartPreview(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionEditChartPreview creates a preview of a chart using only the first 100 data points in a Schema. It then inserts that chart into the DOM on the right hand side of the page (bottom on mobile).

func ActionEditRole

func ActionEditRole(d *common.Data) error

ActionEditRole edits a Role document in the database.

Note: It would be nice if this could be replaced with a generic function.

func ActionEditTask

func ActionEditTask(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionEditTask is, as of September 1, 2020, the best way to create an Interactive Section or other Task. It is used to create all other Task, Schema, and UX documents. It is also used to edit the Task which edits Tasks.

Warnings and caveats: 1. Adding a field to a Schema is easy. Modifying an existing field's name is not. When you modify a field's name you are making all previous Data stored using that field's name as the key in the JSON in the Data collection in the Database incompatible since that Data will now not have a key in Schema. Ex.: Field "A" renamed to field "B". When you open the Data to edit it, it will throw an error because field "A" was present in the Data, but it is not present in the new Schema. 2. Removing an existing field's name is not easy for the same reason as (1). If there is a Data document and you go back to read or edit it, the Schema will not contain the field and it will throw an error. TODO implement convert in integrity/convert and the NextSchemaID field in type Schema.

Data documents are never deleted when the schema changes. So when you export to JSON a Schema with fields "A" and "B" and then update it to only contain Field "A", the JSON document containing "B" will still be there on the server. TODO we want to delete this document in all of the databases (local JSON files & Firestore) when this occurs but this hasn't been implemented.

Schema: mywkQhPF1qIT979zOn6J

func ActionEditUser

func ActionEditUser(d *common.Data) error

ActionEditUser edits a User document in the database.

Note: It would be nice if this could be replaced with a generic function.

func ActionEditWebsiteContent

func ActionEditWebsiteContent(data *common.Data, request *common.POSTRequest) error

ActionEditWebsiteContent interprets the contents of this Task as a website builder and overwrite the existing website with this Task's data.

Unlike most bots created so far, it does not assume you are using a particular schema ID / schema.

func ActionExportApp

func ActionExportApp(data *common.Data, response *common.POSTResponse) error

ExportApp exports Data used to create Tasks, Schemas, UXs, Bots, and Actions. This Task does NOT export any Data. This Task does NOT export the underlying Task, Bot, etc. documents. After export, the "App" can be imported into another instance of Polyapp using Import App.

func ActionExportData

func ActionExportData(data *common.Data, response *common.POSTResponse) error

ActionExportData exports all the data from one of Polyapp's Schemas into one of several different supported formats.

func ActionExternalAPIEgressData

func ActionExternalAPIEgressData(data *common.Data, request *common.POSTRequest, response *common.POSTResponse,
	botStaticData map[string]string) error

ActionExternalAPIEgressData calls an external API and puts the response into the current Task. Configuration is provided by Bot Static Data pointing to an "API Call"'s Bot Static Data To Use.

func ActionExternalAPIIngressData

func ActionExternalAPIIngressData(data *common.Data, request *common.POSTRequest, response *common.POSTResponse,
	botStaticData map[string]string) error

ActionExternalAPIIngressData calls an external API and puts the response into the current Task. Configuration is provided by Bot Static Data pointing to an "API Call"'s Bot Static Data To Use.

func ActionHTTPSCall

func ActionHTTPSCall(currentData *common.Data, request *common.POSTRequest, response *common.POSTResponse, botStaticData map[string]string) error

ActionHTTPSCall makes a call for an HTTP verb to a configurable URL. The request location is specified by the HTTPSCall bot static data. The body of the request conforms to the type HTTPSCall.

Supported HTTP verbs: GET, HEAD, POST, PUT, PATCH, DELETE

Example configuration in BotStaticData: HTTPSCall GET https://example.com?aParam=value Example 2: HTTPSCall POST https://example.com?aParam=value

You can also configure acceptable response codes. If you do not set this, it is set to []int{200}

Example configuration: HTTPSCallAcceptStatusCodes 200,404 Example Configuration: HTTPSCallAcceptStatusCodes 200

func ActionHomeLoad

func ActionHomeLoad(request *common.POSTRequest, response *common.POSTResponse) error

ActionHomeLoad is triggered when the Home Page is loaded. It adds some static content to the page. This is usually the wrong approach to use when adding static content to Polyapp, but it is also the most flexible since it does not require any components and lets you directly put information into the DOM.

func ActionImmediateSimpleConversion

func ActionImmediateSimpleConversion(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionImmediateSimpleConversion An Immediate Conversion goes through all Data associated with a Task and immediately runs the conversion on each Data when you click Done. A Simple Conversion takes the value in one field and places it into another field.

func ActionImportApp

func ActionImportApp(data *common.Data, request *common.POSTRequest) error

ImportApp import Data used to create Tasks, Schemas, UXs, Bots, and Actions then run EditTask's Action and EditBot's Action to create the Task, Bot, etc. documents. It is assumed that the documents were exported using "Export App".

func ActionImportData

func ActionImportData(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionImportData is used by the Import Task to help import Data into Polyapp.

func ActionImportDataAndCreateTask

func ActionImportDataAndCreateTask(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionImportDataAndCreateTask imports data from the specified source and examines it to determine a schema for the Data. Once a schema is determined, a new entry in Edit Task is created. This Edit Task is then used to create a new Task, Schema, and UX. The final step is to import the source data into the newly created Schema.

This bot should be triggered at Done.

func ActionLoadChartJavascript

func ActionLoadChartJavascript(request *common.POSTRequest, response *common.POSTResponse) error

ActionLoadChartJavascript inserts code which loads the Javascript needed to display charts.

func ActionLoadEditTask

func ActionLoadEditTask(currentData *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionLoadEditTask performs some one-time setup for the Edit Task Task.

func ActionLoadTracking

func ActionLoadTracking(data *common.Data, request *common.POSTRequest) error

ActionLoadTracking is triggered when a Task loads.

func ActionMicroserviceBotGenerator

func ActionMicroserviceBotGenerator(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionMicroserviceBotGenerator Generates code needed for a microservice Bot. The Bot is assumed to be coupled to a particular Schema ID.

func ActionNewData

func ActionNewData(request *common.POSTRequest, response *common.POSTResponse) error

ActionNewData opens a new Data in this Task. Usually used "At Done", this Bot creates a new Data and directs you to view it. This is extremely useful if the Task represents a contact like a phone call and when you press "Done" you need to open a new contact for the next phone call you receive. Keep in mind that using this Bot can mess with reporting. For example, if you were using the time the contact was opened as the "start time" for your call tracking and the "Last Done" for your "finish time", then when you install this Bot you will get "start time"s which start prior to a new call being received. This problem could be mitigated with some custom code or by integrating call logging into your Polyapp Task.

func ActionNextData

func ActionNextData(currentData *common.Data, request *common.POSTRequest, response *common.POSTResponse, botStaticData map[string]string) error

ActionNextData opens the current Task with the next Data. By default the next Data is the next ID for a query on this SchemaID. For example if you have ID 'a' and the schema contains IDs: '0', 'a', 'b', 'c', then the current Task would be opened with Data 'b'. TODO right now this is very similar to calling the GETDataTables. It would be better to actually call that func.

func ActionPopulateFromUser

func ActionPopulateFromUser(data *common.Data, request *common.POSTRequest, response *common.POSTResponse, botStaticData map[string]string) error

ActionPopulateFromUser takes information stored in the User document and sets it into the current, top-level Data. All information must be mapped in a "Bot Static Data" for any setting to take place. The format is: "PopulateFromUser {UserProperty}-{FieldName}" Examples: "PopulateFromUser UID-field name", "PopulateFromUser Full Name-field name" "PopulateFromUser Phone Number-phone number". Full list of possible User fields includes: UID, Full Name, Photo URL, Email Verified, Phone Number, Email, Roles, Bots Triggered At Load, Bots Triggered At Done, Home Task, Home UX, Home Schema, Home Data, polyappFirestoreID.

func ActionProductivityChart

func ActionProductivityChart(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionProductivityChart is a custom chart task. It creates a new Chart which calculates the difference between when a Task was started and when it was "Done" for the last time. This value is displayed on the Y axis. The X axis displays when Tasks were first opened.

func ActionReCreateAllTasks

func ActionReCreateAllTasks(request *common.POSTRequest) error

ActionReCreateAllTasks Other names: "Re-Generate All Tasks" or "Generate All Tasks". This Task has a Bot which runs a Done which loops over all Tasks in the system, finds their associated Datas (if available) and re-runs "Edit Task" on them.

This is an administration tool used when the "Edit Task" Task or its Bot is updated and you want to re-generate all of your Tasks to take advantage of that update.

Because this Task affects so much of the system, you must have total system access - Industry Polyapp and Domain Polyapp and EditTask on that line - access to run this code.

func ActionRefreshRecentReport

func ActionRefreshRecentReport(request *common.POSTRequest, response *common.POSTResponse) error

ActionRefreshRecentReport refreshes the most recent report you viewed and then redirects the browser to view that report.

Call this: /t/polyapp/Reporting/oirJixuiCaUiigcRQuenayNHo?ux=lFUmSlLZpIMUUpLpLbHTODHgK&schema=oyFnvZuDqpgkhTJCzrHbYrSZx&data=pEtpSZvNQFsaMtcTxCInMuiKO

func ActionSetInitialHiddenColumns

func ActionSetInitialHiddenColumns(data *common.Data, response *common.POSTResponse) error

ActionSetInitialHiddenColumns determines if a Task appears to be brand new. If so, it sets the Hidden Columns to the metadata columns.

func ActionSurveyAtLoad

func ActionSurveyAtLoad(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

func ActionSurveyContinuous

func ActionSurveyContinuous(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionSurveyContinuous is called when someone enters information into the survey. It is used to update predictions.

func ActionTable

func ActionTable(data *common.Data, botStaticData map[string]string, request *common.POSTRequest) error

ActionTable is the Action taken continuously with Table tasks. It redirects users to a new URL with a variable Data ID if you select a row. If you click the Done button it redirects you to a random ID for that Data ID. Right now there is no support for creating a Data from the available information.

Side effect: This Action deletes the Data document. See in-function comments for 'why'.

func ActionTextTemplate

func ActionTextTemplate(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionTextTemplate A Text Template is a document template created using a what you see is what you get document editor. After you have created the document, you can add template variables which are populated from a Data. For example, let's imagine that you regularly submit a textual report which outlines the work you conducted for a client. Let's further say that the work you conducted was performed with Polyapp. You could use this Task to create a text-based report, add in template variables which will be populated from the Data like "{{.Name}}", and then use the Bot and Bot Static Data configuration information listed here to add the report to a Task. When you click "Done" on the Task, the report is generated and stored in a configurable location for your convenience.

func ActionTextTemplateReportCreator

func ActionTextTemplateReportCreator(data *common.Data, botStaticData map[string]string) error

func ActionTextTemplateValidate

func ActionTextTemplateValidate(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionTextTemplateValidate ensures the "Text Template" field is valid. If it is invalid it inserts an error into the DOM.

Bot ID is ZDKOBDoDcsQoHsSjbOlEzNjAC

func ActionUserActivity

func ActionUserActivity(request *common.POSTRequest) error

ActionUserActivity records user activity when a Task is loaded or when a Task is Done. It is designed to run as a User Bot. It knows if the Task is loading or Done based on the Data provided.

func ActionViewTaskHelpText

func ActionViewTaskHelpText(data *common.Data, request *common.POSTRequest, response *common.POSTResponse) error

ActionViewTaskHelpText This Task helps you view a particular Task's Help Text. It uses a hidden, read-only field which holds the Head Task ID. When the page is loaded, it reads the Help Text of the Task documents and displays it via its Bot, the "View Task Help Text" Bot.

func CreateFileDataRecursively

func CreateFileDataRecursively(data *common.Data) error

CreateFileDataRecursively goes through a Data and its children and their children, etc., and creates them via Create in package fileCRUD.

This function is a great way to implement ExportToJSON or "Export to JSON" field's functionality. The only thing you would be missing is if you need to save any generated Data, like Task or Schema or User, to the file system too. This function will not do that for you.

func DoConfigureAPICallRequest

func DoConfigureAPICallRequest(ConfigureAPICall *ConfigureAPICall, bodyMappingMap map[string]string, queryMappingMap map[string]string) error

DoConfigureAPICallRequest performs the work of making a request based on the ConfigureAPICall structure. It stores the response in the ConfigureAPICall structure which was passed in.

This function exists to make sure when we run "Test" in the "Configure API Call" Task the same code runs as when we make the request in reality.

func EditBot

func EditBot(data *common.Data) error

EditBot interprets the current Data into a Bot and updates the Bot if a Bot ID is included or creates a new Bot. Also creates / updates child Actions.

Works with Schema snYQbrlFiAdTgLEuJJcOAxksU

func ExportJSONRecursively

func ExportJSONRecursively(schema common.Schema, includePrefix bool, keyStyle string, removeMetadata bool) ([]byte, error)

ExportJSONRecursively returns []byte JSON document containing not only every Data in this Schema, but also every Subtask associated with those Data documents.

schema is the Schema from which you wish to export all Data.

includePrefix if set to true sets field keys to include the prefix like "ind_dom_sch_key", false field keys are "key".

keyStyle is one of: "", camelCase, PascalCase, underscore_case

func FindFieldsWhichNeedConversions

func FindFieldsWhichNeedConversions(fields []Field, oldSchema common.Schema) ([]string, error)

FindFieldsWhichNeedConversions searched through oldSchema to find all of its fields. It then checks editTask to ensure it has all of those fields. If a field is not found, it is added to a list of prefixed field names which need conversions and returned.

This function does NOT check to make sure the Field has the correct data type because we can sometimes do an automatic conversion with common.ConvertDataToMatchSchema

Special case: "Done" field never needs a conversion.

func GenerateBotScaffold

func GenerateBotScaffold(data *common.Data) error

GenerateBotScaffold is a Task which can help you get started creating new Bots in Polyapp. It will ask you for a Bot ID and a Schema ID you are operating on. By examining these two documents, it can generate code snippets which you can copy and paste into the code in the places indicated in the Help Text.

func ImportArbitraryJSONRecursively

func ImportArbitraryJSONRecursively(fullMap map[string]interface{}, schema common.Schema) ([]*common.Data, error)

ImportArbitraryJSONRecursively takes a map which was unmarshalled from JSON, converts each object in the JSON into a common.Data, and returns them. If an object has a child object then a reference is added from the parent common.Data to the child common.Data.

Key conversions: This function assumes keys are either all prefixed or none of them are prefixed. A poll is taken of fullMap's top level keys and majority wins. A key is thought to be prefixed if it follows the format: _i_d_s_k or i_d_s_k If it is a tie then keys are assumed to not be prefixed.

Schema determination: The top-level map much follow the schema of the schema parameter. Child objects in the JSON must be from one of the parent object's Schemas. If an object's Schema is not detected an error is returned. This prevents partial imports and partial import rollbacks.

func QueryAndMakeChart

func QueryAndMakeChart(industry, domain, schema, fieldName, chartType, chartName string, chartFilters []chartFilter, request *common.POSTRequest, html io.Writer, length int) error

func RefIntoStructure

func RefIntoStructure(ref string, s interface{}, exportToJSON bool) error

RefIntoStructure takes the section ref and a pointer to the structure to populate. This function retrieves the relevant data as determined by the ref and populates the structure with that data.

It is essentially a wrapper around DataIntoStructure which also extracts the Data from the Ref and Reads the Data from the database.

func StoreAPIResponse

func StoreAPIResponse(ConfigureAPICall ConfigureAPICall, s common.Schema) error

StoreAPIResponse can parse a ConfigureAPICall's Body field into a common.Data by using a recursive data import.

The API Response is assumed to be JSON.

func WhereIsBotBeingRun

func WhereIsBotBeingRun(request *common.POSTRequest) (atLoad bool, continously bool, atDone bool)

WhereIsBotBeingRun helps you adjust your code's behavior based on how where in the Task life cycle the Bot is being run.

Types

type APICall

type APICall struct {
	APIResponseSchemaID       string   `suffix:"API Response Schema ID"`
	ConfigureAPICall          string   `suffix:"Configure API Call"`
	GenerateAPIResponseSchema bool     `suffix:"Generate API Response Schema"`
	IngressBotID              string   `suffix:"Ingress Bot ID"`
	EgressBotID               string   `suffix:"Egress Bot ID"`
	Name                      string   `suffix:"Name"`
	BotStaticDataToUse        []string `suffix:"Bot Static Data To Use"`
}

type APICallRequestBodyMapping

type APICallRequestBodyMapping struct {
	PolyappFieldName     string `suffix:"Polyapp Field Name"`
	ExternalAPIFieldName string `suffix:"External API Field Name"`
}

type APICallRequestQueryMapping

type APICallRequestQueryMapping struct {
	PolyappFieldName     string `suffix:"Polyapp Field Name"`
	ExternalAPIFieldName string `suffix:"External API Field Name"`
}

type APICallResponseMapping

type APICallResponseMapping struct {
	PolyappFieldName     string `suffix:"Polyapp Field Name"`
	ExternalAPIFieldName string `suffix:"External API Field Name"`
}

type BotScaffold

type BotScaffold struct {
	TaskID   string `suffix:"Task ID"`
	SchemaID string `suffix:"Schema ID"`
}

type ConfigureAPICall

type ConfigureAPICall struct {
	FirestoreID         string
	AdditionalHeaders   []string `suffix:"Additional Headers"`
	AcceptEncoding      string   `suffix:"Accept-Encoding"`
	UserAgentHeader     string   `suffix:"User-Agent Header"`
	MaxRetries          float64  `suffix:"Max Retries"`
	Body                string   `suffix:"Body"`
	ContentLengthHeader float64  `suffix:"Content-Length Header"`
	Cookies             []string `suffix:"Cookies"`
	AcceptHeader        string   `suffix:"Accept Header"`
	HTTPVerb            string   `suffix:"HTTP Verb"`
	RequestURL          string   `suffix:"Request URL"`
	ConnectionHeader    string   `suffix:"Connection Header"`
	HostHeader          string   `suffix:"Host Header"`
	ContentTypeHeader   string   `suffix:"Content-Type Header"`
	Test                bool
	APICallResponse     string `suffix:"Test Response"`
	APICallStatusCode   string `suffix:"Test Status Code"`
}

type CreateChartFromData

type CreateChartFromData struct {
	Name         string
	Schema       string
	FieldName    string        `suffix:"Field Name"`
	ChartType    string        `suffix:"Chart Type"`
	ChartHTML    []byte        `suffix:"Chart HTML"`
	ChartFilters []chartFilter `suffix:"Chart Filters"`
}

type CreateDashboard

type CreateDashboard struct {
	Header          string
	ReportIDs       []string `suffix:"Report IDs"`
	SetAsHomePage   bool     `suffix:"Set As Home Page"`
	Fields          []Field
	Links           []Link
	DashboardHTML   []byte `suffix:"Dashboard HTML"`
	DashboardDataID string
	ExportToJSON    bool `suffix:"Export to JSON"`
	// contains filtered or unexported fields
}

type CreateSurvey

type CreateSurvey struct {
	Title                  string  `suffix:"Title"`
	Welcome                string  `suffix:"Welcome"`
	ExternalServiceURL     string  `suffix:"External Service URL"`
	GeneratedTaskURL       string  `suffix:"Generated Task URL"`
	Fields                 []Field `suffix:"Fields"`
	TaskID                 string  `suffix:"Task ID"`
	SchemaID               string  `suffix:"Schema ID"`
	UXID                   string  `suffix:"UX ID"`
	ViewTaskHelpTextDataID string  `suffix:"View Task Help Text Data ID"`
	EditTaskDataID         string  `suffix:"Edit Task Data ID"`
	DashboardDataID        string  `suffix:"Dashboard Data ID"`
	TableReportDataID      string  `suffix:"Table Report Data ID"`
}

type CreateTableFromData

type CreateTableFromData struct {
	Name          string
	Schema        string
	TableHTML     []byte `suffix:"Table HTML"`
	TimeFilter    []chartFilter
	HiddenColumns []string
	ChartFilters  []chartFilter
}

type CreateTheme

type CreateTheme struct {
	Description    string `suffix:"Description"`
	SecondaryColor string `suffix:"Secondary Color"`
	PrimaryColor   string `suffix:"Primary Color"`
	LightColor     string `suffix:"Light Color"`
	DarkColor      string `suffix:"Dark Color"`
	LogoforIcon    []byte `suffix:"Logo for Icon"`
	Name           string `suffix:"Name"`
	BootstrapTheme []byte `suffix:"Bootstrap Theme"`
	SetAsMyTheme   bool   `suffix:"Set As My Theme"`
	ExportToJSON   bool   `suffix:"Export to JSON"`
}

type EditChart

type EditChart struct {
	Name             string
	Schema           string
	FieldName        string `suffix:"Field Name"`
	ChartType        string `suffix:"Chart Type"`
	ChartHTML        []byte `suffix:"Chart HTML"`
	ChartPreviewHTML []byte `suffix:"Chart Preview HTML"`
}

type EditTask

type EditTask struct {
	Name     string `suffix:"Name"`
	HelpText string `suffix:"Help Text"`
	// AgreeToMakePublic, if true, sends the Data, Task, Schema, UX, Bot, Action documents to a remote server.
	AgreeToMakePublic         bool   `suffix:"Agree to Make Public"`
	ExportAsJSONToFile        bool   `suffix:"Export As JSON To File"`
	TaskID                    string `suffix:"Task ID"`
	SchemaID                  string `suffix:"Schema ID"`
	UXID                      string `suffix:"UX ID"`
	ViewTaskHelpTextDataID    string `suffix:"View Task Help Text Data ID"`
	Industry                  string `suffix:"Industry"`
	Domain                    string
	BotsTriggeredAtLoad       []string `suffix:"Bots Triggered At Load"`
	BotsTriggeredContinuously []string `suffix:"Bots Triggered Continuously"`
	BotsTriggeredAtDone       []string `suffix:"Bots Triggered At Done"`
	BotStaticData             []string `suffix:"Bot Static Data"`
	Theme                     string   `suffix:"Theme"`
	Done                      bool     `suffix:"Done"`
	Fields                    []string `suffix:"Fields" dataType:"ARef" industry:"polyapp" domain:"TaskSchemaUX" schema:"SszMuOVRaMIOUteoWiXClbpSC"`
	Subtasks                  []string `suffix:"Subtasks" dataType:"ARef" industry:"polyapp" domain:"TaskSchemaUX" schema:"SYfKUkHjtbesOmcBsPVyimJjk"`
	ImmediateSimpleConversion []string `` /* 128-byte string literal not displayed */
}

EditTask Schema is gjGLMlcNApJyvRjmgQbopsXPI

func CreateEditTaskAndData

func CreateEditTaskAndData(industry, domain string, fieldNames []string, illustrativeDataRow []string) (EditTask, common.Data, error)

CreateEditTaskAndData uses allDB.CreateData to create Fields and the EditTask Data which are represented by the provided fieldNames and the illustrativeDataRow. len(fieldNames) must == len(illustrativeDataRow)

type Field

type Field struct {
	Name     string `suffix:"Name"`
	HelpText string `suffix:"Help Text"`
	// UserInterface can be one of: "single line input", "multiple line input", "multiple line text editor", "select", "image upload", etc.
	UserInterface string `suffix:"User Interface"`
	// Validator can be one of: "", "Not Empty (also known as a Required Field)"
	Validator string `suffix:"Validator"`
	// SelectOptions is only set if you are creating a Select.
	SelectOptions []string `suffix:"Select Options"`
	// UseAsDoneButton is usually ignored unless the UserInterface is a "button". If set to True, this will make this Field ID _Done instead of the default.
	UseAsDoneButton bool `suffix:"Use as Done Button"`
	// ReadOnly is true if this field should be read-only. This means that both the UI should show it as Read-Only and the server (Task) should enforce that status.
	ReadOnly bool `suffix:"Read Only"`
	// Hidden is set to True if you want the field to exist in the Schema and Task but not in the UX.
	Hidden      bool   `suffix:"Hidden"`
	FirestoreID string `suffix:"PolyappFirestoreID"`
}

Field Schema is SszMuOVRaMIOUteoWiXClbpSC

func (Field) Validate

func (f Field) Validate() error

type GetChartFilters

type GetChartFilters struct {
	ChartFilters                 []chartFilter                  `suffix:"Chart Filters"`
	ChartUserTimeFilters         []chartTimeFilter              `suffix:"Chart User Time Filters"`
	ChartTimeRangeFilters        []chartTimeRangeFilter         `suffix:"Chart Time Range Filters"`
	ChartRelativeTimeRangeFilter []chartRelativeTimeRangeFilter `suffix:"Chart Relative Time Filters"`
}

type HTTPSCallRequest

type HTTPSCallRequest struct {
	CurrentData map[string]interface{} `json:"CurrentData"`
	// ReferencedData is made up of simplified Data documents which were referenced in CurrentData via data.Ref or data.ARef.
	ReferencedData map[string]map[string]interface{} `json:"ReferencedData"`
	Request        *common.POSTRequest               `json:"Request"`
	Response       *common.POSTResponse              `json:"Response"`
	BotStaticData  map[string]string                 `json:"BotStaticData"`
}

type HTTPSCallResponse

type HTTPSCallResponse struct {
	Request  *common.POSTRequest  `json:"Request"`
	Response *common.POSTResponse `json:"Response"`
	// CreateDatas will only be created if the Data being created passes validation and the User has access to the Industry and Domain or the Datas ID.
	CreateDatas []common.Data `json:"CreateDatas"`
	// UpdateDatas will only be updated if the Data being created passes validation and the User has access to the Industry and Domain or the Datas ID.
	UpdateDatas []common.Data `json:"UpdateDatas"`
	// DeleteDatas will only be deleted if the Data being deleted exists and the User has access to the Industry and Domain or the Datas ID.
	DeleteDatas []string `json:"DeleteDatas"`
}

type ImmediateSimpleConversion

type ImmediateSimpleConversion struct {
	DeleteOldFieldValue bool      `suffix:"Delete Old Field Value"`
	DoneTimestamps      []float64 `suffix:"Done Timestamps"`
	NewFieldName        string    `suffix:"New Field Name"`
	DoneUserIDs         []string  `suffix:"Done User IDs"`
	LoadTimestamps      []float64 `suffix:"Load Timestamps"`
	OldFieldName        string    `suffix:"Old Field Name"`
	Done                bool      `suffix:"Done"`
	LoadUserIDs         []string  `suffix:"Load User IDs"`
}

func ValidateConversionCoverage

func ValidateConversionCoverage(immediateSimpleConversions []ImmediateSimpleConversion, fieldsWhichNeedConversions []string) (missingConversions bool, immediateSimpleConversionsOut []ImmediateSimpleConversion)

ValidateConversionCoverage ensures the list of immediateSimpleConversions covers a all fieldsWhichNeedConversions. It may be a superset.

If a field which needs a conversion does not already have a conversion then a conversion is added to immediateSimpleConversion. After all fields have been processed the new superset of immediateSimpleConversion is returned.

type Link struct {
	Name string
	URL  string
}

type MicroserviceBotGenerator

type MicroserviceBotGenerator struct {
	SchemaID                      string `suffix:"Schema ID"`
	GeneratedCodeandConfiguration []byte `suffix:"Generated Code and Configuration"`
	TaskID                        string `suffix:"Task ID"`
}

type Subtask

type Subtask struct {
	TaskID          string `suffix:"Task ID"`
	SingletonOrList string `suffix:"Singleton or List"`
}

Subtask Schema is SYfKUkHjtbesOmcBsPVyimJjk

type TextTemplate

type TextTemplate struct {
	BotStaticData      []string `suffix:"Bot Static Data"`
	TextTemplate       string   `suffix:"Text Template"`
	ReportStorageField string   `suffix:"Report Storage Field"`
	BotID              string   `suffix:"Bot ID"`
	ReportStorageData  string   `suffix:"Report Storage Data"`
	Description        string   `suffix:"Description"`
	Name               string   `suffix:"Name"`
}

type Tree

type Tree struct {
	FirestoreID string
	Children    []*Tree
}

func CreateEditTaskFromJSON

func CreateEditTaskFromJSON(industry, domain, name string, illustrativeJSON map[string]interface{}) ([]common.Data, *Tree, error)

CreateEditTaskFromJSON uses allDB.CreateData to create Fields, EditTask, and Subtasks which are represented by the provided exampleJSONMap. It returns these as Data in the first return argument.

For a simple JSON structure like this one: ```

{
  "field": "value",
  "array": [
    "array value 1",
    "array value 2"
  ]
}

```

The provided map would be translated into a single Task which has a "field" string field and an "array" array field composed of strings.

If the exampleJSONMap contains an embedded JSON object, that JSON object is parsed to create a new Task. In this way, we can convert the entire JSON object into one or more Tasks, each with their own Schema and UX.

Rather than storing the Data ourselves, the Data are returned after all parsing is complete with the first common.Data being the head Data. The Tree may be used to determine dependencies in the returned slice of common.Data.

Known Problem: {"a":{"A":[{"AA":""}]},"b":{"A":[{"AA":"","BB":""}]}} Even if we iterated over every option in the first "A" array, we haven't seen every option in "AA" under "b". Because we assume that "A"'s schema in "a" is independent from "A"'s schema in "b" we won't assign all possible property values to the subtask under "A". To fix this sort of error, try importing only 2 layers of your application at a time. Then go into "Edit Task" and edit the subtasks until they work the correct way.

type UserActivity

type UserActivity struct {
	UserID    string  `suffix:"User ID"`
	EventURL  string  `suffix:"Event URL"`
	EventTime float64 `suffix:"Event Time"`
	Event     string
}

type ViewTaskHelpText

type ViewTaskHelpText struct {
	HeadTaskID string `suffix:"Head Task ID"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL