@protobase/server 0.27.0 → 0.28.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/app-identity.d.ts +12 -0
- package/dist/app-name.js +4 -2
- package/dist/better-auth/create-auth.d.ts +6 -5
- package/dist/better-auth/create-auth.js +3 -4
- package/dist/create-admin.d.ts +10 -1
- package/dist/create-admin.js +4 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/meta.js +2 -1
- package/dist/project-config.d.ts +3 -0
- package/dist/project-config.js +4 -2
- package/dist/web-app/app-icons.d.ts +31 -0
- package/dist/web-app/app-icons.js +26 -0
- package/dist/web-app/web-manifest-route.js +2 -2
- package/dist/web-app/web-manifest.js +22 -3
- package/package.json +4 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/app-identity.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `app` section of `protobase.config.ts`: the colours the installed app shows, beside its name (`createAuth`'s
|
|
4
|
+
* `appName`) and its icons (`protobase.favicon.svg` and the PNGs beside it). Any CSS colour, such as `#0d9488`.
|
|
5
|
+
*/
|
|
6
|
+
export type AppIdentity = {
|
|
7
|
+
/** The colour of the installed app's title bar and of the browser's toolbar around it. */
|
|
8
|
+
themeColor?: string;
|
|
9
|
+
/** The colour of the screen an installed app shows while it starts. */
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
package/dist/app-name.js
CHANGED
|
@@ -4,8 +4,10 @@ const appNameVariable = "PROTOBASE_APP_NAME";
|
|
|
4
4
|
const defaultAppName = "Protobase";
|
|
5
5
|
/**
|
|
6
6
|
* The app's name the platform passes in `PROTOBASE_APP_NAME`, such as `Property Finder`; `undefined` when it is not
|
|
7
|
-
* set. Protobase names the app with it in sign-in prompts and in the mail it sends,
|
|
7
|
+
* set. Protobase names the app with it in sign-in prompts and in the mail it sends, over the name the app gives itself.
|
|
8
8
|
*/
|
|
9
9
|
const readAppName = (env) => env["PROTOBASE_APP_NAME"]?.trim() || void 0;
|
|
10
|
+
/** The name the app goes by: the platform's `PROTOBASE_APP_NAME`, which deployments rename it with, over its own `own`. */
|
|
11
|
+
const appNameOver = (env, own) => readAppName(env) ?? own;
|
|
10
12
|
//#endregion
|
|
11
|
-
export { appNameVariable, defaultAppName, readAppName };
|
|
13
|
+
export { appNameOver, appNameVariable, defaultAppName, readAppName };
|
|
@@ -34,8 +34,9 @@ export type CreateAuthOptions = {
|
|
|
34
34
|
passkeyDomain?: string;
|
|
35
35
|
/**
|
|
36
36
|
* The app's name: authenticator apps and passkey prompts show it, the auth emails name the app with it, and the
|
|
37
|
-
* default mailer sends them from it, as the sender's display name
|
|
38
|
-
* `PROTOBASE_APP_NAME`, when set,
|
|
37
|
+
* default mailer sends them from it, as the sender's display name; the tab titles, the sidebar's logo and the
|
|
38
|
+
* installed app show it too. The name the platform passes in `PROTOBASE_APP_NAME`, when set, overrides it; without
|
|
39
|
+
* either it is `Protobase` (without a sender's display name).
|
|
39
40
|
*/
|
|
40
41
|
appName?: string;
|
|
41
42
|
/** Signs cookies and encrypts the JWT private keys. Generate with `openssl rand -base64 32`. */
|
|
@@ -1294,7 +1295,7 @@ export declare const createAuth: (options: CreateAuthOptions) => import("better-
|
|
|
1294
1295
|
email: string;
|
|
1295
1296
|
emailVerified: boolean;
|
|
1296
1297
|
name: string;
|
|
1297
|
-
image
|
|
1298
|
+
image? /** Signs cookies and encrypts the JWT private keys. Generate with `openssl rand -base64 32`. */ : string | null | undefined;
|
|
1298
1299
|
};
|
|
1299
1300
|
};
|
|
1300
1301
|
}>>[];
|
|
@@ -4018,7 +4019,7 @@ export declare const createAuth: (options: CreateAuthOptions) => import("better-
|
|
|
4018
4019
|
userId: string;
|
|
4019
4020
|
expiresAt: Date;
|
|
4020
4021
|
token: string;
|
|
4021
|
-
ipAddress
|
|
4022
|
+
ipAddress?: string | null | undefined;
|
|
4022
4023
|
userAgent?: string | null | undefined;
|
|
4023
4024
|
};
|
|
4024
4025
|
user: Record<string, any> & {
|
|
@@ -5971,7 +5972,7 @@ export declare const createAuth: (options: CreateAuthOptions) => import("better-
|
|
|
5971
5972
|
/** The app keeps each user's metadata, in the column `users.metadata` names. */
|
|
5972
5973
|
userMetadata: boolean;
|
|
5973
5974
|
socialProviders: string[];
|
|
5974
|
-
/** The app's name it signs in and mails as: `
|
|
5975
|
+
/** The app's name it signs in and mails as: `PROTOBASE_APP_NAME`, else `appName`, else `Protobase`. */
|
|
5975
5976
|
appName: string;
|
|
5976
5977
|
operator: string | undefined;
|
|
5977
5978
|
platformSignIn: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appOrigins, multiHostBaseURL, readOrigins, resolveOrigins } from "./origins.js";
|
|
2
|
-
import {
|
|
2
|
+
import { appNameOver, defaultAppName } from "../app-name.js";
|
|
3
3
|
import { goTrueIssuer, goTrueKeyPair } from "../gotrue/keys.js";
|
|
4
4
|
import { roleDefinitions } from "./organizations/role-definitions.js";
|
|
5
5
|
import { narrowClaims } from "./roles/active-role.js";
|
|
@@ -38,7 +38,6 @@ const platformOperator = () => readOperatorSettings(globalThis.process?.env ?? {
|
|
|
38
38
|
const platformSignInSettings = () => readPlatformSignIn(globalThis.process?.env ?? {});
|
|
39
39
|
const platformOrigins = () => readOrigins(globalThis.process?.env ?? {});
|
|
40
40
|
const platformPasskeyDomain = () => readPasskeyDomain(globalThis.process?.env ?? {});
|
|
41
|
-
const platformAppName = () => readAppName(globalThis.process?.env ?? {});
|
|
42
41
|
const tokenLifetime = "15m";
|
|
43
42
|
/**
|
|
44
43
|
* Better Auth for a single-tenant admin: sign-in with a password, an emailed code or a passkey, two-factor
|
|
@@ -276,7 +275,7 @@ const createAuth = (options) => {
|
|
|
276
275
|
const signUpRole = options.signUp && checkSignUpRole(options.signUp.role, roles);
|
|
277
276
|
const others = roles.filter((role) => role !== "admin");
|
|
278
277
|
const defaultRole = options.defaultRole ?? (options.organizations ? "user" : others.length === 1 ? others[0] : void 0);
|
|
279
|
-
const appName =
|
|
278
|
+
const appName = appNameOver(globalThis.process?.env ?? {}, options.appName);
|
|
280
279
|
const mailer = options.mailer === void 0 ? platformMailer(void 0, appName) : options.mailer || void 0;
|
|
281
280
|
const provider = options.operator === void 0 ? platformOperator() : options.operator || void 0;
|
|
282
281
|
const operator = provider && resolveOperator(provider);
|
|
@@ -329,7 +328,7 @@ const createAuth = (options) => {
|
|
|
329
328
|
/** The app keeps each user's metadata, in the column `users.metadata` names. */
|
|
330
329
|
userMetadata: Boolean(options.users?.metadata),
|
|
331
330
|
socialProviders,
|
|
332
|
-
/** The app's name it signs in and mails as: `
|
|
331
|
+
/** The app's name it signs in and mails as: `PROTOBASE_APP_NAME`, else `appName`, else `Protobase`. */
|
|
333
332
|
appName: appName ?? "Protobase",
|
|
334
333
|
operator: operator?.name,
|
|
335
334
|
platformSignIn: platformSignIn && {
|
package/dist/create-admin.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { MobileConfig } from "./mobile-config.js";
|
|
2
|
+
import { AppIdentity } from "./app-identity.js";
|
|
3
|
+
import { AppIcons } from "./web-app/app-icons.js";
|
|
2
4
|
import { AdminAuth } from "./better-auth/create-auth.js";
|
|
3
5
|
import { EventsOptions } from "./changes/events-options.js";
|
|
4
6
|
import { JobDefinition } from "./jobs/job-types.js";
|
|
@@ -46,6 +48,13 @@ export type CreateAdminInput = {
|
|
|
46
48
|
webhooks?: WebhooksOptions;
|
|
47
49
|
/** The app's iOS and Android build (see `MobileConfig`): the API answers its Capacitor origins through CORS. */
|
|
48
50
|
mobile?: MobileConfig;
|
|
51
|
+
/** The app's colours, which its web manifest carries (see `AppIdentity`). */
|
|
52
|
+
app?: AppIdentity;
|
|
53
|
+
/**
|
|
54
|
+
* The icons the project has of its own, as `protobase build` and `protobase dev` find them beside its favicon: the
|
|
55
|
+
* web manifest names its PNGs, and `/meta` the favicon when it is the project's, which the sidebar's logo draws.
|
|
56
|
+
*/
|
|
57
|
+
icons?: AppIcons;
|
|
49
58
|
/**
|
|
50
59
|
* The plugins the app's bundle carries, as `protobase build` writes them: its protobase.ui.tsx and its extensions'
|
|
51
60
|
* UI configs, each a plugin.json path on the app's origin. `/meta` names them to everyone, before any other plugin,
|
|
@@ -72,5 +81,5 @@ export type CreateAdminInput = {
|
|
|
72
81
|
upgradeWebSocket?: UpgradeWebSocket;
|
|
73
82
|
};
|
|
74
83
|
/** The admin REST API as a Hono app. It uses only Web APIs, so it runs on Node, Workers and anywhere else Hono does. */
|
|
75
|
-
export declare const createAdmin: ({ resources: appResources, views: appViews, pages, userMenu, bottomBars, db, authenticate, auth, functions, files: filesOptions, events, history: historyOptions, jobs, subscriptions, webhooks: webhooksOptions, mobile, bundlePlugins, fieldTypes, options, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }: CreateAdminInput) => Admin;
|
|
84
|
+
export declare const createAdmin: ({ resources: appResources, views: appViews, pages, userMenu, bottomBars, db, authenticate, auth, functions, files: filesOptions, events, history: historyOptions, jobs, subscriptions, webhooks: webhooksOptions, mobile, app: identity, icons, bundlePlugins, fieldTypes, options, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }: CreateAdminInput) => Admin;
|
|
76
85
|
//#endregion
|
package/dist/create-admin.js
CHANGED
|
@@ -63,6 +63,7 @@ import { batchRoute } from "./routes/batch.js";
|
|
|
63
63
|
import { collectionRoutes } from "./routes/collection.js";
|
|
64
64
|
import { docsRoutes } from "./routes/docs.js";
|
|
65
65
|
import { metaRoutes } from "./routes/meta.js";
|
|
66
|
+
import { faviconPath } from "./web-app/web-manifest.js";
|
|
66
67
|
import { webManifestRoute } from "./web-app/web-manifest-route.js";
|
|
67
68
|
import { recordRoutes } from "./routes/record.js";
|
|
68
69
|
import { createScanGuard } from "./scan-guard.js";
|
|
@@ -75,7 +76,7 @@ const declaredRoles = (auth, roles) => {
|
|
|
75
76
|
return names.length > 0 ? [...new Set(names)] : void 0;
|
|
76
77
|
};
|
|
77
78
|
/** The admin REST API as a Hono app. It uses only Web APIs, so it runs on Node, Workers and anywhere else Hono does. */
|
|
78
|
-
const createAdmin = ({ resources: appResources, views: appViews = [], pages = [], userMenu, bottomBars = [], db, authenticate, auth, functions = {}, files: filesOptions, events, history: historyOptions, jobs = [], subscriptions = [], webhooks: webhooksOptions, mobile, bundlePlugins = [], fieldTypes = {}, options = {}, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }) => {
|
|
79
|
+
const createAdmin = ({ resources: appResources, views: appViews = [], pages = [], userMenu, bottomBars = [], db, authenticate, auth, functions = {}, files: filesOptions, events, history: historyOptions, jobs = [], subscriptions = [], webhooks: webhooksOptions, mobile, app: identity, icons, bundlePlugins = [], fieldTypes = {}, options = {}, formsDifficulty, commentUsers: givenCommentUsers, verifyToken, upgradeWebSocket }) => {
|
|
79
80
|
const basePath = options.basePath ?? "/api/v1";
|
|
80
81
|
const appModels = appResources.map((resource) => resource.toModel());
|
|
81
82
|
const withComments = appModels.some((model) => model.comments);
|
|
@@ -191,7 +192,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
|
|
|
191
192
|
} }
|
|
192
193
|
};
|
|
193
194
|
const appName = auth?.appName ?? readAppName(globalThis.process?.env ?? {}) ?? "Protobase";
|
|
194
|
-
const meta = createMeta(deps, appName);
|
|
195
|
+
const meta = createMeta(deps, appName, icons?.favicon ? faviconPath : void 0);
|
|
195
196
|
const onError = createErrorHandler(options.onUnhandledError);
|
|
196
197
|
const guarded = (routes, caller = authenticate) => {
|
|
197
198
|
const app = new Hono();
|
|
@@ -301,7 +302,7 @@ const createAdmin = ({ resources: appResources, views: appViews = [], pages = []
|
|
|
301
302
|
}
|
|
302
303
|
app.route(basePath, api);
|
|
303
304
|
app.route(`${deps.systemPath}/meta`, metaApp);
|
|
304
|
-
app.route(systemPath || "/", webManifestRoute(appName));
|
|
305
|
+
app.route(systemPath || "/", webManifestRoute(appName, identity, icons));
|
|
305
306
|
app.route(deps.systemPath || "/", system);
|
|
306
307
|
const webhooks = createWebhooks({
|
|
307
308
|
deps,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { MobileConfig } from "./mobile-config.js";
|
|
2
|
+
import { AppIdentity } from "./app-identity.js";
|
|
3
|
+
import { AppIcons, PngIcon, pngIcons } from "./web-app/app-icons.js";
|
|
2
4
|
import { SignInPolicy, SignInRule, StaffAccessRule, defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
|
|
3
5
|
import { StaffSignIn } from "./better-auth/staff-log.js";
|
|
4
6
|
import { MailMessage, Mailer } from "./mail/smtp-mailer.js";
|
|
@@ -98,4 +100,4 @@ import { isSchedule } from "./jobs/schedule.js";
|
|
|
98
100
|
import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
|
|
99
101
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
100
102
|
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
101
|
-
export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSource, type HistoryOptions, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JwtOptions, type JwtVerifyOptions, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type MemberInput, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewOrganization, type NewUser, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type QueryOptions, type QueryResult, type ReasoningDetail, type ReasoningEffort, type RecordKeyInput, type RecordPage, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredObject, type StoredOrganization, type StoredUser, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type User, type UserCreatedHook, type ViewSource, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storeFile, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
|
|
103
|
+
export { type Admin, type AdminAuth, type AdminOptions, type ApiFunction, type ApiKeys, type ApiKeysOptions, type AppIcons, type AppIdentity, type ApprovalAnswer, type ApprovalRequest, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type Authenticator, type BetterAuthAuthenticatorOptions, type Caller, type CallerOptions, type CapturedRow, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentUsers, type Completion, type CompletionOptions, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSource, type HistoryOptions, HttpProblem, type IssueTokenOptions, type JobContext, type JobDefinition, type JobOptions, type JobsRuntime, type JwtOptions, type JwtVerifyOptions, type LinkedAccount, type ListParams, type LocalFilesOptions, type MailMessage, type Mailer, type MapLayer, type MapOptions, type MapSettings, type MemberInput, MissingCredentials, type MobileConfig, ModelError, type ModelSettings, type NewOrganization, type NewUser, type OperatorProvider, type OrganizationRole, type OrganizationsOptions, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProjectConfig, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type QueryOptions, type QueryResult, type ReasoningDetail, type ReasoningEffort, type RecordKeyInput, type RecordPage, type RenderedEmail, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StoreFileInput, type StoredMember, type StoredObject, type StoredOrganization, type StoredUser, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TenantValue, type ToolCall, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type User, type UserCreatedHook, type ViewSource, type WebhooksOptions, type WidgetOptions, type WriteEvent, type WriteOperation, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storeFile, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ import { beforeSignInPluginsVariable, pluginOptions, pluginsBeforeSignIn, plugin
|
|
|
49
49
|
import { runtimeUrl, runtimeVariable, seesRuntime } from "./runtime/runtime-settings.js";
|
|
50
50
|
import { checkSourceNames, sourceOptions, sourcesFor, sourcesVariable } from "./sources/source-settings.js";
|
|
51
51
|
import { renderVariant, thumbHash } from "./files/images.js";
|
|
52
|
+
import { pngIcons } from "./web-app/app-icons.js";
|
|
52
53
|
import { createAdmin } from "./create-admin.js";
|
|
53
54
|
import { handleDroppedConnections } from "./dropped-connections.js";
|
|
54
55
|
import { configExports } from "./resource-source.js";
|
|
@@ -74,4 +75,4 @@ import { aspectRatio, fileSize, fileType, imageSize, processor } from "./files/p
|
|
|
74
75
|
import { defineEmail } from "./mail/define-email.js";
|
|
75
76
|
import { startJobs } from "./jobs/runtime.js";
|
|
76
77
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
77
|
-
export { FatalJobError, HttpProblem, MissingCredentials, ModelError, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storeFile, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
|
|
78
|
+
export { FatalJobError, HttpProblem, MissingCredentials, ModelError, addAppRoleToOwners, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaMigration, badRequest, beforeSignInPluginsVariable, betterAuthAuthenticator, betterAuthTokens, changesMigration, checkAi, checkAuthSchema, checkChanges, checkComments, checkComputed, checkJobsSchema, checkSourceNames, checkViewQueries, checkWebhooksSchema, coalesce, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, createAdmin, createAuth, createConversations, createFileCleanup, createOrganization, createUser, defaultAppName, defaultSignInPolicy, defineConfig, defineEmail, defineFunction, defineJob, defineTool, deleteUser, errorReportingSettings, errorReportingVariable, eventMatcher, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, handleDroppedConnections, hasUsers, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listOrganizations, listUsers, localFileStore, localFiles, mapSettings, mapStyleUrl, mapStyleVariable, maxTokenTtlSeconds, maxWidgetPropsBytes, mergeConfig, migrationCommand, newWebhookSecret, normalizeRoles, notFound, parseColumns, parseRoles, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, processor, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIn, readWriteQueryTool, recordOf, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, s3Files, seesAssistant, seesRuntime, setMemberRoles, setUserBanned, setUserRole, signInPolicyMethods, sourceOptions, sourcesFor, sourcesVariable, startErrorReporting, startJobs, storageCleanupSchedule, storeFile, streamChatCompletion, subscription, thumbHash, unauthorized, variantPath, verifySignature, verifyStandardWebhook, webauthnPath, webhooks, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps };
|
package/dist/meta.js
CHANGED
|
@@ -28,7 +28,7 @@ const modelsHash = (deps) => sha256Hex(stableJson(deps.registry.entries.map((ent
|
|
|
28
28
|
* they could use once signed in, which keep their place in the bottom bar and the user menu.
|
|
29
29
|
* The ETag hashes all of it, so it differs per user and per roles.
|
|
30
30
|
*/
|
|
31
|
-
const createMeta = (deps, appName) => {
|
|
31
|
+
const createMeta = (deps, appName, appIcon) => {
|
|
32
32
|
const base = modelsHash(deps);
|
|
33
33
|
const forCaller = async (session) => {
|
|
34
34
|
const accesses = await Promise.all(deps.registry.entries.map((entry) => requestAccess(deps, entry, session)));
|
|
@@ -62,6 +62,7 @@ const createMeta = (deps, appName) => {
|
|
|
62
62
|
const sources = sourcesFor(deps.sources, session.user.roles);
|
|
63
63
|
const body = {
|
|
64
64
|
appName,
|
|
65
|
+
...appIcon && { appIcon },
|
|
65
66
|
resources: visible.map((access) => access.readable),
|
|
66
67
|
views,
|
|
67
68
|
pages,
|
package/dist/project-config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MobileConfig } from "./mobile-config.js";
|
|
2
|
+
import { AppIdentity } from "./app-identity.js";
|
|
2
3
|
import { AdminAuth } from "./better-auth/create-auth.js";
|
|
3
4
|
import { EventsOptions } from "./changes/events-options.js";
|
|
4
5
|
import { Authenticator } from "./types.js";
|
|
@@ -35,6 +36,8 @@ export type ProjectConfig = {
|
|
|
35
36
|
jobs?: Record<string, unknown>;
|
|
36
37
|
/** The app's iOS and Android build (see `MobileConfig`): `protobase mobile` needs it, and the API answers the app's origins. */
|
|
37
38
|
mobile?: MobileConfig;
|
|
39
|
+
/** The installed app's colours (see `AppIdentity`), which its web manifest carries. */
|
|
40
|
+
app?: AppIdentity;
|
|
38
41
|
options?: AdminOptions;
|
|
39
42
|
};
|
|
40
43
|
/** Typed identity, for `export default defineConfig({ extends: [...], config, auth, ... })` in `protobase.config.ts`. */
|
package/dist/project-config.js
CHANGED
|
@@ -143,14 +143,15 @@ const mergedOptions = (named) => {
|
|
|
143
143
|
*/
|
|
144
144
|
const mergeConfig = (...configs) => {
|
|
145
145
|
const named = configs.flatMap((config, index) => flatten(config, config.name ?? `config ${index + 1}`));
|
|
146
|
-
const { db, authenticate, auth, events, history, webhooks, mobile } = lastSet(named.map(({ config }) => ({
|
|
146
|
+
const { db, authenticate, auth, events, history, webhooks, mobile, app } = lastSet(named.map(({ config }) => ({
|
|
147
147
|
db: config.db,
|
|
148
148
|
authenticate: config.authenticate,
|
|
149
149
|
auth: config.auth,
|
|
150
150
|
events: config.events,
|
|
151
151
|
history: config.history,
|
|
152
152
|
webhooks: config.webhooks,
|
|
153
|
-
mobile: config.mobile
|
|
153
|
+
mobile: config.mobile,
|
|
154
|
+
app: config.app
|
|
154
155
|
})));
|
|
155
156
|
const module = mergedModule(named);
|
|
156
157
|
const functions = mergedFunctions(named);
|
|
@@ -171,6 +172,7 @@ const mergeConfig = (...configs) => {
|
|
|
171
172
|
...webhooks && { webhooks },
|
|
172
173
|
...jobs && { jobs },
|
|
173
174
|
...mobile && { mobile },
|
|
175
|
+
...app && { app },
|
|
174
176
|
...options && { options }
|
|
175
177
|
};
|
|
176
178
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/web-app/app-icons.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The PNG icons a project may put beside its `protobase.favicon.svg`, for platforms that take no SVG, each square at
|
|
4
|
+
* `size` pixels and answered on the app's own origin at `/<file>`: Android's 192 and 512 pixel icons, a 512 pixel
|
|
5
|
+
* maskable one whose mark keeps to the middle 80%, and the 180 pixel Apple touch icon an iPhone home screen shows.
|
|
6
|
+
*/
|
|
7
|
+
export declare const pngIcons: {
|
|
8
|
+
readonly icon192: {
|
|
9
|
+
readonly file: "protobase.icon-192.png";
|
|
10
|
+
readonly size: 192;
|
|
11
|
+
};
|
|
12
|
+
readonly icon512: {
|
|
13
|
+
readonly file: "protobase.icon-512.png";
|
|
14
|
+
readonly size: 512;
|
|
15
|
+
};
|
|
16
|
+
readonly maskable: {
|
|
17
|
+
readonly file: "protobase.icon-maskable.png";
|
|
18
|
+
readonly size: 512;
|
|
19
|
+
};
|
|
20
|
+
readonly appleTouch: {
|
|
21
|
+
readonly file: "protobase.apple-touch-icon.png";
|
|
22
|
+
readonly size: 180;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type PngIcon = keyof typeof pngIcons;
|
|
26
|
+
/** The icons a project has of its own: `favicon` when the favicon is its own rather than Protobase's, and its PNGs. */
|
|
27
|
+
export type AppIcons = {
|
|
28
|
+
favicon: boolean;
|
|
29
|
+
png: PngIcon[];
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/web-app/app-icons.ts
|
|
2
|
+
/**
|
|
3
|
+
* The PNG icons a project may put beside its `protobase.favicon.svg`, for platforms that take no SVG, each square at
|
|
4
|
+
* `size` pixels and answered on the app's own origin at `/<file>`: Android's 192 and 512 pixel icons, a 512 pixel
|
|
5
|
+
* maskable one whose mark keeps to the middle 80%, and the 180 pixel Apple touch icon an iPhone home screen shows.
|
|
6
|
+
*/
|
|
7
|
+
const pngIcons = {
|
|
8
|
+
icon192: {
|
|
9
|
+
file: "protobase.icon-192.png",
|
|
10
|
+
size: 192
|
|
11
|
+
},
|
|
12
|
+
icon512: {
|
|
13
|
+
file: "protobase.icon-512.png",
|
|
14
|
+
size: 512
|
|
15
|
+
},
|
|
16
|
+
maskable: {
|
|
17
|
+
file: "protobase.icon-maskable.png",
|
|
18
|
+
size: 512
|
|
19
|
+
},
|
|
20
|
+
appleTouch: {
|
|
21
|
+
file: "protobase.apple-touch-icon.png",
|
|
22
|
+
size: 180
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { pngIcons };
|
|
@@ -4,9 +4,9 @@ import { Hono } from "hono";
|
|
|
4
4
|
/** The path under the system path (`/api`) the admin app's page links its manifest at. */
|
|
5
5
|
const webManifestPath = "/manifest.webmanifest";
|
|
6
6
|
/** Answers the web app manifest to anyone: the browser fetches it without the user's token, before they sign in. */
|
|
7
|
-
const webManifestRoute = (appName) => {
|
|
7
|
+
const webManifestRoute = (appName, identity, icons) => {
|
|
8
8
|
const app = new Hono();
|
|
9
|
-
const body = JSON.stringify(webManifest(appName));
|
|
9
|
+
const body = JSON.stringify(webManifest(appName, identity, icons));
|
|
10
10
|
app.get(webManifestPath, () => new Response(body, { headers: {
|
|
11
11
|
"content-type": "application/manifest+json",
|
|
12
12
|
"cache-control": "no-cache"
|
|
@@ -1,22 +1,41 @@
|
|
|
1
|
+
import { pngIcons } from "./app-icons.js";
|
|
1
2
|
//#region src/web-app/web-manifest.ts
|
|
2
3
|
/** Where the app's favicon is on its own origin, which `protobase build` and `protobase dev` always answer. */
|
|
3
4
|
const faviconPath = "/protobase.favicon.svg";
|
|
5
|
+
const manifestIcons = {
|
|
6
|
+
icon192: "any",
|
|
7
|
+
icon512: "any",
|
|
8
|
+
maskable: "maskable"
|
|
9
|
+
};
|
|
10
|
+
const isManifestIcon = (icon) => icon in manifestIcons;
|
|
11
|
+
const manifestIcon = (icon) => {
|
|
12
|
+
const { file, size } = pngIcons[icon];
|
|
13
|
+
return {
|
|
14
|
+
src: `/${file}`,
|
|
15
|
+
sizes: `${size}x${size}`,
|
|
16
|
+
type: "image/png",
|
|
17
|
+
...manifestIcons[icon] === "maskable" && { purpose: "maskable" }
|
|
18
|
+
};
|
|
19
|
+
};
|
|
4
20
|
/**
|
|
5
21
|
* The web app manifest that makes the admin app installable: named for the app, opening at its home page in a window
|
|
6
|
-
* of its own, with the favicon as its icon
|
|
22
|
+
* of its own, with the favicon as its icon, the project's PNGs beside it and its colours when it has them. An SVG with
|
|
23
|
+
* `sizes: "any"` meets Chrome's 192 and 512 pixel icon sizes; Safari and some Android launchers take only PNGs.
|
|
7
24
|
*/
|
|
8
|
-
const webManifest = (appName) => ({
|
|
25
|
+
const webManifest = (appName, { themeColor, backgroundColor } = {}, icons) => ({
|
|
9
26
|
name: appName,
|
|
10
27
|
short_name: appName,
|
|
11
28
|
id: "/",
|
|
12
29
|
start_url: "/",
|
|
13
30
|
scope: "/",
|
|
14
31
|
display: "standalone",
|
|
32
|
+
...themeColor && { theme_color: themeColor },
|
|
33
|
+
...backgroundColor && { background_color: backgroundColor },
|
|
15
34
|
icons: [{
|
|
16
35
|
src: faviconPath,
|
|
17
36
|
sizes: "any",
|
|
18
37
|
type: "image/svg+xml"
|
|
19
|
-
}]
|
|
38
|
+
}, ...(icons?.png ?? []).filter(isManifestIcon).map(manifestIcon)]
|
|
20
39
|
});
|
|
21
40
|
//#endregion
|
|
22
41
|
export { faviconPath, webManifest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@better-auth/passkey": "^1.7.7",
|
|
34
34
|
"@better-auth/sso": "^1.7.7",
|
|
35
|
-
"@protobase/layout": "0.
|
|
36
|
-
"@protobase/query": "0.
|
|
37
|
-
"@protobase/schema": "0.
|
|
35
|
+
"@protobase/layout": "0.28.0",
|
|
36
|
+
"@protobase/query": "0.28.0",
|
|
37
|
+
"@protobase/schema": "0.28.0",
|
|
38
38
|
"@react-email/render": "^2.1.0",
|
|
39
39
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
40
40
|
"@sentry/core": "^11.7.0",
|