@protobase/client 0.21.11 → 0.22.0

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/auth.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SignInPolicy, SignInPolicyState } from "./sign-in-policy.js";
2
2
  import { AccountSignIn, AuthenticatorSetup, Passkey } from "./account-security.js";
3
- import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationRole } from "./organizations.js";
3
+ import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationRole, OrganizationsFound } from "./organizations.js";
4
4
  import { ActiveRole } from "./roles.js";
5
5
  import { StaffSignIn } from "./staff-sign-in.js";
6
6
  import { AuthUser, SetupStatus, SignInResult, TwoFactorMethod } from "./auth-types.js";
@@ -67,7 +67,7 @@ export declare const createAuthSession: (options?: AuthSessionOptions) => {
67
67
  switchTo: (organizationId: string | null) => Promise<{
68
68
  organizationId: string | null;
69
69
  }>;
70
- search: (query: string) => Promise<Organization[]>;
70
+ search: (query: string, offset?: number) => Promise<OrganizationsFound>;
71
71
  create: (input: {
72
72
  name: string;
73
73
  slug: string;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import { routedClient } from "./routed-client.js";
9
9
  import { SourceMeta, sourceMeta } from "./source-meta.js";
10
10
  import { SignInPolicy, SignInPolicyClient, SignInPolicyState, SignInRule, StaffAccessRule } from "./sign-in-policy.js";
11
11
  import { AccountSecurity, AccountSignIn, AuthenticatorSetup, Passkey, RequiredSetup } from "./account-security.js";
12
- import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationRole, OrganizationsClient } from "./organizations.js";
12
+ import { CurrentOrganization, InvitationPreview, InvitationSent, Organization, OrganizationInvitation, OrganizationMember, OrganizationRole, OrganizationsClient, OrganizationsFound } from "./organizations.js";
13
13
  import { ActiveRole, RoleOption, RolesClient } from "./roles.js";
14
14
  import { StaffSignIn, StaffSignInClient } from "./staff-sign-in.js";
15
15
  import { AuthUser, PlatformSignIn, RoleLabel, SamlSignIn, SetupStatus, SignInMethod, SignInResult, TwoFactorMethod } from "./auth-types.js";
@@ -18,4 +18,4 @@ import { AuthSession, AuthSessionOptions, createAuthSession, tokenExpiry } from
18
18
  import { createStaticSession } from "./static-session.js";
19
19
  import { AssistantClient, AssistantClientOptions, AssistantConnection, createAssistantClient } from "./assistant.js";
20
20
  import { RuntimeClient, RuntimeClientOptions, RuntimeLastUpdate, RuntimePolicy, RuntimeStatus, RuntimeUpdateStage, createRuntimeClient } from "./runtime.js";
21
- export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, ApiError, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type CurrentOrganization, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type SamlSignIn, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
21
+ export { type AccountSecurity, type AccountSignIn, type ActiveRole, type Aggregate, type AggregateGroup, type AggregateParams, ApiError, type AssistantClient, type AssistantClientOptions, type AssistantConnection, AuthError, type AuthSession, type AuthSessionOptions, type AuthUser, type AuthenticatorSetup, type BatchOp, type BatchRef, type BatchResult, type Client, type ClientOptions, type CommentPage, type CommentPerson, type CurrentOrganization, type Facet, type FilterInput, type FormChallenge, type FormProof, type Histogram, type HistogramBucket, type HistoryChange, type HistoryPage, type InvitationPreview, type InvitationSent, type InvokeOptions, type ListPage, type ListParams, type MapBounds, type MapBucket, type MapLayerModel, type MapParams, type MapResult, type MentionableUser, type Meta, type MetaResult, type Organization, type OrganizationInvitation, type OrganizationMember, type OrganizationRole, type OrganizationsClient, type OrganizationsFound, type Passkey, type PlatformSignIn, type PluginRef, PreconditionFailedError, type ProblemDetails, type ProblemError, type PublicForm, type RecordComment, type RecordOf, type RecordPermissions, type RecordPhotos, type RelatedLabels, type RequiredSetup, type ResourcePermissions, type ResourceRef, type RoleLabel, type RoleOption, type RolesClient, type RuntimeClient, type RuntimeClientOptions, type RuntimeLastUpdate, type RuntimePolicy, type RuntimeStatus, type RuntimeUpdateStage, type SamlSignIn, type Series, type SeriesParams, type SeriesPoint, type SetupStatus, type SignInMethod, type SignInPolicy, type SignInPolicyClient, type SignInPolicyState, type SignInResult, type SignInRule, type SourceMeta, type SourceRef, type StaffAccessRule, type StaffSignIn, type StaffSignInClient, type Stored, type StoredFile, type StoredFileVariant, type TwoFactorMethod, type UploadOptions, type UploadProgress, type UploadResult, createAssistantClient, createAuthSession, createClient, createRuntimeClient, createStaticSession, fileUrl, filterText, isApiError, listWire, routedClient, sourceMeta, tokenExpiry };
@@ -8,6 +8,11 @@ export type Organization = {
8
8
  slug: string;
9
9
  logo?: string | null;
10
10
  };
11
+ /** A page of organizations and how many there are in all. */
12
+ export type OrganizationsFound = {
13
+ organizations: Organization[];
14
+ total: number;
15
+ };
11
16
  /**
12
17
  * The organization the session works in: for a member with their organization role, app roles there and membership
13
18
  * id; for someone with a global role who entered it without being a member, without them. `globalRoles` are the
@@ -72,8 +77,8 @@ export declare const organizationsClient: (client: BetterAuthClient, refreshToke
72
77
  switchTo: (organizationId: string | null) => Promise<{
73
78
  organizationId: string | null;
74
79
  }>;
75
- /** Every organization whose name or slug contains `query`, for people with a global role. */
76
- search: (query: string) => Promise<Organization[]>;
80
+ /** For people with a global role, 20 organizations by slug from `offset` whose name or slug contains `query`, and the total. */
81
+ search: (query: string, offset?: number) => Promise<OrganizationsFound>;
77
82
  /** Creates an organization, owned by the person with every app role, and works in it. */
78
83
  create: (input: {
79
84
  name: string;
@@ -48,8 +48,11 @@ const organizationsClient = (client, refreshToken) => {
48
48
  current: () => call("/organization/current", "Could not read the current organization"),
49
49
  /** Works in another organization from now on; `null` for none. */
50
50
  switchTo: async (organizationId) => thenRefresh(await call("/organization/switch", "Could not switch the organization", { body: { organizationId } })),
51
- /** Every organization whose name or slug contains `query`, for people with a global role. */
52
- search: async (query) => (await call("/organization/search", "Could not search the organizations", { query: { query } })).organizations,
51
+ /** For people with a global role, 20 organizations by slug from `offset` whose name or slug contains `query`, and the total. */
52
+ search: (query, offset = 0) => call("/organization/search", "Could not search the organizations", { query: {
53
+ query,
54
+ ...offset > 0 && { offset: String(offset) }
55
+ } }),
53
56
  /** Creates an organization, owned by the person with every app role, and works in it. */
54
57
  create: async (input) => thenRefresh(await call("/organization/create", "Could not create the organization", { body: input })),
55
58
  rename: (organizationId, data) => call("/organization/update", "Could not change the organization", { body: {
@@ -10,6 +10,13 @@ const withinSource = (model, drawn) => ({
10
10
  }))
11
11
  });
12
12
  const keptLayoutItem = (item, models) => {
13
+ if (item.kind === "group") {
14
+ const items = item.items.flatMap((inner) => keptLayoutItem(inner, models));
15
+ return items.length > 0 ? [{
16
+ ...item,
17
+ items
18
+ }] : [];
19
+ }
13
20
  if (item.kind !== "related") return [item];
14
21
  if (!Object.hasOwn(models, item.resource) || item.through && !Object.hasOwn(models, item.through.resource)) return [];
15
22
  const { columns, ...rest } = item;
@@ -98,7 +98,10 @@ const createStaticSession = (token, user = {
98
98
  globalRoles: []
99
99
  }),
100
100
  switchTo: unsupported("switch organizations"),
101
- search: async () => [],
101
+ search: async () => ({
102
+ organizations: [],
103
+ total: 0
104
+ }),
102
105
  create: unsupported("create an organization"),
103
106
  rename: unsupported("change an organization"),
104
107
  remove: unsupported("delete an organization"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/client",
3
- "version": "0.21.11",
3
+ "version": "0.22.0",
4
4
  "description": "Typed fetch client for the Protobase REST API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "^1.7.7",
33
- "@protobase/layout": "0.21.11",
34
- "@protobase/schema": "0.21.11",
33
+ "@protobase/layout": "0.22.0",
34
+ "@protobase/schema": "0.22.0",
35
35
  "@simplewebauthn/browser": "^13.3.0",
36
36
  "better-auth": "^1.7.7"
37
37
  }