@teleporthq/teleport-plugin-next-workflows 0.43.74 → 0.43.75
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/__tests__/emit-custom-event-channel.test.ts +13 -0
- package/__tests__/payment-driver-stripe.test.ts +23 -0
- package/__tests__/payment-subscription-nodes.test.ts +8 -0
- package/dist/cjs/data-api-route-generator.d.ts +6 -8
- package/dist/cjs/data-api-route-generator.d.ts.map +1 -1
- package/dist/cjs/data-api-route-generator.js +6 -15
- package/dist/cjs/data-api-route-generator.js.map +1 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.d.ts.map +1 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.js +3 -1
- package/dist/cjs/nodes/general/general-emit-custom-event.js.map +1 -1
- package/dist/cjs/payments/drivers/stripe-driver-code.d.ts.map +1 -1
- package/dist/cjs/payments/drivers/stripe-driver-code.js +11 -0
- package/dist/cjs/payments/drivers/stripe-driver-code.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/data-api-route-generator.d.ts +6 -8
- package/dist/esm/data-api-route-generator.d.ts.map +1 -1
- package/dist/esm/data-api-route-generator.js +7 -16
- package/dist/esm/data-api-route-generator.js.map +1 -1
- package/dist/esm/nodes/general/general-emit-custom-event.d.ts.map +1 -1
- package/dist/esm/nodes/general/general-emit-custom-event.js +3 -1
- package/dist/esm/nodes/general/general-emit-custom-event.js.map +1 -1
- package/dist/esm/payments/drivers/stripe-driver-code.d.ts.map +1 -1
- package/dist/esm/payments/drivers/stripe-driver-code.js +11 -0
- package/dist/esm/payments/drivers/stripe-driver-code.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/data-api-route-generator.ts +8 -18
- package/src/nodes/general/general-emit-custom-event.ts +3 -1
- package/src/payments/drivers/stripe-driver-code.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teleporthq/teleport-plugin-next-workflows",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.75",
|
|
4
4
|
"description": "A plugin for workflow code generation in Next.js projects.",
|
|
5
5
|
"author": "teleportHQ",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/types": "^7.5.5",
|
|
69
|
-
"@teleporthq/teleport-shared": "^0.43.
|
|
70
|
-
"@teleporthq/teleport-types": "^0.43.
|
|
69
|
+
"@teleporthq/teleport-shared": "^0.43.75",
|
|
70
|
+
"@teleporthq/teleport-types": "^0.43.75"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "4bc0af8166575b4af971f39e63228ce2eefce661"
|
|
73
73
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import { generateSqlValidatorCode } from './sql-validator'
|
|
15
15
|
import { generateCommonJsSessionTokenResolverCode } from './session-cookie-resolver'
|
|
16
|
-
import { TableAccess } from '@teleporthq/teleport-shared'
|
|
16
|
+
import { ContentTables, TableAccess } from '@teleporthq/teleport-shared'
|
|
17
17
|
|
|
18
18
|
const DATA_NODE_TYPES = new Set([
|
|
19
19
|
'data-select',
|
|
@@ -79,28 +79,18 @@ export const BROWSER_READABLE_TABLES: ReadonlyArray<string> = [
|
|
|
79
79
|
'teleport_shipping_rates',
|
|
80
80
|
'teleport_tax_rates',
|
|
81
81
|
'teleport_store_locations',
|
|
82
|
-
|
|
82
|
+
...ContentTables.CONTENT_POSTS_TABLES,
|
|
83
83
|
]
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* What a browser is served of the readable tables whose unpublished rows sit
|
|
87
|
-
* beside the public ones — the same
|
|
88
|
-
* (teleport-plugin-next-data-source `browser-row-policy.ts
|
|
89
|
-
*
|
|
90
|
-
*
|
|
87
|
+
* beside the public ones — the same map the per-table read routes apply
|
|
88
|
+
* (teleport-plugin-next-data-source `browser-row-policy.ts`): both read it from
|
|
89
|
+
* teleport-shared. A browser may not filter or sort by a hidden column: a
|
|
90
|
+
* filter is an oracle for a column it never returns.
|
|
91
91
|
*/
|
|
92
|
-
export const BROWSER_ROW_POLICIES: Readonly<
|
|
93
|
-
|
|
94
|
-
> = {
|
|
95
|
-
teleport_blog_posts: {
|
|
96
|
-
predicate: "status = 'published'",
|
|
97
|
-
hiddenColumns: ['author_email', 'authorEmail'],
|
|
98
|
-
},
|
|
99
|
-
teleport_products: {
|
|
100
|
-
predicate: "LOWER(TRIM(status)) = 'active'",
|
|
101
|
-
hiddenColumns: [],
|
|
102
|
-
},
|
|
103
|
-
}
|
|
92
|
+
export const BROWSER_ROW_POLICIES: Readonly<Record<string, ContentTables.VisitorRowPolicy>> =
|
|
93
|
+
ContentTables.VISITOR_ROW_POLICIES
|
|
104
94
|
|
|
105
95
|
export const generateDataAPIRoute = (options: DataAPIRouteOptions = {}): string => {
|
|
106
96
|
const validatorCode = generateSqlValidatorCode()
|
|
@@ -10,7 +10,9 @@ async function general_emit_custom_event(config: any, context: Record<string, un
|
|
|
10
10
|
const scope = config.scope || GLOBAL_SCOPE
|
|
11
11
|
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
// The "A Custom Event is Triggered" workflow listens on this channel (see
|
|
14
|
+
// trigger-generator); a bare name started nothing.
|
|
15
|
+
const event = new CustomEvent('workflow:custom:' + eventName, {
|
|
14
16
|
detail: eventData,
|
|
15
17
|
bubbles: scope === GLOBAL_SCOPE,
|
|
16
18
|
cancelable: true,
|
|
@@ -16,6 +16,15 @@ module.exports = function createStripeDriver(core) {
|
|
|
16
16
|
// An older store's test key, read after the names the editor saves.
|
|
17
17
|
var LEGACY_SECRET_KEY_NAMES = ['STRIPE_TEST_KEY'];
|
|
18
18
|
var MISSING_KEY = 'STRIPE_SECRET_KEY is not configured';
|
|
19
|
+
// How long a Checkout page takes money. Stripe's default is a day, which is
|
|
20
|
+
// how long an abandoned checkout would hold its stock on a store without
|
|
21
|
+
// the scheduled release; the store's own hold is 60 minutes, and Stripe
|
|
22
|
+
// takes no less than 30.
|
|
23
|
+
var CHECKOUT_LIFETIME_MINUTES = 60;
|
|
24
|
+
|
|
25
|
+
function checkoutExpiresAt() {
|
|
26
|
+
return Math.floor(Date.now() / 1000) + CHECKOUT_LIFETIME_MINUTES * 60;
|
|
27
|
+
}
|
|
19
28
|
var INTERVALS = ['day', 'week', 'month', 'year'];
|
|
20
29
|
// Checkout tolerates a signature this old, as Stripe's own libraries do.
|
|
21
30
|
var SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
@@ -62,6 +71,7 @@ module.exports = function createStripeDriver(core) {
|
|
|
62
71
|
mode: 'payment',
|
|
63
72
|
success_url: input.successUrl || undefined,
|
|
64
73
|
cancel_url: input.cancelUrl || undefined,
|
|
74
|
+
expires_at: checkoutExpiresAt(),
|
|
65
75
|
};
|
|
66
76
|
var lineItems = input.lineItems;
|
|
67
77
|
if (lineItems && Array.isArray(lineItems) && lineItems.length > 0) {
|
|
@@ -151,6 +161,7 @@ module.exports = function createStripeDriver(core) {
|
|
|
151
161
|
mode: 'subscription',
|
|
152
162
|
success_url: input.successUrl || undefined,
|
|
153
163
|
cancel_url: input.cancelUrl || undefined,
|
|
164
|
+
expires_at: checkoutExpiresAt(),
|
|
154
165
|
line_items: [
|
|
155
166
|
{
|
|
156
167
|
price_data: {
|