@postxl/generator 0.56.7 → 0.56.8

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.
@@ -188,7 +188,7 @@ function generateModelBusinessLogicUpdate({ model, meta }) {
188
188
  */
189
189
  export const ${zodCloneObject} = z.object({
190
190
  ${model.fields
191
- .filter((f) => !f.attributes.isReadonly && f.kind !== "relation" || f.kind === 'id')
191
+ .filter((f) => !f.attributes.isReadonly || f.kind === "id")
192
192
  .map((f) => `${f.name}: z.${(0, zod_1.getZodDecoderDefinition)({ field: f, allowAnyOptionalField: f.kind !== 'id' })}`)
193
193
  .join(',')}
194
194
  })
@@ -333,11 +333,11 @@ function generateCloneMethod({ model, meta, m }) {
333
333
  const refModelMeta = (0, meta_1.getModelMetadata)({ model: referencingModel });
334
334
  const refFieldMeta = (0, meta_1.getFieldMetadata)({ field: referencingField });
335
335
  backReferenceNames.push(`${refModelMeta.userFriendlyNamePlural}.${referencingField.name}`);
336
+ const { view, update } = refModelMeta.businessLogic;
336
337
  backReferenceCloning.push(`
337
338
  // ${referencingModel.name}.${referencingField.name}
338
- for (const childId of await this.viewService.${refModelMeta.businessLogic.view.serviceVariableName}.data.${refFieldMeta.getByForeignKeyIdsMethodFnName}(id)) {
339
- const clonedChild = await this.updateService.${refModelMeta.businessLogic.update.serviceVariableName}.clone({ data: { id: childId }, execution})
340
- await this.updateService.${refModelMeta.businessLogic.update.serviceVariableName}.update({ data: { id: clonedChild.id, ${referencingField.name}: clone.id }, execution })
339
+ for (const childId of await this.viewService.${view.serviceVariableName}.data.${refFieldMeta.getByForeignKeyIdsMethodFnName}(id)) {
340
+ await this.updateService.${update.serviceVariableName}.clone({ data: { id: childId, ${referencingField.name}: clone.id }, execution })
341
341
  }
342
342
  `);
343
343
  }
@@ -351,7 +351,7 @@ function generateCloneMethod({ model, meta, m }) {
351
351
  throw new Error(\`${meta.userFriendlyName} with id \${id} not found\`)
352
352
  }
353
353
 
354
- const clone = await this.create({ data: { ...omitId(source), ...data }, execution })
354
+ const clone = await this.data.create({ item: { ...omitId(source), ...data }, execution })
355
355
 
356
356
  ${backReferenceCloning.join('\n')}
357
357
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.56.7",
3
+ "version": "0.56.8",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {