@intentsolutionsio/supabase-pack 1.0.0 → 1.0.3

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 (133) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +73 -47
  3. package/package.json +4 -4
  4. package/skills/supabase-advanced-troubleshooting/SKILL.md +404 -200
  5. package/skills/supabase-advanced-troubleshooting/references/errors.md +11 -0
  6. package/skills/supabase-advanced-troubleshooting/references/evidence-collection-framework.md +34 -0
  7. package/skills/supabase-advanced-troubleshooting/references/examples.md +11 -0
  8. package/skills/supabase-advanced-troubleshooting/references/rls-edge-functions-realtime.md +363 -0
  9. package/skills/supabase-advanced-troubleshooting/references/systematic-isolation.md +56 -0
  10. package/skills/supabase-advanced-troubleshooting/references/timing-analysis.md +35 -0
  11. package/skills/supabase-architecture-variants/SKILL.md +395 -216
  12. package/skills/supabase-architecture-variants/references/errors.md +11 -0
  13. package/skills/supabase-architecture-variants/references/examples.md +12 -0
  14. package/skills/supabase-architecture-variants/references/serverless-and-multi-tenant.md +251 -0
  15. package/skills/supabase-architecture-variants/references/variant-a-monolith-(simple).md +44 -0
  16. package/skills/supabase-architecture-variants/references/variant-b-service-layer-(moderate).md +72 -0
  17. package/skills/supabase-architecture-variants/references/variant-c-microservice-(complex).md +81 -0
  18. package/skills/supabase-auth-storage-realtime-core/SKILL.md +471 -37
  19. package/skills/supabase-ci-integration/SKILL.md +315 -67
  20. package/skills/supabase-ci-integration/references/errors.md +10 -0
  21. package/skills/supabase-ci-integration/references/examples.md +36 -0
  22. package/skills/supabase-ci-integration/references/implementation.md +54 -0
  23. package/skills/supabase-common-errors/SKILL.md +320 -62
  24. package/skills/supabase-common-errors/references/errors.md +53 -0
  25. package/skills/supabase-common-errors/references/examples.md +23 -0
  26. package/skills/supabase-cost-tuning/SKILL.md +365 -131
  27. package/skills/supabase-cost-tuning/references/cost-estimation.md +34 -0
  28. package/skills/supabase-cost-tuning/references/cost-reduction-strategies.md +40 -0
  29. package/skills/supabase-cost-tuning/references/errors.md +11 -0
  30. package/skills/supabase-cost-tuning/references/examples.md +15 -0
  31. package/skills/supabase-data-handling/SKILL.md +378 -145
  32. package/skills/supabase-data-handling/references/errors.md +11 -0
  33. package/skills/supabase-data-handling/references/examples.md +27 -0
  34. package/skills/supabase-data-handling/references/implementation.md +223 -0
  35. package/skills/supabase-data-handling/references/retention-and-backup.md +221 -0
  36. package/skills/supabase-debug-bundle/SKILL.md +267 -73
  37. package/skills/supabase-debug-bundle/references/errors.md +12 -0
  38. package/skills/supabase-debug-bundle/references/examples.md +24 -0
  39. package/skills/supabase-debug-bundle/references/implementation.md +54 -0
  40. package/skills/supabase-deploy-integration/SKILL.md +258 -147
  41. package/skills/supabase-deploy-integration/references/errors.md +11 -0
  42. package/skills/supabase-deploy-integration/references/examples.md +21 -0
  43. package/skills/supabase-deploy-integration/references/google-cloud-run.md +36 -0
  44. package/skills/supabase-deploy-integration/references/vercel-deployment.md +35 -0
  45. package/skills/supabase-enterprise-rbac/SKILL.md +327 -160
  46. package/skills/supabase-enterprise-rbac/references/api-scoping-and-enforcement.md +255 -0
  47. package/skills/supabase-enterprise-rbac/references/errors.md +11 -0
  48. package/skills/supabase-enterprise-rbac/references/examples.md +12 -0
  49. package/skills/supabase-enterprise-rbac/references/role-implementation.md +33 -0
  50. package/skills/supabase-enterprise-rbac/references/sso-integration.md +35 -0
  51. package/skills/supabase-hello-world/SKILL.md +160 -54
  52. package/skills/supabase-incident-runbook/SKILL.md +453 -131
  53. package/skills/supabase-incident-runbook/references/errors.md +11 -0
  54. package/skills/supabase-incident-runbook/references/examples.md +10 -0
  55. package/skills/supabase-incident-runbook/references/immediate-actions-by-error-type.md +41 -0
  56. package/skills/supabase-install-auth/SKILL.md +186 -50
  57. package/skills/supabase-install-auth/references/examples.md +102 -0
  58. package/skills/supabase-known-pitfalls/SKILL.md +411 -241
  59. package/skills/supabase-known-pitfalls/references/errors.md +11 -0
  60. package/skills/supabase-known-pitfalls/references/examples.md +12 -0
  61. package/skills/supabase-load-scale/SKILL.md +346 -217
  62. package/skills/supabase-load-scale/references/capacity-planning.md +47 -0
  63. package/skills/supabase-load-scale/references/errors.md +11 -0
  64. package/skills/supabase-load-scale/references/examples.md +26 -0
  65. package/skills/supabase-load-scale/references/load-testing-with-k6.md +59 -0
  66. package/skills/supabase-load-scale/references/scaling-patterns.md +65 -0
  67. package/skills/supabase-load-scale/references/table-partitioning.md +263 -0
  68. package/skills/supabase-local-dev-loop/SKILL.md +272 -73
  69. package/skills/supabase-local-dev-loop/references/errors.md +11 -0
  70. package/skills/supabase-local-dev-loop/references/examples.md +21 -0
  71. package/skills/supabase-local-dev-loop/references/implementation.md +60 -0
  72. package/skills/supabase-migration-deep-dive/SKILL.md +338 -177
  73. package/skills/supabase-migration-deep-dive/references/backfill-versioning-rollback.md +258 -0
  74. package/skills/supabase-migration-deep-dive/references/errors.md +11 -0
  75. package/skills/supabase-migration-deep-dive/references/examples.md +12 -0
  76. package/skills/supabase-migration-deep-dive/references/implementation-plan.md +80 -0
  77. package/skills/supabase-migration-deep-dive/references/pre-migration-assessment.md +39 -0
  78. package/skills/supabase-multi-env-setup/SKILL.md +393 -152
  79. package/skills/supabase-multi-env-setup/references/configuration-structure.md +59 -0
  80. package/skills/supabase-multi-env-setup/references/errors.md +11 -0
  81. package/skills/supabase-multi-env-setup/references/examples.md +11 -0
  82. package/skills/supabase-observability/SKILL.md +318 -196
  83. package/skills/supabase-observability/references/alert-configuration.md +40 -0
  84. package/skills/supabase-observability/references/errors.md +11 -0
  85. package/skills/supabase-observability/references/examples.md +13 -0
  86. package/skills/supabase-observability/references/metrics-collection.md +65 -0
  87. package/skills/supabase-performance-tuning/SKILL.md +304 -160
  88. package/skills/supabase-performance-tuning/references/caching-strategy.md +49 -0
  89. package/skills/supabase-performance-tuning/references/errors.md +11 -0
  90. package/skills/supabase-performance-tuning/references/examples.md +13 -0
  91. package/skills/supabase-policy-guardrails/SKILL.md +248 -221
  92. package/skills/supabase-policy-guardrails/references/ci-cost-security.md +484 -0
  93. package/skills/supabase-policy-guardrails/references/errors.md +11 -0
  94. package/skills/supabase-policy-guardrails/references/eslint-rules.md +46 -0
  95. package/skills/supabase-policy-guardrails/references/examples.md +10 -0
  96. package/skills/supabase-prod-checklist/SKILL.md +474 -84
  97. package/skills/supabase-prod-checklist/references/errors.md +63 -0
  98. package/skills/supabase-prod-checklist/references/examples.md +153 -0
  99. package/skills/supabase-prod-checklist/references/implementation.md +113 -0
  100. package/skills/supabase-rate-limits/SKILL.md +311 -98
  101. package/skills/supabase-rate-limits/references/errors.md +11 -0
  102. package/skills/supabase-rate-limits/references/examples.md +46 -0
  103. package/skills/supabase-rate-limits/references/implementation.md +66 -0
  104. package/skills/supabase-reference-architecture/SKILL.md +249 -182
  105. package/skills/supabase-reference-architecture/references/errors.md +29 -0
  106. package/skills/supabase-reference-architecture/references/examples.md +116 -0
  107. package/skills/supabase-reference-architecture/references/key-components.md +244 -0
  108. package/skills/supabase-reference-architecture/references/project-structure.md +109 -0
  109. package/skills/supabase-reliability-patterns/SKILL.md +229 -234
  110. package/skills/supabase-reliability-patterns/references/circuit-breaker.md +36 -0
  111. package/skills/supabase-reliability-patterns/references/dead-letter-queue.md +48 -0
  112. package/skills/supabase-reliability-patterns/references/errors.md +11 -0
  113. package/skills/supabase-reliability-patterns/references/examples.md +11 -0
  114. package/skills/supabase-reliability-patterns/references/idempotency-keys.md +36 -0
  115. package/skills/supabase-reliability-patterns/references/offline-degradation-health-dualwrite.md +489 -0
  116. package/skills/supabase-schema-from-requirements/SKILL.md +373 -34
  117. package/skills/supabase-sdk-patterns/SKILL.md +388 -99
  118. package/skills/supabase-sdk-patterns/references/errors.md +11 -0
  119. package/skills/supabase-sdk-patterns/references/examples.md +45 -0
  120. package/skills/supabase-sdk-patterns/references/implementation.md +67 -0
  121. package/skills/supabase-security-basics/SKILL.md +282 -102
  122. package/skills/supabase-security-basics/references/errors.md +10 -0
  123. package/skills/supabase-security-basics/references/examples.md +70 -0
  124. package/skills/supabase-security-basics/references/implementation.md +39 -0
  125. package/skills/supabase-upgrade-migration/SKILL.md +248 -66
  126. package/skills/supabase-upgrade-migration/references/errors.md +10 -0
  127. package/skills/supabase-upgrade-migration/references/examples.md +51 -0
  128. package/skills/supabase-upgrade-migration/references/implementation.md +29 -0
  129. package/skills/supabase-webhooks-events/SKILL.md +412 -138
  130. package/skills/supabase-webhooks-events/references/errors.md +55 -0
  131. package/skills/supabase-webhooks-events/references/event-handler-pattern.md +106 -0
  132. package/skills/supabase-webhooks-events/references/examples.md +133 -0
  133. package/skills/supabase-webhooks-events/references/signature-verification.md +165 -0
