diff --git a/reference/organics/flow/build.md b/reference/organics/flow/build.md new file mode 100644 index 000000000..853a1664e --- /dev/null +++ b/reference/organics/flow/build.md @@ -0,0 +1,16 @@ +# `build` + +Build a value by running some logic, then using the return value. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | builder | ((ref)) | The function to be run in order to build the result. Note that this function should not cause any side effects. + + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((ref)) | The value returned by the builder function \ No newline at end of file diff --git a/reference/organics/flow/dive.md b/reference/organics/flow/dive.md new file mode 100644 index 000000000..812817173 --- /dev/null +++ b/reference/organics/flow/dive.md @@ -0,0 +1,16 @@ +# `Dive` + +Dive into some recursive logic, inputted as a function. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | recursee | ((ref)) | The recursive logic function to run +| 2 | maxDepth | ((number)) | (Optional) A maximum depth (zero-indexed) + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((ref)) | The (optional) result from performing this recursive dive \ No newline at end of file diff --git a/reference/organics/flow/flow.md b/reference/organics/flow/flow.md new file mode 100644 index 000000000..32f85db54 --- /dev/null +++ b/reference/organics/flow/flow.md @@ -0,0 +1 @@ +These helpers are used as utilities for asynchronous flow control. \ No newline at end of file diff --git a/reference/organics/flow/for-each.md b/reference/organics/flow/for-each.md new file mode 100644 index 000000000..6946fa8f9 --- /dev/null +++ b/reference/organics/flow/for-each.md @@ -0,0 +1,11 @@ +# `forEach` + +Run a given function once for each item in an array or a dictionary. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | arrayOrDictionary | ((ref)) | The array or dictionary over which to loop +| 2 | iteratee | ((ref)) | The function to run for each item in the object + diff --git a/reference/organics/flow/iterate.md b/reference/organics/flow/iterate.md new file mode 100644 index 000000000..c13927d69 --- /dev/null +++ b/reference/organics/flow/iterate.md @@ -0,0 +1,14 @@ +# `iterate` + +Run a given function every time the given wellspring says to run it. +Note on ‘splash’: A splash is the moment in time when the wellspring invokes the given function, eachSplash. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | wellspring | ((ref)) | The function that triggers a sequence of splashes, saying when, how many times, and with what value to run the given eachSplash function. +| 2 | eachSplash | ((ref)) | The function to run each time the wellspring splashes out a value. +| 3 | eachBatch | ((ref)) | The function to run when the current batch of values fills up and if the wellspring finishes without filling up the last batch +| 4 | skipDuplicates | ((boolean)) | Whether or not to skip running eachSplash if the splashed value has been seen before. Uses a strict equality check (===). +| 5 | batchSize | ((number)) | The number of un-skipped times the wellspring can splash before considering the batch full and invoking eachBatch with an array of the values of the batch. \ No newline at end of file diff --git a/reference/organics/flow/pause.md b/reference/organics/flow/pause.md new file mode 100644 index 000000000..3a628c89b --- /dev/null +++ b/reference/organics/flow/pause.md @@ -0,0 +1,7 @@ +# `pause` + +Wait for at least the given number of milliseconds before proceeding. + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | ms | ((number)) | The number of milliseconds to wait (must be greater than or equal to 0) \ No newline at end of file diff --git a/reference/organics/flow/simultaneously-for-each.md b/reference/organics/flow/simultaneously-for-each.md new file mode 100644 index 000000000..b0f312cf2 --- /dev/null +++ b/reference/organics/flow/simultaneously-for-each.md @@ -0,0 +1,16 @@ +# `simultaneouslyForEach` + +Run a given function once for each item in an array or a dictionary. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | arrayOrDictionary | ((ref)) | The array or dictionary over which to loop +| 2 | iteratee | ((ref)) | The function to run for each item in the object + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((ref)) | An array or dictionary of the results, which is the combined result of running iteratee on each item/property \ No newline at end of file diff --git a/reference/organics/flow/simultaneously.md b/reference/organics/flow/simultaneously.md new file mode 100644 index 000000000..e346b004f --- /dev/null +++ b/reference/organics/flow/simultaneously.md @@ -0,0 +1,15 @@ +# `simultaneously` + +Run multiple functions at the same time, then assembles the return values into the structure defined by stencil. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | stencil | ((ref)) | The one-dimensional array or dictionary, consisting of functions to run in parallel. + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((ref)) | An array or dictionary of the return values of the functions run in parallel. \ No newline at end of file diff --git a/reference/organics/flow/until.md b/reference/organics/flow/until.md new file mode 100644 index 000000000..6bc225bde --- /dev/null +++ b/reference/organics/flow/until.md @@ -0,0 +1,10 @@ +# `until` + +Run a given function repeatedly until its return value is `true`. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | checker | ((ref)) | The function to be run until it returns `true` +| 2 | timeout | ((number)) | (optional) A timeout value, in milliseconds \ No newline at end of file diff --git a/reference/organics/gravatar/get-avatar-url.md b/reference/organics/gravatar/get-avatar-url.md new file mode 100644 index 000000000..4c37d444e --- /dev/null +++ b/reference/organics/gravatar/get-avatar-url.md @@ -0,0 +1,19 @@ +# `getAvatarUrl` + +Determine the source URL for the gravatar image belonging to a particular email address + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | emailAddress | ((string)) | The email address associated with the desired avatar image. +| 2 | gravatarSize | ((number)) | The desired height and width of the avatar image in pixels (between 1 and 2048). +| 3 | defaultImage | ((string)) | The backup image to use in case this email address has no matching avatar. +| 4 | rating | ((string)) | The most extreme rating level to consider "appropriate" for your audience ("G", "PG", "R", or "X".) +| 5 | useHttps | ((boolean)) | Whether to build a secure avatar URL ("https://".) + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((string)) | Avatar source URL \ No newline at end of file diff --git a/reference/organics/gravatar/gravatar.md b/reference/organics/gravatar/gravatar.md new file mode 100644 index 000000000..2d52956b3 --- /dev/null +++ b/reference/organics/gravatar/gravatar.md @@ -0,0 +1 @@ +This helper is used to look up the avatar image associated with a particular email address. \ No newline at end of file diff --git a/reference/organics/organics.md b/reference/organics/organics.md new file mode 100644 index 000000000..bf58e0163 --- /dev/null +++ b/reference/organics/organics.md @@ -0,0 +1,5 @@ +# sails-hook-organics + +`sails-hooks-organics` exposes a set of commonly used functions as helpers. These helpers represent functions hand-chosen by the Sails core team for their usefulness in building Sails- and Node-based applications. + + \ No newline at end of file diff --git a/reference/organics/passwords/check-password.md b/reference/organics/passwords/check-password.md new file mode 100644 index 000000000..17782daa4 --- /dev/null +++ b/reference/organics/passwords/check-password.md @@ -0,0 +1,10 @@ +# `checkPassword` + +Check a password attempt by comparing an inputted password with the existing bcrypt hash of the correct password. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | passwordAttempt | ((string)) | The new password attempt (unencrypted) +| 2 | hashedPassword | ((string)) | The existing password hash against which to compare the attempt diff --git a/reference/organics/passwords/hash-password.md b/reference/organics/passwords/hash-password.md new file mode 100644 index 000000000..36b7731bb --- /dev/null +++ b/reference/organics/passwords/hash-password.md @@ -0,0 +1,16 @@ +# `hashPassword` + +Hash an inputted password using the one-way bcrypt hashing algorithm. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | password | ((string)) | The password to hash +| 2 | strength | ((number)) | The number of iterations it takes to generate the cryptographic key. + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((string)) | The password hash generated by running the provided password through the bcrypt hashing algorithm. \ No newline at end of file diff --git a/reference/organics/passwords/passwords.md b/reference/organics/passwords/passwords.md new file mode 100644 index 000000000..99439b2e9 --- /dev/null +++ b/reference/organics/passwords/passwords.md @@ -0,0 +1 @@ +These helpers may be used for password encryption and authentication. \ No newline at end of file diff --git a/reference/organics/sendgrid/send-html-email.md b/reference/organics/sendgrid/send-html-email.md new file mode 100644 index 000000000..b103e2127 --- /dev/null +++ b/reference/organics/sendgrid/send-html-email.md @@ -0,0 +1,23 @@ +# `sendHtmlEmail` + +Send an automated HTML email using the SendGrid API. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | to | ((string)) | The email address of the desired recipient +| 2 | subject | ((string)) | The subject line of the email +| 3 | htmlMessage | ((string)) | The HTML body of the email +| 4 | from | ((string)) | The email address of the sender +| 5 | fromName | ((string)) | The display name of the sender, to be displayed in the recipient inbox +| 6 | secret | ((string)) | The secret API key from a valid SendGrid developer account +| 7 | toName | ((string)) | The full name of the primary recipient +| 8 | bcc | ((string)) | The list of email addresses of recipients secretly copied on the email +| 9 | attachments | ((string)) | The attachments to include on the email, with file content encoded as base64 + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((string)) | A SendGrid message ID; does not guarantee successful delivery. \ No newline at end of file diff --git a/reference/organics/sendgrid/sendgrid.md b/reference/organics/sendgrid/sendgrid.md new file mode 100644 index 000000000..725f17122 --- /dev/null +++ b/reference/organics/sendgrid/sendgrid.md @@ -0,0 +1 @@ +These helpers are for communicating with the SendGrid API, which is used to send automated emails. \ No newline at end of file diff --git a/reference/organics/stripe/charge-customer.md b/reference/organics/stripe/charge-customer.md new file mode 100644 index 000000000..231c2c5de --- /dev/null +++ b/reference/organics/stripe/charge-customer.md @@ -0,0 +1,20 @@ +# `chargeCustomer` + +Create and capture a charge for a specified amount using the saved default payment source of a Stripe customer. + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | stripeCustomerId | ((string)) | The ID of the Stripe customer to charge +| 2 | amount | ((number)) | The amount of currency to charge, expressed in the smallest currency unit. Must be greater than or equal to $0.50 US or equivalent in charge currency. +| 3 | chargeDescription | ((string)) | The text to include in automatic email receipts (if in use) and to display in the Stripe web interface alongside this charge. +| 4 | statementDescriptor | ((string)) | The text to be displayed on the customer’s credit card statement +| 5 | currency | ((string)) | The three-letter ISO currency code in lowercase indicating the currency used in this transaction. +| 6 | secret | ((string)) | The secret API key + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((string)) | The ID of the processed Stripe charge \ No newline at end of file diff --git a/reference/organics/stripe/save-billing-info.md b/reference/organics/stripe/save-billing-info.md new file mode 100644 index 000000000..f472d7656 --- /dev/null +++ b/reference/organics/stripe/save-billing-info.md @@ -0,0 +1,19 @@ +# `saveBillingInfo` + +Save the latest billing details in Stripe for a new or existing customer + +### Usage + +| | Argument | Type | Details | +|---|:--------------------|-------------------|:-----------------------------------| +| 1 | stripeCustomerId | ((string)) | The ID of the Stripe customer whose information should be updated. If unspecified, this creates a new customer entry in Stripe. +| 2 | token | ((string)) | The token used to create the source +| 3 | emailAddress | ((string)) | The email address of the Stripe customer +| 4 | plan | ((string)) | The unique identifier for the plan object +| 5 | secret | ((string)) | The secret API key. + +##### Result + +| Type | Description | +|:--------------------|:-----------------| +| ((string)) | The ID of the Stripe customer updated or created. \ No newline at end of file diff --git a/reference/organics/stripe/stripe.md b/reference/organics/stripe/stripe.md new file mode 100644 index 000000000..e097ce11a --- /dev/null +++ b/reference/organics/stripe/stripe.md @@ -0,0 +1 @@ +These helpers are used to communicate with the Stripe API to charge credit cards, etc. \ No newline at end of file