ghost 5.18.0 → 5.19.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 (177) hide show
  1. package/README.md +1 -1
  2. package/components/tryghost-adapter-manager-5.19.1.tgz +0 -0
  3. package/components/tryghost-api-framework-5.19.1.tgz +0 -0
  4. package/components/tryghost-api-version-compatibility-service-5.19.1.tgz +0 -0
  5. package/components/tryghost-audience-feedback-5.19.1.tgz +0 -0
  6. package/components/tryghost-bootstrap-socket-5.19.1.tgz +0 -0
  7. package/components/tryghost-constants-5.19.1.tgz +0 -0
  8. package/components/tryghost-custom-theme-settings-service-5.19.1.tgz +0 -0
  9. package/components/tryghost-domain-events-5.19.1.tgz +0 -0
  10. package/components/tryghost-email-analytics-provider-mailgun-5.19.1.tgz +0 -0
  11. package/components/tryghost-email-analytics-service-5.19.1.tgz +0 -0
  12. package/components/tryghost-email-content-generator-5.19.1.tgz +0 -0
  13. package/components/tryghost-express-dynamic-redirects-5.19.1.tgz +0 -0
  14. package/components/tryghost-extract-api-key-5.19.1.tgz +0 -0
  15. package/components/tryghost-html-to-plaintext-5.19.1.tgz +0 -0
  16. package/components/{tryghost-job-manager-5.18.0.tgz → tryghost-job-manager-5.19.1.tgz} +0 -0
  17. package/components/tryghost-link-redirects-5.19.1.tgz +0 -0
  18. package/components/tryghost-link-replacer-5.19.1.tgz +0 -0
  19. package/components/tryghost-link-tracking-5.19.1.tgz +0 -0
  20. package/components/{tryghost-magic-link-5.18.0.tgz → tryghost-magic-link-5.19.1.tgz} +0 -0
  21. package/components/tryghost-mailgun-client-5.19.1.tgz +0 -0
  22. package/components/tryghost-member-analytics-service-5.19.1.tgz +0 -0
  23. package/components/tryghost-member-attribution-5.19.1.tgz +0 -0
  24. package/components/tryghost-member-events-5.19.1.tgz +0 -0
  25. package/components/tryghost-members-analytics-ingress-5.19.1.tgz +0 -0
  26. package/components/tryghost-members-api-5.19.1.tgz +0 -0
  27. package/components/tryghost-members-csv-5.19.1.tgz +0 -0
  28. package/components/tryghost-members-events-service-5.19.1.tgz +0 -0
  29. package/components/tryghost-members-importer-5.19.1.tgz +0 -0
  30. package/components/tryghost-members-offers-5.19.1.tgz +0 -0
  31. package/components/tryghost-members-payments-5.19.1.tgz +0 -0
  32. package/components/tryghost-members-ssr-5.19.1.tgz +0 -0
  33. package/components/tryghost-members-stripe-service-5.19.1.tgz +0 -0
  34. package/components/tryghost-minifier-5.19.1.tgz +0 -0
  35. package/components/tryghost-mw-api-version-mismatch-5.19.1.tgz +0 -0
  36. package/components/tryghost-mw-cache-control-5.19.1.tgz +0 -0
  37. package/components/{tryghost-mw-error-handler-5.18.0.tgz → tryghost-mw-error-handler-5.19.1.tgz} +0 -0
  38. package/components/tryghost-mw-session-from-token-5.19.1.tgz +0 -0
  39. package/components/tryghost-mw-update-user-last-seen-5.19.1.tgz +0 -0
  40. package/components/tryghost-mw-vhost-5.19.1.tgz +0 -0
  41. package/components/tryghost-oembed-service-5.19.1.tgz +0 -0
  42. package/components/tryghost-package-json-5.19.1.tgz +0 -0
  43. package/components/{tryghost-referrers-5.18.0.tgz → tryghost-referrers-5.19.1.tgz} +0 -0
  44. package/components/tryghost-security-5.19.1.tgz +0 -0
  45. package/components/tryghost-session-service-5.19.1.tgz +0 -0
  46. package/components/tryghost-settings-path-manager-5.19.1.tgz +0 -0
  47. package/components/tryghost-staff-service-5.19.1.tgz +0 -0
  48. package/components/tryghost-stats-service-5.19.1.tgz +0 -0
  49. package/components/tryghost-update-check-service-5.19.1.tgz +0 -0
  50. package/components/tryghost-verification-trigger-5.19.1.tgz +0 -0
  51. package/components/tryghost-version-notifications-data-service-5.19.1.tgz +0 -0
  52. package/core/boot.js +3 -1
  53. package/core/built/admin/assets/{chunk.143.6d23a3157dae7a9c899d.js → chunk.143.af6972210ca7d2bfdcff.js} +6 -6
  54. package/core/built/admin/assets/{chunk.174.e997dfffceeaa0ce4636.js → chunk.174.3a133d51d9b45097c101.js} +31 -31
  55. package/core/built/admin/assets/{chunk.178.52a9ca26217a593eda67.js → chunk.178.6f68a314b66338b41c62.js} +4 -4
  56. package/core/built/admin/assets/{chunk.427.4483d5bbdaf2a65888ac.js → chunk.613.f1d519ad47e7f9024263.js} +40 -47
  57. package/core/built/admin/assets/{chunk.427.4483d5bbdaf2a65888ac.js.LICENSE.txt → chunk.613.f1d519ad47e7f9024263.js.LICENSE.txt} +0 -0
  58. package/core/built/admin/assets/{ghost-7e6e9479705e7e772bb5ea3b6476cd52.js → ghost-5ce6f5a730c83c91fc258b12c537ea35.js} +555 -559
  59. package/core/built/admin/assets/{ghost-ff0bee94743aa886ce35305a5b46fac3.css → ghost-982146a4ada3a5af1981d1919ae01d08.css} +1 -1
  60. package/core/built/admin/assets/{ghost-dark-a41f7645a406e0df78b7152f3f805e66.css → ghost-dark-41929e4857de411a23597a9de49a4e4f.css} +1 -1
  61. package/core/built/admin/assets/{vendor-4da5d2584fbe1442e25e4271a5513f1c.js → vendor-5c7d7063620bec13668c4370145cd4b4.js} +41 -34
  62. package/core/built/admin/index.html +6 -6
  63. package/core/frontend/helpers/t.js +12 -0
  64. package/core/frontend/helpers/tpl/content-cta.hbs +1 -1
  65. package/core/frontend/public/robots.txt +1 -0
  66. package/core/frontend/services/sitemap/handler.js +1 -1
  67. package/core/frontend/services/sitemap/index-generator.js +1 -3
  68. package/core/frontend/src/comment-counts/js/comment-counts.js +8 -0
  69. package/core/server/api/endpoints/feedback-members.js +23 -0
  70. package/core/server/api/endpoints/index.js +5 -1
  71. package/core/server/api/endpoints/utils/serializers/input/posts.js +6 -1
  72. package/core/server/api/endpoints/utils/serializers/output/mappers/posts.js +8 -0
  73. package/core/server/data/exporter/table-lists.js +3 -1
  74. package/core/server/data/importer/handlers/json.js +21 -23
  75. package/core/server/data/importer/importers/data/base.js +1 -1
  76. package/core/server/data/migrations/versions/4.0/05-add-members-subscribe-events-table.js +1 -1
  77. package/core/server/data/migrations/versions/4.0/06-populate-members-subscribe-events-table.js +1 -1
  78. package/core/server/data/migrations/versions/4.0/11-add-members-paid-subscription-events-table.js +1 -1
  79. package/core/server/data/migrations/versions/4.0/13-add-members-payment-events-table.js +1 -1
  80. package/core/server/data/migrations/versions/4.0/17-populate-members-status-events-table.js +1 -1
  81. package/core/server/data/migrations/versions/4.0/22-solve-orphaned-webhooks.js +1 -1
  82. package/core/server/data/migrations/versions/4.0/25-populate-members-paid-subscription-events-table.js +1 -1
  83. package/core/server/data/migrations/versions/4.11/02-add-email-verification-required-setting.js +1 -1
  84. package/core/server/data/migrations/versions/4.12/01-add-email-only-column-to-posts-meta-table.js +1 -1
  85. package/core/server/data/migrations/versions/4.3/03-add-default-product.js +1 -1
  86. package/core/server/data/migrations/versions/4.3/04-attach-members-to-product.js +1 -1
  87. package/core/server/data/migrations/versions/4.3/06-add-stripe-prices-table.js +2 -2
  88. package/core/server/data/migrations/versions/4.3/08-migrate-members-signup-setting.js +1 -1
  89. package/core/server/data/migrations/versions/4.33/2022-01-14-11-51-add-default-free-tier.js +1 -1
  90. package/core/server/data/migrations/versions/4.42/2022-03-21-17-17-add.js +2 -2
  91. package/core/server/data/migrations/versions/4.43/2022-03-28-19-26-recreate-newsletter-table.js +5 -5
  92. package/core/server/data/migrations/versions/4.46/2022-04-13-13-00-add-default-newsletter.js +1 -1
  93. package/core/server/data/migrations/versions/4.46/2022-04-20-08-39-map-subscribers-to-default-newsletter.js +1 -1
  94. package/core/server/data/migrations/versions/4.7/03-add-labs-setting.js +1 -1
  95. package/core/server/data/migrations/versions/4.8/03-add-default-product-portal-products.js +1 -1
  96. package/core/server/data/migrations/versions/4.8/04-migrate-show-newsletter-header-setting.js +1 -1
  97. package/core/server/data/migrations/versions/5.0/2022-05-06-13-22-add-frontend-integration.js +1 -1
  98. package/core/server/data/migrations/versions/5.17/2022-09-29-12-39-add-track-clicks-column-to-emails.js +2 -2
  99. package/core/server/data/migrations/versions/5.19/2022-09-02-20-25-add-columns-to-products-table.js +19 -0
  100. package/core/server/data/migrations/versions/5.19/2022-09-02-20-52-backfill-new-product-columns.js +37 -0
  101. package/core/server/data/migrations/versions/5.19/2022-10-10-06-58-add-subscriptions-table.js +19 -0
  102. package/core/server/data/migrations/versions/5.19/2022-10-10-10-05-add-members-feedback-table.js +10 -0
  103. package/core/server/data/migrations/versions/5.19/2022-10-11-10-38-add-feedback-enabled-column-to-newsletters.js +7 -0
  104. package/core/server/data/schema/commands.js +3 -3
  105. package/core/server/data/schema/fixtures/fixtures.json +4 -1
  106. package/core/server/data/schema/schema.js +90 -24
  107. package/core/server/data/schema/validator.js +1 -1
  108. package/core/server/models/base/bookshelf.js +3 -4
  109. package/core/server/models/base/plugins/data-manipulation.js +1 -1
  110. package/core/server/models/base/plugins/events.js +1 -1
  111. package/core/server/models/base/utils.js +1 -1
  112. package/core/server/models/member-feedback.js +22 -0
  113. package/core/server/models/newsletter.js +3 -2
  114. package/core/server/models/post.js +24 -0
  115. package/core/server/models/settings.js +1 -1
  116. package/core/server/models/user.js +1 -1
  117. package/core/server/services/audience-feedback/FeedbackRepository.js +67 -0
  118. package/core/server/services/audience-feedback/index.js +33 -0
  119. package/core/server/services/bulk-email/bulk-email-processor.js +7 -1
  120. package/core/server/services/mail/GhostMailer.js +17 -1
  121. package/core/server/services/mega/feedback-buttons.js +69 -0
  122. package/core/server/services/mega/mega.js +1 -1
  123. package/core/server/services/mega/post-email-serializer.js +24 -4
  124. package/core/server/services/mega/template.js +3 -0
  125. package/core/server/services/members/middleware.js +40 -0
  126. package/core/server/services/notifications/notifications.js +1 -1
  127. package/core/server/services/settings/settings-service.js +1 -1
  128. package/core/server/services/themes/storage.js +1 -1
  129. package/core/server/web/members/app.js +12 -0
  130. package/core/shared/labs.js +4 -2
  131. package/package.json +111 -111
  132. package/yarn.lock +585 -498
  133. package/components/tryghost-adapter-manager-5.18.0.tgz +0 -0
  134. package/components/tryghost-api-framework-5.18.0.tgz +0 -0
  135. package/components/tryghost-api-version-compatibility-service-5.18.0.tgz +0 -0
  136. package/components/tryghost-bootstrap-socket-5.18.0.tgz +0 -0
  137. package/components/tryghost-constants-5.18.0.tgz +0 -0
  138. package/components/tryghost-custom-theme-settings-service-5.18.0.tgz +0 -0
  139. package/components/tryghost-domain-events-5.18.0.tgz +0 -0
  140. package/components/tryghost-email-analytics-provider-mailgun-5.18.0.tgz +0 -0
  141. package/components/tryghost-email-analytics-service-5.18.0.tgz +0 -0
  142. package/components/tryghost-email-content-generator-5.18.0.tgz +0 -0
  143. package/components/tryghost-express-dynamic-redirects-5.18.0.tgz +0 -0
  144. package/components/tryghost-extract-api-key-5.18.0.tgz +0 -0
  145. package/components/tryghost-html-to-plaintext-5.18.0.tgz +0 -0
  146. package/components/tryghost-link-redirects-5.18.0.tgz +0 -0
  147. package/components/tryghost-link-replacer-5.18.0.tgz +0 -0
  148. package/components/tryghost-link-tracking-5.18.0.tgz +0 -0
  149. package/components/tryghost-mailgun-client-5.18.0.tgz +0 -0
  150. package/components/tryghost-member-analytics-service-5.18.0.tgz +0 -0
  151. package/components/tryghost-member-attribution-5.18.0.tgz +0 -0
  152. package/components/tryghost-member-events-5.18.0.tgz +0 -0
  153. package/components/tryghost-members-analytics-ingress-5.18.0.tgz +0 -0
  154. package/components/tryghost-members-api-5.18.0.tgz +0 -0
  155. package/components/tryghost-members-csv-5.18.0.tgz +0 -0
  156. package/components/tryghost-members-events-service-5.18.0.tgz +0 -0
  157. package/components/tryghost-members-importer-5.18.0.tgz +0 -0
  158. package/components/tryghost-members-offers-5.18.0.tgz +0 -0
  159. package/components/tryghost-members-payments-5.18.0.tgz +0 -0
  160. package/components/tryghost-members-ssr-5.18.0.tgz +0 -0
  161. package/components/tryghost-members-stripe-service-5.18.0.tgz +0 -0
  162. package/components/tryghost-minifier-5.18.0.tgz +0 -0
  163. package/components/tryghost-mw-api-version-mismatch-5.18.0.tgz +0 -0
  164. package/components/tryghost-mw-cache-control-5.18.0.tgz +0 -0
  165. package/components/tryghost-mw-session-from-token-5.18.0.tgz +0 -0
  166. package/components/tryghost-mw-update-user-last-seen-5.18.0.tgz +0 -0
  167. package/components/tryghost-mw-vhost-5.18.0.tgz +0 -0
  168. package/components/tryghost-oembed-service-5.18.0.tgz +0 -0
  169. package/components/tryghost-package-json-5.18.0.tgz +0 -0
  170. package/components/tryghost-security-5.18.0.tgz +0 -0
  171. package/components/tryghost-session-service-5.18.0.tgz +0 -0
  172. package/components/tryghost-settings-path-manager-5.18.0.tgz +0 -0
  173. package/components/tryghost-staff-service-5.18.0.tgz +0 -0
  174. package/components/tryghost-stats-service-5.18.0.tgz +0 -0
  175. package/components/tryghost-update-check-service-5.18.0.tgz +0 -0
  176. package/components/tryghost-verification-trigger-5.18.0.tgz +0 -0
  177. package/components/tryghost-version-notifications-data-service-5.18.0.tgz +0 -0
