@rebasepro/server 0.10.1-canary.b1e3dbf → 0.10.1-canary.d8d45b2
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.es.js +34 -3
- package/dist/index.es.js.map +1 -1
- package/dist/src-BITicbgD.js.map +1 -1
- package/dist/storage/routes.d.ts +9 -1
- package/dist/storage/types.d.ts +1 -1
- package/package.json +5 -5
package/dist/index.es.js
CHANGED
|
@@ -14580,7 +14580,7 @@ function buildAdapterAuthMiddleware(adapter, requireAuth, publicRead) {
|
|
|
14580
14580
|
function createStorageRoutes(config) {
|
|
14581
14581
|
const router = new Hono();
|
|
14582
14582
|
router.onError(errorHandler);
|
|
14583
|
-
const { controller, registry, sources: declaredSources, requireAuth: requireAuth$1 = true, publicRead = false, authAdapter, authorize } = config;
|
|
14583
|
+
const { controller, registry, sources: declaredSources, requireAuth: requireAuth$1 = true, publicRead = false, authAdapter, authorize, authorizeData } = config;
|
|
14584
14584
|
/**
|
|
14585
14585
|
* Run the per-object authorization hook, if one is configured.
|
|
14586
14586
|
*
|
|
@@ -14601,7 +14601,8 @@ function createStorageRoutes(config) {
|
|
|
14601
14601
|
bucket,
|
|
14602
14602
|
operation,
|
|
14603
14603
|
user,
|
|
14604
|
-
storageId: storageId ?? void 0
|
|
14604
|
+
storageId: storageId ?? void 0,
|
|
14605
|
+
data: authorizeData?.()
|
|
14605
14606
|
});
|
|
14606
14607
|
} catch {
|
|
14607
14608
|
allowed = false;
|
|
@@ -20963,6 +20964,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
20963
20964
|
logger.info("Schema Editor mounted", { path: `${basePath}/schema-editor` });
|
|
20964
20965
|
}
|
|
20965
20966
|
}
|
|
20967
|
+
const storageAuthorizeData = {};
|
|
20966
20968
|
if (storageController) {
|
|
20967
20969
|
const storageMaxSize = (config.storage && typeof config.storage === "object" && "type" in config.storage ? config.storage.maxFileSize : void 0) ?? 50 * 1024 * 1024;
|
|
20968
20970
|
assertStorageAccessControlConfigured({
|
|
@@ -20977,7 +20979,8 @@ async function _initializeRebaseBackend(config) {
|
|
|
20977
20979
|
requireAuth: resolveRequireAuth(config.auth),
|
|
20978
20980
|
publicRead: config.storagePublicRead === true,
|
|
20979
20981
|
authAdapter,
|
|
20980
|
-
authorize: config.storageAuthorize
|
|
20982
|
+
authorize: config.storageAuthorize,
|
|
20983
|
+
authorizeData: () => storageAuthorizeData.current
|
|
20981
20984
|
});
|
|
20982
20985
|
const storageRouter = new Hono();
|
|
20983
20986
|
if (apiKeyPreAuth) storageRouter.use("/*", apiKeyPreAuth, createStorageApiKeyGuard());
|
|
@@ -21056,6 +21059,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
21056
21059
|
roles: ["admin"]
|
|
21057
21060
|
};
|
|
21058
21061
|
const defaultData = buildSdkData(await scopeDataDriver(defaultDriver, serviceIdentity));
|
|
21062
|
+
storageAuthorizeData.current = defaultData;
|
|
21059
21063
|
const dataSourcesByKey = {};
|
|
21060
21064
|
for (const driverKey of driverRegistry.list()) {
|
|
21061
21065
|
if (driverKey === "(default)") continue;
|
|
@@ -23744,6 +23748,7 @@ async function bootFromBundle(options = {}) {
|
|
|
23744
23748
|
const server = createServer(getRequestListener(app.fetch));
|
|
23745
23749
|
const usersCollection = await loadUsersCollection(bundle);
|
|
23746
23750
|
const storage = resolveStorageSources(process.env, storageSourceDefs, path.join(bundle.dir, "uploads"));
|
|
23751
|
+
await ensureCollectionSchema(bundle, dataSources, env);
|
|
23747
23752
|
const backend = await initializeRebaseBackend({
|
|
23748
23753
|
server,
|
|
23749
23754
|
app,
|
|
@@ -23953,6 +23958,32 @@ async function runFromBundle(options = {}) {
|
|
|
23953
23958
|
process.exit(1);
|
|
23954
23959
|
}
|
|
23955
23960
|
}
|
|
23961
|
+
/**
|
|
23962
|
+
* Bring the database's collection tables up to date before serving.
|
|
23963
|
+
*
|
|
23964
|
+
* Delegates to whichever driver bootstrapped the default data source; a driver
|
|
23965
|
+
* without `ensureCollectionSchema` (a schemaless one, or an older build) simply
|
|
23966
|
+
* skips, which is why this cannot break an existing deployment.
|
|
23967
|
+
*
|
|
23968
|
+
* Failure is fatal on purpose. Booting anyway would produce exactly the state
|
|
23969
|
+
* this exists to prevent — an app that answers sign-in and 500s every data
|
|
23970
|
+
* request — and a crash-looping pod with the DDL error in its logs is a far
|
|
23971
|
+
* better signal than a running one that silently cannot serve.
|
|
23972
|
+
*/
|
|
23973
|
+
async function ensureCollectionSchema(bundle, dataSources, env) {
|
|
23974
|
+
if ((env.REBASE_MIGRATE_ON_BOOT || "ensure") === "none") {
|
|
23975
|
+
logger.info("REBASE_MIGRATE_ON_BOOT=none — leaving the database schema untouched.");
|
|
23976
|
+
return;
|
|
23977
|
+
}
|
|
23978
|
+
if ((bundle.manifest.mode ?? "cms") !== "cms") return;
|
|
23979
|
+
if (!bundle.collectionsDir) return;
|
|
23980
|
+
const primary = dataSources[0];
|
|
23981
|
+
if (!primary?.bootstrapper.ensureCollectionSchema) return;
|
|
23982
|
+
const collections = await loadCollectionsFromDirectory(bundle.collectionsDir);
|
|
23983
|
+
if (collections.length === 0) return;
|
|
23984
|
+
const { applied } = await primary.bootstrapper.ensureCollectionSchema(collections, primary.connection, (message) => logger.info(`schema: ${message}`));
|
|
23985
|
+
logger.info(applied > 0 ? `Applied ${applied} additive schema change(s) before boot.` : "Collection schema is up to date.");
|
|
23986
|
+
}
|
|
23956
23987
|
//#endregion
|
|
23957
23988
|
//#region src/api/contract-routes.ts
|
|
23958
23989
|
var contract_routes_exports = /* @__PURE__ */ __exportAll({ createContractRoutes: () => createContractRoutes });
|