@rebasepro/server-postgresql 0.0.1-canary.09e5ec5
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/LICENSE +6 -0
- package/README.md +106 -0
- package/build-errors.txt +37 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/index.es.js +11298 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +11306 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +100 -0
- package/dist/server-postgresql/src/PostgresBootstrapper.d.ts +40 -0
- package/dist/server-postgresql/src/auth/ensure-tables.d.ts +6 -0
- package/dist/server-postgresql/src/auth/services.d.ts +192 -0
- package/dist/server-postgresql/src/cli.d.ts +1 -0
- package/dist/server-postgresql/src/collections/PostgresCollectionRegistry.d.ts +43 -0
- package/dist/server-postgresql/src/connection.d.ts +40 -0
- package/dist/server-postgresql/src/data-transformer.d.ts +58 -0
- package/dist/server-postgresql/src/databasePoolManager.d.ts +20 -0
- package/dist/server-postgresql/src/history/HistoryService.d.ts +71 -0
- package/dist/server-postgresql/src/history/ensure-history-table.d.ts +7 -0
- package/dist/server-postgresql/src/index.d.ts +13 -0
- package/dist/server-postgresql/src/interfaces.d.ts +18 -0
- package/dist/server-postgresql/src/schema/auth-schema.d.ts +868 -0
- package/dist/server-postgresql/src/schema/doctor-cli.d.ts +2 -0
- package/dist/server-postgresql/src/schema/doctor.d.ts +43 -0
- package/dist/server-postgresql/src/schema/generate-drizzle-schema-logic.d.ts +2 -0
- package/dist/server-postgresql/src/schema/generate-drizzle-schema.d.ts +1 -0
- package/dist/server-postgresql/src/schema/introspect-db-logic.d.ts +82 -0
- package/dist/server-postgresql/src/schema/introspect-db.d.ts +1 -0
- package/dist/server-postgresql/src/schema/test-schema.d.ts +24 -0
- package/dist/server-postgresql/src/services/BranchService.d.ts +47 -0
- package/dist/server-postgresql/src/services/EntityFetchService.d.ts +209 -0
- package/dist/server-postgresql/src/services/EntityPersistService.d.ts +41 -0
- package/dist/server-postgresql/src/services/RelationService.d.ts +98 -0
- package/dist/server-postgresql/src/services/entity-helpers.d.ts +38 -0
- package/dist/server-postgresql/src/services/entityService.d.ts +104 -0
- package/dist/server-postgresql/src/services/index.d.ts +4 -0
- package/dist/server-postgresql/src/services/realtimeService.d.ts +188 -0
- package/dist/server-postgresql/src/utils/drizzle-conditions.d.ts +116 -0
- package/dist/server-postgresql/src/websocket.d.ts +5 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +23 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/drizzle-test/0000_woozy_junta.sql +6 -0
- package/drizzle-test/0001_youthful_arachne.sql +1 -0
- package/drizzle-test/0002_lively_dragon_lord.sql +2 -0
- package/drizzle-test/0003_mean_king_cobra.sql +2 -0
- package/drizzle-test/meta/0000_snapshot.json +47 -0
- package/drizzle-test/meta/0001_snapshot.json +48 -0
- package/drizzle-test/meta/0002_snapshot.json +38 -0
- package/drizzle-test/meta/0003_snapshot.json +48 -0
- package/drizzle-test/meta/_journal.json +34 -0
- package/drizzle-test-out/0000_tan_trauma.sql +6 -0
- package/drizzle-test-out/0001_rapid_drax.sql +1 -0
- package/drizzle-test-out/meta/0000_snapshot.json +44 -0
- package/drizzle-test-out/meta/0001_snapshot.json +54 -0
- package/drizzle-test-out/meta/_journal.json +20 -0
- package/drizzle.test.config.ts +10 -0
- package/jest-all.log +3128 -0
- package/jest.log +49 -0
- package/package.json +92 -0
- package/scratch.ts +41 -0
- package/src/PostgresBackendDriver.ts +1008 -0
- package/src/PostgresBootstrapper.ts +231 -0
- package/src/auth/ensure-tables.ts +381 -0
- package/src/auth/services.ts +799 -0
- package/src/cli.ts +648 -0
- package/src/collections/PostgresCollectionRegistry.ts +96 -0
- package/src/connection.ts +84 -0
- package/src/data-transformer.ts +608 -0
- package/src/databasePoolManager.ts +85 -0
- package/src/history/HistoryService.ts +248 -0
- package/src/history/ensure-history-table.ts +45 -0
- package/src/index.ts +13 -0
- package/src/interfaces.ts +60 -0
- package/src/schema/auth-schema.ts +169 -0
- package/src/schema/doctor-cli.ts +47 -0
- package/src/schema/doctor.ts +595 -0
- package/src/schema/generate-drizzle-schema-logic.ts +765 -0
- package/src/schema/generate-drizzle-schema.ts +151 -0
- package/src/schema/introspect-db-logic.ts +542 -0
- package/src/schema/introspect-db.ts +211 -0
- package/src/schema/test-schema.ts +11 -0
- package/src/services/BranchService.ts +237 -0
- package/src/services/EntityFetchService.ts +1576 -0
- package/src/services/EntityPersistService.ts +349 -0
- package/src/services/RelationService.ts +1274 -0
- package/src/services/entity-helpers.ts +147 -0
- package/src/services/entityService.ts +211 -0
- package/src/services/index.ts +13 -0
- package/src/services/realtimeService.ts +1034 -0
- package/src/utils/drizzle-conditions.ts +1000 -0
- package/src/websocket.ts +518 -0
- package/test/auth-services.test.ts +661 -0
- package/test/batch-many-to-many-regression.test.ts +573 -0
- package/test/branchService.test.ts +367 -0
- package/test/data-transformer-hardening.test.ts +417 -0
- package/test/data-transformer.test.ts +175 -0
- package/test/doctor.test.ts +182 -0
- package/test/drizzle-conditions.test.ts +895 -0
- package/test/entityService.errors.test.ts +367 -0
- package/test/entityService.relations.test.ts +1008 -0
- package/test/entityService.subcollection-search.test.ts +566 -0
- package/test/entityService.test.ts +1035 -0
- package/test/generate-drizzle-schema.test.ts +988 -0
- package/test/historyService.test.ts +141 -0
- package/test/introspect-db-generation.test.ts +436 -0
- package/test/introspect-db-utils.test.ts +389 -0
- package/test/n-plus-one-regression.test.ts +314 -0
- package/test/postgresDataDriver.test.ts +648 -0
- package/test/realtimeService.test.ts +307 -0
- package/test/relation-pipeline-gaps.test.ts +637 -0
- package/test/relations.test.ts +1115 -0
- package/test/unmapped-tables-safety.test.ts +345 -0
- package/test-drizzle-bug.ts +18 -0
- package/test-drizzle-out/0000_cultured_freak.sql +7 -0
- package/test-drizzle-out/0001_tiresome_professor_monster.sql +1 -0
- package/test-drizzle-out/meta/0000_snapshot.json +55 -0
- package/test-drizzle-out/meta/0001_snapshot.json +63 -0
- package/test-drizzle-out/meta/_journal.json +20 -0
- package/test-drizzle-prompt.sh +2 -0
- package/test-policy-prompt.sh +3 -0
- package/test-programmatic.ts +30 -0
- package/test-programmatic2.ts +59 -0
- package/test-schema-no-policies.ts +12 -0
- package/test_drizzle_mock.js +3 -0
- package/test_find_changed.mjs +32 -0
- package/test_hash.js +14 -0
- package/test_output.txt +3145 -0
- package/tsconfig.json +49 -0
- package/tsconfig.prod.json +20 -0
- package/vite.config.ts +82 -0
package/jest.log
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
> @rebasepro/server-postgresql@0.0.1 test /Users/francesco/rebase/packages/server-postgresql
|
|
3
|
+
> jest --passWithNoTests test/entityService.subcollection-search.test.ts
|
|
4
|
+
|
|
5
|
+
console.warn
|
|
6
|
+
Unrecognized relation format for property 'posts' in collection 'tags'
|
|
7
|
+
|
|
8
|
+
186 | const relation = (sourceCollection.relations ?? []).find((rel: Relation) => rel.relationName === property.relationName)
|
|
9
|
+
187 | if (!relation) {
|
|
10
|
+
> 188 | console.warn(`Unrecognized relation format for property '${propertyKey}' in collection '${sourceCollection.slug}'`);
|
|
11
|
+
| ^
|
|
12
|
+
189 | return undefined;
|
|
13
|
+
190 | }
|
|
14
|
+
191 |
|
|
15
|
+
|
|
16
|
+
at resolvePropertyRelation (../common/src/util/relations.ts:188:17)
|
|
17
|
+
at ../common/src/util/relations.ts:154:30
|
|
18
|
+
at Array.forEach (<anonymous>)
|
|
19
|
+
at resolveCollectionRelations (../common/src/util/relations.ts:153:47)
|
|
20
|
+
at EntityFetchService.fetchCollectionFromPath (src/services/EntityFetchService.ts:775:65)
|
|
21
|
+
at EntityFetchService.fetchCollection (src/services/EntityFetchService.ts:722:25)
|
|
22
|
+
at EntityService.fetchCollection (src/services/entityService.ts:70:34)
|
|
23
|
+
at Object.<anonymous> (test/entityService.subcollection-search.test.ts:450:40)
|
|
24
|
+
|
|
25
|
+
PASS test/entityService.subcollection-search.test.ts
|
|
26
|
+
EntityService - Subcollection Search Tests
|
|
27
|
+
fetchCollection with subcollection search
|
|
28
|
+
✓ should handle search in one-to-many inverse relation subcollection (3 ms)
|
|
29
|
+
✓ should handle search in many-to-one owning relation subcollection (1 ms)
|
|
30
|
+
✓ should handle search in nested subcollection (posts/123/comments)
|
|
31
|
+
✓ should combine search conditions with existing filters (1 ms)
|
|
32
|
+
✓ should handle empty search results gracefully
|
|
33
|
+
✓ should handle search with ordering and pagination (1 ms)
|
|
34
|
+
searchEntities with subcollection paths
|
|
35
|
+
✓ should handle direct search on subcollection using searchEntities method (1 ms)
|
|
36
|
+
fetchRelatedEntities with search
|
|
37
|
+
✓ should pass search parameters correctly to fetchEntitiesUsingJoins
|
|
38
|
+
Edge cases and error handling
|
|
39
|
+
✓ should handle invalid subcollection paths gracefully (15 ms)
|
|
40
|
+
✓ should handle missing relations gracefully (20 ms)
|
|
41
|
+
✓ should handle search in collection with no searchable properties
|
|
42
|
+
Performance and optimization
|
|
43
|
+
✓ should use proper limit when searching (default 50 for search) (1 ms)
|
|
44
|
+
|
|
45
|
+
Test Suites: 1 passed, 1 total
|
|
46
|
+
Tests: 12 passed, 12 total
|
|
47
|
+
Snapshots: 0 total
|
|
48
|
+
Time: 0.276 s, estimated 1 s
|
|
49
|
+
Ran all test suites matching /test\/entityService.subcollection-search.test.ts/i.
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rebasepro/server-postgresql",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-canary.09e5ec5",
|
|
5
|
+
"description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
|
|
6
|
+
"funding": {
|
|
7
|
+
"url": "https://github.com/sponsors/rebaseco"
|
|
8
|
+
},
|
|
9
|
+
"author": "Rebase",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/rebasepro/rebase.git",
|
|
14
|
+
"directory": "packages/server-postgresql"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.umd.js",
|
|
17
|
+
"module": "./dist/index.es.js",
|
|
18
|
+
"types": "./dist/server-postgresql/src/index.d.ts",
|
|
19
|
+
"source": "src/index.ts",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"cms",
|
|
25
|
+
"admin",
|
|
26
|
+
"postgresql",
|
|
27
|
+
"database",
|
|
28
|
+
"drizzle",
|
|
29
|
+
"backend",
|
|
30
|
+
"rebase"
|
|
31
|
+
],
|
|
32
|
+
"jest": {
|
|
33
|
+
"transform": {
|
|
34
|
+
"^.+\\.tsx?$": "ts-jest"
|
|
35
|
+
},
|
|
36
|
+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
|
|
37
|
+
"moduleFileExtensions": [
|
|
38
|
+
"ts",
|
|
39
|
+
"tsx",
|
|
40
|
+
"js",
|
|
41
|
+
"jsx",
|
|
42
|
+
"json",
|
|
43
|
+
"node"
|
|
44
|
+
],
|
|
45
|
+
"moduleNameMapper": {
|
|
46
|
+
"^@rebasepro/common$": "<rootDir>/../common/src/index.ts",
|
|
47
|
+
"^@rebasepro/types$": "<rootDir>/../types/src/index.ts",
|
|
48
|
+
"^@rebasepro/utils$": "<rootDir>/../utils/src/index.ts"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./dist/server-postgresql/src/index.d.ts",
|
|
54
|
+
"development": "./src/index.ts",
|
|
55
|
+
"import": "./dist/index.es.js",
|
|
56
|
+
"require": "./dist/index.umd.js"
|
|
57
|
+
},
|
|
58
|
+
"./package.json": "./package.json"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"arg": "^5.0.2",
|
|
62
|
+
"chalk": "^4.1.2",
|
|
63
|
+
"drizzle-orm": "^0.44.4",
|
|
64
|
+
"execa": "^4.1.0",
|
|
65
|
+
"pg": "^8.11.3",
|
|
66
|
+
"@rebasepro/server-core": "0.0.1-canary.09e5ec5",
|
|
67
|
+
"@rebasepro/types": "0.0.1-canary.09e5ec5",
|
|
68
|
+
"@rebasepro/common": "0.0.1-canary.09e5ec5",
|
|
69
|
+
"@rebasepro/utils": "0.0.1-canary.09e5ec5"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/node": "^20.10.5",
|
|
74
|
+
"@types/pg": "^8.6.5",
|
|
75
|
+
"drizzle-kit": "^0.31.4",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"ts-jest": "^29.4.5",
|
|
78
|
+
"typescript": "^5.0.0",
|
|
79
|
+
"vite": "^5.0.0"
|
|
80
|
+
},
|
|
81
|
+
"gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"watch": "vite build --watch",
|
|
87
|
+
"build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
|
|
88
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
|
89
|
+
"test": "jest --passWithNoTests",
|
|
90
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f"
|
|
91
|
+
}
|
|
92
|
+
}
|
package/scratch.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { pgTable, integer, varchar } from "drizzle-orm/pg-core";
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import { drizzle } from "drizzle-orm/node-postgres";
|
|
4
|
+
import { Client } from "pg";
|
|
5
|
+
import { config } from "dotenv";
|
|
6
|
+
config({ path: "../../.env" });
|
|
7
|
+
|
|
8
|
+
const authors = pgTable("authors", {
|
|
9
|
+
id: integer("id").primaryKey(),
|
|
10
|
+
name: varchar("name")
|
|
11
|
+
});
|
|
12
|
+
const posts = pgTable("posts", {
|
|
13
|
+
id: integer("id").primaryKey(),
|
|
14
|
+
author_id: integer("author_id")
|
|
15
|
+
});
|
|
16
|
+
const profiles = pgTable("profiles", {
|
|
17
|
+
id: integer("id").primaryKey(),
|
|
18
|
+
author_id: integer("author_id")
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
const client = new Client({
|
|
23
|
+
connectionString: process.env.DATABASE_URL || "postgres://postgres:postgres@localhost:5432/postgres"
|
|
24
|
+
});
|
|
25
|
+
await client.connect();
|
|
26
|
+
const db = drizzle(client);
|
|
27
|
+
|
|
28
|
+
let query = db.select().from(posts);
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
query = query.innerJoin(authors, eq(posts.author_id, authors.id));
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
query = query.innerJoin(profiles, eq(authors.id, profiles.author_id));
|
|
33
|
+
|
|
34
|
+
const results = await query;
|
|
35
|
+
console.log("Drizzle Inner Join Results:");
|
|
36
|
+
console.log(JSON.stringify(results, null, 2));
|
|
37
|
+
|
|
38
|
+
await client.end();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main().catch(console.error);
|