diff --git a/.circleci/config.yml b/.circleci/config.yml index 84c6f4005d6..0413974d101 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,17 +19,17 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Install NPM dependencies command: npm ci - save_cache: - key: reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + key: reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} paths: - node_modules - save_cache: - key: reaction-v4-node-modules-{{ .Branch }} + key: reaction-v5-node-modules-{{ .Branch }} paths: - node_modules @@ -49,8 +49,8 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Lint JavaScript command: npm run lint @@ -61,8 +61,8 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Lint GraphQL schemas command: npm run lint:gql @@ -73,8 +73,8 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Run Unit Tests command: npm run test:unit @@ -92,8 +92,8 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Run Integration Query Tests command: MONGO_URL=mongodb://localhost:27017/test npm run test:integration:query @@ -111,8 +111,8 @@ jobs: - checkout - restore_cache: keys: - - reaction-v4-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} - - reaction-v4-node-modules-{{ .Branch }} + - reaction-v5-node-modules-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }} + - reaction-v5-node-modules-{{ .Branch }} - run: name: Run Integration Mutation Tests command: MONGO_URL=mongodb://localhost:27017/test npm run test:integration:mutation diff --git a/jest.config.cjs b/jest.config.cjs index a0a11c6761b..76e12de9db4 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -11,6 +11,7 @@ const externalNodeModules = [ "@reactioncommerce/api-plugin-carts", "@reactioncommerce/api-plugin-catalogs", "@reactioncommerce/api-plugin-email", + "@reactioncommerce/api-plugin-email-templates", "@reactioncommerce/api-plugin-i18n", "@reactioncommerce/api-plugin-job-queue", "@reactioncommerce/api-plugin-notifications", diff --git a/package-lock.json b/package-lock.json index 41a151f879d..adcb632041d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1653,6 +1653,19 @@ "@reactioncommerce/logger": "^1.1.3" } }, + "@reactioncommerce/api-plugin-email-templates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@reactioncommerce/api-plugin-email-templates/-/api-plugin-email-templates-1.0.0.tgz", + "integrity": "sha512-sfuSwLI8DPm9Bd96ILXsrma+e/08XW3huLDe7/8xg4Fo3CPlG4e18TUT8ZWUuyvwYMWhCqIdH10/LN2KyDKLzw==", + "requires": { + "@reactioncommerce/api-utils": "^1.9.0", + "@reactioncommerce/logger": "^1.1.3", + "@reactioncommerce/random": "^1.0.2", + "@reactioncommerce/reaction-error": "^1.0.1", + "handlebars": "^4.7.6", + "simpl-schema": "^1.5.7" + } + }, "@reactioncommerce/api-plugin-i18n": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@reactioncommerce/api-plugin-i18n/-/api-plugin-i18n-1.0.0.tgz", diff --git a/package.json b/package.json index 7563dbaf54b..92cba52d403 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@reactioncommerce/api-plugin-carts": "^1.0.0", "@reactioncommerce/api-plugin-catalogs": "~1.0.0", "@reactioncommerce/api-plugin-email": "~1.0.0", + "@reactioncommerce/api-plugin-email-templates": "~1.0.0", "@reactioncommerce/api-plugin-i18n": "~1.0.0", "@reactioncommerce/api-plugin-job-queue": "~1.0.0", "@reactioncommerce/api-plugin-notifications": "~1.0.0", diff --git a/plugins.json b/plugins.json index 19e76b8dd46..6c3102493bc 100644 --- a/plugins.json +++ b/plugins.json @@ -9,7 +9,7 @@ "discountCodes": "@reactioncommerce/plugin-discount-codes", "discounts": "./src/core-services/discounts/index.js", "email": "@reactioncommerce/api-plugin-email", - "emailTemplates": "./src/plugins/email-templates/index.js", + "emailTemplates": "@reactioncommerce/api-plugin-email-templates", "examplePayments": "@reactioncommerce/plugin-payments-example", "files": "./src/core-services/files/index.js", "i18": "@reactioncommerce/api-plugin-i18n", diff --git a/src/plugins/email-templates/index.js b/src/plugins/email-templates/index.js deleted file mode 100644 index 4c55e9d0a1d..00000000000 --- a/src/plugins/email-templates/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import queries from "./queries/index.js"; -import mutations from "./mutations/index.js"; -import policies from "./policies.json"; -import resolvers from "./resolvers/index.js"; -import schemas from "./schemas/index.js"; -import { EmailTemplates } from "./simpleSchemas.js"; -import startup from "./startup.js"; - -/** - * @summary Import and call this function to add this plugin to your API. - * @param {ReactionAPI} app The ReactionAPI instance - * @returns {undefined} - */ -export default async function register(app) { - await app.registerPlugin({ - label: "Email Templates", - name: "reaction-email-templates", - version: app.context.appVersion, - graphQL: { - resolvers, - schemas - }, - policies, - queries, - mutations, - simpleSchemas: { - EmailTemplates - }, - functionsByType: { - startup: [startup] - }, - collections: { - Templates: { - name: "Templates", - indexes: [ - // Create indexes. We set specific names for backwards compatibility - // with indexes created by the aldeed:schema-index Meteor package. - [{ shopId: 1 }, { name: "c2_shopId" }] - ] - } - } - }); -} diff --git a/src/plugins/email-templates/mutations/index.js b/src/plugins/email-templates/mutations/index.js deleted file mode 100644 index cd91db31aef..00000000000 --- a/src/plugins/email-templates/mutations/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import renderEmail from "./renderEmail.js"; -import updateTemplate from "./updateTemplate.js"; - -export default { - renderEmail, - updateTemplate -}; diff --git a/src/plugins/email-templates/mutations/renderEmail.js b/src/plugins/email-templates/mutations/renderEmail.js deleted file mode 100644 index c73ff3380e7..00000000000 --- a/src/plugins/email-templates/mutations/renderEmail.js +++ /dev/null @@ -1,25 +0,0 @@ -import Handlebars from "handlebars"; -import getTemplateConfig from "../util/getTemplateConfig.js"; - -/** - * @summary Renders an email given some name and data. - * The core email plugin expects that some other plugin (this one by default) - * will add a `renderEmail` function to the `mutations` object. - * @param {Object} context App context - * @param {Object} [data] Data that will be used to populate placeholders in the template - * @param {String} shopId The shop ID, to look up the email template for this shop - * @param {String} templateName Template name - * @param {String} language i18n language of template - * @returns {Object} An object with rendered content in properties `html` and `subject` - */ -export default async function renderEmail(context, { data, shopId, templateName, language }) { - const { template, subject } = await getTemplateConfig(context, shopId, templateName, language); - - const renderSubject = Handlebars.compile(subject); - const renderBody = Handlebars.compile(template); - - return { - subject: renderSubject(data), - html: renderBody(data) - }; -} diff --git a/src/plugins/email-templates/mutations/updateTemplate.js b/src/plugins/email-templates/mutations/updateTemplate.js deleted file mode 100644 index f1b93fe7145..00000000000 --- a/src/plugins/email-templates/mutations/updateTemplate.js +++ /dev/null @@ -1,49 +0,0 @@ -import ReactionError from "@reactioncommerce/reaction-error"; -import SimpleSchema from "simpl-schema"; - -const inputSchema = new SimpleSchema( - { - templateId: String, - shopId: String, - title: { type: String, optional: true }, - subject: { type: String, optional: true }, - template: { type: String, optional: true } - }, - { requiredByDefault: false } -); - -/** - * @name updateTemplate - * @summary Updates email template in Templates collection - * @param {Object} context - an object containing the per-request state - * @param {Object} input - an object of all mutation arguments that were sent by the client - * @returns {Promise} UpdateTemplatePayload - */ -export default async function updateTemplate(context, input) { - const { collections } = context; - const { Templates } = collections; - const { templateId, shopId, ...params } = input; - - await context.validatePermissions("reaction:legacy:email-templates", "update", { shopId }); - - inputSchema.validate(params); - - params.updatedAt = new Date(); - - try { - const { result } = await Templates.updateOne( - { _id: templateId, shopId }, - { $set: params } - ); - - if (result.n === 0) { - throw new ReactionError("not-found", "Template not found"); - } - - const template = await Templates.findOne({ _id: templateId, shopId }); - - return template; - } catch ({ message }) { - throw new ReactionError("error", message); - } -} diff --git a/src/plugins/email-templates/policies.json b/src/plugins/email-templates/policies.json deleted file mode 100644 index a50afd8898d..00000000000 --- a/src/plugins/email-templates/policies.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "description": "Shop managers acting on email settings.", - "subjects": [ "reaction:groups:shop-managers" ], - "resources": [ "reaction:legacy:email-templates" ], - "actions": [ - "read", - "update" - ], - "effect": "allow" - } -] diff --git a/src/plugins/email-templates/queries/emailTemplates.js b/src/plugins/email-templates/queries/emailTemplates.js deleted file mode 100644 index e494bab1f01..00000000000 --- a/src/plugins/email-templates/queries/emailTemplates.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @name emailTemplates - * @method - * @memberof GraphQL/Templates - * @summary Query the Templates collection for a list of email templates - * @param {Object} context - an object containing the per-request state - * @param {String} shopId - ID of the shop to query against - * @returns {Promise} Email templates cursor - */ -export default async function emailTemplates(context, shopId) { - const { collections } = context; - const { Templates } = collections; - - await context.validatePermissions("reaction:legacy:email-templates", "read", { shopId }); - - return Templates.find({ - shopId, - type: "email" - }); -} diff --git a/src/plugins/email-templates/queries/index.js b/src/plugins/email-templates/queries/index.js deleted file mode 100644 index 3c04bc6008e..00000000000 --- a/src/plugins/email-templates/queries/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import emailTemplates from "./emailTemplates.js"; - -export default { - emailTemplates -}; diff --git a/src/plugins/email-templates/resolvers/Mutation/index.js b/src/plugins/email-templates/resolvers/Mutation/index.js deleted file mode 100644 index 9fe6185be17..00000000000 --- a/src/plugins/email-templates/resolvers/Mutation/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import updateTemplate from "./updateTemplate.js"; - -export default { - updateTemplate -}; diff --git a/src/plugins/email-templates/resolvers/Mutation/updateTemplate.js b/src/plugins/email-templates/resolvers/Mutation/updateTemplate.js deleted file mode 100644 index 389fd53ec88..00000000000 --- a/src/plugins/email-templates/resolvers/Mutation/updateTemplate.js +++ /dev/null @@ -1,38 +0,0 @@ -import { decodeShopOpaqueId, decodeTemplateOpaqueId } from "../../xforms/id.js"; - -/** - * @name Mutation.updateTemplate - * @method - * @memberof Routes/GraphQL - * @summary Update a specified redirect rule - * @param {Object} parentResult - unused - * @param {Object} args.input - updateTemplateInput - * @param {String} args.input.title - path to redirect from - * @param {String} args.input.subject - path to redirect to - * @param {Boolean} args.input.template - whether the tag is visible - * @param {String} [args.input.clientMutationId] - An optional string identifying the mutation call - * @param {Object} context - an object containing the per-request state - * @returns {Promise} updateTemplatePayload - */ -export default async function updateTemplate(parentResult, { input }, context) { - const { - clientMutationId = null, - id: opaqueTemplateId, - shopId: opaqueShopId, - ...templateInput - } = input; - - const shopId = decodeShopOpaqueId(opaqueShopId); - const templateId = decodeTemplateOpaqueId(opaqueTemplateId); - - const template = await context.mutations.updateTemplate(context, { - shopId, - templateId, - ...templateInput - }); - - return { - clientMutationId, - template - }; -} diff --git a/src/plugins/email-templates/resolvers/Query/emailTemplates.js b/src/plugins/email-templates/resolvers/Query/emailTemplates.js deleted file mode 100644 index daa7dc314e4..00000000000 --- a/src/plugins/email-templates/resolvers/Query/emailTemplates.js +++ /dev/null @@ -1,28 +0,0 @@ -import getPaginatedResponse from "@reactioncommerce/api-utils/graphql/getPaginatedResponse.js"; -import wasFieldRequested from "@reactioncommerce/api-utils/graphql/wasFieldRequested.js"; -import { decodeShopOpaqueId } from "../../xforms/id.js"; - -/** - * @name Query/emailTemplates - * @method - * @memberof Templates/Query - * @param {Object} _ unused - * @param {Object} args - an object of all the arguments that were sent by the client - * @param {String} args.shopId - id of the shop - * @param {Object} context - an object containing the per-request state - * @param {Object} info - info about the GraphQL request - * @returns {Promise} an array of email templates - */ -export default async function emailTemplates(_, args, context, info) { - const { shopId: opaqueShopId, ...connectionArgs } = args; - - const shopId = decodeShopOpaqueId(opaqueShopId); - - const query = await context.queries.emailTemplates(context, shopId); - - return getPaginatedResponse(query, connectionArgs, { - includeHasNextPage: wasFieldRequested("pageInfo.hasNextPage", info), - includeHasPreviousPage: wasFieldRequested("pageInfo.hasPreviousPage", info), - includeTotalCount: wasFieldRequested("totalCount", info) - }); -} diff --git a/src/plugins/email-templates/resolvers/Query/index.js b/src/plugins/email-templates/resolvers/Query/index.js deleted file mode 100644 index 3c04bc6008e..00000000000 --- a/src/plugins/email-templates/resolvers/Query/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import emailTemplates from "./emailTemplates.js"; - -export default { - emailTemplates -}; diff --git a/src/plugins/email-templates/resolvers/Template/index.js b/src/plugins/email-templates/resolvers/Template/index.js deleted file mode 100644 index f193a8ff5e5..00000000000 --- a/src/plugins/email-templates/resolvers/Template/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import { encodeShopOpaqueId, encodeTemplateOpaqueId } from "../../xforms/id.js"; - -export default { - _id: (node) => encodeTemplateOpaqueId(node._id), - shopId: (node) => encodeShopOpaqueId(node.shopId) -}; diff --git a/src/plugins/email-templates/resolvers/index.js b/src/plugins/email-templates/resolvers/index.js deleted file mode 100644 index 460cdab123b..00000000000 --- a/src/plugins/email-templates/resolvers/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import Query from "./Query/index.js"; -import Mutation from "./Mutation/index.js"; -import Template from "./Template/index.js"; - -export default { - Query, - Mutation, - Template -}; diff --git a/src/plugins/email-templates/schemas/index.js b/src/plugins/email-templates/schemas/index.js deleted file mode 100644 index 27b4f853a14..00000000000 --- a/src/plugins/email-templates/schemas/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import importAsString from "@reactioncommerce/api-utils/importAsString.js"; - -const schema = importAsString("./schema.graphql"); -const updateTemplate = importAsString("./updateTemplate.graphql"); - -export default [ - schema, - updateTemplate -]; diff --git a/src/plugins/email-templates/schemas/schema.graphql b/src/plugins/email-templates/schemas/schema.graphql deleted file mode 100644 index 5a55281c3f7..00000000000 --- a/src/plugins/email-templates/schemas/schema.graphql +++ /dev/null @@ -1,80 +0,0 @@ -"Represents a Template" -type Template implements Node { - "The shop ID" - _id: ID! - - "Email template language" - language: String - - "Email template name" - name: String - - "The shop that owns the template" - shopId: ID! - - "Email template string" - subject: String - - "Email template body or html text" - template: String - - "Email template title" - title: String -} - -"A connection edge in which each node is a `Template` object" -type TemplateEdge { - "The cursor that represents this node in the paginated results" - cursor: ConnectionCursor! - - "The email template" - node: Template -} - -""" -Wraps a list of Templates, providing pagination cursors and information. - -For information about what Relay-compatible connections are and how to use them, see the following articles: -- [Relay Connection Documentation](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections) -- [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm) -- [Using Relay-style Connections With Apollo Client](https://www.apollographql.com/docs/react/recipes/pagination.html) -""" -type TemplateConnection { - "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each" - edges: [TemplateEdge] - - """ - You can request the `nodes` directly to avoid the extra wrapping that `NodeEdge` has, - if you know you will not need to paginate the results. - """ - nodes: [Template] - - "Information to help a client request the next or previous page" - pageInfo: PageInfo! - - "The total number of nodes that match your query" - totalCount: Int! -} - -extend type Query { - "Retrieves a list of email templates" - emailTemplates( - "The shopId to which email templates belong to" - shopId: ID! - - "Return only results that come after this cursor. Use this with `first` to specify the number of results to return." - after: ConnectionCursor, - - "Return only results that come before this cursor. Use this with `last` to specify the number of results to return." - before: ConnectionCursor, - - "Return at most this many results. This parameter may be used with either `after` or `offset` parameters." - first: ConnectionLimitInt, - - "Return at most this many results. This parameter may be used with the `before` parameter." - last: ConnectionLimitInt, - - "Return only results that come after the Nth result. This parameter may be used with the `first` parameter." - offset: Int, - ) : TemplateConnection -} diff --git a/src/plugins/email-templates/schemas/updateTemplate.graphql b/src/plugins/email-templates/schemas/updateTemplate.graphql deleted file mode 100644 index 9a7bf686e92..00000000000 --- a/src/plugins/email-templates/schemas/updateTemplate.graphql +++ /dev/null @@ -1,39 +0,0 @@ - -"Input for `updateTemplate` mutation" -input UpdateTemplateInput { - "An optional string identifying the mutation call, which will be returned in the response payload" - clientMutationId: String - - "ID of template to modify" - id: ID! - - "The shop that owns the template" - shopId: ID! - - "Email template string" - subject: String - - "Email template body or html text" - template: String - - "Email template title" - title: String - -} - -"Response payload for `updateTemplate` mutation" -type UpdateTemplatePayload { - "The same string you sent with the mutation params, for matching mutation calls with their responses" - clientMutationId: String - - "The updated template" - template: Template! -} - -extend type Mutation { - "Updates an existing template" - updateTemplate( - "Mutation input" - input: UpdateTemplateInput! - ): UpdateTemplatePayload! -} diff --git a/src/plugins/email-templates/simpleSchemas.js b/src/plugins/email-templates/simpleSchemas.js deleted file mode 100644 index d90bc48565c..00000000000 --- a/src/plugins/email-templates/simpleSchemas.js +++ /dev/null @@ -1,81 +0,0 @@ -import SimpleSchema from "simpl-schema"; - -/** - * @name EmailTemplates - * @memberof Schemas - * @type {SimpleSchema} - * @summary EmailTemplates schema - */ -export const EmailTemplates = new SimpleSchema({ - "audience": { - optional: true, - type: Array - }, - "audience.$": { - type: String - }, - "block": { - optional: true, - type: String - }, - "defaultData": { - blackbox: true, - optional: true, - type: Object - }, - "enabled": { - defaultValue: true, - type: Boolean - }, - "language": { - defaultValue: "en", - optional: true, - type: String - }, - "name": { - optional: true, - type: String - }, - "parser": { - optional: true, - type: String - }, - "priority": { - defaultValue: 1, - optional: true, - type: SimpleSchema.Integer - }, - "provides": { - defaultValue: "template", - type: String - }, - "route": { - optional: true, - type: String - }, - "shopId": { - label: "Template ShopId", - type: String - }, - "source": { - optional: true, - type: String - }, - "subject": { - optional: true, - type: String - }, - "template": { - optional: true, - type: String - }, - "title": { - optional: true, - type: String - }, - "type": { - defaultValue: "email", - optional: true, - type: String - } -}); diff --git a/src/plugins/email-templates/startup.js b/src/plugins/email-templates/startup.js deleted file mode 100644 index 9b2d6d8a3b5..00000000000 --- a/src/plugins/email-templates/startup.js +++ /dev/null @@ -1,15 +0,0 @@ -import seedEmailTemplatesForShop from "./util/seedEmailTemplatesForShop.js"; - -/** - * @name startup - * @summary Called on startup - * @param {Object} context App context - * @returns {undefined} - */ -export default async function emailTemplatesStartup(context) { - context.appEvents.on("afterShopCreate", async (payload) => { - const { shop } = payload; - - await seedEmailTemplatesForShop(context, shop._id); - }); -} diff --git a/src/plugins/email-templates/templates/accounts/inviteNewShopMember.js b/src/plugins/email-templates/templates/accounts/inviteNewShopMember.js deleted file mode 100644 index 0bc0eee3039..00000000000 --- a/src/plugins/email-templates/templates/accounts/inviteNewShopMember.js +++ /dev/null @@ -1,175 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - - -Basic Email - - - - - - - - - - -
- - - - -
- - - - - - -
 
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - - - - - -
 