@@ -1,112 +1,294 @@
1
1
  ---
2
2
  name: supabase-upgrade-migration
3
- description: |
4
- Analyze, plan, and execute Supabase SDK upgrades with breaking change detection.
5
- Use when upgrading Supabase SDK versions, detecting deprecations,
6
- or migrating to new API versions.
7
- Trigger with phrases like "upgrade supabase", "supabase migration",
8
- "supabase breaking changes", "update supabase SDK", "analyze supabase version".
9
- allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(git:*)
3
+ description: "Upgrade Supabase SDK and CLI versions with breaking-change detection\
4
+ \ and automated code migration.\nUse when upgrading @supabase/supabase-js (v1\u2192\
5
+ v2 or minor bumps), migrating auth/realtime/storage\nAPIs, or updating the Supabase\
6
+ \ CLI. Trigger with phrases like \"upgrade supabase\",\n\"supabase breaking changes\"\
7
+ , \"migrate supabase v2\", \"update supabase SDK\".\n"
8
+ allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*), Bash(pip:*), Bash(supabase:*),
9
+ Bash(git:*), Grep, Glob
10
10
  version: 1.0.0
11
11
  license: MIT
12
12
  author: Jeremy Longshore <jeremy@intentsolutions.io>
13
+ tags:
14
+ - saas
15
+ - supabase
16
+ - migration
17
+ - upgrade
18
+ - sdk
19
+ compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
13
20
  ---
