@palmares/schemas 0.0.1 → 0.1.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.
Files changed (174) hide show
  1. package/.turbo/turbo-build$colon$watch.log +12 -410
  2. package/CHANGELOG.md +17 -0
  3. package/__tests__/.drizzle/migrations/0000_skinny_harrier.sql +22 -0
  4. package/__tests__/.drizzle/migrations/meta/0000_snapshot.json +156 -0
  5. package/__tests__/.drizzle/migrations/meta/_journal.json +13 -0
  6. package/__tests__/.drizzle/schema.ts +35 -0
  7. package/__tests__/drizzle.config.ts +11 -0
  8. package/__tests__/eslint.config.js +10 -0
  9. package/__tests__/manage.ts +5 -0
  10. package/__tests__/node_modules/.bin/drizzle-kit +17 -0
  11. package/__tests__/node_modules/.bin/esbuild +14 -0
  12. package/__tests__/node_modules/.bin/tsc +17 -0
  13. package/__tests__/node_modules/.bin/tsserver +17 -0
  14. package/__tests__/node_modules/.bin/tsx +17 -0
  15. package/__tests__/package.json +36 -0
  16. package/__tests__/sqlite.db +0 -0
  17. package/__tests__/src/core/array.test.ts +130 -0
  18. package/__tests__/src/core/boolean.test.ts +66 -0
  19. package/__tests__/src/core/datetime.test.ts +102 -0
  20. package/__tests__/src/core/index.ts +35 -0
  21. package/__tests__/src/core/model.test.ts +260 -0
  22. package/__tests__/src/core/models.ts +50 -0
  23. package/__tests__/src/core/numbers.test.ts +177 -0
  24. package/__tests__/src/core/object.test.ts +198 -0
  25. package/__tests__/src/core/string.test.ts +222 -0
  26. package/__tests__/src/core/test.test.ts +59 -0
  27. package/__tests__/src/core/types.test.ts +97 -0
  28. package/__tests__/src/core/union.test.ts +99 -0
  29. package/__tests__/src/settings.ts +71 -0
  30. package/__tests__/tsconfig.json +11 -0
  31. package/dist/cjs/src/adapter/fields/index.js +2 -2
  32. package/dist/cjs/src/adapter/fields/object.js +9 -0
  33. package/dist/cjs/src/adapter/index.js +1 -0
  34. package/dist/cjs/src/constants.js +1 -7
  35. package/dist/cjs/src/domain.js +146 -1
  36. package/dist/cjs/src/index.js +69 -74
  37. package/dist/cjs/src/model.js +206 -206
  38. package/dist/cjs/src/schema/array.js +185 -58
  39. package/dist/cjs/src/schema/boolean.js +105 -44
  40. package/dist/cjs/src/schema/datetime.js +104 -38
  41. package/dist/cjs/src/schema/number.js +134 -114
  42. package/dist/cjs/src/schema/object.js +106 -43
  43. package/dist/cjs/src/schema/schema.js +123 -75
  44. package/dist/cjs/src/schema/string.js +152 -58
  45. package/dist/cjs/src/schema/union.js +412 -290
  46. package/dist/cjs/src/utils.js +42 -15
  47. package/dist/cjs/src/validators/array.js +6 -1
  48. package/dist/cjs/src/validators/boolean.js +2 -0
  49. package/dist/cjs/src/validators/datetime.js +4 -0
  50. package/dist/cjs/src/validators/number.js +12 -40
  51. package/dist/cjs/src/validators/object.js +1 -0
  52. package/dist/cjs/src/validators/schema.js +5 -1
  53. package/dist/cjs/src/validators/string.js +30 -2
  54. package/dist/cjs/src/validators/union.js +5 -4
  55. package/dist/cjs/src/validators/utils.js +99 -27
  56. package/dist/cjs/tsconfig.types.tsbuildinfo +1 -1
  57. package/dist/cjs/types/adapter/fields/array.d.ts +2 -2
  58. package/dist/cjs/types/adapter/fields/array.d.ts.map +1 -1
  59. package/dist/cjs/types/adapter/fields/boolean.d.ts.map +1 -1
  60. package/dist/cjs/types/adapter/fields/datetime.d.ts.map +1 -1
  61. package/dist/cjs/types/adapter/fields/index.d.ts +2 -2
  62. package/dist/cjs/types/adapter/fields/index.d.ts.map +1 -1
  63. package/dist/cjs/types/adapter/fields/number.d.ts.map +1 -1
  64. package/dist/cjs/types/adapter/fields/object.d.ts +2 -1
  65. package/dist/cjs/types/adapter/fields/object.d.ts.map +1 -1
  66. package/dist/cjs/types/adapter/fields/string.d.ts.map +1 -1
  67. package/dist/cjs/types/adapter/fields/union.d.ts.map +1 -1
  68. package/dist/cjs/types/adapter/index.d.ts +1 -0
  69. package/dist/cjs/types/adapter/index.d.ts.map +1 -1
  70. package/dist/cjs/types/adapter/types.d.ts +28 -18
  71. package/dist/cjs/types/adapter/types.d.ts.map +1 -1
  72. package/dist/cjs/types/constants.d.ts +0 -1
  73. package/dist/cjs/types/constants.d.ts.map +1 -1
  74. package/dist/cjs/types/domain.d.ts +5 -4
  75. package/dist/cjs/types/domain.d.ts.map +1 -1
  76. package/dist/cjs/types/index.d.ts +78 -55
  77. package/dist/cjs/types/index.d.ts.map +1 -1
  78. package/dist/cjs/types/model.d.ts +17 -17
  79. package/dist/cjs/types/model.d.ts.map +1 -1
  80. package/dist/cjs/types/schema/array.d.ts +168 -47
  81. package/dist/cjs/types/schema/array.d.ts.map +1 -1
  82. package/dist/cjs/types/schema/boolean.d.ts +103 -44
  83. package/dist/cjs/types/schema/boolean.d.ts.map +1 -1
  84. package/dist/cjs/types/schema/datetime.d.ts +90 -30
  85. package/dist/cjs/types/schema/datetime.d.ts.map +1 -1
  86. package/dist/cjs/types/schema/number.d.ts +133 -125
  87. package/dist/cjs/types/schema/number.d.ts.map +1 -1
  88. package/dist/cjs/types/schema/object.d.ts +104 -35
  89. package/dist/cjs/types/schema/object.d.ts.map +1 -1
  90. package/dist/cjs/types/schema/schema.d.ts +62 -44
  91. package/dist/cjs/types/schema/schema.d.ts.map +1 -1
  92. package/dist/cjs/types/schema/string.d.ts +152 -65
  93. package/dist/cjs/types/schema/string.d.ts.map +1 -1
  94. package/dist/cjs/types/schema/types.d.ts +11 -2
  95. package/dist/cjs/types/schema/types.d.ts.map +1 -1
  96. package/dist/cjs/types/schema/union.d.ts +133 -40
  97. package/dist/cjs/types/schema/union.d.ts.map +1 -1
  98. package/dist/cjs/types/types.d.ts +35 -0
  99. package/dist/cjs/types/types.d.ts.map +1 -1
  100. package/dist/cjs/types/utils.d.ts +41 -27
  101. package/dist/cjs/types/utils.d.ts.map +1 -1
  102. package/dist/cjs/types/validators/array.d.ts.map +1 -1
  103. package/dist/cjs/types/validators/boolean.d.ts.map +1 -1
  104. package/dist/cjs/types/validators/datetime.d.ts.map +1 -1
  105. package/dist/cjs/types/validators/number.d.ts +5 -6
  106. package/dist/cjs/types/validators/number.d.ts.map +1 -1
  107. package/dist/cjs/types/validators/object.d.ts.map +1 -1
  108. package/dist/cjs/types/validators/schema.d.ts +2 -2
  109. package/dist/cjs/types/validators/schema.d.ts.map +1 -1
  110. package/dist/cjs/types/validators/string.d.ts +9 -9
  111. package/dist/cjs/types/validators/string.d.ts.map +1 -1
  112. package/dist/cjs/types/validators/utils.d.ts +44 -27
  113. package/dist/cjs/types/validators/utils.d.ts.map +1 -1
  114. package/dist/esm/src/adapter/fields/index.js +2 -2
  115. package/dist/esm/src/adapter/fields/object.js +6 -0
  116. package/dist/esm/src/adapter/index.js +1 -0
  117. package/dist/esm/src/constants.js +1 -2
  118. package/dist/esm/src/domain.js +11 -1
  119. package/dist/esm/src/index.js +38 -73
  120. package/dist/esm/src/model.js +83 -78
  121. package/dist/esm/src/schema/array.js +136 -54
  122. package/dist/esm/src/schema/boolean.js +98 -44
  123. package/dist/esm/src/schema/datetime.js +91 -38
  124. package/dist/esm/src/schema/number.js +127 -110
  125. package/dist/esm/src/schema/object.js +98 -43
  126. package/dist/esm/src/schema/schema.js +102 -67
  127. package/dist/esm/src/schema/string.js +147 -59
  128. package/dist/esm/src/schema/union.js +119 -40
  129. package/dist/esm/src/types.js +14 -1
  130. package/dist/esm/src/utils.js +56 -27
  131. package/dist/esm/src/validators/array.js +6 -1
  132. package/dist/esm/src/validators/boolean.js +2 -0
  133. package/dist/esm/src/validators/datetime.js +4 -0
  134. package/dist/esm/src/validators/number.js +9 -23
  135. package/dist/esm/src/validators/object.js +1 -0
  136. package/dist/esm/src/validators/schema.js +5 -1
  137. package/dist/esm/src/validators/string.js +30 -2
  138. package/dist/esm/src/validators/union.js +5 -4
  139. package/dist/esm/src/validators/utils.js +62 -36
  140. package/package.json +3 -3
  141. package/src/adapter/fields/array.ts +2 -2
  142. package/src/adapter/fields/boolean.ts +3 -8
  143. package/src/adapter/fields/datetime.ts +3 -9
  144. package/src/adapter/fields/index.ts +11 -11
  145. package/src/adapter/fields/number.ts +3 -9
  146. package/src/adapter/fields/object.ts +13 -10
  147. package/src/adapter/fields/string.ts +3 -9
  148. package/src/adapter/fields/union.ts +3 -9
  149. package/src/adapter/index.ts +1 -0
  150. package/src/adapter/types.ts +60 -45
  151. package/src/constants.ts +1 -3
  152. package/src/domain.ts +15 -1
  153. package/src/index.ts +189 -211
  154. package/src/model.ts +119 -115
  155. package/src/schema/array.ts +274 -90
  156. package/src/schema/boolean.ts +145 -60
  157. package/src/schema/datetime.ts +133 -49
  158. package/src/schema/number.ts +210 -173
  159. package/src/schema/object.ts +167 -74
  160. package/src/schema/schema.ts +205 -126
  161. package/src/schema/string.ts +221 -94
  162. package/src/schema/types.ts +44 -16
  163. package/src/schema/union.ts +193 -68
  164. package/src/types.ts +53 -0
  165. package/src/utils.ts +115 -57
  166. package/src/validators/array.ts +46 -27
  167. package/src/validators/boolean.ts +13 -7
  168. package/src/validators/datetime.ts +24 -16
  169. package/src/validators/number.ts +53 -63
  170. package/src/validators/object.ts +6 -5
  171. package/src/validators/schema.ts +33 -25
  172. package/src/validators/string.ts +122 -59
  173. package/src/validators/union.ts +8 -8
  174. package/src/validators/utils.ts +67 -42
