@iebh/tera-fy 2.0.12 → 2.0.13
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/CHANGELOG.md +7 -0
- package/lib/syncro/entities.js +19 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.13](https://github.com/IEBH/TERA-fy/compare/v2.0.12...v2.0.13) (2025-03-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### fix
|
|
7
|
+
|
|
8
|
+
* Create user via Syncro row if it doesnt already exist ([5a9dfe2](https://github.com/IEBH/TERA-fy/commit/5a9dfe286d16f4bcddcfd0870db0d194342ba4ab))
|
|
9
|
+
|
|
3
10
|
## [2.0.12](https://github.com/IEBH/TERA-fy/compare/v2.0.11...v2.0.12) (2025-03-12)
|
|
4
11
|
|
|
5
12
|
## [2.0.11](https://github.com/IEBH/TERA-fy/compare/v2.0.9...v2.0.11) (2025-03-10)
|
package/lib/syncro/entities.js
CHANGED
|
@@ -185,10 +185,27 @@ export default {
|
|
|
185
185
|
return Syncro.wrapSupabase(supabase.from('users')
|
|
186
186
|
.select('data')
|
|
187
187
|
.limit(1)
|
|
188
|
+
.maybeSingle()
|
|
188
189
|
.eq('id', id)
|
|
189
190
|
)
|
|
190
|
-
.then(
|
|
191
|
-
|
|
191
|
+
.then(user => {
|
|
192
|
+
if (user) return user.data; // User is valid and already exists
|
|
193
|
+
|
|
194
|
+
// User row doesn't already exist - need to create stub
|
|
195
|
+
return Syncro.wrapSupabase(supabase.from('users')
|
|
196
|
+
.insert({
|
|
197
|
+
data: {
|
|
198
|
+
id,
|
|
199
|
+
data: { // Create user prototype data
|
|
200
|
+
id,
|
|
201
|
+
credits: 1000,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
})
|
|
205
|
+
.select('data')
|
|
206
|
+
)
|
|
207
|
+
.then(newUser => newUser.data) // Return back the data that eventually got created - allowing for database triggers, default field values etc.
|
|
208
|
+
})
|
|
192
209
|
},
|
|
193
210
|
flushState({supabase, state, fsId}) {
|
|
194
211
|
return Syncro.wrapSupabase(supabase.rpc('syncro_merge_data', {
|
package/package.json
CHANGED