@rebasepro/types 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/controllers/client.d.ts +9 -3
- package/dist/index.es.js +42 -2
- package/dist/index.es.js.map +1 -1
- package/dist/types/properties.d.ts +3 -2
- package/dist/types/relations.d.ts +38 -4
- package/dist/types/resource_kinds.d.ts +11 -1
- package/dist/types/schema_editing.d.ts +53 -0
- package/dist/types/storage_source.d.ts +34 -0
- package/package.json +1 -1
|
@@ -108,9 +108,9 @@ export interface AuthClient {
|
|
|
108
108
|
* Whether a session could exist that this client has not loaded yet.
|
|
109
109
|
*
|
|
110
110
|
* `false` means the only way this client can hold a session is an explicit
|
|
111
|
-
* sign-in during this page's lifetime: it
|
|
112
|
-
*
|
|
113
|
-
*
|
|
111
|
+
* sign-in during this page's lifetime: it does not persist sessions
|
|
112
|
+
* (`persistSession: false`), so it restores none on load, from storage or,
|
|
113
|
+
* in cookie mode, from the httpOnly auth cookie. A caller that would otherwise probe the server
|
|
114
114
|
* — `getUser()` on mount, say — can skip it, because the answer is already
|
|
115
115
|
* known and the request can only ever fail.
|
|
116
116
|
*
|
|
@@ -656,6 +656,12 @@ export interface RebaseServerClient<DB = RegisteredDatabase> extends Omit<Rebase
|
|
|
656
656
|
* `rebase.dataAsAdmin` go over the same wire wherever they run. A function
|
|
657
657
|
* that genuinely needs raw SQL can ask `runtimeKey()` and degrade, rather
|
|
658
658
|
* than discovering it at the call.
|
|
659
|
+
*
|
|
660
|
+
* It is not for making tables. An application table is a collection in
|
|
661
|
+
* `config/collections/`, created by boot with its validation, callbacks,
|
|
662
|
+
* security rules, admin view and SDK type; a `CREATE TABLE`, `ALTER TABLE`,
|
|
663
|
+
* `DROP TABLE` or `CREATE INDEX` run here gets none of those. Such a
|
|
664
|
+
* statement still runs, and logs a warning naming the collection to declare.
|
|
659
665
|
*/
|
|
660
666
|
sql(query: string, options?: {
|
|
661
667
|
database?: ResourceRef;
|
package/dist/index.es.js
CHANGED
|
@@ -884,6 +884,29 @@ function isManyToMany(relation) {
|
|
|
884
884
|
function isToMany(relation) {
|
|
885
885
|
return relation.cardinality === "many";
|
|
886
886
|
}
|
|
887
|
+
/**
|
|
888
|
+
* The conditions of a join step, as a list: one entry for a plain step, one
|
|
889
|
+
* per alternative for a step that joins on any of several.
|
|
890
|
+
* @group Models
|
|
891
|
+
*/
|
|
892
|
+
function joinConditions(step) {
|
|
893
|
+
return Array.isArray(step.on) ? step.on : [step.on];
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* The one condition of a step that has no alternatives — for the write paths,
|
|
897
|
+
* which only run on a writable chain and a chain with alternatives never is.
|
|
898
|
+
* Throws rather than pick one of several: writing a link into the wrong column
|
|
899
|
+
* is the mistake read-only exists to prevent.
|
|
900
|
+
* @group Models
|
|
901
|
+
*/
|
|
902
|
+
function soleJoinCondition(step) {
|
|
903
|
+
if (Array.isArray(step.on)) {
|
|
904
|
+
if (step.on.length === 1) return step.on[0];
|
|
905
|
+
if (step.on.length === 0) throw new Error(`The join into '${step.table}' lists no conditions, so it joins nothing.`);
|
|
906
|
+
throw new Error(`The join into '${step.table}' matches any of ${step.on.length} conditions, so it is read-only: there is no one column to write a link into.`);
|
|
907
|
+
}
|
|
908
|
+
return step.on;
|
|
909
|
+
}
|
|
887
910
|
//#endregion
|
|
888
911
|
//#region src/types/policy.ts
|
|
889
912
|
/**
|
|
@@ -1953,7 +1976,8 @@ amendResourceKind("bucket", {
|
|
|
1953
1976
|
"publicRead",
|
|
1954
1977
|
"prefix",
|
|
1955
1978
|
"account",
|
|
1956
|
-
"default"
|
|
1979
|
+
"default",
|
|
1980
|
+
"orphanSweep"
|
|
1957
1981
|
],
|
|
1958
1982
|
envBases: [
|
|
1959
1983
|
"STORAGE_TYPE",
|
|
@@ -2240,10 +2264,26 @@ function resourceToStorageSource(declaration) {
|
|
|
2240
2264
|
transport: declaration.transport,
|
|
2241
2265
|
...typeof declaration.options.account === "string" ? { account: declaration.options.account } : {},
|
|
2242
2266
|
...declaration.options.default === true ? { default: true } : {},
|
|
2267
|
+
...orphanSweepOf(declaration.options.orphanSweep),
|
|
2243
2268
|
...declaration.label !== void 0 ? { label: declaration.label } : {}
|
|
2244
2269
|
};
|
|
2245
2270
|
}
|
|
2246
2271
|
/**
|
|
2272
|
+
* A bucket's `orphanSweep` option as a definition carries it: `true` is the
|
|
2273
|
+
* defaults, an object keeps only the fields of the right type. The runtime
|
|
2274
|
+
* checks the values (the grace-period floor, the schedule) and refuses a bad
|
|
2275
|
+
* one loudly; this only refuses to invent one.
|
|
2276
|
+
*/
|
|
2277
|
+
function orphanSweepOf(option) {
|
|
2278
|
+
if (option === true) return { orphanSweep: {} };
|
|
2279
|
+
if (!option || typeof option !== "object") return {};
|
|
2280
|
+
const { olderThanHours, schedule } = option;
|
|
2281
|
+
return { orphanSweep: {
|
|
2282
|
+
...typeof olderThanHours === "number" ? { olderThanHours } : {},
|
|
2283
|
+
...typeof schedule === "string" ? { schedule } : {}
|
|
2284
|
+
} };
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2247
2287
|
* The declared databases, as definitions.
|
|
2248
2288
|
*
|
|
2249
2289
|
* Both the frontend and a project's own backend entrypoint read this. The
|
|
@@ -3815,6 +3855,6 @@ function resolverFromSources(client) {
|
|
|
3815
3855
|
};
|
|
3816
3856
|
}
|
|
3817
3857
|
//#endregion
|
|
3818
|
-
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ADMIN_ROLE, ADMIN_SCOPES, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, ANONYMOUS_USER_IDS, BATCH_REF_KEY, BUILT_IN_SCOPES, BUILT_IN_SCOPE_DESCRIPTIONS, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DATA_PLANE_SCOPES, DEFAULT_CAPABILITIES, DEFAULT_COMMIT_PATHS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_FUZZY_THRESHOLD, DEFAULT_LIST_LIMIT, DEFAULT_RESOURCE_KEY, DEFAULT_SEARCH_COLUMN, DEFAULT_SEARCH_LANGUAGE, DEFAULT_SEARCH_MODE, DEFAULT_SEARCH_WEIGHT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_TENANT_BYPASS_ROLES, DEFAULT_VECTOR_LIST_LIMIT, EMPTY_ACCESS_MODEL, EntityReference, EntityRelation, FIELD_OPERATORS, FIREBASE_CAPABILITIES, GeoPoint, IMPERSONATE_HEADER, INCLUDE_COUNT_KEY, JUNCTION_PIVOT_KEY, KEY_MANAGEMENT_SCOPES, LEGACY_RLS_JWT_SQL, LEGACY_RLS_ROLES_SQL, LEGACY_RLS_SCHEMA, LEGACY_RLS_UID_SQL, LIST_OPS, ListLimitError, MAX_INCLUDE_DEPTH, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REBASE_SCHEMA, RELEVANCE_SORT_FIELD, RESERVED_BACKEND_PREFIXES, RESOURCE_GRAPH_VERSION, REST_TO_CANONICAL, RLS_IS_ANONYMOUS_SQL, RLS_JWT_SQL, RLS_ROLES_SQL, RLS_UID_SQL, RUNTIME_CONTRACT_VERSION, RUNTIME_ONLY_COLLECTION_KEYS, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, SCOPE_TARGETS, SIMULATED_CONTEXT_HEADER, SIMULATE_API_KEY_ID_HEADER, SIMULATE_ROLE_HEADER, SIMULATE_USER_ID_HEADER, STORAGE_REFERENCE_SCHEME, Vector, amendResourceKind, applyCollectionPatch, bucket, buildResourceGraph, canonicalSchemaPayload, collectionPatchProblems, computeSchemaVersion, database, declareCron, declareFunction, declareResource, declaredDataSources, declaredDatabaseExtensions, declaredQueueConsumers, declaredResources, declaredStorageSources, declaredSubscriptions, describeScope, deserializeCollections, diffCollections, diffJsonValues, encodeRelationAggregateSort, envBasesForResource, findEnvSuffixCollision, findStorageSuffixCollision, formatSimulatedContext, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasAdminRole, hasFieldOperation, hasForeignKeyOnTarget, intersectScopes, isAdminScope, isAnonymousUid, isBranchAdmin, isBuiltInScope, isChannelBusInstance, isCollectionPatch, isContentHashedFileName, isDataPlaneScope, isDocumentAdmin, isFieldOperation, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStorageKey, isPublicStoragePath, isRelationAggregateSort, isRelationalCollectionConfig, isResourceHandle, isSQLAdmin, isSchemaAdmin, isSchemaEditingAdmin, isSerializedCollectionRef, isStorageReference, isTenantClaimSource, isTenantMembershipSource, isToMany, isUnsupported, isValidAppHost, isValidEngine, knownScopes, nestAdminCollectionKeys, nestAdminKeysOf, nestAdminPropertyKeys, nestCollectionPatchPaths, parseAppAddress, parseEnvBoolean, parseRelationAggregateSort, parseScope, parseSimulatedContext, parseStorageReference, policy, queue, registerDataSourceCapabilities, registerResourceKind, reservedPrefixFor, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resolveClientListLimit, resolveResourceRefs, resolveStorageReferences, resourceEnvSuffix, resourceId, resourceKeyOf, resourceKind, resourceKinds, resourceToDataSource, resourceToStorageSource, rewriteLegacyRlsFunctions, roleNameProblem, runtimeOnlyKeyIn, scopeAcceptsTarget, scopeGrants, scopeGrantsAny, scopeTargets, scopesBeyond, scopesForRoles, serializeCollections, setQueueRuntime, setTopicRuntime, simulationHeaders, sortKeyToString, storageEnvSuffix, storageObjectPath, storageReference, storageReferencesForDownloadUrls, storageTargetOfDownloadUrl, storageTargetsInText, summarizeRoles, summarizeScopes, toCanonicalOp, toCollectionJson, topic, unsupportedMethod, usesLegacyRlsFunctions, validateScopes };
|
|
3858
|
+
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ADMIN_ROLE, ADMIN_SCOPES, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, ANONYMOUS_USER_IDS, BATCH_REF_KEY, BUILT_IN_SCOPES, BUILT_IN_SCOPE_DESCRIPTIONS, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DATA_PLANE_SCOPES, DEFAULT_CAPABILITIES, DEFAULT_COMMIT_PATHS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_FUZZY_THRESHOLD, DEFAULT_LIST_LIMIT, DEFAULT_RESOURCE_KEY, DEFAULT_SEARCH_COLUMN, DEFAULT_SEARCH_LANGUAGE, DEFAULT_SEARCH_MODE, DEFAULT_SEARCH_WEIGHT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_TENANT_BYPASS_ROLES, DEFAULT_VECTOR_LIST_LIMIT, EMPTY_ACCESS_MODEL, EntityReference, EntityRelation, FIELD_OPERATORS, FIREBASE_CAPABILITIES, GeoPoint, IMPERSONATE_HEADER, INCLUDE_COUNT_KEY, JUNCTION_PIVOT_KEY, KEY_MANAGEMENT_SCOPES, LEGACY_RLS_JWT_SQL, LEGACY_RLS_ROLES_SQL, LEGACY_RLS_SCHEMA, LEGACY_RLS_UID_SQL, LIST_OPS, ListLimitError, MAX_INCLUDE_DEPTH, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REBASE_SCHEMA, RELEVANCE_SORT_FIELD, RESERVED_BACKEND_PREFIXES, RESOURCE_GRAPH_VERSION, REST_TO_CANONICAL, RLS_IS_ANONYMOUS_SQL, RLS_JWT_SQL, RLS_ROLES_SQL, RLS_UID_SQL, RUNTIME_CONTRACT_VERSION, RUNTIME_ONLY_COLLECTION_KEYS, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, SCOPE_TARGETS, SIMULATED_CONTEXT_HEADER, SIMULATE_API_KEY_ID_HEADER, SIMULATE_ROLE_HEADER, SIMULATE_USER_ID_HEADER, STORAGE_REFERENCE_SCHEME, Vector, amendResourceKind, applyCollectionPatch, bucket, buildResourceGraph, canonicalSchemaPayload, collectionPatchProblems, computeSchemaVersion, database, declareCron, declareFunction, declareResource, declaredDataSources, declaredDatabaseExtensions, declaredQueueConsumers, declaredResources, declaredStorageSources, declaredSubscriptions, describeScope, deserializeCollections, diffCollections, diffJsonValues, encodeRelationAggregateSort, envBasesForResource, findEnvSuffixCollision, findStorageSuffixCollision, formatSimulatedContext, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasAdminRole, hasFieldOperation, hasForeignKeyOnTarget, intersectScopes, isAdminScope, isAnonymousUid, isBranchAdmin, isBuiltInScope, isChannelBusInstance, isCollectionPatch, isContentHashedFileName, isDataPlaneScope, isDocumentAdmin, isFieldOperation, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStorageKey, isPublicStoragePath, isRelationAggregateSort, isRelationalCollectionConfig, isResourceHandle, isSQLAdmin, isSchemaAdmin, isSchemaEditingAdmin, isSerializedCollectionRef, isStorageReference, isTenantClaimSource, isTenantMembershipSource, isToMany, isUnsupported, isValidAppHost, isValidEngine, joinConditions, knownScopes, nestAdminCollectionKeys, nestAdminKeysOf, nestAdminPropertyKeys, nestCollectionPatchPaths, parseAppAddress, parseEnvBoolean, parseRelationAggregateSort, parseScope, parseSimulatedContext, parseStorageReference, policy, queue, registerDataSourceCapabilities, registerResourceKind, reservedPrefixFor, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resolveClientListLimit, resolveResourceRefs, resolveStorageReferences, resourceEnvSuffix, resourceId, resourceKeyOf, resourceKind, resourceKinds, resourceToDataSource, resourceToStorageSource, rewriteLegacyRlsFunctions, roleNameProblem, runtimeOnlyKeyIn, scopeAcceptsTarget, scopeGrants, scopeGrantsAny, scopeTargets, scopesBeyond, scopesForRoles, serializeCollections, setQueueRuntime, setTopicRuntime, simulationHeaders, soleJoinCondition, sortKeyToString, storageEnvSuffix, storageObjectPath, storageReference, storageReferencesForDownloadUrls, storageTargetOfDownloadUrl, storageTargetsInText, summarizeRoles, summarizeScopes, toCanonicalOp, toCollectionJson, topic, unsupportedMethod, usesLegacyRlsFunctions, validateScopes };
|
|
3819
3859
|
|
|
3820
3860
|
//# sourceMappingURL=index.es.js.map
|