package/src/model.ts CHANGED
@@ -138,22 +138,22 @@ async function getSchemaFromModelField(
138
138
  }
139
139
 
140
140
  /**
141
- * Different from other schemas, this function is a factory function that returns either an ObjectSchema or an ArraySchema.
142
- * The idea is to build the schema of a model dynamically based on its fields.
141
+ * Different from other schemas, this function is a factory function that returns either an ObjectSchema or an
142
+ * ArraySchema. The idea is to build the schema of a model dynamically based on its fields.
143
143
  *
144
- * Another feature is that it can automatically add the foreign key relation to the schema, but for that you need to define
145
- * the fields of the related model in the fields object.
144
+ * Another feature is that it can automatically add the foreign key relation to the schema, but for that you need to
145
+ * define the fields of the related model in the fields object.
146
146
  *
147
147
  * For example: A User model have a field `companyId` that is a ForeignKeyField to the Company model. The `relationName`
148
- * is the direct relation from the User model to the Company model, and the `relatedName` is the reverse relation from the
149
- * Company model to the User model. If you define the fieldName as either the relatedName or the relationName it will fetch
150
- * the data automatically.
148
+ * is the direct relation from the User model to the Company model, and the `relatedName` is the reverse relation from
149
+ * the Company model to the User model. If you define the fieldName as either the relatedName or the relationName it
150
+ * will fetch the data automatically.
151
151
  *
152
- * **Important**: We build the schema dynamically but also lazily, if you don't try to parse or validate the schema, it won't be built.
153
- * After the first time it's built, it's cached and never built again.
152
+ * **Important**: We build the schema dynamically but also lazily, if you don't try to parse or validate the schema, it
153
+ * won't be built. After the first time it's built, it's cached and never built again.
154
154
  *
155
- * **Important 2**: If you want to use the automatic relation feature, you need to define guarantee that the foreignKey field fieldName
156
- * exists on `show` array, or that it doesn't exist on `omit` array.
155
+ * **Important 2**: If you want to use the automatic relation feature, you need to define guarantee that the foreignKey
156
+ * field fieldName exists on `show` array, or that it doesn't exist on `omit` array.
157
157
  *
158
158
  * Like: `{ options: { show: ['id', 'name', 'companyId'] }}` or `{ options: { omit: ['id'] }}` it **will work**.
159
159
  *
@@ -206,16 +206,16 @@ async function getSchemaFromModelField(
206
206
  * fields: {
207
207
  * usersOfCompany: p.modelSchema(User, { many: true }).optional({ outputOnly: true });
208
208
  * },
209
- * show: ['id', 'type'] // The `companyId` field on the 'User' model is tied to the `id` field on the 'Company' model so 'id' is required.
210
- * });
209
+ * // The `companyId` field on the 'User' model is tied to the `id` field on the 'Company' model so 'id' is required.
210
+ * show: ['id', 'type'] * });
211
211
  *```
212
212
  * @param model - The model that you want to build the schema from.
213
213
  * @param options - The options to build the schema.
214
214
  * @param options.ignoreExtraneousFields - If you want to ignore extraneous fields set this to true.
215
215
  * @param options.engineInstance - What engine instance you want to use to fetch the data. Defaults to the first one.
216
- * @param options.omitRelation - Fields that you want to omit from the relation. For example, on the example above, on the
217
- * `userSchema` you can omit the `companyId` field from the relation by just passing `['company']`, on the `companySchema`
218
- * you can omit the `id` field from company by passing `['usersOfCompany']`.
216
+ * @param options.omitRelation - Fields that you want to omit from the relation. For example, on the example above, on
217
+ * the `userSchema` you can omit the `companyId` field from the relation by just passing `['company']`, on the
218
+ * `companySchema` you can omit the `id` field from company by passing `['usersOfCompany']`.
219
219
  *
220
220
  * @param options.fields - Extra fields that you want to add to the schema. If it has the same name as the model field,
221
221
  * We will not create a schema for that field and use the one you have defined here.
@@ -354,7 +354,7 @@ export function modelSchema<
354
354
  },
355
355
  TDefinitionsOfSchemaType,
356
356
  Record<any, any>
357
- >[]
357
+ >
358
358
  ]
359
359
  >
360
360
  : ObjectSchema<
@@ -385,117 +385,121 @@ export function modelSchema<
385
385
 
386
386
  // Add this callback to transform the model fields
387
387
  parentSchema.__runBeforeParseAndData = async () => {
388
- if (parentSchema.__alreadyAppliedModel) return;
389
- parentSchema.__alreadyAppliedModel = true;
390
- const fieldsOfModels = (model as unknown as typeof InternalModelClass_DoNotUse)._fields();
391
- const fieldsAsEntries = Object.entries(fieldsOfModels);
392
- const fieldsWithAutomaticRelations = new Map<
393
- Schema<any, any>,
394
- {
395
- relationOrRelatedName: string;
396
- isArray: boolean;
397
- model: ReturnType<typeof Model>;
398
- fieldToSearchOnModel: string;
399
- fieldToGetFromData: string;
400
- }[]
401
- >();
388
+ const promise = new Promise((resolve) => {
389
+ const fieldsOfModels = (model as unknown as typeof InternalModelClass_DoNotUse)._fields();
390
+ const fieldsAsEntries = Object.entries(fieldsOfModels);
391
+ const fieldsWithAutomaticRelations = new Map<
392
+ Schema<any, any>,
393
+ {
394
+ relationOrRelatedName: string;
395
+ isArray: boolean;
396
+ model: ReturnType<typeof Model>;
397
+ fieldToSearchOnModel: string;
398
+ fieldToGetFromData: string;
399
+ }[]
400
+ >();
402
401
 
403
- const fields = await fieldsAsEntries.reduce(
404
- async (accumulatorAsPromise, [key, value]) => {
405
- if (omitAsSet.has(key as any)) return accumulatorAsPromise;
406
- if (showAsSet.size > 0 && !showAsSet.has(key as any)) return accumulatorAsPromise;
402
+ const fields = fieldsAsObject as Record<any, Schema<any, any>>;
403
+ Promise.all(
404
+ fieldsAsEntries.map(async ([key, value]) => {
405
+ if (omitAsSet.has(key as any)) return;
406
+ if (showAsSet.size > 0 && !showAsSet.has(key as any)) return;
407
407
 
408
- let schema = (fieldsAsObject as any)[key as any];
409
- const optionsForForeignKeyRelation: any = {};
410
- if (!schema || value instanceof ForeignKeyField) {
411
- const newSchema = await getSchemaFromModelField(
412
- model,
413
- value,
414
- parentSchema?.__getParent?.(),
415
- options?.fields,
416
- options?.engineInstance,
417
- optionsForForeignKeyRelation
418
- );
419
- if (!schema) schema = newSchema;
420
- }
408
+ let schema = (fieldsAsObject as any)[key as any];
409
+ const optionsForForeignKeyRelation: any = {};
410
+ if (!schema || value instanceof ForeignKeyField) {
411
+ const newSchema = await getSchemaFromModelField(
412
+ model,
413
+ value,
414
+ parentSchema?.__getParent?.(),
415
+ options?.fields,
416
+ options?.engineInstance,
417
+ optionsForForeignKeyRelation
418
+ );
419
+ if (!schema) schema = newSchema;
420
+ }
421
421
 
422
- // Appends the foreign key relation to the schema automatically.
423
- if (optionsForForeignKeyRelation.foreignKeyRelation) {
424
- const rootSchema = optionsForForeignKeyRelation?.foreignKeyRelation?.schema || lazyModelSchema;
425
- const existingRelations =
426
- fieldsWithAutomaticRelations.get(rootSchema) ||
427
- ([] as {
428
- relationOrRelatedName: string;
429
- isArray: boolean;
430
- model: ReturnType<typeof Model>;
431
- fieldToSearchOnModel: string;
432
- fieldToGetFromData: string;
433
- }[]);
434
- existingRelations.push({
435
- relationOrRelatedName: optionsForForeignKeyRelation.foreignKeyRelation.relationOrRelatedName,
436
- isArray: optionsForForeignKeyRelation.foreignKeyRelation.isArray,
437
- model: optionsForForeignKeyRelation.foreignKeyRelation.model,
438
- fieldToSearchOnModel: optionsForForeignKeyRelation.foreignKeyRelation.fieldToSearchOnModel,
439
- fieldToGetFromData: optionsForForeignKeyRelation.foreignKeyRelation.fieldToGetFromData
440
- });
441
- fieldsWithAutomaticRelations.set(rootSchema, existingRelations);
442
- }
422
+ // Appends the foreign key relation to the schema automatically.
423
+ if (optionsForForeignKeyRelation.foreignKeyRelation) {
424
+ const rootSchema = optionsForForeignKeyRelation?.foreignKeyRelation?.schema || lazyModelSchema;
425
+ const existingRelations =
426
+ fieldsWithAutomaticRelations.get(rootSchema) ||
427
+ ([] as {
428
+ relationOrRelatedName: string;
429
+ isArray: boolean;
430
+ model: ReturnType<typeof Model>;
431
+ fieldToSearchOnModel: string;
432
+ fieldToGetFromData: string;
433
+ }[]);
434
+ existingRelations.push({
435
+ relationOrRelatedName: optionsForForeignKeyRelation.foreignKeyRelation.relationOrRelatedName,
436
+ isArray: optionsForForeignKeyRelation.foreignKeyRelation.isArray,
437
+ model: optionsForForeignKeyRelation.foreignKeyRelation.model,
438
+ fieldToSearchOnModel: optionsForForeignKeyRelation.foreignKeyRelation.fieldToSearchOnModel,
439
+ fieldToGetFromData: optionsForForeignKeyRelation.foreignKeyRelation.fieldToGetFromData
440
+ });
441
+ fieldsWithAutomaticRelations.set(rootSchema, existingRelations);
442
+ }
443
443
 
444
- const accumulator = await accumulatorAsPromise;
445
- accumulator[key] = schema;
446
- return accumulator;
447
- },
448
- Promise.resolve(fieldsAsObject as Record<any, Schema<any, any>>)
449
- );
444
+ (fieldsAsObject as any)[key] = schema;
445
+ return fieldsAsObject;
446
+ })
447
+ ).then(async () => {
448
+ if (fieldsWithAutomaticRelations.size > 0) {
449
+ // This way we can get all of the relations concurrently with Promise.all
450
+ for (const [schema, relations] of fieldsWithAutomaticRelations.entries()) {
451
+ schema.toRepresentation(
452
+ async (data: any | any[]) => {
453
+ const allData = Array.isArray(data) ? data : [data];
454
+ // since we are changing the data by reference, just return the data itself.
455
+ await Promise.all(
456
+ allData.map(async (data) =>
457
+ Promise.all(
458
+ relations.map(async (relation) => {
459
+ // Ignore if the data of the relation already exists
460
+ if (relation.relationOrRelatedName in data) return;
450
461
 
451
- if (fieldsWithAutomaticRelations.size > 0) {
452
- // This way we can get all of the relations concurrently with Promise.all
453
- for (const [schema, relations] of fieldsWithAutomaticRelations.entries()) {
454
- schema.toRepresentation(
455
- async (data: any | any[]) => {
456
- const allData = Array.isArray(data) ? data : [data];
457
- // since we are changing the data by reference, just return the data itself.
458
- await Promise.all(
459
- allData.map(async (data) =>
460
- Promise.all(
461
- relations.map(async (relation) => {
462
- // Ignore if the data of the relation already exists
463
- if (relation.relationOrRelatedName in data) return;
462
+ let relationData: any | any[] = await relation.model.default.get({
463
+ search: {
464
+ [relation.fieldToSearchOnModel]: data[relation.fieldToGetFromData]
465
+ }
466
+ });
467
+ if (relation.isArray !== true) relationData = relationData[0];
468
+ data[relation.relationOrRelatedName] = relationData;
464
469
 
465
- let relationData: any | any[] = await relation.model.default.get({
466
- search: {
467
- [relation.fieldToSearchOnModel]: data[relation.fieldToGetFromData]
468
- }
469
- });
470
- if (relation.isArray !== true) relationData = relationData[0];
471
- data[relation.relationOrRelatedName] = relationData;
470
+ if ((schema as any).__omitRelation.has(relation.relationOrRelatedName as any))
471
+ delete data[relation.fieldToGetFromData];
472
+ })
473
+ )
474
+ )
475
+ );
472
476
 
473
- if ((schema as any).__omitRelation.has(relation.relationOrRelatedName as any))
474
- delete data[relation.fieldToGetFromData];
475
- })
476
- )
477
- )
477
+ return data;
478
+ },
479
+ {
480
+ after: true
481
+ }
478
482
  );
479
-
480
- return data;
481
- },
482
- {
483
- after: true
484
483
  }
485
- );
486
- }
487
- }
484
+ }
488
485
 
489
- (lazyModelSchema as any).__data = fields as any;
486
+ (lazyModelSchema as any).__data = fields as any;
490
487
 
491
- await Promise.all(
492
- customFieldValues.map(async (schema: any) => {
493
- schema['__getParent'] = () => lazyModelSchema;
494
- if (schema['__runBeforeParseAndData']) await schema['__runBeforeParseAndData'](schema);
495
- })
496
- );
488
+ await Promise.all(
489
+ customFieldValues.map(async (schema: any) => {
490
+ schema['__getParent'] = () => lazyModelSchema;
491
+ if (schema['__runBeforeParseAndData']) await schema['__runBeforeParseAndData'](schema);
492
+ })
493
+ );
494
+ resolve(undefined);
495
+ });
496
+ });
497
+ if (parentSchema.__alreadyAppliedModel) return parentSchema.__alreadyAppliedModel;
498
+ parentSchema.__alreadyAppliedModel = promise;
499
+ return promise;
497
500
  };
498
501
 
499
502
  if (options?.ignoreExtraneousFields !== true) lazyModelSchema.removeExtraneous();
503
+
500
504
  return parentSchema;
501
505
  }