14
-
15
- # Supabase Upgrade & Migration
21
+ # Supabase Upgrade Migration
16
22
 
17
23
  ## Overview
18
- Guide for upgrading Supabase SDK versions and handling breaking changes.
24
+
25
+ Upgrade `@supabase/supabase-js` and the Supabase CLI with breaking-change detection, automated code migration, and rollback planning. Covers the v1-to-v2 migration path (auth method renames, `data`/`error` destructuring, realtime API overhaul), minor version bumps, `@supabase/ssr` adoption, and Python SDK upgrades via `pip install --upgrade supabase`.
26
+
27
+ ## Current State
28
+
29
+ !`npm list @supabase/supabase-js 2>/dev/null | grep supabase || echo 'supabase-js not installed'`
30
+ !`supabase --version 2>/dev/null || echo 'CLI not installed'`
31
+ !`pip show supabase 2>/dev/null | grep Version || echo 'Python SDK not installed'`
19
32
 
20
33
  ## Prerequisites
21
- - Current Supabase SDK installed
22
- - Git for version control
23
- - Test suite available
24
- - Staging environment
34
+
35
+ - `@supabase/supabase-js` or the Python `supabase` package installed in the project
36
+ - Git with a clean working tree (no uncommitted changes)
37
+ - Test suite available for post-upgrade verification
38
+ - Node.js >= 18 (for supabase-js v2) or Python >= 3.8 (for Python SDK)
25
39
 
