@paymentsdb/sync-engine 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.
- package/README.md +310 -0
- package/dist/chunk-3OQVG44L.js +4196 -0
- package/dist/chunk-CMGFQCD7.js +87 -0
- package/dist/chunk-J6VKHOSX.js +641 -0
- package/dist/chunk-TYAHH7EW.js +406 -0
- package/dist/cli/index.cjs +5371 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/lib.cjs +5337 -0
- package/dist/cli/lib.d.cts +73 -0
- package/dist/cli/lib.d.ts +73 -0
- package/dist/cli/lib.js +21 -0
- package/dist/index.cjs +4321 -0
- package/dist/index.d.cts +815 -0
- package/dist/index.d.ts +815 -0
- package/dist/index.js +17 -0
- package/dist/migrations/0000_initial_migration.sql +1 -0
- package/dist/migrations/0001_products.sql +17 -0
- package/dist/migrations/0002_customers.sql +23 -0
- package/dist/migrations/0003_prices.sql +34 -0
- package/dist/migrations/0004_subscriptions.sql +56 -0
- package/dist/migrations/0005_invoices.sql +77 -0
- package/dist/migrations/0006_charges.sql +43 -0
- package/dist/migrations/0007_coupons.sql +19 -0
- package/dist/migrations/0008_disputes.sql +17 -0
- package/dist/migrations/0009_events.sql +12 -0
- package/dist/migrations/0010_payouts.sql +30 -0
- package/dist/migrations/0011_plans.sql +25 -0
- package/dist/migrations/0012_add_updated_at.sql +108 -0
- package/dist/migrations/0013_add_subscription_items.sql +12 -0
- package/dist/migrations/0014_migrate_subscription_items.sql +26 -0
- package/dist/migrations/0015_add_customer_deleted.sql +2 -0
- package/dist/migrations/0016_add_invoice_indexes.sql +2 -0
- package/dist/migrations/0017_drop_charges_unavailable_columns.sql +6 -0
- package/dist/migrations/0018_setup_intents.sql +17 -0
- package/dist/migrations/0019_payment_methods.sql +12 -0
- package/dist/migrations/0020_disputes_payment_intent_created_idx.sql +3 -0
- package/dist/migrations/0021_payment_intent.sql +42 -0
- package/dist/migrations/0022_adjust_plans.sql +5 -0
- package/dist/migrations/0023_invoice_deleted.sql +1 -0
- package/dist/migrations/0024_subscription_schedules.sql +29 -0
- package/dist/migrations/0025_tax_ids.sql +14 -0
- package/dist/migrations/0026_credit_notes.sql +36 -0
- package/dist/migrations/0027_add_marketing_features_to_products.sql +2 -0
- package/dist/migrations/0028_early_fraud_warning.sql +22 -0
- package/dist/migrations/0029_reviews.sql +28 -0
- package/dist/migrations/0030_refunds.sql +29 -0
- package/dist/migrations/0031_add_default_price.sql +2 -0
- package/dist/migrations/0032_update_subscription_items.sql +3 -0
- package/dist/migrations/0033_add_last_synced_at.sql +85 -0
- package/dist/migrations/0034_remove_foreign_keys.sql +13 -0
- package/dist/migrations/0035_checkout_sessions.sql +77 -0
- package/dist/migrations/0036_checkout_session_line_items.sql +24 -0
- package/dist/migrations/0037_add_features.sql +18 -0
- package/dist/migrations/0038_active_entitlement.sql +20 -0
- package/dist/migrations/0039_add_paused_to_subscription_status.sql +1 -0
- package/dist/migrations/0040_managed_webhooks.sql +28 -0
- package/dist/migrations/0041_rename_managed_webhooks.sql +2 -0
- package/dist/migrations/0042_convert_to_jsonb_generated_columns.sql +1821 -0
- package/dist/migrations/0043_add_account_id.sql +49 -0
- package/dist/migrations/0044_make_account_id_required.sql +54 -0
- package/dist/migrations/0045_sync_status.sql +18 -0
- package/dist/migrations/0046_sync_status_per_account.sql +91 -0
- package/dist/migrations/0047_api_key_hashes.sql +12 -0
- package/dist/migrations/0048_rename_reserved_columns.sql +1253 -0
- package/dist/migrations/0049_remove_redundant_underscores_from_metadata_tables.sql +68 -0
- package/dist/migrations/0050_rename_id_to_match_stripe_api.sql +239 -0
- package/dist/migrations/0051_remove_webhook_uuid.sql +7 -0
- package/dist/migrations/0052_webhook_url_uniqueness.sql +7 -0
- package/dist/migrations/0053_sync_observability.sql +104 -0
- package/dist/migrations/0054_drop_sync_status.sql +5 -0
- package/dist/migrations/0055_bigint_money_columns.sql +72 -0
- package/dist/migrations/0056_sync_run_closed_at.sql +53 -0
- package/dist/migrations/0057_rename_sync_tables.sql +57 -0
- package/dist/migrations/0058_improve_sync_runs_status.sql +36 -0
- 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/migrations/0061_add_page_cursor.sql +3 -0
- package/dist/migrations/0062_balance_transactions.sql +42 -0
- package/dist/supabase/index.cjs +523 -0
- package/dist/supabase/index.d.cts +121 -0
- package/dist/supabase/index.d.ts +121 -0
- package/dist/supabase/index.js +26 -0
- package/package.json +83 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
declare const STRIPE_SCHEMA_COMMENT_PREFIX = "stripe-sync";
|
|
2
|
+
declare const INSTALLATION_STARTED_SUFFIX = "installation:started";
|
|
3
|
+
declare const INSTALLATION_ERROR_SUFFIX = "installation:error";
|
|
4
|
+
declare const INSTALLATION_INSTALLED_SUFFIX = "installed";
|
|
5
|
+
interface DeployClientOptions {
|
|
6
|
+
accessToken: string;
|
|
7
|
+
projectRef: string;
|
|
8
|
+
projectBaseUrl?: string;
|
|
9
|
+
supabaseManagementUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ProjectInfo {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
region: string;
|
|
15
|
+
}
|
|
16
|
+
declare class SupabaseSetupClient {
|
|
17
|
+
private api;
|
|
18
|
+
private projectRef;
|
|
19
|
+
private projectBaseUrl;
|
|
20
|
+
private supabaseManagementUrl?;
|
|
21
|
+
private accessToken;
|
|
22
|
+
constructor(options: DeployClientOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Validate that the project exists and we have access
|
|
25
|
+
*/
|
|
26
|
+
validateProject(): Promise<ProjectInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* Deploy an Edge Function
|
|
29
|
+
*/
|
|
30
|
+
deployFunction(name: string, code: string, verifyJwt?: boolean): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Set secrets for Edge Functions
|
|
33
|
+
*/
|
|
34
|
+
setSecrets(secrets: {
|
|
35
|
+
name: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}[]): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Run SQL against the database
|
|
40
|
+
*/
|
|
41
|
+
runSQL(sql: string): Promise<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Setup pg_cron job to invoke worker function
|
|
44
|
+
* @param intervalSeconds - How often to run the worker (default: 60 seconds)
|
|
45
|
+
*/
|
|
46
|
+
setupPgCronJob(intervalSeconds?: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the webhook URL for this project
|
|
49
|
+
*/
|
|
50
|
+
getWebhookUrl(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Get the anon key for this project (needed for Realtime subscriptions)
|
|
53
|
+
*/
|
|
54
|
+
getAnonKey(): Promise<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the project URL
|
|
57
|
+
*/
|
|
58
|
+
getProjectUrl(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Invoke an Edge Function
|
|
61
|
+
*/
|
|
62
|
+
invokeFunction(name: string, bearerToken: string): Promise<{
|
|
63
|
+
success: boolean;
|
|
64
|
+
error?: string;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Check if stripe-sync is installed in the database.
|
|
68
|
+
*
|
|
69
|
+
* Uses the Supabase Management API to run SQL queries.
|
|
70
|
+
* Uses duck typing (schema + migrations table) combined with comment validation.
|
|
71
|
+
* Throws error for legacy installations to prevent accidental corruption.
|
|
72
|
+
*
|
|
73
|
+
* @param schema The schema name to check (defaults to 'stripe')
|
|
74
|
+
* @returns true if properly installed with comment marker, false if not installed
|
|
75
|
+
* @throws Error if legacy installation detected (schema exists without comment)
|
|
76
|
+
*/
|
|
77
|
+
isInstalled(schema?: string): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Update installation progress comment on the stripe schema
|
|
80
|
+
*/
|
|
81
|
+
updateInstallationComment(message: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete an Edge Function
|
|
84
|
+
*/
|
|
85
|
+
deleteFunction(name: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Delete a secret
|
|
88
|
+
*/
|
|
89
|
+
deleteSecret(name: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Uninstall stripe-sync from a Supabase project
|
|
92
|
+
* Invokes the stripe-setup edge function's DELETE endpoint which handles cleanup
|
|
93
|
+
*/
|
|
94
|
+
uninstall(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Inject package version into Edge Function code
|
|
97
|
+
*/
|
|
98
|
+
private injectPackageVersion;
|
|
99
|
+
install(stripeKey: string, packageVersion?: string, workerIntervalSeconds?: number): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
declare function install(params: {
|
|
102
|
+
supabaseAccessToken: string;
|
|
103
|
+
supabaseProjectRef: string;
|
|
104
|
+
stripeKey: string;
|
|
105
|
+
packageVersion?: string;
|
|
106
|
+
workerIntervalSeconds?: number;
|
|
107
|
+
baseProjectUrl?: string;
|
|
108
|
+
supabaseManagementUrl?: string;
|
|
109
|
+
}): Promise<void>;
|
|
110
|
+
declare function uninstall(params: {
|
|
111
|
+
supabaseAccessToken: string;
|
|
112
|
+
supabaseProjectRef: string;
|
|
113
|
+
baseProjectUrl?: string;
|
|
114
|
+
supabaseManagementUrl?: string;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
|
|
117
|
+
declare const setupFunctionCode: string;
|
|
118
|
+
declare const webhookFunctionCode: string;
|
|
119
|
+
declare const workerFunctionCode: string;
|
|
120
|
+
|
|
121
|
+
export { type DeployClientOptions, INSTALLATION_ERROR_SUFFIX, INSTALLATION_INSTALLED_SUFFIX, INSTALLATION_STARTED_SUFFIX, type ProjectInfo, STRIPE_SCHEMA_COMMENT_PREFIX, SupabaseSetupClient as SupabaseDeployClient, SupabaseSetupClient, install, setupFunctionCode, uninstall, webhookFunctionCode, workerFunctionCode };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INSTALLATION_ERROR_SUFFIX,
|
|
3
|
+
INSTALLATION_INSTALLED_SUFFIX,
|
|
4
|
+
INSTALLATION_STARTED_SUFFIX,
|
|
5
|
+
STRIPE_SCHEMA_COMMENT_PREFIX,
|
|
6
|
+
SupabaseSetupClient,
|
|
7
|
+
install,
|
|
8
|
+
setupFunctionCode,
|
|
9
|
+
uninstall,
|
|
10
|
+
webhookFunctionCode,
|
|
11
|
+
workerFunctionCode
|
|
12
|
+
} from "../chunk-TYAHH7EW.js";
|
|
13
|
+
import "../chunk-CMGFQCD7.js";
|
|
14
|
+
export {
|
|
15
|
+
INSTALLATION_ERROR_SUFFIX,
|
|
16
|
+
INSTALLATION_INSTALLED_SUFFIX,
|
|
17
|
+
INSTALLATION_STARTED_SUFFIX,
|
|
18
|
+
STRIPE_SCHEMA_COMMENT_PREFIX,
|
|
19
|
+
SupabaseSetupClient as SupabaseDeployClient,
|
|
20
|
+
SupabaseSetupClient,
|
|
21
|
+
install,
|
|
22
|
+
setupFunctionCode,
|
|
23
|
+
uninstall,
|
|
24
|
+
webhookFunctionCode,
|
|
25
|
+
workerFunctionCode
|
|
26
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paymentsdb/sync-engine",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Stripe Sync Engine to sync Stripe data to Postgres",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"bin": "./dist/cli/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./supabase": {
|
|
16
|
+
"types": "./dist/supabase/index.d.ts",
|
|
17
|
+
"import": "./dist/supabase/index.js",
|
|
18
|
+
"require": "./dist/supabase/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./cli": {
|
|
21
|
+
"types": "./dist/cli/lib.d.ts",
|
|
22
|
+
"import": "./dist/cli/lib.js",
|
|
23
|
+
"require": "./dist/cli/lib.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"prebuild": "npm run clean",
|
|
29
|
+
"build": "tsup src/index.ts src/supabase/index.ts src/cli/index.ts src/cli/lib.ts --format esm,cjs --dts --shims && cp -r src/database/migrations dist/migrations",
|
|
30
|
+
"lint": "eslint src --ext .ts",
|
|
31
|
+
"test": "vitest"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@ngrok/ngrok": "^1.4.1",
|
|
38
|
+
"chalk": "^5.3.0",
|
|
39
|
+
"commander": "^12.1.0",
|
|
40
|
+
"dotenv": "^16.4.7",
|
|
41
|
+
"express": "^4.18.2",
|
|
42
|
+
"inquirer": "^12.3.0",
|
|
43
|
+
"papaparse": "5.4.1",
|
|
44
|
+
"pg": "^8.16.3",
|
|
45
|
+
"pg-node-migrations": "0.0.8",
|
|
46
|
+
"stripe": "^17.7.0",
|
|
47
|
+
"supabase-management-js": "^0.1.6",
|
|
48
|
+
"ws": "^8.18.0",
|
|
49
|
+
"yesql": "^7.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/express": "^4.17.21",
|
|
53
|
+
"@types/inquirer": "^9.0.7",
|
|
54
|
+
"@types/node": "^24.10.1",
|
|
55
|
+
"@types/papaparse": "5.3.16",
|
|
56
|
+
"@types/pg": "^8.15.5",
|
|
57
|
+
"@types/ws": "^8.5.13",
|
|
58
|
+
"@types/yesql": "^4.1.4",
|
|
59
|
+
"@vitest/ui": "^4.0.9",
|
|
60
|
+
"tsx": "^4.19.2",
|
|
61
|
+
"vitest": "^3.2.4"
|
|
62
|
+
},
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/stripe-experiments/sync-engine.git"
|
|
66
|
+
},
|
|
67
|
+
"homepage": "https://github.com/stripe-experiments/sync-engine#readme",
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/stripe-experiments/sync-engine/issues"
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"stripe",
|
|
73
|
+
"postgres",
|
|
74
|
+
"sync",
|
|
75
|
+
"webhooks",
|
|
76
|
+
"supabase",
|
|
77
|
+
"billing",
|
|
78
|
+
"database",
|
|
79
|
+
"typescript"
|
|
80
|
+
],
|
|
81
|
+
"author": "PaymentsDB <https://paymentsdb.com/>",
|
|
82
|
+
"license": "Apache-2.0"
|
|
83
|
+
}
|