@rebasepro/server-postgres 0.16.0 → 0.16.1-canary.g041c925
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/PostgresAdapter.d.ts +1 -1
- package/dist/PostgresBackendDriver.d.ts +16 -7
- package/dist/PostgresBootstrapper.d.ts +6 -6
- package/dist/auth/services.d.ts +1 -1
- package/dist/backup/backup-cron.d.ts +1 -1
- package/dist/backup/backup-service.d.ts +2 -2
- package/dist/backup/index.d.ts +4 -4
- package/dist/{backup-service-BZoixhVl.js → backup-service-FN6V3rVi.js} +4 -4
- package/dist/{backup-service-BZoixhVl.js.map → backup-service-FN6V3rVi.js.map} +1 -1
- package/dist/collections/PostgresCollectionRegistry.d.ts +1 -1
- package/dist/collections/buildRegistry.d.ts +1 -1
- package/dist/collections/validate-relations.d.ts +1 -1
- package/dist/{connection-BuZ97wsr.js → connection-GOKU3Hu5.js} +34 -7
- package/dist/connection-GOKU3Hu5.js.map +1 -0
- package/dist/connection.d.ts +16 -0
- package/dist/data-transformer.d.ts +1 -1
- package/dist/{ensure-collection-policies-BVFb2olB.js → ensure-collection-policies-B01cv9UC.js} +4 -4
- package/dist/{ensure-collection-policies-BVFb2olB.js.map → ensure-collection-policies-B01cv9UC.js.map} +1 -1
- package/dist/{auth-users-columns-CgyPWQ18.js → ensure-collection-tables-CvW6tbI7.js} +1482 -12
- package/dist/ensure-collection-tables-CvW6tbI7.js.map +1 -0
- package/dist/index.d.ts +16 -16
- package/dist/index.es.js +2183 -1817
- package/dist/index.es.js.map +1 -1
- package/dist/{rls-bootstrap-sql-B5Sajku6.js → rls-bootstrap-sql-DAwWHs81.js} +3 -3
- package/dist/{rls-bootstrap-sql-B5Sajku6.js.map → rls-bootstrap-sql-DAwWHs81.js.map} +1 -1
- package/dist/{rls-enforcement-Ch0T6OwW.js → rls-enforcement-eSahD7ec.js} +13 -3
- package/dist/rls-enforcement-eSahD7ec.js.map +1 -0
- package/dist/schema/classify-change.d.ts +82 -0
- package/dist/schema/dynamic-tables.d.ts +1 -1
- package/dist/schema/ensure-collection-policies.d.ts +1 -1
- package/dist/schema/ensure-collection-tables.d.ts +93 -2
- package/dist/schema/generate-schema-commit.d.ts +136 -0
- package/dist/schema/generated-schema-staleness.d.ts +19 -0
- package/dist/schema/introspect-db-constraints.d.ts +1 -1
- package/dist/schema/introspect-db-logic.d.ts +3 -3
- package/dist/schema/introspect-db-project.d.ts +1 -1
- package/dist/schema/introspect-db-queries.d.ts +1 -1
- package/dist/schema/introspect-db-structure.d.ts +2 -2
- package/dist/schema/introspect-runtime.d.ts +1 -1
- package/dist/schema/vector-index.d.ts +88 -0
- package/dist/services/BranchService.d.ts +2 -2
- package/dist/services/FetchService.d.ts +4 -4
- package/dist/services/PersistService.d.ts +5 -5
- package/dist/services/RelationService.d.ts +3 -3
- package/dist/services/RelationWriteService.d.ts +3 -3
- package/dist/services/cdc/junction-tables.d.ts +1 -1
- package/dist/services/cdc/trigger-cdc.d.ts +1 -1
- package/dist/services/channel-bus/PostgresChannelBus.d.ts +1 -1
- package/dist/services/channel-bus/index.d.ts +2 -2
- package/dist/services/collection-helpers.d.ts +1 -1
- package/dist/services/dataService.d.ts +10 -10
- package/dist/services/index.d.ts +4 -4
- package/dist/services/junction-writes.d.ts +2 -2
- package/dist/services/nested-path.d.ts +1 -1
- package/dist/services/realtimeService.d.ts +3 -3
- package/dist/services/row-pipeline.d.ts +1 -1
- package/dist/services/write-denial.d.ts +1 -1
- package/dist/{src-BBFsDaeA.js → src-DolrXONo.js} +93 -1
- package/dist/src-DolrXONo.js.map +1 -0
- package/dist/utils/drizzle-conditions.d.ts +2 -2
- package/dist/{websocket-BVgDVO-V.js → websocket-7Dp77lTh.js} +43 -6
- package/dist/websocket-7Dp77lTh.js.map +1 -0
- package/dist/websocket.d.ts +29 -2
- package/package.json +7 -7
- package/src/PostgresBackendDriver.ts +41 -2
- package/src/backup/backup-service.ts +1 -1
- package/src/cli-helpers.ts +3 -2
- package/src/connection.ts +37 -3
- package/src/databasePoolManager.ts +5 -2
- package/src/schema/classify-change.ts +436 -0
- package/src/schema/ensure-collection-tables.test.ts +168 -1
- package/src/schema/ensure-collection-tables.ts +344 -14
- package/src/schema/generate-drizzle-schema-logic.ts +23 -11
- package/src/schema/generate-drizzle-schema.ts +13 -2
- package/src/schema/generate-postgres-ddl-logic.ts +16 -1
- package/src/schema/generate-postgres-ddl.ts +13 -2
- package/src/schema/generate-schema-commit.ts +242 -0
- package/src/schema/generated-schema-staleness.ts +114 -1
- package/src/schema/vector-index.ts +278 -0
- package/src/services/collection-helpers.ts +3 -2
- package/src/websocket.ts +36 -2
- package/dist/auth-users-columns-CgyPWQ18.js.map +0 -1
- package/dist/connection-BuZ97wsr.js.map +0 -1
- package/dist/ensure-collection-tables-BY1pHRD_.js +0 -840
- package/dist/ensure-collection-tables-BY1pHRD_.js.map +0 -1
- package/dist/rls-enforcement-Ch0T6OwW.js.map +0 -1
- package/dist/src-BBFsDaeA.js.map +0 -1
- package/dist/utils/table-classification.d.ts +0 -8
- package/dist/websocket-BVgDVO-V.js.map +0 -1
- package/src/utils/table-classification.ts +0 -16
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* No side effects beyond `SELECT`. Introspection reads a database it does not
|
|
10
10
|
* own — it must never `ANALYZE`, create a temp table, or otherwise write.
|
|
11
11
|
*/
|
|
12
|
-
import type { SchemaMetadata } from "./introspect-db-logic";
|
|
12
|
+
import type { SchemaMetadata } from "./introspect-db-logic.js";
|
|
13
13
|
/** The subset of `pg.Client` this module needs, so tests can pass a fake. */
|
|
14
14
|
export interface QueryableClient {
|
|
15
15
|
query<R = Record<string, unknown>>(text: string, values?: unknown[]): Promise<{
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
* which the caller fills from {@link ./introspect-db-queries.countRowsUpTo} for
|
|
34
34
|
* the tables {@link lookupCandidates} names.
|
|
35
35
|
*/
|
|
36
|
-
import type { ForeignKeyRow, SchemaMetadata, TableColumn, TableMeta } from "./introspect-db-logic";
|
|
37
|
-
import type { CheckFactsByTable } from "./introspect-db-constraints";
|
|
36
|
+
import type { ForeignKeyRow, SchemaMetadata, TableColumn, TableMeta } from "./introspect-db-logic.js";
|
|
37
|
+
import type { CheckFactsByTable } from "./introspect-db-constraints.js";
|
|
38
38
|
/**
|
|
39
39
|
* The row count above which a referenced table is a real entity rather than a
|
|
40
40
|
* code list. Deliberately low: `pagila.category` has 16 rows and `language` 6,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* the same way whether it was generated or introspected.
|
|
13
13
|
*/
|
|
14
14
|
import type { PostgresCollectionConfig } from "@rebasepro/types";
|
|
15
|
-
import { TableMeta } from "./introspect-db-logic";
|
|
15
|
+
import { TableMeta } from "./introspect-db-logic.js";
|
|
16
16
|
export interface IntrospectedSchema {
|
|
17
17
|
tablesMap: Map<string, TableMeta>;
|
|
18
18
|
enumMap: Map<string, string[]>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place a `{ type: "vector" }` property becomes an ANN index.
|
|
3
|
+
*
|
|
4
|
+
* Without an index, pgvector answers `ORDER BY embedding <=> $1` by computing
|
|
5
|
+
* the distance to every row and sorting — exact, and linear. That is the right
|
|
6
|
+
* answer at ten thousand rows and the wrong one at a million, which is why the
|
|
7
|
+
* default here is to build an index rather than to leave the column bare.
|
|
8
|
+
*
|
|
9
|
+
* ## The operator class is not a detail
|
|
10
|
+
*
|
|
11
|
+
* An index is built for exactly one operator class, and the planner uses it
|
|
12
|
+
* only for the operator that class implements. `vector_cosine_ops` answers
|
|
13
|
+
* `<=>` and nothing else; a query asking for `<->` against a cosine index gets
|
|
14
|
+
* a sequential scan and no error. So the default indexed distance here is
|
|
15
|
+
* `cosine`, because `cosine` is what `vectorSearch` measures with when the
|
|
16
|
+
* caller does not say — see `DrizzleConditionBuilder.buildVectorSearch`. The
|
|
17
|
+
* two defaults have to agree, and this comment is the reason they do.
|
|
18
|
+
*
|
|
19
|
+
* ## Why 2000 dimensions is a ceiling and not an error
|
|
20
|
+
*
|
|
21
|
+
* pgvector cannot index a `vector` wider than 2000 dimensions with either
|
|
22
|
+
* method. A 3072-dimension embedding (`text-embedding-3-large`) is therefore
|
|
23
|
+
* storable and searchable but not indexable. Refusing the boot over that would
|
|
24
|
+
* make a working configuration unbootable; silently indexing it is impossible.
|
|
25
|
+
* So the column is created, the index is skipped, and the reason is reported.
|
|
26
|
+
*
|
|
27
|
+
* Like `search-column.ts`, this module exists so that the DDL generator and the
|
|
28
|
+
* boot-time ensure render the *same* specification rather than describing the
|
|
29
|
+
* same index twice, differently. `contracts/derived-names.txt` records the
|
|
30
|
+
* names both produce, and CI fails if they diverge.
|
|
31
|
+
*/
|
|
32
|
+
import type { CollectionConfig, Property, VectorDistance } from "@rebasepro/types";
|
|
33
|
+
/**
|
|
34
|
+
* The widest `vector` pgvector will build an HNSW or IVFFlat index over.
|
|
35
|
+
* Storage and exact search are unaffected by this limit.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MAX_INDEXABLE_VECTOR_DIMENSIONS = 2000;
|
|
38
|
+
/** The distance indexed when a property does not name one. */
|
|
39
|
+
export declare const DEFAULT_VECTOR_DISTANCE: VectorDistance;
|
|
40
|
+
/** The index method used when a property does not name one. */
|
|
41
|
+
export declare const DEFAULT_VECTOR_INDEX_METHOD: "hnsw";
|
|
42
|
+
export interface VectorIndexSpec {
|
|
43
|
+
schema: string;
|
|
44
|
+
table: string;
|
|
45
|
+
column: string;
|
|
46
|
+
indexName: string;
|
|
47
|
+
method: "hnsw" | "ivfflat";
|
|
48
|
+
distance: VectorDistance;
|
|
49
|
+
operatorClass: string;
|
|
50
|
+
/** Rendered into `WITH (...)`; empty when every parameter is defaulted. */
|
|
51
|
+
parameters: Array<[string, number]>;
|
|
52
|
+
}
|
|
53
|
+
/** A vector column that will not be indexed, and why. */
|
|
54
|
+
export interface SkippedVectorIndex {
|
|
55
|
+
schema: string;
|
|
56
|
+
table: string;
|
|
57
|
+
column: string;
|
|
58
|
+
dimensions: number;
|
|
59
|
+
reason: string;
|
|
60
|
+
}
|
|
61
|
+
export interface VectorIndexPlan {
|
|
62
|
+
specs: VectorIndexSpec[];
|
|
63
|
+
skipped: SkippedVectorIndex[];
|
|
64
|
+
}
|
|
65
|
+
export declare class VectorIndexConfigError extends Error {
|
|
66
|
+
constructor(message: string);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Every ANN index a collection's vector properties call for.
|
|
70
|
+
*
|
|
71
|
+
* `resolveColumn` is passed in rather than imported so that this module stays
|
|
72
|
+
* free of the DDL generator, which imports *it*. Both callers hand it the same
|
|
73
|
+
* `resolveColumnName`, and a contract test asserts the names agree.
|
|
74
|
+
*/
|
|
75
|
+
export declare const buildVectorIndexPlan: (collection: CollectionConfig, resolveColumn: (propName: string, prop?: Property | null) => string) => VectorIndexPlan;
|
|
76
|
+
/**
|
|
77
|
+
* The `CREATE INDEX` for one spec.
|
|
78
|
+
*
|
|
79
|
+
* `CONCURRENTLY` is deliberately absent, for the same reason it is absent from
|
|
80
|
+
* `searchIndexStatements`: this form is replayed as part of a migration, where
|
|
81
|
+
* a concurrent build is not allowed. The boot-time ensure rewrites it — see
|
|
82
|
+
* `ensureCollectionTables`.
|
|
83
|
+
*/
|
|
84
|
+
export declare const vectorIndexStatement: (spec: VectorIndexSpec) => string;
|
|
85
|
+
/** Every statement for a plan, in a stable order. */
|
|
86
|
+
export declare const vectorIndexStatements: (plan: VectorIndexPlan) => string[];
|
|
87
|
+
/** The index names a plan creates — what the derived-names contract records. */
|
|
88
|
+
export declare const vectorIndexNames: (plan: VectorIndexPlan) => string[];
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* same `rebase` schema convention used by entity_history, auth, etc.
|
|
8
8
|
*/
|
|
9
9
|
import { BranchInfo } from "@rebasepro/types";
|
|
10
|
-
import { DrizzleClient } from "../interfaces";
|
|
11
|
-
import { DatabasePoolManager } from "../databasePoolManager";
|
|
10
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
11
|
+
import { DatabasePoolManager } from "../databasePoolManager.js";
|
|
12
12
|
export declare class BranchService {
|
|
13
13
|
private db;
|
|
14
14
|
private poolManager;
|
|
@@ -2,10 +2,10 @@ import { SQL } from "drizzle-orm";
|
|
|
2
2
|
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
3
|
import { FilterValues, OrderByTuple, LogicalCondition } from "@rebasepro/types";
|
|
4
4
|
import type { VectorSearchParams } from "@rebasepro/types";
|
|
5
|
-
import { RelationService } from "./RelationService";
|
|
6
|
-
import { DrizzleClient } from "../interfaces";
|
|
7
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
8
|
-
import { type NestedPathHop } from "./nested-path";
|
|
5
|
+
import { RelationService } from "./RelationService.js";
|
|
6
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
7
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
8
|
+
import { type NestedPathHop } from "./nested-path.js";
|
|
9
9
|
/**
|
|
10
10
|
* Service for handling all row read operations.
|
|
11
11
|
* Handles fetching, searching, counting, and filtering rows.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RelationService } from "./RelationService";
|
|
2
|
-
import { RelationWriteService } from "./RelationWriteService";
|
|
3
|
-
import { FetchService } from "./FetchService";
|
|
4
|
-
import { DrizzleClient } from "../interfaces";
|
|
5
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
1
|
+
import { RelationService } from "./RelationService.js";
|
|
2
|
+
import { RelationWriteService } from "./RelationWriteService.js";
|
|
3
|
+
import { FetchService } from "./FetchService.js";
|
|
4
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
5
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
6
6
|
/**
|
|
7
7
|
* Service for handling all row write operations.
|
|
8
8
|
* Handles saving, deleting, and updating rows.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DrizzleClient } from "../interfaces";
|
|
1
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
2
2
|
import { CollectionConfig, FilterValues, OrderByTuple, ResolvedRelation, ResolvedHasMany, ResolvedHasOne } from "@rebasepro/types";
|
|
3
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
4
|
-
import type { NestedPathHop } from "./nested-path";
|
|
3
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
4
|
+
import type { NestedPathHop } from "./nested-path.js";
|
|
5
5
|
/**
|
|
6
6
|
* Service for handling all relation-related operations.
|
|
7
7
|
* Handles fetching, updating, and managing row relations.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CollectionConfig, ResolvedManyToMany, ResolvedRelation, ResolvedVia } from "@rebasepro/types";
|
|
2
|
-
import { DrizzleClient } from "../interfaces";
|
|
3
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
4
|
-
import type { NestedPathHop } from "./nested-path";
|
|
2
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
3
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
4
|
+
import type { NestedPathHop } from "./nested-path.js";
|
|
5
5
|
/**
|
|
6
6
|
* Writing relations: junction membership, foreign-key stamping, and the links a
|
|
7
7
|
* nested path creates or removes.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CollectionConfig } from "@rebasepro/types";
|
|
2
|
-
import { PostgresCollectionRegistry } from "../../collections/PostgresCollectionRegistry";
|
|
2
|
+
import { PostgresCollectionRegistry } from "../../collections/PostgresCollectionRegistry.js";
|
|
3
3
|
/**
|
|
4
4
|
* One end of a many-to-many, as seen from the junction table.
|
|
5
5
|
*
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* than correctness. That is what makes coalescing safe.
|
|
27
27
|
*/
|
|
28
28
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
29
|
-
import { ChannelBus, ChannelBusFrame, ChannelBusHandler } from "./ChannelBus";
|
|
29
|
+
import { ChannelBus, ChannelBusFrame, ChannelBusHandler } from "./ChannelBus.js";
|
|
30
30
|
/** NOTIFY channel carrying channel-bus frames. */
|
|
31
31
|
export declare const CHANNEL_BUS_NOTIFY_CHANNEL = "rebase_channel_bus";
|
|
32
32
|
/**
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
18
18
|
import { type ChannelBus, type ChannelBusSetting } from "@rebasepro/types";
|
|
19
|
-
export * from "./ChannelBus";
|
|
20
|
-
export { PostgresChannelBus, CHANNEL_BUS_NOTIFY_CHANNEL, PG_NOTIFY_MAX_PAYLOAD_BYTES, DEFAULT_BATCH_WINDOW_MS, parseChannelBusFrame, parseChannelBusPayload } from "./PostgresChannelBus";
|
|
19
|
+
export * from "./ChannelBus.js";
|
|
20
|
+
export { PostgresChannelBus, CHANNEL_BUS_NOTIFY_CHANNEL, PG_NOTIFY_MAX_PAYLOAD_BYTES, DEFAULT_BATCH_WINDOW_MS, parseChannelBusFrame, parseChannelBusPayload } from "./PostgresChannelBus.js";
|
|
21
21
|
export interface ChannelBusDeps {
|
|
22
22
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
23
23
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PgTable, AnyPgColumn } from "drizzle-orm/pg-core";
|
|
2
2
|
import { CollectionConfig, ResolvedHasMany, ResolvedHasOne } from "@rebasepro/types";
|
|
3
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
3
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
4
4
|
import { ApiError } from "@rebasepro/server";
|
|
5
5
|
export { buildCompositeId, parseIdValues, isAddressableId, COMPOSITE_ID_SEPARATOR } from "@rebasepro/common";
|
|
6
6
|
export type { PrimaryKeyInfo } from "@rebasepro/common";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FilterValues, LogicalCondition, OrderByTuple } from "@rebasepro/types";
|
|
2
2
|
import type { VectorSearchParams } from "@rebasepro/types";
|
|
3
|
-
import { FetchService } from "./FetchService";
|
|
4
|
-
import { PersistService } from "./PersistService";
|
|
5
|
-
import { RelationService } from "./RelationService";
|
|
6
|
-
import { DataRepository, DrizzleClient } from "../interfaces";
|
|
7
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
8
|
-
export { sanitizeAndConvertDates, serializeDataToServer, parseDataFromServer } from "../data-transformer";
|
|
9
|
-
export { FetchService } from "./FetchService";
|
|
10
|
-
export { PersistService } from "./PersistService";
|
|
11
|
-
export { RelationService } from "./RelationService";
|
|
12
|
-
export * from "../interfaces";
|
|
3
|
+
import { FetchService } from "./FetchService.js";
|
|
4
|
+
import { PersistService } from "./PersistService.js";
|
|
5
|
+
import { RelationService } from "./RelationService.js";
|
|
6
|
+
import { DataRepository, DrizzleClient } from "../interfaces.js";
|
|
7
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
8
|
+
export { sanitizeAndConvertDates, serializeDataToServer, parseDataFromServer } from "../data-transformer.js";
|
|
9
|
+
export { FetchService } from "./FetchService.js";
|
|
10
|
+
export { PersistService } from "./PersistService.js";
|
|
11
|
+
export { RelationService } from "./RelationService.js";
|
|
12
|
+
export * from "../interfaces.js";
|
|
13
13
|
/**
|
|
14
14
|
* DataService - Facade for row operations.
|
|
15
15
|
*
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FetchService } from "./FetchService";
|
|
2
|
-
export { PersistService } from "./PersistService";
|
|
3
|
-
export { RelationService } from "./RelationService";
|
|
4
|
-
export { getCollectionByPath, getTableForCollection, getPrimaryKeys, deriveRowAddress, parseIdValues, buildCompositeId } from "./collection-helpers";
|
|
1
|
+
export { FetchService } from "./FetchService.js";
|
|
2
|
+
export { PersistService } from "./PersistService.js";
|
|
3
|
+
export { RelationService } from "./RelationService.js";
|
|
4
|
+
export { getCollectionByPath, getTableForCollection, getPrimaryKeys, deriveRowAddress, parseIdValues, buildCompositeId } from "./collection-helpers.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyPgColumn, PgTable } from "drizzle-orm/pg-core";
|
|
2
2
|
import type { ResolvedVia } from "@rebasepro/types";
|
|
3
|
-
import { DrizzleClient } from "../interfaces";
|
|
4
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
3
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
4
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
5
5
|
/**
|
|
6
6
|
* Writing a many-to-many means writing rows in a junction table, and doing that
|
|
7
7
|
* needs three things: the table, the column naming the row being written from,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CollectionConfig, ResolvedRelation } from "@rebasepro/types";
|
|
2
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
2
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
3
3
|
/**
|
|
4
4
|
* The last hop of a nested collection path, e.g. `authors/1/posts`.
|
|
5
5
|
*
|
|
@@ -2,9 +2,9 @@ import { WebSocket } from "ws";
|
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { DataDriver, WebSocketMessage, LogicalCondition, OrderByTuple } from "@rebasepro/types";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
-
import { RealtimeProvider, CollectionSubscriptionConfig, SingleSubscriptionConfig } from "../interfaces";
|
|
6
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
7
|
-
import { ChannelBus } from "./channel-bus";
|
|
5
|
+
import { RealtimeProvider, CollectionSubscriptionConfig, SingleSubscriptionConfig } from "../interfaces.js";
|
|
6
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
7
|
+
import { ChannelBus } from "./channel-bus/index.js";
|
|
8
8
|
import type { ChannelRetentionRule } from "@rebasepro/types";
|
|
9
9
|
/**
|
|
10
10
|
* Auth context stored per-subscription so real-time refetches respect RLS.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CollectionConfig, ResolvedRelation } from "@rebasepro/types";
|
|
2
|
-
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry";
|
|
2
|
+
import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry.js";
|
|
3
3
|
/**
|
|
4
4
|
* Turning a drizzle result into a row we serve.
|
|
5
5
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SQL } from "drizzle-orm";
|
|
2
2
|
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
3
|
import { ApiError } from "@rebasepro/server";
|
|
4
|
-
import { DrizzleClient } from "../interfaces";
|
|
4
|
+
import { DrizzleClient } from "../interfaces.js";
|
|
5
5
|
/**
|
|
6
6
|
* Explain a write that matched no rows.
|
|
7
7
|
*
|
|
@@ -410,6 +410,98 @@ function usesLegacyRlsFunctions(sql) {
|
|
|
410
410
|
return /\bauth\.(uid|jwt|roles)\s*\(\s*\)/i.test(sql);
|
|
411
411
|
}
|
|
412
412
|
//#endregion
|
|
413
|
+
//#region ../types/src/types/resources.ts
|
|
414
|
+
var GLOBAL_KEY = Symbol.for("@rebasepro/types.resourceRegistry");
|
|
415
|
+
function registry() {
|
|
416
|
+
const g = globalThis;
|
|
417
|
+
let existing = g[GLOBAL_KEY];
|
|
418
|
+
if (!existing) {
|
|
419
|
+
existing = {
|
|
420
|
+
kinds: /* @__PURE__ */ new Map(),
|
|
421
|
+
declarations: /* @__PURE__ */ new Map()
|
|
422
|
+
};
|
|
423
|
+
g[GLOBAL_KEY] = existing;
|
|
424
|
+
}
|
|
425
|
+
return existing;
|
|
426
|
+
}
|
|
427
|
+
/** Register a resource kind. Idempotent for an identical spec; throws on a conflicting one. */
|
|
428
|
+
function registerResourceKind(spec) {
|
|
429
|
+
const existing = registry().kinds.get(spec.kind);
|
|
430
|
+
if (existing && JSON.stringify(existing) !== JSON.stringify(spec)) throw new Error(`Resource kind "${spec.kind}" is already registered with a different definition. Two packages cannot define the same kind.`);
|
|
431
|
+
registry().kinds.set(spec.kind, spec);
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region ../types/src/types/resource_kinds.ts
|
|
435
|
+
/**
|
|
436
|
+
* The kinds Rebase ships, and the constructors a project declares them with.
|
|
437
|
+
*
|
|
438
|
+
* Each kind is registered rather than hardcoded, so a fourth one arrives
|
|
439
|
+
* without editing a manifest schema, a validator and a switch statement. That
|
|
440
|
+
* cost is precisely why databases and buckets ended up declared in different
|
|
441
|
+
* files with different rules — the cheapest thing to do was always to bolt the
|
|
442
|
+
* new kind onto whichever home was nearest.
|
|
443
|
+
*
|
|
444
|
+
* A kind owns its engine list. `custom:<id>` is always accepted, so a build
|
|
445
|
+
* that ships an engine this package has never heard of says so at the call site
|
|
446
|
+
* instead of looking like a typo of one that exists.
|
|
447
|
+
*/
|
|
448
|
+
registerResourceKind({
|
|
449
|
+
kind: "database",
|
|
450
|
+
engines: [
|
|
451
|
+
"postgres",
|
|
452
|
+
"mongodb",
|
|
453
|
+
"firestore",
|
|
454
|
+
"sqlite"
|
|
455
|
+
],
|
|
456
|
+
defaultEngine: "postgres",
|
|
457
|
+
envBases: [
|
|
458
|
+
"DATABASE_URL",
|
|
459
|
+
"REBASE_DRIVER",
|
|
460
|
+
"REBASE_DB_POOL_MAX"
|
|
461
|
+
],
|
|
462
|
+
optionKeys: ["databaseId", "migrations"],
|
|
463
|
+
implicitDefault: true
|
|
464
|
+
});
|
|
465
|
+
registerResourceKind({
|
|
466
|
+
kind: "bucket",
|
|
467
|
+
engines: [
|
|
468
|
+
"local",
|
|
469
|
+
"s3",
|
|
470
|
+
"gcs",
|
|
471
|
+
"azure",
|
|
472
|
+
"firebase"
|
|
473
|
+
],
|
|
474
|
+
defaultEngine: "local",
|
|
475
|
+
envBases: [
|
|
476
|
+
"S3_BUCKET",
|
|
477
|
+
"GCS_BUCKET",
|
|
478
|
+
"STORAGE_BUCKET",
|
|
479
|
+
"STORAGE_PUBLIC_URL"
|
|
480
|
+
],
|
|
481
|
+
envBasesByEngine: {
|
|
482
|
+
local: ["STORAGE_BUCKET"],
|
|
483
|
+
s3: [
|
|
484
|
+
"S3_BUCKET",
|
|
485
|
+
"STORAGE_ENDPOINT",
|
|
486
|
+
"STORAGE_REGION",
|
|
487
|
+
"STORAGE_PUBLIC_URL"
|
|
488
|
+
],
|
|
489
|
+
gcs: ["GCS_BUCKET", "STORAGE_PUBLIC_URL"],
|
|
490
|
+
azure: ["STORAGE_BUCKET", "STORAGE_PUBLIC_URL"],
|
|
491
|
+
firebase: ["STORAGE_BUCKET", "STORAGE_PUBLIC_URL"]
|
|
492
|
+
},
|
|
493
|
+
optionKeys: ["publicRead", "prefix"],
|
|
494
|
+
implicitDefault: false
|
|
495
|
+
});
|
|
496
|
+
registerResourceKind({
|
|
497
|
+
kind: "topic",
|
|
498
|
+
engines: ["jobs"],
|
|
499
|
+
defaultEngine: "jobs",
|
|
500
|
+
envBases: ["REBASE_TOPIC_URL"],
|
|
501
|
+
optionKeys: ["delivery", "maxAttempts"],
|
|
502
|
+
implicitDefault: false
|
|
503
|
+
});
|
|
504
|
+
//#endregion
|
|
413
505
|
export { isRelationAggregateSort as _, rewriteLegacyRlsFunctions as a, toCanonicalOp as b, isPostgresCollectionConfig as c, getDataSourceCapabilities as d, ALL_WHERE_FILTER_OPS as f, encodeRelationAggregateSort as g, REST_TO_CANONICAL as h, RLS_UID_SQL as i, isRelationalCollectionConfig as l, NULL_OPS as m, REBASE_SCHEMA as n, usesLegacyRlsFunctions as o, CANONICAL_TO_REST as p, RLS_ROLES_SQL as r, getDeclaredSubcollections as s, LEGACY_RLS_SCHEMA as t, DEFAULT_DATA_SOURCE_KEY as u, parseRelationAggregateSort as v, sortKeyToString as y };
|
|
414
506
|
|
|
415
|
-
//# sourceMappingURL=src-
|
|
507
|
+
//# sourceMappingURL=src-DolrXONo.js.map
|