@rebasepro/server 0.21.2-canary.g1ea48be → 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-DZXQRmYD.js → auth-CCDpk2rn.js} +7 -5
- package/dist/{auth-DZXQRmYD.js.map → auth-CCDpk2rn.js.map} +1 -1
- package/dist/{cron-routes-cv0hSd-O.js → cron-routes-B7CRGfiq.js} +2 -2
- package/dist/{cron-routes-cv0hSd-O.js.map → cron-routes-B7CRGfiq.js.map} +1 -1
- package/dist/{cron-store-Bdm7JqFB.js → cron-store-BYGZFNWk.js} +2 -2
- package/dist/{cron-store-Bdm7JqFB.js.map → cron-store-BYGZFNWk.js.map} +1 -1
- package/dist/ddl-bootstrap-CfNvxMuK.js.map +1 -1
- package/dist/{history-recorder-CYfkqP2X.js → history-recorder-BQmB0P_j.js} +2 -2
- package/dist/{history-recorder-CYfkqP2X.js.map → history-recorder-BQmB0P_j.js.map} +1 -1
- package/dist/{history-store-B1CBwLfi.js → history-store-CetkrBBD.js} +2 -2
- package/dist/{history-store-B1CBwLfi.js.map → history-store-CetkrBBD.js.map} +1 -1
- package/dist/index.es.js +60 -20
- package/dist/index.es.js.map +1 -1
- package/dist/init/global-callbacks.d.ts +21 -0
- package/dist/{jobs-2fO2BI8P.js → jobs-Bjr8DZAi.js} +2 -2
- package/dist/{jobs-2fO2BI8P.js.map → jobs-Bjr8DZAi.js.map} +1 -1
- package/dist/{openapi-generator-D8ZIN_ss.js → openapi-generator-D8uFz-LW.js} +2 -2
- package/dist/{openapi-generator-D8ZIN_ss.js.map → openapi-generator-D8uFz-LW.js.map} +1 -1
- package/dist/{query-parser-CoIOmflr.js → query-parser-BleZmY18.js} +2 -2
- package/dist/{query-parser-CoIOmflr.js.map → query-parser-BleZmY18.js.map} +1 -1
- package/dist/{src-BYax9_rm.js → src-1vL-I1Po.js} +69 -2
- package/dist/src-1vL-I1Po.js.map +1 -0
- package/package.json +5 -5
- package/dist/src-BYax9_rm.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -2,16 +2,16 @@ import { createRequire as __rebaseCreateRequire } from "module";
|
|
|
2
2
|
import __rebaseProcess from "process";
|
|
3
3
|
globalThis.process ??= __rebaseProcess;
|
|
4
4
|
__rebaseCreateRequire(import.meta.url);
|
|
5
|
-
import { A as
|
|
5
|
+
import { A as createDataSourceRegistry, B as fieldKeyForColumn, D as restrictedFieldNames, E as effectiveAccess, F as revokeInternalTableSql, G as enumToObjectEntries, H as getTableName, I as getJunctionConfigForRelation, J as hydrateRegExp, K as buildCompositeId, L as getEffectiveSecurityRules, M as resolveDataSource, N as authSecretsMissingExclusion, O as assertBeforeQueryIsPostgresOnly, Q as unref, S as cursorToStartAfter, T as canWriteField, V as findRelation, W as resolveCollectionRelations, X as suggestNearMiss, Y as splitSearchTerms, Z as toSnakeCase, _t as isUnsupported, at as isFieldOperation, c as collectAllPages, ct as JUNCTION_PIVOT_KEY, dt as EntityReference, ft as EntityRelation, g as topLevelIncludeNames, gt as RebaseClientError, h as serializeInclude, ht as RebaseApiError, it as hasFieldOperation, j as isRelationalCollection, k as CollectionRegistry, l as paginateFind, lt as isManyToMany, mt as Vector, n as buildSdkData, nt as BATCH_REF_KEY, o as serializeFilter, p as mergeIncludeSpecs, pt as GeoPoint, q as resolvePrimaryKeys, rt as FIELD_OPERATORS, s as serializeLogicalCondition, t as buildRoutedRebaseData, u as resolveFindWindow, v as normalizeOrderBy, vt as unsupportedMethod, y as serializeOrderBy, z as securityRuleToConditions } from "./src-1vL-I1Po.js";
|
|
6
6
|
import { E as DEFAULT_DATA_SOURCE_KEY, F as sortKeyToString, I as toCanonicalOp, P as parseRelationAggregateSort, S as getCollectionDataPath, _ as resourceKinds, a as resourceToStorageSource, b as RLS_UID_SQL, c as DEFAULT_STORAGE_SOURCE_KEY, d as DEFAULT_RESOURCE_KEY, f as buildResourceGraph, g as resourceKind, h as resourceKeyOf, i as resourceToDataSource, l as findStorageSuffixCollision, m as resourceEnvSuffix, n as declaredQueueConsumers, o as setQueueRuntime, p as resolveResourceRefs, r as declaredSubscriptions, s as setTopicRuntime, u as storageEnvSuffix, v as RLS_JWT_SQL, w as isPostgresCollectionConfig, y as RLS_ROLES_SQL } from "./src-Br6ARbs6.js";
|
|
7
7
|
import { n as ADMIN_PROPERTY_KEYS, t as ADMIN_COLLECTION_KEYS } from "./admin_block-DxKLmdiv.js";
|
|
8
8
|
import { a as isDuplicateObjectRace, i as isConcurrentDdlRace, n as createDdlBootstrapper, o as isSQLAdmin, s as isSchemaEditingAdmin, t as CONCURRENT_DDL_SQLSTATES } from "./ddl-bootstrap-CfNvxMuK.js";
|
|
9
9
|
import { i as parseEnvBoolean, r as validateCronExpression, t as CronScheduler } from "./cron-scheduler-COPQxlEq.js";
|
|
10
10
|
import { i as SCHEMA_VERSION_HEADER, n as createContractRoutes, r as computeSchemaVersion } from "./contract-routes-eLxV0le1.js";
|
|
11
|
-
import { $ as requireAdmin, A as defaultAuthLimiter, B as resolveEmailLinkBase, C as providerVerifiedEmail, Ct as raw, D as DEFAULT_FUNCTIONS_ANONYMOUS_LIMIT, Dt as isPublicStoragePath, E as isBootstrapWindowOpen, Et as PUBLIC_STORAGE_PREFIX, F as extractLinks, G as createAdapterAuthMiddleware, H as hashPassword, I as registerDevEmailSink, J as extractUserFromToken, K as createAuthMiddleware, L as SMTPEmailService, M as activeDevEmailSink, N as clearActiveDevEmailSink, O as createDataRateLimiter, P as createDevEmailSink, Q as queryTokenAuth, R as createEmailService, S as pkceTokenParams, St as html, T as createBuiltinAuthAdapter, Tt as isOperationAllowed, U as validatePasswordStrength, V as resolveAuthHooks, W as verifyPassword, X as optionalAuth, Y as fileTokenAuth, Z as publicObjectAuth, _ as verifyOidcIdToken, _t as getUserInvitationTemplate, a as resolveRateLimitStoreKind, at as validateApiKey, b as createGoogleProvider, bt as RawHtml, c as createSlackProvider, ct as SERVICE_IDENTITY, d as createDiscordProvider, dt as completeUserCreation, et as requireAuth, f as createTwitterProvider, ft as generateSecurePassword, g as tryVerifyOidcIdToken, gt as getPasswordResetTemplate, h as createMicrosoftProvider, ht as getMagicLinkTemplate, i as createApiKeyStore, it as isApiKeyToken, j as MemoryRateLimitStore, k as createRateLimiter, l as createBitbucketProvider, lt as scopeDataDriver, m as createAppleProvider, mt as getEmailVerificationTemplate, n as createCustomAuthAdapter, nt as createFunctionApiKeyGuard, o as createSqlRateLimitStore, ot as extractBearerToken, p as createFacebookProvider, pt as getEmailOtpTemplate, q as createRequireAuth, r as createApiKeyRoutes, rt as createStorageApiKeyGuard, s as createSpotifyProvider, st as safeCompare, tt as createApiKeyPreAuth, u as createGitLabProvider, ut as supportsRlsScoping, v as createGitHubProvider, vt as getWelcomeEmailTemplate, w as createJwksRoutes, wt as httpMethodToOperation, x as oauthCodeFlowSchema, xt as escapeHtml, y as createLinkedinProvider, yt as resolveEmailBranding, z as assertEmailLinkBases } from "./auth-
|
|
11
|
+
import { $ as requireAdmin, A as defaultAuthLimiter, B as resolveEmailLinkBase, C as providerVerifiedEmail, Ct as raw, D as DEFAULT_FUNCTIONS_ANONYMOUS_LIMIT, Dt as isPublicStoragePath, E as isBootstrapWindowOpen, Et as PUBLIC_STORAGE_PREFIX, F as extractLinks, G as createAdapterAuthMiddleware, H as hashPassword, I as registerDevEmailSink, J as extractUserFromToken, K as createAuthMiddleware, L as SMTPEmailService, M as activeDevEmailSink, N as clearActiveDevEmailSink, O as createDataRateLimiter, P as createDevEmailSink, Q as queryTokenAuth, R as createEmailService, S as pkceTokenParams, St as html, T as createBuiltinAuthAdapter, Tt as isOperationAllowed, U as validatePasswordStrength, V as resolveAuthHooks, W as verifyPassword, X as optionalAuth, Y as fileTokenAuth, Z as publicObjectAuth, _ as verifyOidcIdToken, _t as getUserInvitationTemplate, a as resolveRateLimitStoreKind, at as validateApiKey, b as createGoogleProvider, bt as RawHtml, c as createSlackProvider, ct as SERVICE_IDENTITY, d as createDiscordProvider, dt as completeUserCreation, et as requireAuth, f as createTwitterProvider, ft as generateSecurePassword, g as tryVerifyOidcIdToken, gt as getPasswordResetTemplate, h as createMicrosoftProvider, ht as getMagicLinkTemplate, i as createApiKeyStore, it as isApiKeyToken, j as MemoryRateLimitStore, k as createRateLimiter, l as createBitbucketProvider, lt as scopeDataDriver, m as createAppleProvider, mt as getEmailVerificationTemplate, n as createCustomAuthAdapter, nt as createFunctionApiKeyGuard, o as createSqlRateLimitStore, ot as extractBearerToken, p as createFacebookProvider, pt as getEmailOtpTemplate, q as createRequireAuth, r as createApiKeyRoutes, rt as createStorageApiKeyGuard, s as createSpotifyProvider, st as safeCompare, tt as createApiKeyPreAuth, u as createGitLabProvider, ut as supportsRlsScoping, v as createGitHubProvider, vt as getWelcomeEmailTemplate, w as createJwksRoutes, wt as httpMethodToOperation, x as oauthCodeFlowSchema, xt as escapeHtml, y as createLinkedinProvider, yt as resolveEmailBranding, z as assertEmailLinkBases } from "./auth-CCDpk2rn.js";
|
|
12
12
|
import { i as rawQueryLoggingEnabled, n as describeCauseChain, o as setLogLevel, r as logger, s as hostEnv } from "./logger-DO2PZc4i.js";
|
|
13
13
|
import { i as schemaDriftRemedy, n as declaredErrorAnswer, r as errorHandler, t as ApiError } from "./errors-DWsX4yTd.js";
|
|
14
|
-
import { a as resolveListLimitParam, c as HARD_DELETE_QUERY_PARAM, i as parseQueryOptions, l as parseHardDelete, n as parseAggregateSelect, o as assertReadableFields, r as parseGroupBy, s as requestViewer, t as orderByEntriesToTuples } from "./query-parser-
|
|
14
|
+
import { a as resolveListLimitParam, c as HARD_DELETE_QUERY_PARAM, i as parseQueryOptions, l as parseHardDelete, n as parseAggregateSelect, o as assertReadableFields, r as parseGroupBy, s as requestViewer, t as orderByEntriesToTuples } from "./query-parser-BleZmY18.js";
|
|
15
15
|
import { D as sha256Bytes, O as sha256Hex, S as normalizePemFromEnv, T as randomHex, _ as verifyAccessToken, a as generateMcpAccessToken, f as hasAsymmetricSigningKey, g as signPurposeToken, i as generateDownloadToken, l as getJwks, m as isJwtConfigured, n as configureJwt, w as constantTimeEqual, x as verifyPurposeToken, y as verifyMcpAccessToken } from "./jwt-C4OW-DNq.js";
|
|
16
16
|
import { a as canonicalStorageKey, i as canonicalStorageId, n as InvalidStorageKeyError, r as canonicalStorageBucket, t as InvalidStorageBucketError } from "./keys-Qfc4XieN.js";
|
|
17
17
|
import { t as logMiddleware } from "./logs-routes-3EEzPjhl.js";
|
|
@@ -24,11 +24,11 @@ import "./proxy-Czngl3p9.js";
|
|
|
24
24
|
import "./request-timeout-C_4C2BeR.js";
|
|
25
25
|
import { t as FunctionSelectionError } from "./selection-CRpqKUbt.js";
|
|
26
26
|
import { n as loadCronJobsFromDirectory, r as loadCronJobsWithDiagnostics } from "./cron-loader-CQjvjpEw.js";
|
|
27
|
-
import { t as createCronRoutes } from "./cron-routes-
|
|
28
|
-
import { t as createCronStore } from "./cron-store-
|
|
27
|
+
import { t as createCronRoutes } from "./cron-routes-B7CRGfiq.js";
|
|
28
|
+
import { t as createCronStore } from "./cron-store-BYGZFNWk.js";
|
|
29
29
|
import { a as parseBackupTimestamp, i as parseBackupDestination, n as createBackupRoutes, o as readBackupBytes, r as listBackupObjects } from "./backup-DzI9jLwc.js";
|
|
30
|
-
import { a as currentAmbientTransaction, i as createJobStore, n as createJobQueue, r as defaultBackoff } from "./jobs-
|
|
31
|
-
import { t as METRIC_SERIES } from "./history-store-
|
|
30
|
+
import { a as currentAmbientTransaction, i as createJobStore, n as createJobQueue, r as defaultBackoff } from "./jobs-Bjr8DZAi.js";
|
|
31
|
+
import { t as METRIC_SERIES } from "./history-store-CetkrBBD.js";
|
|
32
32
|
import { createHash, createSign, randomBytes } from "node:crypto";
|
|
33
33
|
import * as fs$3 from "fs";
|
|
34
34
|
import fs, { existsSync } from "fs";
|
|
@@ -7379,7 +7379,7 @@ async function mountOpenApiDocs(app, basePath, enableSwagger, serverCollections,
|
|
|
7379
7379
|
basePath,
|
|
7380
7380
|
requireAuth
|
|
7381
7381
|
}));
|
|
7382
|
-
const { generateOpenApiSpec } = await import("./openapi-generator-
|
|
7382
|
+
const { generateOpenApiSpec } = await import("./openapi-generator-D8uFz-LW.js");
|
|
7383
7383
|
generateOpenApiSpecFn = generateOpenApiSpec;
|
|
7384
7384
|
if (isPublic) app.get(`${basePath}/docs`, (c) => spec(c));
|
|
7385
7385
|
else app.get(`${basePath}/docs`, createRequireAuth({}), requireAdmin, (c) => spec(c));
|
|
@@ -8834,6 +8834,33 @@ function injectCallbackClient(results, client) {
|
|
|
8834
8834
|
return injected;
|
|
8835
8835
|
}
|
|
8836
8836
|
//#endregion
|
|
8837
|
+
//#region src/init/global-callbacks.ts
|
|
8838
|
+
/**
|
|
8839
|
+
* Hand the backend's global callbacks to one driver.
|
|
8840
|
+
*
|
|
8841
|
+
* `initializeRebaseBackend({ callbacks })` is declared once, on the backend,
|
|
8842
|
+
* but no driver resolves callbacks from the backend's `collectionRegistry`:
|
|
8843
|
+
* each builds a registry of its own in `initializeDriver` and reads global
|
|
8844
|
+
* callbacks from that. So they are given to each driver here, by the
|
|
8845
|
+
* coordinator, rather than left for every driver to remember to ask for.
|
|
8846
|
+
*
|
|
8847
|
+
* Refuses rather than skipping, in two cases.
|
|
8848
|
+
*
|
|
8849
|
+
* - **A registry that cannot take them.** Every collection that driver serves
|
|
8850
|
+
* would run with the global hooks off, an `afterRead` that masks PII among
|
|
8851
|
+
* them, and nothing would say so.
|
|
8852
|
+
* - **A global `beforeQuery` on a driver that does not compile one.** Only
|
|
8853
|
+
* `@rebasepro/server-postgres` narrows a read before running it. Anywhere
|
|
8854
|
+
* else the hook is a row filter that filters nothing, which is the refusal
|
|
8855
|
+
* `assertBeforeQueryIsPostgresOnly` makes for a collection's own hook.
|
|
8856
|
+
*/
|
|
8857
|
+
function handGlobalCallbacksTo(driverId, engine, driverResult, callbacks) {
|
|
8858
|
+
if (callbacks.beforeQuery && engine !== "postgres") throw new Error(`callbacks.beforeQuery: a global \`beforeQuery\` narrows every collection's reads before they are compiled, which is a Postgres feature, and data source "${driverId}" is served by \`${engine}\`. Its collections would keep returning every row the engine allows. Declare the hook on the Postgres collections that need it instead. Redaction that works on every engine is \`afterRead\`.`);
|
|
8859
|
+
const registry = driverResult.collectionRegistry;
|
|
8860
|
+
if (!registry?.setGlobalCallbacks) throw new Error(`callbacks: data source "${driverId}" (\`${engine}\`) returned no collection registry that accepts global callbacks, so the ones declared on \`initializeRebaseBackend({ callbacks })\` would not run on any of its collections. Return a \`collectionRegistry\` implementing \`setGlobalCallbacks\` from the adapter's \`initializeDriver\`, or move the hooks onto each collection's \`callbacks\`.`);
|
|
8861
|
+
registry.setGlobalCallbacks(callbacks);
|
|
8862
|
+
}
|
|
8863
|
+
//#endregion
|
|
8837
8864
|
//#region src/init/process-safety.ts
|
|
8838
8865
|
/**
|
|
8839
8866
|
* Installed once per process. The singleton is process-global for the same
|
|
@@ -15449,16 +15476,23 @@ function matchesLogical(row, condition) {
|
|
|
15449
15476
|
* cached row does not carry — a local list may therefore be missing rows the
|
|
15450
15477
|
* server would have returned, which is why {@link isExactlyEvaluable} refuses
|
|
15451
15478
|
* to call a search query exact.
|
|
15479
|
+
*
|
|
15480
|
+
* Every term has to match, but they may match different fields — the same rule
|
|
15481
|
+
* both drivers apply, and the one that finds `sebastian melendez` on a row that
|
|
15482
|
+
* keeps the two halves of a name in separate fields. Matching the typed string
|
|
15483
|
+
* as a whole found neither that row nor, because the space was part of the
|
|
15484
|
+
* needle, anything at all for `sebastian `.
|
|
15452
15485
|
*/
|
|
15453
15486
|
function matchesSearch(row, searchString) {
|
|
15454
15487
|
if (!searchString) return true;
|
|
15455
|
-
const
|
|
15456
|
-
if (
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
if (typeof value === "
|
|
15460
|
-
|
|
15461
|
-
|
|
15488
|
+
const terms = splitSearchTerms(searchString).map((term) => term.toLowerCase());
|
|
15489
|
+
if (terms.length === 0) return true;
|
|
15490
|
+
const values = Object.values(row);
|
|
15491
|
+
return terms.every((term) => values.some((value) => {
|
|
15492
|
+
if (typeof value === "string") return value.toLowerCase().includes(term);
|
|
15493
|
+
if (typeof value === "number") return String(value).includes(term);
|
|
15494
|
+
return false;
|
|
15495
|
+
}));
|
|
15462
15496
|
}
|
|
15463
15497
|
/** Does this row belong in the result set for `params`, ignoring pagination? */
|
|
15464
15498
|
function matchesParams(row, params) {
|
|
@@ -18906,6 +18940,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
18906
18940
|
provision: config.provisionSchema ?? true
|
|
18907
18941
|
}
|
|
18908
18942
|
});
|
|
18943
|
+
if (config.callbacks) handGlobalCallbacksTo(b.id || bootstrapper.type, bootstrapper.type, driverResult, config.callbacks);
|
|
18909
18944
|
delegates[b.id || bootstrapper.type] = driverResult.driver;
|
|
18910
18945
|
driverResults.set(bootstrapper, driverResult);
|
|
18911
18946
|
if (introspectCollections) {
|
|
@@ -19145,7 +19180,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
19145
19180
|
]) {
|
|
19146
19181
|
const providerConfig = safeAuthConfig[key];
|
|
19147
19182
|
if (providerConfig && requiredFields.every((f) => Boolean(providerConfig[f]))) {
|
|
19148
|
-
const createFn = (await import("./auth-
|
|
19183
|
+
const createFn = (await import("./auth-CCDpk2rn.js").then((n) => n.t))[factory];
|
|
19149
19184
|
oauthProviders.push(createFn(providerConfig));
|
|
19150
19185
|
}
|
|
19151
19186
|
}
|
|
@@ -19650,8 +19685,8 @@ async function _initializeRebaseBackend(config) {
|
|
|
19650
19685
|
if (surfaces.cron || config.cronsDir && ownership.cronScheduler) {
|
|
19651
19686
|
const { loadCronJobsWithDiagnostics } = await import("./cron-loader-CQjvjpEw.js").then((n) => n.t);
|
|
19652
19687
|
const { CronScheduler } = await import("./cron-scheduler-COPQxlEq.js").then((n) => n.n);
|
|
19653
|
-
const { createCronRoutes } = await import("./cron-routes-
|
|
19654
|
-
const { createCronStore } = await import("./cron-store-
|
|
19688
|
+
const { createCronRoutes } = await import("./cron-routes-B7CRGfiq.js").then((n) => n.n);
|
|
19689
|
+
const { createCronStore } = await import("./cron-store-BYGZFNWk.js").then((n) => n.n);
|
|
19655
19690
|
const { jobs: loadedCronJobs, problems: cronProblems } = config.cronsDir ? await loadCronJobsWithDiagnostics(config.cronsDir) : {
|
|
19656
19691
|
jobs: [],
|
|
19657
19692
|
problems: []
|
|
@@ -19708,7 +19743,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
19708
19743
|
}
|
|
19709
19744
|
let metricsHistory;
|
|
19710
19745
|
try {
|
|
19711
|
-
const { createMetricsHistory } = await import("./history-recorder-
|
|
19746
|
+
const { createMetricsHistory } = await import("./history-recorder-BQmB0P_j.js");
|
|
19712
19747
|
metricsHistory = createMetricsHistory(defaultDriver);
|
|
19713
19748
|
if (metricsHistory) {
|
|
19714
19749
|
await metricsHistory.ensure();
|
|
@@ -19720,7 +19755,7 @@ async function _initializeRebaseBackend(config) {
|
|
|
19720
19755
|
}
|
|
19721
19756
|
let jobQueue;
|
|
19722
19757
|
if (config.jobs?.enabled) {
|
|
19723
|
-
const { createJobStore, createJobQueue } = await import("./jobs-
|
|
19758
|
+
const { createJobStore, createJobQueue } = await import("./jobs-Bjr8DZAi.js").then((n) => n.t);
|
|
19724
19759
|
const store = createJobStore(defaultDriver);
|
|
19725
19760
|
if (store) {
|
|
19726
19761
|
await store.ensureTable();
|
|
@@ -19859,6 +19894,11 @@ Use a driver that supports the job queue, or remove the declarations. Refusing t
|
|
|
19859
19894
|
return targets;
|
|
19860
19895
|
};
|
|
19861
19896
|
const setCollectionCallbacks = (slug, callbacks) => {
|
|
19897
|
+
const declared = collectionRegistry.get(slug);
|
|
19898
|
+
if (declared) assertBeforeQueryIsPostgresOnly([{
|
|
19899
|
+
...declared,
|
|
19900
|
+
callbacks
|
|
19901
|
+
}]);
|
|
19862
19902
|
let attached = 0;
|
|
19863
19903
|
const replaced = /* @__PURE__ */ new Set();
|
|
19864
19904
|
for (const registry of callbackTargets()) {
|