stripe-experiment-sync 1.0.13 → 1.0.15
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/dist/{chunk-RCU5ZXAX.js → chunk-3KVILTN4.js} +3 -1
- package/dist/{chunk-5SS5ZEQF.js → chunk-AODI5WO6.js} +27 -10
- package/dist/{chunk-2GSABFXH.js → chunk-GOBVFXU7.js} +806 -209
- package/dist/chunk-XIFB5ALW.js +400 -0
- package/dist/cli/index.cjs +850 -250
- package/dist/cli/index.js +7 -6
- package/dist/cli/lib.cjs +847 -248
- package/dist/cli/lib.d.cts +2 -0
- package/dist/cli/lib.d.ts +2 -0
- package/dist/cli/lib.js +4 -4
- package/dist/index.cjs +807 -208
- package/dist/index.d.cts +110 -3
- package/dist/index.d.ts +110 -3
- package/dist/index.js +2 -2
- package/dist/migrations/0059_sigma_subscription_item_change_events_v2_beta.sql +61 -0
- package/dist/migrations/0060_sigma_exchange_rates_from_usd.sql +38 -0
- package/dist/supabase/index.cjs +18 -33
- package/dist/supabase/index.d.cts +1 -5
- package/dist/supabase/index.d.ts +1 -5
- package/dist/supabase/index.js +2 -2
- package/package.json +3 -1
- package/dist/chunk-O2N4AEQS.js +0 -417
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "stripe-experiment-sync",
|
|
4
|
-
version: "1.0.
|
|
4
|
+
version: "1.0.15",
|
|
5
5
|
private: false,
|
|
6
6
|
description: "Stripe Sync Engine to sync Stripe data to Postgres",
|
|
7
7
|
type: "module",
|
|
@@ -41,6 +41,7 @@ var package_default = {
|
|
|
41
41
|
dotenv: "^16.4.7",
|
|
42
42
|
express: "^4.18.2",
|
|
43
43
|
inquirer: "^12.3.0",
|
|
44
|
+
papaparse: "5.4.1",
|
|
44
45
|
pg: "^8.16.3",
|
|
45
46
|
"pg-node-migrations": "0.0.8",
|
|
46
47
|
stripe: "^17.7.0",
|
|
@@ -52,6 +53,7 @@ var package_default = {
|
|
|
52
53
|
"@types/express": "^4.17.21",
|
|
53
54
|
"@types/inquirer": "^9.0.7",
|
|
54
55
|
"@types/node": "^24.10.1",
|
|
56
|
+
"@types/papaparse": "5.3.16",
|
|
55
57
|
"@types/pg": "^8.15.5",
|
|
56
58
|
"@types/ws": "^8.5.13",
|
|
57
59
|
"@types/yesql": "^4.1.4",
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
StripeSync,
|
|
3
3
|
createStripeWebSocketClient,
|
|
4
4
|
runMigrations
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-GOBVFXU7.js";
|
|
6
6
|
import {
|
|
7
7
|
install,
|
|
8
8
|
uninstall
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XIFB5ALW.js";
|
|
10
10
|
|
|
11
11
|
// src/cli/config.ts
|
|
12
12
|
import dotenv from "dotenv";
|
|
@@ -18,6 +18,7 @@ async function loadConfig(options) {
|
|
|
18
18
|
config.stripeApiKey = options.stripeKey || process.env.STRIPE_API_KEY || "";
|
|
19
19
|
config.ngrokAuthToken = options.ngrokToken || process.env.NGROK_AUTH_TOKEN || "";
|
|
20
20
|
config.databaseUrl = options.databaseUrl || process.env.DATABASE_URL || "";
|
|
21
|
+
config.enableSigma = options.enableSigma ?? (process.env.ENABLE_SIGMA !== void 0 ? process.env.ENABLE_SIGMA === "true" : void 0);
|
|
21
22
|
const questions = [];
|
|
22
23
|
if (!config.stripeApiKey) {
|
|
23
24
|
questions.push({
|
|
@@ -29,8 +30,8 @@ async function loadConfig(options) {
|
|
|
29
30
|
if (!input || input.trim() === "") {
|
|
30
31
|
return "Stripe API key is required";
|
|
31
32
|
}
|
|
32
|
-
if (!input.startsWith("sk_")) {
|
|
33
|
-
return 'Stripe API key should start with "sk_"';
|
|
33
|
+
if (!input.startsWith("sk_") && !input.startsWith("rk_")) {
|
|
34
|
+
return 'Stripe API key should start with "sk_" or "rk_"';
|
|
34
35
|
}
|
|
35
36
|
return true;
|
|
36
37
|
}
|
|
@@ -53,11 +54,22 @@ async function loadConfig(options) {
|
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
56
|
}
|
|
57
|
+
if (config.enableSigma === void 0) {
|
|
58
|
+
questions.push({
|
|
59
|
+
type: "confirm",
|
|
60
|
+
name: "enableSigma",
|
|
61
|
+
message: "Enable Sigma sync? (Requires Sigma access in Stripe API key)",
|
|
62
|
+
default: false
|
|
63
|
+
});
|
|
64
|
+
}
|
|
56
65
|
if (questions.length > 0) {
|
|
57
|
-
console.log(chalk.yellow("\nMissing
|
|
66
|
+
console.log(chalk.yellow("\nMissing configuration. Please provide:"));
|
|
58
67
|
const answers = await inquirer.prompt(questions);
|
|
59
68
|
Object.assign(config, answers);
|
|
60
69
|
}
|
|
70
|
+
if (config.enableSigma === void 0) {
|
|
71
|
+
config.enableSigma = false;
|
|
72
|
+
}
|
|
61
73
|
return config;
|
|
62
74
|
}
|
|
63
75
|
|
|
@@ -117,7 +129,9 @@ var VALID_SYNC_OBJECTS = [
|
|
|
117
129
|
"credit_note",
|
|
118
130
|
"early_fraud_warning",
|
|
119
131
|
"refund",
|
|
120
|
-
"checkout_sessions"
|
|
132
|
+
"checkout_sessions",
|
|
133
|
+
"subscription_item_change_events_v2_beta",
|
|
134
|
+
"exchange_rates_from_usd"
|
|
121
135
|
];
|
|
122
136
|
async function backfillCommand(options, entityName) {
|
|
123
137
|
let stripeSync = null;
|
|
@@ -146,8 +160,8 @@ async function backfillCommand(options, entityName) {
|
|
|
146
160
|
if (!input || input.trim() === "") {
|
|
147
161
|
return "Stripe API key is required";
|
|
148
162
|
}
|
|
149
|
-
if (!input.startsWith("sk_")) {
|
|
150
|
-
return 'Stripe API key should start with "sk_"';
|
|
163
|
+
if (!input.startsWith("sk_") && !input.startsWith("rk_")) {
|
|
164
|
+
return 'Stripe API key should start with "sk_" or "rk_"';
|
|
151
165
|
}
|
|
152
166
|
return true;
|
|
153
167
|
}
|
|
@@ -204,6 +218,7 @@ async function backfillCommand(options, entityName) {
|
|
|
204
218
|
stripeSync = new StripeSync({
|
|
205
219
|
databaseUrl: config.databaseUrl,
|
|
206
220
|
stripeSecretKey: config.stripeApiKey,
|
|
221
|
+
enableSigma: process.env.ENABLE_SIGMA === "true",
|
|
207
222
|
stripeApiVersion: process.env.STRIPE_API_VERSION || "2020-08-27",
|
|
208
223
|
autoExpandLists: process.env.AUTO_EXPAND_LISTS === "true",
|
|
209
224
|
backfillRelatedEntities: process.env.BACKFILL_RELATED_ENTITIES !== "false",
|
|
@@ -342,7 +357,7 @@ Cleaning up... (signal: ${signal || "manual"})`));
|
|
|
342
357
|
process.on("SIGTERM", () => cleanup("SIGTERM"));
|
|
343
358
|
try {
|
|
344
359
|
const config = await loadConfig(options);
|
|
345
|
-
const useWebSocketMode = !config.ngrokAuthToken;
|
|
360
|
+
const useWebSocketMode = process.env.USE_WEBSOCKET === "true" || !config.ngrokAuthToken;
|
|
346
361
|
const modeLabel = useWebSocketMode ? "WebSocket" : "Webhook (ngrok)";
|
|
347
362
|
console.log(chalk3.blue(`
|
|
348
363
|
Mode: ${modeLabel}`));
|
|
@@ -367,6 +382,7 @@ Mode: ${modeLabel}`));
|
|
|
367
382
|
stripeSync = new StripeSync({
|
|
368
383
|
databaseUrl: config.databaseUrl,
|
|
369
384
|
stripeSecretKey: config.stripeApiKey,
|
|
385
|
+
enableSigma: config.enableSigma,
|
|
370
386
|
stripeApiVersion: process.env.STRIPE_API_VERSION || "2020-08-27",
|
|
371
387
|
autoExpandLists: process.env.AUTO_EXPAND_LISTS === "true",
|
|
372
388
|
backfillRelatedEntities: process.env.BACKFILL_RELATED_ENTITIES !== "false",
|
|
@@ -514,7 +530,8 @@ async function installCommand(options) {
|
|
|
514
530
|
mask: "*",
|
|
515
531
|
validate: (input) => {
|
|
516
532
|
if (!input.trim()) return "Stripe key is required";
|
|
517
|
-
if (!input.startsWith("sk_")
|
|
533
|
+
if (!input.startsWith("sk_") && !input.startsWith("rk_"))
|
|
534
|
+
return 'Stripe key should start with "sk_" or "rk_"';
|
|
518
535
|
return true;
|
|
519
536
|
}
|
|
520
537
|
});
|