logo
 
Hi, {{invitedUserName}}.
 
{{currentUserName}} from {{shopName}} has invited you to join the group {{groupName}}.
 
- - - - -
Get Started 
 
 
 
You received this email because you were invited to join a group in the store {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}
 
-
- - -`; diff --git a/src/plugins/email-templates/templates/accounts/resetPassword.js b/src/plugins/email-templates/templates/accounts/resetPassword.js deleted file mode 100644 index d4618478fa5..00000000000 --- a/src/plugins/email-templates/templates/accounts/resetPassword.js +++ /dev/null @@ -1,175 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - - -Basic Email - - - - - - - - - - -
- - - - -
- - - - - - -
 
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - - - - - -
 
logo
 
Reset Your Password
 
We've received a request to reset your password. If you didn't make the request, you can just ignore this email.
 
- - - - -
Reset Password 
 
 
 
You received this email because you have an account with {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}
 
-
- - -`; diff --git a/src/plugins/email-templates/templates/accounts/sendWelcomeEmail.js b/src/plugins/email-templates/templates/accounts/sendWelcomeEmail.js deleted file mode 100644 index 16a7f93d417..00000000000 --- a/src/plugins/email-templates/templates/accounts/sendWelcomeEmail.js +++ /dev/null @@ -1,175 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - - -Basic Email - - - - - - - - - - -
- - - - -
- - - - - - -
 
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - - - - - -
 
