From 6c9b73e39b8fe7c88c250fd4a738be20b905c521 Mon Sep 17 00:00:00 2001 From: Seun Martins Date: Fri, 13 Oct 2017 21:22:15 +0100 Subject: [PATCH 01/59] Split create group function so it can be called outside of init --- server/api/core/core.js | 60 +++------------------------------- server/api/core/groups.js | 68 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 server/api/core/groups.js diff --git a/server/api/core/core.js b/server/api/core/core.js index eac1541aa3b..69c616a420e 100644 --- a/server/api/core/core.js +++ b/server/api/core/core.js @@ -14,9 +14,10 @@ import ProcessJobs from "/server/jobs"; import { registerTemplate } from "./templates"; import { sendVerificationEmail } from "./accounts"; import { getMailUrl } from "./email/config"; +import { createGroups } from "./groups"; // Unpack the named Collections we use. -const { Jobs, Packages, Shops, Groups } = Collections; +const { Jobs, Packages, Shops } = Collections; export default { @@ -43,7 +44,7 @@ export default { this.loadPackages(); // process imports from packages and any hooked imports this.Import.flush(); - this.createDefaultGroups(); + this.createGroups(); // timing is important, packages are rqd for initial permissions configuration. if (!Meteor.isAppTest) { this.createDefaultAdminUser(); @@ -65,60 +66,7 @@ export default { }, defaultCustomerRoles: [ "guest", "account/profile", "product", "tag", "index", "cart/checkout", "cart/completed"], defaultVisitorRoles: ["anonymous", "guest", "product", "tag", "index", "cart/checkout", "cart/completed"], - createDefaultGroups(options = {}) { - const self = this; - const { shopId } = options; - const allGroups = Groups.find({}).fetch(); - const query = {}; - - if (shopId) { - query._id = shopId; - } - - const shops = Shops.find(query).fetch(); - - /* Get all defined roles from the DB minus "anonymous" because that gets removed from a user on register - * if it's not removed, it causes mismatch between roles in user (i.e Meteor.user().roles[shopId]) vs that in - * the user's group (Group.find(usergroup).permissions) */ - let ownerRoles = Roles - .getAllRoles().fetch() - .map(role => role.name) - .filter(role => role !== "anonymous"); // see comment above - - // Join all other roles with package roles for owner. Owner should have all roles - // this is needed because of default roles defined in the app that are not in Roles.getAllRoles - ownerRoles = ownerRoles.concat(this.defaultCustomerRoles); - ownerRoles = _.uniq(ownerRoles); - - // we're making a Shop Manager default group that have all roles minue the owner role - const shopManagerRoles = ownerRoles.filter(role => role !== "owner"); - const roles = { - "shop manager": shopManagerRoles, - "customer": this.defaultCustomerRoles, - "guest": this.defaultVisitorRoles, - "owner": ownerRoles - }; - - if (shops && shops.length) { - shops.forEach(shop => createGroupsForShop(shop)); - } - function createGroupsForShop(shop) { - Object.keys(roles).forEach(groupKeys => { - const groupExists = allGroups.find(grp => grp.slug === groupKeys && grp.shopId === shop._id); - if (!groupExists) { // create group only if it doesn't exist before - // get roles from the default groups of the primary shop; we try to use this first before using default roles - const primaryShopGroup = allGroups.find(grp => grp.slug === groupKeys && grp.shopId === self.getPrimaryShopId()); - Logger.debug(`creating group ${groupKeys} for shop ${shop.name}`); - Groups.insert({ - name: groupKeys, - slug: groupKeys, - permissions: primaryShopGroup && primaryShopGroup.permissions || roles[groupKeys], - shopId: shop._id - }); - } - }); - } - }, + createGroups, /** * canInviteToGroup * @summary checks if the user making the request is allowed to make invitation to that group diff --git a/server/api/core/groups.js b/server/api/core/groups.js new file mode 100644 index 00000000000..ef5d38669a7 --- /dev/null +++ b/server/api/core/groups.js @@ -0,0 +1,68 @@ +import _ from "lodash"; +import { Roles } from "meteor/alanning:roles"; +import { Logger, Reaction } from "/server/api"; +import { Shops, Groups } from "/lib/collections"; + +export function createGroups(options = {}) { + const { shopId } = options; + let { roles } = options; + const allGroups = Groups.find({}).fetch(); + const query = {}; + + if (!roles) { + roles = getDefaultGroupRoles(); + } + + if (shopId) { + query._id = shopId; + } + + const shops = Shops.find(query).fetch(); + + if (shops && shops.length) { + shops.forEach((shop) => createGroupsForShop(shop)); + } + function createGroupsForShop(shop) { + Object.keys(roles).forEach((groupKey) => { + const groupExists = allGroups.find((grp) => grp.slug === groupKey && grp.shopId === shop._id); + if (!groupExists) { // create group only if it doesn't exist before + // get roles from the default groups of the primary shop; we try to use this first before using default roles + const primaryShopGroup = allGroups.find((grp) => grp.slug === groupKey && grp.shopId === Reaction.getPrimaryShopId()); + Logger.debug(`creating group ${groupKey} for shop ${shop.name}`); + Groups.insert({ + name: groupKey, + slug: groupKey, + permissions: primaryShopGroup && primaryShopGroup.permissions || roles[groupKey], + shopId: shop._id + }); + } + }); + } +} + +function getDefaultGroupRoles() { + /* Get all defined roles from the DB except "anonymous" because that gets removed from a user on register + * if it's not removed, it causes mismatch between roles in user (i.e Meteor.user().roles[shopId]) vs that in + * the user's group (Group.find(usergroup).permissions) */ + let ownerRoles = Roles + .getAllRoles().fetch() + .map(role => role.name) + .filter(role => role !== "anonymous"); // see comment above + + // Join all other roles with package roles for owner. Owner should have all roles + // this is needed because of default roles defined in the app that are not in Roles.getAllRoles + ownerRoles = ownerRoles.concat(Reaction.defaultCustomerRoles); + ownerRoles = _.uniq(ownerRoles); + + // we're making a Shop Manager default group that have all roles except the owner role + const shopManagerRoles = ownerRoles.filter((role) => role !== "owner"); + + const roles = { + "shop manager": shopManagerRoles, + "customer": Reaction.defaultCustomerRoles, + "guest": Reaction.defaultVisitorRoles, + "owner": ownerRoles + }; + + return roles; +} From 2f8e10bdf8b985a01a200b9c98fa246746d18914 Mon Sep 17 00:00:00 2001 From: Seun Martins Date: Tue, 17 Oct 2017 13:11:08 +0100 Subject: [PATCH 02/59] Update test ref causing test failure --- .../server/migrations/5_update_defaultRoles_to_groups.js | 2 +- server/methods/core/shop.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/plugins/core/versions/server/migrations/5_update_defaultRoles_to_groups.js b/imports/plugins/core/versions/server/migrations/5_update_defaultRoles_to_groups.js index 48cc384af70..aa5bab3a4f2 100644 --- a/imports/plugins/core/versions/server/migrations/5_update_defaultRoles_to_groups.js +++ b/imports/plugins/core/versions/server/migrations/5_update_defaultRoles_to_groups.js @@ -53,7 +53,7 @@ Migrations.add({ const { defaultRoles, defaultVisitorRole } = shop; let ownerRoles = Roles.getAllRoles().fetch().map(role => role.name); - // See detailed comment in Reaction.createDefaultGroups. The code here follows similar pattern. + // See detailed comment in `/server/api/core/groups.js`. The code here follows similar pattern. ownerRoles = ownerRoles.concat(Reaction.defaultCustomerRoles); ownerRoles = _.uniq(ownerRoles); diff --git a/server/methods/core/shop.js b/server/methods/core/shop.js index 1e8769f0909..ad46e641236 100644 --- a/server/methods/core/shop.js +++ b/server/methods/core/shop.js @@ -120,7 +120,7 @@ Meteor.methods({ // update user Reaction.insertPackagesForShop(shop._id); - Reaction.createDefaultGroups({ shopId: shop._id }); + Reaction.createGroups({ shopId: shop._id }); const ownerGroup = Collections.Groups.findOne({ slug: "owner", shopId: shop._id }); Roles.addUsersToRoles([currentUser, shopUser._id], ownerGroup.permissions, shop._id); Collections.Accounts.update({ _id: shopUser._id }, { From e0c1c13cce4c62d0ebc2970e97e33e9cdcd7be11 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 16:44:22 -0700 Subject: [PATCH 03/59] add @typedef for SimpleSchema. add jsdoc for TaxSettings, Profile, Email, Accounts. add @namespace for Schema to hold all methods and constants for schemas. --- lib/collections/schemas/accounts.js | 56 +++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/lib/collections/schemas/accounts.js b/lib/collections/schemas/accounts.js index 213952c5e2e..6d02e582c18 100644 --- a/lib/collections/schemas/accounts.js +++ b/lib/collections/schemas/accounts.js @@ -5,9 +5,23 @@ import { Metafield } from "./metafield"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Accounts Schemas + * @typedef {SimpleSchema} SimpleSchema + * @summary SimpleSchema for Collections - Reaction uses {@link https://github.com/aldeed/meteor-simple-schema SimpleSchema} to apply basic content and structure validation to Collections. See {@link https://docs.reactioncommerce.com/reaction-docs/master/simple-schema full documentation}. */ +/** + * @file Reaction Core schemas + * Reaction uses {@link https://github.com/aldeed/meteor-simple-schema SimpleSchema} to apply basic content and structure validation to Collections. See {@link https://docs.reactioncommerce.com/reaction-docs/master/simple-schema full documentation}. + * @namespace schemas + */ + +/** + * @name TaxSettings + * @memberof schemas + * @type {SimpleSchema} + * @property {String} exemptionNo optional + * @property {String} customerUsageType optional + */ const TaxSettings = new SimpleSchema({ exemptionNo: { type: String, @@ -21,6 +35,18 @@ const TaxSettings = new SimpleSchema({ registerSchema("TaxSettings", TaxSettings); +/** + * @name Profile + * @memberof schemas + * @type {SimpleSchema} + * @property {Address[]} addressBook optional, array of Addresses + * @property {Boolean} invited optional + * @property {String} name optional + * @property {String} picture optional + * @property {String} bio optional + * @property {String} username optional + * @property {String} currency User currency + */ export const Profile = new SimpleSchema({ addressBook: { type: [Address], @@ -56,6 +82,14 @@ export const Profile = new SimpleSchema({ registerSchema("Profile", Profile); +/** + * @name Email + * @memberof schemas + * @type {SimpleSchema} + * @property {String} provides optional + * @property {String} address required + * @property {Boolean} verified optional + */ export const Email = new SimpleSchema({ provides: { type: String, @@ -76,9 +110,25 @@ export const Email = new SimpleSchema({ registerSchema("Email", Email); /** - * Reaction Schemas Accounts + * @name Accounts + * @memberof schemas + * @type {SimpleSchema} + * @property {String} userId required + * @property {String[]} sessions optional, Array of strings + * @property {String} shopId required + * @property {String} name optional + * @property {String} username optional + * @property {Email[]} emails optional, Array of strings + * @property {Boolean} acceptsMarketing optional + * @property {String} state optional + * @property {TaxSettings} taxSettings optional + * @property {String} note optional + * @property {Profile} profile optional + * @property {String[]} groups optional, Array of groupIds of the groups the user belongs to + * @property {Metafield[]} metafields optional + * @property {Date} createdAt required + * @property {Date} updatedAt optional */ - export const Accounts = new SimpleSchema({ userId: { type: String, From 7f7a52aa70054d5c8a35a1b0838c8e5b3ff14cfc Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 16:44:49 -0700 Subject: [PATCH 04/59] add schema helper methods as @memberof schemas --- lib/collections/schemas/helpers.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/collections/schemas/helpers.js b/lib/collections/schemas/helpers.js index 07aca65f37f..be246f331c1 100644 --- a/lib/collections/schemas/helpers.js +++ b/lib/collections/schemas/helpers.js @@ -4,10 +4,12 @@ import { Reaction } from "/lib/api"; import { Shops } from "/lib/collections"; /** - * shopIdAutoValue - * @summary used for schema injection autoValue + * @name shopIdAutoValue + * @memberof schemas + * @method + * @summary Helper method used for schema injection autoValue * @example autoValue: shopIdAutoValue - * @return {String} returns current shopId + * @return {String} current shopId */ export function shopIdAutoValue() { // we should always have a shopId @@ -20,8 +22,10 @@ export function shopIdAutoValue() { } /** - * shopIdAutoValueForCart - * @summary copy of shopIdAutoValue with modification for Cart + * @name shopIdAutoValueForCart + * @memberof schemas + * @method + * @summary Helper method copy of shopIdAutoValue with modification for Cart * @example autoValue: shopIdAutoValue * @return {String} shopId */ @@ -42,10 +46,12 @@ export function shopIdAutoValueForCart() { } /** - * schemaIdAutoValue - * @summary used for schema injection autoValue + * @name schemaIdAutoValue + * @memberof schemas + * @method + * @summary Helper method used for schema injection autoValue * @example autoValue: schemaIdAutoValue - * @return {String} returns randomId + * @return {String} randomId */ export function schemaIdAutoValue() { if (this.isSet && Meteor.isServer) { @@ -58,10 +64,12 @@ export function schemaIdAutoValue() { } /** - * shopDefaultCountry - * @summary used for schema injection autoValue + * @name shopDefaultCountry + * @memberof schemas + * @method + * @summary Helper method used for schema injection autoValue * @example autoValue: shopDefaultCountry - * @return {String} returns country value from default shop + * @return {String} country value from default shop */ export function shopDefaultCountry() { try { From 7227640c29930a781b57815615334f2dbe243154 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 16:45:23 -0700 Subject: [PATCH 05/59] add Assets schema as @memberof schemas --- lib/collections/schemas/assets.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/collections/schemas/assets.js b/lib/collections/schemas/assets.js index 8c51c601f24..96ba353d2e9 100644 --- a/lib/collections/schemas/assets.js +++ b/lib/collections/schemas/assets.js @@ -1,6 +1,16 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Assets + * @memberof schemas + * @type {SimpleSchema} + * @property {String} type required + * @property {String} name optional + * @property {String} ns optional, namespace for i18n. Allows to load translation for custom plugins. + * @property {String} path optional + * @property {String} content optional + */ export const Assets = new SimpleSchema({ type: { type: String @@ -9,9 +19,6 @@ export const Assets = new SimpleSchema({ type: String, optional: true }, - /** - * namespace for i18n. This allows to load translation for custom plugins - */ ns: { type: String, optional: true From ec86a38348da24102a9d20221edfc60f5e5aa409 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 16:48:36 -0700 Subject: [PATCH 06/59] example: documenting a schema within a plugin - document Webhook, ShopifyProduct, ShopifyConnectPackageConfig as @type {SimpleSchema} within @module connectors-shopify --- .../lib/collections/schemas/shopifyConnect.js | 25 +++++++++++++++++++ .../server/collections/shopifyProduct.js | 12 +++++++++ 2 files changed, 37 insertions(+) diff --git a/imports/plugins/included/connectors-shopify/lib/collections/schemas/shopifyConnect.js b/imports/plugins/included/connectors-shopify/lib/collections/schemas/shopifyConnect.js index 116ac81af0d..b108bee9bba 100644 --- a/imports/plugins/included/connectors-shopify/lib/collections/schemas/shopifyConnect.js +++ b/imports/plugins/included/connectors-shopify/lib/collections/schemas/shopifyConnect.js @@ -2,6 +2,22 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { PackageConfig } from "/lib/collections/schemas/registry"; import { registerSchema } from "/imports/plugins/core/collections"; +/** + * @file ShopifyProduct + * + * @module connectors-shopify + */ + +/** + * @name Webhook + * @type {SimpleSchema} + * @property {Number} shopifyId Shopify webhook ID + * @property {String} topic Shopify webhook topic + * @property {String} address URL webhook will POST to + * @property {String} format Format of webhook data + * @property {Array} integrations Array of integration strings using this webhook + * @property {String} description Shopify webhook description, currently unused + */ const Webhook = new SimpleSchema({ shopifyId: { type: Number, @@ -35,6 +51,15 @@ const Webhook = new SimpleSchema({ registerSchema("Webhook", Webhook); +/** + * @name ShopifyConnectPackageConfig + * @type {SimpleSchema} + * @property {String} settings.apiKey Shopify API key + * @property {String} settings.password Shopify API password + * @property {String} settings.sharedSecret Shopify API shared secret + * @property {String} settings.shopName Shop slug + * @property {Array} settings.webhooks Array of registered Shopify webhooks + */ export const ShopifyConnectPackageConfig = new SimpleSchema([ PackageConfig, { "settings.apiKey": { diff --git a/imports/plugins/included/connectors-shopify/server/collections/shopifyProduct.js b/imports/plugins/included/connectors-shopify/server/collections/shopifyProduct.js index 2f91ebe5d3d..c8d306d59e4 100644 --- a/imports/plugins/included/connectors-shopify/server/collections/shopifyProduct.js +++ b/imports/plugins/included/connectors-shopify/server/collections/shopifyProduct.js @@ -2,6 +2,18 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { Products } from "/lib/collections"; import { registerSchema } from "/imports/plugins/core/collections"; +/** + * @file ShopifyProduct + * + * @module connectors-shopify + */ + +/** + * @name ShopifyProduct + * @summary ShopifyProduct schema attached to Products type "simple" and "variant" + * @type {SimpleSchema} + * @property {Number} shopifyId Shopify ID + */ export const ShopifyProduct = new SimpleSchema({ shopifyId: { type: Number, From e2cda14faff90deb731207fcda77b13fb9ce4735 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 17:58:19 -0700 Subject: [PATCH 07/59] documents Address, AnalyticsEvents, ReactionAnalyticsPackageConfig schemas --- lib/collections/schemas/address.js | 22 +++++++++++++++++--- lib/collections/schemas/analytics.js | 31 +++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/lib/collections/schemas/address.js b/lib/collections/schemas/address.js index 31987670b88..26b8f31427f 100644 --- a/lib/collections/schemas/address.js +++ b/lib/collections/schemas/address.js @@ -4,9 +4,25 @@ import { Metafield } from "./metafield"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** -* Reaction Schemas Address -*/ - + * @name Address + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id + * @property {String} fullName, required + * @property {String} address1, required + * @property {String} address2 + * @property {String} city, required + * @property {String} company + * @property {String} phone, required + * @property {String} region, required, State/Province/Region + * @property {String} postal, required + * @property {String} country, required + * @property {Boolean} isCommercial, required + * @property {Boolean} isBillingDefault, required + * @property {Boolean} isShippingDefault, required + * @property {Boolean} failedValidation + * @property {Metafield[]} metafields + */ export const Address = new SimpleSchema({ _id: { type: String, diff --git a/lib/collections/schemas/analytics.js b/lib/collections/schemas/analytics.js index b05890e0f7d..ae00b827fa5 100644 --- a/lib/collections/schemas/analytics.js +++ b/lib/collections/schemas/analytics.js @@ -6,6 +6,22 @@ import { PackageConfig } from "./registry"; import { shopIdAutoValue } from "./helpers"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name AnalyticsEvents + * @memberof schemas + * @type {SimpleSchema} + * @property {String} eventType, required + * @property {String} category + * @property {String} action + * @property {String} label + * @property {String} value + * @property {Object} user + * @property {String} user.id + * @property {Boolean} user.isAnonymous + * @property {String} shopId AnaltyicsEvents shopId + * @property {Date} createdAt + * @property {Object} data Any additional data + */ export const AnalyticsEvents = new SimpleSchema({ "eventType": { type: String @@ -57,7 +73,6 @@ export const AnalyticsEvents = new SimpleSchema({ return new Date; } }, - // Any additional data "data": { type: Object, blackbox: true, @@ -67,11 +82,17 @@ export const AnalyticsEvents = new SimpleSchema({ registerSchema("AnalyticsEvents", AnalyticsEvents); -/* - * Analytics - * api_key: "UA-XXXXX-X" (this is your tracking ID) +/** + * @name ReactionAnalyticsPackageConfig + * @memberof schemas + * @type {SimpleSchema} + * @property {Boolean} settings.public.segmentio.enabled Enable Segment.io + * @property {String} settings.public.segmentio.api_key Segment.io Write Key + * @property {Boolean} settings.public.googleAnalytics.enabled Enable Google Analytics + * @property {String} settings.public.googleAnalytics.api_key Google Analytics API Key, "UA-XXXXX-X" + * @property {Boolean} settings.public.mixpanel.enabled Enable Mixpanel + * @property {String} settings.public.mixpanel.api_key Mixpanel API Key */ - export const ReactionAnalyticsPackageConfig = new SimpleSchema([ PackageConfig, { "settings.public.segmentio.enabled": { From 319777649b5458a4ff01f4a6b393f5f080a32738 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 19:36:59 -0700 Subject: [PATCH 08/59] jsdoc: add Meteor/Accounts methods as a @namespace with methods from 3 different files - accounts-passwords.js, accounts.js, serviceConfiguration.js --- server/methods/accounts/accounts-password.js | 11 +- server/methods/accounts/accounts.js | 217 +++++++++++------- .../methods/accounts/serviceConfiguration.js | 11 +- 3 files changed, 154 insertions(+), 85 deletions(-) diff --git a/server/methods/accounts/accounts-password.js b/server/methods/accounts/accounts-password.js index 077d1926b07..721a9055865 100644 --- a/server/methods/accounts/accounts-password.js +++ b/server/methods/accounts/accounts-password.js @@ -4,8 +4,17 @@ import { check } from "meteor/check"; import { Accounts } from "meteor/accounts-base"; import { Reaction, Logger } from "/server/api"; +/** + * @name sendResetPasswordEmail + * @memberof Meteor/Accounts + * @method + * @example Meteor.call("accounts/sendResetPasswordEmail", options) + * @summary Send reset password email + * @param {Object} options + * @param {String} options.email - email of user + * @returns {false} + */ Meteor.methods({ - "accounts/sendResetPasswordEmail"(options) { check(options, { email: String diff --git a/server/methods/accounts/accounts.js b/server/methods/accounts/accounts.js index 4acc734092b..21589d385c2 100644 --- a/server/methods/accounts/accounts.js +++ b/server/methods/accounts/accounts.js @@ -12,13 +12,21 @@ import * as Schemas from "/lib/collections/schemas"; import { Logger, Reaction } from "/server/api"; import { sendUpdatedVerificationEmail } from "/server/api/core/accounts"; +/** + * @file Meteor methods for Accounts + * Reaction extends {@link https://github.com/meteor/meteor/tree/master/packages/accounts-base MeteorAccounts} with Reaction-specific behavior and user interaction. + * @namespace Meteor/Accounts + */ /** - * verifyAccount - * @summary verify registered user account + * @name verifyAccount + * @memberof Meteor/Accounts + * @method + * @summary Verify registered user account + * @example Meteor.call("accounts/verifyAccount", email, token) * @param {String} email - user email * @param {String} token - user token, if the user is invited - * @returns {Boolean} - returns boolean + * @returns {Boolean} - return True on success */ export function verifyAccount(email, token) { check(email, String); @@ -60,12 +68,13 @@ export function verifyAccount(email, token) { return false; } - /** - * updateEmailAddress - * @summary update a user's email address. - * @param {String} email - user email. - * @returns {Boolean} - returns boolean. + * @name updateEmailAddress + * @memberof Meteor/Accounts + * @method + * @summary Update a user's email address + * @param {String} email - user email + * @returns {Boolean} - return True on success */ export function updateEmailAddress(email) { check(email, String); @@ -77,10 +86,11 @@ export function updateEmailAddress(email) { return true; } - /** - * removeEmailAddress - * @summary remove a user's email address. + * @name removeEmailAddress + * @memberof Meteor/Accounts + * @method + * @summary Remove a user's email address. * @param {String} email - user email. * @returns {Boolean} - returns boolean. */ @@ -101,11 +111,11 @@ export function removeEmailAddress(email) { return true; } - /** - * syncUsersAndAccounts - * @summary syncs emails associated with a user profile between the Users and - * Accounts collections. + * @name syncUsersAndAccounts + * @memberof Meteor/Accounts + * @method + * @summary Syncs emails associated with a user profile between the Users and Accounts collections. * @returns {Boolean} - returns boolean. */ export function syncUsersAndAccounts() { @@ -124,10 +134,11 @@ export function syncUsersAndAccounts() { return true; } - /** + * @name getValidator * @summary Returns the name of the geocoder method to use * @returns {string} Name of the Geocoder method to use + * @private */ function getValidator() { const shopId = Reaction.getShopId(); @@ -170,10 +181,12 @@ function getValidator() { } /** + * @name compareAddress * @summary Compare individual fields of address and accumulate errors * @param {Object} address - the address provided by the customer * @param {Object} validationAddress - address provided by validator * @returns {Object} An object with an array of errors per field + * @private */ function compareAddress(address, validationAddress) { const errors = { @@ -249,6 +262,9 @@ function compareAddress(address, validationAddress) { } /** + * @name validateAddress + * @memberof Meteor/Accounts + * @method * @summary Validates an address, and if fails returns details of issues * @param {Object} address - The address object to validate * @returns {{validated: boolean, address: *}} - The results of the validation @@ -281,22 +297,26 @@ export function validateAddress(address) { return validationResults; } -/* - * check if current user has password - */ +/** + * @name currentUserHasPassword + * @summary Check if current user has password + * @returns {Boolean} True if current user has password + * @private + */ function currentUserHasPassword() { const user = Meteor.users.findOne(Meteor.userId()); return !!user.services.password; } /** - * addressBookAdd - * @description add new addresses to an account + * @name addressBookAdd + * @memberof Meteor/Accounts + * @method + * @summary Add new addresses to an account + * @example Meteor.call("accounts/addressBookAdd", address, callBackFunction(error, result)) * @param {Object} address - address - * @param {String} [accountUserId] - `account.userId` used by admin to edit - * users - * @return {Object} with keys `numberAffected` and `insertedId` if doc was - * inserted + * @param {String} [accountUserId] - `account.userId` used by admin to edit users + * @return {Object} with keys `numberAffected` and `insertedId` if doc was inserted */ export function addressBookAdd(address, accountUserId) { check(address, Schemas.Address); @@ -383,14 +403,15 @@ export function addressBookAdd(address, accountUserId) { } /** - * addressBookUpdate - * @description update existing address in user's profile - * @param {Object} address - address - * @param {String|null} [accountUserId] - `account.userId` used by admin to - * edit users - * @param {shipping|billing} [type] - name of selected address type - * @return {Number} The number of affected documents - */ + * @name addressBookUpdate + * @memberof Meteor/Accounts + * @method + * @description update existing address in user's profile + * @param {Object} address - address + * @param {String|null} [accountUserId] - `account.userId` used by admin to edit users + * @param {shipping|billing} [type] - name of selected address type + * @return {Number} The number of affected documents + */ export function addressBookUpdate(address, accountUserId, type) { check(address, Schemas.Address); check(accountUserId, Match.OneOf(String, null, undefined)); @@ -501,13 +522,14 @@ export function addressBookUpdate(address, accountUserId, type) { } /** - * addressBookRemove - * @description remove existing address in user's profile - * @param {String} addressId - address `_id` - * @param {String} [accountUserId] - `account.userId` used by admin to edit - * users - * @return {Number|Object} The number of removed documents or error object - */ + * @name addressBookRemove + * @memberof Meteor/Accounts + * @method + * @summary Remove existing address in user's profile + * @param {String} addressId - address `_id` + * @param {String} [accountUserId] - `account.userId` used by admin to edit users + * @return {Number|Object} The number of removed documents or error object + */ export function addressBookRemove(addressId, accountUserId) { check(addressId, String); check(accountUserId, Match.Optional(String)); @@ -538,8 +560,10 @@ export function addressBookRemove(addressId, accountUserId) { } /** - * inviteShopOwner - * invite a new user as owner of a new shop + * @name inviteShopOwner + * @summary Invite a new user as owner of a new shop + * @memberof Meteor/Accounts + * @method * @param {Object} options - * @param {String} options.email - email of invitee * @param {String} options.name - name of invitee @@ -603,17 +627,17 @@ export function inviteShopOwner(options) { } /** - * inviteShopMember - * invite new admin users - * (not consumers) to secure access in the dashboard - * to permissions as specified in packages/roles - * @param {Object} options - - * @param {String} options.shopId - shop to invite user - * @param {String} options.groupId - groupId to invite user - * @param {String} options.email - email of invitee - * @param {String} options.name - name of invitee - * @returns {Boolean} returns true - */ + * @name inviteShopMember + * @summary Invite new admin users (not consumers) to secure access in the dashboard to permissions as specified in packages/roles + * @memberof Meteor/Accounts + * @method + * @param {Object} options - + * @param {String} options.shopId - shop to invite user + * @param {String} options.groupId - groupId to invite user + * @param {String} options.email - email of invitee + * @param {String} options.name - name of invitee + * @returns {Boolean} returns true + */ export function inviteShopMember(options) { const { shopId, email, name, groupId } = options; check(options, Object); @@ -695,14 +719,15 @@ export function inviteShopMember(options) { return true; } - /** - * accounts/sendWelcomeEmail - * send an email to consumers on sign up - * @param {String} shopId - shopId of new User - * @param {String} userId - new userId to welcome - * @returns {Boolean} returns boolean - */ + * @name sendWelcomeEmail + * @summary Send an email to consumers on sign up + * @memberof Meteor/Accounts + * @method + * @param {String} shopId - shopId of new User + * @param {String} userId - new userId to welcome + * @returns {Boolean} returns boolean + */ export function sendWelcomeEmail(shopId, userId) { check(shopId, String); check(userId, String); @@ -795,16 +820,14 @@ export function sendWelcomeEmail(shopId, userId) { } /** - * accounts/addUserPermissions - * @param {String} userId - userId - * @param {Array|String} permissions - - * Name of role/permission. If array, users - * returned will have at least one of the roles - * specified but need not have _all_ roles. - * @param {String} [group] Optional name of group to restrict roles to. - * User"s Roles.GLOBAL_GROUP will also be checked. - * @returns {Boolean} success/failure - */ + * @name addUserPermissions + * @memberof Meteor/Accounts + * @method + * @param {String} userId - userId + * @param {Array|String} permissions - Name of role/permission. If array, users returned will have at least one of the roles specified but need not have _all_ roles. + * @param {String} [group] Optional name of group to restrict roles to. User's Roles.GLOBAL_GROUP will also be checked. + * @returns {Boolean} success/failure + */ export function addUserPermissions(userId, permissions, group) { if (!Reaction.hasPermission("reaction-accounts", Meteor.userId(), group)) { throw new Meteor.Error(403, "Access denied"); @@ -820,8 +843,14 @@ export function addUserPermissions(userId, permissions, group) { } } -/* - * removeUserPermissions +/** + * @name removeUserPermissions + * @memberof Meteor/Accounts + * @method + * @param {String} userId - userId + * @param {Array|String} permissions - Name of role/permission. If array, users returned will have at least one of the roles specified but need not have _all_ roles. + * @param {String} [group] Optional name of group to restrict roles to. + * @returns {Boolean} success/failure */ export function removeUserPermissions(userId, permissions, group) { if (!Reaction.hasPermission("reaction-accounts", Meteor.userId(), group)) { @@ -831,7 +860,6 @@ export function removeUserPermissions(userId, permissions, group) { check(permissions, Match.OneOf(String, Array)); check(group, Match.Optional(String, null)); this.unblock(); - try { return Roles.removeUsersFromRoles(userId, permissions, group); } catch (error) { @@ -841,7 +869,9 @@ export function removeUserPermissions(userId, permissions, group) { } /** - * accounts/setUserPermissions + * @name setUserPermissions + * @memberof Meteor/Accounts + * @method * @param {String} userId - userId * @param {String|Array} permissions - string/array of permissions * @param {String} group - group @@ -863,7 +893,15 @@ export function setUserPermissions(userId, permissions, group) { } } -// Get shop logo, if available. If not, use default logo from file-system +/** + * @name getEmailLogo + * @memberof Meteor/Accounts + * @summary Get shop logo, if available. If not, use default logo from file-system + * @method + * @private + * @param {Object} shop - shop + * @return {String} Email logo path + */ function getEmailLogo(shop) { let emailLogo; if (Array.isArray(shop.brandAssets)) { @@ -876,6 +914,14 @@ function getEmailLogo(shop) { return emailLogo; } +/** + * @name getCurrentUserName + * @memberof Meteor/Accounts + * @method + * @private + * @param {Object} currentUser - User + * @return {String} Name of currentUser or "Admin" + */ function getCurrentUserName(currentUser) { if (currentUser && currentUser.profile && currentUser.profile.name) { return currentUser.profile.name; @@ -892,6 +938,14 @@ function getCurrentUserName(currentUser) { return "Admin"; } +/** + * @name getDataForEmail + * @memberof Meteor/Accounts + * @method + * @private + * @param {Object} options - shop, currentUserName, token, emailLogo, name + * @return {Object} data - primaryShop, shop, contactEmail, homepage, emailLogo, legalName, physicalAddress, shopName, socialLinks, user, invitedUserName, url + */ function getDataForEmail(options) { const { shop, currentUserName, token, emailLogo, name } = options; const primaryShop = Shops.findOne(Reaction.getPrimaryShopId()); @@ -944,11 +998,11 @@ function getDataForEmail(options) { } /** - * accounts/createFallbackLoginToken - * @returns {String} returns a new loginToken for current user, - * that can be used for special login scenarios - e.g. store the - * newly created token as cookie on the browser, if the client - * does not offer local storage. + * @name createFallbackLoginToken + * @memberof Meteor/Accounts + * @method + * @summary Returns a new loginToken for current user, that can be used for special login scenarios - e.g. store the newly created token as cookie on the browser, if the client does not offer local storage. + * @returns {String} loginToken for current user */ export function createFallbackLoginToken() { if (this.userId) { @@ -959,9 +1013,6 @@ export function createFallbackLoginToken() { } } -/** - * Reaction Account Methods - */ Meteor.methods({ "accounts/verifyAccount": verifyAccount, "accounts/validateAddress": validateAddress, diff --git a/server/methods/accounts/serviceConfiguration.js b/server/methods/accounts/serviceConfiguration.js index 07eac003480..1e91dba50d4 100644 --- a/server/methods/accounts/serviceConfiguration.js +++ b/server/methods/accounts/serviceConfiguration.js @@ -4,7 +4,16 @@ import { check } from "meteor/check"; import { ServiceConfiguration } from "meteor/service-configuration"; import { Reaction } from "/server/api"; - +/** + * @name updateServiceConfiguration + * @memberof Meteor/Accounts + * @method + * @example Meteor.call("accounts/updateServiceConfiguration", service, fields, (callBackFunction)) + * @summary Update service configuration + * @param {String} service + * @param {Array} fields + * @returns {false} + */ Meteor.methods({ "accounts/updateServiceConfiguration": function (service, fields) { check(service, String); From a6fdbe0d9f6b7f2450e5883872dba23ccf85bf0a Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 19:57:51 -0700 Subject: [PATCH 09/59] jsdoc: use @summary over @description --- server/methods/accounts/accounts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/methods/accounts/accounts.js b/server/methods/accounts/accounts.js index 21589d385c2..bd02f42261b 100644 --- a/server/methods/accounts/accounts.js +++ b/server/methods/accounts/accounts.js @@ -406,7 +406,7 @@ export function addressBookAdd(address, accountUserId) { * @name addressBookUpdate * @memberof Meteor/Accounts * @method - * @description update existing address in user's profile + * @summary Update existing address in user's profile * @param {Object} address - address * @param {String|null} [accountUserId] - `account.userId` used by admin to edit users * @param {shipping|billing} [type] - name of selected address type From c04ad2d453eb693e44f5090bf8e7c31ad944a752 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 17 Oct 2017 20:04:27 -0700 Subject: [PATCH 10/59] jsdoc: add Meteor/Accounts/Validation methods as separate @namespace --- lib/api/account-validation.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/api/account-validation.js b/lib/api/account-validation.js index 6d1f12a9dee..10f6e1e5f6a 100644 --- a/lib/api/account-validation.js +++ b/lib/api/account-validation.js @@ -1,10 +1,18 @@ import { Meteor } from "meteor/meteor"; import { check, Match } from "meteor/check"; +/** + * @file Methods for Account Validation + * Methods for validating account username, email and password. Methods are exported globally in the `LoginFormValidation` object and they are also registered as Meteor methods. + * @namespace Meteor/Accounts/Validation + */ + const validationMethods = { /** - * Username validation - * @summary Determins if a username meets the minimum requirement of 3 characters + * @name username + * @method + * @memberof Meteor/Accounts/Validation + * @summary Determines if a username meets the minimum requirement of 3 characters * @param {String} username Username to validate * @return {Boolean|Object} true if valid, error object if invalid */ @@ -25,8 +33,12 @@ const validationMethods = { }, /** - * Email validation + * @name email + * @method + * @memberof Meteor/Accounts/Validation * @summary Validates both required and optional email addresses. + * @example LoginFormValidation.email(emailAddress) + * @example Meteor.call("accounts/validation/email", newEmail, false, callbackFunction()) * @param {String} email Email address to validate * @param {Boolean} optional If set to true, validation will pass if email is blank * @return {Boolean|Object} Returns true if valid; Returns an error object if invalid @@ -53,10 +65,11 @@ const validationMethods = { }, /** - * Password validation - * Passwords may be validated 2 ways. - * "exists" (options.validationLevel = "exists") - Password must not be blank. Thats is the only rule. Used to validate a sign in. - * undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. Used for validating a new sign up. + * @name password + * @method + * @memberof Meteor/Accounts/Validation + * @summary Passwords may be validated 2 ways. 1. "exists" (options.validationLevel = "exists") - Password must not be blank. Thats is the only rule. Used to validate a sign in. 2. undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. Used for validating a new sign up. + * @example LoginFormValidation.password(pword, { validationLevel: "exists" }) * @param {String} password Password to validate * @param {Object} options Options to apply to the password validator * @param {String} options.validationLevel "exists" | undefined (default) From f676a6035056add4ba15949a9e2d3d4b00b3fa3a Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 14:36:21 -0700 Subject: [PATCH 11/59] document Cart schemas --- lib/collections/schemas/cart.js | 63 +++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/lib/collections/schemas/cart.js b/lib/collections/schemas/cart.js index 6e1d543af3b..1c7299f795f 100644 --- a/lib/collections/schemas/cart.js +++ b/lib/collections/schemas/cart.js @@ -8,9 +8,25 @@ import { Metafield } from "./metafield"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * CartItem Schema + * @name CartItem + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id, required + * @property {String} productId, required + * @property {String} shopId, Cart Item shopId + * @property {Number} quantity, required + * @property {Product} product, required + * @property {ProductVariant} variants, required + * @property {Metafield[]} metafields + * @property {String} title, Cart Item title + * @property {String} type, Product type + * @property {ShippingParcel} parcel, Note: Currently the parcel is in the simple product schema, so we need to include it here as well. + * @property {String} cartItemId, Note: Seems strange here but has to be here since we share schemas between cart and order + * @property {Object} transaction, Transaction associated with this item + * @property {Object} taxData optional, blackbox + * @property {Number} taxRate optional + * @property {Object} shippingMethod, Shipping Method associated with this item */ - export const CartItem = new SimpleSchema({ _id: { type: String @@ -50,15 +66,15 @@ export const CartItem = new SimpleSchema({ type: String, optional: true }, - parcel: { // Currently the parcel is in the simple product schema, so we need to include it here as well. Maybe it should go in productvariant - type: ShippingParcel, + parcel: { + type: ShippingParcel, // @todo Maybe it should go in productvariant optional: true }, - cartItemId: { // Seems strange here but has to be here since we share schemas between cart and order + cartItemId: { type: String, optional: true }, - transaction: { // Transaction associated with this item. + transaction: { type: Object, optional: true, blackbox: true @@ -73,20 +89,22 @@ export const CartItem = new SimpleSchema({ decimal: true, optional: true }, - shippingMethod: { // Shipping Method associated with this item + shippingMethod: { type: Object, optional: true, - blackbox: true // Revert this to schema at some point + blackbox: true // @todo Revert this to schema at some point } }); registerSchema("CartItem", CartItem); /** - * CartItem Schema - * used in check by inventory/addReserve method + * @name CartItems + * @memberof schemas + * @summary Used in check by inventory/addReserve method + * @type {SimpleSchema} + * @property {CartItem[]} items, an Array of CartItem, optional */ - export const CartItems = new SimpleSchema({ items: { type: [CartItem], @@ -97,11 +115,27 @@ export const CartItems = new SimpleSchema({ registerSchema("CartItems", CartItems); /** - * Cart Schema + * @name Cart + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id required for check of users' carts + * @property {String} shopId required, Cart ShopId + * @property {String} userId required + * @property {String} sessionId required + * @property {String} email optional + * @property {CartItem[]} items Array of CartItem, optional + * @property {Shipment[]} shipping Array of Shipment, optional, blackbox + * @property {Payment[]} billing Array of Payment, optional, blackbox + * @property {Number} tax tax rate + * @property {Object[]} taxes Array of objects, optional + * @property {Object} taxRatesByShop optional + * @property {Number} discount optional + * @property {Workflow} workflow optional + * @property {Date} createdAt required + * @property {Date} updatedAt optional */ - export const Cart = new SimpleSchema({ - _id: { // required for check of users' carts + _id: { type: String, optional: true }, @@ -148,7 +182,6 @@ export const Cart = new SimpleSchema({ optional: true, blackbox: true }, - // This is the taxRate tax: { type: Number, decimal: true, From c2d2c3a5e3db098933fdf7d83c9cb01d07942a62 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 14:42:02 -0700 Subject: [PATCH 12/59] document email schema --- lib/collections/schemas/emails.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/collections/schemas/emails.js b/lib/collections/schemas/emails.js index 2f3e7c806a9..daa3e0b8f8a 100644 --- a/lib/collections/schemas/emails.js +++ b/lib/collections/schemas/emails.js @@ -1,6 +1,22 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Emails + * @memberof schemas + * @type {SimpleSchema} + * @property {String} to, required + * @property {String} from, required + * @property {String} subject, required + * @property {String} text, optional + * @property {String} html, optional + * @property {String} userId, optional + * @property {String} jobId, required + * @property {String} type, optional + * @property {String} status, optional + * @property {Date} createdAt, required + * @property {Date} updatedAt, required + */ export const Emails = new SimpleSchema({ to: { type: String From 39a5f1dce7049ccd4388f30250360089ecd9ddea Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 14:44:36 -0700 Subject: [PATCH 13/59] document Event schema --- lib/collections/schemas/event.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/collections/schemas/event.js b/lib/collections/schemas/event.js index f46bc685c1f..2490d3d3410 100644 --- a/lib/collections/schemas/event.js +++ b/lib/collections/schemas/event.js @@ -2,7 +2,15 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * event schema for an event log + * @name Event for EventLog + * @memberof schemas + * @type {SimpleSchema} + * @property {String} title Event title, required + * @property {String} type Event type, required + * @property {String} description Event description, optional + * @property {String} userId User who triggered event, optional + * @property {String} trigger Action that triggered event, optional + * @property {Date} createdAt required */ export const Event = new SimpleSchema({ title: { From 122019a0d61dedaf75d9e64942e743d3b3430ad6 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 14:55:40 -0700 Subject: [PATCH 14/59] document Groups schema --- lib/collections/schemas/groups.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/collections/schemas/groups.js b/lib/collections/schemas/groups.js index 51bf674b98c..03cf1424d0c 100644 --- a/lib/collections/schemas/groups.js +++ b/lib/collections/schemas/groups.js @@ -1,6 +1,19 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Group + * @memberof schemas + * @type {SimpleSchema} + * @property {String} name, required + * @property {String} description, optional + * @property {String} slug, required + * @property {String[]} permissions, optional + * @property {String} shopId, required + * @property {String} createdBy, optional + * @property {Date} createdAt, required + * @property {Date} updatedAt, required + */ export const Groups = new SimpleSchema({ name: { type: String From a174a2f96cc3f9fc71930471c2f9cfb94c5df3f9 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 14:55:50 -0700 Subject: [PATCH 15/59] document Inventory schema --- lib/collections/schemas/inventory.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/collections/schemas/inventory.js b/lib/collections/schemas/inventory.js index f7b60655d57..75ef93b82f6 100644 --- a/lib/collections/schemas/inventory.js +++ b/lib/collections/schemas/inventory.js @@ -5,10 +5,27 @@ import { Metafield } from "./metafield"; import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Inventory + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id, optional, inserted by mongo, we need it for schema validation + * @property {String} shopId, required, Inventory shopId + * @property {String} productId, required + * @property {String} variantId, required + * @property {String} orderItemId, optional + * @property {Workflow} workflow, optional + * @property {String} sku, optional + * @property {Metafield[]} metafields, optional + * @property {Document[]} documents, optional + * @property {Notes[]} notes, optional + * @property {Date} createdAt, optional, but required: schema validation failing in method with this required. should be considered temporary. + * @property {Date} updatedAt, optional + */ export const Inventory = new SimpleSchema({ _id: { type: String, - optional: true // inserted by mongo, we need it for schema validation + optional: true }, shopId: { type: String, @@ -52,7 +69,7 @@ export const Inventory = new SimpleSchema({ }, createdAt: { type: Date, - optional: true, // schema validation failing in method with this required. should be considered temporary. + optional: true, autoValue: function () { if (this.isInsert || this.isUpdate && !this.isSet) { return new Date; From 83d4383e320648359d93dae261831a4b00110694 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:01:48 -0700 Subject: [PATCH 16/59] document LayoutStructure schema with a link to docs --- lib/collections/schemas/layouts.js | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/collections/schemas/layouts.js b/lib/collections/schemas/layouts.js index b11da8010a5..76dd9bf6aa0 100644 --- a/lib/collections/schemas/layouts.js +++ b/lib/collections/schemas/layouts.js @@ -2,25 +2,22 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * @summary Layout Schema - * Layout are used by the Shops and Packages schemas. - * They are used to defin both the template layout on the site, - * as well as the workflow components that will be used in each - * layout block. - * - * "layout": "coreLayout", - * "workflow": "coreWorkflow", - * "theme": "default", - * "enabled": true, - * "structure": { - * "template": "products", - * "layoutHeader": "layoutHeader", - * "layoutFooter": "layoutFooter", - * "notFound": "notFound", - * "dashboardControls": "dashboardControls", - * "adminControlsFooter": "adminControlsFooter" + * @name LayoutStructure + * @memberof schemas + * @type {SimpleSchema} + * @summary Layout are used by the Shops and Packages schemas. + * Layouts are used to in two ways: 1) define the template layout on the site + * 2) define workflow components used in each layout block + * Read more about Layouts in {@link https://docs.reactioncommerce.com/reaction-docs/master/layout documentation} + * @property {String} template, optional + * @property {String} layoutHeader, optional + * @property {String} layoutFooter, optional + * @property {String} notFound, optional + * @property {String} dashboardHeader, optional + * @property {String} dashboardControls, optional + * @property {String} dashboardHeaderControls, optional + * @property {String} adminControlsFooter, optional */ - export const LayoutStructure = new SimpleSchema({ template: { type: String, From e58977bf2f671bdf2da0cd70ec60b9f56ff66411 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:04:29 -0700 Subject: [PATCH 17/59] document Logs schema --- lib/collections/schemas/logs.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/collections/schemas/logs.js b/lib/collections/schemas/logs.js index 9fea18fdf85..3ac08deb46c 100644 --- a/lib/collections/schemas/logs.js +++ b/lib/collections/schemas/logs.js @@ -1,8 +1,19 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Logs + * @type {SimpleSchema} + * @memberof schemas + * @property {String} logType, required + * @property {String} shopId, required + * @property {String} level, required, default: "info", allowed: "trace", "debug", "info", "warn", "error", "fatal" + * @property {String} source, required, default: "server", allowed: "client", "server" + * @property {Boolean} handled, required, default: faulse + * @property {Object} data, blackbox + * @property {Date} date, required + */ export const Logs = new SimpleSchema({ - logType: { type: String }, From 0fd2eb194f73c9276494da5f60f39a330dfbb896 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:06:19 -0700 Subject: [PATCH 18/59] document Metafield schema --- lib/collections/schemas/metafield.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/collections/schemas/metafield.js b/lib/collections/schemas/metafield.js index c8f888848cb..9e5edbabac8 100644 --- a/lib/collections/schemas/metafield.js +++ b/lib/collections/schemas/metafield.js @@ -2,9 +2,16 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Metafield Schema + * @name Metafield + * @memberof schemas + * @type {SimpleSchema} + * @property {String} key, optional + * @property {String} namespace, optional + * @property {String} scope, optional + * @property {String} value, optional + * @property {String} valueType, optional + * @property {String} description, optional */ - export const Metafield = new SimpleSchema({ key: { type: String, From d4a8e1a326f82c14ca771e0bdf9d7f87cc7f459e Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:10:44 -0700 Subject: [PATCH 19/59] document Notification schema --- lib/collections/schemas/notifications.js | 33 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/collections/schemas/notifications.js b/lib/collections/schemas/notifications.js index 3037adb8aaf..de7af159227 100644 --- a/lib/collections/schemas/notifications.js +++ b/lib/collections/schemas/notifications.js @@ -1,22 +1,33 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; - +/** + * @name Notification + * @memberof schemas + * @type {SimpleSchema} + * @summary Notification sends messages corresponding to the type: + * Type Message(This would be the corresponding message) + * ----------------| ----------------------------------------------- + * orderCanceled | "Your order was canceled." + * forAdmin: | "You have a new order." + * newOrder: | "You just made an order." + * orderDelivered: | "Your order has been delivered." + * orderProcessing: | "Your order is being processed." + * orderShipped: | "Your order has been shipped. + * @property {String} message, required + * @property {String} type, required, types: "orderCanceled", "forAdmin", "newOrder", "orderDelivered", "orderProcessing", "orderShipped" + * @property {String} url, required + * @property {String} to, required + * @property {Boolean} hasDetails, required + * @property {String} details, required + * @property {String} status, required, default: "unread" + * @property {Date} timeSent, required + */ export const Notification = new SimpleSchema({ message: { type: String, optional: false }, - /** - * Type Message(This would be the corresponding message) - * ----------------| ----------------------------------------------- - * orderCanceled | "Your order was canceled." - * forAdmin: | "You have a new order." - * newOrder: | "You just made an order." - * orderDelivered: | "Your order has been delivered." - * orderProcessing: | "Your order is being processed." - * orderShipped: | "Your order has been shipped." - */ type: { type: String, optional: false From 5765f292d6c15e44086406218820f46f94108bda Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:17:45 -0700 Subject: [PATCH 20/59] document Order schemas --- lib/collections/schemas/orders.js | 59 ++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/lib/collections/schemas/orders.js b/lib/collections/schemas/orders.js index 0d082c4f1de..2a3b98efdac 100644 --- a/lib/collections/schemas/orders.js +++ b/lib/collections/schemas/orders.js @@ -3,9 +3,12 @@ import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Order Document Schema + * @name Document + * @memberof schemas + * @type {SimpleSchema} + * @property {String} docId, required + * @property {String} docType, optional */ - export const Document = new SimpleSchema({ docId: { type: String @@ -19,9 +22,14 @@ export const Document = new SimpleSchema({ registerSchema("Document", Document); /** - * Order History Schema + * @name History + * @memberof schemas + * @type {SimpleSchema} + * @property {String} event, required + * @property {String} value, required + * @property {String} userId, required + * @property {String} updatedAt, required */ - export const History = new SimpleSchema({ event: { type: String @@ -40,9 +48,13 @@ export const History = new SimpleSchema({ registerSchema("History", History); /** - * Order Notes Schema + * @name Notes + * @memberof schemas + * @type {SimpleSchema} + * @property {String} content, required + * @property {String} userId, required + * @property {Date} updatedAt, required */ - export const Notes = new SimpleSchema({ content: { type: String @@ -58,9 +70,15 @@ export const Notes = new SimpleSchema({ registerSchema("Notes", Notes); /** - * OrderItems Schema - * merges with Cart and Order to create Orders collection - */ + * @name OrderItems + * @memberof schemas + * @summary Merges with Cart and Order to create Orders collection + * @type {SimpleSchema} + * @property {String} additionalField, optional + * @property {Workflow} workflow, optional + * @property {History[]} history, optional + * @property {Document[]} documents, optional +*/ export const OrderItem = new SimpleSchema({ additionalField: { type: String, @@ -82,10 +100,16 @@ export const OrderItem = new SimpleSchema({ registerSchema("OrderItem", OrderItem); - /** - * OrderTransaction Schema - * order transactions tie shipping, billing, and inventory transactions + * @name OrderTransaction Schema + * @memberof schemas + * @summary order transactions tie shipping, billing, and inventory transactions + * @type {SimpleSchema} + * @property {String} itemId, optional + * @property {String} paymentId, optional + * @property {String} shipmentId, optional + * @property {String} inventoryId, optional + * @property {Date} createdAt, required */ export const OrderTransaction = new SimpleSchema({ itemId: { @@ -119,7 +143,16 @@ export const OrderTransaction = new SimpleSchema({ registerSchema("OrderTransaction", OrderTransaction); /** - * Order Schema + * @name Order Schema + * @memberof schemas + * @type {SimpleSchema} + * @property {String} userId, required + * @property {String} cartId, optional + * @property {History[]} history, optional + * @property {Document[]} documents, optional + * @property {Notes[]} notes, optional + * @property {OrderItem[]} items, optional + * @property {OrderTransaction[]} transactions, optional */ export const Order = new SimpleSchema({ userId: { From c435996b545f03f8f4749738bbaa1c29ce6ae4c0 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 15:36:43 -0700 Subject: [PATCH 21/59] document Payment schemas --- lib/collections/schemas/payments.js | 73 +++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/lib/collections/schemas/payments.js b/lib/collections/schemas/payments.js index a97e270f2af..e0b466be08b 100644 --- a/lib/collections/schemas/payments.js +++ b/lib/collections/schemas/payments.js @@ -5,9 +5,15 @@ import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Schema for items we're inserting into our Payments to keep track of what items - * were paid for with a given paymentMethod + * @name PaymentItem + * @summary Schema for items we're inserting into our Payments to keep track of what items were paid for with a given paymentMethod * @type {SimpleSchema} + * @memberof schemas + * @property {String} _id, optional, Shipment Line Item + * @property {String} productId, required + * @property {String} shopId, optional, Shipment Item ShopId + * @property {Number} quantity, required + * @property {String} variantId, required */ export const PaymentItem = new SimpleSchema({ _id: { @@ -38,9 +44,29 @@ export const PaymentItem = new SimpleSchema({ registerSchema("PaymentItem", PaymentItem); - /** - * PaymentMethod Schema + * @name PaymentMethod + * @type {SimpleSchema} + * @memberof schemas + * @property {String} processor, required + * @property {String} paymentPackageId, required + * @property {String} paymentSettingsKey, required + * @property {String} storedCard, optional + * @property {String} method, allowed values: "credit", "debit", "shipping-credit" + * @property {String} transactionId, required + * @property {Object} metadata, optional, blackbox + * @property {Workflow} workflow, optional + * @property {String} status, required + * @property {String} mode, allowed values: "authorize", "capture", "refund", "cancel", "void" + * @property {String} riskLevel, allowed values: "normal", "elevated", "high" + * @property {Date} createdAt, required + * @property {Date} updatedAt, optional + * @property {String} authorization, optional + * @property {Number} amount, optional + * @property {String} currency, required + * @property {Object[]} transactions, optional, blackbox + * @property {PaymentItem[]} items, optional + * @property {String} shopId, optional */ export const PaymentMethod = new SimpleSchema({ processor: { @@ -133,9 +159,16 @@ export const PaymentMethod = new SimpleSchema({ registerSchema("PaymentMethod", PaymentMethod); /** - * Invoice Schema + * @name Invoice + * @type {SimpleSchema} + * @memberof schemas + * @property {String} transaction, optional + * @property {Number} shipping, optional + * @property {Number} taxes, optional + * @property {Number} subtotal, required + * @property {Number} discounts, optional + * @property {Number} total, required */ - export const Invoice = new SimpleSchema({ transaction: { type: String, @@ -169,9 +202,12 @@ export const Invoice = new SimpleSchema({ registerSchema("Invoice", Invoice); /** - * Currency Schema + * @name Currency + * @type {SimpleSchema} + * @memberof schemas + * @property {String} userCurrency, default value: "USD" + * @property {Number} exchangeRate, optional */ - export const Currency = new SimpleSchema({ userCurrency: { type: String, @@ -188,9 +224,16 @@ export const Currency = new SimpleSchema({ registerSchema("Currency", Currency); /** - * Payment Schema + * @name Payment + * @type {SimpleSchema} + * @memberof schemas + * @property {String} _id, required, Payment Id + * @property {Address} address, optional + * @property {PaymentMethod} paymentMethod, optional + * @property {Invoice} invoice, optional + * @property {Currency} currency, optional + * @property {String} shopId, optional */ - export const Payment = new SimpleSchema({ _id: { type: String, @@ -221,6 +264,16 @@ export const Payment = new SimpleSchema({ registerSchema("Payment", Payment); +/** + * @name Payment + * @type {SimpleSchema} + * @memberof schemas + * @property {String} type, required + * @property {Number} amount, required + * @property {Number} created, required + * @property {String} currency, required + * @property {Object} raw, optional, blackbox + */ export const Refund = new SimpleSchema({ type: { type: String From 008e1e44f85b9d041a2524d28f34adad0c549d90 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:01:31 -0700 Subject: [PATCH 22/59] document Product, ProductPosition, ProductVariant, PriceRange schemas --- lib/collections/schemas/products.js | 119 +++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 22 deletions(-) diff --git a/lib/collections/schemas/products.js b/lib/collections/schemas/products.js index 0480f062eb3..99442c569a1 100644 --- a/lib/collections/schemas/products.js +++ b/lib/collections/schemas/products.js @@ -10,7 +10,14 @@ import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * VariantMedia Schema + * @name VariantMedia + * @memberof schemas + * @type {SimpleSchema} + * @property {String} mediaId, optional + * @property {Number} priority, optional + * @property {Metafield[]} metafields, optional + * @property {Date} updatedAt, optional + * @property {Date} createdAt, required */ export const VariantMedia = new SimpleSchema({ mediaId: { @@ -47,7 +54,14 @@ export const VariantMedia = new SimpleSchema({ registerSchema("VariantMedia", VariantMedia); /** - * ProductPosition Schema + * @name ProductPosition + * @memberof schemas + * @type {SimpleSchema} + * @property {String} tag, optional + * @property {Number} position, optional + * @property {Boolean} pinned, optional + * @property {Number} weight, optional, default value: 0 + * @property {Date} updatedAt, required */ export const ProductPosition = new SimpleSchema({ tag: { @@ -77,7 +91,43 @@ export const ProductPosition = new SimpleSchema({ registerSchema("ProductPosition", ProductPosition); /** - * ProductVariant Schema + * @name ProductVariant + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id, required, Variant ID + * @property {String[]} ancestors, default value: [] + * @property {Number} index, optional, Variant position number in list. Used for keeping array index, moving variants through list, like drag-n-drop. + * @property {Boolean} isVisible, default value: false + * @property {Boolean} isDeleted, default value: false + * @property {String} barcode, optional + * @property {Number} compareAtPrice, optional, Compare at price + * @property {String} fulfillmentService, optional, Fullfillment service + * @property {Number} weight, default value: 0 + * @property {Number} length, optional, default value: 0 + * @property {Number} width, optional, default value: 0 + * @property {Number} height, optional, default value: 0 + * @property {Boolean} inventoryManagement, default value: true + * @property {Boolean} inventoryPolicy, default value: false, If disabled, an item can be sold even if it not in stock. + * @property {Number} lowInventoryWarningThreshold, default value: 0, Warn of low inventory at this number + * @property {Number} inventoryQuantity, default value: 0 + * @property {Number} minOrderQuantity, optional + * @property {Boolean} isLowQuantity, optional, denormalized field, indicates when at least one of variant is lower than `lowInventoryWarningThreshold` + * @property {Boolean} isSoldOut, optional, denormalized field, indicates when all variants `inventoryQuantity` is 0 + * @property {Number} price, default value: 0.00 + * @property {String} shopId, required, Variant ShopId + * @property {String} sku, optional + * @property {String} type, default value: "variant" + * @property {Boolean} taxable, default value: true + * @property {String} taxCode, default value: "0000" + * @property {String} taxDescription, optional + * @property {String} title, Label for customers, default value: "" + * @property {String} optionTitle, Option internal name, default value: "Untitled option" + * @property {Metafield[]} metafields, optional + * @property {Date} createdAt, optional + * @property {Date} updatedAt, optional + * @property {Event[]} eventLog, optional, Variant Event Log + * @property {Workflow} workflow, optional + * @property {String} originCountry, optional */ export const ProductVariant = new SimpleSchema({ _id: { @@ -88,8 +138,6 @@ export const ProductVariant = new SimpleSchema({ type: [String], defaultValue: [] }, - // since implementing of flattened model this property is used for keeping - // array index. This is needed for moving variants through list (drag'n'drop) index: { label: "Variant position number in list", type: Number, @@ -184,9 +232,6 @@ export const ProductVariant = new SimpleSchema({ } } }, - // this represents an ability to sell item without keeping it on stock. In - // other words if it is disabled, then you can sell item even if it is not in - // stock. inventoryPolicy: { type: Boolean, label: "Deny when out of stock", @@ -228,15 +273,11 @@ export const ProductVariant = new SimpleSchema({ type: Number, optional: true }, - // Denormalized field: Indicates when at least one of variants - // `inventoryQuantity` are lower then their `lowInventoryWarningThreshold`. - // This is some kind of marketing course. isLowQuantity: { label: "Indicates that the product quantity is too low", type: Boolean, optional: true }, - // Denormalized field: Indicates when all variants `inventoryQuantity` is zero isSoldOut: { label: "Indicates when the product quantity is zero", type: Boolean, @@ -283,13 +324,11 @@ export const ProductVariant = new SimpleSchema({ optional: true, label: "Tax Description" }, - // Label for customers title: { label: "Label", type: String, defaultValue: "" }, - // Option internal name optionTitle: { label: "Option", type: String, @@ -331,6 +370,14 @@ export const ProductVariant = new SimpleSchema({ registerSchema("ProductVariant", ProductVariant); +/** + * PriceRange + * @type {SimpleSchema} + * @memberof schemas + * @property {String} range, default value: "0.00" + * @property {Number} min, optional, default value: 0 + * @property {Number} max, optional, default value: 0 + */ export const PriceRange = new SimpleSchema({ range: { type: String, @@ -353,7 +400,42 @@ export const PriceRange = new SimpleSchema({ registerSchema("PriceRange", PriceRange); /** - * Product Schema + * Product + * @type {SimpleSchema} + * @memberof schemas + * @property {String} _id Product ID + * @property {[String]} ancestors default value: [] + * @property {String} shopId Product ShopID + * @property {String} title Product Title + * @property {String} pageTitle, optional + * @property {String} description optional + * @property {String} productType optional + * @property {String} originCountry optional + * @property {String} type default value: "simple" + * @property {String} vendor optional + * @property {Metafield[]} metafields optional + * @property {Object} positions ProductPosition + * @property {PriceRange} price denormalized, object with range string, min and max + * @property {Boolean} isLowQuantity denormalized, Indicates when at least one variant `inventoryQuantity` is lower than `lowInventoryWarningThreshold` + * @property {Boolean} isSoldOut denormalized, Indicates when all variants `inventoryQuantity` is zero + * @property {Boolean} isBackorder denormalized, It is `true` if product not in stock, but customers anyway could order it. + * @property {Boolean} requiresShipping default value: true, Require a shipping address + * @property {ShippingParcel} parcel, optional + * @property {String[]} hashtags, optional + * @property {String} twitterMsg, optional + * @property {String} facebookMsg, optional + * @property {String} googleplusMsg, optional + * @property {String} pinterestMsg, optional + * @property {String} metaDescription, optional + * @property {String} handle, optional, slug + * @property {Boolean} isDeleted, default value: false + * @property {Boolean} isVisible, default value: false + * @property {String} template, default value: "productDetailSimple" + * @property {Date} createdAt, required + * @property {Date} updatedAt, optional + * @property {Date} publishedAt, optional + * @property {String} publishedScope, optional + * @property {Workflow} workflow, optional */ export const Product = new SimpleSchema({ _id: { @@ -410,27 +492,20 @@ export const Product = new SimpleSchema({ blackbox: true, optional: true }, - // Denormalized field: object with range string, min and max price: { label: "Price", type: PriceRange }, - // Denormalized field: Indicates when at least one of variants - // `inventoryQuantity` are lower then their `lowInventoryWarningThreshold`. - // This is some kind of marketing course. isLowQuantity: { label: "Indicates that the product quantity is too low", type: Boolean, optional: true }, - // Denormalized field: Indicates when all variants `inventoryQuantity` is zero isSoldOut: { label: "Indicates when the product quantity is zero", type: Boolean, optional: true }, - // Denormalized field. It is `true` if product not in stock, but customers - // anyway could order it. isBackorder: { label: "Indicates when the seller has allowed the sale of product which" + " is not in stock", From 8aea96c0b7bd46348a443ad953e61eab0d976d84 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:02:55 -0700 Subject: [PATCH 23/59] document Sms schema --- lib/collections/schemas/sms.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/collections/schemas/sms.js b/lib/collections/schemas/sms.js index b05fab1ad8f..6571a380a98 100644 --- a/lib/collections/schemas/sms.js +++ b/lib/collections/schemas/sms.js @@ -1,6 +1,16 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Sms + * @memberof schemas + * @type {SimpleSchema} + * @property {String} apiKey, optional + * @property {String} apiToken, optional + * @property {String} shopId, optional + * @property {String} smsPhone, optional + * @property {String} smsProvider, optional + */ export const Sms = new SimpleSchema({ apiKey: { type: String, From cdd86b230d03203ee57d366a1c55329861432e2d Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:15:41 -0700 Subject: [PATCH 24/59] document SocialProvider schemas --- lib/collections/schemas/social.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/collections/schemas/social.js b/lib/collections/schemas/social.js index 04e56556175..1a505ca0fa3 100644 --- a/lib/collections/schemas/social.js +++ b/lib/collections/schemas/social.js @@ -2,8 +2,12 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { PackageConfig } from "./registry"; import { registerSchema } from "@reactioncommerce/reaction-collections"; -/* - * Settings for Social Package +/** + * @name SocialProvider + * @memberof schemas + * @type {SimpleSchema} + * @property {String} profilePage optional, Profile Page + * @property {Boolean} enabled optional, default value: false */ export const SocialProvider = new SimpleSchema({ profilePage: { @@ -22,6 +26,21 @@ export const SocialProvider = new SimpleSchema({ registerSchema("SocialProvider", SocialProvider); +/** + * @name SocialPackageConfig + * @memberof schemas + * @type {SimpleSchema} + * @extends {PackageConfig} + * @property {Object} settings.public optional + * @property {Object} settings.public.apps optional + * @property {SocialProvider} settings.public.apps.facebook optional, Facebook + * @property {String} settings.public.apps.facebook.appId optional, Facebook App ID + * @property {String} settings.public.apps.facebook.appSecret optional, Facebook App Secret + * @property {SocialProvider} settings.public.apps.twitter optional, Twitter + * @property {String} settings.public.apps.twitter.username optional, Twitter username + * @property {SocialProvider} settings.public.apps.pinterest optional, Pinterest + * @property {SocialProvider} settings.public.apps.googleplus optional, Google+ + */ export const SocialPackageConfig = new SimpleSchema([ PackageConfig, { "settings.public": { From c95d76f6a93c3f65c0733bb5de6882779abd96ca Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:21:37 -0700 Subject: [PATCH 25/59] document Themes, Translations, Workflow schemas --- lib/collections/schemas/themes.js | 16 +++++++++------- lib/collections/schemas/translations.js | 18 +++++++++++------- lib/collections/schemas/workflow.js | 10 ++++++---- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/lib/collections/schemas/themes.js b/lib/collections/schemas/themes.js index 42d18dcb655..0a10dc51c27 100644 --- a/lib/collections/schemas/themes.js +++ b/lib/collections/schemas/themes.js @@ -2,32 +2,34 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * @summary Themes Schema - * Schema for themes used in reaction-layout + * @name Themes + * @summary Schema for themes used in reaction-layout + * @type {SimpleSchema} + * @namespace schemas + * @property {String} name required + * @property {String} author optional + * @property {String} layout default value: "coreLayout" + * @property {String} url optional + * @property {Object[]} components optional, blackbox */ - export const Themes = new SimpleSchema({ name: { type: String, index: true }, - author: { type: String, optional: true }, - layout: { type: String, optional: true, defaultValue: "coreLayout" }, - url: { type: String, optional: true }, - components: { type: [Object], optional: true, diff --git a/lib/collections/schemas/translations.js b/lib/collections/schemas/translations.js index ea8ecce9056..5f8c58f8149 100644 --- a/lib/collections/schemas/translations.js +++ b/lib/collections/schemas/translations.js @@ -2,13 +2,17 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { shopIdAutoValue } from "./helpers"; import { registerSchema } from "@reactioncommerce/reaction-collections"; -/* -* translations schema -* mostly just a blackbox for now -* someday maybe we'll validate the entire schema -* since ui editing for these values are likely -*/ - +/** + * @name Translation + * @memberof schemas + * @type {SimpleSchema} + * @todo Mostly just a blackbox for now. Someday we'll validate the entire schema + * @property {String} shopId, Translation ShopId + * @property {String} language, language + * @property {String} i18n, translation + * @property {String} ns, Namespace + * @property {Object} translation, blackbox + */ export const Translation = new SimpleSchema({ shopId: { type: String, diff --git a/lib/collections/schemas/workflow.js b/lib/collections/schemas/workflow.js index a0fa896460b..4e9bbd37239 100644 --- a/lib/collections/schemas/workflow.js +++ b/lib/collections/schemas/workflow.js @@ -2,11 +2,13 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * workflow schema for attaching to collection where - * PackageWorkflow is controlling view flow - * Shop defaultWorkflow is defined in Shop + * @name Workflow + * @summary for attaching to collection where PackageWorkflow is controlling view flow. Shop defaultWorkflow is defined in Shop. + * @memberof schemas + * @type {SimpleSchema} + * @property {String} status, default value: "new" + * @property {String[]} workflow, optional */ - export const Workflow = new SimpleSchema({ status: { type: String, From 30c49c5cd8d8e92cf54b9f802944eb8d09ec4955 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:25:42 -0700 Subject: [PATCH 26/59] document Revisions schema --- lib/collections/schemas/revisions.js | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/collections/schemas/revisions.js b/lib/collections/schemas/revisions.js index 52eeb54b65b..640a6ecdfcc 100644 --- a/lib/collections/schemas/revisions.js +++ b/lib/collections/schemas/revisions.js @@ -2,56 +2,59 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name Revisions + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id Revision Id + * @property {Workflow} workflow required + * @property {String} documentId Reference Document Id + * @property {String} documentType Document Type, default value: product, allowed values: "product", "image", "tag" + * @property {String} parentDocument optional + * @property {"object"} documentData blackbox object + * @property {String} changeType optional, allowed values: "insert", "update", "remove" + * @property {Object[]} diff optional, blackbox + * @property {Date} createdAt required + * @property {Date} updatedAt optional + * @property {Date} publishAt optional + */ export const Revisions = new SimpleSchema({ _id: { type: String, label: "Revision Id" }, - - // status: { - // type: String, - // label: "Revision Status" - // }, - workflow: { type: Workflow, optional: false }, - documentId: { type: String, label: "Reference Document Id" }, - documentType: { type: String, label: "Document Type", defaultValue: "product", allowedValues: ["product", "image", "tag"] }, - parentDocument: { type: String, optional: true }, - documentData: { type: "object", blackbox: true }, - changeType: { type: String, optional: true, allowedValues: ["insert", "update", "remove"] }, - diff: { type: [Object], blackbox: true, optional: true }, - createdAt: { type: Date, autoValue: function () { @@ -64,7 +67,6 @@ export const Revisions = new SimpleSchema({ } } }, - updatedAt: { type: Date, autoValue: function () { @@ -72,7 +74,6 @@ export const Revisions = new SimpleSchema({ }, optional: true }, - publishAt: { type: Date, optional: true From b5a1c1f099345eb2fe5a181deb5db20bc571e67f Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 16:28:56 -0700 Subject: [PATCH 27/59] document Tag schema --- lib/collections/schemas/tags.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/collections/schemas/tags.js b/lib/collections/schemas/tags.js index fd603a36278..3a7c4be86bc 100644 --- a/lib/collections/schemas/tags.js +++ b/lib/collections/schemas/tags.js @@ -4,9 +4,24 @@ import { Metafield } from "./metafield"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Tag Schema + * @name Tag + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id optional + * @property {String} name required + * @property {String} slug required + * @property {String} type optional + * @property {Metafield[]} metafields optional + * @property {Number} position optional + * @property {String[]} relatedTagIds optional + * @property {Boolean} isDeleted default value: false + * @property {Boolean} isTopLevel required + * @property {Boolean} isVisible defalut value: true + * @property {String[]} groups optional, default value: [], groupIds that this tag belongs to + * @property {String} shopId Tag shopId + * @property {Date} createdAt required + * @property {Date} updatedAt required */ - export const Tag = new SimpleSchema({ _id: { type: String, From bf0b9efbb7489f4c2f24da62930dfd1c94219fb8 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 17:21:12 -0700 Subject: [PATCH 28/59] document Registry schemas + added link to blog --- lib/collections/schemas/registry.js | 68 ++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/lib/collections/schemas/registry.js b/lib/collections/schemas/registry.js index ccf20449fb0..09a6e7df9f7 100644 --- a/lib/collections/schemas/registry.js +++ b/lib/collections/schemas/registry.js @@ -3,9 +3,13 @@ import { Layout } from "./layouts"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * Permissions Schema + * @name Permissions + * @memberof schemas + * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @type {SimpleSchema} + * @property {String} permission + * @property {String} label */ - export const Permissions = new SimpleSchema({ permission: { type: String @@ -18,10 +22,31 @@ export const Permissions = new SimpleSchema({ registerSchema("Permissions", Permissions); /** - * Permissions Registry - * the registry entries in the Package registry + * @name Registry + * @memberof schemas + * @type {SimpleSchema} + * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @property {String[]} provides Legacy `provides` apps use a String rather than an array. These are transformed in loadPackages. + * @property {String} route optional + * @property {String} name optional, Registry name must be unique. Namespace your plugin (e.g. `yourorg-plugin-name`) to avoid conflicts. + * @property {String} template optional, Assign to a Blaze template + * @property {String} workflow optional, A layout for a template in the package + * @property {String} layout optional, Force the app to render a specific layout + * @property {String[]} triggersEnter optional, Trigger on Enter + * @property {String[]} triggersExit optional, Trigger on Exit + * @property {Object} options optional, Routing Options + * @property {String} description optional, deprecated + * @property {String} icon optional, A set of CSS classes, often Font Awesome classes, used to define the package in the sidebar. + * @property {String} label optional, Human-readable name for a Registry entry + * @property {String} container optional, Used to group plugins + * @property {Number} priority optional, Plugin load order. Lower values loaded first. + * @property {Boolean} enabled optional, Enable or not + * @property {Permissions[]} permissions optional, Define a new user permission + * @property {String[]} audience optional, Define what permissions are required to view a step in a workflow + * @property {Object} meta optional, Set `dashboardSize` for the `actionView` + * @property {String[]} showForShopTypes optional, Shop Types this plugin should show for + * @property {String[]} hideForShopTypes optional, Shop Types this plugin should not show for */ - export const Registry = new SimpleSchema({ // TODO: This should _not_ be optional in the future, but we need to organize our packages better provides: { @@ -122,9 +147,18 @@ export const Registry = new SimpleSchema({ registerSchema("Registry", Registry); - /** - * PackageConfig Schema + * @name PackageConfig + * @memberof schemas + * @type {SimpleSchema} + * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @property {String} shopId {@see https://github.com/reactioncommerce/reaction/issues/646#issuecomment-169351842} + * @property {String} name required + * @property {Boolean} enabled defalut value: true + * @property {String} icon optional + * @property {Object} settings optional + * @property {Registry[]} registry optional + * @property {Layout[]} layout optional */ export const PackageConfig = new SimpleSchema({ shopId: { @@ -165,10 +199,24 @@ export const PackageConfig = new SimpleSchema({ registerSchema("PackageConfig", PackageConfig); /** - * CorePackageConfig Schema - * Core Reaction Settings + * @name CorePackageConfig + * @memberof schemas + * @type {SimpleSchema} + * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @extends {PackageConfig} + * @property {Object} settings.mail optional, Mail settings + * @property {String} settings.mail.user Mail user + * @property {String} settings.mail.password Mail password + * @property {String} settings.mail.host Mail host + * @property {String} settings.mail.port Mail port + * @property {String} settings.openexchangerates.appId OpenExchangeRates Id + * @property {String} settings.openexchangerates.refreshPeriod default value: every 1 hour + * @property {String} settings.google.clientId default value: null + * @property {String} settings.google.apiKey default value: null + * @property {Object} settings.public optional Settings in `public` are published to the client. + * @property {Boolean} settings.public.allowGuestCheckout allows guest checkout + * @property {String} settings.cart.cleanupDurationDays default value: older than 3 days */ - export const CorePackageConfig = new SimpleSchema([ PackageConfig, { "settings.mail": { From a413bc87ab76259aa2981799cf738ce7518b0817 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 17:45:18 -0700 Subject: [PATCH 29/59] document Shipping schema --- lib/collections/schemas/shipping.js | 163 +++++++++++++++++++++------- 1 file changed, 126 insertions(+), 37 deletions(-) diff --git a/lib/collections/schemas/shipping.js b/lib/collections/schemas/shipping.js index bfd40d2a487..9d26da0925c 100644 --- a/lib/collections/schemas/shipping.js +++ b/lib/collections/schemas/shipping.js @@ -7,12 +7,14 @@ import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * ShippoShippingMethod Schema - * TODO move shippo related schema to shippo module - * This will only exist in ShippingMethods Inside Cart/Order and not DB shipping Collection - * as Shippo Methods are Dynamic. + * @name ShippoShippingMethod + * @memberof schemas + * @type {SimpleSchema} + * @todo Move Shippo-related schema to Shippo module + * @summary This will only exist in ShippingMethods Inside Cart/Order and not DB shipping Collection as Shippo Methods are Dynamic. + * @property {String} serviceLevelToken optional + * @property {String} rateId optional */ - export const ShippoShippingMethod = new SimpleSchema({ serviceLevelToken: { type: String, @@ -27,9 +29,30 @@ export const ShippoShippingMethod = new SimpleSchema({ registerSchema("ShippoShippingMethod", ShippoShippingMethod); /** - * ShippingMethod Schema + * @name ShippingMethod + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id Shipment method Id + * @property {String} name Method name + * @property {String} label Public label + * @property {String} group Group, allowed values: "Ground", "Priority", "One Day", "Free" + * @property {Number} cost optional + * @property {Number} handling optional, default value: 0 + * @property {Number} rate Rate + * @property {Boolean} enabled default value: false + * @property {Array} validRanges optional, Matching cart ranges + * @property {Object} validRanges.$ optional + * @property {Number} validRanges.begin optional + * @property {Number} validRanges.end optional + * @property {Array} validLocales optional + * @property {Object} validLocales.$ optional + * @property {String} validLocales.$.origination optional + * @property {String} validLocales.$.destination optional + * @property {Number} validLocales.$.deliveryBegin optional + * @property {Number} validLocales.$.deliveryEnd optional + * @property {String} carrier optional + * @property {ShippoShippingMethod} settings optional */ - export const ShippingMethod = new SimpleSchema({ "_id": { type: String, @@ -137,9 +160,13 @@ export const ShippingMethod = new SimpleSchema({ registerSchema("ShippingMethod", ShippingMethod); /** - * ShipmentQuote Schema + * @name ShipmentQuote + * @memberof schemas + * @type {SimpleSchema} + * @property {String} carrier Name of carrier + * @property {ShippingMethod} method ShippingMethod + * @property {Number} rate default value: 0.00 */ - export const ShipmentQuote = new SimpleSchema({ carrier: { type: String @@ -156,7 +183,17 @@ export const ShipmentQuote = new SimpleSchema({ registerSchema("ShipmentQuote", ShipmentQuote); -// populate with order.items that are added to a shipment +/** + * @name ShipmentItem + * @memberof schemas + * @type {SimpleSchema} + * @summary Populate with order.items that are added to a shipment + * @property {String} _id Shipment Line Item, optional + * @property {String} productId required + * @property {String} shopId Shipment Item ShopId, optional + * @property {Number} quantity required + * @property {String} variantId required + */ export const ShipmentItem = new SimpleSchema({ _id: { type: String, @@ -187,9 +224,15 @@ export const ShipmentItem = new SimpleSchema({ registerSchema("ShipmentItem", ShipmentItem); /** - * ShippingParcel Schema + * @name ShippingParcel + * @memberof schemas + * @type {SimpleSchema} + * @property {String} containers optional + * @property {Number} length optional + * @property {Number} width optional + * @property {Number} height optional + * @property {Number} weight optional */ - export const ShippingParcel = new SimpleSchema({ containers: { type: String, @@ -220,10 +263,14 @@ export const ShippingParcel = new SimpleSchema({ registerSchema("ShippingParcel", ShippingParcel); /** - * ShippoShipment Schema - * Specific properties of Shipment for use with Shippo. We don't use + * @name ShippoShipment + * @summary Specific properties of Shipment for use with Shippo. We don't use + * @memberof schemas + * @type {SimpleSchema} + * @property {String} transactionId optional + * @property {String} trackingStatusStatus optional Tracking Status's status + * @property {String} trackingStatusDate optional */ - export const ShippoShipment = new SimpleSchema({ transactionId: { type: String, @@ -242,14 +289,19 @@ export const ShippoShipment = new SimpleSchema({ registerSchema("ShippoShipment", ShippoShipment); /** - * ShipmentQuotesQueryStatus schema - Used to know the - * status of a query/consumption of a shipping provider's API (e.g Shippo) - * for shipping quotations. (Shipping quotations are the costs from - * different shipping methods like Fedex, DHL etc of shipping one - * or more items to a particular place in a given amount of time.) + * @name ShipmentQuotesQueryStatusUsed + * @todo Should requestStatus be required or not? + * @memberof schemas + * @type {SimpleSchema} + * @summary Status of a query/consumption of a shipping provider's API (e.g Shippo) for shipping quotations. + * @description Shipping quotations are the costs from different shipping methods like Fedex, DHL etc of + * shipping one or more items to a particular place in a given amount of time.) + * @property {String} requestStatus optional, default value: "noRequestYet" + * @property {String} shippingProvider optional + * @property {Number} numOfShippingMethodsFound optional + * @property {String} message optional */ export const ShipmentQuotesQueryStatus = new SimpleSchema({ - // TODO: Should requestStatus be required or not? requestStatus: { type: String, optional: true, @@ -272,10 +324,27 @@ export const ShipmentQuotesQueryStatus = new SimpleSchema({ registerSchema("ShipmentQuotesQueryStatus", ShipmentQuotesQueryStatus); /** - * Shipment Schema - * used for cart/order shipment tracking + * @name Shipment + * @summary Used for cart/order shipment tracking + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id Shipment ID + * @property {String} shopId required + * @property {String} paymentId Payment ID + * @property {Address} address optional + * @property {ShippingMethod} shipmentMethod optional + * @property {ShipmentQuote[]} shipmentQuotes optional + * @property {ShipmentQuotesQueryStatus} shipmentQuotesQueryStatus optional + * @property {String} tracking optional + * @property {ShippingParcel} parcel optional + * @property {ShipmentItem[]} items optional + * @property {Workflow} workflow optional + * @property {Invoice} invoice optional + * @property {Object[]} transactions optional + * @property {String} shippingLabelUrl For printable Shipping label + * @property {String} customsLabelUrl For Customs printable label + * @property {ShippoShipment} shippo For Shippo specific properties */ - export const Shipment = new SimpleSchema({ _id: { type: String, @@ -330,15 +399,15 @@ export const Shipment = new SimpleSchema({ type: [Object], optional: true, blackbox: true - }, // For printable Shipping label + }, shippingLabelUrl: { type: String, optional: true - }, // For Customs printable label + }, customsLabelUrl: { type: String, optional: true - }, // shippo specific properties + }, shippo: { type: ShippoShipment, optional: true @@ -348,12 +417,13 @@ export const Shipment = new SimpleSchema({ registerSchema("Shipment", Shipment); /** - * ShippoShippingProvider Schema - * Specific properties for use with Shippo. We don't use - * ShippingProvider service* fields because Shippo is on level - * higher service than simple carrier's ,e.g Fedex api. + * @name ShippoShippingProvider Schema + * @summary Specific properties for use with Shippo. + * @description We don't use ShippingProvider service* fields because Shippo is on level higher service than simple carrier's ,e.g Fedex api. + * @memberof schemas + * @type {SimpleSchema} + * @property {String} carrierAccountId optional */ - export const ShippoShippingProvider = new SimpleSchema({ carrierAccountId: { type: String, @@ -364,9 +434,18 @@ export const ShippoShippingProvider = new SimpleSchema({ registerSchema("ShippoShippingProvider", ShippoShippingProvider); /** - * ShippingProvider Schema + * @name ShippingProvider + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id optional + * @property {String} name optional + * @property {String} label optional + * @property {Boolean} enabled optional, default value: true + * @property {String} serviceAuth optional + * @property {String} serviceSecret optional + * @property {String} serviceUrl optional + * @property {ShippoShippingProvider} shippoProvider optional */ - export const ShippingProvider = new SimpleSchema({ _id: { type: String, @@ -411,9 +490,16 @@ export const ShippingProvider = new SimpleSchema({ registerSchema("ShippingProvider", ShippingProvider); /** - * Shipping Schema + * @name Shipping + * @memberof schemas + * @type {SimpleSchema} + * @property {String} _id optional + * @property {String} shopId required + * @property {String} name optional + * @property {ShippingProvider} provider optional + * @property {ShippingMethod[]} methods optional + * @property {ShipmentQuote[]} shipmentQuotes optional */ - export const Shipping = new SimpleSchema({ _id: { type: String, @@ -451,7 +537,10 @@ export const Shipping = new SimpleSchema({ registerSchema("Shipping", Shipping); /** - * Shipping Package Schema + * @name ShippingPackage + * @memberof schemas + * @type {SimpleSchema} + * @property {String} settings.name default value: "Flat Rate Service" */ export const ShippingPackageConfig = new SimpleSchema([ PackageConfig, { From 0076498079aab8f22e3bba26104b87b92645f4bf Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 20:18:00 -0700 Subject: [PATCH 30/59] document Shops schemas --- lib/collections/schemas/shops.js | 59 +++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/collections/schemas/shops.js b/lib/collections/schemas/shops.js index 4df05386a51..e12ffdb3342 100644 --- a/lib/collections/schemas/shops.js +++ b/lib/collections/schemas/shops.js @@ -8,7 +8,14 @@ import { Workflow } from "./workflow"; import { registerSchema } from "@reactioncommerce/reaction-collections"; /** - * CustomEmailSettings Schema + * @name CustomEmailSettings + * @namespace schemas + * @type {SimpleSchema} + * @property {String} service optional + * @property {String} username optional + * @property {String} password optional + * @property {String} host optional + * @property {Number} port optional */ export const CustomEmailSettings = new SimpleSchema({ service: { @@ -36,7 +43,15 @@ export const CustomEmailSettings = new SimpleSchema({ registerSchema("CustomEmailSettings", CustomEmailSettings); /** - * Currency Schema + * @name Currency + * @namespace schemas + * @type {SimpleSchema} + * @property {String} symbol default value: $ + * @property {String} format default value: %s%v + * @property {Number} scale optional, default value: 2 + * @property {String} decimal optional, default value: . + * @property {String} thousand optional, default value: , + * @property {Number} rate optional */ export const Currency = new SimpleSchema({ symbol: { @@ -71,7 +86,11 @@ export const Currency = new SimpleSchema({ registerSchema("Currency", Currency); /** - * Locale Schema + * @name Locale + * @namespace schemas + * @type {SimpleSchema} + * @property {Object} continents blackbox + * @property {Object} countries blackbox */ export const Locale = new SimpleSchema({ continents: { @@ -87,9 +106,13 @@ export const Locale = new SimpleSchema({ registerSchema("Locale", Locale); /** - * Languages Schema + * @name Languages + * @namespace schemas + * @type {SimpleSchema} + * @property {String} label required + * @property {String} i18n required + * @property {Boolean} enabled, default value: true */ - export const Languages = new SimpleSchema({ label: { type: String @@ -106,7 +129,11 @@ export const Languages = new SimpleSchema({ registerSchema("Languages", Languages); /** - * ShopTheme Schema + * @name ShopTheme + * @namespace schemas + * @type {SimpleSchema} + * @property {String} themeId required + * @property {String} styles optional */ export const ShopTheme = new SimpleSchema({ themeId: { @@ -121,7 +148,11 @@ export const ShopTheme = new SimpleSchema({ registerSchema("ShopTheme", ShopTheme); /** - * Shop Theme Schema + * @name BrandAsset + * @namespace schemas + * @type {SimpleSchema} + * @property {String} mediaId optional + * @property {String} type optional */ export const BrandAsset = new SimpleSchema({ mediaId: { @@ -136,6 +167,14 @@ export const BrandAsset = new SimpleSchema({ registerSchema("BrandAsset", BrandAsset); +/** + * @name MerchantShop + * @namespace schemas + * @type {SimpleSchema} + * @property {String} _id Shop label + * @property {String} slug Shop slug + * @property {String} name Shop name + */ const MerchantShop = new SimpleSchema({ _id: { type: String, @@ -154,7 +193,11 @@ const MerchantShop = new SimpleSchema({ registerSchema("MerchantShop", MerchantShop); /** - * Shop Schema + * @name Shop + * @namespace schemas + * @type {SimpleSchema} + * @property {String} _id optional + * @property {String} slug optional */ export const Shop = new SimpleSchema({ "_id": { From 14cffc58481afbf9aff5f26aa8750dde2ac11d6d Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:09:22 -0700 Subject: [PATCH 31/59] jsdoc: add Meteor/Cart @namespace methods as @membersof --- server/methods/core/cart.js | 96 +++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/server/methods/core/cart.js b/server/methods/core/cart.js index 93d904e559e..c30b10aaf19 100644 --- a/server/methods/core/cart.js +++ b/server/methods/core/cart.js @@ -7,7 +7,8 @@ import * as Collections from "/lib/collections"; import { Logger, Reaction } from "/server/api"; /** - * quantityProcessing + * @method quantityProcessing + * @private * @summary perform calculations admissibility of adding product to cart * @param {Object} product - product to add to Cart * @param {Object} variant - product variant @@ -44,7 +45,8 @@ function quantityProcessing(product, variant, itemQty = 1) { } /** - * getSessionCarts + * @method getSessionCarts + * @private * @summary get Cart cursor with all session carts * @param {String} userId - current user _id * @param {String} sessionId - current user session id @@ -96,28 +98,23 @@ function removeShippingAddresses(cart) { } /** - * Reaction Cart Methods - */ - + * @file Meteor for Cart + * + * @namespace Meteor/Cart +*/ Meteor.methods({ /** - * cart/mergeCart - * @summary merge matching sessionId cart into specified userId cart - * - * There should be one cart for each independent, non logged in user session - * When a user logs in that cart now belongs to that user and we use the a - * single user cart. - * If they are logged in on more than one devices, regardless of session,the - * user cart will be used - * If they had more than one cart, on more than one device,logged in at - * separate times then merge the carts - * - * @param {String} cartId - cartId of the cart to merge matching session - * carts into. + * @method cart/mergeCart + * @summary Merge matching sessionId cart into specified userId cart + * @description There should be one cart for each independent, non-logged-in user session. + * When a user logs in that cart now belongs to that user and we use the a single user cart. + * If they are logged in on more than one devices, regardless of session,the user cart will be used + * If they had more than one cart, on more than one device,logged in at separate times then merge the carts + * @memberof Meteor/Cart + * @param {String} cartId - cartId of the cart to merge matching session carts into. * @param {String} [currentSessionId] - current client session id - * @todo I think this method should be moved out from methods to a Function - * Declaration to keep it more secure + * @todo I think this method should be moved out from methods to a Function Declaration to keep it more secure * @return {Object|Boolean} cartId - cartId on success or false */ "cart/mergeCart": function (cartId, currentSessionId) { @@ -240,14 +237,13 @@ Meteor.methods({ }, /** - * cart/createCart - * @description create new cart for user, but all checks for current cart's - * existence should go before this method will be called, to keep it clean + * @method cart/createCart + * @description create new cart for user, but all checks for current cart's existence should go before this method will be called, to keep it clean * @summary create and return new cart for user + * @memberof Meteor/Cart * @param {String} userId - userId to create cart for * @param {String} sessionId - current client session id - * @todo I think this method should be moved out from methods to a Function - * Declaration to keep it more secure + * @todo I think this method should be moved out from methods to a Function Declaration to keep it more secure * @returns {String} cartId - users cartId */ "cart/createCart": function (userId, sessionId) { @@ -317,12 +313,12 @@ Meteor.methods({ }, /** - * cart/addToCart + * @method cart/addToCart * @summary add items to a user cart - * when we add an item to the cart, we want to break all relationships - * with the existing item. We want to fix price, qty, etc into history - * however, we could check reactively for price /qty etc, adjustments on - * the original and notify them + * @description when we add an item to the cart, we want to break all relationships with the existing item. + * We want to fix price, qty, etc into history + * however, we could check reactively for price /qty etc, adjustments on the original and notify them + * @memberof Meteor/Cart * @param {String} productId - productId to add to Cart * @param {String} variantId - product variant _id * @param {Number} [itemQty] - qty to add to cart @@ -481,7 +477,8 @@ Meteor.methods({ }, /** - * cart/removeFromCart + * @method cart/removeFromCart + * @memberof Meteor/Cart * @summary removes or adjust quantity of a variant from the cart * @param {String} itemId - cart item _id * @param {Number} [quantity] - if provided will adjust increment by quantity @@ -572,8 +569,10 @@ Meteor.methods({ Meteor.call("cart/resetShipmentMethod", cart._id); return cartResult; }, + /** - * cart/setShipmentMethod + * @method cart/setShipmentMethod + * @memberof Meteor/Cart * @summary saves method as order default * @param {String} cartId - cartId to apply shipmentMethod * @param {Object} method - shipmentMethod object @@ -641,7 +640,8 @@ Meteor.methods({ }, /** - * cart/setUserCurrency + * @method cart/setUserCurrency + * @memberof Meteor/Cart * @summary saves user currency in cart, to be paired with order/setCurrencyExhange * @param {String} cartId - cartId to apply setUserCurrency * @param {String} userCurrency - userCurrency to set to cart @@ -700,7 +700,8 @@ Meteor.methods({ }, /** - * cart/resetShipmentMethod + * @method cart/resetShipmentMethod + * @memberof Meteor/Cart * @summary removes `shipmentMethod` object from cart * @param {String} cartId - cart _id * @return {Number} update result @@ -724,7 +725,8 @@ Meteor.methods({ }, /** - * cart/setShipmentAddress + * @method cart/setShipmentAddress + * @memberof Meteor/Cart * @summary adds address book to cart shipping * @param {String} cartId - cartId to apply shipmentMethod * @param {Object} address - addressBook object @@ -867,7 +869,8 @@ Meteor.methods({ }, /** - * cart/setPaymentAddress + * @method cart/setPaymentAddress + * @memberof Meteor/Cart * @summary adds addressbook to cart payments * @param {String} cartId - cartId to apply payment address * @param {Object} address - addressBook object @@ -918,17 +921,17 @@ Meteor.methods({ return Collections.Cart.update(selector, update); }, + /** - * cart/unsetAddresses - * @description removes address from cart. + * @method cart/unsetAddresses + * @summary removes address from cart. + * @memberof Meteor/Cart * @param {String} addressId - address._id * @param {String} userId - cart owner _id * @param {String} [type] - billing default or shipping default * @since 0.10.1 - * @todo check if no more address in cart as shipping, we should reset - * `cartWorkflow` to second step - * @return {Number|Object|Boolean} The number of removed documents or error - * object or `false` if we don't need to update cart + * @todo check if no more address in cart as shipping, we should reset `cartWorkflow` to second step + * @return {Number|Object|Boolean} The number of removed documents or errorobject or `false` if we don't need to update cart */ "cart/unsetAddresses": function (addressId, userId, type) { check(addressId, String); @@ -987,10 +990,10 @@ Meteor.methods({ }, /** - * cart/submitPayment - * @summary saves a submitted payment to cart, triggers workflow - * and adds "paymentSubmitted" to cart workflow - * Note: this method also has a client stub, that forwards to cartCompleted + * @method cart/submitPayment + * @memberof Meteor/Cart + * @summary saves a submitted payment to cart, triggers workflow and adds "paymentSubmitted" to cart workflow + * @description Note: this method also has a client stub, that forwards to cartCompleted * @param {Object|Array} paymentMethods - an array of paymentMethods or (deprecated) a single paymentMethod object * @return {String} returns update result */ @@ -1091,6 +1094,7 @@ Meteor.methods({ /** * @method cart/setAnonymousUserEmail + * @memberof Meteor/Cart * @summary assigns email to anonymous user's cart instance * @param {Object} userId - current user's Id * @param {String} email - email to set for anonymous user's cart instance From bc0b804bb842a3d8656275618f25c6e336db6c1a Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:14:04 -0700 Subject: [PATCH 32/59] jsdoc: add Meteor/Email @namespace methods as @memberof --- server/methods/email.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/server/methods/email.js b/server/methods/email.js index a44a90f652a..d247fcf57a2 100644 --- a/server/methods/email.js +++ b/server/methods/email.js @@ -4,9 +4,18 @@ import { check, Match } from "meteor/check"; import { Jobs, Packages } from "/lib/collections"; import { Logger, Reaction } from "/server/api"; +/** + * @file Meteor methods for Email + * + * + * @namespace Meteor/Email +*/ Meteor.methods({ /** - * Verify the current email configuration + * @name verifySettings + * @method + * @summary Verify the current email configuration + * @memberof Meteor/Email * @param {Object} settings - optional settings object (otherwise uses settings in database) * @return {Boolean} - returns true if SMTP connection succeeds */ @@ -57,9 +66,11 @@ Meteor.methods({ } }, - /** - * Save new email configuration + * @name saveSettings + * @method + * @summary Save new email configuration + * @memberof Meteor/Email * @param {Object} settings - mail provider settings * @return {Boolean} - returns true if update succeeds */ @@ -90,9 +101,11 @@ Meteor.methods({ return true; }, - /** - * Retry a failed or cancelled email job + * @name retryFailed + * @method + * @summary Retry a failed or cancelled email job + * @memberof Meteor/Email * @param {String} jobId - a sendEmail job ID * @return {Boolean} - returns true if job is successfully restarted */ From 792f5412bfa00e69fb2c0b063c53180d08fb2b3f Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:21:36 -0700 Subject: [PATCH 33/59] jsdoc: add Meteor/Group @namespace methods as @memberof --- server/methods/core/groups.js | 40 +++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/server/methods/core/groups.js b/server/methods/core/groups.js index c8be19899a1..e0acdcd1858 100644 --- a/server/methods/core/groups.js +++ b/server/methods/core/groups.js @@ -7,11 +7,16 @@ import { Accounts, Groups } from "/lib/collections"; import { getSlug } from "/lib/api"; /** - * Reaction Permission Group Methods - */ + * @file Reaction permission group methods + * + * + * @namespace Meteor/Group +*/ Meteor.methods({ /** - * group/createGroup + * @name group/createGroup + * @method + * @memberof Meteor/Group * @summary creates a new permission group for a shop * It creates permission group for a given shop with passed in roles * @param {Object} groupData - info about group to create @@ -63,9 +68,11 @@ Meteor.methods({ }, /** - * group/updateGroup + * @name group/updateGroup + * @method + * @memberof Meteor/Group * @summary updates a permission group for a shop - * changes the details of a group (name, desc, permissions etc) to the values passed in. + * @description changes the details of a group (name, desc, permissions etc) to the values passed in. * It also goes into affected user data to modify both the groupName (using Accounts schema) * and group permissions (using "accounts/removeUserPermissions") * @param {Object} groupId - group to be updated @@ -113,10 +120,13 @@ Meteor.methods({ Logger.error(error); throw new Meteor.Error(500, "Update not successful"); }, + /** - * group/addUser + * @name group/addUser + * @method + * @memberof Meteor/Group * @summary adds a user to a permission group - * It updates the user's list of permissions/roles with the defined the list defined for the group + * @description It updates the user's list of permissions/roles with the defined the list defined for the group * (NB: At this time, a user only belongs to only one group per shop) * @param {String} userId - current data of the group to be updated * @param {String} groupId - id of the group @@ -185,9 +195,11 @@ Meteor.methods({ }, /** - * group/removeUser + * @name group/removeUser + * @method + * @memberof Meteor/Group * @summary removes a user from a group for a shop, and adds them to the default customer group. - * It updates the user's permission list to reflect. (NB: At this time, a user only belongs to only one group per shop) + * @description It updates the user's permission list to reflect. (NB: At this time, a user only belongs to only one group per shop) * @param {String} userId - current data of the group to be updated * @param {String} groupId - name of the group * @return {Object} - object.status of 200 on success or Error object on failure @@ -223,6 +235,7 @@ Meteor.methods({ /** * changeMarketplaceOwner + * @private * @summary checks if the user making the request is allowed to make invitation to that group * @param {Object} options - * @param {String} options.userId - userID @@ -236,6 +249,15 @@ function changeMarketplaceOwner({ userId, permissions }) { Meteor.users.update({ _id: Meteor.userId() }, { $unset: { [`roles.${Roles.GLOBAL_GROUP}`]: "" } }); } +/** + * setUserPermissions + * @private + * @summary set user permissions + * @param {Object} users - + * @param {String} permissions - + * @param {String} shopId - + * @return {null} - + */ function setUserPermissions(users, permissions, shopId) { let affectedUsers = users; if (!Array.isArray(users)) { From af94e232ca88e5c4aa5f8285bff5d9ea7cdcdac3 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:30:33 -0700 Subject: [PATCH 34/59] jsdoc: add Meteor/Inventory @namespace methods as @memberof --- .../inventory/server/methods/statusChanges.js | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/imports/plugins/included/inventory/server/methods/statusChanges.js b/imports/plugins/included/inventory/server/methods/statusChanges.js index 8ab88ec31d0..6bfcf808b53 100644 --- a/imports/plugins/included/inventory/server/methods/statusChanges.js +++ b/imports/plugins/included/inventory/server/methods/statusChanges.js @@ -28,13 +28,17 @@ import { Logger, Reaction } from "/server/api"; // DDPRateLimiter.addRule(addReserveRule, 5, 1000); // DDPRateLimiter.addRule(addBackorderRule, 5, 1000); -// -// Inventory methods -// - +/** + * @file Meteor methods for Inventory + * + * + * @namespace Meteor/Inventory +*/ Meteor.methods({ /** - * inventory/setStatus + * @name setStatus + * @method + * @memberof Meteor/Inventory * @summary sets status from one status to a new status. Defaults to "new" to "reserved" * @param {Array} cartItems array of objects of type Schemas.CartItems * @param {String} status optional - sets the inventory workflow status, defaults to "reserved" @@ -144,8 +148,11 @@ Meteor.methods({ `finished creating ${reservationCount} new ${reservationStatus} reservations`); return reservationCount; }, + /** - * inventory/clearStatus + * @name clearStatus + * @method + * @memberof Meteor/Inventory * @summary used to reset status on inventory item (defaults to "new") * @param {Array} cartItems array of objects Schemas.CartItem * @param {[type]} status optional reset workflow.status, defaults to "new" @@ -197,8 +204,11 @@ Meteor.methods({ } Logger.debug("inventory/clearReserve", newStatus); }, + /** - * inventory/clearReserve + * @name clearReserve + * @method + * @memberof Meteor/Inventory * @summary resets "reserved" items to "new" * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} @@ -207,9 +217,12 @@ Meteor.methods({ check(cartItems, [Schemas.CartItem]); return Meteor.call("inventory/clearStatus", cartItems); }, + /** - * inventory/clearReserve - * converts new items to reserved, or backorders + * @name clearReserve + * @summary converts new items to reserved, or backorders + * @method + * @memberof Meteor/Inventory * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -217,15 +230,14 @@ Meteor.methods({ check(cartItems, [Schemas.CartItem]); return Meteor.call("inventory/setStatus", cartItems); }, + /** - * inventory/backorder - * @summary is used by the cart process to create a new Inventory - * backorder item, but this could be used for inserting any - * custom inventory. - * - * A note on DDP Limits. - * As these are wide open we defined some ddp limiting rules http://docs.meteor.com/#/full/ddpratelimiter - * + * @name backorder + * @summary is used by the cart process to create a new Inventory backorder item, + * but this could be used for inserting any custom inventory. + * @method + * @description A note on DDP Limits: As these are wide open we defined some {@link http://docs.meteor.com/#/full/ddpratelimiter ddp limiting rules} + * @memberof Meteor/Inventory * @param {Object} reservation Schemas.Inventory * @param {Number} backOrderQty number of backorder items to create * @returns {Number} number of inserted backorder documents @@ -282,20 +294,27 @@ Meteor.methods({ Logger.error("skipped bulk operations backorder updates."); return null; }, - // - // send low stock warnings - // + + /** + * @name lowStock + * @summary send low stock warnings + * @method + * @memberof Meteor/Inventory + * @param {Object} product object type Product + * @return {undefined} + * @todo implement inventory/lowstock calculations + */ "inventory/lowStock": function (product) { check(product, Schemas.Product); - // - // TODO: implement inventory/lowstock calculations // placeholder is here to give plugins a place to hook into - // Logger.debug("inventory/lowStock"); }, + /** - * inventory/remove - * delete an inventory item permanently + * @name remove + * @summary delete an inventory item permanently + * @method + * @memberof Meteor/Inventory * @param {Object} inventoryItem object type Schemas.Inventory * @return {String} return remove result */ @@ -317,9 +336,12 @@ Meteor.methods({ Logger.debug("inventory/remove", inventoryItem); return Inventory.remove(inventoryItem); }, + /** - * inventory/shipped - * mark inventory as shipped + * @name shipped + * @method + * @memberof Meteor/Inventory + * @summary mark inventory as shipped * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -327,9 +349,12 @@ Meteor.methods({ check(cartItems, [Schemas.CartItem]); return Meteor.call("inventory/setStatus", cartItems, "shipped", "sold"); }, + /** - * inventory/sold - * mark inventory as sold + * @name sold + * @method + * @memberof Meteor/Inventory + * @summary mark inventory as sold * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -337,9 +362,12 @@ Meteor.methods({ check(cartItems, [Schemas.CartItem]); return Meteor.call("inventory/setStatus", cartItems, "sold", "reserved"); }, + /** - * inventory/return - * mark inventory as returned + * @name return + * @method + * @memberof Meteor/Inventory + * @summary mark inventory as returned * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -347,9 +375,12 @@ Meteor.methods({ check(cartItems, [Schemas.CartItem]); return Meteor.call("inventory/setStatus", cartItems, "return"); }, + /** - * inventory/returnToStock - * mark inventory as return and available for sale + * @name returnToStock + * @method + * @memberof Meteor/Inventory + * @summary mark inventory as return and available for sale * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ From cc46f7d9aa31afd53be5cb680cf066a7eb57c759 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:32:45 -0700 Subject: [PATCH 35/59] jsdoc: add Meteor/Notification @namespacce methods as @memberof --- .../server/methods/notifications.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/imports/plugins/included/notifications/server/methods/notifications.js b/imports/plugins/included/notifications/server/methods/notifications.js index 678c4b55a4e..f45efc8a594 100644 --- a/imports/plugins/included/notifications/server/methods/notifications.js +++ b/imports/plugins/included/notifications/server/methods/notifications.js @@ -4,11 +4,16 @@ import { Reaction, Logger } from "/server/api"; import { Notifications, Packages } from "/lib/collections"; /** - * Reaction Notification methods - */ + * @file Meteor methods for Notifications + * + * + * @namespace Meteor/Notification +*/ Meteor.methods({ /** - * notification/send + * @name send + * @memberof Meteor/Notification + * @method * @summary This send a notification to a user * @param {String} userId - The user * @param {String} type - The type of Notification @@ -63,7 +68,9 @@ Meteor.methods({ }, /** - * notification/markOneAsRead + * @name markOneAsRead + * @memberof Meteor/Notification + * @method * @summary This marks all user's notification as ready * @param {String} id - The notification id * @return {Object} returns cursor @@ -79,7 +86,9 @@ Meteor.methods({ }, /** - * notification/delete + * @name delete + * @memberof Meteor/Notification + * @method * @summary This deletes a notification * @param {String} id - The notification id * @return {Object} return cursor From cdf17c5293da7a76883256c46eb89493101af35f Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:35:38 -0700 Subject: [PATCH 36/59] jsdoc: add Meteor/SMS @namespace methods as @memberof --- .../plugins/included/sms/server/methods/sms.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/imports/plugins/included/sms/server/methods/sms.js b/imports/plugins/included/sms/server/methods/sms.js index 9125cfb8d1f..93a633676ee 100644 --- a/imports/plugins/included/sms/server/methods/sms.js +++ b/imports/plugins/included/sms/server/methods/sms.js @@ -5,13 +5,17 @@ import { check } from "meteor/check"; import { Sms, Accounts } from "/lib/collections"; import { Reaction, Logger } from "/server/api"; - /** - * Sms Methods - */ + * @file Meteor methods for SMS + * + * + * @namespace Meteor/SMS +*/ Meteor.methods({ /** - * sms/saveSettings + * @name saveSettings + * @method + * @memberof Meteor/SMS * @summary This save the sms provider settings * @param {Object} settings - settings * @return {object} returns result @@ -30,7 +34,9 @@ Meteor.methods({ }, /** - * sms/send + * @name send + * @method + * @memberof Meteor/SMS * @summary This send the sms to the user * @param {String} message - The message to send * @param {String} userId - The user to receive the message From dcedb24f5e5c219a5828b4deb2f94203f2d154ef Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:41:43 -0700 Subject: [PATCH 37/59] jsdoc: add Meteor/Workflow @namespace methods as @memberof --- .../core/checkout/server/methods/workflow.js | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/imports/plugins/core/checkout/server/methods/workflow.js b/imports/plugins/core/checkout/server/methods/workflow.js index 45c695613a2..d7eeb86bbf0 100644 --- a/imports/plugins/core/checkout/server/methods/workflow.js +++ b/imports/plugins/core/checkout/server/methods/workflow.js @@ -7,13 +7,19 @@ import { Logger, Reaction } from "/server/api"; /* eslint no-shadow: 0 */ +/** + * @file Meteor methods for SMS + * + * + * @namespace Meteor/Workflow +*/ Meteor.methods({ /** - * workflow/pushCartWorkflow + * @name pushCartWorkflow + * @memberof Meteor/Workflow + * @method * @summary updates cart workflow status - * @description status in the workflow is stored as the current active - * workflow step. - * + * @description status in the workflow is stored as the current active workflow step. * first sets, second call moves status to next workflow * additional calls do nothing * user permissions to template are verified @@ -206,11 +212,11 @@ Meteor.methods({ }, /** - * workflow/revertCartWorkflow - * @description if something was changed on the previous `cartWorkflow` steps - * we need to revert to this step to renew the order - * @param {String} newWorkflowStatus - name of `cartWorkflow` step, which - * we need to revert + * @name revertCartWorkflow + * @memberof Meteor/Workflow + * @method + * @summary if something was changed on the previous `cartWorkflow` steps, we need to revert to this step to renew the order + * @param {String} newWorkflowStatus - name of `cartWorkflow` step, which we need to revert * @todo need tests * @return {Number|Boolean} cart update results */ @@ -242,18 +248,17 @@ Meteor.methods({ }, /** - * workflow/pushOrderWorkflow - * Push the status as the current workflow step, - * move the current status to completed worflow steps + * @name pushOrderWorkflow + * @summary Update the order workflow: Push the status as the current workflow step, move the current status to completed worflow steps * - * Step 1 meteor call to push a new workflow + * @description Step 1 meteor call to push a new workflow * Meteor.call("workflow/pushOrderWorkflow", "coreOrderWorkflow", "processing", this); - * NOTE: "coreOrderWorkflow", "processing" will be combined into "coreOrderWorkflow/processing" - * and set as the status + * NOTE: "coreOrderWorkflow", "processing" will be combined into "coreOrderWorkflow/processing" and set as the status * * Step 2 (this method) of the "workflow/pushOrderWorkflow" flow; Try to update the current status * - * @summary Update the order workflow + * @method + * @memberof Meteor/Workflow * @param {String} workflow workflow to push to * @param {String} status - Workflow status * @param {Order} order - Schemas.Order, an order object @@ -284,10 +289,11 @@ Meteor.methods({ }, /** - * workflow/pullOrderWorkflow - * Push the status as the current workflow step, - * move the current status to completed worflow steps + * @name pullOrderWorkflow + * @description Push the status as the current workflow step, move the current status to completed worflow steps * @summary Pull a previous order status + * @method + * @memberof Meteor/Workflow * @param {String} workflow workflow to push to * @param {String} status - Workflow status * @param {Order} order - Schemas.Order, an order object @@ -313,6 +319,15 @@ Meteor.methods({ return result; }, + /** + * @name pushItemWorkflow + * @method + * @memberof Meteor/Workflow + * @param {String} status Workflow status + * @param {Object} order Schemas.Order, an order object + * @param {String[]} itemIds Array of item IDs + * @return {Boolean} true if update was successful + */ "workflow/pushItemWorkflow": function (status, order, itemIds) { check(status, String); check(order, Object); From d3f30f0b3e60c94c6b13ce99004e6f141fb6a0ab Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:49:54 -0700 Subject: [PATCH 38/59] jsdoc: add Meteor/Product @namespace methods as @memberof --- server/methods/catalog.js | 104 ++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 28 deletions(-) diff --git a/server/methods/catalog.js b/server/methods/catalog.js index 59c8c7657e9..209d05c2ee9 100644 --- a/server/methods/catalog.js +++ b/server/methods/catalog.js @@ -8,15 +8,20 @@ import { ProductRevision as Catalog } from "/imports/plugins/core/revisions/serv import { Media, Products, Revisions, Tags } from "/lib/collections"; import { Logger, Reaction } from "/server/api"; -/** - * Reaction Product Methods - */ /* eslint new-cap: 0 */ /* eslint no-loop-func: 0 */ /* eslint quotes: 0 */ +/** + * @file Meteor methods for Product + * + * + * @namespace Meteor/Product +*/ + /** * updateVariantProductField + * @private * @summary updates the variant * @param {Array} variants - the array of variants * @param {String} field - the field to update @@ -31,6 +36,7 @@ function updateVariantProductField(variants, field, value) { /** * @array toDenormalize + * @private * @summary contains a list of fields, which should be denormalized * @type {string[]} */ @@ -44,6 +50,7 @@ const toDenormalize = [ /** * @function createTitle + * @private * @description Recursive method which trying to find a new `title`, given the * existing copies * @param {String} newTitle - product `title` @@ -99,6 +106,7 @@ function createTitle(newTitle, productId) { /** * @function createHandle + * @private * @description Recursive method which trying to find a new `handle`, given the * existing copies * @param {String} productHandle - product `handle` @@ -157,6 +165,7 @@ function createHandle(productHandle, productId) { /** * @function copyMedia + * @private * @description copy images links to cloned variant from original * @param {String} newId - [cloned|original] product _id * @param {String} variantOldId - old variant _id @@ -177,6 +186,7 @@ function copyMedia(newId, variantOldId, variantNewId) { /** * @function denormalize + * @private * @description With flattened model we do not want to get variant docs in * `products` publication, but we need some data from variants to display price, * quantity, etc. That's why we are denormalizing these properties into product @@ -236,8 +246,8 @@ function denormalize(id, field) { /** * isSoldOut - * @description We are stop accepting new orders if product marked as - * `isSoldOut`. + * @private + * @summary We are stop accepting new orders if product marked as `isSoldOut`. * @param {Array} variants - Array with top-level variants * @return {Boolean} true if summary product quantity is zero. */ @@ -252,8 +262,8 @@ function isSoldOut(variants) { /** * isLowQuantity - * @description If at least one of the variants is less than the threshold, - * then function returns `true` + * @private + * @summary If at least one of the variants is less than the threshold, then function returns `true` * @param {Array} variants - array of child variants * @return {boolean} low quantity or not */ @@ -271,8 +281,8 @@ function isLowQuantity(variants) { /** * isBackorder - * @description Is products variants is still available to be ordered after - * summary variants quantity is zero + * @private + * @description Is products variants is still available to be ordered after summary variants quantity is zero * @param {Array} variants - array with variant objects * @return {boolean} is backorder allowed or not for a product */ @@ -285,7 +295,8 @@ function isBackorder(variants) { /** * flushQuantity - * @description if variant `inventoryQuantity` not zero, function update it to + * @private + * @summary if variant `inventoryQuantity` not zero, function update it to * zero. This needed in case then option with it's own `inventoryQuantity` * creates to top-level variant. In that case top-level variant should display * sum of his options `inventoryQuantity` fields. @@ -315,7 +326,9 @@ function flushQuantity(id) { Meteor.methods({ /** - * products/cloneVariant + * @name cloneVariant + * @memberof Meteor/Product + * @method * @summary clones a product variant into a new variant * @description the method copies variants, but will also create and clone * child variants (options) @@ -438,7 +451,9 @@ Meteor.methods({ }, /** - * products/createVariant + * @name createVariant + * @memberof Meteor/Product + * @method * @summary initializes empty variant template * @param {String} parentId - the product _id or top level variant _id where * we create variant @@ -504,7 +519,9 @@ Meteor.methods({ }, /** - * products/updateVariant + * @name updateVariant + * @memberof Meteor/Product + * @method * @summary update individual variant with new values, merges into original * only need to supply updated information. Currently used for a one use case * - to manage top-level variant autoform. @@ -553,7 +570,9 @@ Meteor.methods({ }, /** - * products/deleteVariant + * @name deleteVariant + * @memberof Meteor/Product + * @method * @summary delete variant, which should also delete child variants * @param {String} variantId - variantId to delete * @returns {Boolean} returns update results: `true` - if at least one variant @@ -598,7 +617,9 @@ Meteor.methods({ }, /** - * products/cloneProduct + * @name cloneProduct + * @memberof Meteor/Product + * @method * @summary clone a whole product, defaulting visibility, etc * in the future we are going to do an inheritance product * that maintains relationships with the cloned product tree @@ -735,7 +756,9 @@ Meteor.methods({ }, /** - * products/createProduct + * @name createProduct + * @memberof Meteor/Product + * @method * @summary when we create a new product, we create it with an empty variant. * all products have a variant with pricing and details * @param {Object} [product] - optional product object @@ -775,7 +798,9 @@ Meteor.methods({ }, /** - * products/archiveProduct + * @name archiveProduct + * @memberof Meteor/Product + * @method * @summary archive a product and unlink it from all media * @param {String} productId - productId to delete * @returns {Number} returns number of removed products @@ -861,7 +886,9 @@ Meteor.methods({ }, /** - * products/updateProductField + * @name updateProductField + * @memberof Meteor/Product + * @method * @summary update single product or variant field * @param {String} _id - product._id or variant._id to update * @param {String} field - key to update @@ -942,7 +969,9 @@ Meteor.methods({ }, /** - * products/updateProductTags + * @name updateProductTags + * @memberof Meteor/Product + * @method * @summary method to insert or update tag with hierarchy * @param {String} productId - productId * @param {String} tagName - tagName @@ -1017,7 +1046,9 @@ Meteor.methods({ }, /** - * products/removeProductTag + * @name removeProductTag + * @memberof Meteor/Product + * @method * @summary method to remove tag from product * @param {String} productId - productId * @param {String} tagId - tagId @@ -1047,7 +1078,9 @@ Meteor.methods({ }, /** - * products/setHandle + * @name setHandle + * @memberof Meteor/Product + * @method * @summary copy of "products/setHandleTag", but without tag * @param {String} productId - productId * @returns {String} handle - product handle @@ -1076,7 +1109,9 @@ Meteor.methods({ }, /** - * products/setHandleTag + * @name setHandleTag + * @memberof Meteor/Product + * @method * @summary set or toggle product handle * @param {String} productId - productId * @param {String} tagId - tagId @@ -1130,7 +1165,9 @@ Meteor.methods({ }, /** - * products/updateProductPosition + * @name updateProductPosition + * @memberof Meteor/Product + * @method * @summary update product grid positions * @param {String} productId - productId * @param {Object} positionData - an object with position,dimensions @@ -1172,7 +1209,9 @@ Meteor.methods({ }, /** - * products/updateVariantsPosition + * @name updateVariantsPosition + * @memberof Meteor/Product + * @method * @description updates top level variant position index * @param {Array} sortedVariantIds - array of top level variant `_id`s * @since 0.11.0 @@ -1208,7 +1247,9 @@ Meteor.methods({ }, /** - * products/updateMetaFields + * @name updateMetaFields + * @memberof Meteor/Product + * @method * @summary update product metafield * @param {String} productId - productId * @param {Object} updatedMeta - update object with metadata @@ -1272,7 +1313,9 @@ Meteor.methods({ }, /** - * products/removeMetaFields + * @name removeMetaFields + * @memberof Meteor/Product + * @method * @summary update product metafield * @param {String} productId - productId * @param {Object} metafields - metadata object to remove @@ -1303,7 +1346,9 @@ Meteor.methods({ }, /** - * products/publishProduct + * @name publishProduct + * @memberof Meteor/Product + * @method * @summary publish (visibility) of product * @todo hook into publishing flow * @param {String} productId - productId @@ -1378,8 +1423,11 @@ Meteor.methods({ Logger.debug("invalid product visibility ", productId); throw new Meteor.Error("Bad Request"); }, + /** - * products/publishProduct + * @name publishProduct + * @memberof Meteor/Product + * @method * @summary publish (visibility) of product * @todo hook into publishing flow * @param {String} productId - productId From 254a9fc5fe066f2fc95a85e2d5220174d958d611 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 21:53:17 -0700 Subject: [PATCH 39/59] jsdoc: add Meteor/Shop @namespace methods as @memberof --- server/methods/core/shop.js | 51 +++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/server/methods/core/shop.js b/server/methods/core/shop.js index 1e8769f0909..669b1fdad43 100644 --- a/server/methods/core/shop.js +++ b/server/methods/core/shop.js @@ -11,11 +11,16 @@ import * as Collections from "/lib/collections"; import * as Schemas from "/lib/collections/schemas"; /** - * Reaction Shop Methods - */ + * @file Meteor methods for Shop + * + * + * @namespace Meteor/Shop +*/ Meteor.methods({ /** - * shop/createShop + * @name createShop + * @method + * @memberof Meteor/Shop * @param {String} shopAdminUserId - optionally create shop for provided userId * @param {Object} shopData - optionally provide shop object to customize * @return {String} return shopId @@ -148,7 +153,9 @@ Meteor.methods({ }, /** - * shop/getLocale + * @name getLocale + * @method + * @memberof Meteor/Shop * @summary determine user's countryCode and return locale object * determine local currency and conversion rate from shop currency * @return {Object} returns user location and locale @@ -252,7 +259,9 @@ Meteor.methods({ }, /** - * shop/getCurrencyRates + * @name getCurrencyRates + * @method + * @memberof Meteor/Shop * @summary It returns the current exchange rate against the shop currency * usage: Meteor.call("shop/getCurrencyRates","USD") * @param {String} currency code @@ -274,7 +283,9 @@ Meteor.methods({ }, /** - * shop/fetchCurrencyRate + * @name fetchCurrencyRate + * @method + * @memberof Meteor/Shop * @summary fetch the latest currency rates from * https://openexchangerates.org * usage: Meteor.call("shop/fetchCurrencyRate") @@ -361,7 +372,9 @@ Meteor.methods({ }, /** - * shop/flushCurrencyRate + * @name flushCurrencyRate + * @method + * @memberof Meteor/Shop * @description Method calls by cron job * @summary It removes exchange rates that are too old * usage: Meteor.call("shop/flushCurrencyRate") @@ -412,7 +425,9 @@ Meteor.methods({ }, /** - * shop/updateShopExternalServices + * @name updateShopExternalServices + * @method + * @memberof Meteor/Shop * @description On submit OpenExchangeRatesForm handler * @summary we need to rerun fetch exchange rates job on every form submit, * that's why we update autoform type to "method-update" @@ -458,7 +473,9 @@ Meteor.methods({ }, /** - * shop/locateAddress + * @name locateAddress + * @method + * @memberof Meteor/Shop * @summary determine user's full location for autopopulating addresses * @param {Number} latitude - latitude * @param {Number} longitude - longitude @@ -488,7 +505,9 @@ Meteor.methods({ }, /** - * shop/createTag + * @name createTag + * @method + * @memberof Meteor/Shop * @summary creates new tag * @param {String} tagName - new tag name * @param {Boolean} isTopLevel - if true -- new tag will be created on top of @@ -518,7 +537,9 @@ Meteor.methods({ }, /** - * shop/updateHeaderTags + * @name updateHeaderTags + * @method + * @memberof Meteor/Shop * @summary method to insert or update tag with hierarchy * @param {String} tagName will insert, tagName + tagId will update existing * @param {String} tagId - tagId to update @@ -604,7 +625,9 @@ Meteor.methods({ }, /** - * shop/removeHeaderTag + * @name removeHeaderTag + * @method + * @memberof Meteor/Shop * @param {String} tagId - method to remove tag navigation tags * @param {String} currentTagId - currentTagId * @return {String} returns remove result @@ -644,7 +667,9 @@ Meteor.methods({ }, /** - * shop/hideHeaderTag + * @name hideHeaderTag + * @method + * @memberof Meteor/Shop * @param {String} tagId - method to remove tag navigation tags * @return {String} returns remove result */ From 245252eaad2475c0d9ddefb49c8cceeb8a1556e7 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 22:04:24 -0700 Subject: [PATCH 40/59] add more Meteor/Shop @namespace methods as @memberof --- server/methods/core/shop.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/server/methods/core/shop.js b/server/methods/core/shop.js index 669b1fdad43..4bfe53b7ac3 100644 --- a/server/methods/core/shop.js +++ b/server/methods/core/shop.js @@ -691,7 +691,9 @@ Meteor.methods({ }, /** - * shop/getWorkflow + * @name getWorkflow + * @method + * @memberof Meteor/Shop * @summary gets the current shop workflows * @param {String} name - workflow name * @return {Array} returns workflow array @@ -712,8 +714,11 @@ Meteor.methods({ }); return shopWorkflows; }, + /** - * shop/updateLanguageConfiguration + * @name updateLanguageConfiguration + * @method + * @memberof Meteor/Shop * @summary enable / disable a language * @param {String} language - language name | "all" to bulk enable / disable * @param {Boolean} enabled - true / false @@ -774,7 +779,9 @@ Meteor.methods({ }, /** - * shop/updateCurrencyConfiguration + * @name updateCurrencyConfiguration + * @method + * @memberof Meteor/Shop * @summary enable / disable a currency * @param {String} currency - currency name | "all" to bulk enable / disable * @param {Boolean} enabled - true / false @@ -832,7 +839,9 @@ Meteor.methods({ }, /** - * shop/updateBrandAsset + * @name updateBrandAsset + * @method + * @memberof Meteor/Shop * @param {Object} asset - brand asset {mediaId: "", type, ""} * @return {Int} returns update result */ @@ -882,7 +891,9 @@ Meteor.methods({ }, /* - * shop/togglePackage + * @name togglePackage + * @method + * @memberof Meteor/Shop * @summary enable/disable Reaction package * @param {String} packageId - package _id * @param {Boolean} enabled - current package `enabled` state @@ -901,8 +912,11 @@ Meteor.methods({ } }); }, + /* - * shop/changeLayout + * @name changeLayout + * @method + * @memberof Meteor/Shop * @summary Change the layout for all workflows so you can use a custom one * @param {String} shopId - the shop's ID * @param {String} layout - new layout to use From 93ae033781e9b6400d44ed438cc75aba3bb5a930 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 22:09:27 -0700 Subject: [PATCH 41/59] jsdoc: add Meteor/Workflow/coreOrderWorkflow @namespace methods to Meteor/Workflow --- server/methods/core/workflows/orders.js | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/methods/core/workflows/orders.js b/server/methods/core/workflows/orders.js index 40fd025885c..f95bae22955 100644 --- a/server/methods/core/workflows/orders.js +++ b/server/methods/core/workflows/orders.js @@ -3,21 +3,17 @@ import { Meteor } from "meteor/meteor"; import { check, Match } from "meteor/check"; import { Reaction } from "/server/api"; - -/** - * Step 4 of the "workflow/pushOrderWorkflow" flow - * The following methods are called from Orders.before.update hook. - * - * @see packages/reaction-schema/common/hooks/orders.js - * @see packages/reaction-core/common/methods/workflow.js - */ Meteor.methods({ /** - * workflow/coreOrderWorkflow/coreOrderProcessing - * Workflow method that checks permissions for a given user to allow them to - * move an order into the processing phase. + * @name coreOrderWorkflow/coreOrderProcessing + * @method + * @memberof Meteor/Workflow + * @summary Workflow method that checks permissions for a given user to allow them to move an order into the processing phase. + * @description Step 4 of the "workflow/pushOrderWorkflow" flow - This method is called from Orders.before.update hook. * @param {Object} options An object containing arbitary data * @return {Boolean} true to allow action, false to cancel execution of hook + * @see packages/reaction-schema/common/hooks/orders.js + * @see packages/reaction-core/common/methods/workflow.js */ "workflow/coreOrderWorkflow/coreOrderProcessing": function (options) { check(options, Match.OrderHookOptions()); @@ -27,11 +23,15 @@ Meteor.methods({ }, /** - * workflow/coreOrderWorkflow/coreOrderCompleted - * Workflow method that performs verios check to determine if an order may be - * moved into the completed phase. + * @name coreOrderWorkflow/coreOrderCompleted + * @method + * @memberof Meteor/Workflow + * @summary Workflow method that performs verios check to determine if an order may be moved into the completed phase. + * @description Step 4 of the "workflow/pushOrderWorkflow" flow - This method is called from Orders.before.update hook. * @param {Object} options An object containing arbitary data * @return {Boolean} true to allow action, false to cancel execution of hook + * @see packages/reaction-schema/common/hooks/orders.js + * @see packages/reaction-core/common/methods/workflow.js */ "workflow/coreOrderWorkflow/coreOrderCompleted": function (options) { check(options, Match.OrderHookOptions()); From d0c9fe48169a00a713321fc3b9291d201ed6e72b Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Wed, 18 Oct 2017 22:21:33 -0700 Subject: [PATCH 42/59] jsdoc: add Meteor/Reaction @namespace for one helper method. --- server/methods/helpers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/methods/helpers.js b/server/methods/helpers.js index 711f503701a..7bc06576d59 100644 --- a/server/methods/helpers.js +++ b/server/methods/helpers.js @@ -1,8 +1,16 @@ import { Meteor } from "meteor/meteor"; +/** + * @file Meteor methods for Reaction + * + * + * @namespace Meteor/Reaction +*/ Meteor.methods({ /** - * reaction/getUserId + * @name getUserId + * @method + * @memberof Meteor/Reaction * @summary return server side userId if available * @return {String} userId - if available */ From df8a4b6b789edbc6e40f3b77eb291087500d69aa Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 13:41:09 -0700 Subject: [PATCH 43/59] jsdoc: formatting - use max-length: 120 --- .../core/checkout/server/methods/workflow.js | 7 ++++--- lib/api/account-validation.js | 6 +++++- server/methods/accounts/accounts.js | 15 ++++++++++----- server/methods/core/cart.js | 9 ++++++--- server/methods/core/groups.js | 3 ++- server/methods/core/shop.js | 18 +++++++++--------- server/methods/core/workflows/orders.js | 8 ++++---- 7 files changed, 40 insertions(+), 26 deletions(-) diff --git a/imports/plugins/core/checkout/server/methods/workflow.js b/imports/plugins/core/checkout/server/methods/workflow.js index d7eeb86bbf0..f98c314cca3 100644 --- a/imports/plugins/core/checkout/server/methods/workflow.js +++ b/imports/plugins/core/checkout/server/methods/workflow.js @@ -215,7 +215,8 @@ Meteor.methods({ * @name revertCartWorkflow * @memberof Meteor/Workflow * @method - * @summary if something was changed on the previous `cartWorkflow` steps, we need to revert to this step to renew the order + * @summary if something was changed on the previous `cartWorkflow` steps, + * we need to revert to this step to renew the order * @param {String} newWorkflowStatus - name of `cartWorkflow` step, which we need to revert * @todo need tests * @return {Number|Boolean} cart update results @@ -249,12 +250,12 @@ Meteor.methods({ /** * @name pushOrderWorkflow - * @summary Update the order workflow: Push the status as the current workflow step, move the current status to completed worflow steps + * @summary Update the order workflow: Push the status as the current workflow step, + * move the current status to completed worflow steps * * @description Step 1 meteor call to push a new workflow * Meteor.call("workflow/pushOrderWorkflow", "coreOrderWorkflow", "processing", this); * NOTE: "coreOrderWorkflow", "processing" will be combined into "coreOrderWorkflow/processing" and set as the status - * * Step 2 (this method) of the "workflow/pushOrderWorkflow" flow; Try to update the current status * * @method diff --git a/lib/api/account-validation.js b/lib/api/account-validation.js index 10f6e1e5f6a..ab7d35b794f 100644 --- a/lib/api/account-validation.js +++ b/lib/api/account-validation.js @@ -68,7 +68,11 @@ const validationMethods = { * @name password * @method * @memberof Meteor/Accounts/Validation - * @summary Passwords may be validated 2 ways. 1. "exists" (options.validationLevel = "exists") - Password must not be blank. Thats is the only rule. Used to validate a sign in. 2. undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. Used for validating a new sign up. + * @summary Passwords may be validated 2 ways. + * 1. "exists" (options.validationLevel = "exists") - Password must not be blank. + * Thats is the only rule. Used to validate a sign in. + * 2. undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. + * Used for validating a new sign up. * @example LoginFormValidation.password(pword, { validationLevel: "exists" }) * @param {String} password Password to validate * @param {Object} options Options to apply to the password validator diff --git a/server/methods/accounts/accounts.js b/server/methods/accounts/accounts.js index bd02f42261b..05e64abfecd 100644 --- a/server/methods/accounts/accounts.js +++ b/server/methods/accounts/accounts.js @@ -14,7 +14,8 @@ import { sendUpdatedVerificationEmail } from "/server/api/core/accounts"; /** * @file Meteor methods for Accounts - * Reaction extends {@link https://github.com/meteor/meteor/tree/master/packages/accounts-base MeteorAccounts} with Reaction-specific behavior and user interaction. + * Reaction extends {@link https://github.com/meteor/meteor/tree/master/packages/accounts-base MeteorAccounts} + * with Reaction-specific behavior and user interaction. * @namespace Meteor/Accounts */ @@ -628,7 +629,8 @@ export function inviteShopOwner(options) { /** * @name inviteShopMember - * @summary Invite new admin users (not consumers) to secure access in the dashboard to permissions as specified in packages/roles + * @summary Invite new admin users (not consumers) to secure access in the dashboard to permissions + * as specified in packages/roles * @memberof Meteor/Accounts * @method * @param {Object} options - @@ -824,7 +826,8 @@ export function sendWelcomeEmail(shopId, userId) { * @memberof Meteor/Accounts * @method * @param {String} userId - userId - * @param {Array|String} permissions - Name of role/permission. If array, users returned will have at least one of the roles specified but need not have _all_ roles. + * @param {Array|String} permissions - Name of role/permission. + * If array, users returned will have at least one of the roles specified but need not have _all_ roles. * @param {String} [group] Optional name of group to restrict roles to. User's Roles.GLOBAL_GROUP will also be checked. * @returns {Boolean} success/failure */ @@ -848,7 +851,8 @@ export function addUserPermissions(userId, permissions, group) { * @memberof Meteor/Accounts * @method * @param {String} userId - userId - * @param {Array|String} permissions - Name of role/permission. If array, users returned will have at least one of the roles specified but need not have _all_ roles. + * @param {Array|String} permissions - Name of role/permission. + * If array, users returned will have at least one of the roles specified but need not have _all_ roles. * @param {String} [group] Optional name of group to restrict roles to. * @returns {Boolean} success/failure */ @@ -1001,7 +1005,8 @@ function getDataForEmail(options) { * @name createFallbackLoginToken * @memberof Meteor/Accounts * @method - * @summary Returns a new loginToken for current user, that can be used for special login scenarios - e.g. store the newly created token as cookie on the browser, if the client does not offer local storage. + * @summary Returns a new loginToken for current user, that can be used for special login scenarios + * e.g. store the newly created token as cookie on the browser, if the client does not offer local storage. * @returns {String} loginToken for current user */ export function createFallbackLoginToken() { diff --git a/server/methods/core/cart.js b/server/methods/core/cart.js index c30b10aaf19..31d8ac5568c 100644 --- a/server/methods/core/cart.js +++ b/server/methods/core/cart.js @@ -238,7 +238,8 @@ Meteor.methods({ /** * @method cart/createCart - * @description create new cart for user, but all checks for current cart's existence should go before this method will be called, to keep it clean + * @description create new cart for user, + * but all checks for current cart's existence should go before this method will be called, to keep it clean * @summary create and return new cart for user * @memberof Meteor/Cart * @param {String} userId - userId to create cart for @@ -315,7 +316,8 @@ Meteor.methods({ /** * @method cart/addToCart * @summary add items to a user cart - * @description when we add an item to the cart, we want to break all relationships with the existing item. + * @description when we add an item to the cart, + * we want to break all relationships with the existing item. * We want to fix price, qty, etc into history * however, we could check reactively for price /qty etc, adjustments on the original and notify them * @memberof Meteor/Cart @@ -931,7 +933,8 @@ Meteor.methods({ * @param {String} [type] - billing default or shipping default * @since 0.10.1 * @todo check if no more address in cart as shipping, we should reset `cartWorkflow` to second step - * @return {Number|Object|Boolean} The number of removed documents or errorobject or `false` if we don't need to update cart + * @return {Number|Object|Boolean} The number of removed documents or + * errorobject or `false` if we don't need to update cart */ "cart/unsetAddresses": function (addressId, userId, type) { check(addressId, String); diff --git a/server/methods/core/groups.js b/server/methods/core/groups.js index e0acdcd1858..07adb61f92d 100644 --- a/server/methods/core/groups.js +++ b/server/methods/core/groups.js @@ -199,7 +199,8 @@ Meteor.methods({ * @method * @memberof Meteor/Group * @summary removes a user from a group for a shop, and adds them to the default customer group. - * @description It updates the user's permission list to reflect. (NB: At this time, a user only belongs to only one group per shop) + * @description It updates the user's permission list to reflect. + * (NB: At this time, a user only belongs to only one group per shop) * @param {String} userId - current data of the group to be updated * @param {String} groupId - name of the group * @return {Object} - object.status of 200 on success or Error object on failure diff --git a/server/methods/core/shop.js b/server/methods/core/shop.js index 4bfe53b7ac3..1bd99d675d7 100644 --- a/server/methods/core/shop.js +++ b/server/methods/core/shop.js @@ -890,7 +890,7 @@ Meteor.methods({ }); }, - /* + /** * @name togglePackage * @method * @memberof Meteor/Shop @@ -913,14 +913,14 @@ Meteor.methods({ }); }, - /* - * @name changeLayout - * @method - * @memberof Meteor/Shop - * @summary Change the layout for all workflows so you can use a custom one - * @param {String} shopId - the shop's ID - * @param {String} layout - new layout to use - * @return {Number} mongo update result + /** + * @name changeLayout + * @method + * @memberof Meteor/Shop + * @summary Change the layout for all workflows so you can use a custom one + * @param {String} shopId - the shop's ID + * @param {String} newLayout - new layout to use + * @return {Number} mongo update result */ "shop/changeLayouts": function (shopId, newLayout) { check(shopId, String); diff --git a/server/methods/core/workflows/orders.js b/server/methods/core/workflows/orders.js index f95bae22955..ba3c85d3086 100644 --- a/server/methods/core/workflows/orders.js +++ b/server/methods/core/workflows/orders.js @@ -8,8 +8,8 @@ Meteor.methods({ * @name coreOrderWorkflow/coreOrderProcessing * @method * @memberof Meteor/Workflow - * @summary Workflow method that checks permissions for a given user to allow them to move an order into the processing phase. - * @description Step 4 of the "workflow/pushOrderWorkflow" flow - This method is called from Orders.before.update hook. + * @summary Checks permissions for a given user to allow them to move an order into the processing phase. + * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. * @param {Object} options An object containing arbitary data * @return {Boolean} true to allow action, false to cancel execution of hook * @see packages/reaction-schema/common/hooks/orders.js @@ -26,8 +26,8 @@ Meteor.methods({ * @name coreOrderWorkflow/coreOrderCompleted * @method * @memberof Meteor/Workflow - * @summary Workflow method that performs verios check to determine if an order may be moved into the completed phase. - * @description Step 4 of the "workflow/pushOrderWorkflow" flow - This method is called from Orders.before.update hook. + * @summary Performs various checks to determine if an order may be moved into the completed phase. + * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. * @param {Object} options An object containing arbitary data * @return {Boolean} true to allow action, false to cancel execution of hook * @see packages/reaction-schema/common/hooks/orders.js From 11e60cca0fa2133aa5efb0d41485f6dc6d37237c Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 15:37:05 -0700 Subject: [PATCH 44/59] document Templates schemas --- lib/collections/schemas/templates.js | 41 ++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/collections/schemas/templates.js b/lib/collections/schemas/templates.js index 116b7199a65..31ba7980051 100644 --- a/lib/collections/schemas/templates.js +++ b/lib/collections/schemas/templates.js @@ -2,6 +2,23 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema"; import { shopIdAutoValue } from "./helpers"; import { registerSchema } from "@reactioncommerce/reaction-collections"; +/** + * @name sharedFields + * @memberof schemas + * @type {SimpleSchema} + * @property {String} shopId Template ShopId + * @property {String} name required + * @property {Number} priority optional, default value: 1 + * @property {Boolean} enabled default value: true + * @property {String} route optional + * @property {String} type default value: "template" + * @property {String} provides default value: "template" + * @property {String} block optional + * @property {Object} defaultData optional, blackbox + * @property {String} parser required + * @property {String} language optional, default value: "en" + * @property {String} source optional + */ const sharedFields = { shopId: { type: String, @@ -25,19 +42,10 @@ const sharedFields = { type: String, optional: true }, - // permissions: { - // type: [String], - // optional: true - // }, - // audience: { - // type: [String], - // optional: true - // }, type: { type: String, defaultValue: "template" }, - provides: { type: String, defaultValue: "template" @@ -65,6 +73,14 @@ const sharedFields = { } }; +/** + * @name ReactLayout + * @memberof schemas + * @type {SimpleSchema} + * @extends {sharedFields} + * @property {String[]} templateFor optional + * @property {Object[]} template optional, blackbox + */ export const ReactLayout = new SimpleSchema({ ...sharedFields, templateFor: { @@ -80,6 +96,13 @@ export const ReactLayout = new SimpleSchema({ registerSchema("ReactLayout", ReactLayout); +/** + * @name Template + * @memberof schemas + * @type {SimpleSchema} + * @extends {sharedFields} + * @property {Object[]} template optional, blackbox + */ export const Template = new SimpleSchema({ ...sharedFields, template: { From 44fde45f30fda8d287ba6b63914184f6a28bb174 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 15:40:00 -0700 Subject: [PATCH 45/59] jsdoc: fix - accidentally @namespace'd instead of @memberof'd --- lib/collections/schemas/shops.js | 16 ++++++++-------- lib/collections/schemas/themes.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/collections/schemas/shops.js b/lib/collections/schemas/shops.js index e12ffdb3342..50db27d805a 100644 --- a/lib/collections/schemas/shops.js +++ b/lib/collections/schemas/shops.js @@ -9,7 +9,7 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; /** * @name CustomEmailSettings - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} service optional * @property {String} username optional @@ -44,7 +44,7 @@ registerSchema("CustomEmailSettings", CustomEmailSettings); /** * @name Currency - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} symbol default value: $ * @property {String} format default value: %s%v @@ -87,7 +87,7 @@ registerSchema("Currency", Currency); /** * @name Locale - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {Object} continents blackbox * @property {Object} countries blackbox @@ -107,7 +107,7 @@ registerSchema("Locale", Locale); /** * @name Languages - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} label required * @property {String} i18n required @@ -130,7 +130,7 @@ registerSchema("Languages", Languages); /** * @name ShopTheme - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} themeId required * @property {String} styles optional @@ -149,7 +149,7 @@ registerSchema("ShopTheme", ShopTheme); /** * @name BrandAsset - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} mediaId optional * @property {String} type optional @@ -169,7 +169,7 @@ registerSchema("BrandAsset", BrandAsset); /** * @name MerchantShop - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} _id Shop label * @property {String} slug Shop slug @@ -194,7 +194,7 @@ registerSchema("MerchantShop", MerchantShop); /** * @name Shop - * @namespace schemas + * @memberof schemas * @type {SimpleSchema} * @property {String} _id optional * @property {String} slug optional diff --git a/lib/collections/schemas/themes.js b/lib/collections/schemas/themes.js index 0a10dc51c27..6f26a6c41c3 100644 --- a/lib/collections/schemas/themes.js +++ b/lib/collections/schemas/themes.js @@ -5,7 +5,7 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Themes * @summary Schema for themes used in reaction-layout * @type {SimpleSchema} - * @namespace schemas + * @memberof schemas * @property {String} name required * @property {String} author optional * @property {String} layout default value: "coreLayout" From 81c05b075fd0ae44ad65a4157b7c244e542564e9 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 15:55:16 -0700 Subject: [PATCH 46/59] jsdoc: method name typo --- server/methods/catalog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/methods/catalog.js b/server/methods/catalog.js index 209d05c2ee9..d2df22a0a41 100644 --- a/server/methods/catalog.js +++ b/server/methods/catalog.js @@ -1425,7 +1425,7 @@ Meteor.methods({ }, /** - * @name publishProduct + * @name toggleVisibility * @memberof Meteor/Product * @method * @summary publish (visibility) of product From 20e4bf359b3b619918f327b8b1ee9166ed9291bd Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 15:58:10 -0700 Subject: [PATCH 47/59] jsdoc: parse fix - instead of {[String]} for arrays, do {String[]} --- lib/collections/schemas/products.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/collections/schemas/products.js b/lib/collections/schemas/products.js index 99442c569a1..20cc8f98839 100644 --- a/lib/collections/schemas/products.js +++ b/lib/collections/schemas/products.js @@ -404,7 +404,7 @@ registerSchema("PriceRange", PriceRange); * @type {SimpleSchema} * @memberof schemas * @property {String} _id Product ID - * @property {[String]} ancestors default value: [] + * @property {String[]} ancestors default value: [] * @property {String} shopId Product ShopID * @property {String} title Product Title * @property {String} pageTitle, optional From a0c808724380ad0abac1f70b88c94b67c6b78cb9 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 16:00:52 -0700 Subject: [PATCH 48/59] jsdoc: add @name for Product and PriceRange schemas --- lib/collections/schemas/products.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/collections/schemas/products.js b/lib/collections/schemas/products.js index 20cc8f98839..16764fc27a7 100644 --- a/lib/collections/schemas/products.js +++ b/lib/collections/schemas/products.js @@ -371,7 +371,7 @@ export const ProductVariant = new SimpleSchema({ registerSchema("ProductVariant", ProductVariant); /** - * PriceRange + * @name PriceRange * @type {SimpleSchema} * @memberof schemas * @property {String} range, default value: "0.00" @@ -400,7 +400,7 @@ export const PriceRange = new SimpleSchema({ registerSchema("PriceRange", PriceRange); /** - * Product + * @name Product * @type {SimpleSchema} * @memberof schemas * @property {String} _id Product ID From 675e8e1131a5ad69431aad208603e7cebb632a17 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Thu, 19 Oct 2017 16:24:19 -0700 Subject: [PATCH 49/59] jsdoc: format Invoice component into @module with methods and @type proptypes --- .../core/orders/client/components/invoice.js | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/imports/plugins/core/orders/client/components/invoice.js b/imports/plugins/core/orders/client/components/invoice.js index 5136e0e042b..8e55f854e3b 100644 --- a/imports/plugins/core/orders/client/components/invoice.js +++ b/imports/plugins/core/orders/client/components/invoice.js @@ -7,19 +7,26 @@ import LineItems from "./lineItems"; import InvoiceActions from "./invoiceActions"; /** - * @summary React component for displaying the `invoice` section on the orders sideview - * @param {Object} props - React PropTypes - * @property {Object} invoice - An object representing an invoice - * @property {Object} order - An object representing an order - * @property {Bool} discounts - A boolean indicating whether discounts are enabled - * @property {Array} refunds - An array/list of refunds - * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured - * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment - * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds - * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded - * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview - */ + * @file Invoice is a React Component for displaying the `invoice` section on the orders sideview + * @module Invoice + * @extends Components + */ + class Invoice extends Component { + /** + * @name Invoice propTypes + * @type {propTypes} + * @param {Object} props - React PropTypes + * @property {Object} invoice - An object representing an invoice + * @property {Object} order - An object representing an order + * @property {Bool} discounts - A boolean indicating whether discounts are enabled + * @property {Array} refunds - An array/list of refunds + * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured + * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment + * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds + * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded + * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview + */ static propTypes = { canMakeAdjustments: PropTypes.bool, discounts: PropTypes.bool, @@ -36,6 +43,8 @@ class Invoice extends Component { } /** + * @name formatDate() + * @method * @summary Formats dates * @param {Number} context - the date to be formatted * @param {String} block - the preferred format @@ -47,6 +56,8 @@ class Invoice extends Component { } /** + * @name handleClick() + * @method * @summary Handle clicking the add discount link * @param {Event} event - the event that fired * @returns {null} null @@ -59,6 +70,8 @@ class Invoice extends Component { } /** + * @name renderDiscountForm() + * @method * @summary Displays the discount form * @returns {null} null */ @@ -81,6 +94,8 @@ class Invoice extends Component { } /** + * @name renderRefundsInfo() + * @method * @summary Displays the refund information after the order payment breakdown on the invoice * @returns {null} null */ @@ -108,6 +123,8 @@ class Invoice extends Component { } /** + * @name renderTotal() + * @method * @summary Displays the total payment form * @returns {null} null */ @@ -124,6 +141,8 @@ class Invoice extends Component { } /** + * @name renderConditionalDisplay() + * @method * @summary Displays either refunds info or the total payment form * @returns {null} null */ @@ -148,6 +167,8 @@ class Invoice extends Component { } /** + * @name renderInvoice() + * @method * @summary Displays the invoice form with broken down payment info * @returns {null} null */ From 8338c21a26bfc8b69068688dc7f3bb61848240d9 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Mon, 23 Oct 2017 17:19:58 -0700 Subject: [PATCH 50/59] jsdoc: fix formatting + add Shops schema --- lib/collections/schemas/accounts.js | 3 +- lib/collections/schemas/address.js | 20 ++-- lib/collections/schemas/analytics.js | 22 ++-- lib/collections/schemas/cart.js | 32 +++--- lib/collections/schemas/emails.js | 22 ++-- lib/collections/schemas/event.js | 10 +- lib/collections/schemas/groups.js | 16 +-- lib/collections/schemas/inventory.js | 24 ++-- lib/collections/schemas/layouts.js | 42 +++++-- lib/collections/schemas/logs.js | 12 +- lib/collections/schemas/metafield.js | 12 +- lib/collections/schemas/notifications.js | 30 +++-- lib/collections/schemas/orders.js | 53 ++++----- lib/collections/schemas/payments.js | 89 +++++++-------- lib/collections/schemas/products.js | 138 +++++++++++------------ lib/collections/schemas/registry.js | 19 ++-- lib/collections/schemas/revisions.js | 4 +- lib/collections/schemas/shipping.js | 26 +++-- lib/collections/schemas/shops.js | 52 +++++++-- lib/collections/schemas/sms.js | 10 +- lib/collections/schemas/social.js | 2 +- lib/collections/schemas/tags.js | 6 +- lib/collections/schemas/templates.js | 8 +- lib/collections/schemas/themes.js | 2 +- lib/collections/schemas/translations.js | 2 +- lib/collections/schemas/workflow.js | 7 +- 26 files changed, 366 insertions(+), 297 deletions(-) diff --git a/lib/collections/schemas/accounts.js b/lib/collections/schemas/accounts.js index 6d02e582c18..3efba481680 100644 --- a/lib/collections/schemas/accounts.js +++ b/lib/collections/schemas/accounts.js @@ -11,7 +11,8 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; /** * @file Reaction Core schemas - * Reaction uses {@link https://github.com/aldeed/meteor-simple-schema SimpleSchema} to apply basic content and structure validation to Collections. See {@link https://docs.reactioncommerce.com/reaction-docs/master/simple-schema full documentation}. + * Reaction uses {@link https://github.com/aldeed/meteor-simple-schema SimpleSchema} to apply basic content and structure validation to Collections. + * See {@link https://docs.reactioncommerce.com/reaction-docs/master/simple-schema full documentation}. * @namespace schemas */ diff --git a/lib/collections/schemas/address.js b/lib/collections/schemas/address.js index 26b8f31427f..acb616d40a5 100644 --- a/lib/collections/schemas/address.js +++ b/lib/collections/schemas/address.js @@ -8,18 +8,18 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @type {SimpleSchema} * @property {String} _id - * @property {String} fullName, required - * @property {String} address1, required + * @property {String} fullName required + * @property {String} address1 required * @property {String} address2 - * @property {String} city, required + * @property {String} city required * @property {String} company - * @property {String} phone, required - * @property {String} region, required, State/Province/Region - * @property {String} postal, required - * @property {String} country, required - * @property {Boolean} isCommercial, required - * @property {Boolean} isBillingDefault, required - * @property {Boolean} isShippingDefault, required + * @property {String} phone required + * @property {String} region required, State/Province/Region + * @property {String} postal required + * @property {String} country required + * @property {Boolean} isCommercial required + * @property {Boolean} isBillingDefault required + * @property {Boolean} isShippingDefault required * @property {Boolean} failedValidation * @property {Metafield[]} metafields */ diff --git a/lib/collections/schemas/analytics.js b/lib/collections/schemas/analytics.js index ae00b827fa5..b7d1a1aee1f 100644 --- a/lib/collections/schemas/analytics.js +++ b/lib/collections/schemas/analytics.js @@ -10,17 +10,17 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name AnalyticsEvents * @memberof schemas * @type {SimpleSchema} - * @property {String} eventType, required - * @property {String} category - * @property {String} action - * @property {String} label - * @property {String} value - * @property {Object} user - * @property {String} user.id - * @property {Boolean} user.isAnonymous + * @property {String} eventType required + * @property {String} category optional + * @property {String} action optional + * @property {String} label optional + * @property {String} value optional + * @property {Object} user optional + * @property {String} user.id optional + * @property {Boolean} user.isAnonymous optional * @property {String} shopId AnaltyicsEvents shopId - * @property {Date} createdAt - * @property {Object} data Any additional data + * @property {Date} createdAt required + * @property {Object} data Any additional data, blackbox */ export const AnalyticsEvents = new SimpleSchema({ "eventType": { @@ -85,7 +85,9 @@ registerSchema("AnalyticsEvents", AnalyticsEvents); /** * @name ReactionAnalyticsPackageConfig * @memberof schemas + * @summary This schema extends PackageConfig with fields specific to the Analytics package. * @type {SimpleSchema} + * @extends {PackageConfig} * @property {Boolean} settings.public.segmentio.enabled Enable Segment.io * @property {String} settings.public.segmentio.api_key Segment.io Write Key * @property {Boolean} settings.public.googleAnalytics.enabled Enable Google Analytics diff --git a/lib/collections/schemas/cart.js b/lib/collections/schemas/cart.js index 1c7299f795f..a78431dcdd8 100644 --- a/lib/collections/schemas/cart.js +++ b/lib/collections/schemas/cart.js @@ -11,21 +11,21 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name CartItem * @memberof schemas * @type {SimpleSchema} - * @property {String} _id, required - * @property {String} productId, required + * @property {String} _id required + * @property {String} productId required * @property {String} shopId, Cart Item shopId - * @property {Number} quantity, required - * @property {Product} product, required - * @property {ProductVariant} variants, required + * @property {Number} quantity required + * @property {Product} product required + * @property {ProductVariant} variants required * @property {Metafield[]} metafields - * @property {String} title, Cart Item title + * @property {String} title Cart Item title * @property {String} type, Product type - * @property {ShippingParcel} parcel, Note: Currently the parcel is in the simple product schema, so we need to include it here as well. - * @property {String} cartItemId, Note: Seems strange here but has to be here since we share schemas between cart and order - * @property {Object} transaction, Transaction associated with this item - * @property {Object} taxData optional, blackbox + * @property {ShippingParcel} parcel Currently, parcel is in simple product schema. Need to include it here as well. + * @property {String} cartItemId Seems strange here but has to be here since we share schemas between Cart and Order + * @property {Object} transaction Transaction associated with this item + * @property {Object} taxData optional blackbox * @property {Number} taxRate optional - * @property {Object} shippingMethod, Shipping Method associated with this item + * @property {Object} shippingMethod Shipping Method associated with this item */ export const CartItem = new SimpleSchema({ _id: { @@ -103,7 +103,7 @@ registerSchema("CartItem", CartItem); * @memberof schemas * @summary Used in check by inventory/addReserve method * @type {SimpleSchema} - * @property {CartItem[]} items, an Array of CartItem, optional + * @property {CartItem[]} items an Array of CartItem optional */ export const CartItems = new SimpleSchema({ items: { @@ -123,11 +123,11 @@ registerSchema("CartItems", CartItems); * @property {String} userId required * @property {String} sessionId required * @property {String} email optional - * @property {CartItem[]} items Array of CartItem, optional - * @property {Shipment[]} shipping Array of Shipment, optional, blackbox - * @property {Payment[]} billing Array of Payment, optional, blackbox + * @property {CartItem[]} items Array of CartItem optional + * @property {Shipment[]} shipping Array of Shipment optional, blackbox + * @property {Payment[]} billing Array of Payment optional, blackbox * @property {Number} tax tax rate - * @property {Object[]} taxes Array of objects, optional + * @property {Object[]} taxes Array of objects optional * @property {Object} taxRatesByShop optional * @property {Number} discount optional * @property {Workflow} workflow optional diff --git a/lib/collections/schemas/emails.js b/lib/collections/schemas/emails.js index daa3e0b8f8a..a4dd32152a8 100644 --- a/lib/collections/schemas/emails.js +++ b/lib/collections/schemas/emails.js @@ -5,17 +5,17 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Emails * @memberof schemas * @type {SimpleSchema} - * @property {String} to, required - * @property {String} from, required - * @property {String} subject, required - * @property {String} text, optional - * @property {String} html, optional - * @property {String} userId, optional - * @property {String} jobId, required - * @property {String} type, optional - * @property {String} status, optional - * @property {Date} createdAt, required - * @property {Date} updatedAt, required + * @property {String} to required + * @property {String} from required + * @property {String} subject required + * @property {String} text optional + * @property {String} html optional + * @property {String} userId optional + * @property {String} jobId required + * @property {String} type optional + * @property {String} status optional + * @property {Date} createdAt required + * @property {Date} updatedAt required */ export const Emails = new SimpleSchema({ to: { diff --git a/lib/collections/schemas/event.js b/lib/collections/schemas/event.js index 2490d3d3410..2579614fb64 100644 --- a/lib/collections/schemas/event.js +++ b/lib/collections/schemas/event.js @@ -5,11 +5,11 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Event for EventLog * @memberof schemas * @type {SimpleSchema} - * @property {String} title Event title, required - * @property {String} type Event type, required - * @property {String} description Event description, optional - * @property {String} userId User who triggered event, optional - * @property {String} trigger Action that triggered event, optional + * @property {String} title Event title required + * @property {String} type Event type required + * @property {String} description Event description optional + * @property {String} userId User who triggered event optional + * @property {String} trigger Action that triggered event optional * @property {Date} createdAt required */ export const Event = new SimpleSchema({ diff --git a/lib/collections/schemas/groups.js b/lib/collections/schemas/groups.js index 03cf1424d0c..7698e467fc5 100644 --- a/lib/collections/schemas/groups.js +++ b/lib/collections/schemas/groups.js @@ -5,14 +5,14 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Group * @memberof schemas * @type {SimpleSchema} - * @property {String} name, required - * @property {String} description, optional - * @property {String} slug, required - * @property {String[]} permissions, optional - * @property {String} shopId, required - * @property {String} createdBy, optional - * @property {Date} createdAt, required - * @property {Date} updatedAt, required + * @property {String} name required + * @property {String} description optional + * @property {String} slug required + * @property {String[]} permissions optional + * @property {String} shopId required + * @property {String} createdBy optional + * @property {Date} createdAt required + * @property {Date} updatedAt required */ export const Groups = new SimpleSchema({ name: { diff --git a/lib/collections/schemas/inventory.js b/lib/collections/schemas/inventory.js index 75ef93b82f6..7256ff8737e 100644 --- a/lib/collections/schemas/inventory.js +++ b/lib/collections/schemas/inventory.js @@ -9,18 +9,18 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Inventory * @memberof schemas * @type {SimpleSchema} - * @property {String} _id, optional, inserted by mongo, we need it for schema validation - * @property {String} shopId, required, Inventory shopId - * @property {String} productId, required - * @property {String} variantId, required - * @property {String} orderItemId, optional - * @property {Workflow} workflow, optional - * @property {String} sku, optional - * @property {Metafield[]} metafields, optional - * @property {Document[]} documents, optional - * @property {Notes[]} notes, optional - * @property {Date} createdAt, optional, but required: schema validation failing in method with this required. should be considered temporary. - * @property {Date} updatedAt, optional + * @property {String} _id optional, inserted by Mongo, we need it for schema validation + * @property {String} shopId required, Inventory shopId + * @property {String} productId required + * @property {String} variantId required + * @property {String} orderItemId optional + * @property {Workflow} workflow optional + * @property {String} sku optional + * @property {Metafield[]} metafields optional + * @property {Document[]} documents optional + * @property {Notes[]} notes optional + * @property {Date} createdAt optional, but consider it temporary: schema validation failing in method with required + * @property {Date} updatedAt optional */ export const Inventory = new SimpleSchema({ _id: { diff --git a/lib/collections/schemas/layouts.js b/lib/collections/schemas/layouts.js index 76dd9bf6aa0..b9688fa65b0 100644 --- a/lib/collections/schemas/layouts.js +++ b/lib/collections/schemas/layouts.js @@ -6,17 +6,17 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @type {SimpleSchema} * @summary Layout are used by the Shops and Packages schemas. - * Layouts are used to in two ways: 1) define the template layout on the site - * 2) define workflow components used in each layout block - * Read more about Layouts in {@link https://docs.reactioncommerce.com/reaction-docs/master/layout documentation} - * @property {String} template, optional - * @property {String} layoutHeader, optional - * @property {String} layoutFooter, optional - * @property {String} notFound, optional - * @property {String} dashboardHeader, optional - * @property {String} dashboardControls, optional - * @property {String} dashboardHeaderControls, optional - * @property {String} adminControlsFooter, optional + * Layouts are used to in two ways: 1) Define the template layout on the site + * 2) Define workflow components used in each layout block + * @description Read more about Layouts in {@link https://docs.reactioncommerce.com/reaction-docs/master/layout documentation} + * @property {String} template optional + * @property {String} layoutHeader optional + * @property {String} layoutFooter optional + * @property {String} notFound optional + * @property {String} dashboardHeader optional + * @property {String} dashboardControls optional + * @property {String} dashboardHeaderControls optional + * @property {String} adminControlsFooter optional */ export const LayoutStructure = new SimpleSchema({ template: { @@ -63,6 +63,26 @@ export const LayoutStructure = new SimpleSchema({ registerSchema("LayoutStructure", LayoutStructure); +/** + * @name Layout + * @memberof schemas + * @type {SimpleSchema} + * @summary Layout are used by the Shops and Packages schemas. + * Read more about Layouts in {@link https://docs.reactioncommerce.com/reaction-docs/master/layout documentation} + * @property {String} layout optional + * @property {String} workflow optional + * @property {String} template optional + * @property {String} collection optional + * @property {String} theme optional + * @property {Boolean} enabled default value: `true` + * @property {String} status optional + * @property {String} label optional + * @property {String} container optional + * @property {String[]} audience optional + * @property {LayoutStructure} structure optional + * @property {Number} priority optional default value: `999` - Layouts are prioritized with lower numbers first. + * @property {Number} position optional default value: `1` + */ export const Layout = new SimpleSchema({ layout: { type: String, diff --git a/lib/collections/schemas/logs.js b/lib/collections/schemas/logs.js index 3ac08deb46c..749e83b4a5c 100644 --- a/lib/collections/schemas/logs.js +++ b/lib/collections/schemas/logs.js @@ -5,13 +5,13 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Logs * @type {SimpleSchema} * @memberof schemas - * @property {String} logType, required - * @property {String} shopId, required - * @property {String} level, required, default: "info", allowed: "trace", "debug", "info", "warn", "error", "fatal" - * @property {String} source, required, default: "server", allowed: "client", "server" - * @property {Boolean} handled, required, default: faulse + * @property {String} logType required + * @property {String} shopId required + * @property {String} level default: `"info"`, allowed: `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`, `"fatal"` + * @property {String} source default: `"server"`, allowed: `"client"`, `"server"` + * @property {Boolean} handled required, default: false * @property {Object} data, blackbox - * @property {Date} date, required + * @property {Date} date required */ export const Logs = new SimpleSchema({ logType: { diff --git a/lib/collections/schemas/metafield.js b/lib/collections/schemas/metafield.js index 9e5edbabac8..01546a18dd8 100644 --- a/lib/collections/schemas/metafield.js +++ b/lib/collections/schemas/metafield.js @@ -5,12 +5,12 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Metafield * @memberof schemas * @type {SimpleSchema} - * @property {String} key, optional - * @property {String} namespace, optional - * @property {String} scope, optional - * @property {String} value, optional - * @property {String} valueType, optional - * @property {String} description, optional + * @property {String} key optional + * @property {String} namespace optional + * @property {String} scope optional + * @property {String} value optional + * @property {String} valueType optional + * @property {String} description optional */ export const Metafield = new SimpleSchema({ key: { diff --git a/lib/collections/schemas/notifications.js b/lib/collections/schemas/notifications.js index de7af159227..564526af86e 100644 --- a/lib/collections/schemas/notifications.js +++ b/lib/collections/schemas/notifications.js @@ -6,22 +6,20 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @type {SimpleSchema} * @summary Notification sends messages corresponding to the type: - * Type Message(This would be the corresponding message) - * ----------------| ----------------------------------------------- - * orderCanceled | "Your order was canceled." - * forAdmin: | "You have a new order." - * newOrder: | "You just made an order." - * orderDelivered: | "Your order has been delivered." - * orderProcessing: | "Your order is being processed." - * orderShipped: | "Your order has been shipped. - * @property {String} message, required - * @property {String} type, required, types: "orderCanceled", "forAdmin", "newOrder", "orderDelivered", "orderProcessing", "orderShipped" - * @property {String} url, required - * @property {String} to, required - * @property {Boolean} hasDetails, required - * @property {String} details, required - * @property {String} status, required, default: "unread" - * @property {Date} timeSent, required + * - `orderCanceled` : "Your order was canceled." + * - `forAdmin` : "You have a new order." + * - `newOrder` : "You just made an order." + * - `orderDelivered` : "Your order has been delivered." + * - `orderProcessing`: "Your order is being processed." + * - `orderShipped` : "Your order has been shipped." + * @property {String} message required + * @property {String} type required, types: `orderCanceled`, `forAdmin`, `newOrder`, `orderDelivered`, `orderProcessing`, `orderShipped` + * @property {String} url required + * @property {String} to required + * @property {Boolean} hasDetails required + * @property {String} details required + * @property {String} status required, default: `unread` + * @property {Date} timeSent required */ export const Notification = new SimpleSchema({ message: { diff --git a/lib/collections/schemas/orders.js b/lib/collections/schemas/orders.js index 2a3b98efdac..8f1c1a13cd1 100644 --- a/lib/collections/schemas/orders.js +++ b/lib/collections/schemas/orders.js @@ -6,8 +6,8 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Document * @memberof schemas * @type {SimpleSchema} - * @property {String} docId, required - * @property {String} docType, optional + * @property {String} docId required + * @property {String} docType optional */ export const Document = new SimpleSchema({ docId: { @@ -25,10 +25,10 @@ registerSchema("Document", Document); * @name History * @memberof schemas * @type {SimpleSchema} - * @property {String} event, required - * @property {String} value, required - * @property {String} userId, required - * @property {String} updatedAt, required + * @property {String} event required + * @property {String} value required + * @property {String} userId required + * @property {String} updatedAt required */ export const History = new SimpleSchema({ event: { @@ -51,9 +51,9 @@ registerSchema("History", History); * @name Notes * @memberof schemas * @type {SimpleSchema} - * @property {String} content, required - * @property {String} userId, required - * @property {Date} updatedAt, required + * @property {String} content required + * @property {String} userId required + * @property {Date} updatedAt required */ export const Notes = new SimpleSchema({ content: { @@ -74,10 +74,10 @@ registerSchema("Notes", Notes); * @memberof schemas * @summary Merges with Cart and Order to create Orders collection * @type {SimpleSchema} - * @property {String} additionalField, optional - * @property {Workflow} workflow, optional - * @property {History[]} history, optional - * @property {Document[]} documents, optional + * @property {String} additionalField optional + * @property {Workflow} workflow optional + * @property {History[]} history optional + * @property {Document[]} documents optional */ export const OrderItem = new SimpleSchema({ additionalField: { @@ -103,13 +103,13 @@ registerSchema("OrderItem", OrderItem); /** * @name OrderTransaction Schema * @memberof schemas - * @summary order transactions tie shipping, billing, and inventory transactions + * @summary Order transactions tie Shipping, Payment, and Inventory transactions * @type {SimpleSchema} - * @property {String} itemId, optional - * @property {String} paymentId, optional - * @property {String} shipmentId, optional - * @property {String} inventoryId, optional - * @property {Date} createdAt, required + * @property {String} itemId optional + * @property {String} paymentId optional + * @property {String} shipmentId optional + * @property {String} inventoryId optional + * @property {Date} createdAt required */ export const OrderTransaction = new SimpleSchema({ itemId: { @@ -146,13 +146,14 @@ registerSchema("OrderTransaction", OrderTransaction); * @name Order Schema * @memberof schemas * @type {SimpleSchema} - * @property {String} userId, required - * @property {String} cartId, optional - * @property {History[]} history, optional - * @property {Document[]} documents, optional - * @property {Notes[]} notes, optional - * @property {OrderItem[]} items, optional - * @property {OrderTransaction[]} transactions, optional + * @summary Order ties a User to a Cart and an array of History, Documents, Notes, Items and OrderTransactions. + * @property {String} userId required + * @property {String} cartId optional + * @property {History[]} history optional + * @property {Document[]} documents optional + * @property {Notes[]} notes optional + * @property {OrderItem[]} items optional + * @property {OrderTransaction[]} transactions optional */ export const Order = new SimpleSchema({ userId: { diff --git a/lib/collections/schemas/payments.js b/lib/collections/schemas/payments.js index e0b466be08b..d7271fdc0ec 100644 --- a/lib/collections/schemas/payments.js +++ b/lib/collections/schemas/payments.js @@ -6,14 +6,15 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; /** * @name PaymentItem - * @summary Schema for items we're inserting into our Payments to keep track of what items were paid for with a given paymentMethod + * @summary Schema for items we're inserting into our Payments + * To keep track of what items were paid for with a given paymentMethod * @type {SimpleSchema} * @memberof schemas - * @property {String} _id, optional, Shipment Line Item - * @property {String} productId, required - * @property {String} shopId, optional, Shipment Item ShopId - * @property {Number} quantity, required - * @property {String} variantId, required + * @property {String} _id optional, Shipment Line Item + * @property {String} productId required + * @property {String} shopId optional, Shipment Item ShopId + * @property {Number} quantity required + * @property {String} variantId required */ export const PaymentItem = new SimpleSchema({ _id: { @@ -48,25 +49,25 @@ registerSchema("PaymentItem", PaymentItem); * @name PaymentMethod * @type {SimpleSchema} * @memberof schemas - * @property {String} processor, required - * @property {String} paymentPackageId, required - * @property {String} paymentSettingsKey, required - * @property {String} storedCard, optional - * @property {String} method, allowed values: "credit", "debit", "shipping-credit" - * @property {String} transactionId, required - * @property {Object} metadata, optional, blackbox - * @property {Workflow} workflow, optional - * @property {String} status, required - * @property {String} mode, allowed values: "authorize", "capture", "refund", "cancel", "void" - * @property {String} riskLevel, allowed values: "normal", "elevated", "high" - * @property {Date} createdAt, required - * @property {Date} updatedAt, optional - * @property {String} authorization, optional - * @property {Number} amount, optional - * @property {String} currency, required - * @property {Object[]} transactions, optional, blackbox - * @property {PaymentItem[]} items, optional - * @property {String} shopId, optional + * @property {String} processor required + * @property {String} paymentPackageId required + * @property {String} paymentSettingsKey required + * @property {String} storedCard optional + * @property {String} method, allowed values: `"credit"`, `"debit"`, `"shipping-credit"` + * @property {String} transactionId required + * @property {Object} metadata optional, blackbox + * @property {Workflow} workflow optional + * @property {String} status required + * @property {String} mode, allowed values: `"authorize"`, `"capture"`, `"refund"`, `"cancel"`, `"void"` + * @property {String} riskLevel, allowed values: `"normal"`, `"elevated"`, `"high"` + * @property {Date} createdAt required + * @property {Date} updatedAt optional + * @property {String} authorization optional + * @property {Number} amount optional + * @property {String} currency required + * @property {Object[]} transactions optional, blackbox + * @property {PaymentItem[]} items optional + * @property {String} shopId optional */ export const PaymentMethod = new SimpleSchema({ processor: { @@ -162,12 +163,12 @@ registerSchema("PaymentMethod", PaymentMethod); * @name Invoice * @type {SimpleSchema} * @memberof schemas - * @property {String} transaction, optional - * @property {Number} shipping, optional - * @property {Number} taxes, optional - * @property {Number} subtotal, required - * @property {Number} discounts, optional - * @property {Number} total, required + * @property {String} transaction optional + * @property {Number} shipping optional + * @property {Number} taxes optional + * @property {Number} subtotal required + * @property {Number} discounts optional + * @property {Number} total required */ export const Invoice = new SimpleSchema({ transaction: { @@ -205,8 +206,8 @@ registerSchema("Invoice", Invoice); * @name Currency * @type {SimpleSchema} * @memberof schemas - * @property {String} userCurrency, default value: "USD" - * @property {Number} exchangeRate, optional + * @property {String} userCurrency, default value: `"USD"` + * @property {Number} exchangeRate optional */ export const Currency = new SimpleSchema({ userCurrency: { @@ -227,12 +228,12 @@ registerSchema("Currency", Currency); * @name Payment * @type {SimpleSchema} * @memberof schemas - * @property {String} _id, required, Payment Id - * @property {Address} address, optional - * @property {PaymentMethod} paymentMethod, optional - * @property {Invoice} invoice, optional - * @property {Currency} currency, optional - * @property {String} shopId, optional + * @property {String} _id required, Payment Id + * @property {Address} address optional + * @property {PaymentMethod} paymentMethod optional + * @property {Invoice} invoice optional + * @property {Currency} currency optional + * @property {String} shopId optional */ export const Payment = new SimpleSchema({ _id: { @@ -268,11 +269,11 @@ registerSchema("Payment", Payment); * @name Payment * @type {SimpleSchema} * @memberof schemas - * @property {String} type, required - * @property {Number} amount, required - * @property {Number} created, required - * @property {String} currency, required - * @property {Object} raw, optional, blackbox + * @property {String} type required + * @property {Number} amount required + * @property {Number} created required + * @property {String} currency required + * @property {Object} raw optional, blackbox */ export const Refund = new SimpleSchema({ type: { diff --git a/lib/collections/schemas/products.js b/lib/collections/schemas/products.js index 16764fc27a7..c4613f4c69f 100644 --- a/lib/collections/schemas/products.js +++ b/lib/collections/schemas/products.js @@ -13,11 +13,11 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name VariantMedia * @memberof schemas * @type {SimpleSchema} - * @property {String} mediaId, optional - * @property {Number} priority, optional - * @property {Metafield[]} metafields, optional - * @property {Date} updatedAt, optional - * @property {Date} createdAt, required + * @property {String} mediaId optional + * @property {Number} priority optional + * @property {Metafield[]} metafields optional + * @property {Date} updatedAt optional + * @property {Date} createdAt required */ export const VariantMedia = new SimpleSchema({ mediaId: { @@ -57,11 +57,11 @@ registerSchema("VariantMedia", VariantMedia); * @name ProductPosition * @memberof schemas * @type {SimpleSchema} - * @property {String} tag, optional - * @property {Number} position, optional - * @property {Boolean} pinned, optional - * @property {Number} weight, optional, default value: 0 - * @property {Date} updatedAt, required + * @property {String} tag optional + * @property {Number} position optional + * @property {Boolean} pinned optional + * @property {Number} weight optional, default value: `0` + * @property {Date} updatedAt required */ export const ProductPosition = new SimpleSchema({ tag: { @@ -94,40 +94,40 @@ registerSchema("ProductPosition", ProductPosition); * @name ProductVariant * @memberof schemas * @type {SimpleSchema} - * @property {String} _id, required, Variant ID - * @property {String[]} ancestors, default value: [] - * @property {Number} index, optional, Variant position number in list. Used for keeping array index, moving variants through list, like drag-n-drop. - * @property {Boolean} isVisible, default value: false - * @property {Boolean} isDeleted, default value: false - * @property {String} barcode, optional - * @property {Number} compareAtPrice, optional, Compare at price - * @property {String} fulfillmentService, optional, Fullfillment service - * @property {Number} weight, default value: 0 - * @property {Number} length, optional, default value: 0 - * @property {Number} width, optional, default value: 0 - * @property {Number} height, optional, default value: 0 - * @property {Boolean} inventoryManagement, default value: true - * @property {Boolean} inventoryPolicy, default value: false, If disabled, an item can be sold even if it not in stock. - * @property {Number} lowInventoryWarningThreshold, default value: 0, Warn of low inventory at this number - * @property {Number} inventoryQuantity, default value: 0 - * @property {Number} minOrderQuantity, optional - * @property {Boolean} isLowQuantity, optional, denormalized field, indicates when at least one of variant is lower than `lowInventoryWarningThreshold` - * @property {Boolean} isSoldOut, optional, denormalized field, indicates when all variants `inventoryQuantity` is 0 - * @property {Number} price, default value: 0.00 - * @property {String} shopId, required, Variant ShopId - * @property {String} sku, optional - * @property {String} type, default value: "variant" - * @property {Boolean} taxable, default value: true - * @property {String} taxCode, default value: "0000" - * @property {String} taxDescription, optional - * @property {String} title, Label for customers, default value: "" - * @property {String} optionTitle, Option internal name, default value: "Untitled option" - * @property {Metafield[]} metafields, optional - * @property {Date} createdAt, optional - * @property {Date} updatedAt, optional - * @property {Event[]} eventLog, optional, Variant Event Log - * @property {Workflow} workflow, optional - * @property {String} originCountry, optional + * @property {String} _id required, Variant ID + * @property {String[]} ancestors, default value: `[]` + * @property {Number} index optional, Variant position number in list. Keep array index for moving variants in a list. + * @property {Boolean} isVisible, default value: `false` + * @property {Boolean} isDeleted, default value: `false` + * @property {String} barcode optional + * @property {Number} compareAtPrice optional, Compare at price + * @property {String} fulfillmentService optional, Fullfillment service + * @property {Number} weight, default value: `0` + * @property {Number} length optional, default value: `0` + * @property {Number} width optional, default value: `0` + * @property {Number} height optional, default value: `0` + * @property {Boolean} inventoryManagement, default value: `true` + * @property {Boolean} inventoryPolicy, default value: `false`, If disabled, item can be sold even if it not in stock. + * @property {Number} lowInventoryWarningThreshold, default value: `0`, Warn of low inventory at this number + * @property {Number} inventoryQuantity, default value: `0` + * @property {Number} minOrderQuantity optional + * @property {Boolean} isLowQuantity optional, true when at least 1 variant is below `lowInventoryWarningThreshold` + * @property {Boolean} isSoldOut optional, denormalized field, indicates when all variants `inventoryQuantity` is 0 + * @property {Number} price, default value: `0.00` + * @property {String} shopId required, Variant ShopId + * @property {String} sku optional + * @property {String} type, default value: `"variant"` + * @property {Boolean} taxable, default value: `true` + * @property {String} taxCode, default value: `"0000"` + * @property {String} taxDescription optional + * @property {String} title, Label for customers, default value: `""` + * @property {String} optionTitle, Option internal name, default value: `"Untitled option"` + * @property {Metafield[]} metafields optional + * @property {Date} createdAt optional + * @property {Date} updatedAt optional + * @property {Event[]} eventLog optional, Variant Event Log + * @property {Workflow} workflow optional + * @property {String} originCountry optional */ export const ProductVariant = new SimpleSchema({ _id: { @@ -374,9 +374,9 @@ registerSchema("ProductVariant", ProductVariant); * @name PriceRange * @type {SimpleSchema} * @memberof schemas - * @property {String} range, default value: "0.00" - * @property {Number} min, optional, default value: 0 - * @property {Number} max, optional, default value: 0 + * @property {String} range, default value: `"0.00"` + * @property {Number} min optional, default value: `0` + * @property {Number} max optional, default value: `0` */ export const PriceRange = new SimpleSchema({ range: { @@ -404,38 +404,38 @@ registerSchema("PriceRange", PriceRange); * @type {SimpleSchema} * @memberof schemas * @property {String} _id Product ID - * @property {String[]} ancestors default value: [] + * @property {String[]} ancestors default value: `[]` * @property {String} shopId Product ShopID * @property {String} title Product Title - * @property {String} pageTitle, optional + * @property {String} pageTitle optional * @property {String} description optional * @property {String} productType optional * @property {String} originCountry optional - * @property {String} type default value: "simple" + * @property {String} type default value: `"simple"` * @property {String} vendor optional * @property {Metafield[]} metafields optional * @property {Object} positions ProductPosition * @property {PriceRange} price denormalized, object with range string, min and max - * @property {Boolean} isLowQuantity denormalized, Indicates when at least one variant `inventoryQuantity` is lower than `lowInventoryWarningThreshold` + * @property {Boolean} isLowQuantity denormalized, true when at least 1 variant is below `lowInventoryWarningThreshold` * @property {Boolean} isSoldOut denormalized, Indicates when all variants `inventoryQuantity` is zero - * @property {Boolean} isBackorder denormalized, It is `true` if product not in stock, but customers anyway could order it. - * @property {Boolean} requiresShipping default value: true, Require a shipping address - * @property {ShippingParcel} parcel, optional - * @property {String[]} hashtags, optional - * @property {String} twitterMsg, optional - * @property {String} facebookMsg, optional - * @property {String} googleplusMsg, optional - * @property {String} pinterestMsg, optional - * @property {String} metaDescription, optional - * @property {String} handle, optional, slug - * @property {Boolean} isDeleted, default value: false - * @property {Boolean} isVisible, default value: false - * @property {String} template, default value: "productDetailSimple" - * @property {Date} createdAt, required - * @property {Date} updatedAt, optional - * @property {Date} publishedAt, optional - * @property {String} publishedScope, optional - * @property {Workflow} workflow, optional + * @property {Boolean} isBackorder denormalized, `true` if product not in stock, but customers anyway could order it + * @property {Boolean} requiresShipping default value: `true`, Require a shipping address + * @property {ShippingParcel} parcel optional + * @property {String[]} hashtags optional + * @property {String} twitterMsg optional + * @property {String} facebookMsg optional + * @property {String} googleplusMsg optional + * @property {String} pinterestMsg optional + * @property {String} metaDescription optional + * @property {String} handle optional, slug + * @property {Boolean} isDeleted, default value: `false` + * @property {Boolean} isVisible, default value: `false` + * @property {String} template, default value: `"productDetailSimple"` + * @property {Date} createdAt required + * @property {Date} updatedAt optional + * @property {Date} publishedAt optional + * @property {String} publishedScope optional + * @property {Workflow} workflow optional */ export const Product = new SimpleSchema({ _id: { diff --git a/lib/collections/schemas/registry.js b/lib/collections/schemas/registry.js index 09a6e7df9f7..40ec4746391 100644 --- a/lib/collections/schemas/registry.js +++ b/lib/collections/schemas/registry.js @@ -5,7 +5,8 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; /** * @name Permissions * @memberof schemas - * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @summary The Permissions schema is part of the Registry. The Registry Schema allows package settings to be defined. + * For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. * @type {SimpleSchema} * @property {String} permission * @property {String} label @@ -151,8 +152,9 @@ registerSchema("Registry", Registry); * @name PackageConfig * @memberof schemas * @type {SimpleSchema} - * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. - * @property {String} shopId {@see https://github.com/reactioncommerce/reaction/issues/646#issuecomment-169351842} + * @summary The PackageConfig is part of the configuration settings required for packages in the Registry. + * The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @property {String} shopId Autovalue removed {@link https://github.com/reactioncommerce/reaction/issues/646#issuecomment-169351842 here} * @property {String} name required * @property {Boolean} enabled defalut value: true * @property {String} icon optional @@ -202,7 +204,8 @@ registerSchema("PackageConfig", PackageConfig); * @name CorePackageConfig * @memberof schemas * @type {SimpleSchema} - * @summary The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. + * @summary The Core Package Config is part of the Registry. + * The Registry Schema allows package settings to be defined. For more, read the in-depth {@link https://blog.reactioncommerce.com/an-intro-to-architecture-the-registry/ Intro to Architecture: The Registry}. * @extends {PackageConfig} * @property {Object} settings.mail optional, Mail settings * @property {String} settings.mail.user Mail user @@ -210,12 +213,12 @@ registerSchema("PackageConfig", PackageConfig); * @property {String} settings.mail.host Mail host * @property {String} settings.mail.port Mail port * @property {String} settings.openexchangerates.appId OpenExchangeRates Id - * @property {String} settings.openexchangerates.refreshPeriod default value: every 1 hour - * @property {String} settings.google.clientId default value: null - * @property {String} settings.google.apiKey default value: null + * @property {String} settings.openexchangerates.refreshPeriod default value: `"every 1 hour"` + * @property {String} settings.google.clientId default value: `null` + * @property {String} settings.google.apiKey default value: `null` * @property {Object} settings.public optional Settings in `public` are published to the client. * @property {Boolean} settings.public.allowGuestCheckout allows guest checkout - * @property {String} settings.cart.cleanupDurationDays default value: older than 3 days + * @property {String} settings.cart.cleanupDurationDays default value: `"older than 3 days"` */ export const CorePackageConfig = new SimpleSchema([ PackageConfig, { diff --git a/lib/collections/schemas/revisions.js b/lib/collections/schemas/revisions.js index 640a6ecdfcc..38a2ae45269 100644 --- a/lib/collections/schemas/revisions.js +++ b/lib/collections/schemas/revisions.js @@ -9,10 +9,10 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @property {String} _id Revision Id * @property {Workflow} workflow required * @property {String} documentId Reference Document Id - * @property {String} documentType Document Type, default value: product, allowed values: "product", "image", "tag" + * @property {String} documentType Document Type, default value: `product`, allowed values: `product`, `image`, `tag` * @property {String} parentDocument optional * @property {"object"} documentData blackbox object - * @property {String} changeType optional, allowed values: "insert", "update", "remove" + * @property {String} changeType optional, allowed values: `insert`, `update`, `remove` * @property {Object[]} diff optional, blackbox * @property {Date} createdAt required * @property {Date} updatedAt optional diff --git a/lib/collections/schemas/shipping.js b/lib/collections/schemas/shipping.js index 9d26da0925c..5b0d8e03cca 100644 --- a/lib/collections/schemas/shipping.js +++ b/lib/collections/schemas/shipping.js @@ -11,7 +11,8 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @type {SimpleSchema} * @todo Move Shippo-related schema to Shippo module - * @summary This will only exist in ShippingMethods Inside Cart/Order and not DB shipping Collection as Shippo Methods are Dynamic. + * @summary This will only exist in ShippingMethods Inside Cart/Order. + * This does not exist in DB Shipping Collection as Shippo Methods are Dynamic. * @property {String} serviceLevelToken optional * @property {String} rateId optional */ @@ -35,11 +36,11 @@ registerSchema("ShippoShippingMethod", ShippoShippingMethod); * @property {String} _id Shipment method Id * @property {String} name Method name * @property {String} label Public label - * @property {String} group Group, allowed values: "Ground", "Priority", "One Day", "Free" + * @property {String} group Group, allowed values: `Ground`, `Priority`, `One Day`, `Free` * @property {Number} cost optional - * @property {Number} handling optional, default value: 0 + * @property {Number} handling optional, default value: `0` * @property {Number} rate Rate - * @property {Boolean} enabled default value: false + * @property {Boolean} enabled default value: `false` * @property {Array} validRanges optional, Matching cart ranges * @property {Object} validRanges.$ optional * @property {Number} validRanges.begin optional @@ -165,7 +166,7 @@ registerSchema("ShippingMethod", ShippingMethod); * @type {SimpleSchema} * @property {String} carrier Name of carrier * @property {ShippingMethod} method ShippingMethod - * @property {Number} rate default value: 0.00 + * @property {Number} rate default value: `0.00` */ export const ShipmentQuote = new SimpleSchema({ carrier: { @@ -188,9 +189,9 @@ registerSchema("ShipmentQuote", ShipmentQuote); * @memberof schemas * @type {SimpleSchema} * @summary Populate with order.items that are added to a shipment - * @property {String} _id Shipment Line Item, optional + * @property {String} _id Shipment Line Item optional * @property {String} productId required - * @property {String} shopId Shipment Item ShopId, optional + * @property {String} shopId Shipment Item ShopId optional * @property {Number} quantity required * @property {String} variantId required */ @@ -296,7 +297,7 @@ registerSchema("ShippoShipment", ShippoShipment); * @summary Status of a query/consumption of a shipping provider's API (e.g Shippo) for shipping quotations. * @description Shipping quotations are the costs from different shipping methods like Fedex, DHL etc of * shipping one or more items to a particular place in a given amount of time.) - * @property {String} requestStatus optional, default value: "noRequestYet" + * @property {String} requestStatus optional, default value: `noRequestsYet` * @property {String} shippingProvider optional * @property {Number} numOfShippingMethodsFound optional * @property {String} message optional @@ -342,7 +343,7 @@ registerSchema("ShipmentQuotesQueryStatus", ShipmentQuotesQueryStatus); * @property {Invoice} invoice optional * @property {Object[]} transactions optional * @property {String} shippingLabelUrl For printable Shipping label - * @property {String} customsLabelUrl For Customs printable label + * @property {String} customsLabelUrl For customs printable label * @property {ShippoShipment} shippo For Shippo specific properties */ export const Shipment = new SimpleSchema({ @@ -419,7 +420,8 @@ registerSchema("Shipment", Shipment); /** * @name ShippoShippingProvider Schema * @summary Specific properties for use with Shippo. - * @description We don't use ShippingProvider service* fields because Shippo is on level higher service than simple carrier's ,e.g Fedex api. + * @description We don't use ShippingProvider service* fields because + * Shippo is on level higher service than simple carrier's ,e.g Fedex api. * @memberof schemas * @type {SimpleSchema} * @property {String} carrierAccountId optional @@ -440,7 +442,7 @@ registerSchema("ShippoShippingProvider", ShippoShippingProvider); * @property {String} _id optional * @property {String} name optional * @property {String} label optional - * @property {Boolean} enabled optional, default value: true + * @property {Boolean} enabled optional, default value: `true` * @property {String} serviceAuth optional * @property {String} serviceSecret optional * @property {String} serviceUrl optional @@ -540,7 +542,7 @@ registerSchema("Shipping", Shipping); * @name ShippingPackage * @memberof schemas * @type {SimpleSchema} - * @property {String} settings.name default value: "Flat Rate Service" + * @property {String} settings.name default value: `Flat Rate Service` */ export const ShippingPackageConfig = new SimpleSchema([ PackageConfig, { diff --git a/lib/collections/schemas/shops.js b/lib/collections/schemas/shops.js index 50db27d805a..92bed4c2423 100644 --- a/lib/collections/schemas/shops.js +++ b/lib/collections/schemas/shops.js @@ -46,11 +46,11 @@ registerSchema("CustomEmailSettings", CustomEmailSettings); * @name Currency * @memberof schemas * @type {SimpleSchema} - * @property {String} symbol default value: $ - * @property {String} format default value: %s%v - * @property {Number} scale optional, default value: 2 - * @property {String} decimal optional, default value: . - * @property {String} thousand optional, default value: , + * @property {String} symbol default value: `$` + * @property {String} format default value: `%s%v` + * @property {Number} scale optional, default value: `2` + * @property {String} decimal optional, default value: `.` + * @property {String} thousand optional, default value: `,` * @property {Number} rate optional */ export const Currency = new SimpleSchema({ @@ -111,7 +111,7 @@ registerSchema("Locale", Locale); * @type {SimpleSchema} * @property {String} label required * @property {String} i18n required - * @property {Boolean} enabled, default value: true + * @property {Boolean} enabled, default value: `true` */ export const Languages = new SimpleSchema({ label: { @@ -197,7 +197,45 @@ registerSchema("MerchantShop", MerchantShop); * @memberof schemas * @type {SimpleSchema} * @property {String} _id optional - * @property {String} slug optional + * @property {String} slug optional, auto-generated + * @property {MerchantShop[]} merchantShops optional + * @property {String} shopType required, default value: `merchant`, accepted values: `primary`, `merchant`, `affiliate` + * @property {Boolean} active required, default value: ` true` + * @property {String} status default value: `active` + * @property {String} name + * @property {String} description optional + * @property {String} keywords optional + * @property {Address[]} addressBook optional + * @property {String[]} domains default value: `[localhost]` + * @property {Email[]} emails optional + * @property {String} defaultPaymentMethod required, default value: `none` + * @property {String} currency default value: `USD` + * @property {Object} currencies optional, blackbox, `Currency` schema + * @property {Locale} locales required + * @property {String} language default value: `en` + * @property {Languages[]} languages optional + * @property {String} public optional + * @property {String} timezone default value: `US/Pacific` + * @property {String} baseUOL Base UOL (Unit of Length), default value: `in`, lowercased by default per style + * @property {Object[]} unitsOfLength optional, default value: `in` + * @property {String} unitsOfLength.$.uol default value: `in` + * @property {String} unitsOfLength.$.label default value: `Inches` + * @property {Boolean} unitsOfLength.$.default default value: `false` + * @property {String} baseUOM Base UOM (Unit of Measure), default value: `oz`, lowercased by default per style + * @property {Object[]} unitsOfMeasure optional + * @property {String} unitsOfMeasure.$.uom default value: `oz` + * @property {String} unitsOfMeasure.$.label default value: `Ounces` + * @property {Boolean} unitsOfMeasure.$.default default value: `false` + * @property {Metafield[]} metafields optional + * @property {String[]} defaultSellerRoles default values: `["owner", "admin", "seller", "guest", "manage-users", "orders", "account/profile", "product", "createProduct", "tag", "index", "cart/checkout", "cart/completed"]` + * @property {Layout[]} layout optional + * @property {ShopTheme} theme optional + * @property {BrandAsset[]} brandAssets optional + * @property {String} appVersion optional + * @property {Date} createdAt optional + * @property {Date} updatedAt optional + * @property {Object[]} paymentMethods blackbox, default value: `[]` + * @property {Workflow} workflow optional */ export const Shop = new SimpleSchema({ "_id": { diff --git a/lib/collections/schemas/sms.js b/lib/collections/schemas/sms.js index 6571a380a98..39ea116be4c 100644 --- a/lib/collections/schemas/sms.js +++ b/lib/collections/schemas/sms.js @@ -5,11 +5,11 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @name Sms * @memberof schemas * @type {SimpleSchema} - * @property {String} apiKey, optional - * @property {String} apiToken, optional - * @property {String} shopId, optional - * @property {String} smsPhone, optional - * @property {String} smsProvider, optional + * @property {String} apiKey optional + * @property {String} apiToken optional + * @property {String} shopId optional + * @property {String} smsPhone optional + * @property {String} smsProvider optional */ export const Sms = new SimpleSchema({ apiKey: { diff --git a/lib/collections/schemas/social.js b/lib/collections/schemas/social.js index 1a505ca0fa3..078bc2c06ff 100644 --- a/lib/collections/schemas/social.js +++ b/lib/collections/schemas/social.js @@ -7,7 +7,7 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @type {SimpleSchema} * @property {String} profilePage optional, Profile Page - * @property {Boolean} enabled optional, default value: false + * @property {Boolean} enabled optional, default value: `false` */ export const SocialProvider = new SimpleSchema({ profilePage: { diff --git a/lib/collections/schemas/tags.js b/lib/collections/schemas/tags.js index 3a7c4be86bc..4019111a484 100644 --- a/lib/collections/schemas/tags.js +++ b/lib/collections/schemas/tags.js @@ -14,10 +14,10 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @property {Metafield[]} metafields optional * @property {Number} position optional * @property {String[]} relatedTagIds optional - * @property {Boolean} isDeleted default value: false + * @property {Boolean} isDeleted default value: `false` * @property {Boolean} isTopLevel required - * @property {Boolean} isVisible defalut value: true - * @property {String[]} groups optional, default value: [], groupIds that this tag belongs to + * @property {Boolean} isVisible defalut value: `true` + * @property {String[]} groups optional, default value: `[],` groupIds that this tag belongs to * @property {String} shopId Tag shopId * @property {Date} createdAt required * @property {Date} updatedAt required diff --git a/lib/collections/schemas/templates.js b/lib/collections/schemas/templates.js index 31ba7980051..b1658d13fc1 100644 --- a/lib/collections/schemas/templates.js +++ b/lib/collections/schemas/templates.js @@ -11,12 +11,12 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @property {Number} priority optional, default value: 1 * @property {Boolean} enabled default value: true * @property {String} route optional - * @property {String} type default value: "template" - * @property {String} provides default value: "template" + * @property {String} type default value: `template` + * @property {String} provides default value: `template` * @property {String} block optional * @property {Object} defaultData optional, blackbox * @property {String} parser required - * @property {String} language optional, default value: "en" + * @property {String} language optional, default value: `en` * @property {String} source optional */ const sharedFields = { @@ -76,6 +76,7 @@ const sharedFields = { /** * @name ReactLayout * @memberof schemas + * @summary Extends fields from sharedFields * @type {SimpleSchema} * @extends {sharedFields} * @property {String[]} templateFor optional @@ -99,6 +100,7 @@ registerSchema("ReactLayout", ReactLayout); /** * @name Template * @memberof schemas + * @summary Extends fields from sharedFields * @type {SimpleSchema} * @extends {sharedFields} * @property {Object[]} template optional, blackbox diff --git a/lib/collections/schemas/themes.js b/lib/collections/schemas/themes.js index 6f26a6c41c3..7ddc615f9b8 100644 --- a/lib/collections/schemas/themes.js +++ b/lib/collections/schemas/themes.js @@ -8,7 +8,7 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @memberof schemas * @property {String} name required * @property {String} author optional - * @property {String} layout default value: "coreLayout" + * @property {String} layout default value: `coreLayout` * @property {String} url optional * @property {Object[]} components optional, blackbox */ diff --git a/lib/collections/schemas/translations.js b/lib/collections/schemas/translations.js index 5f8c58f8149..b3bff310f28 100644 --- a/lib/collections/schemas/translations.js +++ b/lib/collections/schemas/translations.js @@ -10,7 +10,7 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; * @property {String} shopId, Translation ShopId * @property {String} language, language * @property {String} i18n, translation - * @property {String} ns, Namespace + * @property {String} ns, namespace * @property {Object} translation, blackbox */ export const Translation = new SimpleSchema({ diff --git a/lib/collections/schemas/workflow.js b/lib/collections/schemas/workflow.js index 4e9bbd37239..f4e6b47a432 100644 --- a/lib/collections/schemas/workflow.js +++ b/lib/collections/schemas/workflow.js @@ -3,11 +3,12 @@ import { registerSchema } from "@reactioncommerce/reaction-collections"; /** * @name Workflow - * @summary for attaching to collection where PackageWorkflow is controlling view flow. Shop defaultWorkflow is defined in Shop. + * @summary Control view flow by attaching layout to a collection. + * Shop defaultWorkflow is defined in Shop. * @memberof schemas * @type {SimpleSchema} - * @property {String} status, default value: "new" - * @property {String[]} workflow, optional + * @property {String} status, default value: `new` + * @property {String[]} workflow optional */ export const Workflow = new SimpleSchema({ status: { From e535af3dd5a27067f453ace4af5445e0bde661cb Mon Sep 17 00:00:00 2001 From: Seun Martins Date: Mon, 23 Oct 2017 18:30:18 -0700 Subject: [PATCH 51/59] Update version no --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78f1ef28ea7..8fc02f47117 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "reaction", "description": "Reaction is a modern reactive, real-time event driven ecommerce platform.", - "version": "1.5.3", + "version": "1.5.4", "main": "main.js", "directories": { "test": "tests" From 01c9f40422b07539dc2d647197d059d45318c9a5 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 07:40:33 -0700 Subject: [PATCH 52/59] jsdoc: rename to Methods instead of Meteor and add examples --- .../core/checkout/server/methods/workflow.js | 27 +++--- .../inventory/server/methods/statusChanges.js | 83 ++++++++++--------- .../server/methods/notifications.js | 16 ++-- .../included/sms/server/methods/sms.js | 12 +-- lib/api/account-validation.js | 23 ++--- server/methods/accounts/accounts-password.js | 4 +- server/methods/accounts/accounts.js | 79 +++++++++--------- .../methods/accounts/serviceConfiguration.js | 4 +- server/methods/catalog.js | 76 ++++++++--------- server/methods/core/cart.js | 77 +++++++++-------- server/methods/core/cartToOrder.js | 16 ++-- server/methods/core/groups.js | 42 +++++----- server/methods/core/shop.js | 70 ++++++++-------- server/methods/core/workflows/orders.js | 4 +- server/methods/email.js | 19 +++-- server/methods/helpers.js | 6 +- 16 files changed, 287 insertions(+), 271 deletions(-) diff --git a/imports/plugins/core/checkout/server/methods/workflow.js b/imports/plugins/core/checkout/server/methods/workflow.js index f98c314cca3..ba274ca403a 100644 --- a/imports/plugins/core/checkout/server/methods/workflow.js +++ b/imports/plugins/core/checkout/server/methods/workflow.js @@ -8,16 +8,17 @@ import { Logger, Reaction } from "/server/api"; /* eslint no-shadow: 0 */ /** - * @file Meteor methods for SMS + * @file Methods for Workflow. Run these methods using `Meteor.call()`. + * @example Meteor.call("workflow/pushCartWorkflow", "coreCartWorkflow", "checkoutLogin"); * - * - * @namespace Meteor/Workflow + * @namespace Methods/Workflow */ Meteor.methods({ /** - * @name pushCartWorkflow - * @memberof Meteor/Workflow + * @name workflow/pushCartWorkflow + * @memberof Methods/Workflow * @method + * @example Meteor.call("workflow/pushCartWorkflow", "coreCartWorkflow", "checkoutLogin"); * @summary updates cart workflow status * @description status in the workflow is stored as the current active workflow step. * first sets, second call moves status to next workflow @@ -212,8 +213,8 @@ Meteor.methods({ }, /** - * @name revertCartWorkflow - * @memberof Meteor/Workflow + * @name workflow/revertCartWorkflow + * @memberof Methods/Workflow * @method * @summary if something was changed on the previous `cartWorkflow` steps, * we need to revert to this step to renew the order @@ -249,7 +250,7 @@ Meteor.methods({ }, /** - * @name pushOrderWorkflow + * @name workflow/pushOrderWorkflow * @summary Update the order workflow: Push the status as the current workflow step, * move the current status to completed worflow steps * @@ -259,7 +260,7 @@ Meteor.methods({ * Step 2 (this method) of the "workflow/pushOrderWorkflow" flow; Try to update the current status * * @method - * @memberof Meteor/Workflow + * @memberof Methods/Workflow * @param {String} workflow workflow to push to * @param {String} status - Workflow status * @param {Order} order - Schemas.Order, an order object @@ -290,11 +291,11 @@ Meteor.methods({ }, /** - * @name pullOrderWorkflow + * @name workflow/pullOrderWorkflow * @description Push the status as the current workflow step, move the current status to completed worflow steps * @summary Pull a previous order status * @method - * @memberof Meteor/Workflow + * @memberof Methods/Workflow * @param {String} workflow workflow to push to * @param {String} status - Workflow status * @param {Order} order - Schemas.Order, an order object @@ -321,9 +322,9 @@ Meteor.methods({ }, /** - * @name pushItemWorkflow + * @name workflow/pushItemWorkflow * @method - * @memberof Meteor/Workflow + * @memberof Methods/Workflow * @param {String} status Workflow status * @param {Object} order Schemas.Order, an order object * @param {String[]} itemIds Array of item IDs diff --git a/imports/plugins/included/inventory/server/methods/statusChanges.js b/imports/plugins/included/inventory/server/methods/statusChanges.js index d097db453ad..1f9e82b5a08 100644 --- a/imports/plugins/included/inventory/server/methods/statusChanges.js +++ b/imports/plugins/included/inventory/server/methods/statusChanges.js @@ -29,20 +29,21 @@ import { Logger, Reaction } from "/server/api"; // DDPRateLimiter.addRule(addBackorderRule, 5, 1000); /** - * @file Meteor methods for Inventory + * @file Methods for Inventory. Run these methods using `Meteor.call()` * * - * @namespace Meteor/Inventory + * @namespace Methods/Inventory */ Meteor.methods({ /** - * @name setStatus + * @name inventory/setStatus * @method - * @memberof Meteor/Inventory - * @summary sets status from one status to a new status. Defaults to "new" to "reserved" + * @memberof Methods/Inventory + * @summary Sets status from one status to a new status. Defaults to `new` to `reserved` + * @example Meteor.call("inventory/backorder", reservation, backOrderQty); * @param {Array} cartItems array of objects of type Schemas.CartItems - * @param {String} status optional - sets the inventory workflow status, defaults to "reserved" - * @param {String} currentStatus - what is the current status to change "from" + * @param {String} status optional - sets the inventory workflow status, defaults to `reserved` + * @param {String} currentStatus - what is the current status to change `from` * @param {String} notFoundStatus - what to use if the status is not found * @todo move this to bulkOp * @return {Number} returns reservationCount @@ -150,13 +151,13 @@ Meteor.methods({ }, /** - * @name clearStatus + * @name inventory/clearStatus * @method - * @memberof Meteor/Inventory - * @summary used to reset status on inventory item (defaults to "new") + * @memberof Methods/Inventory + * @summary Used to reset status on inventory item (defaults to `new`) * @param {Array} cartItems array of objects Schemas.CartItem - * @param {Array} status optional reset workflow.status, defaults to "new" - * @param {Array} currentStatus optional matching workflow.status, defaults to "reserved" + * @param {Array} status optional reset workflow.status, defaults to `new` + * @param {Array} currentStatus optional matching workflow.status, defaults to `reserved` * @return {undefined} undefined */ "inventory/clearStatus": function (cartItems, status, currentStatus) { @@ -206,10 +207,11 @@ Meteor.methods({ }, /** - * @name clearReserve + * @name inventory/clearReserve * @method - * @memberof Meteor/Inventory - * @summary resets "reserved" items to "new" + * @memberof Methods/Inventory + * @example Meteor.call("inventory/clearReserve", cart.items) + * @summary Resets `reserved` items to `new` * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -219,10 +221,11 @@ Meteor.methods({ }, /** - * @name clearReserve - * @summary converts new items to reserved, or backorders + * @name inventory/addReserve + * @summary Converts new items to reserved, or backorders * @method - * @memberof Meteor/Inventory + * @example Meteor.call("inventory/addReserve", cart.items) + * @memberof Methods/Inventory * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -232,12 +235,12 @@ Meteor.methods({ }, /** - * @name backorder - * @summary is used by the cart process to create a new Inventory backorder item, + * @name inventory/backorder + * @summary Used by the cart process to create a new Inventory backorder item, * but this could be used for inserting any custom inventory. * @method - * @description A note on DDP Limits: As these are wide open we defined some {@link http://docs.meteor.com/#/full/ddpratelimiter ddp limiting rules} - * @memberof Meteor/Inventory + * A note on DDP Limits: As these are wide open we defined some {@link http://docs.meteor.com/#/full/ddpratelimiter ddp limiting rules} + * @memberof Methods/Inventory * @param {Object} reservation Schemas.Inventory * @param {Number} backOrderQty number of backorder items to create * @returns {Number} number of inserted backorder documents @@ -296,10 +299,10 @@ Meteor.methods({ }, /** - * @name lowStock - * @summary send low stock warnings + * @name inventory/lowStock + * @summary Send low stock warnings * @method - * @memberof Meteor/Inventory + * @memberof Methods/Inventory * @param {Object} product object type Product * @return {undefined} * @todo implement inventory/lowstock calculations @@ -311,10 +314,10 @@ Meteor.methods({ }, /** - * @name remove - * @summary delete an inventory item permanently + * @name inventory/remove + * @summary Delete an inventory item permanently * @method - * @memberof Meteor/Inventory + * @memberof Methods/Inventory * @param {Object} inventoryItem object type Schemas.Inventory * @return {String} return remove result */ @@ -338,10 +341,10 @@ Meteor.methods({ }, /** - * @name shipped + * @name inventory/shipped * @method - * @memberof Meteor/Inventory - * @summary mark inventory as shipped + * @memberof Methods/Inventory + * @summary Mark inventory as shipped * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -351,10 +354,10 @@ Meteor.methods({ }, /** - * @name sold + * @name inventory/sold * @method - * @memberof Meteor/Inventory - * @summary mark inventory as sold + * @memberof Methods/Inventory + * @summary Mark inventory as sold * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -364,10 +367,10 @@ Meteor.methods({ }, /** - * @name return + * @name inventory/return * @method - * @memberof Meteor/Inventory - * @summary mark inventory as returned + * @memberof Methods/Inventory + * @summary Mark inventory as returned * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ @@ -377,10 +380,10 @@ Meteor.methods({ }, /** - * @name returnToStock + * @name inventory/returnToStock * @method - * @memberof Meteor/Inventory - * @summary mark inventory as return and available for sale + * @memberof Methods/Inventory + * @summary Mark inventory as return and available for sale * @param {Array} cartItems array of objects Schemas.CartItem * @return {undefined} */ diff --git a/imports/plugins/included/notifications/server/methods/notifications.js b/imports/plugins/included/notifications/server/methods/notifications.js index f45efc8a594..554bd789619 100644 --- a/imports/plugins/included/notifications/server/methods/notifications.js +++ b/imports/plugins/included/notifications/server/methods/notifications.js @@ -4,15 +4,15 @@ import { Reaction, Logger } from "/server/api"; import { Notifications, Packages } from "/lib/collections"; /** - * @file Meteor methods for Notifications + * @file Methods for Notifications. Run these methods using `Meteor.call()`. * * - * @namespace Meteor/Notification + * @namespace Methods/Notification */ Meteor.methods({ /** - * @name send - * @memberof Meteor/Notification + * @name notification/send + * @memberof Methods/Notification * @method * @summary This send a notification to a user * @param {String} userId - The user @@ -68,8 +68,8 @@ Meteor.methods({ }, /** - * @name markOneAsRead - * @memberof Meteor/Notification + * @name notification/markOneAsRead + * @memberof Methods/Notification * @method * @summary This marks all user's notification as ready * @param {String} id - The notification id @@ -86,8 +86,8 @@ Meteor.methods({ }, /** - * @name delete - * @memberof Meteor/Notification + * @name notification/delete + * @memberof Methods/Notification * @method * @summary This deletes a notification * @param {String} id - The notification id diff --git a/imports/plugins/included/sms/server/methods/sms.js b/imports/plugins/included/sms/server/methods/sms.js index 93a633676ee..37fedf11e8c 100644 --- a/imports/plugins/included/sms/server/methods/sms.js +++ b/imports/plugins/included/sms/server/methods/sms.js @@ -6,16 +6,16 @@ import { Sms, Accounts } from "/lib/collections"; import { Reaction, Logger } from "/server/api"; /** - * @file Meteor methods for SMS + * @file Meteor methods for SMS. Run these methods using `Meteor.call()`. * * - * @namespace Meteor/SMS + * @namespace Methods/SMS */ Meteor.methods({ /** - * @name saveSettings + * @name sms/saveSettings * @method - * @memberof Meteor/SMS + * @memberof Methods/SMS * @summary This save the sms provider settings * @param {Object} settings - settings * @return {object} returns result @@ -34,9 +34,9 @@ Meteor.methods({ }, /** - * @name send + * @name sms/send * @method - * @memberof Meteor/SMS + * @memberof Methods/SMS * @summary This send the sms to the user * @param {String} message - The message to send * @param {String} userId - The user to receive the message diff --git a/lib/api/account-validation.js b/lib/api/account-validation.js index 86421b70037..de4f3f9bd58 100644 --- a/lib/api/account-validation.js +++ b/lib/api/account-validation.js @@ -3,15 +3,18 @@ import { check, Match } from "meteor/check"; /** * @file Methods for Account Validation - * Methods for validating account username, email and password. Methods are exported globally in the `LoginFormValidation` object and they are also registered as Meteor methods. - * @namespace Meteor/Accounts/Validation + * Methods for validating account username, email and password. Methods are exported globally in the `LoginFormValidation` object and they are also registered as Meteor methods. Call the methods using + * `Meteor.call()` or `LoginFormValidation.method`. + * @example LoginFormValidation.password(password, { validationLevel: "exists" }) + * @example Meteor.call("accounts/validation/email", newEmail, false, (result, error)) + * @namespace Methods/Accounts/Validation */ const validationMethods = { /** - * @name username + * @name accounts/validation/username * @method - * @memberof Meteor/Accounts/Validation + * @memberof Methods/Accounts/Validation * @summary Determines if a username meets the minimum requirement of 3 characters * @param {String} username Username to validate * @return {Boolean|Object} true if valid, error object if invalid @@ -33,9 +36,9 @@ const validationMethods = { }, /** - * @name email + * @name accounts/validation/email * @method - * @memberof Meteor/Accounts/Validation + * @memberof Methods/Accounts/Validation * @summary Validates both required and optional email addresses. * @example LoginFormValidation.email(emailAddress) * @example Meteor.call("accounts/validation/email", newEmail, false, callbackFunction()) @@ -65,13 +68,13 @@ const validationMethods = { }, /** - * @name password + * @name accounts/validation/password * @method - * @memberof Meteor/Accounts/Validation + * @memberof Methods/Accounts/Validation * @summary Passwords may be validated 2 ways. - * 1. "exists" (options.validationLevel = "exists") - Password must not be blank. + * 1. "exists" `(options.validationLevel = "exists")` - Password must not be blank. * Thats is the only rule. Used to validate a sign in. - * 2. undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. + * 2. undefined `(options.validationLevel = undefined)` - Password must meet the lenght and other criteria to validate. * Used for validating a new sign up. * @example LoginFormValidation.password(pword, { validationLevel: "exists" }) * @param {String} password Password to validate diff --git a/server/methods/accounts/accounts-password.js b/server/methods/accounts/accounts-password.js index 721a9055865..a467377b814 100644 --- a/server/methods/accounts/accounts-password.js +++ b/server/methods/accounts/accounts-password.js @@ -5,8 +5,8 @@ import { Accounts } from "meteor/accounts-base"; import { Reaction, Logger } from "/server/api"; /** - * @name sendResetPasswordEmail - * @memberof Meteor/Accounts + * @name accounts/sendResetPasswordEmail + * @memberof Methods/Accounts * @method * @example Meteor.call("accounts/sendResetPasswordEmail", options) * @summary Send reset password email diff --git a/server/methods/accounts/accounts.js b/server/methods/accounts/accounts.js index 05e64abfecd..c084dde7ffb 100644 --- a/server/methods/accounts/accounts.js +++ b/server/methods/accounts/accounts.js @@ -13,15 +13,15 @@ import { Logger, Reaction } from "/server/api"; import { sendUpdatedVerificationEmail } from "/server/api/core/accounts"; /** - * @file Meteor methods for Accounts - * Reaction extends {@link https://github.com/meteor/meteor/tree/master/packages/accounts-base MeteorAccounts} - * with Reaction-specific behavior and user interaction. - * @namespace Meteor/Accounts + * @file Extends Meteor's {@link https://github.com/meteor/meteor/tree/master/packages/accounts-base Accounts-Base} + * with methods for Reaction-specific behavior and user interaction. Run these methods using: `Meteor.call()` + * @example Meteor.call("accounts/verifyAccount", email, token) + * @namespace Methods/Accounts */ /** - * @name verifyAccount - * @memberof Meteor/Accounts + * @name accounts/verifyAccount + * @memberof Methods/Accounts * @method * @summary Verify registered user account * @example Meteor.call("accounts/verifyAccount", email, token) @@ -70,8 +70,8 @@ export function verifyAccount(email, token) { } /** - * @name updateEmailAddress - * @memberof Meteor/Accounts + * @name accounts/updateEmailAddress + * @memberof Methods/Accounts * @method * @summary Update a user's email address * @param {String} email - user email @@ -88,8 +88,8 @@ export function updateEmailAddress(email) { } /** - * @name removeEmailAddress - * @memberof Meteor/Accounts + * @name accounts/removeEmailAddress + * @memberof Methods/Accounts * @method * @summary Remove a user's email address. * @param {String} email - user email. @@ -113,8 +113,8 @@ export function removeEmailAddress(email) { } /** - * @name syncUsersAndAccounts - * @memberof Meteor/Accounts + * @name accounts/syncUsersAndAccounts + * @memberof Methods/Accounts * @method * @summary Syncs emails associated with a user profile between the Users and Accounts collections. * @returns {Boolean} - returns boolean. @@ -182,7 +182,7 @@ function getValidator() { } /** - * @name compareAddress + * @name acompareAddress * @summary Compare individual fields of address and accumulate errors * @param {Object} address - the address provided by the customer * @param {Object} validationAddress - address provided by validator @@ -263,8 +263,8 @@ function compareAddress(address, validationAddress) { } /** - * @name validateAddress - * @memberof Meteor/Accounts + * @name accounts/validateAddress + * @memberof Methods/Accounts * @method * @summary Validates an address, and if fails returns details of issues * @param {Object} address - The address object to validate @@ -310,8 +310,8 @@ function currentUserHasPassword() { } /** - * @name addressBookAdd - * @memberof Meteor/Accounts + * @name accounts/addressBookAdd + * @memberof Methods/Accounts * @method * @summary Add new addresses to an account * @example Meteor.call("accounts/addressBookAdd", address, callBackFunction(error, result)) @@ -404,8 +404,8 @@ export function addressBookAdd(address, accountUserId) { } /** - * @name addressBookUpdate - * @memberof Meteor/Accounts + * @name accounts/addressBookUpdate + * @memberof Methods/Accounts * @method * @summary Update existing address in user's profile * @param {Object} address - address @@ -523,8 +523,8 @@ export function addressBookUpdate(address, accountUserId, type) { } /** - * @name addressBookRemove - * @memberof Meteor/Accounts + * @name accounts/addressBookRemove + * @memberof Methods/Accounts * @method * @summary Remove existing address in user's profile * @param {String} addressId - address `_id` @@ -561,9 +561,9 @@ export function addressBookRemove(addressId, accountUserId) { } /** - * @name inviteShopOwner + * @name accounts/inviteShopOwner * @summary Invite a new user as owner of a new shop - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @method * @param {Object} options - * @param {String} options.email - email of invitee @@ -628,10 +628,10 @@ export function inviteShopOwner(options) { } /** - * @name inviteShopMember + * @name accounts/inviteShopMember * @summary Invite new admin users (not consumers) to secure access in the dashboard to permissions * as specified in packages/roles - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @method * @param {Object} options - * @param {String} options.shopId - shop to invite user @@ -722,9 +722,9 @@ export function inviteShopMember(options) { } /** - * @name sendWelcomeEmail + * @name accounts/sendWelcomeEmail * @summary Send an email to consumers on sign up - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @method * @param {String} shopId - shopId of new User * @param {String} userId - new userId to welcome @@ -822,8 +822,8 @@ export function sendWelcomeEmail(shopId, userId) { } /** - * @name addUserPermissions - * @memberof Meteor/Accounts + * @name accounts/addUserPermissions + * @memberof Methods/Accounts * @method * @param {String} userId - userId * @param {Array|String} permissions - Name of role/permission. @@ -847,8 +847,8 @@ export function addUserPermissions(userId, permissions, group) { } /** - * @name removeUserPermissions - * @memberof Meteor/Accounts + * @name accounts/removeUserPermissions + * @memberof Methods/Accounts * @method * @param {String} userId - userId * @param {Array|String} permissions - Name of role/permission. @@ -873,8 +873,8 @@ export function removeUserPermissions(userId, permissions, group) { } /** - * @name setUserPermissions - * @memberof Meteor/Accounts + * @name accounts/setUserPermissions + * @memberof Methods/Accounts * @method * @param {String} userId - userId * @param {String|Array} permissions - string/array of permissions @@ -899,7 +899,7 @@ export function setUserPermissions(userId, permissions, group) { /** * @name getEmailLogo - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @summary Get shop logo, if available. If not, use default logo from file-system * @method * @private @@ -920,7 +920,7 @@ function getEmailLogo(shop) { /** * @name getCurrentUserName - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @method * @private * @param {Object} currentUser - User @@ -944,11 +944,12 @@ function getCurrentUserName(currentUser) { /** * @name getDataForEmail - * @memberof Meteor/Accounts + * @memberof Methods/Accounts * @method * @private * @param {Object} options - shop, currentUserName, token, emailLogo, name - * @return {Object} data - primaryShop, shop, contactEmail, homepage, emailLogo, legalName, physicalAddress, shopName, socialLinks, user, invitedUserName, url + * @return {Object} data - primaryShop, shop, contactEmail, homepage, + * emailLogo, legalName, physicalAddress, shopName, socialLinks, user, invitedUserName, url */ function getDataForEmail(options) { const { shop, currentUserName, token, emailLogo, name } = options; @@ -1002,8 +1003,8 @@ function getDataForEmail(options) { } /** - * @name createFallbackLoginToken - * @memberof Meteor/Accounts + * @name accounts/createFallbackLoginToken + * @memberof Methods/Accounts * @method * @summary Returns a new loginToken for current user, that can be used for special login scenarios * e.g. store the newly created token as cookie on the browser, if the client does not offer local storage. diff --git a/server/methods/accounts/serviceConfiguration.js b/server/methods/accounts/serviceConfiguration.js index 1e91dba50d4..01d0a49836a 100644 --- a/server/methods/accounts/serviceConfiguration.js +++ b/server/methods/accounts/serviceConfiguration.js @@ -5,8 +5,8 @@ import { ServiceConfiguration } from "meteor/service-configuration"; import { Reaction } from "/server/api"; /** - * @name updateServiceConfiguration - * @memberof Meteor/Accounts + * @name accounts/updateServiceConfiguration + * @memberof Methods/Accounts * @method * @example Meteor.call("accounts/updateServiceConfiguration", service, fields, (callBackFunction)) * @summary Update service configuration diff --git a/server/methods/catalog.js b/server/methods/catalog.js index d2df22a0a41..51151827f9a 100644 --- a/server/methods/catalog.js +++ b/server/methods/catalog.js @@ -13,10 +13,10 @@ import { Logger, Reaction } from "/server/api"; /* eslint quotes: 0 */ /** - * @file Meteor methods for Product + * @file Methods for Products. Run these methods using `Meteor.call()`. * * - * @namespace Meteor/Product + * @namespace Methods/Products */ /** @@ -326,8 +326,8 @@ function flushQuantity(id) { Meteor.methods({ /** - * @name cloneVariant - * @memberof Meteor/Product + * @name products/cloneVariant + * @memberof Methods/Products * @method * @summary clones a product variant into a new variant * @description the method copies variants, but will also create and clone @@ -451,8 +451,8 @@ Meteor.methods({ }, /** - * @name createVariant - * @memberof Meteor/Product + * @name products/createVariant + * @memberof Methods/Products * @method * @summary initializes empty variant template * @param {String} parentId - the product _id or top level variant _id where @@ -519,8 +519,8 @@ Meteor.methods({ }, /** - * @name updateVariant - * @memberof Meteor/Product + * @name products/updateVariant + * @memberof Methods/Products * @method * @summary update individual variant with new values, merges into original * only need to supply updated information. Currently used for a one use case @@ -570,8 +570,8 @@ Meteor.methods({ }, /** - * @name deleteVariant - * @memberof Meteor/Product + * @name products/deleteVariant + * @memberof Methods/Products * @method * @summary delete variant, which should also delete child variants * @param {String} variantId - variantId to delete @@ -617,8 +617,8 @@ Meteor.methods({ }, /** - * @name cloneProduct - * @memberof Meteor/Product + * @name products/cloneProduct + * @memberof Methods/Products * @method * @summary clone a whole product, defaulting visibility, etc * in the future we are going to do an inheritance product @@ -756,8 +756,8 @@ Meteor.methods({ }, /** - * @name createProduct - * @memberof Meteor/Product + * @name products/createProduct + * @memberof Methods/Products * @method * @summary when we create a new product, we create it with an empty variant. * all products have a variant with pricing and details @@ -798,8 +798,8 @@ Meteor.methods({ }, /** - * @name archiveProduct - * @memberof Meteor/Product + * @name products/archiveProduct + * @memberof Methods/Products * @method * @summary archive a product and unlink it from all media * @param {String} productId - productId to delete @@ -886,8 +886,8 @@ Meteor.methods({ }, /** - * @name updateProductField - * @memberof Meteor/Product + * @name products/updateProductField + * @memberof Methods/Products * @method * @summary update single product or variant field * @param {String} _id - product._id or variant._id to update @@ -969,8 +969,8 @@ Meteor.methods({ }, /** - * @name updateProductTags - * @memberof Meteor/Product + * @name products/updateProductTags + * @memberof Methods/Products * @method * @summary method to insert or update tag with hierarchy * @param {String} productId - productId @@ -1046,8 +1046,8 @@ Meteor.methods({ }, /** - * @name removeProductTag - * @memberof Meteor/Product + * @name products/removeProductTag + * @memberof Methods/Products * @method * @summary method to remove tag from product * @param {String} productId - productId @@ -1078,8 +1078,8 @@ Meteor.methods({ }, /** - * @name setHandle - * @memberof Meteor/Product + * @name products/setHandle + * @memberof Methods/Products * @method * @summary copy of "products/setHandleTag", but without tag * @param {String} productId - productId @@ -1109,8 +1109,8 @@ Meteor.methods({ }, /** - * @name setHandleTag - * @memberof Meteor/Product + * @name products/setHandleTag + * @memberof Methods/Products * @method * @summary set or toggle product handle * @param {String} productId - productId @@ -1165,8 +1165,8 @@ Meteor.methods({ }, /** - * @name updateProductPosition - * @memberof Meteor/Product + * @name products/updateProductPosition + * @memberof Methods/Products * @method * @summary update product grid positions * @param {String} productId - productId @@ -1209,8 +1209,8 @@ Meteor.methods({ }, /** - * @name updateVariantsPosition - * @memberof Meteor/Product + * @name products/updateVariantsPosition + * @memberof Methods/Products * @method * @description updates top level variant position index * @param {Array} sortedVariantIds - array of top level variant `_id`s @@ -1247,8 +1247,8 @@ Meteor.methods({ }, /** - * @name updateMetaFields - * @memberof Meteor/Product + * @name products/updateMetaFields + * @memberof Methods/Products * @method * @summary update product metafield * @param {String} productId - productId @@ -1313,8 +1313,8 @@ Meteor.methods({ }, /** - * @name removeMetaFields - * @memberof Meteor/Product + * @name products/removeMetaFields + * @memberof Methods/Products * @method * @summary update product metafield * @param {String} productId - productId @@ -1346,8 +1346,8 @@ Meteor.methods({ }, /** - * @name publishProduct - * @memberof Meteor/Product + * @name products/publishProduct + * @memberof Methods/Products * @method * @summary publish (visibility) of product * @todo hook into publishing flow @@ -1425,8 +1425,8 @@ Meteor.methods({ }, /** - * @name toggleVisibility - * @memberof Meteor/Product + * @name products/toggleVisibility + * @memberof Methods/Products * @method * @summary publish (visibility) of product * @todo hook into publishing flow diff --git a/server/methods/core/cart.js b/server/methods/core/cart.js index 31d8ac5568c..b8d7267b63e 100644 --- a/server/methods/core/cart.js +++ b/server/methods/core/cart.js @@ -9,7 +9,7 @@ import { Logger, Reaction } from "/server/api"; /** * @method quantityProcessing * @private - * @summary perform calculations admissibility of adding product to cart + * @summary Perform calculations admissibility of adding product to cart * @param {Object} product - product to add to Cart * @param {Object} variant - product variant * @param {Number} itemQty - qty to add to cart, defaults to 1, deducts @@ -47,7 +47,7 @@ function quantityProcessing(product, variant, itemQty = 1) { /** * @method getSessionCarts * @private - * @summary get Cart cursor with all session carts + * @summary Get Cart cursor with all session carts * @param {String} userId - current user _id * @param {String} sessionId - current user session id * @param {String} shopId - shop id @@ -85,6 +85,13 @@ function getSessionCarts(userId, sessionId, shopId) { return allowedCarts; } +/** + * @method removeShippingAddresses + * @private + * @summary Remove shipping address from cart + * @param {String} cart - current cart + * @return null + */ function removeShippingAddresses(cart) { const cartShipping = cart.shipping; cartShipping.map((sRecord) => { @@ -98,20 +105,20 @@ function removeShippingAddresses(cart) { } /** - * @file Meteor for Cart - * - * @namespace Meteor/Cart + * @file Methods for Cart - Use these methods by running `Meteor.call()` + * @example Meteor.call("cart/createCart", this.userId, sessionId) + * @namespace Methods/Cart */ Meteor.methods({ /** * @method cart/mergeCart * @summary Merge matching sessionId cart into specified userId cart - * @description There should be one cart for each independent, non-logged-in user session. + * There should be one cart for each independent, non-logged-in user session. * When a user logs in that cart now belongs to that user and we use the a single user cart. * If they are logged in on more than one devices, regardless of session,the user cart will be used * If they had more than one cart, on more than one device,logged in at separate times then merge the carts - * @memberof Meteor/Cart + * @memberof Methods/Cart * @param {String} cartId - cartId of the cart to merge matching session carts into. * @param {String} [currentSessionId] - current client session id * @todo I think this method should be moved out from methods to a Function Declaration to keep it more secure @@ -238,10 +245,9 @@ Meteor.methods({ /** * @method cart/createCart - * @description create new cart for user, + * @summary create new cart for user, * but all checks for current cart's existence should go before this method will be called, to keep it clean - * @summary create and return new cart for user - * @memberof Meteor/Cart + * @memberof Methods/Cart * @param {String} userId - userId to create cart for * @param {String} sessionId - current client session id * @todo I think this method should be moved out from methods to a Function Declaration to keep it more secure @@ -315,12 +321,11 @@ Meteor.methods({ /** * @method cart/addToCart - * @summary add items to a user cart - * @description when we add an item to the cart, + * @summary Add items to a user cart. When we add an item to the cart, * we want to break all relationships with the existing item. - * We want to fix price, qty, etc into history - * however, we could check reactively for price /qty etc, adjustments on the original and notify them - * @memberof Meteor/Cart + * We want to fix price, qty, etc into history. + * However, we could check reactively for price /qty etc, adjustments on the original and notify them. + * @memberof Methods/Cart * @param {String} productId - productId to add to Cart * @param {String} variantId - product variant _id * @param {Number} [itemQty] - qty to add to cart @@ -480,8 +485,8 @@ Meteor.methods({ /** * @method cart/removeFromCart - * @memberof Meteor/Cart - * @summary removes or adjust quantity of a variant from the cart + * @memberof Methods/Cart + * @summary Removes or adjust quantity of a variant from the cart * @param {String} itemId - cart item _id * @param {Number} [quantity] - if provided will adjust increment by quantity * @returns {Number} returns Mongo update result @@ -574,8 +579,8 @@ Meteor.methods({ /** * @method cart/setShipmentMethod - * @memberof Meteor/Cart - * @summary saves method as order default + * @memberof Methods/Cart + * @summary Saves method as order default * @param {String} cartId - cartId to apply shipmentMethod * @param {Object} method - shipmentMethod object * @return {Number} return Mongo update result @@ -643,8 +648,8 @@ Meteor.methods({ /** * @method cart/setUserCurrency - * @memberof Meteor/Cart - * @summary saves user currency in cart, to be paired with order/setCurrencyExhange + * @memberof Methods/Cart + * @summary Saves user currency in cart, to be paired with order/setCurrencyExhange * @param {String} cartId - cartId to apply setUserCurrency * @param {String} userCurrency - userCurrency to set to cart * @return {Number} update result @@ -703,8 +708,8 @@ Meteor.methods({ /** * @method cart/resetShipmentMethod - * @memberof Meteor/Cart - * @summary removes `shipmentMethod` object from cart + * @memberof Methods/Cart + * @summary Removes `shipmentMethod` object from cart * @param {String} cartId - cart _id * @return {Number} update result */ @@ -728,8 +733,8 @@ Meteor.methods({ /** * @method cart/setShipmentAddress - * @memberof Meteor/Cart - * @summary adds address book to cart shipping + * @memberof Methods/Cart + * @summary Adds address book to cart shipping * @param {String} cartId - cartId to apply shipmentMethod * @param {Object} address - addressBook object * @return {Number} update result @@ -872,8 +877,8 @@ Meteor.methods({ /** * @method cart/setPaymentAddress - * @memberof Meteor/Cart - * @summary adds addressbook to cart payments + * @memberof Methods/Cart + * @summary Adds addressbook to cart payments * @param {String} cartId - cartId to apply payment address * @param {Object} address - addressBook object * @todo maybe we need to rename this method to `cart/setBillingAddress`? @@ -926,15 +931,15 @@ Meteor.methods({ /** * @method cart/unsetAddresses - * @summary removes address from cart. - * @memberof Meteor/Cart + * @summary Removes address from cart. + * @memberof Methods/Cart * @param {String} addressId - address._id * @param {String} userId - cart owner _id * @param {String} [type] - billing default or shipping default * @since 0.10.1 - * @todo check if no more address in cart as shipping, we should reset `cartWorkflow` to second step + * @todo Check if no more address in cart as shipping, we should reset `cartWorkflow` to second step * @return {Number|Object|Boolean} The number of removed documents or - * errorobject or `false` if we don't need to update cart + * error object or `false` if we don't need to update cart */ "cart/unsetAddresses": function (addressId, userId, type) { check(addressId, String); @@ -994,9 +999,9 @@ Meteor.methods({ /** * @method cart/submitPayment - * @memberof Meteor/Cart - * @summary saves a submitted payment to cart, triggers workflow and adds "paymentSubmitted" to cart workflow - * @description Note: this method also has a client stub, that forwards to cartCompleted + * @memberof Methods/Cart + * @summary Saves a submitted payment to cart, triggers workflow and adds "paymentSubmitted" to cart workflow + * Note: this method also has a client stub, that forwards to cartCompleted * @param {Object|Array} paymentMethods - an array of paymentMethods or (deprecated) a single paymentMethod object * @return {String} returns update result */ @@ -1097,8 +1102,8 @@ Meteor.methods({ /** * @method cart/setAnonymousUserEmail - * @memberof Meteor/Cart - * @summary assigns email to anonymous user's cart instance + * @memberof Methods/Cart + * @summary Assigns email to anonymous user's cart instance * @param {Object} userId - current user's Id * @param {String} email - email to set for anonymous user's cart instance * @return {Number} returns update result diff --git a/server/methods/core/cartToOrder.js b/server/methods/core/cartToOrder.js index 5adb142b477..118e3f9b84d 100644 --- a/server/methods/core/cartToOrder.js +++ b/server/methods/core/cartToOrder.js @@ -7,13 +7,15 @@ import { Logger, Reaction } from "/server/api"; /** - * cart/copyCartToOrder - * @summary transform cart to order when a payment is processed we want to - * copy the cart over to an order object, and give the user a new empty - * cart. reusing the cart schema makes sense, but integrity of the order, we - * don't want to just make another cart item - * @todo: Partial order processing, shopId processing - * @todo: Review Security on this method + * @name cart/copyCartToOrder + * @method + * @memberof Methods/Cart + * @summary Transform Cart to Order when a payment is processed. + * We want to copy the cart over to an order object, and give the user a new empty + * cart. Reusing the cart schema makes sense, but integrity of the order, + * we don't want to just make another cart item + * @todo Partial order processing, shopId processing + * @todo Review Security on this method * @param {String} cartId - cartId to transform to order * @return {String} returns orderId */ diff --git a/server/methods/core/groups.js b/server/methods/core/groups.js index 07adb61f92d..5f655e05cba 100644 --- a/server/methods/core/groups.js +++ b/server/methods/core/groups.js @@ -7,24 +7,24 @@ import { Accounts, Groups } from "/lib/collections"; import { getSlug } from "/lib/api"; /** - * @file Reaction permission group methods - * - * - * @namespace Meteor/Group + * @file Methods for creating and managing admin user permission groups. + * Run these methods using `Meteor.call()`. + * @example Meteor.call("group/createGroup", sampleCustomerGroup, shop._id) + * @namespace Methods/Group */ Meteor.methods({ /** * @name group/createGroup * @method - * @memberof Meteor/Group - * @summary creates a new permission group for a shop + * @memberof Methods/Group + * @summary Creates a new permission group for a shop * It creates permission group for a given shop with passed in roles * @param {Object} groupData - info about group to create * @param {String} groupData.name - name of the group to be created * @param {String} groupData.description - Optional description of the group to be created * @param {Array} groupData.permissions - permissions to assign to the group being created * @param {String} shopId - id of the shop the group belongs to - * @return {Object} - object.status of 200 on success or Error object on failure + * @return {Object} - `object.status` of 200 on success or Error object on failure */ "group/createGroup": function (groupData, shopId) { check(groupData, Object); @@ -70,16 +70,16 @@ Meteor.methods({ /** * @name group/updateGroup * @method - * @memberof Meteor/Group - * @summary updates a permission group for a shop - * @description changes the details of a group (name, desc, permissions etc) to the values passed in. + * @memberof Methods/Group + * @summary Updates a permission group for a shop. + * Change the details of a group (name, desc, permissions etc) to the values passed in. * It also goes into affected user data to modify both the groupName (using Accounts schema) * and group permissions (using "accounts/removeUserPermissions") * @param {Object} groupId - group to be updated * @param {Object} newGroupData - updated group info (similar to current group data) * slug remains untouched; used as key in querying * @param {String} shopId - id of the shop the group belongs to - * @return {Object} - object.status of 200 on success or Error object on failure + * @return {Object} - `object.status` of 200 on success or Error object on failure */ "group/updateGroup": function (groupId, newGroupData, shopId) { check(groupId, String); @@ -124,13 +124,13 @@ Meteor.methods({ /** * @name group/addUser * @method - * @memberof Meteor/Group - * @summary adds a user to a permission group - * @description It updates the user's list of permissions/roles with the defined the list defined for the group + * @memberof Methods/Group + * @summary Adds a user to a permission group + * Updates the user's list of permissions/roles with the defined the list defined for the group * (NB: At this time, a user only belongs to only one group per shop) * @param {String} userId - current data of the group to be updated * @param {String} groupId - id of the group - * @return {Object} - object.status of 200 on success or Error object on failure + * @return {Object} - `object.status` of 200 on success or Error object on failure */ "group/addUser": function (userId, groupId) { check(userId, String); @@ -197,13 +197,13 @@ Meteor.methods({ /** * @name group/removeUser * @method - * @memberof Meteor/Group - * @summary removes a user from a group for a shop, and adds them to the default customer group. - * @description It updates the user's permission list to reflect. + * @memberof Methods/Group + * @summary Removes a user from a group for a shop, and adds them to the default customer group. + * Updates the user's permission list to reflect. * (NB: At this time, a user only belongs to only one group per shop) * @param {String} userId - current data of the group to be updated * @param {String} groupId - name of the group - * @return {Object} - object.status of 200 on success or Error object on failure + * @return {Object} - `object.status` of 200 on success or Error object on failure */ "group/removeUser": function (userId, groupId) { check(userId, String); @@ -237,7 +237,7 @@ Meteor.methods({ /** * changeMarketplaceOwner * @private - * @summary checks if the user making the request is allowed to make invitation to that group + * @summary Checks if the user making the request is allowed to make invitation to that group * @param {Object} options - * @param {String} options.userId - userID * @param {String} options.permissions - permissions @@ -253,7 +253,7 @@ function changeMarketplaceOwner({ userId, permissions }) { /** * setUserPermissions * @private - * @summary set user permissions + * @summary Set user permissions * @param {Object} users - * @param {String} permissions - * @param {String} shopId - diff --git a/server/methods/core/shop.js b/server/methods/core/shop.js index 1bd99d675d7..3bdb04be0ff 100644 --- a/server/methods/core/shop.js +++ b/server/methods/core/shop.js @@ -14,13 +14,13 @@ import * as Schemas from "/lib/collections/schemas"; * @file Meteor methods for Shop * * - * @namespace Meteor/Shop + * @namespace Methods/Shop */ Meteor.methods({ /** - * @name createShop + * @name shop/createShop * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @param {String} shopAdminUserId - optionally create shop for provided userId * @param {Object} shopData - optionally provide shop object to customize * @return {String} return shopId @@ -153,9 +153,9 @@ Meteor.methods({ }, /** - * @name getLocale + * @name shop/getLocale * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary determine user's countryCode and return locale object * determine local currency and conversion rate from shop currency * @return {Object} returns user location and locale @@ -259,9 +259,9 @@ Meteor.methods({ }, /** - * @name getCurrencyRates + * @name shop/getCurrencyRates * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary It returns the current exchange rate against the shop currency * usage: Meteor.call("shop/getCurrencyRates","USD") * @param {String} currency code @@ -283,9 +283,9 @@ Meteor.methods({ }, /** - * @name fetchCurrencyRate + * @name shop/fetchCurrencyRate * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary fetch the latest currency rates from * https://openexchangerates.org * usage: Meteor.call("shop/fetchCurrencyRate") @@ -372,9 +372,9 @@ Meteor.methods({ }, /** - * @name flushCurrencyRate + * @name shop/flushCurrencyRate * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @description Method calls by cron job * @summary It removes exchange rates that are too old * usage: Meteor.call("shop/flushCurrencyRate") @@ -425,9 +425,9 @@ Meteor.methods({ }, /** - * @name updateShopExternalServices + * @name shop/updateShopExternalServices * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @description On submit OpenExchangeRatesForm handler * @summary we need to rerun fetch exchange rates job on every form submit, * that's why we update autoform type to "method-update" @@ -473,9 +473,9 @@ Meteor.methods({ }, /** - * @name locateAddress + * @name shop/locateAddress * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary determine user's full location for autopopulating addresses * @param {Number} latitude - latitude * @param {Number} longitude - longitude @@ -505,9 +505,9 @@ Meteor.methods({ }, /** - * @name createTag + * @name shop/createTag * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary creates new tag * @param {String} tagName - new tag name * @param {Boolean} isTopLevel - if true -- new tag will be created on top of @@ -537,9 +537,9 @@ Meteor.methods({ }, /** - * @name updateHeaderTags + * @name shop/updateHeaderTags * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary method to insert or update tag with hierarchy * @param {String} tagName will insert, tagName + tagId will update existing * @param {String} tagId - tagId to update @@ -625,9 +625,9 @@ Meteor.methods({ }, /** - * @name removeHeaderTag + * @name shop/removeHeaderTag * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @param {String} tagId - method to remove tag navigation tags * @param {String} currentTagId - currentTagId * @return {String} returns remove result @@ -667,9 +667,9 @@ Meteor.methods({ }, /** - * @name hideHeaderTag + * @name shop/hideHeaderTag * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @param {String} tagId - method to remove tag navigation tags * @return {String} returns remove result */ @@ -691,9 +691,9 @@ Meteor.methods({ }, /** - * @name getWorkflow + * @name shop/getWorkflow * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary gets the current shop workflows * @param {String} name - workflow name * @return {Array} returns workflow array @@ -716,9 +716,9 @@ Meteor.methods({ }, /** - * @name updateLanguageConfiguration + * @name shop/updateLanguageConfiguration * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary enable / disable a language * @param {String} language - language name | "all" to bulk enable / disable * @param {Boolean} enabled - true / false @@ -779,9 +779,9 @@ Meteor.methods({ }, /** - * @name updateCurrencyConfiguration + * @name shop/updateCurrencyConfiguration * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary enable / disable a currency * @param {String} currency - currency name | "all" to bulk enable / disable * @param {Boolean} enabled - true / false @@ -839,9 +839,9 @@ Meteor.methods({ }, /** - * @name updateBrandAsset + * @name shop/updateBrandAsset * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @param {Object} asset - brand asset {mediaId: "", type, ""} * @return {Int} returns update result */ @@ -891,9 +891,9 @@ Meteor.methods({ }, /** - * @name togglePackage + * @name shop/togglePackage * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary enable/disable Reaction package * @param {String} packageId - package _id * @param {Boolean} enabled - current package `enabled` state @@ -914,9 +914,9 @@ Meteor.methods({ }, /** - * @name changeLayout + * @name shop/changeLayout * @method - * @memberof Meteor/Shop + * @memberof Methods/Shop * @summary Change the layout for all workflows so you can use a custom one * @param {String} shopId - the shop's ID * @param {String} newLayout - new layout to use diff --git a/server/methods/core/workflows/orders.js b/server/methods/core/workflows/orders.js index ba3c85d3086..08d4b18309c 100644 --- a/server/methods/core/workflows/orders.js +++ b/server/methods/core/workflows/orders.js @@ -7,7 +7,7 @@ Meteor.methods({ /** * @name coreOrderWorkflow/coreOrderProcessing * @method - * @memberof Meteor/Workflow + * @memberof Methods/Workflow * @summary Checks permissions for a given user to allow them to move an order into the processing phase. * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. * @param {Object} options An object containing arbitary data @@ -25,7 +25,7 @@ Meteor.methods({ /** * @name coreOrderWorkflow/coreOrderCompleted * @method - * @memberof Meteor/Workflow + * @memberof Methods/Workflow * @summary Performs various checks to determine if an order may be moved into the completed phase. * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. * @param {Object} options An object containing arbitary data diff --git a/server/methods/email.js b/server/methods/email.js index d247fcf57a2..33d56ea9962 100644 --- a/server/methods/email.js +++ b/server/methods/email.js @@ -5,17 +5,18 @@ import { Jobs, Packages } from "/lib/collections"; import { Logger, Reaction } from "/server/api"; /** - * @file Meteor methods for Email + * @file Methods for sending emails, retrying failed emails and verifying email configuration. + * Run these methods using `Meteor.call()` * - * - * @namespace Meteor/Email + * @example Meteor.call("emails/retryFailed", email._id, (err) + * @namespace Methods/Email */ Meteor.methods({ /** - * @name verifySettings + * @name email/verifySettings * @method * @summary Verify the current email configuration - * @memberof Meteor/Email + * @memberof Methods/Email * @param {Object} settings - optional settings object (otherwise uses settings in database) * @return {Boolean} - returns true if SMTP connection succeeds */ @@ -67,10 +68,10 @@ Meteor.methods({ }, /** - * @name saveSettings + * @name email/saveSettings * @method * @summary Save new email configuration - * @memberof Meteor/Email + * @memberof Methods/Email * @param {Object} settings - mail provider settings * @return {Boolean} - returns true if update succeeds */ @@ -102,10 +103,10 @@ Meteor.methods({ }, /** - * @name retryFailed + * @name email/retryFailed * @method * @summary Retry a failed or cancelled email job - * @memberof Meteor/Email + * @memberof Methods/Email * @param {String} jobId - a sendEmail job ID * @return {Boolean} - returns true if job is successfully restarted */ diff --git a/server/methods/helpers.js b/server/methods/helpers.js index 7bc06576d59..890904e2c6a 100644 --- a/server/methods/helpers.js +++ b/server/methods/helpers.js @@ -4,13 +4,13 @@ import { Meteor } from "meteor/meteor"; * @file Meteor methods for Reaction * * - * @namespace Meteor/Reaction + * @namespace Methods/Reaction */ Meteor.methods({ /** - * @name getUserId + * @name reaction/getUserId * @method - * @memberof Meteor/Reaction + * @memberof Methods/Reaction * @summary return server side userId if available * @return {String} userId - if available */ From b41eaf5b0640ac6d7c9d3b909cabaa9807d80afe Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 08:13:53 -0700 Subject: [PATCH 53/59] jsdoc: use component namespace instead of module --- .../plugins/core/components/lib/components.js | 48 +++++++++++++------ .../core/components/lib/composer/compose.js | 4 +- .../core/components/lib/composer/tracker.js | 14 ++++-- imports/plugins/core/components/lib/hoc.js | 29 +++++++---- 4 files changed, 66 insertions(+), 29 deletions(-) diff --git a/imports/plugins/core/components/lib/components.js b/imports/plugins/core/components/lib/components.js index 19d26f8a776..956ad508646 100644 --- a/imports/plugins/core/components/lib/components.js +++ b/imports/plugins/core/components/lib/components.js @@ -1,9 +1,7 @@ import { compose, setDisplayName } from "recompose"; /** - * @file Reaction Components API - * - * @module components + * @namespace components */ export const Components = {}; // populated with final wrapped components @@ -11,17 +9,17 @@ export const ComponentsTable = {}; // storage for separate elements of each comp /** - * Register a component and container(s) with a name. - * The raw component can then be extended or replaced. + * @example // Register a component and container(s) with a name. + * // The raw component can then be extended or replaced. * - * Structure of a component in the list: + * // Structure of a component in the list: * * ComponentsTable.MyComponent = { * name: 'MyComponent', * hocs: [fn1, fn2], * rawComponent: React.Component * } - * + * @memberof components * @param {String} name The name of the component to register. * @param {React.Component} rawComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to wrap around the raw component. @@ -43,11 +41,13 @@ export function registerComponent(name, rawComponent, hocs = []) { /** - * Register containers (HOC) with a name. + * @name registerHOC + * @method + * @summary Register containers (HOC) with a name. * If some containers already exist for the component, they will be extended. * @param {String} name The name of the component to register. * @param {Function|Array} hocs The HOCs to wrap around the raw component. - * + * @memberof components * @returns {undefined} */ export function registerHOC(name, hocs = []) { @@ -81,9 +81,12 @@ export function registerHOC(name, hocs = []) { /** - * Get a component registered with registerComponent(name, component, ...hocs). + * @name getComponent + * @method + * @summary Get a component registered with registerComponent(name, component, ...hocs). * @param {String} name The name of the component to get. * @return {Function|React.Component} A (wrapped) React component + * @memberof components */ export function getComponent(name) { const component = ComponentsTable[name]; @@ -99,12 +102,15 @@ export function getComponent(name) { /** - * Replace a Reaction component with a new component and optionally add one or more higher order components. + * @name replaceComponent + * @method + * @summary Replace a Reaction component with a new component and optionally add one or more higher order components. * This function keeps track of the previous HOCs and wraps the new HOCs around previous ones * @param {String} name The name of the component to register. * @param {React.Component} newComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to compose with the raw component. * @returns {Function|React.Component} A component callable with Components[name] + * @memberof components */ export function replaceComponent(name, newComponent, hocs = []) { const previousComponent = ComponentsTable[name]; @@ -120,26 +126,35 @@ export function replaceComponent(name, newComponent, hocs = []) { /** - * Get the raw UI component without any possible HOCs wrapping it. + * @name getRawComponent + * @method + * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} A React component + * @memberof components */ export const getRawComponent = (name) => ComponentsTable[name].rawComponent; /** - * Get the raw UI component without any possible HOCs wrapping it. + * @name getHOCs + * @method + * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} Array of HOCs + * @memberof components */ export const getHOCs = (name) => ComponentsTable[name].hocs; /** - * Wrap a new component with the HOCs from a different component + * @name copyHOCs + * @method + * @summary Wrap a new component with the HOCs from a different component * @param {String} sourceComponentName The name of the component to get the HOCs from * @param {Function|React.Component} targetComponent Component to wrap * @returns {Function|React.Component} A new component wrapped with the HOCs of the source component + * @memberof components */ export function copyHOCs(sourceComponentName, targetComponent) { const sourceComponent = ComponentsTable[sourceComponentName]; @@ -148,9 +163,12 @@ export function copyHOCs(sourceComponentName, targetComponent) { /** - * Populate the final Components object with the contents of the lookup table. + * @name loadRegisteredComponents + * @method + * @summary Populate the final Components object with the contents of the lookup table. * This should only be called once on app startup. * @returns {Object} An object containing all of the registered components + * @memberof components **/ export function loadRegisteredComponents() { Object.keys(ComponentsTable).map((name) => { diff --git a/imports/plugins/core/components/lib/composer/compose.js b/imports/plugins/core/components/lib/composer/compose.js index 634ce624b1d..5c1b4fc0117 100644 --- a/imports/plugins/core/components/lib/composer/compose.js +++ b/imports/plugins/core/components/lib/composer/compose.js @@ -5,9 +5,7 @@ import _ from "lodash"; import { getDisplayName } from "recompose"; /** - * @file Reaction Components API - * - * @module components + * @namespace components */ export default function compose(dataLoader, options = {}) { diff --git a/imports/plugins/core/components/lib/composer/tracker.js b/imports/plugins/core/components/lib/composer/tracker.js index 5df3b16da65..d7aa24767f2 100644 --- a/imports/plugins/core/components/lib/composer/tracker.js +++ b/imports/plugins/core/components/lib/composer/tracker.js @@ -5,14 +5,19 @@ import compose from "./compose"; /** * @file **Reaction Components API** - Most of the React components in the Reaction UI can be replaced or extended with the API outlined here. This allows anyone to create a custom plugin that can easily change the look of the UI and/or extend its functionality without having to edit core Reaction code. See {@link https://docs.reactioncommerce.com/reaction-docs/master/components-api full tutorial and documentation}. - * @module components + * + * + * @namespace components */ /** - * getTrackerLoader creates a Meteor Tracker to watch dep updates from + * @name getTrackerLoader + * @summary getTrackerLoader creates a Meteor Tracker to watch dep updates from * the passed in reactiveMapper function * @param {Function} reactiveMapper data fetching function to bind to a tracker * @return {Function} composed function + * @memberof components + * @private */ function getTrackerLoader(reactiveMapper) { return (props, onData, env) => { @@ -33,10 +38,13 @@ function getTrackerLoader(reactiveMapper) { /** - * A higher order component to wrap a reactive function with Meteor's Tracker + * @name composeWithTracker + * @method + * @summary A higher order component to wrap a reactive function with Meteor's Tracker * @param {Function} reactiveMapper data fetching function to bind to a tracker * @param {React.Component|Boolean|Object} options can be a custom loader, false (to disable), or a full options object * @return {Function} composed function + * @memberof components */ export function composeWithTracker(reactiveMapper, options) { let composeOptions = {}; diff --git a/imports/plugins/core/components/lib/hoc.js b/imports/plugins/core/components/lib/hoc.js index 7d8a5728835..b5a496a212b 100644 --- a/imports/plugins/core/components/lib/hoc.js +++ b/imports/plugins/core/components/lib/hoc.js @@ -5,9 +5,7 @@ import { Accounts, Groups } from "/lib/collections"; import { composeWithTracker } from "./composer"; /** - * @file Reaction Components API - * - * @module components + * @namespace components */ let Reaction; @@ -20,9 +18,12 @@ if (Meteor.isClient) { /** - * A wrapper to reactively inject the current user into a component + * @name withCurrentUser + * @method + * @summary A wrapper to reactively inject the current user into a component * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentUser" prop + * @memberof components */ export function withCurrentUser(component) { return composeWithTracker((props, onData) => { @@ -32,10 +33,13 @@ export function withCurrentUser(component) { /** - * A wrapper to reactively inject the current account into a component. + * @name withCurrentAccount + * @method + * @summary A wrapper to reactively inject the current account into a component. * This assumes you have signed up and are not an anonymous user. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentAccount" prop + * @memberof components */ export function withCurrentAccount(component) { return composeWithTracker((props, onData) => { @@ -64,10 +68,13 @@ export function withCurrentAccount(component) { /** - * A wrapper to reactively inject the current user's admin status. + * @name withIsAdmin + * @method + * @summary A wrapper to reactively inject the current user's admin status. * Sets a boolean 'isAdmin' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isAdmin" prop + * @memberof components */ export function withIsAdmin(component) { return composeWithTracker((props, onData) => { @@ -76,11 +83,14 @@ export function withIsAdmin(component) { } /** - * A wrapper to reactively inject a user's permission based on group or roles + * @name withPermissions + * @method + * @summary A wrapper to reactively inject a user's permission based on group or roles * Group access is given to users at that group level and above * @param {Array|String} roles String or array of strings of permissions to check. default: roles=["guest", "anonymous"] * @param {String} group Slug title of a group to check against. Group option supercedes roles option. default: group="customer". * @return {Function} the new wrapped component with a "hasPermissions" prop + * @memberof components */ export function withPermissions({ roles = ["guest", "anonymous"], group }) { return composeWithTracker((props, onData) => { @@ -110,10 +120,13 @@ export function withPermissions({ roles = ["guest", "anonymous"], group }) { /** - * A wrapper to reactively inject the current user's owner status. + * @name withIsOwner + * @method + * @summary A wrapper to reactively inject the current user's owner status. * Sets a boolean 'isOwner' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isOwner" prop + * @memberof components */ export function withIsOwner(component) { return composeWithTracker((props, onData) => { From 8d3fb718e69ca90b7f71c031a7a9720ef2c90b82 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 08:22:03 -0700 Subject: [PATCH 54/59] jsdoc: use @namespace for components instead. add example at top --- .../plugins/core/components/lib/components.js | 23 ++++++++----------- .../core/components/lib/composer/compose.js | 4 ---- .../core/components/lib/composer/tracker.js | 15 +++++++++--- imports/plugins/core/components/lib/hoc.js | 14 ++++------- 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/imports/plugins/core/components/lib/components.js b/imports/plugins/core/components/lib/components.js index 956ad508646..690a3fee600 100644 --- a/imports/plugins/core/components/lib/components.js +++ b/imports/plugins/core/components/lib/components.js @@ -1,13 +1,8 @@ import { compose, setDisplayName } from "recompose"; -/** - * @namespace components - */ - export const Components = {}; // populated with final wrapped components export const ComponentsTable = {}; // storage for separate elements of each component - /** * @example // Register a component and container(s) with a name. * // The raw component can then be extended or replaced. @@ -19,7 +14,9 @@ export const ComponentsTable = {}; // storage for separate elements of each comp * hocs: [fn1, fn2], * rawComponent: React.Component * } - * @memberof components + * @name registerComponent + * @method + * @memberof Components * @param {String} name The name of the component to register. * @param {React.Component} rawComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to wrap around the raw component. @@ -47,7 +44,7 @@ export function registerComponent(name, rawComponent, hocs = []) { * If some containers already exist for the component, they will be extended. * @param {String} name The name of the component to register. * @param {Function|Array} hocs The HOCs to wrap around the raw component. - * @memberof components + * @memberof Components * @returns {undefined} */ export function registerHOC(name, hocs = []) { @@ -86,7 +83,7 @@ export function registerHOC(name, hocs = []) { * @summary Get a component registered with registerComponent(name, component, ...hocs). * @param {String} name The name of the component to get. * @return {Function|React.Component} A (wrapped) React component - * @memberof components + * @memberof Components */ export function getComponent(name) { const component = ComponentsTable[name]; @@ -110,7 +107,7 @@ export function getComponent(name) { * @param {React.Component} newComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to compose with the raw component. * @returns {Function|React.Component} A component callable with Components[name] - * @memberof components + * @memberof Components */ export function replaceComponent(name, newComponent, hocs = []) { const previousComponent = ComponentsTable[name]; @@ -131,7 +128,7 @@ export function replaceComponent(name, newComponent, hocs = []) { * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} A React component - * @memberof components + * @memberof Components */ export const getRawComponent = (name) => ComponentsTable[name].rawComponent; @@ -142,7 +139,7 @@ export const getRawComponent = (name) => ComponentsTable[name].rawComponent; * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} Array of HOCs - * @memberof components + * @memberof Components */ export const getHOCs = (name) => ComponentsTable[name].hocs; @@ -154,7 +151,7 @@ export const getHOCs = (name) => ComponentsTable[name].hocs; * @param {String} sourceComponentName The name of the component to get the HOCs from * @param {Function|React.Component} targetComponent Component to wrap * @returns {Function|React.Component} A new component wrapped with the HOCs of the source component - * @memberof components + * @memberof Components */ export function copyHOCs(sourceComponentName, targetComponent) { const sourceComponent = ComponentsTable[sourceComponentName]; @@ -168,7 +165,7 @@ export function copyHOCs(sourceComponentName, targetComponent) { * @summary Populate the final Components object with the contents of the lookup table. * This should only be called once on app startup. * @returns {Object} An object containing all of the registered components - * @memberof components + * @memberof Components **/ export function loadRegisteredComponents() { Object.keys(ComponentsTable).map((name) => { diff --git a/imports/plugins/core/components/lib/composer/compose.js b/imports/plugins/core/components/lib/composer/compose.js index 5c1b4fc0117..5a013a7516b 100644 --- a/imports/plugins/core/components/lib/composer/compose.js +++ b/imports/plugins/core/components/lib/composer/compose.js @@ -4,10 +4,6 @@ import hoistStatics from "hoist-non-react-statics"; import _ from "lodash"; import { getDisplayName } from "recompose"; -/** - * @namespace components - */ - export default function compose(dataLoader, options = {}) { return function (Child) { const { diff --git a/imports/plugins/core/components/lib/composer/tracker.js b/imports/plugins/core/components/lib/composer/tracker.js index d7aa24767f2..0bd7c6d750f 100644 --- a/imports/plugins/core/components/lib/composer/tracker.js +++ b/imports/plugins/core/components/lib/composer/tracker.js @@ -6,8 +6,17 @@ import compose from "./compose"; /** * @file **Reaction Components API** - Most of the React components in the Reaction UI can be replaced or extended with the API outlined here. This allows anyone to create a custom plugin that can easily change the look of the UI and/or extend its functionality without having to edit core Reaction code. See {@link https://docs.reactioncommerce.com/reaction-docs/master/components-api full tutorial and documentation}. * + * @example // Register a component and container(s) with a name. + * // The raw component can then be extended or replaced. * - * @namespace components + * // Structure of a component in the list: + * + * ComponentsTable.MyComponent = { + * name: 'MyComponent', + * hocs: [fn1, fn2], + * rawComponent: React.Component + * } + * @namespace Components */ /** @@ -16,7 +25,7 @@ import compose from "./compose"; * the passed in reactiveMapper function * @param {Function} reactiveMapper data fetching function to bind to a tracker * @return {Function} composed function - * @memberof components + * @memberof Components * @private */ function getTrackerLoader(reactiveMapper) { @@ -44,7 +53,7 @@ function getTrackerLoader(reactiveMapper) { * @param {Function} reactiveMapper data fetching function to bind to a tracker * @param {React.Component|Boolean|Object} options can be a custom loader, false (to disable), or a full options object * @return {Function} composed function - * @memberof components + * @memberof Components */ export function composeWithTracker(reactiveMapper, options) { let composeOptions = {}; diff --git a/imports/plugins/core/components/lib/hoc.js b/imports/plugins/core/components/lib/hoc.js index b5a496a212b..3f3a8ff81bf 100644 --- a/imports/plugins/core/components/lib/hoc.js +++ b/imports/plugins/core/components/lib/hoc.js @@ -4,10 +4,6 @@ import { Roles } from "meteor/alanning:roles"; import { Accounts, Groups } from "/lib/collections"; import { composeWithTracker } from "./composer"; -/** - * @namespace components - */ - let Reaction; if (Meteor.isClient) { @@ -23,7 +19,7 @@ if (Meteor.isClient) { * @summary A wrapper to reactively inject the current user into a component * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentUser" prop - * @memberof components + * @memberof Components */ export function withCurrentUser(component) { return composeWithTracker((props, onData) => { @@ -39,7 +35,7 @@ export function withCurrentUser(component) { * This assumes you have signed up and are not an anonymous user. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentAccount" prop - * @memberof components + * @memberof Components */ export function withCurrentAccount(component) { return composeWithTracker((props, onData) => { @@ -74,7 +70,7 @@ export function withCurrentAccount(component) { * Sets a boolean 'isAdmin' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isAdmin" prop - * @memberof components + * @memberof Components */ export function withIsAdmin(component) { return composeWithTracker((props, onData) => { @@ -90,7 +86,7 @@ export function withIsAdmin(component) { * @param {Array|String} roles String or array of strings of permissions to check. default: roles=["guest", "anonymous"] * @param {String} group Slug title of a group to check against. Group option supercedes roles option. default: group="customer". * @return {Function} the new wrapped component with a "hasPermissions" prop - * @memberof components + * @memberof Components */ export function withPermissions({ roles = ["guest", "anonymous"], group }) { return composeWithTracker((props, onData) => { @@ -126,7 +122,7 @@ export function withPermissions({ roles = ["guest", "anonymous"], group }) { * Sets a boolean 'isOwner' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isOwner" prop - * @memberof components + * @memberof Components */ export function withIsOwner(component) { return composeWithTracker((props, onData) => { From d278fb9f07a9af404ea2684adacec01e130fc8e8 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 08:33:51 -0700 Subject: [PATCH 55/59] jsdoc: fix - 2 typos from PR review --- lib/collections/transform/cartOrder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/collections/transform/cartOrder.js b/lib/collections/transform/cartOrder.js index 851f9262479..942350ebafa 100644 --- a/lib/collections/transform/cartOrder.js +++ b/lib/collections/transform/cartOrder.js @@ -49,8 +49,8 @@ function getSummary(items, prop, prop2, shopId) { /** * Reaction transform methods on Collections * @file Use transform methods to return Cart and Order calculated values: count, subTotal, shipping, taxes, total. - * Usethese methods on Cart and Orders in templates, `{{cart.getCount}}` and in code, `Cart.findOne().getTotal()`. - * These use Mongo Collection {@link http://docs.meteor.com/api/collections.html#Mongo-Collection transforms}. + * Use these methods on Cart and Orders in templates, `{{cart.getCount}}` and in code, `Cart.findOne().getTotal()`. + * These use Meteor Collection {@link http://docs.meteor.com/api/collections.html#Mongo-Collection transforms}. * @module cartOrderTransform */ From 52a797c53dbe1d2f71ae8098eb67393d6383e87e Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 09:11:54 -0700 Subject: [PATCH 56/59] jsdoc: document + add registry methods --- server/methods/core/registry.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/server/methods/core/registry.js b/server/methods/core/registry.js index 269a3249bf5..72b024d5492 100644 --- a/server/methods/core/registry.js +++ b/server/methods/core/registry.js @@ -5,14 +5,32 @@ import { Packages } from "/lib/collections"; import { Reaction } from "/server/api"; import { mergeDeep } from "/lib/api"; +/** + * @file Methods for Registry + * + * + * @namespace Methods/Registry +*/ + export const methods = { + /** + * @name registry/update + * @method + * @memberof Methods/Registry + * @example Meteor.call("registry/update", packageId, settingsKey, fields) + * @param {String} packageId id of package + * @param {String} name Name of package + * @param {Array} fields Fields to update + * @todo Name could be optional. Just use package name as default. + * @return {Boolean} true on success, false on error + */ "registry/update": function (packageId, name, fields) { check(packageId, String); check(name, String); check(fields, Array); // settings use just the last name from full name so that schemas don't need to define overly complex names based with // x/x/x formatting. - // TODO name could be optional, just use package name as default + // TODO Name could be optional. Just use package name as default const setting = name.split("/").splice(-1); let dataToSave = {}; dataToSave[setting] = {}; From 4bd89d3652660b27cf14065f03ea6c9e53e7b5ee Mon Sep 17 00:00:00 2001 From: Aaron Judd Date: Tue, 24 Oct 2017 09:26:54 -0700 Subject: [PATCH 57/59] Revert "jsdoc: format Invoice React component into @module" --- .../plugins/core/components/lib/components.js | 53 +++++++------------ .../core/components/lib/composer/compose.js | 6 +++ .../core/components/lib/composer/tracker.js | 23 ++------ imports/plugins/core/components/lib/hoc.js | 31 ++++------- .../core/orders/client/components/invoice.js | 45 +++++----------- 5 files changed, 51 insertions(+), 107 deletions(-) diff --git a/imports/plugins/core/components/lib/components.js b/imports/plugins/core/components/lib/components.js index 690a3fee600..19d26f8a776 100644 --- a/imports/plugins/core/components/lib/components.js +++ b/imports/plugins/core/components/lib/components.js @@ -1,22 +1,27 @@ import { compose, setDisplayName } from "recompose"; +/** + * @file Reaction Components API + * + * @module components + */ + export const Components = {}; // populated with final wrapped components export const ComponentsTable = {}; // storage for separate elements of each component + /** - * @example // Register a component and container(s) with a name. - * // The raw component can then be extended or replaced. + * Register a component and container(s) with a name. + * The raw component can then be extended or replaced. * - * // Structure of a component in the list: + * Structure of a component in the list: * * ComponentsTable.MyComponent = { * name: 'MyComponent', * hocs: [fn1, fn2], * rawComponent: React.Component * } - * @name registerComponent - * @method - * @memberof Components + * * @param {String} name The name of the component to register. * @param {React.Component} rawComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to wrap around the raw component. @@ -38,13 +43,11 @@ export function registerComponent(name, rawComponent, hocs = []) { /** - * @name registerHOC - * @method - * @summary Register containers (HOC) with a name. + * Register containers (HOC) with a name. * If some containers already exist for the component, they will be extended. * @param {String} name The name of the component to register. * @param {Function|Array} hocs The HOCs to wrap around the raw component. - * @memberof Components + * * @returns {undefined} */ export function registerHOC(name, hocs = []) { @@ -78,12 +81,9 @@ export function registerHOC(name, hocs = []) { /** - * @name getComponent - * @method - * @summary Get a component registered with registerComponent(name, component, ...hocs). + * Get a component registered with registerComponent(name, component, ...hocs). * @param {String} name The name of the component to get. * @return {Function|React.Component} A (wrapped) React component - * @memberof Components */ export function getComponent(name) { const component = ComponentsTable[name]; @@ -99,15 +99,12 @@ export function getComponent(name) { /** - * @name replaceComponent - * @method - * @summary Replace a Reaction component with a new component and optionally add one or more higher order components. + * Replace a Reaction component with a new component and optionally add one or more higher order components. * This function keeps track of the previous HOCs and wraps the new HOCs around previous ones * @param {String} name The name of the component to register. * @param {React.Component} newComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to compose with the raw component. * @returns {Function|React.Component} A component callable with Components[name] - * @memberof Components */ export function replaceComponent(name, newComponent, hocs = []) { const previousComponent = ComponentsTable[name]; @@ -123,35 +120,26 @@ export function replaceComponent(name, newComponent, hocs = []) { /** - * @name getRawComponent - * @method - * @summary Get the raw UI component without any possible HOCs wrapping it. + * Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} A React component - * @memberof Components */ export const getRawComponent = (name) => ComponentsTable[name].rawComponent; /** - * @name getHOCs - * @method - * @summary Get the raw UI component without any possible HOCs wrapping it. + * Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} Array of HOCs - * @memberof Components */ export const getHOCs = (name) => ComponentsTable[name].hocs; /** - * @name copyHOCs - * @method - * @summary Wrap a new component with the HOCs from a different component + * Wrap a new component with the HOCs from a different component * @param {String} sourceComponentName The name of the component to get the HOCs from * @param {Function|React.Component} targetComponent Component to wrap * @returns {Function|React.Component} A new component wrapped with the HOCs of the source component - * @memberof Components */ export function copyHOCs(sourceComponentName, targetComponent) { const sourceComponent = ComponentsTable[sourceComponentName]; @@ -160,12 +148,9 @@ export function copyHOCs(sourceComponentName, targetComponent) { /** - * @name loadRegisteredComponents - * @method - * @summary Populate the final Components object with the contents of the lookup table. + * Populate the final Components object with the contents of the lookup table. * This should only be called once on app startup. * @returns {Object} An object containing all of the registered components - * @memberof Components **/ export function loadRegisteredComponents() { Object.keys(ComponentsTable).map((name) => { diff --git a/imports/plugins/core/components/lib/composer/compose.js b/imports/plugins/core/components/lib/composer/compose.js index 5a013a7516b..634ce624b1d 100644 --- a/imports/plugins/core/components/lib/composer/compose.js +++ b/imports/plugins/core/components/lib/composer/compose.js @@ -4,6 +4,12 @@ import hoistStatics from "hoist-non-react-statics"; import _ from "lodash"; import { getDisplayName } from "recompose"; +/** + * @file Reaction Components API + * + * @module components + */ + export default function compose(dataLoader, options = {}) { return function (Child) { const { diff --git a/imports/plugins/core/components/lib/composer/tracker.js b/imports/plugins/core/components/lib/composer/tracker.js index 0bd7c6d750f..5df3b16da65 100644 --- a/imports/plugins/core/components/lib/composer/tracker.js +++ b/imports/plugins/core/components/lib/composer/tracker.js @@ -5,28 +5,14 @@ import compose from "./compose"; /** * @file **Reaction Components API** - Most of the React components in the Reaction UI can be replaced or extended with the API outlined here. This allows anyone to create a custom plugin that can easily change the look of the UI and/or extend its functionality without having to edit core Reaction code. See {@link https://docs.reactioncommerce.com/reaction-docs/master/components-api full tutorial and documentation}. - * - * @example // Register a component and container(s) with a name. - * // The raw component can then be extended or replaced. - * - * // Structure of a component in the list: - * - * ComponentsTable.MyComponent = { - * name: 'MyComponent', - * hocs: [fn1, fn2], - * rawComponent: React.Component - * } - * @namespace Components + * @module components */ /** - * @name getTrackerLoader - * @summary getTrackerLoader creates a Meteor Tracker to watch dep updates from + * getTrackerLoader creates a Meteor Tracker to watch dep updates from * the passed in reactiveMapper function * @param {Function} reactiveMapper data fetching function to bind to a tracker * @return {Function} composed function - * @memberof Components - * @private */ function getTrackerLoader(reactiveMapper) { return (props, onData, env) => { @@ -47,13 +33,10 @@ function getTrackerLoader(reactiveMapper) { /** - * @name composeWithTracker - * @method - * @summary A higher order component to wrap a reactive function with Meteor's Tracker + * A higher order component to wrap a reactive function with Meteor's Tracker * @param {Function} reactiveMapper data fetching function to bind to a tracker * @param {React.Component|Boolean|Object} options can be a custom loader, false (to disable), or a full options object * @return {Function} composed function - * @memberof Components */ export function composeWithTracker(reactiveMapper, options) { let composeOptions = {}; diff --git a/imports/plugins/core/components/lib/hoc.js b/imports/plugins/core/components/lib/hoc.js index 3f3a8ff81bf..7d8a5728835 100644 --- a/imports/plugins/core/components/lib/hoc.js +++ b/imports/plugins/core/components/lib/hoc.js @@ -4,6 +4,12 @@ import { Roles } from "meteor/alanning:roles"; import { Accounts, Groups } from "/lib/collections"; import { composeWithTracker } from "./composer"; +/** + * @file Reaction Components API + * + * @module components + */ + let Reaction; if (Meteor.isClient) { @@ -14,12 +20,9 @@ if (Meteor.isClient) { /** - * @name withCurrentUser - * @method - * @summary A wrapper to reactively inject the current user into a component + * A wrapper to reactively inject the current user into a component * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentUser" prop - * @memberof Components */ export function withCurrentUser(component) { return composeWithTracker((props, onData) => { @@ -29,13 +32,10 @@ export function withCurrentUser(component) { /** - * @name withCurrentAccount - * @method - * @summary A wrapper to reactively inject the current account into a component. + * A wrapper to reactively inject the current account into a component. * This assumes you have signed up and are not an anonymous user. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentAccount" prop - * @memberof Components */ export function withCurrentAccount(component) { return composeWithTracker((props, onData) => { @@ -64,13 +64,10 @@ export function withCurrentAccount(component) { /** - * @name withIsAdmin - * @method - * @summary A wrapper to reactively inject the current user's admin status. + * A wrapper to reactively inject the current user's admin status. * Sets a boolean 'isAdmin' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isAdmin" prop - * @memberof Components */ export function withIsAdmin(component) { return composeWithTracker((props, onData) => { @@ -79,14 +76,11 @@ export function withIsAdmin(component) { } /** - * @name withPermissions - * @method - * @summary A wrapper to reactively inject a user's permission based on group or roles + * A wrapper to reactively inject a user's permission based on group or roles * Group access is given to users at that group level and above * @param {Array|String} roles String or array of strings of permissions to check. default: roles=["guest", "anonymous"] * @param {String} group Slug title of a group to check against. Group option supercedes roles option. default: group="customer". * @return {Function} the new wrapped component with a "hasPermissions" prop - * @memberof Components */ export function withPermissions({ roles = ["guest", "anonymous"], group }) { return composeWithTracker((props, onData) => { @@ -116,13 +110,10 @@ export function withPermissions({ roles = ["guest", "anonymous"], group }) { /** - * @name withIsOwner - * @method - * @summary A wrapper to reactively inject the current user's owner status. + * A wrapper to reactively inject the current user's owner status. * Sets a boolean 'isOwner' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isOwner" prop - * @memberof Components */ export function withIsOwner(component) { return composeWithTracker((props, onData) => { diff --git a/imports/plugins/core/orders/client/components/invoice.js b/imports/plugins/core/orders/client/components/invoice.js index 8e55f854e3b..5136e0e042b 100644 --- a/imports/plugins/core/orders/client/components/invoice.js +++ b/imports/plugins/core/orders/client/components/invoice.js @@ -7,26 +7,19 @@ import LineItems from "./lineItems"; import InvoiceActions from "./invoiceActions"; /** - * @file Invoice is a React Component for displaying the `invoice` section on the orders sideview - * @module Invoice - * @extends Components - */ - + * @summary React component for displaying the `invoice` section on the orders sideview + * @param {Object} props - React PropTypes + * @property {Object} invoice - An object representing an invoice + * @property {Object} order - An object representing an order + * @property {Bool} discounts - A boolean indicating whether discounts are enabled + * @property {Array} refunds - An array/list of refunds + * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured + * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment + * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds + * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded + * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview + */ class Invoice extends Component { - /** - * @name Invoice propTypes - * @type {propTypes} - * @param {Object} props - React PropTypes - * @property {Object} invoice - An object representing an invoice - * @property {Object} order - An object representing an order - * @property {Bool} discounts - A boolean indicating whether discounts are enabled - * @property {Array} refunds - An array/list of refunds - * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured - * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment - * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds - * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded - * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview - */ static propTypes = { canMakeAdjustments: PropTypes.bool, discounts: PropTypes.bool, @@ -43,8 +36,6 @@ class Invoice extends Component { } /** - * @name formatDate() - * @method * @summary Formats dates * @param {Number} context - the date to be formatted * @param {String} block - the preferred format @@ -56,8 +47,6 @@ class Invoice extends Component { } /** - * @name handleClick() - * @method * @summary Handle clicking the add discount link * @param {Event} event - the event that fired * @returns {null} null @@ -70,8 +59,6 @@ class Invoice extends Component { } /** - * @name renderDiscountForm() - * @method * @summary Displays the discount form * @returns {null} null */ @@ -94,8 +81,6 @@ class Invoice extends Component { } /** - * @name renderRefundsInfo() - * @method * @summary Displays the refund information after the order payment breakdown on the invoice * @returns {null} null */ @@ -123,8 +108,6 @@ class Invoice extends Component { } /** - * @name renderTotal() - * @method * @summary Displays the total payment form * @returns {null} null */ @@ -141,8 +124,6 @@ class Invoice extends Component { } /** - * @name renderConditionalDisplay() - * @method * @summary Displays either refunds info or the total payment form * @returns {null} null */ @@ -167,8 +148,6 @@ class Invoice extends Component { } /** - * @name renderInvoice() - * @method * @summary Displays the invoice form with broken down payment info * @returns {null} null */ From db5109f956aed83e552b799ca5576d8f2c80480c Mon Sep 17 00:00:00 2001 From: Seun Martins Date: Tue, 24 Oct 2017 09:33:44 -0700 Subject: [PATCH 58/59] Add jsdoc on new function --- server/api/core/groups.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/api/core/groups.js b/server/api/core/groups.js index ef5d38669a7..12e4cd26b0a 100644 --- a/server/api/core/groups.js +++ b/server/api/core/groups.js @@ -3,6 +3,16 @@ import { Roles } from "meteor/alanning:roles"; import { Logger, Reaction } from "/server/api"; import { Shops, Groups } from "/lib/collections"; +/** + * @method createGroups + * @summary creates groups for shops + * @param {object} options - + * @param {string} options.shopId - the id of shop to create the group for. Not passing a shopId creates + * the group(s) for all available shops + * @param {object} options.roles - key-value pair representing the group slug (key) and + * array of roles for the group (value) + * @return {null} + */ export function createGroups(options = {}) { const { shopId } = options; let { roles } = options; @@ -40,6 +50,12 @@ export function createGroups(options = {}) { } } +/** + * @method getDefaultGroupRoles + * @private + * @summary Generates default groups + * @return {object} roles - object key-value pair containing the default groups and roles for the groups + */ function getDefaultGroupRoles() { /* Get all defined roles from the DB except "anonymous" because that gets removed from a user on register * if it's not removed, it causes mismatch between roles in user (i.e Meteor.user().roles[shopId]) vs that in From 8a04113f7c60eabb161573ae12c1331667f83ec0 Mon Sep 17 00:00:00 2001 From: Machiko Yasuda Date: Tue, 24 Oct 2017 11:22:27 -0700 Subject: [PATCH 59/59] jsdoc: format Invoice component and use @namespace for Components instead --- .../plugins/core/components/lib/components.js | 53 ++++++++++++------- .../core/components/lib/composer/compose.js | 6 --- .../core/components/lib/composer/tracker.js | 23 ++++++-- imports/plugins/core/components/lib/hoc.js | 31 +++++++---- .../core/orders/client/components/invoice.js | 45 +++++++++++----- 5 files changed, 107 insertions(+), 51 deletions(-) diff --git a/imports/plugins/core/components/lib/components.js b/imports/plugins/core/components/lib/components.js index 19d26f8a776..690a3fee600 100644 --- a/imports/plugins/core/components/lib/components.js +++ b/imports/plugins/core/components/lib/components.js @@ -1,27 +1,22 @@ import { compose, setDisplayName } from "recompose"; -/** - * @file Reaction Components API - * - * @module components - */ - export const Components = {}; // populated with final wrapped components export const ComponentsTable = {}; // storage for separate elements of each component - /** - * Register a component and container(s) with a name. - * The raw component can then be extended or replaced. + * @example // Register a component and container(s) with a name. + * // The raw component can then be extended or replaced. * - * Structure of a component in the list: + * // Structure of a component in the list: * * ComponentsTable.MyComponent = { * name: 'MyComponent', * hocs: [fn1, fn2], * rawComponent: React.Component * } - * + * @name registerComponent + * @method + * @memberof Components * @param {String} name The name of the component to register. * @param {React.Component} rawComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to wrap around the raw component. @@ -43,11 +38,13 @@ export function registerComponent(name, rawComponent, hocs = []) { /** - * Register containers (HOC) with a name. + * @name registerHOC + * @method + * @summary Register containers (HOC) with a name. * If some containers already exist for the component, they will be extended. * @param {String} name The name of the component to register. * @param {Function|Array} hocs The HOCs to wrap around the raw component. - * + * @memberof Components * @returns {undefined} */ export function registerHOC(name, hocs = []) { @@ -81,9 +78,12 @@ export function registerHOC(name, hocs = []) { /** - * Get a component registered with registerComponent(name, component, ...hocs). + * @name getComponent + * @method + * @summary Get a component registered with registerComponent(name, component, ...hocs). * @param {String} name The name of the component to get. * @return {Function|React.Component} A (wrapped) React component + * @memberof Components */ export function getComponent(name) { const component = ComponentsTable[name]; @@ -99,12 +99,15 @@ export function getComponent(name) { /** - * Replace a Reaction component with a new component and optionally add one or more higher order components. + * @name replaceComponent + * @method + * @summary Replace a Reaction component with a new component and optionally add one or more higher order components. * This function keeps track of the previous HOCs and wraps the new HOCs around previous ones * @param {String} name The name of the component to register. * @param {React.Component} newComponent Interchangeable/extendable component. * @param {Function|Array} hocs The HOCs to compose with the raw component. * @returns {Function|React.Component} A component callable with Components[name] + * @memberof Components */ export function replaceComponent(name, newComponent, hocs = []) { const previousComponent = ComponentsTable[name]; @@ -120,26 +123,35 @@ export function replaceComponent(name, newComponent, hocs = []) { /** - * Get the raw UI component without any possible HOCs wrapping it. + * @name getRawComponent + * @method + * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} A React component + * @memberof Components */ export const getRawComponent = (name) => ComponentsTable[name].rawComponent; /** - * Get the raw UI component without any possible HOCs wrapping it. + * @name getHOCs + * @method + * @summary Get the raw UI component without any possible HOCs wrapping it. * @param {String} name The name of the component to get. * @returns {Function|React.Component} Array of HOCs + * @memberof Components */ export const getHOCs = (name) => ComponentsTable[name].hocs; /** - * Wrap a new component with the HOCs from a different component + * @name copyHOCs + * @method + * @summary Wrap a new component with the HOCs from a different component * @param {String} sourceComponentName The name of the component to get the HOCs from * @param {Function|React.Component} targetComponent Component to wrap * @returns {Function|React.Component} A new component wrapped with the HOCs of the source component + * @memberof Components */ export function copyHOCs(sourceComponentName, targetComponent) { const sourceComponent = ComponentsTable[sourceComponentName]; @@ -148,9 +160,12 @@ export function copyHOCs(sourceComponentName, targetComponent) { /** - * Populate the final Components object with the contents of the lookup table. + * @name loadRegisteredComponents + * @method + * @summary Populate the final Components object with the contents of the lookup table. * This should only be called once on app startup. * @returns {Object} An object containing all of the registered components + * @memberof Components **/ export function loadRegisteredComponents() { Object.keys(ComponentsTable).map((name) => { diff --git a/imports/plugins/core/components/lib/composer/compose.js b/imports/plugins/core/components/lib/composer/compose.js index 634ce624b1d..5a013a7516b 100644 --- a/imports/plugins/core/components/lib/composer/compose.js +++ b/imports/plugins/core/components/lib/composer/compose.js @@ -4,12 +4,6 @@ import hoistStatics from "hoist-non-react-statics"; import _ from "lodash"; import { getDisplayName } from "recompose"; -/** - * @file Reaction Components API - * - * @module components - */ - export default function compose(dataLoader, options = {}) { return function (Child) { const { diff --git a/imports/plugins/core/components/lib/composer/tracker.js b/imports/plugins/core/components/lib/composer/tracker.js index 5df3b16da65..0bd7c6d750f 100644 --- a/imports/plugins/core/components/lib/composer/tracker.js +++ b/imports/plugins/core/components/lib/composer/tracker.js @@ -5,14 +5,28 @@ import compose from "./compose"; /** * @file **Reaction Components API** - Most of the React components in the Reaction UI can be replaced or extended with the API outlined here. This allows anyone to create a custom plugin that can easily change the look of the UI and/or extend its functionality without having to edit core Reaction code. See {@link https://docs.reactioncommerce.com/reaction-docs/master/components-api full tutorial and documentation}. - * @module components + * + * @example // Register a component and container(s) with a name. + * // The raw component can then be extended or replaced. + * + * // Structure of a component in the list: + * + * ComponentsTable.MyComponent = { + * name: 'MyComponent', + * hocs: [fn1, fn2], + * rawComponent: React.Component + * } + * @namespace Components */ /** - * getTrackerLoader creates a Meteor Tracker to watch dep updates from + * @name getTrackerLoader + * @summary getTrackerLoader creates a Meteor Tracker to watch dep updates from * the passed in reactiveMapper function * @param {Function} reactiveMapper data fetching function to bind to a tracker * @return {Function} composed function + * @memberof Components + * @private */ function getTrackerLoader(reactiveMapper) { return (props, onData, env) => { @@ -33,10 +47,13 @@ function getTrackerLoader(reactiveMapper) { /** - * A higher order component to wrap a reactive function with Meteor's Tracker + * @name composeWithTracker + * @method + * @summary A higher order component to wrap a reactive function with Meteor's Tracker * @param {Function} reactiveMapper data fetching function to bind to a tracker * @param {React.Component|Boolean|Object} options can be a custom loader, false (to disable), or a full options object * @return {Function} composed function + * @memberof Components */ export function composeWithTracker(reactiveMapper, options) { let composeOptions = {}; diff --git a/imports/plugins/core/components/lib/hoc.js b/imports/plugins/core/components/lib/hoc.js index 7d8a5728835..3f3a8ff81bf 100644 --- a/imports/plugins/core/components/lib/hoc.js +++ b/imports/plugins/core/components/lib/hoc.js @@ -4,12 +4,6 @@ import { Roles } from "meteor/alanning:roles"; import { Accounts, Groups } from "/lib/collections"; import { composeWithTracker } from "./composer"; -/** - * @file Reaction Components API - * - * @module components - */ - let Reaction; if (Meteor.isClient) { @@ -20,9 +14,12 @@ if (Meteor.isClient) { /** - * A wrapper to reactively inject the current user into a component + * @name withCurrentUser + * @method + * @summary A wrapper to reactively inject the current user into a component * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentUser" prop + * @memberof Components */ export function withCurrentUser(component) { return composeWithTracker((props, onData) => { @@ -32,10 +29,13 @@ export function withCurrentUser(component) { /** - * A wrapper to reactively inject the current account into a component. + * @name withCurrentAccount + * @method + * @summary A wrapper to reactively inject the current account into a component. * This assumes you have signed up and are not an anonymous user. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with a "currentAccount" prop + * @memberof Components */ export function withCurrentAccount(component) { return composeWithTracker((props, onData) => { @@ -64,10 +64,13 @@ export function withCurrentAccount(component) { /** - * A wrapper to reactively inject the current user's admin status. + * @name withIsAdmin + * @method + * @summary A wrapper to reactively inject the current user's admin status. * Sets a boolean 'isAdmin' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isAdmin" prop + * @memberof Components */ export function withIsAdmin(component) { return composeWithTracker((props, onData) => { @@ -76,11 +79,14 @@ export function withIsAdmin(component) { } /** - * A wrapper to reactively inject a user's permission based on group or roles + * @name withPermissions + * @method + * @summary A wrapper to reactively inject a user's permission based on group or roles * Group access is given to users at that group level and above * @param {Array|String} roles String or array of strings of permissions to check. default: roles=["guest", "anonymous"] * @param {String} group Slug title of a group to check against. Group option supercedes roles option. default: group="customer". * @return {Function} the new wrapped component with a "hasPermissions" prop + * @memberof Components */ export function withPermissions({ roles = ["guest", "anonymous"], group }) { return composeWithTracker((props, onData) => { @@ -110,10 +116,13 @@ export function withPermissions({ roles = ["guest", "anonymous"], group }) { /** - * A wrapper to reactively inject the current user's owner status. + * @name withIsOwner + * @method + * @summary A wrapper to reactively inject the current user's owner status. * Sets a boolean 'isOwner' prop on the wrapped component. * @param {Function|React.Component} component - the component to wrap * @return {Function} the new wrapped component with an "isOwner" prop + * @memberof Components */ export function withIsOwner(component) { return composeWithTracker((props, onData) => { diff --git a/imports/plugins/core/orders/client/components/invoice.js b/imports/plugins/core/orders/client/components/invoice.js index 5136e0e042b..8e55f854e3b 100644 --- a/imports/plugins/core/orders/client/components/invoice.js +++ b/imports/plugins/core/orders/client/components/invoice.js @@ -7,19 +7,26 @@ import LineItems from "./lineItems"; import InvoiceActions from "./invoiceActions"; /** - * @summary React component for displaying the `invoice` section on the orders sideview - * @param {Object} props - React PropTypes - * @property {Object} invoice - An object representing an invoice - * @property {Object} order - An object representing an order - * @property {Bool} discounts - A boolean indicating whether discounts are enabled - * @property {Array} refunds - An array/list of refunds - * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured - * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment - * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds - * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded - * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview - */ + * @file Invoice is a React Component for displaying the `invoice` section on the orders sideview + * @module Invoice + * @extends Components + */ + class Invoice extends Component { + /** + * @name Invoice propTypes + * @type {propTypes} + * @param {Object} props - React PropTypes + * @property {Object} invoice - An object representing an invoice + * @property {Object} order - An object representing an order + * @property {Bool} discounts - A boolean indicating whether discounts are enabled + * @property {Array} refunds - An array/list of refunds + * @property {Bool} paymentCaptured - A boolean indicating whether payment has been captured + * @property {Bool} canMakeAdjustments - A boolean indicating whether adjustments could be made on total payment + * @property {Bool} hasRefundingEnabled - A boolean indicating whether payment supports refunds + * @property {Bool} isFetching - A boolean indicating whether refund list is being loaded + * @return {Node} React node containing component for displaying the `invoice` section on the orders sideview + */ static propTypes = { canMakeAdjustments: PropTypes.bool, discounts: PropTypes.bool, @@ -36,6 +43,8 @@ class Invoice extends Component { } /** + * @name formatDate() + * @method * @summary Formats dates * @param {Number} context - the date to be formatted * @param {String} block - the preferred format @@ -47,6 +56,8 @@ class Invoice extends Component { } /** + * @name handleClick() + * @method * @summary Handle clicking the add discount link * @param {Event} event - the event that fired * @returns {null} null @@ -59,6 +70,8 @@ class Invoice extends Component { } /** + * @name renderDiscountForm() + * @method * @summary Displays the discount form * @returns {null} null */ @@ -81,6 +94,8 @@ class Invoice extends Component { } /** + * @name renderRefundsInfo() + * @method * @summary Displays the refund information after the order payment breakdown on the invoice * @returns {null} null */ @@ -108,6 +123,8 @@ class Invoice extends Component { } /** + * @name renderTotal() + * @method * @summary Displays the total payment form * @returns {null} null */ @@ -124,6 +141,8 @@ class Invoice extends Component { } /** + * @name renderConditionalDisplay() + * @method * @summary Displays either refunds info or the total payment form * @returns {null} null */ @@ -148,6 +167,8 @@ class Invoice extends Component { } /** + * @name renderInvoice() + * @method * @summary Displays the invoice form with broken down payment info * @returns {null} null */