vsrepo 1.1.7 → 1.1.9
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.
|
@@ -488,6 +488,34 @@ export type UpsertWithRelations<T, M extends Prisma.ModelName, TRelations> =
|
|
|
488
488
|
[K in Extract<keyof TRelations, keyof T>]?: RelationPayload<T[K], TRelations[K], M, K>;
|
|
489
489
|
};
|
|
490
490
|
|
|
491
|
+
type ExtractNestedUpdateInput<M extends Prisma.ModelName, K extends PropertyKey> =
|
|
492
|
+
NonNullable<ExtractUnionProp<PrismaModelInputs<M>['updateInput'], K>> extends { update?: infer U }
|
|
493
|
+
? (
|
|
494
|
+
Exclude<U, any[]> extends infer Obj
|
|
495
|
+
? Obj extends { where: any, data: infer D }
|
|
496
|
+
? Exclude<D, any[]>
|
|
497
|
+
: Obj
|
|
498
|
+
: never
|
|
499
|
+
)
|
|
500
|
+
: never;
|
|
501
|
+
|
|
502
|
+
type RelationUpdatePayload<TField, TRelationConfig, M extends Prisma.ModelName, K extends PropertyKey> = NonNullable<TField> extends any[]
|
|
503
|
+
? (ExtractNestedUpdateInput<M, K>)[]
|
|
504
|
+
: NonNullable<TField> extends object
|
|
505
|
+
? ExtractNestedUpdateInput<M, K> | (TRelationConfig extends { mode: 'oto'; restriction: 'set' } | { mode: 'mto'; nullAble: true } ? null : never)
|
|
506
|
+
: never;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Payload aceito pelo `patch` quando o repository possui relações configuradas.
|
|
510
|
+
*
|
|
511
|
+
* Substitui os campos relacionais pelo formato compatível com os modos
|
|
512
|
+
* configurados em `relations` para fluxos de Update.
|
|
513
|
+
*/
|
|
514
|
+
export type UpdateWithRelations<T, M extends Prisma.ModelName, TRelations> =
|
|
515
|
+
DistributiveOmit<PrismaModelInputs<M>['updateInput'], keyof TRelations> & {
|
|
516
|
+
[K in Extract<keyof TRelations, keyof T>]?: RelationUpdatePayload<T[K], TRelations[K], M, K>;
|
|
517
|
+
};
|
|
518
|
+
|
|
491
519
|
type InjectedSave<
|
|
492
520
|
T, M extends Prisma.ModelName, Config, C extends BuildConfig<any> | undefined,
|
|
493
521
|
TSelects = ExtractSelectModels<Config>,
|
|
@@ -514,7 +542,7 @@ type InjectedPatch<
|
|
|
514
542
|
TSelects = ExtractSelectModels<Config>,
|
|
515
543
|
TDefault = ExtractDefaultSelect<Config>,
|
|
516
544
|
TPk = ExtractPkName<T, Config>,
|
|
517
|
-
|
|
545
|
+
TRelations = ExtractRelations<Config>
|
|
518
546
|
> = C extends { baseMethods: { patch: { active: false } } } ? {} : {
|
|
519
547
|
/**
|
|
520
548
|
* Atualiza parcialmente (patch) um registro existente pela chave primária (PK), aceita os campos de relações definidas nas `relations`.
|
|
@@ -524,11 +552,11 @@ type InjectedPatch<
|
|
|
524
552
|
* @returns O registro atualizado refinado conforme a entrada.
|
|
525
553
|
*/
|
|
526
554
|
patch<
|
|
527
|
-
O extends
|
|
555
|
+
O extends UpdateWithRelations<T, M, TRelations>,
|
|
528
556
|
S extends keyof TSelects | false = ResolveMethodDefaultSelect<Config, C, 'patch', TSelects>
|
|
529
557
|
>(
|
|
530
558
|
pk: T[TPk extends keyof T ? TPk : never],
|
|
531
|
-
obj: O &
|
|
559
|
+
obj: O & UpdateWithRelations<T, M, TRelations>,
|
|
532
560
|
options?: MethodOptions<S>
|
|
533
561
|
): Promise<RefineSaveResult<ResolveCurrentReturn<M, TSelects, S, TDefault>, O>>;
|
|
534
562
|
};
|
package/package.json
CHANGED
|
@@ -54,7 +54,9 @@ if (prismaArg.startsWith('-')) {
|
|
|
54
54
|
|
|
55
55
|
const outputDir = path.resolve(workspaceRoot, outputArg);
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const CLASSIC_PRISMA_GENERATED_PATH = "@prisma/client";
|
|
58
|
+
|
|
59
|
+
const prismaTargetPath = prismaArg === CLASSIC_PRISMA_GENERATED_PATH ? prismaArg : stripKnownExtension(
|
|
58
60
|
path.resolve(workspaceRoot, prismaArg, prismaArg.endsWith('client') ? '' : 'client')
|
|
59
61
|
);
|
|
60
62
|
|
|
@@ -97,7 +99,7 @@ for (const fileName of typeFiles) {
|
|
|
97
99
|
|
|
98
100
|
contents = contents.replace(
|
|
99
101
|
/from\s+(['"])@vsrepo\/prisma\/types\1/g,
|
|
100
|
-
`from '${relativeImportPath(path.dirname(targetFile), prismaTargetPath)}'`
|
|
102
|
+
`from '${prismaTargetPath === CLASSIC_PRISMA_GENERATED_PATH ? prismaTargetPath : relativeImportPath(path.dirname(targetFile), prismaTargetPath)}'`
|
|
101
103
|
);
|
|
102
104
|
|
|
103
105
|
fs.writeFileSync(targetFile, GENERATED_HEADER + contents, 'utf8');
|