logo
 
Hello!
 
Welcome to {{shopName}}.
 
- - - - -
Get Started 
 
 
 
You received this email because you have an account with {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}
 
-
- - -`; diff --git a/src/plugins/email-templates/templates/accounts/verifyEmail.js b/src/plugins/email-templates/templates/accounts/verifyEmail.js deleted file mode 100644 index c9e2e659d3a..00000000000 --- a/src/plugins/email-templates/templates/accounts/verifyEmail.js +++ /dev/null @@ -1,194 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - - -Basic Email - - - - - - - - - - -
- - - - -
- - - - - - -
 
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
logo
 
Hi,
 
Congratulations, your Reaction shop is ready to go! You just need to verify your email, {{userEmailAddress}}, to get started.
 
- - - - -
Verify Your Email 
 
Go ahead, jump on in! You can start adding products, setting up your payment provider and shipping details, and much more! In case you get stuck, we have some helpful docs to get you unstuck, and we’re here to help.
 
We’d love your feedback and any thoughts you have as you explore your shop. You can email us at any time, submit comments, or file an issue.
 
Thanks!
The Reaction Team
 
 
 
- - Support - | - - Docs - | - - Blog - | - - Developer Chat - -
- - - Twitter | - - - - Facebook | - - - - Instagram | - - - - GitHub - -
 
 
 
You received this email because a user of {{shopName}} invited you to create an account. Questions or suggestions? Email us at {{contactEmail}}
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}
 
-
- - -`; diff --git a/src/plugins/email-templates/templates/accounts/verifyUpdatedEmail.js b/src/plugins/email-templates/templates/accounts/verifyUpdatedEmail.js deleted file mode 100644 index 4d77a82af5e..00000000000 --- a/src/plugins/email-templates/templates/accounts/verifyUpdatedEmail.js +++ /dev/null @@ -1,195 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - - -Verify your email - - - - - - - - - - -
- - - - -
- - - - - - -
 
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
logo
 
