@protobase/server 0.48.0 → 0.49.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/admin-options.d.ts +2 -2
- package/dist/app-identity.d.ts +2 -2
- package/dist/app-name.d.ts +2 -0
- package/dist/better-auth/auth-settings.d.ts +8754 -0
- package/dist/better-auth/auth-settings.js +43 -0
- package/dist/better-auth/authenticate-settings.d.ts +15 -0
- package/dist/better-auth/authenticate-settings.js +12 -0
- package/dist/better-auth/create-auth.d.ts +23 -11
- package/dist/better-auth/create-auth.js +21 -9
- package/dist/better-auth/mcp/mcp-auth-plugins.d.ts +2719 -0
- package/dist/better-auth/mcp/mcp-auth-plugins.js +68 -0
- package/dist/better-auth/mcp/mcp-plugins.d.ts +7 -2
- package/dist/better-auth/mcp/mcp-plugins.js +3 -68
- package/dist/better-auth/mcp/mcp-token-claims.js +1 -1
- package/dist/better-auth/organizations/store.d.ts +1 -0
- package/dist/better-auth/saml-plugin.d.ts +993 -0
- package/dist/better-auth/saml-plugin.js +36 -0
- package/dist/better-auth/saml-sign-in.d.ts +27 -1
- package/dist/better-auth/saml-sign-in.js +1 -33
- package/dist/better-auth/user-table.js +1 -1
- package/dist/better-auth/users.d.ts +1 -1
- package/dist/create-admin.d.ts +5 -3
- package/dist/create-admin.js +3 -1
- package/dist/encryption/keyring.js +1 -1
- package/dist/files/options.d.ts +5 -8
- package/dist/files/provider-settings.d.ts +16 -0
- package/dist/files/provider-settings.js +17 -0
- package/dist/files/runtime.js +4 -4
- package/dist/forms/runtime.js +3 -3
- package/dist/index.d.ts +16 -15
- package/dist/index.js +8 -10
- package/dist/internal.d.ts +13 -0
- package/dist/internal.js +13 -0
- package/dist/jobs/declared-job.d.ts +24 -0
- package/dist/jobs/declared-job.js +26 -0
- package/dist/jobs/job-types.d.ts +1 -1
- package/dist/mcp/mcp-authenticator.js +3 -3
- package/dist/notifications/device-store-of.d.ts +1 -1
- package/dist/notifications/device-store-of.js +1 -1
- package/dist/notifications/device-store.d.ts +1 -1
- package/dist/notifications/device-store.js +1 -1
- package/dist/notifications/history-store-of.d.ts +1 -1
- package/dist/notifications/history-store-of.js +1 -1
- package/dist/notifications/history-store.d.ts +1 -1
- package/dist/notifications/history-store.js +1 -1
- package/dist/notifications/options.d.ts +3 -1
- package/dist/notifications/options.js +1 -1
- package/dist/notifications/schema.d.ts +2 -2
- package/dist/notifications/schema.js +7 -7
- package/dist/notifications/send-notification.js +1 -1
- package/dist/notifications/sender.d.ts +1 -1
- package/dist/notifications/sender.js +2 -2
- package/dist/notifications/senders-of.d.ts +1 -1
- package/dist/notifications/senders-of.js +1 -1
- package/dist/package.js +1 -1
- package/dist/webhooks/subscription.d.ts +1 -0
- package/dist/webhooks/table/options.d.ts +1 -1
- package/dist/webhooks/table/schema.d.ts +2 -2
- package/dist/webhooks/table/schema.js +2 -2
- package/dist/webhooks/table/webhook-table.js +2 -2
- package/dist/webhooks/table/webhooks-module.d.ts +108 -0
- package/dist/webhooks/table/webhooks-module.js +11 -0
- package/package.json +6 -5
- package/dist/notifications/plugin.d.ts +0 -13
- package/dist/notifications/plugin.js +0 -16
- package/dist/project-config.d.ts +0 -54
- package/dist/project-config.js +0 -182
- package/dist/webhooks/table/plugin.d.ts +0 -10
- package/dist/webhooks/table/plugin.js +0 -18
package/dist/project-config.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { jobDefinitions } from "./jobs/define-job.js";
|
|
2
|
-
import { isSubscription } from "./webhooks/subscription.js";
|
|
3
|
-
import { isPageDefinition } from "@protobase/layout";
|
|
4
|
-
//#region src/project-config.ts
|
|
5
|
-
/** Typed identity, for `export default defineConfig({ extends: [...], config, auth, ... })` in `protobase.config.ts`. */
|
|
6
|
-
const defineConfig = (config) => config;
|
|
7
|
-
const lastSet = (objects) => Object.fromEntries(objects.flatMap((object) => Object.entries(object)).filter(([, value]) => value !== void 0));
|
|
8
|
-
const flatten = (config, label) => [...(config.extends ?? []).flatMap((parent, index) => flatten(parent, parent.name ?? `${label} extends[${index}]`)), {
|
|
9
|
-
config,
|
|
10
|
-
label
|
|
11
|
-
}];
|
|
12
|
-
const checkUnique = (kind, entries) => {
|
|
13
|
-
const seen = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const { name, value, label } of entries) {
|
|
15
|
-
const first = seen.get(name);
|
|
16
|
-
if (first && first.value !== value) throw new Error(`${kind} "${name}" is defined twice, ${first.label === label ? `in ${label}` : `by ${first.label} and by ${label}`}; rename one of them`);
|
|
17
|
-
if (!first) seen.set(name, {
|
|
18
|
-
value,
|
|
19
|
-
label
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const mergedModule = (named) => {
|
|
24
|
-
const withModule = named.filter(({ config }) => config.config);
|
|
25
|
-
if (withModule.length === 0) return void 0;
|
|
26
|
-
const exports = withModule.flatMap(({ config, label }) => Object.entries(config.config).map(([key, value]) => ({
|
|
27
|
-
key,
|
|
28
|
-
value,
|
|
29
|
-
label
|
|
30
|
-
})));
|
|
31
|
-
const values = exports.map((entry) => ({
|
|
32
|
-
...entry,
|
|
33
|
-
value: entry.value
|
|
34
|
-
}));
|
|
35
|
-
checkUnique("The resource", values.filter(({ value }) => typeof value?.recordSchema === "function" && typeof value.toModel === "function").map(({ value, label }) => ({
|
|
36
|
-
name: String(value.toModel().name),
|
|
37
|
-
value,
|
|
38
|
-
label
|
|
39
|
-
})));
|
|
40
|
-
checkUnique("The page", exports.filter(({ value }) => isPageDefinition(value)).map(({ value, label }) => ({
|
|
41
|
-
name: value.name,
|
|
42
|
-
value,
|
|
43
|
-
label
|
|
44
|
-
})));
|
|
45
|
-
checkUnique("The subscription", exports.filter(({ value }) => isSubscription(value)).map(({ value, label }) => ({
|
|
46
|
-
name: value.name,
|
|
47
|
-
value,
|
|
48
|
-
label
|
|
49
|
-
})));
|
|
50
|
-
const menus = values.filter(({ value }) => typeof value?.toUserMenuModel === "function");
|
|
51
|
-
if (new Set(menus.map(({ value }) => value)).size > 1) throw new Error(`Only one config may export a user menu; ${menus.map(({ label }) => label).join(" and ")} each do`);
|
|
52
|
-
const module = {};
|
|
53
|
-
const own = withModule.at(-1).label;
|
|
54
|
-
for (const { key, value, label } of exports) {
|
|
55
|
-
if (Object.values(module).includes(value)) continue;
|
|
56
|
-
module[label === own ? key : `${label}:${key}`] = value;
|
|
57
|
-
}
|
|
58
|
-
return module;
|
|
59
|
-
};
|
|
60
|
-
const mergedAssistant = (named) => {
|
|
61
|
-
const options = named.map(({ config, label }) => ({
|
|
62
|
-
assistant: config.options?.assistant,
|
|
63
|
-
label
|
|
64
|
-
})).filter(({ assistant }) => assistant !== void 0);
|
|
65
|
-
if (options.length === 0) return void 0;
|
|
66
|
-
if (options.at(-1).assistant === false) return false;
|
|
67
|
-
const after = options.slice(options.findLastIndex(({ assistant }) => assistant === false) + 1);
|
|
68
|
-
const tools = after.flatMap(({ assistant, label }) => (assistant.tools ?? []).map((tool) => ({
|
|
69
|
-
tool,
|
|
70
|
-
label
|
|
71
|
-
})));
|
|
72
|
-
checkUnique("The assistant tool", tools.map(({ tool, label }) => ({
|
|
73
|
-
name: tool.name,
|
|
74
|
-
value: tool,
|
|
75
|
-
label
|
|
76
|
-
})));
|
|
77
|
-
return {
|
|
78
|
-
...lastSet(after.map(({ assistant }) => assistant)),
|
|
79
|
-
...tools.length > 0 && { tools: tools.map(({ tool }) => tool) }
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
const mergedFunctions = (named) => {
|
|
83
|
-
const all = named.flatMap(({ config, label }) => Object.entries(config.functions ?? {}).map(([name, value]) => ({
|
|
84
|
-
name,
|
|
85
|
-
value,
|
|
86
|
-
label
|
|
87
|
-
})));
|
|
88
|
-
if (all.length === 0) return void 0;
|
|
89
|
-
checkUnique("The function", all);
|
|
90
|
-
return Object.fromEntries(all.map(({ name, value }) => [name, value]));
|
|
91
|
-
};
|
|
92
|
-
const mergedFiles = (named) => {
|
|
93
|
-
const all = named.flatMap(({ config, label }) => config.files ? [{
|
|
94
|
-
files: config.files,
|
|
95
|
-
label
|
|
96
|
-
}] : []);
|
|
97
|
-
if (all.length === 0) return void 0;
|
|
98
|
-
const providers = all.flatMap(({ files, label }) => Object.entries(files.providers ?? {}).map(([name, value]) => ({
|
|
99
|
-
name,
|
|
100
|
-
value,
|
|
101
|
-
label
|
|
102
|
-
})));
|
|
103
|
-
checkUnique("The file provider", providers);
|
|
104
|
-
const trustedHosts = [...new Set(all.flatMap(({ files }) => files.trustedHosts ?? []))];
|
|
105
|
-
const { retention, secret, sharp } = lastSet(all.map(({ files }) => ({
|
|
106
|
-
retention: files.retention,
|
|
107
|
-
secret: files.secret,
|
|
108
|
-
sharp: files.sharp
|
|
109
|
-
})));
|
|
110
|
-
return {
|
|
111
|
-
...providers.length > 0 && { providers: Object.fromEntries(providers.map(({ name, value }) => [name, value])) },
|
|
112
|
-
...retention !== void 0 && { retention },
|
|
113
|
-
...secret !== void 0 && { secret },
|
|
114
|
-
...sharp !== void 0 && { sharp },
|
|
115
|
-
...trustedHosts.length > 0 && { trustedHosts }
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
const mergedJobs = (named) => {
|
|
119
|
-
const all = named.flatMap(({ config, label }) => jobDefinitions(config.jobs ?? {}).map((value) => ({
|
|
120
|
-
name: value.name,
|
|
121
|
-
value,
|
|
122
|
-
label
|
|
123
|
-
})));
|
|
124
|
-
if (all.length === 0) return void 0;
|
|
125
|
-
checkUnique("The job", all);
|
|
126
|
-
return Object.fromEntries(all.map(({ name, value }) => [name, value]));
|
|
127
|
-
};
|
|
128
|
-
const mergedOptions = (named) => {
|
|
129
|
-
const all = named.flatMap(({ config }) => config.options ? [config.options] : []);
|
|
130
|
-
if (all.length === 0) return void 0;
|
|
131
|
-
const writeHooks = all.flatMap((options) => options.writeHooks ?? []);
|
|
132
|
-
const assistant = mergedAssistant(named);
|
|
133
|
-
return {
|
|
134
|
-
...lastSet(all),
|
|
135
|
-
...writeHooks.length > 0 && { writeHooks },
|
|
136
|
-
...assistant !== void 0 && { assistant }
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* One config from several, each after the ones it `extends`, the last being the app's own. Named things are all kept:
|
|
141
|
-
* resources, views and pages of the config modules, functions, jobs, assistant tools, file providers; one name defined by two configs is an error naming
|
|
142
|
-
* both. Write hooks run in the same order. Every other value is the last config's that sets it, so the app's own wins.
|
|
143
|
-
*/
|
|
144
|
-
const mergeConfig = (...configs) => {
|
|
145
|
-
const named = configs.flatMap((config, index) => flatten(config, config.name ?? `config ${index + 1}`));
|
|
146
|
-
const { db, authenticate, auth, events, history, webhooks, notifications, mobile, app } = lastSet(named.map(({ config }) => ({
|
|
147
|
-
db: config.db,
|
|
148
|
-
authenticate: config.authenticate,
|
|
149
|
-
auth: config.auth,
|
|
150
|
-
events: config.events,
|
|
151
|
-
history: config.history,
|
|
152
|
-
webhooks: config.webhooks,
|
|
153
|
-
notifications: config.notifications,
|
|
154
|
-
mobile: config.mobile,
|
|
155
|
-
app: config.app
|
|
156
|
-
})));
|
|
157
|
-
const module = mergedModule(named);
|
|
158
|
-
const functions = mergedFunctions(named);
|
|
159
|
-
const files = mergedFiles(named);
|
|
160
|
-
const jobs = mergedJobs(named);
|
|
161
|
-
const options = mergedOptions(named);
|
|
162
|
-
const name = configs.at(-1)?.name;
|
|
163
|
-
return {
|
|
164
|
-
...name && { name },
|
|
165
|
-
...module && { config: module },
|
|
166
|
-
...db && { db },
|
|
167
|
-
...authenticate && { authenticate },
|
|
168
|
-
...auth && { auth },
|
|
169
|
-
...functions && { functions },
|
|
170
|
-
...files && { files },
|
|
171
|
-
...events && { events },
|
|
172
|
-
...history && { history },
|
|
173
|
-
...webhooks && { webhooks },
|
|
174
|
-
...notifications && { notifications },
|
|
175
|
-
...jobs && { jobs },
|
|
176
|
-
...mobile && { mobile },
|
|
177
|
-
...app && { app },
|
|
178
|
-
...options && { options }
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
//#endregion
|
|
182
|
-
export { defineConfig, mergeConfig };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { WebhooksOptions } from "./options.js";
|
|
2
|
-
import { ProjectConfig } from "../../project-config.js";
|
|
3
|
-
//#region src/webhooks/table/plugin.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Webhook subscriptions made in the admin app: `extends: [webhooks()]` in `protobase.config.ts`. It adds the Webhook
|
|
6
|
-
* subscriptions and Webhook deliveries pages, over a `webhooks` schema that `protobase migration` writes. Who may
|
|
7
|
-
* create subscriptions is the resources' access (`webhook_subscriptions.create`, ...); each delivers as its owner.
|
|
8
|
-
*/
|
|
9
|
-
export declare const webhooks: (options?: WebhooksOptions) => ProjectConfig;
|
|
10
|
-
//#endregion
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { webhooksSchema } from "./options.js";
|
|
2
|
-
import { webhookResources } from "@protobase/schema/internal";
|
|
3
|
-
//#region src/webhooks/table/plugin.ts
|
|
4
|
-
/**
|
|
5
|
-
* Webhook subscriptions made in the admin app: `extends: [webhooks()]` in `protobase.config.ts`. It adds the Webhook
|
|
6
|
-
* subscriptions and Webhook deliveries pages, over a `webhooks` schema that `protobase migration` writes. Who may
|
|
7
|
-
* create subscriptions is the resources' access (`webhook_subscriptions.create`, ...); each delivers as its owner.
|
|
8
|
-
*/
|
|
9
|
-
const webhooks = (options = {}) => {
|
|
10
|
-
const schema = webhooksSchema(options);
|
|
11
|
-
return {
|
|
12
|
-
name: "protobase-webhooks",
|
|
13
|
-
config: webhookResources(schema, { deliveryLog: Boolean(options.deliveryLog) }),
|
|
14
|
-
webhooks: options
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
export { webhooks };
|