@atscript/db-client 0.1.121 → 0.1.123

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.cjs CHANGED
@@ -110,6 +110,7 @@ var Client = class {
110
110
  _fetch;
111
111
  _headers;
112
112
  _navigate;
113
+ _lenientWrites;
113
114
  _metaPromise;
114
115
  _validatorPromise;
115
116
  /** Cached deserialized form schemas keyed by form name. */
@@ -120,6 +121,7 @@ var Client = class {
120
121
  this._fetch = opts?.fetch ?? globalThis.fetch.bind(globalThis);
121
122
  this._headers = opts?.headers;
122
123
  this._navigate = opts?.navigate;
124
+ this._lenientWrites = opts?.lenientWrites;
123
125
  }
124
126
  /**
125
127
  * `GET /query` — query records with typed filter, sort, select, and relations.
@@ -331,7 +333,7 @@ var Client = class {
331
333
  (await this._getValidator()).validate(data, mode);
332
334
  }
333
335
  _getValidator() {
334
- if (!this._validatorPromise) this._validatorPromise = Promise.all([this.meta(), Promise.resolve().then(() => require("./validator.cjs"))]).then(([m, { createClientValidator }]) => createClientValidator(m)).catch((err) => {
336
+ if (!this._validatorPromise) this._validatorPromise = Promise.all([this.meta(), Promise.resolve().then(() => require("./validator.cjs"))]).then(([m, { createClientValidator }]) => createClientValidator(m, { lenientWrites: this._lenientWrites })).catch((err) => {
335
337
  this._validatorPromise = void 0;
336
338
  throw err;
337
339
  });
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as TDbInsertManyResult, D as Uniquery, E as TypedWithRelation, O as UniqueryControls, S as TDbDeleteResult, T as TDbUpdateResult, _ as OwnOf, b as SearchIndexInfo, c as AtscriptClientShape, d as DataOf, f as FieldMeta, g as NavOf, h as MetaResponse, i as ValidatorMode, l as ClientOptions, m as IdOf, n as ClientValidator, o as AggregateQuery, p as FilterExpr, s as AggregateResult, t as ClientValidationError, u as ClientResponse, v as PageResult, w as TDbInsertResult, x as ServerError, y as RelationInfo } from "./validator-DFrZ7tTQ.cjs";
1
+ import { C as TDbDeleteResult, D as TypedWithRelation, E as TDbUpdateResult, O as Uniquery, S as ServerError, T as TDbInsertResult, _ as NavOf, a as ValidatorMode, b as RelationInfo, c as AggregateResult, d as ClientResponse, f as DataOf, g as MetaResponse, h as IdOf, k as UniqueryControls, l as AtscriptClientShape, m as FilterExpr, n as ClientValidator, p as FieldMeta, r as ClientValidatorOptions, s as AggregateQuery, t as ClientValidationError, u as ClientOptions, v as OwnOf, w as TDbInsertManyResult, x as SearchIndexInfo, y as PageResult } from "./validator-3I12BVi4.cjs";
2
2
  import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, Uniquery as Uniquery$1, UniqueryControls as UniqueryControls$1 } from "@uniqu/core";
3
3
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
4
4
  import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbDeleteResult as TDbDeleteResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1 } from "@atscript/db";
@@ -36,6 +36,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape> {
36
36
  private readonly _fetch;
37
37
  private readonly _headers?;
38
38
  private readonly _navigate?;
39
+ private readonly _lenientWrites?;
39
40
  private _metaPromise?;
40
41
  private _validatorPromise?;
41
42
  /** Cached deserialized form schemas keyed by form name. */
@@ -305,4 +306,4 @@ declare class ActionUnsupportedError extends Error {
305
306
  constructor(action: string, processor: string, message: string);
306
307
  }
307
308
  //#endregion
308
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
309
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as TDbInsertManyResult, D as Uniquery, E as TypedWithRelation, O as UniqueryControls, S as TDbDeleteResult, T as TDbUpdateResult, _ as OwnOf, b as SearchIndexInfo, c as AtscriptClientShape, d as DataOf, f as FieldMeta, g as NavOf, h as MetaResponse, i as ValidatorMode, l as ClientOptions, m as IdOf, n as ClientValidator, o as AggregateQuery, p as FilterExpr, s as AggregateResult, t as ClientValidationError, u as ClientResponse, v as PageResult, w as TDbInsertResult, x as ServerError, y as RelationInfo } from "./validator-ADGQn9EV.mjs";
1
+ import { C as TDbDeleteResult, D as TypedWithRelation, E as TDbUpdateResult, O as Uniquery, S as ServerError, T as TDbInsertResult, _ as NavOf, a as ValidatorMode, b as RelationInfo, c as AggregateResult, d as ClientResponse, f as DataOf, g as MetaResponse, h as IdOf, k as UniqueryControls, l as AtscriptClientShape, m as FilterExpr, n as ClientValidator, p as FieldMeta, r as ClientValidatorOptions, s as AggregateQuery, t as ClientValidationError, u as ClientOptions, v as OwnOf, w as TDbInsertManyResult, x as SearchIndexInfo, y as PageResult } from "./validator-DBEmk_s8.mjs";
2
2
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
3
  import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, Uniquery as Uniquery$1, UniqueryControls as UniqueryControls$1 } from "@uniqu/core";