26
40
  ## Instructions
27
41
 
28
- ### Step 1: Check Current Version
42
+ ### Step 1: Audit Versions, Scan Usage, and Review Breaking Changes
43
+
44
+ Check every installed Supabase package and find all import sites in the codebase.
45
+
29
46
  ```bash
47
+ # Check current SDK version
30
48
  npm list @supabase/supabase-js
31
- npm view @supabase/supabase-js version
49
+
50
+ # Check CLI version
51
+ supabase --version
52
+
53
+ # Check Python SDK version
54
+ pip show supabase | grep Version
55
+
56
+ # Find all JS/TS Supabase imports
57
+ grep -rn "from '@supabase/supabase-js'" --include="*.ts" --include="*.tsx" --include="*.js" src/ lib/ app/ 2>/dev/null
58
+ grep -rn "createClient" --include="*.ts" --include="*.tsx" --include="*.js" src/ lib/ app/ 2>/dev/null
59
+
60
+ # Find all Python Supabase imports
61
+ grep -rn "from supabase" --include="*.py" src/ app/ 2>/dev/null
32
62
  ```
33
63
 
34
- ### Step 2: Review Changelog
35
- ```bash
36
- open https://github.com/supabase/sdk/releases
64
+ **supabase-js v1 v2 breaking changes:**
65
+
66
+ | v1 Pattern | v2 Replacement | Notes |
67
+ |-----------|---------------|-------|
68
+ | `createClient(url, key)` | `createClient(url, key)` | Signature unchanged, but return type differs |
69
+ | `supabase.auth.session()` | `supabase.auth.getSession()` | Sync → async, returns `{ data: { session } }` |
70
+ | `supabase.auth.user()` | `supabase.auth.getUser()` | Sync → async, returns `{ data: { user } }` |
71
+ | `supabase.auth.signIn({ email, password })` | `supabase.auth.signInWithPassword({ email, password })` | Method split by auth type |
72
+ | `supabase.auth.signIn({ provider: 'google' })` | `supabase.auth.signInWithOAuth({ provider: 'google' })` | OAuth separated |
73
+ | `supabase.auth.signIn({ email })` | `supabase.auth.signInWithOtp({ email })` | Magic link separated |
74
+ | `supabase.auth.api.resetPasswordForEmail(e)` | `supabase.auth.resetPasswordForEmail(e)` | `.api` namespace removed |
75
+ | `{ data: subscription }` from `onAuthStateChange` | `{ data: { subscription } }` | Extra destructuring level |
76
+ | `error.message` string parsing | `error.code` enum (`PGRST116`, etc.) | Reliable error matching |
77
+ | `.single()` returns error on 0 rows | `.maybeSingle()` for optional rows | New method for nullable results |
78
+ | `supabase.from('t').on('INSERT', cb).subscribe()` | `supabase.channel('c').on('postgres_changes', ...).subscribe()` | Realtime v2 channel API |
79
+ | `supabase.storage.from('b').download('path')` | Same, but returns `{ data: Blob, error }` | Consistent error/data tuple |
80
+
81
+ **Realtime v2 migration detail:**
82
+
83
+ ```typescript
84
+ // v1 realtime
85
+ supabase
86
+ .from('messages')
87
+ .on('INSERT', (payload) => console.log(payload.new))
88
+ .subscribe()
89
+
90
+ // v2 realtime — channel-based API
91
+ supabase
92
+ .channel('messages-insert')
93
+ .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'messages' },
94
+ (payload) => console.log(payload.new))
95
+ .subscribe()
37
96
  ```
38
97
 
39
- ### Step 3: Create Upgrade Branch
98
+ ### Step 2: Run the Upgrade and Apply Code Migrations
99
+
100
+ Create a branch, install new packages, and transform code to match v2 APIs.
101
+
40
102
  ```bash