Hi,
 
Your email address was recently updated in Reaction. To complete the update, please verify your email, {{userEmailAddress}}.
 
- - - - -
Verify Email 
 
We'll always reach out when there's activity on your Reaction account.
 
Don't recognize this request? Contact us, email us, or file an issue.
 
Thanks!
The Reaction Team
 
 
 
- - Support - | - - Docs - | - - Blog - | - - Developer Chat - -
- - - Twitter | - - - - Facebook | - - - - Instagram | - - - - GitHub - -
 
 
 
You received this email because a user of {{shopName}} invited you to create an account. Questions or suggestions? Email us at {{contactEmail}}
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}
 
-
- - -`; diff --git a/src/plugins/email-templates/templates/coreDefault.js b/src/plugins/email-templates/templates/coreDefault.js deleted file mode 100644 index 4655a784724..00000000000 --- a/src/plugins/email-templates/templates/coreDefault.js +++ /dev/null @@ -1,5 +0,0 @@ -export default ` - - This is the placeholder template at private/email/templates/coreDefault.html - -`; diff --git a/src/plugins/email-templates/templates/index.js b/src/plugins/email-templates/templates/index.js deleted file mode 100644 index c0895d5bc20..00000000000 --- a/src/plugins/email-templates/templates/index.js +++ /dev/null @@ -1,143 +0,0 @@ -import coreDefaultTemplate from "./coreDefault.js"; -import inviteNewShopMemberTemplate from "./accounts/inviteNewShopMember.js"; -import resetPasswordTemplate from "./accounts/resetPassword.js"; -import welcomeEmailTemplate from "./accounts/sendWelcomeEmail.js"; -import verifyUpdatedEmailTemplate from "./accounts/verifyUpdatedEmail.js"; -import verifyEmailTemplate from "./accounts/verifyEmail.js"; -import coreOrderNewTemplate from "./orders/new.js"; -import orderShippedTemplate from "./orders/shipped.js"; -import orderRefundedTemplate from "./orders/refunded.js"; -import orderItemRefundTemplate from "./orders/itemRefund.js"; - -export default [ - /* - * Default email templates - * Used when no other template is found - */ - { - language: "en", - title: "Default", - name: "coreDefault", - template: coreDefaultTemplate, - subject: "A message from {{shop.name}}" - }, - - /* - * Account related email templates - */ - - /* - * Accounts - Invite Shop member and create new user account - * When: Admin invites new member to shop - */ - { - language: "en", - title: "Accounts - Invite Shop Member - New User Account", - name: "accounts/inviteNewShopMember", - template: inviteNewShopMemberTemplate, - subject: "You have been invited to join the group \"{{groupName}}\" in the store \"{{shop.name}}\"" - }, - - /* - * Accounts - Reset Password - * When: User requests to reset their password - */ - { - language: "en", - title: "Accounts - Reset Password", - name: "accounts/resetPassword", - template: resetPasswordTemplate, - subject: "{{shop.name}}: Here's your password reset link" - }, - - /* - * Accounts - Welcome Email - * When: New user signs up for an account - */ - { - language: "en", - title: "Accounts - Welcome Email", - name: "accounts/sendWelcomeEmail", - template: welcomeEmailTemplate, - subject: "You're In. Welcome to {{shop.name}}!" - }, - - /* - * Accounts - Verify Email - * When: A user signs up - */ - { - language: "en", - title: "Accounts - Verify Account (via LaunchDock)", - name: "accounts/verifyEmail", - template: verifyEmailTemplate, - subject: "{{shopName}}: Please verify your email address" - }, - - /* - * Accounts - Verify Updated Email - * When: A user changes their email - */ - { - language: "en", - title: "Accounts - Verify Updated Email Address", - name: "accounts/verifyUpdatedEmail", - template: verifyUpdatedEmailTemplate, - subject: "Verify your new email address" - }, - - /* - * Order related email templates - */ - - /* - * Orders - New Order Place - * When: A user completes the cart checkout flow and a new order is placed - */ - { - language: "en", - title: "Orders - New Order Placed", - name: "orders/new", - template: coreOrderNewTemplate, - subject: "Your order is confirmed - {{order.referenceId}}" - }, - - /* - * Orders - Order Shipped - * When: Admin completes the order flow and item is shipped - * When: Admin re-sends shipment notification - */ - { - language: "en", - title: "Orders - Order Shipped", - name: "orders/shipped", - template: orderShippedTemplate, - subject: "{{shop.name}}: Your order has shipped - {{order.referenceId}}" - }, - - /* - * Orders - Order Refunded - * When: Admin completes the order flow and item is shipped - * When: Admin re-sends shipment notification - */ - { - language: "en", - title: "Orders - Order Refunded", - name: "orders/refunded", - template: orderRefundedTemplate, - subject: "{{shop.name}}: Confirmation of refund for {{order.referenceId}}" - }, - - /* - * Orders - Order Refunded - * When: Admin completes the order flow and item is shipped - * When: Admin refunds line items - */ - { - language: "en", - title: "Orders - Order Item Refunded", - name: "orders/itemRefund", - template: orderItemRefundTemplate, - subject: "{{shop.name}}: Refund confirmation - {{order.referenceId}}" - } -]; diff --git a/src/plugins/email-templates/templates/orders/itemRefund.js b/src/plugins/email-templates/templates/orders/itemRefund.js deleted file mode 100644 index 651cc1b5ac7..00000000000 --- a/src/plugins/email-templates/templates/orders/itemRefund.js +++ /dev/null @@ -1,469 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - Order Confirm Email - - - - - - - - -
- - - - -
- - - - - - - - - - -
 
 
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - -
 
- logo -
 
Your refund has been processed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each combinedItems}} - - - - - - - - - - {{/each}} - - - - -
Hi {{billing.address.fullName}},
We’ve refunded you for the following items. Please allow additional days for your bank or credit card to process the transaction.
Have a question? Reply to this email or contact us at {{contactEmail}}.
- - - - - - - - - - - -
 
Your OrderOrder Date 
-
 
 
 
- - - - - - - - -
{{order.referenceId}}{{orderDate}} 
-
 
 
- - - - - - - - -
Shipping AddressBilling AddressPayment Type
-
 
 
 
- - - - - - - - - - - - - - -
- {{#with shipping.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#with billing.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#each billing.payments}} - {{this.displayName}} ({{this.displayAmount}})
- {{/each}} -
 
Item(s)
-
 
 
- - - - - - - - -
- - - - - - - - - - - -
 
{{quantity}} x  - {{#if imageURLs}} - - {{else}} - - {{/if}} -
-
  - - - - - - - -
{{variantTitle}}{{price.displayAmount}}
-
-
 
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Subtotal: {{billing.subtotal}}
Shipping: {{billing.shipping}}
Tax: {{billing.taxes}}
Discounts: {{billing.discounts}}
 
 
 
Previous Total: {{billing.total}}
Refunds: {{billing.refunds}}
 
 
 
- - - - - - - -
NEW TOTAL:{{billing.adjustedTotal}}
-
-
-
 
 
 
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{#if physicalAddress}}{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}{{/if}}
-
-
-
-
- - -`; diff --git a/src/plugins/email-templates/templates/orders/new.js b/src/plugins/email-templates/templates/orders/new.js deleted file mode 100644 index bad408f125b..00000000000 --- a/src/plugins/email-templates/templates/orders/new.js +++ /dev/null @@ -1,448 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - Order Confirm Email - - - - - - - - -
- - - - -
- - - - - - - - - - -
 
 
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - -
 
