@protobase/server 0.133.3 → 0.133.4
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.
|
@@ -6,6 +6,7 @@ import { storeSqlOf } from "../store/store-sql.js";
|
|
|
6
6
|
import { mayBeId } from "../store/store-reads.js";
|
|
7
7
|
import { pageOf } from "../store/page-of.js";
|
|
8
8
|
import { builderName, rowsIn } from "./host-scope.js";
|
|
9
|
+
import { notDefaultOrganization } from "./not-default.js";
|
|
9
10
|
import { isEveryOrganization } from "@protobase/query";
|
|
10
11
|
import { sql } from "kysely";
|
|
11
12
|
//#region src/better-auth/organizations/host.ts
|
|
@@ -285,11 +286,11 @@ const organizationsPage = async (auth, scope, { after, size = 100 }) => {
|
|
|
285
286
|
const ownOrganizationsWithoutMembers = (auth, userId) => acrossOrganizations("the first user owns every organization without members", () => ownEmptyOrganizations(auth, userId));
|
|
286
287
|
const ownEmptyOrganizations = async (auth, userId) => {
|
|
287
288
|
const settings = settingsOf(auth);
|
|
288
|
-
const
|
|
289
|
+
const context = await contextOf(auth);
|
|
290
|
+
const store = storeSqlOf(context);
|
|
289
291
|
const member = store.table("member");
|
|
290
292
|
const m = member.columns;
|
|
291
|
-
const
|
|
292
|
-
const notDefault = defaultId === void 0 ? sql`` : sql`and cast(o.id as text) <> ${defaultId}`;
|
|
293
|
+
const notDefault = notDefaultOrganization(context.options, settings.options.default?.id);
|
|
293
294
|
const { rows } = await sql`insert into ${member} (id, ${m.organization_id}, ${m.user_id}, ${m.role}, ${m.app_roles}, ${m.created_at})
|
|
294
295
|
select ${store.newId}, o.id, ${userId}, 'owner', ${JSON.stringify(settings.creatorAppRoles)}::jsonb, ${/* @__PURE__ */ new Date()} from ${store.table("organization")} o
|
|
295
296
|
where not exists (select from ${member} m where m.${m.organization_id} = o.id) ${notDefault}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { storedId } from "../store/store-reads.js";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
//#region src/better-auth/organizations/not-default.ts
|
|
4
|
+
/**
|
|
5
|
+
* The condition that leaves the configured default organization out of a statement on `organization o`, nothing without
|
|
6
|
+
* one. Where the ids are uuids, the id is compared as Postgres prints it, so one written in upper case matches too.
|
|
7
|
+
*/
|
|
8
|
+
const notDefaultOrganization = (options, defaultId) => {
|
|
9
|
+
if (defaultId === void 0) return sql``;
|
|
10
|
+
return sql`and cast(o.id as text) <> ${storedId(options, defaultId)}`;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { notDefaultOrganization };
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.133.
|
|
3
|
+
"version": "0.133.4",
|
|
4
4
|
"description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@better-auth/sso": "^1.7.12",
|
|
45
45
|
"@livekit/protocol": "1.53.1",
|
|
46
46
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
47
|
-
"@protobase/layout": "0.133.
|
|
48
|
-
"@protobase/query": "0.133.
|
|
49
|
-
"@protobase/schema": "0.133.
|
|
50
|
-
"@protobase/workflow-plugins": "0.133.
|
|
51
|
-
"@protobase/workflows": "0.133.
|
|
47
|
+
"@protobase/layout": "0.133.4",
|
|
48
|
+
"@protobase/query": "0.133.4",
|
|
49
|
+
"@protobase/schema": "0.133.4",
|
|
50
|
+
"@protobase/workflow-plugins": "0.133.4",
|
|
51
|
+
"@protobase/workflows": "0.133.4",
|
|
52
52
|
"@react-email/render": "^2.1.0",
|
|
53
53
|
"@react-pdf/primitives": "^4.4.0",
|
|
54
54
|
"@react-pdf/renderer": "^4.9.1",
|