41
- git checkout -b upgrade/supabase-sdk-vX.Y.Z
103
+ # Create upgrade branch
104
+ git checkout -b upgrade-supabase-sdk
105
+
106
+ # Upgrade JS/TS SDK
42
107
  npm install @supabase/supabase-js@latest
43
- npm test
44
- ```
45
108
 
46
- ### Step 4: Handle Breaking Changes
47
- Update import statements, configuration, and method signatures as needed.
109
+ # Upgrade SSR helper (if used with Next.js/SvelteKit/Nuxt)
110
+ npm install @supabase/ssr@latest
48
111
 
49
- ## Output
50
- - Updated SDK version
51
- - Fixed breaking changes
52
- - Passing test suite
53
- - Documented rollback procedure
112
+ # Upgrade CLI
113
+ npm install -g supabase@latest
54
114
 
55
- ## Error Handling
56
- | SDK Version | API Version | Node.js | Breaking Changes |
57
- |-------------|-------------|---------|------------------|
58
- | 3.x | 2024-01 | 18+ | Major refactor |
59
- | 2.x | 2023-06 | 16+ | Auth changes |
60
- | 1.x | 2022-01 | 14+ | Initial release |
115
+ # Upgrade Python SDK
116
+ pip install --upgrade supabase
61
117
 
62
- ## Examples
118
+ # Regenerate TypeScript types from linked project
119
+ npx supabase gen types typescript --linked > lib/database.types.ts
120
+
121
+ # Generate a database migration if schema drifted
122
+ npx supabase db diff --use-migra -f upgrade_check
123
+ ```
124
+
125
+ Apply auth code migrations:
63
126
 
