nitro-web 0.0.1

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.
Files changed (152) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintrc.json +86 -0
  3. package/_example/.env-example +16 -0
  4. package/_example/client/config.ts +5 -0
  5. package/_example/client/css/index.css +35 -0
  6. package/_example/client/fonts/Roboto-Bold.ttf +0 -0
  7. package/_example/client/fonts/Roboto-BoldItalic.ttf +0 -0
  8. package/_example/client/fonts/Roboto-Italic.ttf +0 -0
  9. package/_example/client/fonts/Roboto-Medium.ttf +0 -0
  10. package/_example/client/fonts/Roboto-MediumItalic.ttf +0 -0
  11. package/_example/client/fonts/Roboto-Regular.ttf +0 -0
  12. package/_example/client/fonts/inter-v13-latin-300.woff2 +0 -0
  13. package/_example/client/fonts/inter-v13-latin-500.woff2 +0 -0
  14. package/_example/client/fonts/inter-v13-latin-600.woff2 +0 -0
  15. package/_example/client/fonts/inter-v13-latin-700.woff2 +0 -0
  16. package/_example/client/fonts/inter-v13-latin-800.woff2 +0 -0
  17. package/_example/client/fonts/inter-v13-latin-900.woff2 +0 -0
  18. package/_example/client/fonts/inter-v13-latin-regular.woff2 +0 -0
  19. package/_example/client/imgs/android-chrome-512x512.png +0 -0
  20. package/_example/client/imgs/favicon.png +0 -0
  21. package/_example/client/imgs/icons/calendar.svg +3 -0
  22. package/_example/client/imgs/icons/email.svg +6 -0
  23. package/_example/client/imgs/icons/eye-open.svg +4 -0
  24. package/_example/client/imgs/icons/eye.svg +5 -0
  25. package/_example/client/imgs/icons/filter.svg +7 -0
  26. package/_example/client/imgs/icons/left-circle.svg +3 -0
  27. package/_example/client/imgs/icons/left.svg +3 -0
  28. package/_example/client/imgs/icons/line-options.svg +5 -0
  29. package/_example/client/imgs/icons/line.svg +3 -0
  30. package/_example/client/imgs/icons/person.svg +7 -0
  31. package/_example/client/imgs/icons/plus-circle.svg +5 -0
  32. package/_example/client/imgs/icons/plus.svg +5 -0
  33. package/_example/client/imgs/icons/right-circle.svg +3 -0
  34. package/_example/client/imgs/icons/right.svg +3 -0
  35. package/_example/client/imgs/icons/search.svg +3 -0
  36. package/_example/client/imgs/icons/shield.svg +6 -0
  37. package/_example/client/imgs/icons/tick-circle-solid.svg +8 -0
  38. package/_example/client/imgs/icons/tick-circle.svg +6 -0
  39. package/_example/client/imgs/icons/tick.svg +5 -0
  40. package/_example/client/imgs/icons/up2-small.svg +4 -0
  41. package/_example/client/imgs/icons/up2.svg +4 -0
  42. package/_example/client/imgs/icons/updown.svg +6 -0
  43. package/_example/client/imgs/icons/v-big-dark.svg +3 -0
  44. package/_example/client/imgs/icons/v-dark.svg +3 -0
  45. package/_example/client/imgs/icons/v.svg +3 -0
  46. package/_example/client/imgs/icons/v2-active.svg +6 -0
  47. package/_example/client/imgs/icons/x1.svg +4 -0
  48. package/_example/client/imgs/logo/logo-white.svg +20 -0
  49. package/_example/client/imgs/logo/logo.svg +20 -0
  50. package/_example/client/imgs/no-image.jpg +0 -0
  51. package/_example/client/imgs/user.jpg +0 -0
  52. package/_example/client/index.html +12 -0
  53. package/_example/client/index.ts +47 -0
  54. package/_example/components/auth.api.js +1 -0
  55. package/_example/components/index.tsx +225 -0
  56. package/_example/components/partials/layouts.tsx +5 -0
  57. package/_example/components/settings.api.js +1 -0
  58. package/_example/server/config.js +120 -0
  59. package/_example/server/email/welcome.html +27 -0
  60. package/_example/server/index.js +32 -0
  61. package/_example/tailwind.config.js +84 -0
  62. package/_example/tsconfig.json +32 -0
  63. package/_example/types.d.ts +7 -0
  64. package/_example/webpack.config.js +4 -0
  65. package/client/app.js +300 -0
  66. package/client/css/components.css +84 -0
  67. package/client/css/fonts.css +67 -0
  68. package/client/imgs/icons/calendar.svg +3 -0
  69. package/client/imgs/icons/email.svg +6 -0
  70. package/client/imgs/icons/eye-open.svg +4 -0
  71. package/client/imgs/icons/eye.svg +5 -0
  72. package/client/imgs/icons/filter.svg +7 -0
  73. package/client/imgs/icons/left-circle.svg +3 -0
  74. package/client/imgs/icons/left.svg +3 -0
  75. package/client/imgs/icons/line-options.svg +5 -0
  76. package/client/imgs/icons/line.svg +3 -0
  77. package/client/imgs/icons/person.svg +7 -0
  78. package/client/imgs/icons/plus-circle.svg +5 -0
  79. package/client/imgs/icons/plus.svg +5 -0
  80. package/client/imgs/icons/right-circle.svg +3 -0
  81. package/client/imgs/icons/right.svg +3 -0
  82. package/client/imgs/icons/search.svg +3 -0
  83. package/client/imgs/icons/shield.svg +6 -0
  84. package/client/imgs/icons/tick-circle-solid.svg +8 -0
  85. package/client/imgs/icons/tick-circle.svg +6 -0
  86. package/client/imgs/icons/tick.svg +5 -0
  87. package/client/imgs/icons/up2-small.svg +4 -0
  88. package/client/imgs/icons/up2.svg +4 -0
  89. package/client/imgs/icons/updown.svg +6 -0
  90. package/client/imgs/icons/v-big-dark.svg +3 -0
  91. package/client/imgs/icons/v-dark.svg +3 -0
  92. package/client/imgs/icons/v.svg +3 -0
  93. package/client/imgs/icons/v2-active.svg +6 -0
  94. package/client/imgs/icons/x1.svg +4 -0
  95. package/client.js +42 -0
  96. package/components/auth/auth.api.js +419 -0
  97. package/components/auth/reset.jsx +88 -0
  98. package/components/auth/signin.jsx +74 -0
  99. package/components/auth/signup.jsx +62 -0
  100. package/components/billing/stripe.api.js +267 -0
  101. package/components/partials/element/accordion.jsx +82 -0
  102. package/components/partials/element/avatar.jsx +28 -0
  103. package/components/partials/element/button.jsx +66 -0
  104. package/components/partials/element/dropdown.jsx +185 -0
  105. package/components/partials/element/initials.jsx +56 -0
  106. package/components/partials/element/message.jsx +124 -0
  107. package/components/partials/element/modal.jsx +229 -0
  108. package/components/partials/element/sidebar.jsx +166 -0
  109. package/components/partials/element/tooltip.jsx +146 -0
  110. package/components/partials/element/topbar.jsx +25 -0
  111. package/components/partials/form/checkbox.jsx +74 -0
  112. package/components/partials/form/drop-handler.jsx +62 -0
  113. package/components/partials/form/drop.jsx +125 -0
  114. package/components/partials/form/form-error.jsx +21 -0
  115. package/components/partials/form/input-color.jsx +77 -0
  116. package/components/partials/form/input-currency.jsx +133 -0
  117. package/components/partials/form/input-date.jsx +223 -0
  118. package/components/partials/form/input.jsx +131 -0
  119. package/components/partials/form/location.jsx +212 -0
  120. package/components/partials/form/select.jsx +369 -0
  121. package/components/partials/form/toggle.jsx +46 -0
  122. package/components/partials/is-first-render.js +15 -0
  123. package/components/partials/layout/layout1.jsx +32 -0
  124. package/components/partials/layout/layout2.jsx +47 -0
  125. package/components/partials/not-found.jsx +7 -0
  126. package/components/partials/styleguide.jsx +252 -0
  127. package/components/settings/settings-account.jsx +143 -0
  128. package/components/settings/settings-business.jsx +121 -0
  129. package/components/settings/settings-team--member.jsx +108 -0
  130. package/components/settings/settings-team.jsx +76 -0
  131. package/components/settings/settings.api.js +54 -0
  132. package/package.json +175 -0
  133. package/readme.md +43 -0
  134. package/server/email/index.js +192 -0
  135. package/server/email/partials/email.css +153 -0
  136. package/server/email/partials/layout1.swig +92 -0
  137. package/server/email/partials/line.swig +8 -0
  138. package/server/email/partials/vert-10.swig +8 -0
  139. package/server/email/partials/vert-15.swig +8 -0
  140. package/server/email/partials/vert-20.swig +8 -0
  141. package/server/email/partials/vert-25.swig +8 -0
  142. package/server/email/partials/vert-30.swig +8 -0
  143. package/server/email/partials/vert-35.swig +8 -0
  144. package/server/email/partials/vert-50.swig +8 -0
  145. package/server/email/reset-password.html +21 -0
  146. package/server/email/welcome.html +21 -0
  147. package/server/models/company.js +76 -0
  148. package/server/models/user.js +45 -0
  149. package/server/router.js +355 -0
  150. package/server.js +20 -0
  151. package/util.js +1145 -0
  152. package/webpack.config.js +302 -0
