@eventpipe/cli 0.2.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 (51) hide show
  1. package/README.md +79 -0
  2. package/dist/auth-fetch.d.ts +5 -0
  3. package/dist/auth-fetch.js +29 -0
  4. package/dist/base-url.d.ts +2 -0
  5. package/dist/base-url.js +8 -0
  6. package/dist/build-bundle.d.ts +12 -0
  7. package/dist/build-bundle.js +48 -0
  8. package/dist/cli-version.d.ts +3 -0
  9. package/dist/cli-version.js +48 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +221 -0
  12. package/dist/cmd-create.d.ts +1 -0
  13. package/dist/cmd-create.js +34 -0
  14. package/dist/cmd-listen.d.ts +2 -0
  15. package/dist/cmd-listen.js +90 -0
  16. package/dist/cmd-login.d.ts +1 -0
  17. package/dist/cmd-login.js +91 -0
  18. package/dist/cmd-update.d.ts +1 -0
  19. package/dist/cmd-update.js +20 -0
  20. package/dist/code-node-ids.d.ts +1 -0
  21. package/dist/code-node-ids.js +20 -0
  22. package/dist/config.d.ts +8 -0
  23. package/dist/config.js +42 -0
  24. package/dist/constants.d.ts +2 -0
  25. package/dist/constants.js +2 -0
  26. package/dist/credentials.d.ts +7 -0
  27. package/dist/credentials.js +42 -0
  28. package/dist/forward-local.d.ts +14 -0
  29. package/dist/forward-local.js +76 -0
  30. package/dist/hash.d.ts +2 -0
  31. package/dist/hash.js +7 -0
  32. package/dist/listen-args.d.ts +9 -0
  33. package/dist/listen-args.js +37 -0
  34. package/dist/publish.d.ts +20 -0
  35. package/dist/publish.js +23 -0
  36. package/dist/studio-sources.d.ts +5 -0
  37. package/dist/studio-sources.js +65 -0
  38. package/examples/forward-test-server.mjs +30 -0
  39. package/examples/stripe-webhook/.eventpipe/bundle.js +3 -0
  40. package/examples/stripe-webhook/.eventpipe/code.bundle.js +3 -0
  41. package/examples/stripe-webhook/.eventpipe/code.reexport.ts +1 -0
  42. package/examples/stripe-webhook/.eventpipe/entry.reexport.ts +1 -0
  43. package/examples/stripe-webhook/README.md +42 -0
  44. package/examples/stripe-webhook/eventpipe.json +28 -0
  45. package/examples/stripe-webhook/eventpipe.json.bak +27 -0
  46. package/examples/stripe-webhook/package.json +8 -0
  47. package/examples/stripe-webhook/src/handler.ts +44 -0
  48. package/examples/stripe-webhook/src/other.ts +1 -0
  49. package/install/macos.sh +32 -0
  50. package/install/windows.ps1 +35 -0
  51. package/package.json +31 -0
