Skip to content

Instantly share code, notes, and snippets.

@enpfeff
Last active March 12, 2018 17:01
Show Gist options
  • Save enpfeff/2911691e69a309026ac8dd2110ba3753 to your computer and use it in GitHub Desktop.
Save enpfeff/2911691e69a309026ac8dd2110ba3753 to your computer and use it in GitHub Desktop.
Halo Api

Execution Of Code

Scope

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.

Issues

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.

The New Pattern

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

Modules

AccountService
ApplicationService
AssetService
AssetMasterTemplateService
AssetTemplateService
CaseService
DomainService
GlobalSearchService
IdpService
MemorizeService
NewportService
OrderService
PasswordService
SKUService
ShowdayService
WorkflowService
WorkflowTplService
NotificationService

Functions

getReport(guid)*

get the report given a case guid

getXReport(guid)*

get a case given the guid or xguid

getV2(id)*

gets a doc by mongo id

superDelete(id)*

Deletes a case from the Db, only executable by a Super Admin

superSave(id, body)*

Saves a case to the Db, only executable by a Super Admin

AccountService

findByEmail(email) ⇒ *

find an account given an email

Kind: Exported function

Param
email

query(query) ⇒ *

find an account given a query

Kind: Exported function

Param
query

save(account) ⏏

save an account and then update the current session

Kind: Exported function

Param
account

search(account) ⇒ *

Search using elasticsearch

Kind: Exported function

Param
account

update(account) ⇒ *

update an account

Kind: Exported function

Param
account

remove(account) ⇒ *

remove an account

Kind: Exported function

Param
account

findById(id, params) ⇒ *

find an account by id and additional optionsla params

Kind: Exported function

Param
id
params

getV2(id) ⇒ *

gets a doc by mongo id

Kind: Exported function

Param Description
id mongo id

superSave(id, body) ⇒ *

Saves a Account from the DB, super admin only

Kind: Exported function

Param
id
body

superDelete(id) ⇒ *

Deletes a Account from the Db, only executable by a Super Admin

Kind: Exported function

Param
id

getUsers(id) ⇒ *

gets the users for a given account

Kind: Exported function

Param
id

ApplicationService

findById(id, params) ⇒ Application

finds an application given an ID

Kind: Exported function

Param
id
params

byType(type) ⇒ *

finds a service by its type

Kind: Exported function

Param
type

query(params) ⇒ *

queries the DB bringing a paged output back

Kind: Exported function

Param
params

create(application) ⇒ *

Creates an application

Kind: Exported function

Param
application

update(application) ⇒ *

updates an application

Kind: Exported function

Param
application

remove(application) ⇒ *

removes an application

Kind: Exported function

Param
application

paged(params) ⇒ *

gets a pages list of Services

Kind: Exported function

Param Type
params Object

populate(ids) ⇒ *

returns a hashmap of services with the key being the id

Kind: Exported function

Param Type Description
ids Array.<string> a list of ids

getV2(id) ⇒ *

gets a doc by mongo id

Kind: Exported function

Param Description
id mongo id

superSave(id, body) ⇒ *

Deletes a Service from the DB, super admin only

Kind: Exported function

Param
id
body

superDelete(id) ⇒ *

Deletes a Service from the Db, only executable by a Super Admin

Kind: Exported function

Param
id

AssetService

save(asset) ⇒ *

Saves an Asset

Kind: Exported function

Param
asset

query(queryParams) ⇒ *

Query's for an asset

Kind: Exported function

Param
queryParams

paged(queryParams) ⇒ *

querys for an asset bringing a paged list back

Kind: Exported function

Param
queryParams

create(asset) ⇒ *

Create an asset

Kind: Exported function

Param
asset

countTypes(subtypes) ⇒ *

Given an array of subtypes bring back a count of each subtype

Kind: Exported function

Param
subtypes

remove(asset) ⇒ *

remove an asset

Kind: Exported function

Param
asset

aggregation(aggregation, [domainWide]) ⇒ Array.<Object>

