This document is going to document the elusive nature of executing code from the builder to make it less elusive and easy to do. Also as the thin client continues to grow we need to make a migration towards a new pattern on how we execute code. So going forward this education should be helpful.
The main issue with the current model is that as we increase the uses of the platform the current code execution framework cannot scale as the platform scales. For example the current interface to the execution framework looks like.
function(activeCase, user, toaster, validate, $http, $q, callback)
As we increase our usage we need to add new arguments to this code and then go back and change existing code to make sure we are matching the new patterns. This is just not scalable. Another issue is the interface to executing code is different in many things, lets consolidate the this into one interface that works for all scenarios.
function(activeCase, session, services, locals) {
    ...
}
//activeCase / activeAsset: the current case or asset depending on the context you are in.
//session:  the current context of the person who is executing this code session has currently looks like
//services: see below
//locals: These are things that pertain to the individual thing executing the code, for example the checkoutDirective might put on some meta to help with the execution of code
- AccountService
 - ApplicationService
 - AssetService
 - AssetMasterTemplateService
 - AssetTemplateService
 - CaseService
 - IdpService
 - MemorizeService
 - NewportService
 - OrderService
 - PasswordService
 - SKUService
 - ShowdayService
 - WorkflowService
 - WorkflowTplService
 - NotificationService
 
- AccountService
- findByEmail(email) ⇒ 
*⏏ - query(query) ⇒ 
*⏏ - save(account) ⏏
 - search(account) ⇒ 
*⏏ - update(account) ⇒ 
*⏏ - remove(account) ⇒ 
*⏏ - findById(id, params) ⇒ 
*⏏ 
 - findByEmail(email) ⇒ 
 
find an account given an email
Kind: Exported function
| Param | 
|---|
find an account given a query
Kind: Exported function
| Param | 
|---|
| query | 
save an account and then update the current session
Kind: Exported function
| Param | 
|---|
| account | 
Search using elasticsearch
Kind: Exported function
| Param | 
|---|
| account | 
update an account
Kind: Exported function
| Param | 
|---|
| account | 
remove an account
Kind: Exported function
| Param | 
|---|
| account | 
find an account by id and additional optionsla params
Kind: Exported function
| Param | 
|---|
| id | 
| params | 
- ApplicationService
- findById(id, params) ⇒ 
Application⏏ - query(params) ⇒ 
*⏏ - create(application) ⇒ 
*⏏ - update(application) ⇒ 
*⏏ - remove(application) ⇒ 
*⏏ 
 - findById(id, params) ⇒ 
 
finds an application given an ID
Kind: Exported function
| Param | 
|---|
| id | 
| params | 
queries the DB bringing a paged output back
Kind: Exported function
| Param | 
|---|
| params | 
Creates an application
Kind: Exported function
| Param | 
|---|
| application | 
updates an application
Kind: Exported function
| Param | 
|---|
| application | 
removes an application
Kind: Exported function
| Param | 
|---|
| application | 
- AssetService
- save(asset) ⇒ 
*⏏ - query(queryParams) ⇒ 
*⏏ - paged(queryParams) ⇒ 
*⏏ - create(asset) ⇒ 
*⏏ - countTypes(subtypes) ⇒ 
*⏏ - remove(asset) ⇒ 
*⏏ - aggregation(aggregation) ⇒ 
*⏏ aggregate(pipeline) ⇒*⏏- findById(id, params) ⇒ 
*⏏ - populateGuids(guids) ⇒ 
*⏏ - createAsset(user, selections) ⇒ 
newAsset⏏ 
 - save(asset) ⇒ 
 
Saves an Asset
Kind: Exported function
| Param | 
|---|
| asset | 
Query's for an asset
Kind: Exported function
| Param | 
|---|
| queryParams | 
querys for an asset bringing a paged list back
Kind: Exported function
| Param | 
|---|
| queryParams | 
Create an asset
Kind: Exported function
| Param | 
|---|
| asset | 
Given an array of subtypes bring back a count of each subtype
Kind: Exported function
| Param | 
|---|
| subtypes | 
remove an asset
Kind: Exported function
| Param | 
|---|
| asset | 
Send an aggregation pipeline to return asset data
Kind: Exported function
| Param | 
|---|
| aggregation | 
Deprecated
Send an aggregation pipeline to return asset data
Kind: Exported function
| Param | 
|---|
| pipeline | 
Find an asset by guid
Kind: Exported function
| Param | Description | 
|---|---|
| id | is a guid | 
| params | 
Given a list of guids bring back the assets for those guids
Kind: Exported function
| Param | 
|---|
| guids | 
create an asset given a assetTemplate
Kind: Exported function
| Param | 
|---|
| user | 
| selections | 
- AssetMasterTemplateService
- findById(id) ⇒ 
*⏏ - create(template) ⇒ 
*⏏ - query(searchParams) ⇒ 
*⏏ - getByType(type) ⇒ 
*⏏ 
 - findById(id) ⇒ 
 