@@ -0,0 +1,27 @@
1
+ {
2
+ "flowId": "00000000-0000-0000-0000-000000000000",
3
+ "nodeId": "code",
4
+ "entry": "src/handler.ts",
5
+ "settings": {
6
+ "timeoutMs": 3000,
7
+ "pipe": {
8
+ "schemaVersion": 3,
9
+ "nodes": [
10
+ {
11
+ "id": "code",
12
+ "type": "code",
13
+ "config": {}
14
+ }
15
+ ],
16
+ "edges": [],
17
+ "envContract": {
18
+ "variables": [
19
+ {
20
+ "key": "STRIPE_SECRET_KEY",
21
+ "description": "Stripe secret key (sk_test_... or sk_live_...). Set values in the dashboard Event tab, not in this repo."
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "eventpipe-example-stripe-webhook",
3
+ "private": true,
4
+ "scripts": {
5
+ "build": "node ../../dist/cli.js build --dir .",
6
+ "push": "node ../../dist/cli.js push --dir ."
7
+ }
8
+ }
@@ -0,0 +1,44 @@
1
+ type FlowEvent = {
2
+ method: string;
3
+ headers: Record<string, string>;
4
+ body: unknown;
5
+ };
6
+
7
+ type FlowContext = {
8
+ env?: Record<string, string>;
9
+ };
10
+
11
+ export async function handler(event: FlowEvent, context: FlowContext) {
12
+ const key = context.env?.STRIPE_SECRET_KEY?.trim() ?? "";
13
+ if (!key) {
14
+ return {
15
+ ok: false,
16
+ error: "Set STRIPE_SECRET_KEY in the flow environment (Event tab). Never use process.env in code boxes.",
17
+ };
18
+ }
19
+
20
+ const res = await fetch("https://api.stripe.com/v1/balance", {
21
+ method: "GET",
22
+ headers: {
23
+ Authorization: `Bearer ${key}`,
24
+ "Stripe-Version": "2024-11-20.acacia",
25
+ },
26
+ });
27
+
28
+ const data = (await res.json()) as Record<string, unknown>;
29
+ if (!res.ok) {
30
+ return {
31
+ ok: false,
32
+ status: res.status,
33
+ stripeError: data.error ?? data,
34
+ };
35
+ }
36
+
37
+ return {
38
+ ok: true,
39
+ available: data.available,
40
+ pending: data.pending,
41
+ livemode: data.livemode,
42
+ note: "Uses REST only so the bundle stays under the 200KB per-node limit; the stripe npm package is too large to bundle here.",
43
+ };
44
+ }
@@ -0,0 +1 @@
1
+ export async function handler() { return 2; }
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ MIN_NODE_MAJOR=20
5
+
6
+ need_node() {
7
+ echo "Node.js ${MIN_NODE_MAJOR}+ is required. Install from https://nodejs.org/ or use nvm:" >&2
8
+ echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash" >&2
9
+ exit 1
10
+ }
11
+
12
+ if ! command -v node >/dev/null 2>&1; then
13
+ need_node
14
+ fi
15
+
16
+ major="$(node -p "parseInt(process.versions.node.split('.')[0], 10)" 2>/dev/null || echo 0)"
17
+ if [ "${major}" -lt "${MIN_NODE_MAJOR}" ]; then
18
+ echo "Node.js ${MIN_NODE_MAJOR}+ is required (found $(node -v))." >&2
19
+ need_node
20
+ fi
21
+
22
+ if ! command -v npm >/dev/null 2>&1; then
23
+ echo "npm is required but not found in PATH." >&2
24
+ exit 1
25
+ fi
26
+
27
+ echo "Installing @eventpipe/cli globally..."
28
+ npm install -g @eventpipe/cli@latest
29
+
30
+ echo ""
31
+ echo "Installed: $(command -v eventpipe)"
32
+ eventpipe --version
@@ -0,0 +1,35 @@
1
+ #Requires -Version 5.0
2
+ $ErrorActionPreference = "Stop"
3
+
4
+ $MinNodeMajor = 20
5
+
6
+ function Need-Node {
7
+ throw "Node.js $MinNodeMajor+ is required. Install from https://nodejs.org/ or use nvm-windows."
8
+ }
9
+
10
+ if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
11
+ Need-Node
12
+ }
13
+
14
+ try {
15
+ $ver = node -p "parseInt(process.versions.node.split('.')[0], 10)"
16
+ if ([int]$ver -lt $MinNodeMajor) {
17
+ Write-Error "Node.js $MinNodeMajor+ is required (found $(node -v))."
18
+ }
19
+ } catch {
20
+ Need-Node
21
+ }
22
+
23
+ if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
24
+ Write-Error "npm is required but not found in PATH."
25
+ }
26
+
27
+ Write-Host "Installing @eventpipe/cli globally..."
28
+ npm install -g @eventpipe/cli@latest
29
+
30
+ Write-Host ""
31
+ $ep = Get-Command eventpipe -ErrorAction SilentlyContinue
32
+ if ($ep) {
33
+ Write-Host "Installed: $($ep.Source)"
34
+ }
35
+ eventpipe --version
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@eventpipe/cli",
3
+ "version": "0.2.1",
4
+ "description": "Build and publish Event Pipe flow bundles (API key auth)",
5
+ "type": "module",
6
+ "bin": {
7
+ "eventpipe": "./dist/cli.js",
8
+ "eventpipe-cli": "./dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "examples",
13
+ "install"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.json",
17
+ "prepublishOnly": "pnpm run build"
18
+ },
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "dependencies": {
23
+ "esbuild": "^0.25.0",
24
+ "ws": "^8.18.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/ws": "^8.5.13",
28
+ "@types/node": "^20",
29
+ "typescript": "^5"
30
+ }
31
+ }