@@ -1,5 +1,4 @@
1
1
  const _ = require('lodash');
2
- const Promise = require('bluebird');
3
2
  const fs = require('fs-extra');
4
3
  const tpl = require('@tryghost/tpl');
5
4
  const errors = require('@tryghost/errors');
@@ -17,36 +16,35 @@ JSONHandler = {
17
16
  contentTypes: ['application/octet-stream', 'application/json'],
18
17
  directories: [],
19
18
 
20
- loadFile: function (files, startDir) { // eslint-disable-line no-unused-vars
19
+ loadFile: async function (files, startDir) { // eslint-disable-line no-unused-vars
21
20
  // @TODO: Handle multiple JSON files
22
21
  const filePath = files[0].path;
23
22
 
24
- return fs.readFile(filePath).then(function (fileData) {
25
- let importData;
23
+ const fileData = await fs.readFile(filePath);
24
+ let importData;
26
25
 
27
- try {
28
- importData = JSON.parse(fileData);
26
+ try {
27
+ importData = JSON.parse(fileData);
29
28
 
30
- // if importData follows JSON-API format `{ db: [exportedData] }`
31
- if (_.keys(importData).length === 1) {
32
- if (!importData.db || !Array.isArray(importData.db)) {
33
- throw new errors.InternalServerError({
34
- message: tpl(messages.invalidJsonFormat)
35
- });
36
- }
37
-
38
- importData = importData.db[0];
29
+ // if importData follows JSON-API format `{ db: [exportedData] }`
30
+ if (_.keys(importData).length === 1) {
31
+ if (!importData.db || !Array.isArray(importData.db)) {
32
+ throw new errors.InternalServerError({
33
+ message: tpl(messages.invalidJsonFormat)
34
+ });
39
35
  }
40
36
 
41
- return importData;
42
- } catch (err) {
43
- return Promise.reject(new errors.BadRequestError({
44
- err: err,
45
- message: err.message,
46
- help: tpl(messages.checkImportJsonIsValid)
47
- }));
37
+ importData = importData.db[0];
48
38
  }
49
- });
39
+
40
+ return importData;
41
+ } catch (err) {
42
+ throw new errors.BadRequestError({
43
+ err,
44
+ message: err.message,
45
+ help: tpl(messages.checkImportJsonIsValid)
46
+ });
47
+ }
50
48
  }
51
49
  };
52
50
 
@@ -1,7 +1,7 @@
1
1
  const debug = require('@tryghost/debug')('importer:base');
2
2
  const _ = require('lodash');
3
3
  const Promise = require('bluebird');
4
- const ObjectId = require('bson-objectid');
4
+ const ObjectId = require('bson-objectid').default;
5
5
  const errors = require('@tryghost/errors');
6
6
  const {sequence} = require('@tryghost/promise');
7
7
  const models = require('../../../../models');
@@ -3,7 +3,7 @@ const {addTable} = require('../../utils');
3
3
  module.exports = addTable('members_subscribe_events', {
4
4
  id: {type: 'string', maxlength: 24, nullable: false, primary: true},
5
5
  member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true},
6
- subscribed: {type: 'bool', nullable: false, defaultTo: true},
6
+ subscribed: {type: 'boolean', nullable: false, defaultTo: true},
7
7
  created_at: {type: 'dateTime', nullable: false},
8
8
  source: {type: 'string', maxlength: 50, nullable: true}
9
9
  });
@@ -1,5 +1,5 @@
1
1
  const {chunk} = require('lodash');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const {createTransactionalMigration} = require('../../utils');
4
4
  const logging = require('@tryghost/logging');
5
5
 
@@ -5,7 +5,7 @@ module.exports = addTable('members_paid_subscription_events', {
5
5
  member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
6
6
  from_plan: {type: 'string', maxlength: 255, nullable: true},
7
7
  to_plan: {type: 'string', maxlength: 255, nullable: true},
8
- currency: {type: 'string', maxLength: 3, nullable: false},
8
+ currency: {type: 'string', maxlength: 191, nullable: false},
9
9
  source: {type: 'string', maxlength: 50, nullable: false},
10
10
  mrr_delta: {type: 'integer', nullable: false},
11
11
  created_at: {type: 'dateTime', nullable: false}
@@ -4,7 +4,7 @@ module.exports = addTable('members_payment_events', {
4
4
  id: {type: 'string', maxlength: 24, nullable: false, primary: true},
5
5
  member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
6
6
  amount: {type: 'integer', nullable: false},
7
- currency: {type: 'string', maxLength: 3, nullable: false},
7
+ currency: {type: 'string', maxlength: 191, nullable: false},
8
8
  source: {type: 'string', maxlength: 50, nullable: false},
9
9
  created_at: {type: 'dateTime', nullable: false}
10
10
  });
@@ -1,5 +1,5 @@
1
1
  const {chunk} = require('lodash');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const logging = require('@tryghost/logging');
4
4
  const {createTransactionalMigration} = require('../../utils');
5
5
 
@@ -1,6 +1,6 @@
1
1
  const {createIrreversibleMigration} = require('../../utils');
2
2
  const logging = require('@tryghost/logging');
3
- const ObjectID = require('bson-objectid');
3
+ const ObjectID = require('bson-objectid').default;
4
4
  const security = require('@tryghost/security');
5
5
 
6
6
  module.exports = createIrreversibleMigration(
@@ -1,5 +1,5 @@
1
1
  const {chunk} = require('lodash');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const {createTransactionalMigration} = require('../../utils');
4
4
  const logging = require('@tryghost/logging');
5
5
  const errors = require('@tryghost/errors');
@@ -1,4 +1,4 @@
1
- const ObjectID = require('bson-objectid');
1
+ const ObjectID = require('bson-objectid').default;
2
2
  const logging = require('@tryghost/logging');
3
3
  const {createTransactionalMigration} = require('../../utils');
4
4
 
@@ -1,7 +1,7 @@
1
1
  const {createAddColumnMigration} = require('../../utils');
2
2
 
3
3
  module.exports = createAddColumnMigration('posts_meta', 'email_only', {
4
- type: 'bool',
4
+ type: 'boolean',
5
5
  nullable: false,
6
6
  defaultTo: false
7
7
  });
@@ -1,5 +1,5 @@
1
1
  const {createTransactionalMigration} = require('../../utils');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const {slugify} = require('@tryghost/string');
4
4
  const logging = require('@tryghost/logging');
5
5
 
@@ -1,5 +1,5 @@
1
1
  const {createTransactionalMigration} = require('../../utils');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const {chunk} = require('lodash');
4
4
  const logging = require('@tryghost/logging');
5
5
 
@@ -4,9 +4,9 @@ module.exports = addTable('stripe_prices', {
4
4
  id: {type: 'string', maxlength: 24, nullable: false, primary: true},
5
5
  stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true},
6
6
  stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id', cascadeDelete: true},
7
- active: {type: 'bool', nullable: false},
7
+ active: {type: 'boolean', nullable: false},
8
8
  nickname: {type: 'string', maxlength: 50, nullable: true},
9
- currency: {type: 'string', maxLength: 3, nullable: false},
9
+ currency: {type: 'string', maxlength: 191, nullable: false},
10
10
  amount: {type: 'integer', nullable: false},
11
11
  type: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'recurring', validations: {isIn: [['recurring', 'one_time']]}},
12
12
  interval: {type: 'string', maxlength: 50, nullable: true},
@@ -1,6 +1,6 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const {createTransactionalMigration} = require('../../utils');
3
- const ObjectId = require('bson-objectid');
3
+ const ObjectId = require('bson-objectid').default;
4
4
 
5
5
  module.exports = createTransactionalMigration(
6
6
  async function up(connection) {
@@ -1,5 +1,5 @@
1
1
  const {createTransactionalMigration} = require('../../utils');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const {slugify} = require('@tryghost/string');
4
4
  const logging = require('@tryghost/logging');
5
5
 
@@ -12,7 +12,7 @@ module.exports = addTable('newsletters', {
12
12
  sender_name: {type: 'string', maxlength: 191, nullable: false},
13
13
  sender_email: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}},
14
14
  sender_reply_to: {type: 'string', maxlength: 191, nullable: false, validations: {isEmail: true}},
15
- default: {type: 'bool', nullable: false, defaultTo: false},
15
+ default: {type: 'boolean', nullable: false, defaultTo: false},
16
16
  status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'active'},
17
17
  recipient_filter: {
18
18
  type: 'text',
@@ -20,6 +20,6 @@ module.exports = addTable('newsletters', {
20
20
  nullable: false,
21
21
  defaultTo: ''
22
22
  },
23
- subscribe_on_signup: {type: 'bool', nullable: false, defaultTo: false},
23
+ subscribe_on_signup: {type: 'boolean', nullable: false, defaultTo: false},
24
24
  sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
25
25
  });
@@ -15,15 +15,15 @@ module.exports = recreateTable('newsletters', {
15
15
  nullable: false,
16
16
  defaultTo: 'members'
17
17
  },
18
- subscribe_on_signup: {type: 'bool', nullable: false, defaultTo: true},
18
+ subscribe_on_signup: {type: 'boolean', nullable: false, defaultTo: true},
19
19
  sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0},
20
20
  header_image: {type: 'string', maxlength: 2000, nullable: true},
21
- show_header_icon: {type: 'bool', nullable: false, defaultTo: true},
22
- show_header_title: {type: 'bool', nullable: false, defaultTo: true},
21
+ show_header_icon: {type: 'boolean', nullable: false, defaultTo: true},
22
+ show_header_title: {type: 'boolean', nullable: false, defaultTo: true},
23
23
  title_font_category: {type: 'string', maxlength: 191, nullable: false, defaultTo: 'sans_serif', validations: {isIn: [['serif', 'sans_serif']]}},
24
24
  title_alignment: {type: 'string', maxlength: 191, nullable: false, defaultTo: 'center', validations: {isIn: [['center', 'left']]}},
25
- show_feature_image: {type: 'bool', nullable: false, defaultTo: true},
25
+ show_feature_image: {type: 'boolean', nullable: false, defaultTo: true},
26
26
  body_font_category: {type: 'string', maxlength: 191, nullable: false, defaultTo: 'sans_serif', validations: {isIn: [['serif', 'sans_serif']]}},
27
27
  footer_content: {type: 'text', maxlength: 1000000000, nullable: true},
28
- show_badge: {type: 'bool', nullable: false, defaultTo: true}
28
+ show_badge: {type: 'boolean', nullable: false, defaultTo: true}
29
29
  });
@@ -1,4 +1,4 @@
1
- const ObjectId = require('bson-objectid');
1
+ const ObjectId = require('bson-objectid').default;
2
2
  const uuid = require('uuid');
3
3
  const logging = require('@tryghost/logging');
4
4
  const startsWith = require('lodash/startsWith');
@@ -1,5 +1,5 @@
1
1
  const logging = require('@tryghost/logging');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
 
4
4
  const {createTransactionalMigration} = require('../../utils');
5
5
 
@@ -1,4 +1,4 @@
1
- const ObjectID = require('bson-objectid');
1
+ const ObjectID = require('bson-objectid').default;
2
2
  const logging = require('@tryghost/logging');
3
3
  const {createTransactionalMigration} = require('../../utils');
4
4
 
@@ -1,4 +1,4 @@
1
- const ObjectID = require('bson-objectid');
1
+ const ObjectID = require('bson-objectid').default;
2
2
  const {createTransactionalMigration} = require('../../utils');
3
3
  const logging = require('@tryghost/logging');
4
4
 
@@ -1,6 +1,6 @@
1
1
  const logging = require('@tryghost/logging');
2
2
  const {createTransactionalMigration} = require('../../utils');
3
- const ObjectId = require('bson-objectid');
3
+ const ObjectId = require('bson-objectid').default;
4
4
 
5
5
  // newsletter_show_header = false ->
6
6
  // newsletter_show_header_title = false
@@ -1,5 +1,5 @@
1
1
  const logging = require('@tryghost/logging');
2
- const ObjectID = require('bson-objectid');
2
+ const ObjectID = require('bson-objectid').default;
3
3
  const security = require('@tryghost/security');
4
4
  const {createTransactionalMigration} = require('../../utils');
5
5
 
@@ -1,7 +1,7 @@
1
1
  const {createAddColumnMigration} = require('../../utils');
2
2
 
3
3
  module.exports = createAddColumnMigration('emails', 'track_clicks', {
4
- type: 'bool',
5
- nullable: false,
4
+ type: 'boolean',
5
+ nullable: false,
6
6
  defaultTo: false
7
7
  });
@@ -0,0 +1,19 @@
1
+ const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils');
2
+
3
+ module.exports = combineNonTransactionalMigrations(
4
+ createAddColumnMigration('products', 'monthly_price', {
5
+ type: 'integer',
6
+ unsigned: true,
7
+ nullable: true
8
+ }),
9
+ createAddColumnMigration('products', 'yearly_price', {
10
+ type: 'integer',
11
+ unsigned: true,
12
+ nullable: true
13
+ }),
14
+ createAddColumnMigration('products', 'currency', {
15
+ type: 'string',
16
+ maxlength: 50,
17
+ nullable: true
18
+ })
19
+ );
@@ -0,0 +1,37 @@
1
+ const logging = require('@tryghost/logging');
2
+
3
+ const {createTransactionalMigration} = require('../../utils');
4
+
5
+ module.exports = createTransactionalMigration(
6
+ async function up(knex) {
7
+ const rows = await knex('products as t') // eslint-disable-line no-restricted-syntax
8
+ .select(
9
+ 't.id as id',
10
+ 'mp.amount as monthly_price',
11
+ 'yp.amount as yearly_price',
12
+ knex.raw('coalesce(yp.currency, mp.currency) as currency')
13
+ )
14
+ .leftJoin('stripe_prices AS mp', 't.monthly_price_id', 'mp.id')
15
+ .leftJoin('stripe_prices AS yp', 't.yearly_price_id', 'yp.id')
16
+ .where('t.type', 'paid');
17
+
18
+ if (!rows.length) {
19
+ logging.info('Did not find any active paid Tiers');
20
+ return;
21
+ } else {
22
+ logging.info(`Updating ${rows.length} Tiers with price and currency information`);
23
+ }
24
+
25
+ for (const row of rows) { // eslint-disable-line no-restricted-syntax
26
+ await knex('products').update(row).where('id', row.id);
27
+ }
28
+ },
29
+ async function down(knex) {
30
+ logging.info('Removing currency and price information for all tiers');
31
+ await knex('products').update({
32
+ currency: null,
33
+ monthly_price: null,
34
+ yearly_price: null
35
+ });
36
+ }
37
+ );
@@ -0,0 +1,19 @@
1
+ const {addTable} = require('../../utils');
2
+
3
+ module.exports = addTable('subscriptions', {
4
+ id: {type: 'string', maxlength: 24, nullable: false, primary: true},
5
+ type: {type: 'string', maxlength: 50, nullable: false},
6
+ status: {type: 'string', maxlength: 50, nullable: false},
7
+ member_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'members.id', cascadeDelete: true},
8
+ tier_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'products.id'},
9
+ cadence: {type: 'string', maxlength: 50, nullable: true},
10
+ currency: {type: 'string', maxlength: 50, nullable: true},
11
+ amount: {type: 'integer', nullable: true},
12
+ payment_provider: {type: 'string', maxlength: 50, nullable: true},
13
+ payment_subscription_url: {type: 'string', maxlength: 2000, nullable: true},
14
+ payment_user_url: {type: 'string', maxlength: 2000, nullable: true},
15
+ offer_id: {type: 'string', maxlength: 24, nullable: true, unique: false, references: 'offers.id'},
16
+ expires_at: {type: 'dateTime', nullable: true},
17
+ created_at: {type: 'dateTime', nullable: false},
18
+ updated_at: {type: 'dateTime', nullable: true}
19
+ });
@@ -0,0 +1,10 @@
1
+ const {addTable} = require('../../utils');
2
+
3
+ module.exports = addTable('members_feedback', {
4
+ id: {type: 'string', maxlength: 24, nullable: false, primary: true},
5
+ score: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0},
6
+ member_id: {type: 'string', maxlength: 24, nullable: false, references: 'members.id', cascadeDelete: true},
7
+ post_id: {type: 'string', maxlength: 24, nullable: false, references: 'posts.id', cascadeDelete: true},
8
+ created_at: {type: 'dateTime', nullable: false},
9
+ updated_at: {type: 'dateTime', nullable: true}
10
+ });
@@ -0,0 +1,7 @@
1
+ const {createAddColumnMigration} = require('../../utils');
2
+
3
+ module.exports = createAddColumnMigration('newsletters', 'feedback_enabled', {
4
+ type: 'boolean',
5
+ nullable: false,
6
+ defaultTo: false
7
+ });
@@ -126,7 +126,7 @@ async function dropColumn(tableName, column, transaction = db.knex, columnSpec =
126
126
  * Adds an unique index to a table over the given columns.
127
127
  *
128
128
  * @param {string} tableName - name of the table to add unique constraint to
129
- * @param {string|[string]} columns - column(s) to form unique constraint with
129
+ * @param {string|string[]} columns - column(s) to form unique constraint with
130
130
  * @param {import('knex')} transaction - connection object containing knex reference
131
131
  */
132
132
  async function addUnique(tableName, columns, transaction = db.knex) {
@@ -153,7 +153,7 @@ async function addUnique(tableName, columns, transaction = db.knex) {
153
153
  * Drops a unique key constraint from a table.
154
154
  *
155
155
  * @param {string} tableName - name of the table to drop unique constraint from
156
- * @param {string|[string]} columns - column(s) unique constraint was formed
156
+ * @param {string|string[]} columns - column(s) unique constraint was formed
157
157
  * @param {import('knex')} transaction - connection object containing knex reference
158
158
  */
159
159
  async function dropUnique(tableName, columns, transaction = db.knex) {
@@ -327,7 +327,7 @@ async function hasPrimaryKeySQLite(tableName, transaction = db.knex) {
327
327
  * Adds an primary key index to a table over the given columns.
328
328
  *
329
329
  * @param {string} tableName - name of the table to add primaykey constraint to
330
- * @param {string|[string]} columns - column(s) to form primary key constraint with
330
+ * @param {string|string[]} columns - column(s) to form primary key constraint with
331
331
  * @param {import('knex')} transaction - connection object containing knex reference
332
332
  */
333
333
  async function addPrimaryKey(tableName, columns, transaction = db.knex) {
@@ -15,7 +15,10 @@
15
15
  "slug": "default-product",
16
16
  "type": "paid",
17
17
  "active": true,
18
- "visibility": "public"
18
+ "visibility": "public",
19
+ "currency": "usd",
20
+ "monthly_price": 500,
21
+ "yearly_price": 5000
19
22
  }
20
23
  ]
21
24
  },