64
- ### Import Changes
65
127
  ```typescript
66
- // Before (v1.x)
67
- import { Client } from '@supabase/supabase-js';
128
+ // BEFORE (v1 auth patterns)
129
+ const session = supabase.auth.session()
130
+ const user = supabase.auth.user()
131
+ const { error } = await supabase.auth.signIn({ email, password })
132
+ const { data: subscription } = supabase.auth.onAuthStateChange(callback)
68
133
 
69
- // After (v2.x)
70
- import { SupabaseClient } from '@supabase/supabase-js';
134
+ // AFTER (v2 auth patterns)
135
+ const { data: { session } } = await supabase.auth.getSession()
136
+ const { data: { user } } = await supabase.auth.getUser()
137
+ const { error } = await supabase.auth.signInWithPassword({ email, password })
138
+ const { data: { subscription } } = supabase.auth.onAuthStateChange(callback)
71
139
  ```
72
140
 
73
- ### Configuration Changes
141
+ Apply error handling migration:
142
+
74
143
  ```typescript
75
- // Before (v1.x)
76
- const client = new Client({ key: 'xxx' });
144
+ // BEFORE (v1 — string matching)
145
+ if (error.message.includes('not found')) { ... }
77
146
 
78
- // After (v2.x)
79
- const client = new SupabaseClient({
80
- apiKey: 'xxx',
81
- });
147
+ // AFTER (v2 — structured error codes)
148
+ if (error.code === 'PGRST116') { ... } // "not found" → PGRST116
82
149
  ```
83
150
 
84
- ### Rollback Procedure
151
+ ### Step 3: Verify, Test, and Prepare Rollback
152
+
85
153
  ```bash
86
- npm install @supabase/supabase-js@1.x.x --save-exact
154
+ # Type check (catches 90% of migration issues)
155
+ npx tsc --noEmit
156
+
157
+ # Run test suite
158
+ npm test
159
+
160
+ # Python tests
161
+ python -m pytest tests/ -v
162
+
163
+ # Manual smoke test critical auth flows:
164
+ # 1. Sign up → confirm email → sign in with password
165
+ # 2. OAuth sign in → callback handling
166
+ # 3. Password reset → email → reset form
167
+ # 4. Session refresh across page navigations
168
+ # 5. Realtime subscription connect/disconnect
169
+ # 6. Storage upload/download round-trip
170
+ ```
171
+
172
+ **Rollback procedure** (if upgrade causes issues):
173
+
174
+ ```text
175
+ # Option A: Pin to previous version
176
+ npm install @supabase/supabase-js@<previous-version>
177
+ pip install supabase==<previous-version>
178
+
179
+ # Option B: Revert the branch
180
+ git stash && git checkout main
181
+ ```
182
+
183
+ ## Output
184
+
185
+ - `@supabase/supabase-js` upgraded to latest version with `npm list` confirmation
186
+ - All `supabase.auth.signIn()` calls migrated to `signInWithPassword` / `signInWithOAuth` / `signInWithOtp`
187
+ - Sync auth methods (`session()`, `user()`) replaced with async `getSession()` / `getUser()`
188
+ - Realtime subscriptions migrated from `.on()` to channel-based API
189
+ - `data`/`error` destructuring updated where return shapes changed
190
+ - TypeScript types regenerated from current schema
191
+ - Test suite passing, type checking clean
192
+ - Rollback branch or version pin documented
193
+
194
+ ## Error Handling
195
+
196
+ | Error | Cause | Solution |
197
+ |-------|-------|----------|
198
+ | `Property 'session' does not exist` | v1 sync `.session()` removed in v2 | Replace with `await supabase.auth.getSession()` |
199
+ | `Property 'signIn' does not exist` | `signIn` split into multiple methods in v2 | Use `signInWithPassword`, `signInWithOAuth`, or `signInWithOtp` |
200
+ | `supabase.auth.api` is undefined | `.api` namespace removed in v2 | Call methods directly on `supabase.auth.*` |
201
+ | `TypeError: supabase.from(...).on is not a function` | Realtime API replaced in v2 | Use `supabase.channel().on('postgres_changes', ...)` |
202
+ | Type errors after `gen types` | Database schema changed between versions | Update application code to match new generated types |
203
+ | `PGRST116` error on `.single()` | Zero rows returned (v2 throws) | Use `.maybeSingle()` for optional lookups |
204
+ | `ERR_REQUIRE_ESM` after upgrade | v2 is ESM-only in some bundlers | Update `tsconfig.json` to `"module": "esnext"` or use dynamic `import()` |
205
+ | `AuthSessionMissingError` | `getSession()` called before auth initialized | Wrap in `onAuthStateChange` listener or check `session !== null` |
206
+
207
+ ## Examples
208
+
209
+ **Full v1 → v2 auth migration (Next.js):**
210
+
211
+ ```typescript
212
+ // lib/supabase.ts — client initialization (unchanged API)
213
+ import { createClient } from '@supabase/supabase-js'
214
+ import type { Database } from './database.types'
215
+
216
+ export const supabase = createClient<Database>(
217
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
218
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
219
+ )
87
220
  ```