- logo -
 
Order Confirmation
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each combinedItems}} - - - - - - - - - - {{/each}} - - - - -
- - - - - - - - - - - -
 
Your OrderOrder DateStatus
-
 
 
 
- - - - - - - - -
{{order.referenceId}}{{orderDate}}Not shipped
-
 
 
- - - - - - - - -
Shipping AddressBilling AddressPayment Type
-
 
 
 
- - - - - - - - - - - - - - -
- {{#with shipping.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#with billing.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#each billing.payments}} - {{this.displayName}} ({{this.displayAmount}})
- {{/each}} -
 
Item(s)
-
 
 
- - - - - - - - -
- - - - - - - - - - - -
 
{{quantity}} x  - {{#if imageURLs}} - - {{else}} - - {{/if}} -
-
  - - - - - - - -
{{variantTitle}}{{price.displayAmount}}
-
-
 
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Subtotal: {{billing.subtotal}}
Shipping: {{billing.shipping}}
Tax: {{billing.taxes}}
Discounts: {{billing.discounts}}
 
 
 
- - - - - - - -
ORDER TOTAL:{{billing.total}}
-
-
-
 
 
 
You received this email because you created an order with {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{#if physicalAddress}}{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}{{/if}}
-
-
-
-
- - -`; diff --git a/src/plugins/email-templates/templates/orders/refunded.js b/src/plugins/email-templates/templates/orders/refunded.js deleted file mode 100644 index d9e465942a5..00000000000 --- a/src/plugins/email-templates/templates/orders/refunded.js +++ /dev/null @@ -1,463 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - Order Confirm Email - - - - - - - - -
- - - - -
- - - - - - - - - - -
 
 
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - -
 
- logo -
 
We got your return!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each combinedItems}} - - - - - - - - - - {{/each}} - - - - -
- - - - - - - - - - - -
 
Your OrderOrder Date 
-
 
 
 
- - - - - - - - -
{{order.referenceId}}{{orderDate}} 
-
 
 
- - - - - - - - -
Shipping AddressBilling AddressPayment Type
-
 
 
 
- - - - - - - - - - - - - - -
- {{#with shipping.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#with billing.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#each billing.payments}} - {{this.displayName}} ({{this.displayAmount}})
- {{/each}} -
 
Item(s)
-
 
 
- - - - - - - - -
- - - - - - - - - - - -
 
{{quantity}} x  - {{#if imageURLs}} - - {{else}} - - {{/if}} -
-
  - - - - - - - -
{{variantTitle}}{{price.displayAmount}}
-
-
 
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Subtotal: {{billing.subtotal}}
Shipping: {{billing.shipping}}
Tax: {{billing.taxes}}
Discounts: {{billing.discounts}}
 
 
 
Previous Total: {{billing.total}}
Refunds: {{billing.refunds}}
 
 
 
- - - - - - - -
NEW TOTAL:{{billing.adjustedTotal}}
-
-
-
 
 
 
You received this email because you created an order with {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{#if physicalAddress}}{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}{{/if}}
-
-
-
-
- - -`; diff --git a/src/plugins/email-templates/templates/orders/shipped.js b/src/plugins/email-templates/templates/orders/shipped.js deleted file mode 100644 index f8abfbb9f7d..00000000000 --- a/src/plugins/email-templates/templates/orders/shipped.js +++ /dev/null @@ -1,452 +0,0 @@ -/* eslint-disable max-len */ -export default ` - - - Order Confirm Email - - - - - - - - -
- - - - -
- - - - - - - - - - -
 
 
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#if socialLinks.display}} - - - - - - - - - - {{else}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - -
 
- logo -
 
Your order is on its way
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each combinedItems}} - - - - - - - - - - {{/each}} - - - - -
- - - - - - - - - - - -
 
Your OrderOrder DateTracking Number
-
 
 
 
- - - - - - {{#if shipping.tracking}} - - {{else}} - - {{/if}} - - -
{{order.referenceId}}{{orderDate}}{{shipping.carrier}}
{{shipping.tracking}}
Tracking not available
-
 
 
- - - - - - - - -
Shipping AddressBilling AddressPayment Type
-
 
 
 
- - - - - - - - - - - - - - -
- {{#with shipping.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#with billing.address}} - {{this.fullName}}
{{this.address}}
{{this.city}} {{this.region}} {{this.postal}} - {{/with}} -
- {{#each billing.payments}} - {{this.displayName}} ({{this.displayAmount}})
- {{/each}} -
 
Item(s)
-
 
 
- - - - - - - - -
- - - - - - - - - - - -
 
{{quantity}} x  - {{#if imageURLs}} - - {{else}} - - {{/if}} -
-
  - - - - - - - -
{{variantTitle}}{{price.displayAmount}}
-
-
 
 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Subtotal: {{billing.subtotal}}
Shipping: {{billing.shipping}}
Tax: {{billing.taxes}}
Discounts: {{billing.discounts}}
 
 
 
- - - - - - - -
ORDER TOTAL:{{billing.total}}
-
-
-
 
 
 
You received this email because you created an order with {{shopName}}. Questions or suggestions? Email us at {{contactEmail}}
 
- - - {{#if socialLinks.twitter.display}} - - {{/if}} - {{#if socialLinks.facebook.display}} - - - {{/if}} - {{#if socialLinks.googlePlus.display}} - - - {{/if}} - -
- twt_icon -   - fb_icon -   - g_plus_icon -
-
 
 
 
 
© {{copyrightDate}} {{#if legalName}}{{legalName}}{{else}}{{shopName}}{{/if}}. All rights reserved
 
{{#if physicalAddress}}{{physicalAddress.address}}, {{physicalAddress.city}}, {{physicalAddress.region}} {{physicalAddress.postal}}{{/if}}
-
-
-
-
- - -`; diff --git a/src/plugins/email-templates/util/getTemplateConfig.js b/src/plugins/email-templates/util/getTemplateConfig.js deleted file mode 100644 index 92c80f9441d..00000000000 --- a/src/plugins/email-templates/util/getTemplateConfig.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @summary Returns a template source for SSR consumption - * @param {Object} context App context - * @param {String} shopId Shop ID - * @param {String} templateName Email template name - * @param {String} language Email language - * @returns {Object} returns source - */ -export default async function getTemplateConfig(context, shopId, templateName, language) { - const { Shops, Templates } = context.collections; - - const shop = await Shops.findOne({ - _id: shopId - }, { - projection: { - language: 1 - } - }); - if (!shop) throw new Error(`Shop with ID ${shopId} not found`); - - const { language: shopLanguage } = shop; - - // check database for a matching template - const templateDoc = await Templates.findOne({ - language: language || shopLanguage, - name: templateName, - shopId, - type: "email" - }); - if (!templateDoc) throw new Error(`No email template ${templateName} found for language ${language || shopLanguage}`); - - return templateDoc; -} diff --git a/src/plugins/email-templates/util/seedEmailTemplate.js b/src/plugins/email-templates/util/seedEmailTemplate.js deleted file mode 100644 index cfece3bb146..00000000000 --- a/src/plugins/email-templates/util/seedEmailTemplate.js +++ /dev/null @@ -1,24 +0,0 @@ -import Logger from "@reactioncommerce/logger"; -import Random from "@reactioncommerce/random"; - -/** - * @param {Object} context App context - * @param {String} shopId Shop ID - * @param {Object} doc The template document - * @returns {undefined} - */ -export default async function seedEmailTemplate(context, shopId, doc) { - const { Templates } = context.collections; - - const existing = await Templates.findOne({ language: doc.language, name: doc.name, shopId, type: "email" }); - if (!existing) { - Logger.debug(`Seeding database with default email template "${doc.name}" for shop ${shopId}`); - await Templates.insertOne({ - ...doc, - _id: Random.id(), - parser: "handlebars", - shopId, - type: "email" - }); - } -} diff --git a/src/plugins/email-templates/util/seedEmailTemplatesForShop.js b/src/plugins/email-templates/util/seedEmailTemplatesForShop.js deleted file mode 100644 index fca7c5facfc..00000000000 --- a/src/plugins/email-templates/util/seedEmailTemplatesForShop.js +++ /dev/null @@ -1,17 +0,0 @@ -import templateDefinitions from "../templates/index.js"; -import seedEmailTemplate from "./seedEmailTemplate.js"; - -/** - * @summary Creates shop-owned email template records from the default templates - * that live in the codebase. - * @param {Object} context App context - * @param {String} shopId Shop ID - * @returns {undefined} - */ -export default async function seedEmailTemplatesForShop(context, shopId) { - const promises = templateDefinitions.map((templateDefinition) => ( - seedEmailTemplate(context, shopId, templateDefinition) - )); - - await Promise.all(promises); -} diff --git a/src/plugins/email-templates/xforms/id.js b/src/plugins/email-templates/xforms/id.js deleted file mode 100644 index a32f57d3f87..00000000000 --- a/src/plugins/email-templates/xforms/id.js +++ /dev/null @@ -1,13 +0,0 @@ -import decodeOpaqueIdForNamespace from "@reactioncommerce/api-utils/decodeOpaqueIdForNamespace.js"; -import encodeOpaqueId from "@reactioncommerce/api-utils/encodeOpaqueId.js"; - -const namespaces = { - Shop: "reaction/shop", - Template: "reaction/template" -}; - -export const encodeShopOpaqueId = encodeOpaqueId(namespaces.Shop); -export const encodeTemplateOpaqueId = encodeOpaqueId(namespaces.Template); - -export const decodeShopOpaqueId = decodeOpaqueIdForNamespace(namespaces.Shop); -export const decodeTemplateOpaqueId = decodeOpaqueIdForNamespace(namespaces.Template); diff --git a/tests/util/factory.js b/tests/util/factory.js index 62c84534c37..6094c1f6dfa 100644 --- a/tests/util/factory.js +++ b/tests/util/factory.js @@ -22,6 +22,10 @@ import { DiscountCodes } from "@reactioncommerce/plugin-discount-codes/src/simpleSchemas.js"; +import { + EmailTemplates +} from "@reactioncommerce/api-plugin-email-templates/src/simpleSchemas.js"; + import { NavigationItem, NavigationTree, @@ -84,10 +88,6 @@ import { extendTaxesSchemas } from "../../src/core-services/taxes/simpleSchemas.js"; -import { - EmailTemplates -} from "../../src/plugins/email-templates/simpleSchemas.js"; - import { extendSimplePricingSchemas } from "../../src/plugins/simple-pricing/simpleSchemas.js";