@rebasepro/server-postgres 0.9.1-canary.7ba0e49 → 0.9.1-canary.97e305f
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 +22 -3
- package/dist/index.es.js.map +1 -1
- package/package.json +6 -6
- package/src/services/row-pipeline.ts +27 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/server-postgres",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.1-canary.
|
|
4
|
+
"version": "0.9.1-canary.97e305f",
|
|
5
5
|
"description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
"execa": "^9.6.1",
|
|
72
72
|
"pg": "^8.21.0",
|
|
73
73
|
"ws": "^8.21.0",
|
|
74
|
-
"@rebasepro/codegen": "0.9.1-canary.
|
|
75
|
-
"@rebasepro/common": "0.9.1-canary.
|
|
76
|
-
"@rebasepro/server": "0.9.1-canary.
|
|
77
|
-
"@rebasepro/types": "0.9.1-canary.
|
|
78
|
-
"@rebasepro/utils": "0.9.1-canary.
|
|
74
|
+
"@rebasepro/codegen": "0.9.1-canary.97e305f",
|
|
75
|
+
"@rebasepro/common": "0.9.1-canary.97e305f",
|
|
76
|
+
"@rebasepro/server": "0.9.1-canary.97e305f",
|
|
77
|
+
"@rebasepro/types": "0.9.1-canary.97e305f",
|
|
78
|
+
"@rebasepro/utils": "0.9.1-canary.97e305f"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@hono/node-server": "^2.0.9",
|
|
@@ -91,6 +91,30 @@ function coerceDeclaredNumbers(
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/** Render one target row in the requested style. */
|
|
94
|
+
/**
|
|
95
|
+
* Drop every column the collection marked `excludeFromApi`.
|
|
96
|
+
*
|
|
97
|
+
* Password hashes and verification tokens have to be readable server-side but
|
|
98
|
+
* must never reach a client — and "never" has to mean every exit from this
|
|
99
|
+
* pipeline, including relation targets, or a secret leaks through whichever
|
|
100
|
+
* path was overlooked. Keyed by both the property name and its column name,
|
|
101
|
+
* since a row can arrive keyed either way depending on the caller.
|
|
102
|
+
*/
|
|
103
|
+
function stripExcluded(
|
|
104
|
+
row: Record<string, unknown>,
|
|
105
|
+
collection: CollectionConfig
|
|
106
|
+
): Record<string, unknown> {
|
|
107
|
+
const properties = collection.properties as Record<string, Property> | undefined;
|
|
108
|
+
if (!properties) return row;
|
|
109
|
+
|
|
110
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
111
|
+
if (!property?.excludeFromApi) continue;
|
|
112
|
+
delete row[key];
|
|
113
|
+
if (property.columnName) delete row[property.columnName];
|
|
114
|
+
}
|
|
115
|
+
return row;
|
|
116
|
+
}
|
|
117
|
+
|
|
94
118
|
function renderTarget(
|
|
95
119
|
targetRow: Record<string, unknown>,
|
|
96
120
|
targetCollection: CollectionConfig,
|
|
@@ -100,7 +124,7 @@ function renderTarget(
|
|
|
100
124
|
if (style === "inline") {
|
|
101
125
|
// The target's columns, and only those: its address is the consumer's
|
|
102
126
|
// to derive, and merging one in overwrites a real `id` column.
|
|
103
|
-
return coerceDeclaredNumbers({ ...targetRow }, targetCollection);
|
|
127
|
+
return stripExcluded(coerceDeclaredNumbers({ ...targetRow }, targetCollection), targetCollection);
|
|
104
128
|
}
|
|
105
129
|
|
|
106
130
|
const address = relationTargetAddress(targetRow, targetCollection, registry);
|
|
@@ -168,7 +192,7 @@ export function toCmsRow(
|
|
|
168
192
|
}
|
|
169
193
|
}
|
|
170
194
|
|
|
171
|
-
return normalized;
|
|
195
|
+
return stripExcluded(normalized, collection);
|
|
172
196
|
}
|
|
173
197
|
|
|
174
198
|
/**
|
|
@@ -211,5 +235,5 @@ export function toRestRow(
|
|
|
211
235
|
}
|
|
212
236
|
}
|
|
213
237
|
|
|
214
|
-
return flat;
|
|
238
|
+
return stripExcluded(flat, collection);
|
|
215
239
|
}
|