88
221
 
89
- ### Deprecation Handling
90
222
  ```typescript
91
- // Monitor for deprecation warnings in development
92
- if (process.env.NODE_ENV === 'development') {
93
- process.on('warning', (warning) => {
94
- if (warning.name === 'DeprecationWarning') {
95
- console.warn('[Supabase]', warning.message);
96
- // Log to tracking system for proactive updates
223
+ // app/login/page.tsx v2 auth flow
224
+ export async function login(email: string, password: string) {
225
+ const { data, error } = await supabase.auth.signInWithPassword({
226
+ email,
227
+ password,
228
+ })
229
+ if (error) {
230
+ // v2: use error.code instead of parsing error.message
231
+ if (error.code === 'invalid_credentials') {
232
+ return { success: false, message: 'Invalid email or password' }
97
233
  }
98
- });
234
+ throw error
235
+ }
236
+ return { success: true, session: data.session }
237
+ }
238
+ ```
239
+
240
+ ```typescript
241
+ // hooks/useAuth.ts — v2 session listener
242
+ import { useEffect, useState } from 'react'
243
+ import { supabase } from '@/lib/supabase'
244
+ import type { Session } from '@supabase/supabase-js'
245
+
246
+ export function useAuth() {
247
+ const [session, setSession] = useState<Session | null>(null)
248
+
249
+ useEffect(() => {
250
+ // v2: getSession is async, returns nested { data: { session } }
251
+ supabase.auth.getSession().then(({ data: { session } }) => {
252
+ setSession(session)
253
+ })
254
+
255
+ // v2: subscription nested one level deeper
256
+ const { data: { subscription } } = supabase.auth.onAuthStateChange(
257
+ (_event, session) => setSession(session)
258
+ )
259
+
260
+ return () => subscription.unsubscribe()
261
+ }, [])
262
+
263
+ return session
99
264
  }
265
+ ```
100
266
 
101
- // Common deprecation patterns to watch for:
102
- // - Renamed methods: client.oldMethod() -> client.newMethod()
103
- // - Changed parameters: { key: 'x' } -> { apiKey: 'x' }
104
- // - Removed features: Check release notes before upgrading
267
+ **Python SDK upgrade:**
268
+
269
+ ```python
270
+ # Before (supabase-py < 2.0)
271
+ from supabase import create_client
272
+ supabase = create_client(url, key)
273
+ data = supabase.table("users").select("*").execute()
274
+ users = data["data"]
275
+
276
+ # After (supabase-py >= 2.0)
277
+ from supabase import create_client, Client
278
+ supabase: Client = create_client(url, key)
279
+ response = supabase.table("users").select("*").execute()
280
+ users = response.data # attribute access, not dict
105
281
  ```
106
282
 
107
283
  ## Resources
