@paddock-connect/core 1.0.2 → 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.
- package/dist/index.cjs +39 -16
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +39 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(index_exports, {
|
|
|
23
23
|
PaddockConnect: () => PaddockConnect
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var import_resend = require("resend");
|
|
27
26
|
var PaddockConnect = class {
|
|
28
27
|
supabase;
|
|
29
28
|
resend;
|
|
@@ -180,22 +179,46 @@ var PaddockConnect = class {
|
|
|
180
179
|
await Promise.all(emailPromises);
|
|
181
180
|
return { data: true, error: null };
|
|
182
181
|
}
|
|
183
|
-
async createNewPost(formData,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
182
|
+
async createNewPost(formData, userId) {
|
|
183
|
+
if (!userId) {
|
|
184
|
+
return { data: null, error: new Error("User ID is required") };
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const { data: profile, error: profileError } = await this.supabase.from("profiles").select("address, fav_team, fav_driver, county").eq("id", userId).single();
|
|
188
|
+
if (profileError || !profile) {
|
|
189
|
+
return {
|
|
190
|
+
data: null,
|
|
191
|
+
error: profileError || new Error("Profile not found")
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
const bannerFile = formData.get("banner");
|
|
195
|
+
const filePath = `${userId}/${Date.now()}_${bannerFile.name}`;
|
|
196
|
+
const { error: uploadError } = await this.supabase.storage.from("banners").upload(filePath, bannerFile);
|
|
197
|
+
if (uploadError) {
|
|
198
|
+
return { data: null, error: uploadError };
|
|
199
|
+
}
|
|
200
|
+
const {
|
|
201
|
+
data: { publicUrl }
|
|
202
|
+
} = this.supabase.storage.from("banners").getPublicUrl(filePath);
|
|
203
|
+
const { error: insertError } = await this.supabase.from("posts").insert({
|
|
204
|
+
user_id: userId,
|
|
205
|
+
post_title: formData.get("title"),
|
|
206
|
+
post_content: formData.get("content"),
|
|
207
|
+
post_event_date: formData.get("screeningDate"),
|
|
208
|
+
user_address: profile.address,
|
|
209
|
+
user_fav_team: profile.fav_team,
|
|
210
|
+
user_fav_driver: profile.fav_driver,
|
|
211
|
+
user_county: profile.county,
|
|
212
|
+
post_media_url: publicUrl
|
|
213
|
+
});
|
|
214
|
+
if (insertError) {
|
|
215
|
+
await this.supabase.storage.from("banners").remove([filePath]);
|
|
216
|
+
return { data: null, error: insertError };
|
|
217
|
+
}
|
|
218
|
+
return { data: true, error: null };
|
|
219
|
+
} catch (err) {
|
|
220
|
+
return { data: null, error: err };
|
|
197
221
|
}
|
|
198
|
-
return { data: true, error: null };
|
|
199
222
|
}
|
|
200
223
|
async getUserProfile() {
|
|
201
224
|
const { data, error: sbError } = await this.supabase.from("profiles").select();
|
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,7 @@ declare class PaddockConnect {
|
|
|
33
33
|
county?: string;
|
|
34
34
|
team?: string;
|
|
35
35
|
driver?: string;
|
|
36
|
+
post_media_url?: string;
|
|
36
37
|
}): Promise<{
|
|
37
38
|
data: any[] | null;
|
|
38
39
|
error: PostgrestError | null;
|
|
@@ -57,6 +58,7 @@ declare class PaddockConnect {
|
|
|
57
58
|
data: {
|
|
58
59
|
post_title: string | undefined;
|
|
59
60
|
post_content: string | undefined;
|
|
61
|
+
post_media_url: string;
|
|
60
62
|
} | null;
|
|
61
63
|
error: PostgrestError | null;
|
|
62
64
|
}>;
|
|
@@ -64,9 +66,9 @@ declare class PaddockConnect {
|
|
|
64
66
|
data: boolean | null;
|
|
65
67
|
error: PostgrestError | null;
|
|
66
68
|
}>;
|
|
67
|
-
createNewPost(formData: FormData,
|
|
69
|
+
createNewPost(formData: FormData, userId: string | undefined): Promise<{
|
|
68
70
|
data: boolean | null;
|
|
69
|
-
error: PostgrestError | null;
|
|
71
|
+
error: PostgrestError | RangeError | Error | null;
|
|
70
72
|
}>;
|
|
71
73
|
getUserProfile(): Promise<{
|
|
72
74
|
data: {
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare class PaddockConnect {
|
|
|
33
33
|
county?: string;
|
|
34
34
|
team?: string;
|
|
35
35
|
driver?: string;
|
|
36
|
+
post_media_url?: string;
|
|
36
37
|
}): Promise<{
|
|
37
38
|
data: any[] | null;
|
|
38
39
|
error: PostgrestError | null;
|
|
@@ -57,6 +58,7 @@ declare class PaddockConnect {
|
|
|
57
58
|
data: {
|
|
58
59
|
post_title: string | undefined;
|
|
59
60
|
post_content: string | undefined;
|
|
61
|
+
post_media_url: string;
|
|
60
62
|
} | null;
|
|
61
63
|
error: PostgrestError | null;
|
|
62
64
|
}>;
|
|
@@ -64,9 +66,9 @@ declare class PaddockConnect {
|
|
|
64
66
|
data: boolean | null;
|
|
65
67
|
error: PostgrestError | null;
|
|
66
68
|
}>;
|
|
67
|
-
createNewPost(formData: FormData,
|
|
69
|
+
createNewPost(formData: FormData, userId: string | undefined): Promise<{
|
|
68
70
|
data: boolean | null;
|
|
69
|
-
error: PostgrestError | null;
|
|
71
|
+
error: PostgrestError | RangeError | Error | null;
|
|
70
72
|
}>;
|
|
71
73
|
getUserProfile(): Promise<{
|
|
72
74
|
data: {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import "resend";
|
|
3
2
|
var PaddockConnect = class {
|
|
4
3
|
supabase;
|
|
5
4
|
resend;
|
|
@@ -156,22 +155,46 @@ var PaddockConnect = class {
|
|
|
156
155
|
await Promise.all(emailPromises);
|
|
157
156
|
return { data: true, error: null };
|
|
158
157
|
}
|
|
159
|
-
async createNewPost(formData,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
158
|
+
async createNewPost(formData, userId) {
|
|
159
|
+
if (!userId) {
|
|
160
|
+
return { data: null, error: new Error("User ID is required") };
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const { data: profile, error: profileError } = await this.supabase.from("profiles").select("address, fav_team, fav_driver, county").eq("id", userId).single();
|
|
164
|
+
if (profileError || !profile) {
|
|
165
|
+
return {
|
|
166
|
+
data: null,
|
|
167
|
+
error: profileError || new Error("Profile not found")
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const bannerFile = formData.get("banner");
|
|
171
|
+
const filePath = `${userId}/${Date.now()}_${bannerFile.name}`;
|
|
172
|
+
const { error: uploadError } = await this.supabase.storage.from("banners").upload(filePath, bannerFile);
|
|
173
|
+
if (uploadError) {
|
|
174
|
+
return { data: null, error: uploadError };
|
|
175
|
+
}
|
|
176
|
+
const {
|
|
177
|
+
data: { publicUrl }
|
|
178
|
+
} = this.supabase.storage.from("banners").getPublicUrl(filePath);
|
|
179
|
+
const { error: insertError } = await this.supabase.from("posts").insert({
|
|
180
|
+
user_id: userId,
|
|
181
|
+
post_title: formData.get("title"),
|
|
182
|
+
post_content: formData.get("content"),
|
|
183
|
+
post_event_date: formData.get("screeningDate"),
|
|
184
|
+
user_address: profile.address,
|
|
185
|
+
user_fav_team: profile.fav_team,
|
|
186
|
+
user_fav_driver: profile.fav_driver,
|
|
187
|
+
user_county: profile.county,
|
|
188
|
+
post_media_url: publicUrl
|
|
189
|
+
});
|
|
190
|
+
if (insertError) {
|
|
191
|
+
await this.supabase.storage.from("banners").remove([filePath]);
|
|
192
|
+
return { data: null, error: insertError };
|
|
193
|
+
}
|
|
194
|
+
return { data: true, error: null };
|
|
195
|
+
} catch (err) {
|
|
196
|
+
return { data: null, error: err };
|
|
173
197
|
}
|
|
174
|
-
return { data: true, error: null };
|
|
175
198
|
}
|
|
176
199
|
async getUserProfile() {
|
|
177
200
|
const { data, error: sbError } = await this.supabase.from("profiles").select();
|