@rebasepro/types 0.13.1-canary.gf57a27e → 0.14.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/call_context.d.ts +17 -8
- package/dist/controllers/client.d.ts +31 -15
- package/dist/controllers/data.d.ts +84 -9
- package/dist/controllers/data_driver.d.ts +58 -8
- package/dist/index.es.js +106 -8
- package/dist/index.es.js.map +1 -1
- package/dist/types/admin_block.d.ts +37 -0
- package/dist/types/auth_adapter.d.ts +7 -0
- package/dist/types/collections.d.ts +10 -5
- package/dist/types/properties.d.ts +9 -2
- package/package.json +1 -1
- package/src/call_context.ts +17 -8
- package/src/controllers/client.ts +31 -15
- package/src/controllers/data.ts +95 -9
- package/src/controllers/data_driver.ts +95 -11
- package/src/types/admin_block.ts +83 -0
- package/src/types/auth_adapter.ts +7 -0
- package/src/types/collections.ts +10 -5
- package/src/types/filter-operators.ts +17 -1
- package/src/types/properties.ts +9 -2
package/src/types/collections.ts
CHANGED
|
@@ -211,11 +211,16 @@ export interface BaseCollectionConfig<M extends Record<string, unknown> = Record
|
|
|
211
211
|
* Whether a write naming a field this collection does not declare is
|
|
212
212
|
* rejected with a 400. Defaults to `true`.
|
|
213
213
|
*
|
|
214
|
-
* Set to `false`
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
214
|
+
* Set to `false` where a column really does exist that the config never
|
|
215
|
+
* declared — populated by a trigger, or introspected rather than declared —
|
|
216
|
+
* and callers need to write it. The column still has to exist: the driver
|
|
217
|
+
* checks the key against the table's own columns whatever this is set to,
|
|
218
|
+
* because a key with no column behind it is not passed to the database and
|
|
219
|
+
* refused, it is dropped from the statement and answered 201.
|
|
220
|
+
*
|
|
221
|
+
* It does not let a typo through to Postgres for Postgres to judge. That is
|
|
222
|
+
* what this flag was documented as doing, and no such judgment ever
|
|
223
|
+
* happened.
|
|
219
224
|
*/
|
|
220
225
|
strictWrites?: boolean;
|
|
221
226
|
|
|
@@ -245,6 +245,22 @@ export const ALL_WHERE_FILTER_OPS: readonly WhereFilterOp[] = [
|
|
|
245
245
|
/** All canonical operator strings for runtime validation. */
|
|
246
246
|
const CANONICAL_OPS: ReadonlySet<string> = new Set<WhereFilterOp>(ALL_WHERE_FILTER_OPS);
|
|
247
247
|
|
|
248
|
+
/**
|
|
249
|
+
* The REST table as a `Map`, because the key `toCanonicalOp` is handed comes
|
|
250
|
+
* off the wire.
|
|
251
|
+
*
|
|
252
|
+
* Indexed as a plain object, every `Object.prototype` member answered:
|
|
253
|
+
* `toCanonicalOp("valueOf")` returned the inherited *function* as though it
|
|
254
|
+
* were a `WhereFilterOp`, and every caller here treats a defined result as
|
|
255
|
+
* "known operator". Same defect the REST codec's own lookup tables were
|
|
256
|
+
* converted away from in `filter-dialect.ts`; this is the copy that survived
|
|
257
|
+
* one package over, and it now sits under the operator validation the REST
|
|
258
|
+
* parser does, which would otherwise have admitted `["constructor", x]`.
|
|
259
|
+
*/
|
|
260
|
+
const REST_OP_LOOKUP: ReadonlyMap<string, WhereFilterOp> = new Map<string, WhereFilterOp>(
|
|
261
|
+
Object.entries(REST_TO_CANONICAL) as [string, WhereFilterOp][]
|
|
262
|
+
);
|
|
263
|
+
|
|
248
264
|
/**
|
|
249
265
|
* Resolve any operator string (canonical or REST short-code) to its
|
|
250
266
|
* canonical `WhereFilterOp` form. Returns `undefined` for unknown operators.
|
|
@@ -257,5 +273,5 @@ const CANONICAL_OPS: ReadonlySet<string> = new Set<WhereFilterOp>(ALL_WHERE_FILT
|
|
|
257
273
|
*/
|
|
258
274
|
export function toCanonicalOp(op: string): WhereFilterOp | undefined {
|
|
259
275
|
if (CANONICAL_OPS.has(op)) return op as WhereFilterOp;
|
|
260
|
-
return (
|
|
276
|
+
return REST_OP_LOOKUP.get(op);
|
|
261
277
|
}
|
package/src/types/properties.ts
CHANGED
|
@@ -218,12 +218,19 @@ export interface BaseProperty<CustomProps = unknown> {
|
|
|
218
218
|
validation?: PropertyValidationSchema;
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
* Never
|
|
221
|
+
* Never mention this column on the API surface, in either direction.
|
|
222
222
|
*
|
|
223
223
|
* For secrets the server must store and read but no client should ever
|
|
224
224
|
* receive — password hashes, verification tokens. The value is still
|
|
225
225
|
* written and queryable server-side; it is stripped from every row the API
|
|
226
|
-
* serves, for every caller, including admins and service keys
|
|
226
|
+
* serves, for every caller, including admins and service keys, and it is
|
|
227
|
+
* absent from every generated description of the surface: the SDK's `Row`,
|
|
228
|
+
* `Insert` and `Update` types, and the OpenAPI schemas, filters and
|
|
229
|
+
* parameters.
|
|
230
|
+
*
|
|
231
|
+
* The generated types are a *description*, not a second enforcement point:
|
|
232
|
+
* the server still accepts such a field on a write, because that is how the
|
|
233
|
+
* value gets written in the first place. Nothing generated offers it.
|
|
227
234
|
*
|
|
228
235
|
* This is a server-side guarantee, unlike `admin.hideFromCollection`, which
|
|
229
236
|
* only stops the admin panel from *rendering* a field and leaves it in the
|