Send an aggregation pipeline to return asset data

Kind: Exported function

Param Type Default Description
aggregation Array.<Object> the aggregation pipeline
[domainWide] boolean false Executes the aggregation domainWide

aggregate(pipeline) ⇒ *

Deprecated

Send an aggregation pipeline to return asset data

Kind: Exported function

Param
pipeline

findById(id, params) ⇒ *

Find an asset by guid

Kind: Exported function

Param Description
id is a guid
params

populateGuids(guids) ⇒ *

Given a list of guids bring back the assets for those guids

Kind: Exported function

Param
guids

createAsset(user, selections) ⇒ newAsset

create an asset given a assetTemplate

Kind: Exported function

Param
user
selections

AssetMasterTemplateService

findById(id) ⇒ *

find an asset master template by Id

Kind: Exported function

Param
id

create(template) ⇒ *

Create an asset Master Template

Kind: Exported function

Param
template

query(searchParams) ⇒ *

query for an asset master template

Kind: Exported function

Param
searchParams

getByType(type) ⇒ *

get an asset master template by type

Kind: Exported function

Param
type

AssetTemplateService

create(template) ⇒ *

Create an asset template

Kind: Exported function

Param
template

update(template) ⇒ *

update an asset template

Kind: Exported function

Param
template

createFromMaster(masterTemplate, accountId, domainId) ⇒ *

create an asset template from a master template

Kind: Exported function

Param
masterTemplate
accountId
domainId

findById(id) ⇒ *

find an asset template by id

Kind: Exported function

Param
id

updateById(id, body) ⇒ *

update an asset template by id

Kind: Exported function

Param
id
body

query(params) ⇒ *

query for an asset template

Kind: Exported function

Param
params

deleteById(id) ⇒ *

delete an asset template

Kind: Exported function

Param
id

getByType(type, params) ⇒ *

get by a type

Kind: Exported function

Param
type
params

getByAccount(accountId, params) ⇒ *

get asset templates by account

Kind: Exported function

Param
accountId
params

CaseService

populate(ids) ⇒ *

given a list of ids bring back the docs

Kind: Exported function

Param Type Description
ids Array.<Object> the ids of the objects to bring back

superDelete(id) ⇒ *

Deletes a case from the Db, only executable by a Super Admin

Kind: Exported function

Param
id

superSave(id, body) ⇒ *

Saves a case to the Db, only executable by a Super Admin

Kind: Exported function

Param
id
body

getV2(id) ⇒ *

gets a doc by mongo id

Kind: Exported function

Param Description
id mongo id

create(workflow, data, name) ⇒ *

Creates a case

Kind: Exported function

Param
workflow
data
name

leanQuery(query) ⇒ *

Brings a minified set of props of a case

Kind: Exported function

Param
query

get(guid) ⇒ *

get a case by guid

Kind: Exported function

Param
guid

aggregation(aggregation) ⇒ *

Deprecated

send an aggregation pipeline

Kind: Exported function

Param
aggregation

aggregationV2(aggregation, [domainWide]) ⇒ *

send an aggregation pipeline

Kind: Exported function

Param Type Default Description
aggregation Array.<Object> the aggregation pipeline
[domainWide] boolean false Executes the aggregation domainWide

aggregationV2Binary(aggregation, fields, fieldNames, outputFormat) ⇒ *

returns an aggregation in binary

Kind: Exported function

Param
aggregation
fields
fieldNames
outputFormat

aggregationV2Email(aggregation, fields, fieldNames, outputFormat, email) ⇒ *

sends an aggregation to an email

Kind: Exported function

Param
aggregation
fields
fieldNames
outputFormat
email

trello(query) ⇒ *

Trello view for workspace call

Kind: Exported function

Param
query

aggregate(pipeline) ⇒ *

Deprecated

send an aggregation pipeline

Kind: Exported function

Param
pipeline

save(aCase, useV1) ⇒ *

save a case

Kind: Exported function

Param
aCase
useV1

paged(params) ⇒ *