find an asset master template by Id
Kind: Exported function
| Param | 
|---|
| id | 
Create an asset Master Template
Kind: Exported function
| Param | 
|---|
| template | 
query for an asset master template
Kind: Exported function
| Param | 
|---|
| searchParams | 
get an asset master template by type
Kind: Exported function
| Param | 
|---|
| type | 
- AssetTemplateService
- create(template) ⇒ 
*⏏ - update(template) ⇒ 
*⏏ - createFromMaster(masterTemplate, accountId, domainId) ⇒ 
*⏏ - findById(id) ⇒ 
*⏏ - updateById(id, body) ⇒ 
*⏏ - query(params) ⇒ 
*⏏ - deleteById(id) ⇒ 
*⏏ - getByType(type, params) ⇒ 
*⏏ - getByAccount(accountId, params) ⇒ 
*⏏ 
 - create(template) ⇒ 
 
Create an asset template
Kind: Exported function
| Param | 
|---|
| template | 
update an asset template
Kind: Exported function
| Param | 
|---|
| template | 
create an asset template from a master template
Kind: Exported function
| Param | 
|---|
| masterTemplate | 
| accountId | 
| domainId | 
find an asset template by id
Kind: Exported function
| Param | 
|---|
| id | 
update an asset template by id
Kind: Exported function
| Param | 
|---|
| id | 
| body | 
query for an asset template
Kind: Exported function
| Param | 
|---|
| params | 
delete an asset template
Kind: Exported function
| Param | 
|---|
| id | 
get by a type
Kind: Exported function
| Param | 
|---|
| type | 
| params | 
get asset templates by account
Kind: Exported function
| Param | 
|---|
| accountId | 
| params | 
- CaseService
- create(workflow, data, name) ⇒ 
*⏏ - leanQuery(query) ⇒ 
*⏏ - get(guid) ⇒ 
*⏏ aggregation(aggregation) ⇒*⏏- aggregationV2(aggregation) ⇒ 
*⏏ - aggregationV2Binary(aggregation, fields, fieldNames, outputFormat) ⇒ 
*⏏ - aggregationV2Email(aggregation, fields, fieldNames, outputFormat, email) ⇒ 
*⏏ - trello(query) ⇒ 
*⏏ aggregate(pipeline) ⇒*⏏- save(aCase, useV1) ⇒ 
*⏏ - paged(params) ⇒ 
*⏏ - query(query, [projection]) ⇒ 
*⏏ - remove(aCase) ⇒ 
*⏏ - createStateChangeOptions(nextStates, srcState) ⏏
 
 - create(workflow, data, name) ⇒ 
 
Creates a case
Kind: Exported function
| Param | 
|---|
| workflow | 
| data | 
| name | 
Brings a minified set of props of a case
Kind: Exported function
| Param | 
|---|
| query | 
get a case by guid
Kind: Exported function
| Param | 
|---|
| guid | 
Deprecated
send an aggregation pipeline
Kind: Exported function
| Param | 
|---|
| aggregation | 
send an aggregation pipeline
Kind: Exported function
| Param | 
|---|
| aggregation | 
returns an aggregation in binary
Kind: Exported function
| Param | 
|---|
| aggregation | 
| fields | 
| fieldNames | 
| outputFormat | 
sends an aggregation to an email
Kind: Exported function
| Param | 
|---|
| aggregation | 
| fields | 
| fieldNames | 
| outputFormat | 
Trello view for workspace call
Kind: Exported function
| Param | 
|---|
| query | 
Deprecated
send an aggregation pipeline
Kind: Exported function
| Param | 
|---|
| pipeline | 
save a case
Kind: Exported function
| Param | 
|---|
| aCase | 
| useV1 | 
get a paged list of cases
Kind: Exported function
| Param | 
|---|
| params | 
query for a case
Kind: Exported function
| Param | 
|---|
| query | 
| [projection] | 
remove a case
Kind: Exported function
| Param | 
|---|
| aCase | 
creates a map of state changes a current case can do
Kind: Exported function
| Param | 
|---|
| nextStates | 
| srcState | 
creates an IDP account
Kind: Exported function
| Param | 
|---|
| password | 
| other | 
updates an Idp Account
Kind: Exported function
| Param | 
|---|
| userId | 
| data | 
- MemorizeService
- query(query) ⇒ 
*⏏ - save(memorizeObject) ⇒ 
*⏏ - create(memorizeObject) ⇒ 
*⏏ 
 - query(query) ⇒ 
 
