@storecraft/database-mongodb 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/index.js +2 -2
- package/migrations/00001_seed_email_templates.js +2 -238
- package/package.json +3 -4
- package/src/con.auth_users.js +4 -11
- package/src/con.collections.js +3 -3
- package/src/con.customers.js +2 -2
- package/src/con.discounts.js +4 -4
- package/src/con.discounts.utils.js +11 -11
- package/src/con.images.js +5 -5
- package/src/con.notifications.js +2 -2
- package/src/con.orders.js +1 -1
- package/src/con.posts.js +1 -1
- package/src/con.products.js +10 -10
- package/src/con.search.js +6 -6
- package/src/con.shared.js +12 -12
- package/src/con.shipping.js +1 -1
- package/src/con.storefronts.js +6 -6
- package/src/con.tags.js +1 -1
- package/src/con.templates.js +1 -1
- package/src/utils.query.js +6 -6
- package/src/utils.relations.js +3 -3
- package/tests/runner.test.js +4 -4
- package/tests/sandbox.test.js +1 -1
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<div style="text-align:center">
|
4
4
|
<img src='https://storecraft.app/storecraft-color.svg'
|
5
|
-
width='90%'
|
5
|
+
width='90%' />
|
6
6
|
</div><hr/><br/>
|
7
7
|
|
8
8
|
Official `mongodb` driver for `StoreCraft` on **Node.js** platforms.
|
@@ -16,13 +16,10 @@ npm i @storecraft/database-mongodb
|
|
16
16
|
```js
|
17
17
|
import 'dotenv/config';
|
18
18
|
import http from "node:http";
|
19
|
-
import { join } from "node:path";
|
20
|
-
import { homedir } from "node:os";
|
21
|
-
|
22
19
|
import { App } from '@storecraft/core'
|
23
|
-
import { NodePlatform } from '@storecraft/
|
20
|
+
import { NodePlatform } from '@storecraft/core/platform/node';
|
24
21
|
import { MongoDB } from '@storecraft/database-mongodb'
|
25
|
-
import { NodeLocalStorage } from '@storecraft/storage
|
22
|
+
import { NodeLocalStorage } from '@storecraft/core/storage/node'
|
26
23
|
|
27
24
|
const app = new App(
|
28
25
|
{
|
package/index.js
CHANGED
@@ -42,7 +42,7 @@ const connect = async (uri, options) => {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
/**
|
45
|
-
* @typedef {import('@storecraft/core/
|
45
|
+
* @typedef {import('@storecraft/core/database').db_driver} db_driver
|
46
46
|
*
|
47
47
|
*
|
48
48
|
* @implements {db_driver}
|
@@ -178,7 +178,7 @@ export class MongoDB {
|
|
178
178
|
|
179
179
|
/**
|
180
180
|
*
|
181
|
-
* @template {import('@storecraft/core/
|
181
|
+
* @template {import('@storecraft/core/api').BaseType} T
|
182
182
|
*
|
183
183
|
*
|
184
184
|
* @param {string} name
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Db, MongoClient } from 'mongodb';
|
2
2
|
import { MongoDB } from '../index.js'
|
3
|
+
import { templates } from '@storecraft/core/assets/seed-templates.js'
|
3
4
|
|
4
5
|
/**
|
5
6
|
*
|
6
7
|
* @param {Db} db
|
7
8
|
* @param {MongoClient} client
|
8
|
-
* @param {MongoDB} driver
|
9
9
|
*/
|
10
10
|
export async function up(db, client) {
|
11
11
|
|
@@ -17,7 +17,7 @@ export async function up(db, client) {
|
|
17
17
|
const driver = client.__db_driver;
|
18
18
|
|
19
19
|
for (const template of templates) {
|
20
|
-
await driver.resources.templates.upsert(template)
|
20
|
+
await driver.resources.templates.upsert(template, template.search);
|
21
21
|
}
|
22
22
|
}
|
23
23
|
);
|
@@ -33,239 +33,3 @@ export async function up(db, client) {
|
|
33
33
|
*/
|
34
34
|
export async function down(db, client) {
|
35
35
|
}
|
36
|
-
|
37
|
-
|
38
|
-
const templates = [
|
39
|
-
{
|
40
|
-
"title": "Welcome Customer",
|
41
|
-
"template_html": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns=\"http://www.w3.org/1999/xhtml\" style=\"color-scheme: light dark; supported-color-schemes: light dark;\">\n <head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta name=\"x-apple-disable-message-reformatting\" />\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <meta name=\"supported-color-schemes\" content=\"light dark\" />\n <title></title>\n <style type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n /* Base ------------------------------ */\n \n @import url(\"https://fonts.googleapis.com/css?family=Nunito+Sans:400,700&display=swap\");\n body {\n width: 100% !important;\n height: 100%;\n margin: 0;\n -webkit-text-size-adjust: none;\n }\n \n a {\n color: #3869D4;\n }\n \n a img {\n border: none;\n }\n \n td {\n word-break: break-word;\n }\n \n .preheader {\n display: none !important;\n visibility: hidden;\n mso-hide: all;\n font-size: 1px;\n line-height: 1px;\n max-height: 0;\n max-width: 0;\n opacity: 0;\n overflow: hidden;\n }\n /* Type ------------------------------ */\n \n body,\n td,\n th {\n font-family: \"Nunito Sans\", Helvetica, Arial, sans-serif;\n }\n \n h1 {\n margin-top: 0;\n color: #333333;\n font-size: 22px;\n font-weight: bold;\n text-align: left;\n }\n \n h2 {\n margin-top: 0;\n color: #333333;\n font-size: 16px;\n font-weight: bold;\n text-align: left;\n }\n \n h3 {\n margin-top: 0;\n color: #333333;\n font-size: 14px;\n font-weight: bold;\n text-align: left;\n }\n \n td,\n th {\n font-size: 16px;\n }\n \n p,\n ul,\n ol,\n blockquote {\n margin: .4em 0 1.1875em;\n font-size: 16px;\n line-height: 1.625;\n }\n \n p.sub {\n font-size: 13px;\n }\n /* Utilities ------------------------------ */\n \n .align-right {\n text-align: right;\n }\n \n .align-left {\n text-align: left;\n }\n \n .align-center {\n text-align: center;\n }\n \n .u-margin-bottom-none {\n margin-bottom: 0;\n }\n /* Buttons ------------------------------ */\n \n .button {\n background-color: #3869D4;\n border-top: 10px solid #3869D4;\n border-right: 18px solid #3869D4;\n border-bottom: 10px solid #3869D4;\n border-left: 18px solid #3869D4;\n display: inline-block;\n color: #FFF;\n text-decoration: none;\n border-radius: 3px;\n box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16);\n -webkit-text-size-adjust: none;\n box-sizing: border-box;\n }\n \n .button--green {\n background-color: #22BC66;\n border-top: 10px solid #22BC66;\n border-right: 18px solid #22BC66;\n border-bottom: 10px solid #22BC66;\n border-left: 18px solid #22BC66;\n }\n \n .button--red {\n background-color: #FF6136;\n border-top: 10px solid #FF6136;\n border-right: 18px solid #FF6136;\n border-bottom: 10px solid #FF6136;\n border-left: 18px solid #FF6136;\n }\n \n @media only screen and (max-width: 500px) {\n .button {\n width: 100% !important;\n text-align: center !important;\n }\n }\n /* Attribute list ------------------------------ */\n \n .attributes {\n margin: 0 0 21px;\n }\n \n .attributes_content {\n background-color: #F4F4F7;\n padding: 16px;\n }\n \n .attributes_item {\n padding: 0;\n }\n /* Related Items ------------------------------ */\n \n .related {\n width: 100%;\n margin: 0;\n padding: 25px 0 0 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .related_item {\n padding: 10px 0;\n color: #CBCCCF;\n font-size: 15px;\n line-height: 18px;\n }\n \n .related_item-title {\n display: block;\n margin: .5em 0 0;\n }\n \n .related_item-thumb {\n display: block;\n padding-bottom: 10px;\n }\n \n .related_heading {\n border-top: 1px solid #CBCCCF;\n text-align: center;\n padding: 25px 0 10px;\n }\n /* Discount Code ------------------------------ */\n \n .discount {\n width: 100%;\n margin: 0;\n padding: 24px;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #F4F4F7;\n border: 2px dashed #CBCCCF;\n }\n \n .discount_heading {\n text-align: center;\n }\n \n .discount_body {\n text-align: center;\n font-size: 15px;\n }\n /* Social Icons ------------------------------ */\n \n .social {\n width: auto;\n }\n \n .social td {\n padding: 0;\n width: auto;\n }\n \n .social_icon {\n height: 20px;\n margin: 0 8px 10px 8px;\n padding: 0;\n }\n /* Data table ------------------------------ */\n \n .purchase {\n width: 100%;\n margin: 0;\n padding: 35px 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .purchase_content {\n width: 100%;\n margin: 0;\n padding: 25px 0 0 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .purchase_item {\n padding: 10px 0;\n color: #51545E;\n font-size: 15px;\n line-height: 18px;\n }\n \n .purchase_heading {\n padding-bottom: 8px;\n border-bottom: 1px solid #EAEAEC;\n }\n \n .purchase_heading p {\n margin: 0;\n color: #85878E;\n font-size: 12px;\n }\n \n .purchase_footer {\n padding-top: 15px;\n border-top: 1px solid #EAEAEC;\n }\n \n .purchase_total {\n margin: 0;\n text-align: right;\n font-weight: bold;\n color: #333333;\n }\n \n .purchase_total--label {\n padding: 0 15px 0 0;\n }\n \n body {\n background-color: #F4F4F7;\n color: #51545E;\n }\n \n p {\n color: #51545E;\n }\n \n p.sub {\n color: #6B6E76;\n }\n \n .email-wrapper {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #F4F4F7;\n }\n \n .email-content {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n /* Masthead ----------------------- */\n \n .email-masthead {\n padding: 25px 0;\n text-align: center;\n }\n \n .email-masthead_logo {\n width: 94px;\n }\n \n .email-masthead_name {\n font-size: 16px;\n font-weight: bold;\n color: #A8AAAF;\n text-decoration: none;\n text-shadow: 0 1px 0 white;\n }\n /* Body ------------------------------ */\n \n .email-body {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #FFFFFF;\n }\n \n .email-body_inner {\n width: 570px;\n margin: 0 auto;\n padding: 0;\n -premailer-width: 570px;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #FFFFFF;\n }\n \n .email-footer {\n width: 570px;\n margin: 0 auto;\n padding: 0;\n -premailer-width: 570px;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n text-align: center;\n }\n \n .email-footer p {\n color: #6B6E76;\n }\n \n .body-action {\n width: 100%;\n margin: 30px auto;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n text-align: center;\n }\n \n .body-sub {\n margin-top: 25px;\n padding-top: 25px;\n border-top: 1px solid #EAEAEC;\n }\n \n .content-cell {\n padding: 35px;\n }\n /*Media Queries ------------------------------ */\n \n @media only screen and (max-width: 600px) {\n .email-body_inner,\n .email-footer {\n width: 100% !important;\n }\n }\n \n @media (prefers-color-scheme: dark) {\n body,\n .email-body,\n .email-body_inner,\n .email-content,\n .email-wrapper,\n .email-masthead,\n .email-footer {\n background-color: #333333 !important;\n color: #FFF !important;\n }\n p,\n ul,\n ol,\n blockquote,\n h1,\n h2,\n h3,\n span,\n .purchase_item {\n color: #FFF !important;\n }\n .attributes_content,\n .discount {\n background-color: #222 !important;\n }\n .email-masthead_name {\n text-shadow: none !important;\n }\n }\n \n :root {\n color-scheme: light dark;\n supported-color-schemes: light dark;\n }\n </style>\n <!--[if mso]>\n <style type=\"text/css\">\n .f-fallback {\n font-family: Arial, sans-serif;\n }\n </style>\n <![endif]-->\n <style type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n body {\n width: 100% !important;\n height: 100%;\n margin: 0;\n -webkit-text-size-adjust: none;\n }\n \n body {\n font-family: \"Nunito Sans\", Helvetica, Arial, sans-serif;\n }\n \n body {\n background-color: #F4F4F7;\n color: #51545E;\n }\n </style>\n </head>\n <body style=\"width: 100% !important; height: 100%; -webkit-text-size-adjust: none; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; background-color: #F4F4F7; color: #51545E; margin: 0;\" bgcolor=\"#F4F4F7\">\n <span class=\"preheader\" style=\"display: none !important; visibility: hidden; mso-hide: all; font-size: 1px; line-height: 1px; max-height: 0; max-width: 0; opacity: 0; overflow: hidden;\">Thanks for signing up with us. We’re thrilled to have you on board.</span>\n <table class=\"email-wrapper\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #F4F4F7; margin: 0; padding: 0;\" bgcolor=\"#F4F4F7\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <table class=\"email-content\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; margin: 0; padding: 0;\">\n <tr>\n <td class=\"email-masthead\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; text-align: center; padding: 25px 0;\" align=\"center\">\n <a href=\"{{info.general_store_website}}\" class=\"f-fallback email-masthead_name\" style=\"color: #A8AAAF; font-size: 16px; font-weight: bold; text-decoration: none; text-shadow: 0 1px 0 white;\">\n {{info.general_store_name}}\n </a>\n </td>\n </tr>\n <!-- Email Body -->\n <tr>\n <td class=\"email-body\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #FFFFFF; margin: 0; padding: 0;\" bgcolor=\"#FFFFFF\">\n <table class=\"email-body_inner\" align=\"center\" width=\"570\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 570px; -premailer-width: 570px; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #FFFFFF; margin: 0 auto; padding: 0;\" bgcolor=\"#FFFFFF\">\n <!-- Body content -->\n <tr>\n <td class=\"content-cell\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding: 35px;\">\n <div class=\"f-fallback\">\n <h1 style=\"margin-top: 0; color: #333333; font-size: 22px; font-weight: bold; text-align: left;\" align=\"left\">Welcome, {{customer.firstname}}!</h1>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">Thanks for signing up with us. We’re thrilled to have you on board.</p>\n <!-- Action -->\n <table class=\"body-action\" align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; text-align: center; margin: 30px auto; padding: 0;\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <!-- Border based button\n https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -->\n <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" role=\"presentation\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <a href=\"{{info.general_confirm_email_base_url}}/user={{customer.id}}\" class=\"f-fallback button\" target=\"_blank\" style=\"color: #FFF; background-color: #3869D4; display: inline-block; text-decoration: none; border-radius: 3px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16); -webkit-text-size-adjust: none; box-sizing: border-box; border-color: #3869D4; border-style: solid; border-width: 10px 18px;\">Confirm your email</a>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">For reference, here's your login information:</p>\n <table class=\"attributes\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"margin: 0 0 21px;\">\n <tr>\n <td class=\"attributes_content\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; background-color: #F4F4F7; padding: 16px;\" bgcolor=\"#F4F4F7\">\n <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\">\n <tr>\n <td class=\"attributes_item\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding: 0;\">\n <span class=\"f-fallback\">\n <strong>User ID:</strong> {{customer.id}}\n </span>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">Need help, or have any questions ? Simply reply to this email, we'd love to help</p>\n <!-- Sub copy -->\n \n </div>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <table class=\"email-footer\" align=\"center\" width=\"570\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 570px; -premailer-width: 570px; -premailer-cellpadding: 0; -premailer-cellspacing: 0; text-align: center; margin: 0 auto; padding: 0;\">\n <tr>\n <td class=\"content-cell\" align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding: 35px;\">\n <p class=\"f-fallback sub align-center\" style=\"font-size: 13px; line-height: 1.625; text-align: center; color: #6B6E76; margin: .4em 0 1.1875em;\" align=\"center\">\n {{info.general_store_name}}\n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </body>\n</html>",
|
42
|
-
"template_text": "Thanks for signing up with us. \nWe’re thrilled to have you on board.\n\n******************\nWelcome, {{customer.firstname}}!\n******************\n\nThanks for signing up with us. We’re thrilled to \nhave you on board.\n\nConfirm your email here: \n{{ info.general_confirm_email_base_url }}/user={{customer.id}}\n\nFor reference, here's your login information:\n\nUser ID: {{customer.id}}\n\nNeed help, or have any questions ?\nSimply reply to this email, we'd love to help\n\n[{{info.general_store_name}}] ({{info.general_store_website}})\n",
|
43
|
-
"reference_example_input": {
|
44
|
-
"customer": {
|
45
|
-
"email": "john@dow.com",
|
46
|
-
"firstname": "John",
|
47
|
-
"lastname": "Dow",
|
48
|
-
"id": "cus_65f2ae6e8bf30e6cd0ca95fa"
|
49
|
-
},
|
50
|
-
"info": {
|
51
|
-
"general_store_name": "Wush Wush Games",
|
52
|
-
"general_store_website": "https://wush.games/",
|
53
|
-
"general_store_description": "We sell retro video games",
|
54
|
-
"general_confirm_email_base_url": "https://wush.games/confirm-email"
|
55
|
-
}
|
56
|
-
},
|
57
|
-
"handle": "welcome-customer",
|
58
|
-
"id": "template_664afed24eba71b9ee185be4",
|
59
|
-
"created_at": "2024-05-20T07:42:10.436Z",
|
60
|
-
"updated_at": "2024-05-20T09:39:46.492Z",
|
61
|
-
"_relations": {
|
62
|
-
"search": [
|
63
|
-
"handle:welcome-customer",
|
64
|
-
"welcome-customer",
|
65
|
-
"id:template_664afed24eba71b9ee185be4",
|
66
|
-
"template_664afed24eba71b9ee185be4",
|
67
|
-
"664afed24eba71b9ee185be4",
|
68
|
-
"welcome",
|
69
|
-
"customer",
|
70
|
-
"welcome customer"
|
71
|
-
]
|
72
|
-
}
|
73
|
-
},
|
74
|
-
{
|
75
|
-
"title": "Checkout Complete",
|
76
|
-
"template_html": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns=\"http://www.w3.org/1999/xhtml\" style=\"color-scheme: light dark; supported-color-schemes: light dark;\">\n <head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta name=\"x-apple-disable-message-reformatting\" />\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <meta name=\"color-scheme\" content=\"light dark\" />\n <meta name=\"supported-color-schemes\" content=\"light dark\" />\n <title></title>\n <style type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n /* Base ------------------------------ */\n \n @import url(\"https://fonts.googleapis.com/css?family=Nunito+Sans:400,700&display=swap\");\n body {\n width: 100% !important;\n height: 100%;\n margin: 0;\n -webkit-text-size-adjust: none;\n }\n \n a {\n color: #3869D4;\n }\n \n a img {\n border: none;\n }\n \n td {\n word-break: break-word;\n }\n \n .preheader {\n display: none !important;\n visibility: hidden;\n mso-hide: all;\n font-size: 1px;\n line-height: 1px;\n max-height: 0;\n max-width: 0;\n opacity: 0;\n overflow: hidden;\n }\n /* Type ------------------------------ */\n \n body,\n td,\n th {\n font-family: \"Nunito Sans\", Helvetica, Arial, sans-serif;\n }\n \n h1 {\n margin-top: 0;\n color: #333333;\n font-size: 22px;\n font-weight: bold;\n text-align: left;\n }\n \n h2 {\n margin-top: 0;\n color: #333333;\n font-size: 16px;\n font-weight: bold;\n text-align: left;\n }\n \n h3 {\n margin-top: 0;\n color: #333333;\n font-size: 14px;\n font-weight: bold;\n text-align: left;\n }\n \n td,\n th {\n font-size: 16px;\n }\n \n p,\n ul,\n ol,\n blockquote {\n margin: .4em 0 1.1875em;\n font-size: 16px;\n line-height: 1.625;\n }\n \n p.sub {\n font-size: 13px;\n }\n /* Utilities ------------------------------ */\n \n .align-right {\n text-align: right;\n }\n \n .align-left {\n text-align: left;\n }\n \n .align-center {\n text-align: center;\n }\n \n .u-margin-bottom-none {\n margin-bottom: 0;\n }\n /* Buttons ------------------------------ */\n \n .button {\n background-color: #3869D4;\n border-top: 10px solid #3869D4;\n border-right: 18px solid #3869D4;\n border-bottom: 10px solid #3869D4;\n border-left: 18px solid #3869D4;\n display: inline-block;\n color: #FFF;\n text-decoration: none;\n border-radius: 3px;\n box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16);\n -webkit-text-size-adjust: none;\n box-sizing: border-box;\n }\n \n .button--green {\n background-color: #22BC66;\n border-top: 10px solid #22BC66;\n border-right: 18px solid #22BC66;\n border-bottom: 10px solid #22BC66;\n border-left: 18px solid #22BC66;\n }\n \n .button--red {\n background-color: #FF6136;\n border-top: 10px solid #FF6136;\n border-right: 18px solid #FF6136;\n border-bottom: 10px solid #FF6136;\n border-left: 18px solid #FF6136;\n }\n \n @media only screen and (max-width: 500px) {\n .button {\n width: 100% !important;\n text-align: center !important;\n }\n }\n /* Attribute list ------------------------------ */\n \n .attributes {\n margin: 0 0 21px;\n }\n \n .attributes_content {\n background-color: #F4F4F7;\n padding: 16px;\n }\n \n .attributes_item {\n padding: 0;\n }\n /* Related Items ------------------------------ */\n \n .related {\n width: 100%;\n margin: 0;\n padding: 25px 0 0 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .related_item {\n padding: 10px 0;\n color: #CBCCCF;\n font-size: 15px;\n line-height: 18px;\n }\n \n .related_item-title {\n display: block;\n margin: .5em 0 0;\n }\n \n .related_item-thumb {\n display: block;\n padding-bottom: 10px;\n }\n \n .related_heading {\n border-top: 1px solid #CBCCCF;\n text-align: center;\n padding: 25px 0 10px;\n }\n /* Discount Code ------------------------------ */\n \n .discount {\n width: 100%;\n margin: 0;\n padding: 24px;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #F4F4F7;\n border: 2px dashed #CBCCCF;\n }\n \n .discount_heading {\n text-align: center;\n }\n \n .discount_body {\n text-align: center;\n font-size: 15px;\n }\n /* Social Icons ------------------------------ */\n \n .social {\n width: auto;\n }\n \n .social td {\n padding: 0;\n width: auto;\n }\n \n .social_icon {\n height: 20px;\n margin: 0 8px 10px 8px;\n padding: 0;\n }\n /* Data table ------------------------------ */\n \n .purchase {\n width: 100%;\n margin: 0;\n padding: 35px 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .purchase_content {\n width: 100%;\n margin: 0;\n padding: 25px 0 0 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n \n .purchase_item {\n padding: 10px 0;\n color: #51545E;\n font-size: 15px;\n line-height: 18px;\n }\n \n .purchase_heading {\n padding-bottom: 8px;\n border-bottom: 1px solid #EAEAEC;\n }\n \n .purchase_heading p {\n margin: 0;\n color: #85878E;\n font-size: 12px;\n }\n \n .purchase_footer {\n padding-top: 15px;\n border-top: 1px solid #EAEAEC;\n }\n \n .purchase_total {\n margin: 0;\n text-align: right;\n font-weight: bold;\n color: #333333;\n }\n \n .purchase_total--label {\n padding: 0 15px 0 0;\n }\n \n body {\n background-color: #F4F4F7;\n color: #51545E;\n }\n \n p {\n color: #51545E;\n }\n \n p.sub {\n color: #6B6E76;\n }\n \n .email-wrapper {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #F4F4F7;\n }\n \n .email-content {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n }\n /* Masthead ----------------------- */\n \n .email-masthead {\n padding: 25px 0;\n text-align: center;\n }\n \n .email-masthead_logo {\n width: 94px;\n }\n \n .email-masthead_name {\n font-size: 16px;\n font-weight: bold;\n color: #A8AAAF;\n text-decoration: none;\n text-shadow: 0 1px 0 white;\n }\n /* Body ------------------------------ */\n \n .email-body {\n width: 100%;\n margin: 0;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #FFFFFF;\n }\n \n .email-body_inner {\n width: 570px;\n margin: 0 auto;\n padding: 0;\n -premailer-width: 570px;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n background-color: #FFFFFF;\n }\n \n .email-footer {\n width: 570px;\n margin: 0 auto;\n padding: 0;\n -premailer-width: 570px;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n text-align: center;\n }\n \n .email-footer p {\n color: #6B6E76;\n }\n \n .body-action {\n width: 100%;\n margin: 30px auto;\n padding: 0;\n -premailer-width: 100%;\n -premailer-cellpadding: 0;\n -premailer-cellspacing: 0;\n text-align: center;\n }\n \n .body-sub {\n margin-top: 25px;\n padding-top: 25px;\n border-top: 1px solid #EAEAEC;\n }\n \n .content-cell {\n padding: 35px;\n }\n /*Media Queries ------------------------------ */\n \n @media only screen and (max-width: 600px) {\n .email-body_inner,\n .email-footer {\n width: 100% !important;\n }\n }\n \n @media (prefers-color-scheme: dark) {\n body,\n .email-body,\n .email-body_inner,\n .email-content,\n .email-wrapper,\n .email-masthead,\n .email-footer {\n background-color: #333333 !important;\n color: #FFF !important;\n }\n p,\n ul,\n ol,\n blockquote,\n h1,\n h2,\n h3,\n span,\n .purchase_item {\n color: #FFF !important;\n }\n .attributes_content,\n .discount {\n background-color: #222 !important;\n }\n .email-masthead_name {\n text-shadow: none !important;\n }\n }\n \n :root {\n color-scheme: light dark;\n supported-color-schemes: light dark;\n }\n </style>\n <!--[if mso]>\n <style type=\"text/css\">\n .f-fallback {\n font-family: Arial, sans-serif;\n }\n </style>\n <![endif]-->\n <style type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n body {\n width: 100% !important;\n height: 100%;\n margin: 0;\n -webkit-text-size-adjust: none;\n }\n \n body {\n font-family: \"Nunito Sans\", Helvetica, Arial, sans-serif;\n }\n \n body {\n background-color: #F4F4F7;\n color: #51545E;\n }\n </style>\n </head>\n <body style=\"width: 100% !important; height: 100%; -webkit-text-size-adjust: none; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; background-color: #F4F4F7; color: #51545E; margin: 0;\" bgcolor=\"#F4F4F7\">\n <table class=\"email-wrapper\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #F4F4F7; margin: 0; padding: 0;\" bgcolor=\"#F4F4F7\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <table class=\"email-content\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; margin: 0; padding: 0;\">\n <tr>\n <td class=\"email-masthead\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; text-align: center; padding: 25px 0;\" align=\"center\">\n <a href=\"{{info.general_store_website}}\" class=\"f-fallback email-masthead_name\" style=\"color: #A8AAAF; font-size: 16px; font-weight: bold; text-decoration: none; text-shadow: 0 1px 0 white;\">\n {{info.general_store_name}}\n </a>\n </td>\n </tr>\n <!-- Email Body -->\n <tr>\n <td class=\"email-body\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #FFFFFF; margin: 0; padding: 0;\" bgcolor=\"#FFFFFF\">\n <table class=\"email-body_inner\" align=\"center\" width=\"570\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 570px; -premailer-width: 570px; -premailer-cellpadding: 0; -premailer-cellspacing: 0; background-color: #FFFFFF; margin: 0 auto; padding: 0;\" bgcolor=\"#FFFFFF\">\n <!-- Body content -->\n <tr>\n <td class=\"content-cell\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding: 35px;\">\n <div class=\"f-fallback\">\n <h1 style=\"margin-top: 0; color: #333333; font-size: 22px; font-weight: bold; text-align: left;\" align=\"left\">Hi {{order.contact.firstname}},</h1>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">Thank you for your purchase. This email is the receipt for your purchase.</p>\n <table class=\"purchase\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; margin: 0; padding: 0px 0;\">\n <tr>\n <td style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <h3 style=\"margin-top: 0; color: #333333; font-size: 14px; font-weight: bold; text-align: left;\" align=\"left\">{{order.id}}</h3></td>\n \n </tr>\n <tr>\n <td colspan=\"2\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <table class=\"purchase_content\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; margin: 0; padding: 25px 0 0;\">\n <tr>\n <th class=\"purchase_heading\" align=\"left\" style=\"font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-bottom: 8px; border-bottom-width: 1px; border-bottom-color: #EAEAEC; border-bottom-style: solid;\">\n <p class=\"f-fallback\" style=\"font-size: 12px; line-height: 1.625; color: #85878E; margin: 0;\">Description</p>\n </th>\n <th class=\"purchase_heading\" align=\"right\" style=\"font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-bottom: 8px; border-bottom-width: 1px; border-bottom-color: #EAEAEC; border-bottom-style: solid;\">\n <p class=\"f-fallback\" style=\"font-size: 12px; line-height: 1.625; color: #85878E; margin: 0;\">Amount</p>\n </th>\n </tr>\n {{#each order.line_items}}\n <tr>\n <td width=\"80%\" class=\"purchase_item\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 15px; color: #51545E; line-height: 18px; padding: 10px 0;\"><span class=\"f-fallback\">{{data.title}}</span></td>\n <td class=\"align-right\" width=\"20%\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; text-align: right;\" align=\"right\"><span class=\"f-fallback\">{{qty}}</span></td>\n </tr>\n {{/each}}\n <tr>\n <td width=\"80%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total purchase_total--label\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0; padding: 0 15px 0 0;\" align=\"right\">Shipping</p>\n </td>\n <td width=\"20%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0;\" align=\"right\">{{order.shipping_method.price}}</p>\n </td>\n </tr>\n <tr>\n <td width=\"80%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total purchase_total--label\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0; padding: 0 15px 0 0;\" align=\"right\">Subtotal Discounts</p>\n </td>\n <td width=\"20%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0;\" align=\"right\">-{{order.pricing.subtotal_discount}}</p>\n </td>\n </tr>\n <tr>\n <td width=\"80%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total purchase_total--label\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0; padding: 0 15px 0 0;\" align=\"right\">Total</p>\n </td>\n <td width=\"20%\" class=\"purchase_footer\" valign=\"middle\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding-top: 15px; border-top-width: 1px; border-top-color: #EAEAEC; border-top-style: solid;\">\n <p class=\"f-fallback purchase_total\" style=\"font-size: 16px; line-height: 1.625; text-align: right; font-weight: bold; color: #333333; margin: 0;\" align=\"right\">{{order.pricing.total}}</p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">If you have any questions about this receipt, simply reply to this email or reach out to our <a href=\"{{info.general_store_support_email}}\" style=\"color: #3869D4;\">support team</a> for help.</p>\n <p style=\"font-size: 16px; line-height: 1.625; color: #51545E; margin: .4em 0 1.1875em;\">Cheers,\n <br />The {{info.general_store_name}} team</p>\n <!-- Action -->\n <table class=\"body-action\" align=\"center\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 100%; -premailer-width: 100%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; text-align: center; margin: 30px auto; padding: 0;\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <!-- Border based button\n https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -->\n <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" role=\"presentation\">\n <tr>\n <td align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <a href=\"{{action_url}}\" class=\"f-fallback button button--blue\" target=\"_blank\" style=\"color: #FFF; background-color: #3869D4; display: inline-block; text-decoration: none; border-radius: 3px; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16); -webkit-text-size-adjust: none; box-sizing: border-box; border-color: #3869D4; border-style: solid; border-width: 10px 18px;\">Download as PDF</a>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n <!-- Sub copy -->\n \n </div>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px;\">\n <table class=\"email-footer\" align=\"center\" width=\"570\" cellpadding=\"0\" cellspacing=\"0\" role=\"presentation\" style=\"width: 570px; -premailer-width: 570px; -premailer-cellpadding: 0; -premailer-cellspacing: 0; text-align: center; margin: 0 auto; padding: 0;\">\n <tr>\n <td class=\"content-cell\" align=\"center\" style=\"word-break: break-word; font-family: "Nunito Sans", Helvetica, Arial, sans-serif; font-size: 16px; padding: 35px;\">\n <p class=\"f-fallback sub align-center\" style=\"font-size: 13px; line-height: 1.625; text-align: center; color: #6B6E76; margin: .4em 0 1.1875em;\" align=\"center\">\n {{info.general_store_name}} \n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </body>\n</html>",
|
77
|
-
"template_text": "[{{info.general_store_name}}] ({{info.general_store_website}})\n\n************\nHi {{order.contact.firstname}},\n************\n\nThank you for your purchase !!!\n\n\nOrder ID is {{order.id}}\n--------------\n\n{{date}}\n--------\n\nDescription\n\nItems\n{{#each order.line_items}}\n- {{data.title}} x {{qty}}\n{{/each}}\n\nShipping \n{{order.shipping_method.title}}, {{order.shipping_method.price}}\n\nDiscounts\n{{#each order.pricing.evo}}\n- {{discount.title}} - {{total_discount}}\n{{/each}}\n\nTotal\n{{order.pricing.total}}\n\nIf you have any questions about this receipt, simply reply to this \nemail or reach out to our support team ( {{ info.general_store_support_email }} ) for help.\n\nCheers,\nThe {{info.general_store_name}} team\n\n\n{{info.general_store_name}}\n{{info.general_store_website}}",
|
78
|
-
"reference_example_input": {
|
79
|
-
"order": {
|
80
|
-
"contact": {
|
81
|
-
"email": "john@doe.com",
|
82
|
-
"firstname": "John",
|
83
|
-
"phone_number": "000-000-000",
|
84
|
-
"customer_id": "cus_65f2ae6e8bf30e6cd0ca95fa"
|
85
|
-
},
|
86
|
-
"address": {},
|
87
|
-
"status": {
|
88
|
-
"checkout": {
|
89
|
-
"id": 0,
|
90
|
-
"name2": "created",
|
91
|
-
"name": "Created"
|
92
|
-
},
|
93
|
-
"payment": {
|
94
|
-
"id": 1,
|
95
|
-
"name": "Authorized",
|
96
|
-
"name2": "authorized"
|
97
|
-
},
|
98
|
-
"fulfillment": {
|
99
|
-
"id": 0,
|
100
|
-
"name2": "draft",
|
101
|
-
"name": "Draft"
|
102
|
-
}
|
103
|
-
},
|
104
|
-
"pricing": {
|
105
|
-
"evo": [
|
106
|
-
{
|
107
|
-
"quantity_discounted": 0,
|
108
|
-
"quantity_undiscounted": 11,
|
109
|
-
"subtotal": 1100,
|
110
|
-
"total": 1150
|
111
|
-
},
|
112
|
-
{
|
113
|
-
"quantity_discounted": 2,
|
114
|
-
"total_discount": 100,
|
115
|
-
"quantity_undiscounted": 9,
|
116
|
-
"discount": {
|
117
|
-
"active": true,
|
118
|
-
"handle": "discount-bundle-50-off-robot-arms-and-legs-not-recursive",
|
119
|
-
"title": "50% OFF Bundle: robot arms and legs (not recursive)",
|
120
|
-
"priority": 0,
|
121
|
-
"application": {
|
122
|
-
"id": 0,
|
123
|
-
"name": "Automatic",
|
124
|
-
"name2": "automatic"
|
125
|
-
},
|
126
|
-
"info": {
|
127
|
-
"details": {
|
128
|
-
"meta": {
|
129
|
-
"id": 4,
|
130
|
-
"type": "bundle",
|
131
|
-
"name": "Bundle Discount"
|
132
|
-
},
|
133
|
-
"extra": {
|
134
|
-
"fixed": 0,
|
135
|
-
"percent": 50,
|
136
|
-
"recursive": false
|
137
|
-
}
|
138
|
-
},
|
139
|
-
"filters": [
|
140
|
-
{
|
141
|
-
"meta": {
|
142
|
-
"id": 4,
|
143
|
-
"type": "product",
|
144
|
-
"op": "p-in-tags",
|
145
|
-
"name": "Product has Tag"
|
146
|
-
},
|
147
|
-
"value": [
|
148
|
-
"robot_arm"
|
149
|
-
]
|
150
|
-
},
|
151
|
-
{
|
152
|
-
"meta": {
|
153
|
-
"id": 4,
|
154
|
-
"type": "product",
|
155
|
-
"op": "p-in-tags",
|
156
|
-
"name": "Product has Tag"
|
157
|
-
},
|
158
|
-
"value": [
|
159
|
-
"robot_leg"
|
160
|
-
]
|
161
|
-
}
|
162
|
-
]
|
163
|
-
}
|
164
|
-
},
|
165
|
-
"discount_code": "discount-bundle-50-off-robot-arms-and-legs-not-recursive",
|
166
|
-
"subtotal": 1000,
|
167
|
-
"total": 1050
|
168
|
-
}
|
169
|
-
],
|
170
|
-
"shipping_method": {
|
171
|
-
"title": "",
|
172
|
-
"handle": "",
|
173
|
-
"price": 50
|
174
|
-
},
|
175
|
-
"subtotal_discount": 100,
|
176
|
-
"subtotal_undiscounted": 1100,
|
177
|
-
"subtotal": 1000,
|
178
|
-
"total": 1050,
|
179
|
-
"quantity_total": 11,
|
180
|
-
"quantity_discounted": 2,
|
181
|
-
"errors": []
|
182
|
-
},
|
183
|
-
"line_items": [
|
184
|
-
{
|
185
|
-
"id": "robot-leg-white",
|
186
|
-
"qty": 3,
|
187
|
-
"data": {
|
188
|
-
"tags": [
|
189
|
-
"robot_leg"
|
190
|
-
],
|
191
|
-
"qty": 100,
|
192
|
-
"active": true,
|
193
|
-
"title": "Robot Leg White",
|
194
|
-
"price": 100
|
195
|
-
}
|
196
|
-
},
|
197
|
-
{
|
198
|
-
"id": "battery",
|
199
|
-
"qty": 5,
|
200
|
-
"data": {
|
201
|
-
"tags": [
|
202
|
-
"would-not-be-discounted"
|
203
|
-
],
|
204
|
-
"qty": 100,
|
205
|
-
"active": true,
|
206
|
-
"title": "Battery",
|
207
|
-
"price": 100
|
208
|
-
}
|
209
|
-
},
|
210
|
-
{
|
211
|
-
"id": "robot-arm-red",
|
212
|
-
"qty": 2,
|
213
|
-
"data": {
|
214
|
-
"tags": [
|
215
|
-
"robot_arm"
|
216
|
-
],
|
217
|
-
"qty": 100,
|
218
|
-
"active": true,
|
219
|
-
"title": "Robot Arm Red",
|
220
|
-
"price": 100
|
221
|
-
}
|
222
|
-
},
|
223
|
-
{
|
224
|
-
"id": "robot-arm-green",
|
225
|
-
"qty": 1,
|
226
|
-
"data": {
|
227
|
-
"tags": [
|
228
|
-
"robot_arm"
|
229
|
-
],
|
230
|
-
"qty": 100,
|
231
|
-
"active": true,
|
232
|
-
"title": "Robot Arm Green",
|
233
|
-
"price": 100
|
234
|
-
}
|
235
|
-
}
|
236
|
-
],
|
237
|
-
"shipping_method": {
|
238
|
-
"handle": "ship-fast",
|
239
|
-
"title": "ship fast",
|
240
|
-
"price": 50
|
241
|
-
},
|
242
|
-
"id": "order_65d774c6445e4581b9e34c11",
|
243
|
-
"created_at": "2024-02-22T16:22:30.095Z",
|
244
|
-
"updated_at": "2024-02-22T16:22:30.095Z"
|
245
|
-
},
|
246
|
-
"info": {
|
247
|
-
"general_store_name": "Wush Wush Games",
|
248
|
-
"general_store_website": "https://wush.games/",
|
249
|
-
"general_store_description": "We sell retro video games",
|
250
|
-
"general_confirm_email_base_url": "https://wush.games/confirm-email",
|
251
|
-
"general_store_support_email": "support@wush.games"
|
252
|
-
}
|
253
|
-
},
|
254
|
-
"handle": "checkout-complete",
|
255
|
-
"id": "template_664b15174eba71b9ee185be5",
|
256
|
-
"created_at": "2024-05-20T09:17:11.255Z",
|
257
|
-
"updated_at": "2024-05-20T10:43:40.766Z",
|
258
|
-
"_relations": {
|
259
|
-
"search": [
|
260
|
-
"handle:checkout-complete",
|
261
|
-
"checkout-complete",
|
262
|
-
"id:template_664b15174eba71b9ee185be5",
|
263
|
-
"template_664b15174eba71b9ee185be5",
|
264
|
-
"664b15174eba71b9ee185be5",
|
265
|
-
"checkout",
|
266
|
-
"complete",
|
267
|
-
"checkout complete"
|
268
|
-
]
|
269
|
-
}
|
270
|
-
}
|
271
|
-
]
|
package/package.json
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/database-mongodb",
|
3
|
-
"version": "1.0.
|
4
|
-
"description": "
|
3
|
+
"version": "1.0.2",
|
4
|
+
"description": "Storecraft database driver for mongodb on node / bun / deno platform",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
7
7
|
"homepage": "https://github.com/store-craft/storecraft",
|
8
8
|
"repository": {
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/store-craft/storecraft.git",
|
11
|
-
"directory": "packages/database-mongodb"
|
11
|
+
"directory": "packages/databases/database-mongodb"
|
12
12
|
},
|
13
13
|
"keywords": [
|
14
14
|
"commerce",
|
@@ -29,7 +29,6 @@
|
|
29
29
|
"mongodb": "^6.3.0"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@storecraft/test-runner": "^1.0.0",
|
33
32
|
"@types/migrate-mongo": "^10.0.4",
|
34
33
|
"@types/node": "^20.11.0",
|
35
34
|
"dotenv": "^16.3.1",
|
package/src/con.auth_users.js
CHANGED
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
} from './con.shared.js'
|
7
7
|
|
8
8
|
/**
|
9
|
-
* @typedef {import('@storecraft/core/
|
9
|
+
* @typedef {import('@storecraft/core/database').db_auth_users} db_col
|
10
10
|
*/
|
11
11
|
|
12
12
|
/**
|
@@ -22,13 +22,6 @@ const col = (d) => d.collection('auth_users');
|
|
22
22
|
*/
|
23
23
|
const upsert = (driver) => upsert_regular(driver, col(driver));
|
24
24
|
|
25
|
-
/**
|
26
|
-
* @param {MongoDB} driver
|
27
|
-
*
|
28
|
-
*
|
29
|
-
* @returns {db_col["get"]}
|
30
|
-
*/
|
31
|
-
const get2 = (driver) => get_regular(driver, col(driver));
|
32
25
|
|
33
26
|
/**
|
34
27
|
* @param {MongoDB} driver
|
@@ -40,7 +33,7 @@ const get = (driver) => {
|
|
40
33
|
return async (id_or_email) => {
|
41
34
|
const filter = objid_or_else_filter(id_or_email, 'email');
|
42
35
|
|
43
|
-
/** @type {import('@storecraft/core/
|
36
|
+
/** @type {import('@storecraft/core/api').AuthUserType} */
|
44
37
|
const res = await col(driver).findOne(
|
45
38
|
filter
|
46
39
|
);
|
@@ -59,7 +52,7 @@ const getByEmail = (driver) => {
|
|
59
52
|
return async (email) => {
|
60
53
|
const filter = { email: email };
|
61
54
|
|
62
|
-
/** @type {import('@storecraft/core/
|
55
|
+
/** @type {import('@storecraft/core/api').AuthUserType} */
|
63
56
|
const res = await col(driver).findOne(
|
64
57
|
filter
|
65
58
|
);
|
@@ -107,7 +100,7 @@ const remove = (driver) => {
|
|
107
100
|
*/
|
108
101
|
const removeByEmail = (driver) => {
|
109
102
|
return async (email) => {
|
110
|
-
/** @type {import('@storecraft/core/
|
103
|
+
/** @type {import('@storecraft/core/api').AuthUserType} */
|
111
104
|
await col(driver).deleteOne(
|
112
105
|
{ email }
|
113
106
|
);
|
package/src/con.collections.js
CHANGED
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
} from './utils.relations.js'
|
13
13
|
|
14
14
|
/**
|
15
|
-
* @typedef {import('@storecraft/core/
|
15
|
+
* @typedef {import('@storecraft/core/database').db_collections} db_col
|
16
16
|
*/
|
17
17
|
|
18
18
|
|
@@ -183,8 +183,8 @@ const list_collection_products = (driver) => {
|
|
183
183
|
/**
|
184
184
|
* @type {import('mongodb').Filter<
|
185
185
|
* import('./utils.relations.js').WithRelations<
|
186
|
-
* import('@storecraft/core/
|
187
|
-
* import('@storecraft/core/
|
186
|
+
* import('@storecraft/core/api').ProductType |
|
187
|
+
* import('@storecraft/core/api').VariantType
|
188
188
|
* >
|
189
189
|
* >}
|
190
190
|
*/
|
package/src/con.customers.js
CHANGED
@@ -6,7 +6,7 @@ import { isDef, sanitize_array, to_objid } from './utils.funcs.js'
|
|
6
6
|
import { query_to_mongo } from './utils.query.js';
|
7
7
|
|
8
8
|
/**
|
9
|
-
* @typedef {import('@storecraft/core/
|
9
|
+
* @typedef {import('@storecraft/core/database').db_customers} db_col
|
10
10
|
*/
|
11
11
|
|
12
12
|
/**
|
@@ -126,7 +126,7 @@ const list_customer_orders = (driver) => {
|
|
126
126
|
/**
|
127
127
|
* @type {import('mongodb').Filter<
|
128
128
|
* import('./utils.relations.js').WithRelations<
|
129
|
-
* import('@storecraft/core/
|
129
|
+
* import('@storecraft/core/api').OrderData
|
130
130
|
* >
|
131
131
|
* >}
|
132
132
|
*/
|
package/src/con.discounts.js
CHANGED
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
import { discount_to_mongo_conjunctions } from './con.discounts.utils.js'
|
10
10
|
import { query_to_mongo } from './utils.query.js'
|
11
11
|
import { report_document_media } from './con.images.js'
|
12
|
-
import { enums } from '@storecraft/core/
|
12
|
+
import { enums } from '@storecraft/core/api'
|
13
13
|
import {
|
14
14
|
add_search_terms_relation_on, delete_me,
|
15
15
|
remove_entry_from_all_connection_of_relation,
|
@@ -19,7 +19,7 @@ import {
|
|
19
19
|
|
20
20
|
|
21
21
|
/**
|
22
|
-
* @typedef {import('@storecraft/core/
|
22
|
+
* @typedef {import('@storecraft/core/database').db_discounts} db_col
|
23
23
|
*/
|
24
24
|
|
25
25
|
|
@@ -211,8 +211,8 @@ const list_discount_products = (driver) => {
|
|
211
211
|
/**
|
212
212
|
* @type {import('mongodb').Filter<
|
213
213
|
* import('./utils.relations.js').WithRelations<
|
214
|
-
* import('@storecraft/core/
|
215
|
-
* import('@storecraft/core/
|
214
|
+
* import('@storecraft/core/api').ProductType |
|
215
|
+
* import('@storecraft/core/api').VariantType
|
216
216
|
* >
|
217
217
|
* >}
|
218
218
|
*/
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import { enums } from "@storecraft/core/
|
1
|
+
import { enums } from "@storecraft/core/api";
|
2
2
|
import { to_objid_safe } from "./utils.funcs.js";
|
3
3
|
|
4
|
-
/** @param {import("@storecraft/core/
|
4
|
+
/** @param {import("@storecraft/core/api").DiscountType} d */
|
5
5
|
const is_order_discount = d => {
|
6
6
|
return (d.info.details.meta.id===enums.DiscountMetaEnum.order.id);
|
7
7
|
}
|
8
8
|
|
9
|
-
/** @param {import("@storecraft/core/
|
9
|
+
/** @param {import("@storecraft/core/api").DiscountType} d */
|
10
10
|
const is_automatic_discount = d => {
|
11
11
|
return (d.application.id===enums.DiscountApplicationEnum.Auto.id);
|
12
12
|
}
|
@@ -20,7 +20,7 @@ const extract_abs_number = v => {
|
|
20
20
|
* for filtering.
|
21
21
|
*
|
22
22
|
*
|
23
|
-
* @param {import("@storecraft/core/
|
23
|
+
* @param {import("@storecraft/core/api").DiscountType} d
|
24
24
|
*/
|
25
25
|
export const discount_to_mongo_conjunctions = d => {
|
26
26
|
// discount has to be product discount + automatic + active + has filters
|
@@ -40,7 +40,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
40
40
|
break;
|
41
41
|
case enums.FilterMetaEnum.p_in_products.op:
|
42
42
|
{
|
43
|
-
/** @type {import("@storecraft/core/
|
43
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_in_products} */
|
44
44
|
const cast = filter.value ?? [];
|
45
45
|
|
46
46
|
conjunctions.push(
|
@@ -50,7 +50,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
50
50
|
break;
|
51
51
|
case enums.FilterMetaEnum.p_not_in_products.op:
|
52
52
|
{
|
53
|
-
/** @type {import("@storecraft/core/
|
53
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_not_in_products} */
|
54
54
|
const cast = filter.value ?? [];
|
55
55
|
|
56
56
|
conjunctions.push(
|
@@ -60,7 +60,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
60
60
|
break;
|
61
61
|
case enums.FilterMetaEnum.p_in_tags.op:
|
62
62
|
{
|
63
|
-
/** @type {import("@storecraft/core/
|
63
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_in_tags} */
|
64
64
|
const cast = filter.value ?? [];
|
65
65
|
|
66
66
|
conjunctions.push(
|
@@ -70,7 +70,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
70
70
|
break;
|
71
71
|
case enums.FilterMetaEnum.p_not_in_tags.op:
|
72
72
|
{
|
73
|
-
/** @type {import("@storecraft/core/
|
73
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_not_in_tags} */
|
74
74
|
const cast = filter.value ?? [];
|
75
75
|
|
76
76
|
conjunctions.push(
|
@@ -80,7 +80,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
80
80
|
break;
|
81
81
|
case enums.FilterMetaEnum.p_in_collections.op:
|
82
82
|
{
|
83
|
-
/** @type {import("@storecraft/core/
|
83
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_in_collections} */
|
84
84
|
const cast = filter.value ?? [];
|
85
85
|
|
86
86
|
conjunctions.push(
|
@@ -94,7 +94,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
94
94
|
break;
|
95
95
|
case enums.FilterMetaEnum.p_not_in_collections.op:
|
96
96
|
{
|
97
|
-
/** @type {import("@storecraft/core/
|
97
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_not_in_collections} */
|
98
98
|
const cast = filter.value ?? [];
|
99
99
|
|
100
100
|
conjunctions.push(
|
@@ -108,7 +108,7 @@ export const discount_to_mongo_conjunctions = d => {
|
|
108
108
|
break;
|
109
109
|
case enums.FilterMetaEnum.p_in_price_range.op:
|
110
110
|
{
|
111
|
-
/** @type {import("@storecraft/core/
|
111
|
+
/** @type {import("@storecraft/core/api").FilterValue_p_in_price_range} */
|
112
112
|
const cast = {
|
113
113
|
from: 0,
|
114
114
|
to: Number.POSITIVE_INFINITY,
|
package/src/con.images.js
CHANGED
@@ -3,14 +3,14 @@ import { MongoDB } from '../index.js'
|
|
3
3
|
import { count_regular, get_regular, list_regular,
|
4
4
|
upsert_regular } from './con.shared.js'
|
5
5
|
import { handle_or_id, to_objid } from './utils.funcs.js';
|
6
|
-
import { func } from '@storecraft/core/
|
7
|
-
import { ID } from '@storecraft/core/
|
6
|
+
import { func } from '@storecraft/core/api';
|
7
|
+
import { ID } from '@storecraft/core/api/utils.func.js';
|
8
8
|
import {
|
9
9
|
image_url_to_handle, image_url_to_name
|
10
|
-
} from '@storecraft/core/
|
10
|
+
} from '@storecraft/core/api/con.images.logic.js';
|
11
11
|
|
12
12
|
/**
|
13
|
-
* @typedef {import('@storecraft/core/
|
13
|
+
* @typedef {import('@storecraft/core/database').db_images} db_col
|
14
14
|
*/
|
15
15
|
|
16
16
|
/**
|
@@ -106,7 +106,7 @@ export const report_document_media = (driver) => {
|
|
106
106
|
*
|
107
107
|
*
|
108
108
|
* @returns {import('mongodb').AnyBulkWriteOperation<
|
109
|
-
* import('@storecraft/core/
|
109
|
+
* import('@storecraft/core/api').ImageType>
|
110
110
|
* }
|
111
111
|
*/
|
112
112
|
const url_to_update = url => {
|
package/src/con.notifications.js
CHANGED
@@ -4,10 +4,10 @@ import { count_regular, get_regular, list_regular,
|
|
4
4
|
remove_regular, upsert_regular } from './con.shared.js'
|
5
5
|
import { to_objid } from './utils.funcs.js';
|
6
6
|
import { add_search_terms_relation_on } from './utils.relations.js';
|
7
|
-
import { union } from '@storecraft/core/
|
7
|
+
import { union } from '@storecraft/core/api/utils.func.js';
|
8
8
|
|
9
9
|
/**
|
10
|
-
* @typedef {import('@storecraft/core/
|
10
|
+
* @typedef {import('@storecraft/core/database').db_notifications} db_col
|
11
11
|
*/
|
12
12
|
|
13
13
|
/**
|
package/src/con.orders.js
CHANGED
@@ -4,7 +4,7 @@ import { count_regular, get_regular, list_regular,
|
|
4
4
|
remove_regular, upsert_regular } from './con.shared.js'
|
5
5
|
|
6
6
|
/**
|
7
|
-
* @typedef {import('@storecraft/core/
|
7
|
+
* @typedef {import('@storecraft/core/database').db_orders} db_col
|
8
8
|
*/
|
9
9
|
|
10
10
|
/**
|
package/src/con.posts.js
CHANGED
package/src/con.products.js
CHANGED
@@ -18,15 +18,15 @@ import {
|
|
18
18
|
update_specific_connection_of_relation,
|
19
19
|
update_specific_connection_of_relation_with_filter
|
20
20
|
} from './utils.relations.js'
|
21
|
-
import { enums } from '@storecraft/core/
|
21
|
+
import { enums } from '@storecraft/core/api'
|
22
22
|
import { report_document_media } from './con.images.js'
|
23
|
-
import { union } from '@storecraft/core/
|
23
|
+
import { union } from '@storecraft/core/api/utils.func.js'
|
24
24
|
import {
|
25
25
|
test_product_filters_against_product
|
26
|
-
} from '@storecraft/core/
|
26
|
+
} from '@storecraft/core/api/con.pricing.logic.js'
|
27
27
|
|
28
28
|
/**
|
29
|
-
* @typedef {import('@storecraft/core/
|
29
|
+
* @typedef {import('@storecraft/core/database').db_products} db_col
|
30
30
|
*/
|
31
31
|
|
32
32
|
/**
|
@@ -304,7 +304,7 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
304
304
|
*/
|
305
305
|
const list_product_collections = (driver) => {
|
306
306
|
return async (product) => {
|
307
|
-
/** @type {import('@storecraft/core/
|
307
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
308
308
|
const options = {
|
309
309
|
expand: ['collections']
|
310
310
|
};
|
@@ -329,7 +329,7 @@ const list_product_collections = (driver) => {
|
|
329
329
|
*/
|
330
330
|
const list_product_variants = (driver) => {
|
331
331
|
return async (product) => {
|
332
|
-
/** @type {import('@storecraft/core/
|
332
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
333
333
|
const options = {
|
334
334
|
expand: ['variants']
|
335
335
|
};
|
@@ -359,7 +359,7 @@ const list_product_variants = (driver) => {
|
|
359
359
|
*/
|
360
360
|
const list_related_products = (driver) => {
|
361
361
|
return async (product) => {
|
362
|
-
/** @type {import('@storecraft/core/
|
362
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
363
363
|
const options = {
|
364
364
|
expand: ['related_products']
|
365
365
|
};
|
@@ -380,7 +380,7 @@ const list_related_products = (driver) => {
|
|
380
380
|
*/
|
381
381
|
const list_product_discounts = (driver) => {
|
382
382
|
return async (product) => {
|
383
|
-
/** @type {import('@storecraft/core/
|
383
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
384
384
|
const options = {
|
385
385
|
expand: ['discounts']
|
386
386
|
};
|
@@ -464,8 +464,8 @@ const changeStockOfBy = (driver) => {
|
|
464
464
|
/**
|
465
465
|
* @type {import('mongodb').AnyBulkWriteOperation<
|
466
466
|
* import('./utils.relations.js').WithRelations<
|
467
|
-
* import('@storecraft/core/
|
468
|
-
* import('@storecraft/core/
|
467
|
+
* import('@storecraft/core/api').ProductType |
|
468
|
+
* import('@storecraft/core/api').VariantType
|
469
469
|
* >
|
470
470
|
* >[]}
|
471
471
|
*/
|
package/src/con.search.js
CHANGED
@@ -2,13 +2,13 @@ import { MongoDB } from '../index.js'
|
|
2
2
|
import { query_to_mongo } from './utils.query.js';
|
3
3
|
|
4
4
|
/**
|
5
|
-
* @typedef {import('@storecraft/core/
|
5
|
+
* @typedef {import('@storecraft/core/database').search} db_col
|
6
6
|
*/
|
7
7
|
|
8
8
|
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @type {(keyof import('@storecraft/core/
|
11
|
+
* @type {(keyof import('@storecraft/core/database').db_driver["resources"])[]}
|
12
12
|
*/
|
13
13
|
const tables = [
|
14
14
|
'tags',
|
@@ -26,7 +26,7 @@ const tables = [
|
|
26
26
|
]
|
27
27
|
|
28
28
|
/**
|
29
|
-
* @type {Record<string, keyof import('@storecraft/core/
|
29
|
+
* @type {Record<string, keyof import('@storecraft/core/database').db_driver["resources"]>}
|
30
30
|
*/
|
31
31
|
const prefix_to_resource = {
|
32
32
|
'au': 'auth_users',
|
@@ -49,7 +49,7 @@ const prefix_to_resource = {
|
|
49
49
|
*
|
50
50
|
* @param {string} id
|
51
51
|
*
|
52
|
-
* @returns {keyof import('@storecraft/core/
|
52
|
+
* @returns {keyof import('@storecraft/core/database').db_driver["resources"]}
|
53
53
|
*/
|
54
54
|
export const id_to_resource = id => {
|
55
55
|
let result = undefined;
|
@@ -102,7 +102,7 @@ export const quicksearch = (driver) => {
|
|
102
102
|
|
103
103
|
const db = driver.mongo_client.db();
|
104
104
|
|
105
|
-
/** @type {import('@storecraft/core/
|
105
|
+
/** @type {import('@storecraft/core/api').QuickSearchResource[]} */
|
106
106
|
const items = await db.collection(tables_filtered[0]).aggregate(
|
107
107
|
[
|
108
108
|
...pipeline,
|
@@ -123,7 +123,7 @@ export const quicksearch = (driver) => {
|
|
123
123
|
).toArray();
|
124
124
|
|
125
125
|
|
126
|
-
/** @type {import('@storecraft/core/
|
126
|
+
/** @type {import('@storecraft/core/api').QuickSearchResult} */
|
127
127
|
const result = {};
|
128
128
|
|
129
129
|
items.reduce(
|
package/src/con.shared.js
CHANGED
@@ -8,15 +8,15 @@ import { add_search_terms_relation_on } from './utils.relations.js'
|
|
8
8
|
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @template {import('@storecraft/core/
|
12
|
-
* @template {import('@storecraft/core/
|
11
|
+
* @template {import('@storecraft/core/api').BaseType} T
|
12
|
+
* @template {import('@storecraft/core/api').BaseType} G
|
13
13
|
*
|
14
14
|
*
|
15
15
|
* @param {MongoDB} driver
|
16
16
|
* @param {Collection<G>} col
|
17
17
|
*
|
18
18
|
*
|
19
|
-
* @returns {import('@storecraft/core/
|
19
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["upsert"]}
|
20
20
|
*
|
21
21
|
*/
|
22
22
|
export const upsert_regular = (driver, col) => {
|
@@ -87,7 +87,7 @@ export const get_relations_names = item => {
|
|
87
87
|
*
|
88
88
|
*
|
89
89
|
* @param {import('./utils.relations.js').WithRelations<T>[]} items
|
90
|
-
* @param {import('@storecraft/core/
|
90
|
+
* @param {import('@storecraft/core/api').ExpandQuery} [expand_query]
|
91
91
|
*
|
92
92
|
*/
|
93
93
|
export const expand = (items, expand_query=undefined) => {
|
@@ -142,7 +142,7 @@ export const zeroed_relations = {
|
|
142
142
|
|
143
143
|
/**
|
144
144
|
*
|
145
|
-
* @param {import('@storecraft/core/
|
145
|
+
* @param {import('@storecraft/core/database').RegularGetOptions["expand"]} expand
|
146
146
|
*/
|
147
147
|
export const expand_to_mongo_projection = (expand) => {
|
148
148
|
let projection = {}
|
@@ -168,7 +168,7 @@ export const expand_to_mongo_projection = (expand) => {
|
|
168
168
|
* @param {Collection<G>} col
|
169
169
|
*
|
170
170
|
*
|
171
|
-
* @returns {import('@storecraft/core/
|
171
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["get"]}
|
172
172
|
*/
|
173
173
|
export const get_regular = (driver, col) => {
|
174
174
|
return async (id_or_handle, options) => {
|
@@ -194,15 +194,15 @@ export const get_regular = (driver, col) => {
|
|
194
194
|
* should be instead
|
195
195
|
*
|
196
196
|
*
|
197
|
-
* @template {import('@storecraft/core/
|
198
|
-
* @template {import('@storecraft/core/
|
197
|
+
* @template {import('@storecraft/core/api').idable} T
|
198
|
+
* @template {import('@storecraft/core/api').idable} G
|
199
199
|
*
|
200
200
|
*
|
201
201
|
* @param {MongoDB} driver
|
202
202
|
* @param {Collection<G>} col
|
203
203
|
*
|
204
204
|
*
|
205
|
-
* @returns {import('@storecraft/core/
|
205
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["getBulk"]}
|
206
206
|
*/
|
207
207
|
export const get_bulk = (driver, col) => {
|
208
208
|
return async (ids, options) => {
|
@@ -247,7 +247,7 @@ export const get_bulk = (driver, col) => {
|
|
247
247
|
* @param {Collection<G>} col
|
248
248
|
*
|
249
249
|
*
|
250
|
-
* @returns {import('@storecraft/core/
|
250
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["remove"]}
|
251
251
|
*/
|
252
252
|
export const remove_regular = (driver, col) => {
|
253
253
|
return async (id_or_handle) => {
|
@@ -269,7 +269,7 @@ export const remove_regular = (driver, col) => {
|
|
269
269
|
* @param {Collection<G>} col
|
270
270
|
*
|
271
271
|
*
|
272
|
-
* @returns {import('@storecraft/core/
|
272
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["list"]}
|
273
273
|
*/
|
274
274
|
export const list_regular = (driver, col) => {
|
275
275
|
return async (query) => {
|
@@ -313,7 +313,7 @@ export const list_regular = (driver, col) => {
|
|
313
313
|
* @param {Collection<G>} col
|
314
314
|
*
|
315
315
|
*
|
316
|
-
* @returns {import('@storecraft/core/
|
316
|
+
* @returns {import('@storecraft/core/database').db_crud<T, G>["count"]}
|
317
317
|
*/
|
318
318
|
export const count_regular = (driver, col) => {
|
319
319
|
return async (query) => {
|
package/src/con.shipping.js
CHANGED
package/src/con.storefronts.js
CHANGED
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
import { report_document_media } from './con.images.js';
|
10
10
|
|
11
11
|
/**
|
12
|
-
* @typedef {import('@storecraft/core/
|
12
|
+
* @typedef {import('@storecraft/core/database').db_storefronts} db_col
|
13
13
|
*/
|
14
14
|
|
15
15
|
/**
|
@@ -113,7 +113,7 @@ const count = (driver) => count_regular(driver, col(driver));
|
|
113
113
|
*/
|
114
114
|
const list_storefront_products = (driver) => {
|
115
115
|
return async (product) => {
|
116
|
-
/** @type {import('@storecraft/core/
|
116
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
117
117
|
const options = {
|
118
118
|
expand: ['products']
|
119
119
|
};
|
@@ -132,7 +132,7 @@ const list_storefront_products = (driver) => {
|
|
132
132
|
*/
|
133
133
|
const list_storefront_collections = (driver) => {
|
134
134
|
return async (product) => {
|
135
|
-
/** @type {import('@storecraft/core/
|
135
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
136
136
|
const options = {
|
137
137
|
expand: ['collections']
|
138
138
|
};
|
@@ -151,7 +151,7 @@ const list_storefront_collections = (driver) => {
|
|
151
151
|
*/
|
152
152
|
const list_storefront_discounts = (driver) => {
|
153
153
|
return async (product) => {
|
154
|
-
/** @type {import('@storecraft/core/
|
154
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
155
155
|
const options = {
|
156
156
|
expand: ['discounts']
|
157
157
|
};
|
@@ -169,7 +169,7 @@ const list_storefront_discounts = (driver) => {
|
|
169
169
|
*/
|
170
170
|
const list_storefront_shipping_methods = (driver) => {
|
171
171
|
return async (product) => {
|
172
|
-
/** @type {import('@storecraft/core/
|
172
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
173
173
|
const options = {
|
174
174
|
expand: ['shipping_methods']
|
175
175
|
};
|
@@ -188,7 +188,7 @@ const list_storefront_shipping_methods = (driver) => {
|
|
188
188
|
*/
|
189
189
|
const list_storefront_posts = (driver) => {
|
190
190
|
return async (product) => {
|
191
|
-
/** @type {import('@storecraft/core/
|
191
|
+
/** @type {import('@storecraft/core/database').RegularGetOptions} */
|
192
192
|
const options = {
|
193
193
|
expand: ['posts']
|
194
194
|
};
|
package/src/con.tags.js
CHANGED
package/src/con.templates.js
CHANGED
@@ -4,7 +4,7 @@ import { count_regular, get_regular, list_regular,
|
|
4
4
|
remove_regular, upsert_regular } from './con.shared.js'
|
5
5
|
|
6
6
|
/**
|
7
|
-
* @typedef {import('@storecraft/core/
|
7
|
+
* @typedef {import('@storecraft/core/database').db_templates} db_col
|
8
8
|
*/
|
9
9
|
|
10
10
|
|
package/src/utils.query.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { to_objid } from "./utils.funcs.js";
|
2
|
-
import { parse } from "@storecraft/core/
|
2
|
+
import { parse } from "@storecraft/core/vql";
|
3
3
|
|
4
4
|
let a = {
|
5
5
|
$or: [
|
@@ -17,7 +17,7 @@ let a = {
|
|
17
17
|
* 4. (a1, a2, a3) >= (b1, b2, b3) ==> (a1 > b1) || (a1=b1 & a2>b2) || (a1=b1 & a2=b2 & a3>=b3)
|
18
18
|
*
|
19
19
|
*
|
20
|
-
* @param {import("@storecraft/core/
|
20
|
+
* @param {import("@storecraft/core/api").Cursor} c
|
21
21
|
* @param {'>' | '>=' | '<' | '<='} relation
|
22
22
|
* @param {(x: [k: string, v: any]) => [k: string, v: any]} transformer
|
23
23
|
* Your chance to change key and value
|
@@ -70,7 +70,7 @@ export const query_cursor_to_mongo = (c, relation, transformer=(x)=>x) => {
|
|
70
70
|
}
|
71
71
|
|
72
72
|
/**
|
73
|
-
* @param {import("@storecraft/core/
|
73
|
+
* @param {import("@storecraft/core/vql").VQL.Node} node
|
74
74
|
*/
|
75
75
|
export const query_vql_node_to_mongo = node => {
|
76
76
|
if(node.op==='LEAF') {
|
@@ -106,7 +106,7 @@ export const query_vql_node_to_mongo = node => {
|
|
106
106
|
|
107
107
|
/**
|
108
108
|
*
|
109
|
-
* @param {import("@storecraft/core/
|
109
|
+
* @param {import("@storecraft/core/vql").VQL.Node} root
|
110
110
|
*/
|
111
111
|
export const query_vql_to_mongo = root => {
|
112
112
|
return root ? query_vql_node_to_mongo(root) : undefined;
|
@@ -116,7 +116,7 @@ export const query_vql_to_mongo = root => {
|
|
116
116
|
* Let's transform ids into mongo ids
|
117
117
|
*
|
118
118
|
*
|
119
|
-
* @param {import("@storecraft/core/
|
119
|
+
* @param {import("@storecraft/core/api").Tuple<string>} c a cursor record
|
120
120
|
*
|
121
121
|
*
|
122
122
|
* @returns {[k: string, v: any]}
|
@@ -131,7 +131,7 @@ const transform = c => {
|
|
131
131
|
* Convert an API Query into mongo dialect, also sanitize.
|
132
132
|
*
|
133
133
|
*
|
134
|
-
* @param {import("@storecraft/core/
|
134
|
+
* @param {import("@storecraft/core/api").ApiQuery} q
|
135
135
|
*/
|
136
136
|
export const query_to_mongo = (q) => {
|
137
137
|
try {
|
package/src/utils.relations.js
CHANGED
@@ -10,7 +10,7 @@ import { zeroed_relations } from './con.shared.js';
|
|
10
10
|
* @typedef {Object} Relation
|
11
11
|
* @property {ObjectId[]} [ids]
|
12
12
|
* @property {Record<
|
13
|
-
* import('@storecraft/core/
|
13
|
+
* import('@storecraft/core/database').ID, T>
|
14
14
|
* } [entries]
|
15
15
|
*/
|
16
16
|
|
@@ -27,7 +27,7 @@ import { zeroed_relations } from './con.shared.js';
|
|
27
27
|
* Basically creates an ids array and embedded documents for fast retrival.
|
28
28
|
*
|
29
29
|
*
|
30
|
-
* @template {import('@storecraft/core/
|
30
|
+
* @template {import('@storecraft/core/api').BaseType} T
|
31
31
|
*
|
32
32
|
*
|
33
33
|
* @param {MongoDB} driver our driver
|
@@ -50,7 +50,7 @@ export const create_explicit_relation = async (
|
|
50
50
|
if(isUndef(value))
|
51
51
|
return data;
|
52
52
|
|
53
|
-
/** @type {import('@storecraft/core/
|
53
|
+
/** @type {import('@storecraft/core/api').BaseType[]} */
|
54
54
|
const items = Array.isArray(value) ? value : [value];
|
55
55
|
|
56
56
|
/** @type {WithRelations<any>} */
|
package/tests/runner.test.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { App } from '@storecraft/core';
|
2
2
|
import { MongoDB, migrateToLatest } from '@storecraft/database-mongodb';
|
3
|
-
import { NodePlatform } from '@storecraft/
|
4
|
-
import
|
3
|
+
import { NodePlatform } from '@storecraft/core/platform/node';
|
4
|
+
import { api } from '@storecraft/core/test-runner';
|
5
5
|
|
6
6
|
export const create_app = async () => {
|
7
7
|
const app = new App(
|
@@ -22,12 +22,12 @@ async function test() {
|
|
22
22
|
|
23
23
|
await migrateToLatest(app.db, false);
|
24
24
|
|
25
|
-
Object.entries(
|
25
|
+
Object.entries(api).slice(0, -1).forEach(
|
26
26
|
([name, runner]) => {
|
27
27
|
runner.create(app).run();
|
28
28
|
}
|
29
29
|
);
|
30
|
-
const last_test = Object.values(
|
30
|
+
const last_test = Object.values(api).at(-1).create(app);
|
31
31
|
last_test.after(async ()=>{app.db.disconnect()});
|
32
32
|
last_test.run();
|
33
33
|
}
|
package/tests/sandbox.test.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { App } from '@storecraft/core';
|
2
2
|
import { MongoDB } from '@storecraft/database-mongodb';
|
3
3
|
import { migrateToLatest } from '@storecraft/database-mongodb/migrate.js';
|
4
|
-
import { NodePlatform } from '@storecraft/
|
4
|
+
import { NodePlatform } from '@storecraft/core/platform/node';
|
5
5
|
|
6
6
|
export const create_app = async () => {
|
7
7
|
const app = new App(
|