4
4
  import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionIntent, TDbActionLevel, TDbActionProcessor, TDbDeleteResult as TDbDeleteResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1 } from "@atscript/db";
@@ -36,6 +36,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape> {
36
36
  private readonly _fetch;
37
37
  private readonly _headers?;
38
38
  private readonly _navigate?;
39
+ private readonly _lenientWrites?;
39
40
  private _metaPromise?;
40
41
  private _validatorPromise?;
41
42
  /** Cached deserialized form schemas keyed by form name. */
@@ -305,4 +306,4 @@ declare class ActionUnsupportedError extends Error {
305
306
  constructor(action: string, processor: string, message: string);
306
307
  }
307
308
  //#endregion
308
- export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
309
+ export { ActionDisabledError, type ActionDisabledErrorBody, ActionNotFoundError, ActionUnsupportedError, type AggregateQuery, type AggregateResult, type AtscriptClientShape, Client, ClientError, type ClientOptions, type ClientResponse, type ClientValidationError, type ClientValidator, type ClientValidatorOptions, type DataOf, type FieldMeta, type FilterExpr, type IdOf, type MetaResponse, type NavOf, type OwnOf, type PageResult, type RelationInfo, type SearchIndexInfo, type ServerError, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbDeleteResult, type TDbInsertManyResult, type TDbInsertResult, type TDbUpdateResult, type TSerializedAnnotatedType, type TypedWithRelation, type Uniquery, type UniqueryControls, type ValidatorMode, VersionMismatchError, type VersionMismatchErrorBody, encodeNavigateId, formatIdentifier, formatIdentifierField };
package/dist/index.mjs CHANGED
@@ -109,6 +109,7 @@ var Client = class {
109
109
  _fetch;
110
110
  _headers;
111
111
  _navigate;
112
+ _lenientWrites;
112
113
  _metaPromise;
113
114
  _validatorPromise;
114
115
  /** Cached deserialized form schemas keyed by form name. */
@@ -119,6 +120,7 @@ var Client = class {
119
120
  this._fetch = opts?.fetch ?? globalThis.fetch.bind(globalThis);
120
121
  this._headers = opts?.headers;
121
122
  this._navigate = opts?.navigate;
123
+ this._lenientWrites = opts?.lenientWrites;
122
124
  }
123
125
  /**
124
126
  * `GET /query` — query records with typed filter, sort, select, and relations.
@@ -330,7 +332,7 @@ var Client = class {
330
332
  (await this._getValidator()).validate(data, mode);
331
333
  }
332
334
  _getValidator() {
333
- if (!this._validatorPromise) this._validatorPromise = Promise.all([this.meta(), import("./validator.mjs")]).then(([m, { createClientValidator }]) => createClientValidator(m)).catch((err) => {
335
+ if (!this._validatorPromise) this._validatorPromise = Promise.all([this.meta(), import("./validator.mjs")]).then(([m, { createClientValidator }]) => createClientValidator(m, { lenientWrites: this._lenientWrites })).catch((err) => {
334
336
  this._validatorPromise = void 0;
335
337
  throw err;
336
338
  });
@@ -1,7 +1,7 @@
1
- import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
2
- import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
3
1
  import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, FilterExpr, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls as UniqueryControls$1 } from "@uniqu/core";
2
+ import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
4
3
  import { DbResponse, TDbDeleteResult as TDbDeleteResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
4
+ import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
5
5
 
6
6
  //#region src/types.d.ts
7
7
  /** Options for creating a Client instance. */
@@ -32,6 +32,14 @@ interface ClientOptions {
32
32
  * ```
33
33
  */
34
34
  navigate?: (url: string) => void | Promise<void>;
35
+ /**
36
+ * Tolerate unknown properties in write payloads during client preflight
37
+ * validation. Enable when the served `/meta` type is a projection of the
38
+ * full server-side type (e.g. an ARBAC read overlay strips write-only
39
+ * fields) — the server stays authoritative. Off by default: strict
40
+ * preflight catches typos.
41
+ */
42
+ lenientWrites?: boolean;
35
43
  }
36
44
  /** Search index metadata from the server. */
37
45
  type SearchIndexInfo = TSearchIndexInfo;
@@ -110,6 +118,19 @@ type ClientResponse<T, Q> = DbResponse<DataOf<T>, NavOf<T>, Q> & {
110
118
  };
111
119
  //#endregion
112
120
  //#region src/validator.d.ts
121
+ /** Options for {@link ClientValidator} / {@link createClientValidator}. */
122
+ interface ClientValidatorOptions {
123
+ /**
124
+ * Tolerate unknown properties in write payloads. Enable when the served
125
+ * `/meta` type is a PROJECTION of the full server-side type (e.g. an ARBAC
126
+ * read overlay that strips write-only fields such as sealed credentials) —
127
+ * otherwise a legitimate write carrying such a field is rejected client-side
128
+ * while the server would accept it. The server stays authoritative; this
129
+ * only relaxes the client preflight, so leave it off unless you need it
130
+ * (strict preflight catches typos).
131
+ */
132
+ lenientWrites?: boolean;
133
+ }
113
134
  /**
114
135
  * Client-side validator backed by an Atscript type from the `/meta` endpoint.
115
136
  *
@@ -118,11 +139,12 @@ type ClientResponse<T, Q> = DbResponse<DataOf<T>, NavOf<T>, Q> & {
118
139
  declare class ClientValidator {
119
140
  private _type;
120
141
  private _validators;
142
+ private _lenientWrites;
121
143
  /** Flat map of dotted field paths to their annotated types. */
122
144
  readonly flatMap: Map<string, TAtscriptAnnotatedType>;
123
145
  /** Set of field paths that are navigation relations (TO/FROM/VIA). */
124
146
  readonly navFields: ReadonlySet<string>;
125
- constructor(type: TAtscriptAnnotatedType<TAtscriptTypeObject>);
147
+ constructor(type: TAtscriptAnnotatedType<TAtscriptTypeObject>, opts?: ClientValidatorOptions);
126
148
  /**
127
149
  * Validate data for a given write mode.
128
150
  * Throws `ClientValidationError` if validation fails.
@@ -154,6 +176,6 @@ declare class ClientValidationError extends Error {
154
176
  * validator.validate({ name: 'foo' }, 'insert')
155
177
  * ```
156
178
  */
157
- declare function createClientValidator(meta: MetaResponse): ClientValidator;
179
+ declare function createClientValidator(meta: MetaResponse, opts?: ClientValidatorOptions): ClientValidator;
158
180
  //#endregion
159
- export { TDbInsertManyResult$1 as C, Uniquery$1 as D, TypedWithRelation as E, UniqueryControls$1 as O, TDbDeleteResult$1 as S, TDbUpdateResult$1 as T, OwnOf as _, createClientValidator as a, SearchIndexInfo as b, AtscriptClientShape as c, DataOf as d, FieldMeta as f, NavOf as g, MetaResponse as h, ValidatorMode$1 as i, ClientOptions as l, IdOf as m, ClientValidator as n, AggregateQuery$1 as o, FilterExpr as p, DbValidationContext as r, AggregateResult$1 as s, ClientValidationError as t, ClientResponse as u, PageResult as v, TDbInsertResult$1 as w, ServerError as x, RelationInfo as y };
181
+ export { TDbDeleteResult$1 as C, TypedWithRelation as D, TDbUpdateResult$1 as E, Uniquery$1 as O, ServerError as S, TDbInsertResult$1 as T, NavOf as _, ValidatorMode$1 as a, RelationInfo as b, AggregateResult$1 as c, ClientResponse as d, DataOf as f, MetaResponse as g, IdOf as h, DbValidationContext as i, UniqueryControls$1 as k, AtscriptClientShape as l, FilterExpr as m, ClientValidator as n, createClientValidator as o, FieldMeta as p, ClientValidatorOptions as r, AggregateQuery$1 as s, ClientValidationError as t, ClientOptions as u, OwnOf as v, TDbInsertManyResult$1 as w, SearchIndexInfo as x, PageResult as y };
@@ -1,7 +1,7 @@
1
- import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, FilterExpr, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls as UniqueryControls$1 } from "@uniqu/core";
2
1
  import { TAtscriptAnnotatedType, TAtscriptTypeObject } from "@atscript/typescript/utils";
3
- import { DbResponse, TDbDeleteResult as TDbDeleteResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
4
2
  import { DbValidationContext, ValidatorMode, ValidatorMode as ValidatorMode$1 } from "@atscript/db/validator";
3
+ import { AggregateQuery as AggregateQuery$1, AggregateResult as AggregateResult$1, FilterExpr, TypedWithRelation, Uniquery as Uniquery$1, UniqueryControls as UniqueryControls$1 } from "@uniqu/core";
4
+ import { DbResponse, TDbDeleteResult as TDbDeleteResult$1, TDbInsertManyResult as TDbInsertManyResult$1, TDbInsertResult as TDbInsertResult$1, TDbUpdateResult as TDbUpdateResult$1, TFieldMeta, TMetaResponse, TRelationInfo, TSearchIndexInfo } from "@atscript/db";
5
5
 
6
6
  //#region src/types.d.ts
7
7
  /** Options for creating a Client instance. */
@@ -32,6 +32,14 @@ interface ClientOptions {
32
32
  * ```
33
33
  */
34
34
  navigate?: (url: string) => void | Promise<void>;
35
+ /**
36
+ * Tolerate unknown properties in write payloads during client preflight
37
+ * validation. Enable when the served `/meta` type is a projection of the
38
+ * full server-side type (e.g. an ARBAC read overlay strips write-only
39
+ * fields) — the server stays authoritative. Off by default: strict
40
+ * preflight catches typos.
41
+ */
42
+ lenientWrites?: boolean;
35
43
  }
36
44
  /** Search index metadata from the server. */
37
45
  type SearchIndexInfo = TSearchIndexInfo;
@@ -110,6 +118,19 @@ type ClientResponse<T, Q> = DbResponse<DataOf<T>, NavOf<T>, Q> & {
110
118
  };
111
119
  //#endregion
112
120
  //#region src/validator.d.ts
121
+ /** Options for {@link ClientValidator} / {@link createClientValidator}. */
122
+ interface ClientValidatorOptions {
123
+ /**
124
+ * Tolerate unknown properties in write payloads. Enable when the served
125
+ * `/meta` type is a PROJECTION of the full server-side type (e.g. an ARBAC
126
+ * read overlay that strips write-only fields such as sealed credentials) —
127
+ * otherwise a legitimate write carrying such a field is rejected client-side
128
+ * while the server would accept it. The server stays authoritative; this
129
+ * only relaxes the client preflight, so leave it off unless you need it
130
+ * (strict preflight catches typos).
131
+ */
132
+ lenientWrites?: boolean;
133
+ }
113
134
  /**
114
135
  * Client-side validator backed by an Atscript type from the `/meta` endpoint.
115
136
  *
@@ -118,11 +139,12 @@ type ClientResponse<T, Q> = DbResponse<DataOf<T>, NavOf<T>, Q> & {
118
139
  declare class ClientValidator {
119
140
  private _type;
120
141
  private _validators;
142
+ private _lenientWrites;
121
143
  /** Flat map of dotted field paths to their annotated types. */
122
144
  readonly flatMap: Map<string, TAtscriptAnnotatedType>;
123
145
  /** Set of field paths that are navigation relations (TO/FROM/VIA). */
124
146
  readonly navFields: ReadonlySet<string>;
125
- constructor(type: TAtscriptAnnotatedType<TAtscriptTypeObject>);
147
+ constructor(type: TAtscriptAnnotatedType<TAtscriptTypeObject>, opts?: ClientValidatorOptions);
126
148
  /**
127
149
  * Validate data for a given write mode.
128
150
  * Throws `ClientValidationError` if validation fails.
@@ -154,6 +176,6 @@ declare class ClientValidationError extends Error {
154
176
  * validator.validate({ name: 'foo' }, 'insert')
155
177
  * ```
156
178
  */
157
- declare function createClientValidator(meta: MetaResponse): ClientValidator;
179
+ declare function createClientValidator(meta: MetaResponse, opts?: ClientValidatorOptions): ClientValidator;
158
180
  //#endregion
159
- export { TDbInsertManyResult$1 as C, Uniquery$1 as D, TypedWithRelation as E, UniqueryControls$1 as O, TDbDeleteResult$1 as S, TDbUpdateResult$1 as T, OwnOf as _, createClientValidator as a, SearchIndexInfo as b, AtscriptClientShape as c, DataOf as d, FieldMeta as f, NavOf as g, MetaResponse as h, ValidatorMode$1 as i, ClientOptions as l, IdOf as m, ClientValidator as n, AggregateQuery$1 as o, FilterExpr as p, DbValidationContext as r, AggregateResult$1 as s, ClientValidationError as t, ClientResponse as u, PageResult as v, TDbInsertResult$1 as w, ServerError as x, RelationInfo as y };
181
+ export { TDbDeleteResult$1 as C, TypedWithRelation as D, TDbUpdateResult$1 as E, Uniquery$1 as O, ServerError as S, TDbInsertResult$1 as T, NavOf as _, ValidatorMode$1 as a, RelationInfo as b, AggregateResult$1 as c, ClientResponse as d, DataOf as f, MetaResponse as g, IdOf as h, DbValidationContext as i, UniqueryControls$1 as k, AtscriptClientShape as l, FilterExpr as m, ClientValidator as n, createClientValidator as o, FieldMeta as p, ClientValidatorOptions as r, AggregateQuery$1 as s, ClientValidationError as t, ClientOptions as u, OwnOf as v, TDbInsertManyResult$1 as w, SearchIndexInfo as x, PageResult as y };
@@ -10,12 +10,14 @@ let _atscript_db_validator = require("@atscript/db/validator");
10
10
  var ClientValidator = class {
11
11
  _type;
12
12
  _validators = /* @__PURE__ */ new Map();
13
+ _lenientWrites;
13
14
  /** Flat map of dotted field paths to their annotated types. */
14
15
  flatMap;
15
16
  /** Set of field paths that are navigation relations (TO/FROM/VIA). */
16
17
  navFields;
17
- constructor(type) {
18
+ constructor(type, opts) {
18
19
  this._type = type;
20
+ this._lenientWrites = opts?.lenientWrites === true;
19
21
  const ctx = (0, _atscript_db_validator.buildValidationContext)(type);
20
22
  this.flatMap = ctx.flatMap;
21
23
  this.navFields = ctx.navFields;
@@ -44,7 +46,7 @@ var ClientValidator = class {
44
46
  _getValidator(mode) {
45
47
  let v = this._validators.get(mode);
46
48
  if (!v) {
47
- v = (0, _atscript_db_validator.buildDbValidator)(this._type, mode);
49
+ v = (0, _atscript_db_validator.buildDbValidator)(this._type, mode, void 0, this._lenientWrites ? { unknownProps: "ignore" } : void 0);
48
50
  this._validators.set(mode, v);
49
51
  }
50
52
  return v;
@@ -73,8 +75,8 @@ var ClientValidationError = class extends Error {
73
75
  * validator.validate({ name: 'foo' }, 'insert')
74
76
  * ```
75
77
  */
76
- function createClientValidator(meta) {
77
- return new ClientValidator((0, _atscript_typescript_utils.deserializeAnnotatedType)(meta.type));
78
+ function createClientValidator(meta, opts) {
79
+ return new ClientValidator((0, _atscript_typescript_utils.deserializeAnnotatedType)(meta.type), opts);
78
80
  }
79
81
  //#endregion
80
82
  exports.ClientValidationError = ClientValidationError;
@@ -1,2 +1,2 @@
1
- import { a as createClientValidator, i as ValidatorMode, n as ClientValidator, r as DbValidationContext, t as ClientValidationError } from "./validator-DFrZ7tTQ.cjs";
2
- export { ClientValidationError, ClientValidator, type DbValidationContext, type ValidatorMode, createClientValidator };
1
+ import { a as ValidatorMode, i as DbValidationContext, n as ClientValidator, o as createClientValidator, r as ClientValidatorOptions, t as ClientValidationError } from "./validator-3I12BVi4.cjs";
2
+ export { ClientValidationError, ClientValidator, ClientValidatorOptions, type DbValidationContext, type ValidatorMode, createClientValidator };
@@ -1,2 +1,2 @@
1
- import { a as createClientValidator, i as ValidatorMode, n as ClientValidator, r as DbValidationContext, t as ClientValidationError } from "./validator-ADGQn9EV.mjs";
2
- export { ClientValidationError, ClientValidator, type DbValidationContext, type ValidatorMode, createClientValidator };
1
+ import { a as ValidatorMode, i as DbValidationContext, n as ClientValidator, o as createClientValidator, r as ClientValidatorOptions, t as ClientValidationError } from "./validator-DBEmk_s8.mjs";
2
+ export { ClientValidationError, ClientValidator, ClientValidatorOptions, type DbValidationContext, type ValidatorMode, createClientValidator };
@@ -9,12 +9,14 @@ import { buildDbValidator, buildValidationContext } from "@atscript/db/validator
9
9
  var ClientValidator = class {
10
10
  _type;
11
11
  _validators = /* @__PURE__ */ new Map();
12
+ _lenientWrites;
12
13
  /** Flat map of dotted field paths to their annotated types. */
13
14
  flatMap;
14
15
  /** Set of field paths that are navigation relations (TO/FROM/VIA). */
15
16
  navFields;
16
- constructor(type) {
17
+ constructor(type, opts) {
17
18
  this._type = type;
19
+ this._lenientWrites = opts?.lenientWrites === true;
18
20
  const ctx = buildValidationContext(type);
19
21
  this.flatMap = ctx.flatMap;
20
22
  this.navFields = ctx.navFields;
@@ -43,7 +45,7 @@ var ClientValidator = class {
43
45
  _getValidator(mode) {
44
46
  let v = this._validators.get(mode);
45
47
  if (!v) {
46
- v = buildDbValidator(this._type, mode);
48
+ v = buildDbValidator(this._type, mode, void 0, this._lenientWrites ? { unknownProps: "ignore" } : void 0);
47
49
  this._validators.set(mode, v);
48
50
  }
49
51
  return v;
@@ -72,8 +74,8 @@ var ClientValidationError = class extends Error {
72
74
  * validator.validate({ name: 'foo' }, 'insert')
73
75
  * ```
74
76
  */
75
- function createClientValidator(meta) {
76
- return new ClientValidator(deserializeAnnotatedType(meta.type));
77
+ function createClientValidator(meta, opts) {
78
+ return new ClientValidator(deserializeAnnotatedType(meta.type), opts);
77
79
  }
78
80
  //#endregion
79
81
  export { ClientValidationError, ClientValidator, createClientValidator };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-client",
3
- "version": "0.1.121",
3
+ "version": "0.1.123",
4
4
  "description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -50,7 +50,7 @@
50
50
  "@atscript/typescript": "^0.1.85",
51
51
  "@uniqu/core": "^0.1.7",
52
52
  "unplugin-atscript": "^0.1.85",
53
- "@atscript/db": "0.1.121"
53
+ "@atscript/db": "0.1.123"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@atscript/db": "^0.1.44",