get a paged list of cases

Kind: Exported function

Param
params

query(query, [projection]) ⇒ *

query for a case

Kind: Exported function

Param
query
[projection]

remove(aCase) ⇒ *

remove a case

Kind: Exported function

Param
aCase

createStateChangeOptions(nextStates, srcState) ⏏

creates a map of state changes a current case can do

Kind: Exported function

Param
nextStates
srcState

DomainService

superDelete(id) ⇒ *

Deletes a case from the Db, only executable by a Super Admin

Kind: Exported function

Param
id

superSave(id, body) ⇒ *

Saves a case to the Db, only executable by a Super Admin

Kind: Exported function

Param
id
body

populate(ids) ⇒ *

Given a list of ids bring back docs

Kind: Exported function

Param Type Description
ids Array.<string> a list of ids

paged(params) ⇒ *

Returns a paged object

Kind: Exported function

Param
params

getV2(id) ⇒ *

gets a doc by mongo id

Kind: Exported function

Param Description
id mongo id

GlobalSearchService

search(query) ⇒ *

finds an application given an ID

Kind: Exported function

Param Description
query a search query

IdpService

create(email, password, other) ⇒ *

creates an IDP account

Kind: Exported function

Param
email
password
other

update(userId, data) ⇒ *

updates an Idp Account

Kind: Exported function

Param
userId
data

MemorizeService

query(query) ⇒ *

query for memorizes

Kind: Exported function

Param
query

save(memorizeObject) ⇒ *

save a memorize

Kind: Exported function

Param
memorizeObject

create(memorizeObject) ⇒ *

create a memorize object

Kind: Exported function

Param
memorizeObject

NewportService

OrderService

findById(id, params) ⇒ *

find an order by id

Kind: Exported function

Param
id
params

create(order) ⇒ *

Create an order

Kind: Exported function

Param
order

pay(order) ⇒ *

pay an order

Kind: Exported function

Param
order

manual(order) ⇒ *

Manually pay an order

Kind: Exported function

Param
order

update(order) ⇒ *

update an order

Kind: Exported function

Param
order

PasswordService

reset(email) ⇒ *

reset a password given an email

Kind: Exported function

Param
email

activate(token, password) ⇒ *

activate a password

Kind: Exported function

Param
token
password

SKUService

findById(id, params) ⇒ *

Finds a sku by id

Kind: Exported function

Param
id
params

ShowdayService

create(asset, accountId) ⇒ *

create a showday membership

Kind: Exported function

Param
asset
accountId

isHorseNameTaken(name) ⏏

determines if the horse name is taken

Kind: Exported function

Param
name

getSimilarHorseNames(name) ⇒ *

get similar horse names

Kind: Exported function

Param
name

WorkflowService

create(template) ⇒ *

create a workflow

Kind: Exported function

Param
template

update(template) ⇒ *

update a workflow

Kind: Exported function

Param
template

findById(id, params) ⇒ *

find a workflow by id

Kind: Exported function

Param
id
params

query(query) ⇒ *

query for a workflow

Kind: Exported function

Param
query

getByAccount(accountId) ⇒ *

get workflows by account

Kind: Exported function

Param
accountId

getByType(type, params) ⇒ *

get a workflow by type

Kind: Exported function

Param
type
params

list() ⇒ *

list workflows

Kind: Exported function

WorkflowTplService

findById(id) ⇒ *

Find a workflow template by id

Kind: Exported function

Param
id

create(template) ⇒ *

create a workflow template

Kind: Exported function

Param
template

getByType(type) ⇒ *

get workflow templates by type

Kind: Exported function

Param
type

NotificationService

toast(msg) ⏏

Creates a toast

Kind: Exported function

Param
msg

alert(msg) ⏏

Creates an alert

Kind: Exported function

Param
msg

confirm(msg, [params]) ⏏

Kind: Exported function

Param Type Default
msg
[params] Object
[params.title] string "Are you sure"
[params.okTest] string "Ok"
[params.cancelText] string "Cancel"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment