@perceo/supabase 0.2.0 → 0.2.2
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.d.ts +5 -0
- package/dist/index.js +14 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -505,6 +505,11 @@ declare class PerceoDataClient {
|
|
|
505
505
|
getProjectSecret(projectId: UUID, keyName: string): Promise<string | null>;
|
|
506
506
|
getProject(id: UUID): Promise<Project | null>;
|
|
507
507
|
getProjectByName(name: string): Promise<Project | null>;
|
|
508
|
+
/**
|
|
509
|
+
* Create a project and add the current user as owner (via RPC).
|
|
510
|
+
* Uses create_project_with_owner so the creator is always a member; requires
|
|
511
|
+
* migration 20260214020000_create_project_with_owner_rpc.sql to be applied.
|
|
512
|
+
*/
|
|
508
513
|
createProject(project: ProjectInsert): Promise<Project>;
|
|
509
514
|
upsertProject(project: ProjectInsert): Promise<Project>;
|
|
510
515
|
updateProject(projectId: UUID, updates: Partial<ProjectInsert>): Promise<Project>;
|
package/dist/index.js
CHANGED
|
@@ -119,10 +119,22 @@ var PerceoDataClient = class _PerceoDataClient {
|
|
|
119
119
|
if (error && error.code !== "PGRST116") throw error;
|
|
120
120
|
return data;
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Create a project and add the current user as owner (via RPC).
|
|
124
|
+
* Uses create_project_with_owner so the creator is always a member; requires
|
|
125
|
+
* migration 20260214020000_create_project_with_owner_rpc.sql to be applied.
|
|
126
|
+
*/
|
|
122
127
|
async createProject(project) {
|
|
123
|
-
const { data, error } = await this.supabase.
|
|
128
|
+
const { data, error } = await this.supabase.rpc("create_project_with_owner", {
|
|
129
|
+
p_name: project.name,
|
|
130
|
+
p_framework: project.framework ?? null,
|
|
131
|
+
p_config: project.config ?? {},
|
|
132
|
+
p_git_remote_url: project.git_remote_url ?? null
|
|
133
|
+
});
|
|
124
134
|
if (error) throw error;
|
|
125
|
-
|
|
135
|
+
const row = Array.isArray(data) ? data[0] : data;
|
|
136
|
+
if (!row) throw new Error("create_project_with_owner returned no row");
|
|
137
|
+
return row;
|
|
126
138
|
}
|
|
127
139
|
async upsertProject(project) {
|
|
128
140
|
const { data, error } = await this.supabase.from("projects").upsert(project, { onConflict: "name" }).select().single();
|