@@ -0,0 +1,92 @@
1
+ <html>
2
+ <head>
3
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:600,400,300' rel='stylesheet' type='text/css'>
4
+ <!-- Nunjunks global defined in webpack.config -->
5
+ <link href='partials/email.css' rel='stylesheet' type='text/css'>
6
+ </head>
7
+
8
+ <body class="email-body">
9
+
10
+ <!-- Email body, bgcolor was F9FBFD -->
11
+ <table width="100%" align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0">
12
+ <tbody>
13
+ <tr>
14
+ <td align="center" valign="top" width="100%">
15
+
16
+ <!-- Center container -->
17
+ <table class="table-scale" width="610px" align="center" cellpadding="0" cellspacing="0" border="0">
18
+ <tbody>
19
+ <tr>
20
+ <td>
21
+
22
+ <!-- Header -->
23
+ {% include "./vert-35.swig" %}
24
+ <table class="table-header" width="100%" cellpadding="0" cellspacing="0" border="0">
25
+ <tbody>
26
+ <tr>
27
+ <td width="100%">
28
+ {% include "./vert-25.swig" %}
29
+ <table width="100%" cellpadding="0" cellspacing="0" border="0">
30
+ <tbody>
31
+ <tr>
32
+ <td width="180px" align="left">
33
+ <a href="%recipient.domain%" target="_blank">
34
+ <img src="%recipient.domain%/assets/imgs/logo/logo-white.svg" width="auto" height="22" border="0">
35
+ </a>
36
+ </td>
37
+ <td align="right">
38
+ </td>
39
+ </tr>
40
+ </tbody>
41
+ </table>
42
+ {% include "./vert-25.swig" %}
43
+ </td>
44
+ </tr>
45
+ </tbody>
46
+ </table>
47
+
48
+ <!-- body -->
49
+ <table class="table-body" width="100%" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0">
50
+ <tbody>
51
+ <tr>
52
+ <td width="100%" align="left">
53
+ {% include "./vert-50.swig" %}
54
+
55
+ <!-- content -->
56
+ <table class='table-content' cellpadding="0" cellspacing="0" border="0">
57
+ <tbody>
58
+ <tr>
59
+ <td style="padding-left:50px; padding-right:50px;" align="center" class="content">
60
+ {% block content %}{% endblock %}
61
+ </td>
62
+ </tr>
63
+ </tbody>
64
+ </table>
65
+ <!-- content -->
66
+
67
+ {% include "./vert-50.swig" %}
68
+ {% include "./vert-10.swig" %}
69
+ {% include "./vert-10.swig" %}
70
+ </td>
71
+ </tr>
72
+ </tbody>
73
+ </table>
74
+ <!-- body -->
75
+
76
+ <!-- footer -->
77
+ {% include "./vert-30.swig" %}
78
+
79
+ </td>
80
+ </tr>
81
+ </tbody>
82
+ </table>
83
+ <!-- Center container -->
84
+
85
+ </td>
86
+ </tr>
87
+ </tbody>
88
+ </table>
89
+ <!-- Email body -->
90
+
91
+ </body>
92
+ </html>
@@ -0,0 +1,8 @@
1
+ <!-- VERTICAL SPACER-->
2
+ <table style="background-color: #aab6ff;" width="100%" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="2px"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="10"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="15"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="20"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="28"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="30"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="35"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <!-- Vertical spacer -->
2
+ <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
3
+ <tbody>
4
+ <tr>
5
+ <td width="100%" height="50"></td>
6
+ </tr>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,21 @@
1
+ {% extends "partials/layout1.swig" %}
2
+ {% block content %}
3
+
4
+ [[ subject = Reset your Password ]]
5
+ <b>%recipient.greet%</b>,<br/>
6
+ <br/>
7
+ Looks like you're having trouble signing into your account. If you need to reset your password, simply click the button below:<br/>
8
+ <br/>
9
+ If you didn't request this, feel free to disregard this email.<br/>
10
+ <br/>
11
+ <span mc:edit="button">
12
+ <a class="button" href="%recipient.domain%/reset/%recipient.token%" target="_blank">
13
+ Reset Your Password
14
+ </a>
15
+ </span><br/>
16
+ <br/>
17
+ Thanks,<br/>
18
+ <b>The Nitro Team</b>
19
+
20
+
21
+ {% endblock %}
@@ -0,0 +1,21 @@
1
+ {% extends "partials/layout1.swig" %}
2
+ {% block content %}
3
+
4
+ [[ subject = Welcome to Nitro ]]
5
+ <b>%recipient.greet%</b>,<br/>
6
+ <br/>
7
+ Thanks for trying out Nitro! <br/>
8
+ <br/>
9
+ If you have any feature requests, feedback or questions, please don't hesitate to reach out to us at <a href="mailto:%recipient.replyToEmail%">%recipient.replyToEmail%</a>.<br/>
10
+ <br/>
11
+ <br/>
12
+ <span mc:edit="button">
13
+ <a class="button" href="%recipient.domain%/signin?email=%recipient.email%" target="_blank">
14
+ Account Sign In
15
+ </a>
16
+ </span><br/>
17
+ <br/>
18
+ Thanks,<br/>
19
+ <b>The Nitro Team</b>
20
+
21
+ {% endblock %}
@@ -0,0 +1,76 @@
1
+ import { addressSchema, fullName } from '../../util.js'
2
+
3
+ export default {
4
+
5
+ fields: {
6
+ business: {
7
+ address: addressSchema(),
8
+ country: { type: 'string', default: 'nz', required: true },
9
+ currency: { type: 'string', default: 'nzd', required: true },
10
+ name: { type: 'string', required: true, index: 'text' },
11
+ number: { type: 'string' },
12
+ phone: { type: 'string' },
13
+ website: { type: 'string', isURL: true },
14
+ },
15
+ status: { type: 'string', default: 'active', enum: ['active', 'unpaid', 'deleted'] },
16
+ users: [{
17
+ _id: { model: 'user' },
18
+ role: { type: 'string', enum: ['owner', 'manager', 'accountant'] },
19
+ status: { type: 'string', required: true, enum: ['invited', 'active', 'deleted'] },
20
+ inviteEmail: { type: 'string' },
21
+ inviteToken: { type: 'string' },
22
+ }],
23
+ },
24
+
25
+ findBL: ['users.inviteToken'],
26
+ updateBL: ['status', 'users'],
27
+
28
+ afterFind: [
29
+ async function (data) {
30
+ if (!data) return
31
+ // Merge expanded users into users
32
+ if (data.usersExpanded) {
33
+ for (let i=data.users.length; i--;) {
34
+ const user = data.users[i]
35
+ const userExpanded = data.usersExpanded.find(o => String(o._id) == String(user._id))
36
+ // console.log(userExpanded)
37
+ if (user.inviteEmail) user.email = user.inviteEmail
38
+ if (userExpanded) Object.assign(user, { ...userExpanded, name: fullName(userExpanded) })
39
+ }
40
+ delete data.usersExpanded
41
+ }
42
+ },
43
+ ],
44
+
45
+ methods: {
46
+ publicData: function(models) {
47
+ return models
48
+ },
49
+ loginPopulate: function() {
50
+ // return the company with expanded company.users
51
+ return [
52
+ {
53
+ as: 'usersExpanded',
54
+ from: 'user',
55
+ let: { users: '$users' }, // company.users
56
+ pipeline: [
57
+ {
58
+ $match: {
59
+ $expr: { $in: ['$_id', '$$users._id'] },
60
+ },
61
+ },
62
+ {
63
+ $project: {
64
+ 'createdAt': 1,
65
+ 'email': 1,
66
+ 'firstName': 1,
67
+ 'lastName': 1,
68
+ 'avatar': 1,
69
+ },
70
+ },
71
+ ],
72
+ },
73
+ ]
74
+ },
75
+ },
76
+ }
@@ -0,0 +1,45 @@
1
+ import { ucFirst, fullName } from '../../util.js'
2
+
3
+ export default {
4
+
5
+ fields: {
6
+ avatar: { type: 'image' },
7
+ company: { model: 'company', required: true },
8
+ email: { type: 'email', required: true, index: 'unique' },
9
+ firstName: { type: 'string', required: true },
10
+ lastName: { type: 'string' },
11
+ password: { type: 'string', minLength: 6, required: true },
12
+ resetToken: { type: 'string' },
13
+ status: { type: 'string', default: 'active', enum: ['active', 'deleted', 'inactive'] },
14
+ stripeCustomer: { type: 'any' },
15
+ stripeSubscription: { type: 'any' },
16
+ stripeIntents: { type: 'any' },
17
+ type: { type: 'string', default: 'user', enum: ['user', 'admin'] },
18
+ usedFreeTrial: { type: 'boolean', default: false },
19
+ },
20
+
21
+ findBL: ['password', 'resetToken'],
22
+ updateBL: ['company', 'password', 'resetToken', 'status', 'stripeSubscription', 'type', 'usedFreeTrial'],
23
+
24
+ beforeValidate: [
25
+ async function (data) {
26
+ if (data.email) data.email = data.email.trim().toLowerCase()
27
+ if (data.firstName) data.firstName = ucFirst(data.firstName)
28
+ if (data.lastName) data.lastName = ucFirst(data.lastName)
29
+ },
30
+ ],
31
+
32
+ afterFind: [
33
+ async function (data) {
34
+ if (!data) return
35
+ data.name = fullName(data)
36
+ },
37
+ ],
38
+
39
+ methods: {
40
+ loginPopulate: function() {
41
+ return []
42
+ },
43
+ },
44
+
45
+ }