query for memorizes
Kind: Exported function
| Param | 
|---|
| query | 
save a memorize
Kind: Exported function
| Param | 
|---|
| memorizeObject | 
create a memorize object
Kind: Exported function
| Param | 
|---|
| memorizeObject | 
- OrderService
- findById(id, params) ⇒ 
*⏏ - create(order) ⇒ 
*⏏ - pay(order) ⇒ 
*⏏ - manual(order) ⇒ 
*⏏ - update(order) ⇒ 
*⏏ 
 - findById(id, params) ⇒ 
 
find an order by id
Kind: Exported function
| Param | 
|---|
| id | 
| params | 
Create an order
Kind: Exported function
| Param | 
|---|
| order | 
pay an order
Kind: Exported function
| Param | 
|---|
| order | 
Manually pay an order
Kind: Exported function
| Param | 
|---|
| order | 
update an order
Kind: Exported function
| Param | 
|---|
| order | 
- PasswordService
- reset(email) ⇒ 
*⏏ - activate(token, password) ⇒ 
*⏏ 
 - reset(email) ⇒ 
 
reset a password given an email
Kind: Exported function
| Param | 
|---|
activate a password
Kind: Exported function
| Param | 
|---|
| token | 
| password | 
Finds a sku by id
Kind: Exported function
| Param | 
|---|
| id | 
| params | 
create a showday membership
Kind: Exported function
| Param | 
|---|
| asset | 
| accountId | 
determines if the horse name is taken
Kind: Exported function
| Param | 
|---|
| name | 
get similar horse names
Kind: Exported function
| Param | 
|---|
| name | 
- WorkflowService
- create(template) ⇒ 
*⏏ - update(template) ⇒ 
*⏏ - findById(id, params) ⇒ 
*⏏ - query(query) ⇒ 
*⏏ - getByAccount(accountId) ⇒ 
*⏏ - getByType(type, params) ⇒ 
*⏏ - list() ⇒ 
*⏏ 
 - create(template) ⇒ 
 
create a workflow
Kind: Exported function
| Param | 
|---|
| template | 
update a workflow
Kind: Exported function
| Param | 
|---|
| template | 
find a workflow by id
Kind: Exported function
| Param | 
|---|
| id | 
| params | 
query for a workflow
Kind: Exported function
| Param | 
|---|
| query | 
get workflows by account
Kind: Exported function
| Param | 
|---|
| accountId | 
get a workflow by type
Kind: Exported function
| Param | 
|---|
| type | 
| params | 
list workflows
- WorkflowTplService
- findById(id) ⇒ 
*⏏ - create(template) ⇒ 
*⏏ - getByType(type) ⇒ 
*⏏ 
 - findById(id) ⇒ 
 
Find a workflow template by id
Kind: Exported function
| Param | 
|---|
| id | 
create a workflow template
Kind: Exported function
| Param | 
|---|
| template | 
get workflow templates by type
Kind: Exported function
| Param | 
|---|
| type | 
Creates a toast
Kind: Exported function
| Param | 
|---|
| msg | 
Creates an alert
Kind: Exported function
| Param | 
|---|
| msg | 
Kind: Exported function
| Param | Type | Default | 
|---|---|---|
| msg | ||
| [params] | Object | 
|
| [params.title] | string | 
"Are you sure" | 
| [params.okTest] | string | 
"Ok" | 
| [params.cancelText] | string | 
"Cancel" |