108
- - [Supabase Changelog](https://github.com/supabase/sdk/releases)
109
- - [Supabase Migration Guide](https://supabase.com/docs/migration)
284
+
285
+ - supabase-js v2 Migration Guide — official step-by-step
286
+ - [supabase-js Releases](https://github.com/supabase/supabase-js/releases) — changelog for every version
287
+ - [Supabase CLI Releases](https://github.com/supabase/cli/releases) — CLI changelog
288
+ - Auth Helpers Migration — `@supabase/auth-helpers` → `@supabase/ssr`
289
+ - [Realtime v2 Guide](https://supabase.com/docs/guides/realtime) — channel-based API reference
290
+ - [supabase-py Releases](https://github.com/supabase-community/supabase-py/releases) — Python SDK changelog
110
291
 
111
292
  ## Next Steps
112
- For CI integration during upgrades, see `supabase-ci-integration`.
293
+
294
+ For CI integration with the upgraded SDK, see `supabase-ci-integration`. For database migration workflows after schema changes, see `supabase-migration-deep-dive`.
@@ -0,0 +1,10 @@
1
+ # Error Handling Reference
2
+
3
+ | SDK Version | API Version | Node.js | Breaking Changes |
4
+ |-------------|-------------|---------|------------------|
5
+ | 3.x | 2024-01 | 18+ | Major refactor |
6
+ | 2.x | 2023-06 | 16+ | Auth changes |
7
+ | 1.x | 2022-01 | 14+ | Initial release |
8
+
9
+ ---
10
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
@@ -0,0 +1,51 @@
1
+ ## Examples
2
+
3
+ ### Import Changes
4
+
5
+ ```typescript
6
+ // Before (v1.x)
7
+ import { Client } from '@supabase/supabase-js';
8
+
9
+ // After (v2.x)
10
+ import { SupabaseClient } from '@supabase/supabase-js';
11
+ ```
12
+
13
+ ### Configuration Changes
14
+
15
+ ```typescript
16
+ // Before (v1.x)
17
+ const client = new Client({ key: 'xxx' });
18
+
19
+ // After (v2.x)
20
+ const client = new SupabaseClient({
21
+ apiKey: 'xxx',
22
+ });
23
+ ```
24
+
25
+ ### Rollback Procedure
26
+
27
+ ```bash
28
+ npm install @supabase/supabase-js@1.x.x --save-exact
29
+ ```
30
+
31
+ ### Deprecation Handling
32
+
33
+ ```typescript
34
+ // Monitor for deprecation warnings in development
35
+ if (process.env.NODE_ENV === 'development') {
36
+ process.on('warning', (warning) => {
37
+ if (warning.name === 'DeprecationWarning') {
38
+ console.warn('[Supabase]', warning.message);
39
+ // Log to tracking system for proactive updates
40
+ }
41
+ });
42
+ }
43
+
44
+ // Common deprecation patterns to watch for:
45
+ // - Renamed methods: client.oldMethod() -> client.newMethod()
46
+ // - Changed parameters: { key: 'x' } -> { apiKey: 'x' }
47
+ // - Removed features: Check release notes before upgrading
48
+ ```
49
+
50
+ ---
51
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
@@ -0,0 +1,29 @@
1
+ ## Implementation Guide
2
+
3
+ ### Step 1: Check Current Version
4
+
5
+ ```bash
6
+ npm list @supabase/supabase-js
7
+ npm view @supabase/supabase-js version
8
+ ```
9
+
10
+ ### Step 2: Review Changelog
11
+
12
+ ```bash
13
+ open https://github.com/supabase/sdk/releases
14
+ ```
15
+
16
+ ### Step 3: Create Upgrade Branch
17
+
18
+ ```bash
19
+ git checkout -b upgrade/supabase-sdk-vX.Y.Z
20
+ npm install @supabase/supabase-js@latest
21
+ npm test
22
+ ```
23
+
24
+ ### Step 4: Handle Breaking Changes
25
+
26
+ Update import statements, configuration, and method signatures as needed.
27
+
28
+ ---
29
+ *[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*