@classytic/mongokit 3.34.0 → 3.35.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.
@@ -1,2 +1,2 @@
1
- import { n as createMongooseAdapter, r as isMongooseModel, t as MongooseAdapter } from "../adapter-BitHg-CN.mjs";
1
+ import { n as createMongooseAdapter, r as isMongooseModel, t as MongooseAdapter } from "../adapter-DlaOGcQN.mjs";
2
2
  export { MongooseAdapter, createMongooseAdapter, isMongooseModel };
@@ -1,5 +1,5 @@
1
1
  import { n as warn } from "./logger-K7dPmu2U.mjs";
2
- import { t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-DKbnKduN.mjs";
2
+ import { t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-waUVQwK4.mjs";
3
3
  import { matchesRecordFilter } from "@classytic/repo-core/filter";
4
4
  import { mergeFieldRuleConstraints } from "@classytic/repo-core/schema";
5
5
  import { asRepositoryLike, isRepository } from "@classytic/repo-core/adapter";
@@ -1,5 +1,5 @@
1
1
  import { n as Repository } from "../Repository-BArvU32x.mjs";
2
- import { n as createMongooseAdapter } from "../adapter-BitHg-CN.mjs";
2
+ import { n as createMongooseAdapter } from "../adapter-DlaOGcQN.mjs";
3
3
  import { asReadOnlyRepo } from "@classytic/repo-core/repository";
4
4
  import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@classytic/repo-core/better-auth";
5
5
  //#region src/better-auth/index.ts
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForU
15
15
  import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
16
16
  import { extractSchemaIndexes } from "./query/primitives/indexes.mjs";
17
17
  import { n as createMemoryCache, t as toPlain } from "./to-plain-vksRrLtc.mjs";
18
- import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-DKbnKduN.mjs";
18
+ import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-waUVQwK4.mjs";
19
19
  import { runChunkedPurge } from "@classytic/repo-core/repository";
20
20
  import { isControlParam } from "@classytic/repo-core/query-parser";
21
21
  //#region src/actions/cascade-references.ts
@@ -474,9 +474,37 @@ function stripDefaultsDeep(node) {
474
474
  delete obj.default;
475
475
  for (const value of Object.values(obj)) stripDefaultsDeep(value);
476
476
  }
477
+ /**
478
+ * Recursively delete every `required` keyword from a JSON-schema subtree
479
+ * (properties, array items, nested subdocuments).
480
+ *
481
+ * PATCH semantics mean every field is optional at EVERY nesting depth, not
482
+ * just the root — a caller may send a partial subdocument-array item (e.g.
483
+ * `variants: [{ sku, isActive }]` to toggle a flag) without re-supplying
484
+ * every field the CREATE schema requires for that item. The one-line
485
+ * `delete clone.required` below only stripped the top-level key; a
486
+ * DocumentArray's `items` schema carries its OWN `required` (built by
487
+ * `subSchemaToJsonSchema`), which survived untouched — so a partial nested
488
+ * item still failed AJV's `required` check before the request ever reached
489
+ * the repository (real defect: PATCHing a product to add ONE variant with
490
+ * no `variationAttributes` 400'd on `variants/0` missing `attributes`, even
491
+ * though `attributes: {}` is a valid, already-persisted value). Same fix
492
+ * shape as `stripDefaultsDeep` above, for the identical reason: an UPDATE
493
+ * schema's partial-field semantics belong to the whole tree, not its root.
494
+ */
495
+ function stripRequiredDeep(node) {
496
+ if (Array.isArray(node)) {
497
+ for (const item of node) stripRequiredDeep(item);
498
+ return;
499
+ }
500
+ if (!node || typeof node !== "object") return;
501
+ const obj = node;
502
+ delete obj.required;
503
+ for (const value of Object.values(obj)) stripRequiredDeep(value);
504
+ }
477
505
  function buildJsonSchemaForUpdate(createJson, options) {
478
506
  const clone = JSON.parse(JSON.stringify(createJson));
479
- delete clone.required;
507
+ stripRequiredDeep(clone);
480
508
  const fieldsToOmit = collectFieldsToOmit(options, "update");
481
509
  applyFieldRules(clone, fieldsToOmit, options);
482
510
  stripDefaultsDeep(clone);
@@ -4,5 +4,5 @@ import { t as configureLogger } from "../logger-K7dPmu2U.mjs";
4
4
  import { t as createError } from "../error-BuByZwKU.mjs";
5
5
  import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "../field-selection-FSQFLpsU.mjs";
6
6
  import { n as createMemoryCache, t as toPlain } from "../to-plain-vksRrLtc.mjs";
7
- import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-DKbnKduN.mjs";
7
+ import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-waUVQwK4.mjs";
8
8
  export { DEFAULT_ID_CHUNK, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, collectIds, configureLogger, createError, createFieldPreset, createMemoryCache, filterResponseData, getFieldsForUser, getMongooseProjection, getSchemaIdType, idChunks, isObjectIdInstance, isValidIdForType, keysetFilter, narrowToIds, selectKeysetChunk, toObjectId, toPlain };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/mongokit",
3
- "version": "3.34.0",
3
+ "version": "3.35.0",
4
4
  "description": "Production-grade MongoDB repositories - smart pagination, events, and plugins. Built on @classytic/repo-core.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -122,7 +122,7 @@
122
122
  },
123
123
  "homepage": "https://github.com/classytic/mongokit#readme",
124
124
  "peerDependencies": {
125
- "@classytic/repo-core": ">=0.23.0",
125
+ "@classytic/repo-core": ">=0.25.0",
126
126
  "mongodb-memory-server": ">=10.4.3",
127
127
  "mongoose": ">=9.4.1"
128
128
  },
@@ -174,7 +174,7 @@
174
174
  "@better-auth/mongo-adapter": "^1.6.29",
175
175
  "@biomejs/biome": "^2.5.8",
176
176
  "@classytic/dev-tools": "^0.2.0",
177
- "@classytic/repo-core": "^0.23.0",
177
+ "@classytic/repo-core": "^0.25.0",
178
178
  "@types/node": "^26.2.0",
179
179
  "@vitest/coverage-v8": "^4.1.10",
180
180
  "ajv": "^8.20.0",