Compare commits

..

13 Commits

Author SHA1 Message Date
88a9b70d53 Actualiser .github/workflows/ci.yml
Some checks failed
CI / build (push) Has been cancelled
CI / build (pull_request) Failing after 40s
2025-11-21 23:37:44 +00:00
550882b803 Actualiser env.example
Some checks failed
CI / build (pull_request) Has been cancelled
CI / build (push) Has been cancelled
2025-11-21 23:15:48 +00:00
be2f359ab6 revert 7fe6d0db4b
Some checks failed
CI / build (push) Has been cancelled
CI / build (pull_request) Has been cancelled
revert Actualiser .github/workflows/ci.yml
2025-11-21 23:12:26 +00:00
e8fa5f8bc6 revert 7fe6d0db4b
Some checks failed
CI / build (pull_request) Has been cancelled
CI / build (push) Has been cancelled
revert Actualiser .github/workflows/ci.yml
2025-11-21 23:11:37 +00:00
68e2823d64 revert 1cbf066658
Some checks failed
CI / build (push) Has been cancelled
CI / build (pull_request) Has been cancelled
revert Actualiser .github/workflows/ci.yml
2025-11-21 23:09:36 +00:00
e977bd83bd Actualiser .github/workflows/ci.yml
Some checks failed
CI / build (push) Has been cancelled
CI / build (pull_request) Has been cancelled
2025-11-21 22:10:19 +00:00
7fe6d0db4b Actualiser .github/workflows/ci.yml
Some checks failed
CI / build (pull_request) Has been cancelled
CI / build (push) Failing after 26s
2025-11-21 20:26:55 +00:00
ccd3e38346 Actualiser .github/workflows/ci.yml
Some checks failed
CI / build (push) Failing after 1m51s
2025-11-21 19:36:31 +00:00
1cbf066658 Actualiser .github/workflows/ci.yml 2025-11-21 19:35:31 +00:00
b732944f7a Supprimer .woodpecker.yml 2025-11-21 19:34:52 +00:00
9044560833 Actualiser .woodpecker.yml
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
2025-11-21 19:09:18 +00:00
Matthieu
e2c7165c8c Test CI OK
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/manual/woodpecker Pipeline is pending
2025-11-21 17:39:16 +01:00
Matthieu
4bfa21d4b3 Test CI Woodpecker 2025-11-21 17:37:10 +01:00
4 changed files with 15 additions and 123 deletions

View File

@@ -1,8 +0,0 @@
steps:
test:
image: alpine
commands:
- echo "Woodpecker CI fonctionne parfaitement !"
- uname -a
- ls -la

View File

@@ -1,7 +1,7 @@
# Configuration de la base de données # Configuration de la base de données
DATABASE_URL="postgresql://postgres:password@localhost:5432/inventory_db" DATABASE_URL="postgresql://postgres:password@localhost:5432/inventory_db"
# Configuration du serveur # Configuration du serveurte
PORT=3000 PORT=3000
NODE_ENV=development NODE_ENV=development

View File

@@ -1,10 +1,7 @@
import { ConflictException, Injectable } from '@nestjs/common'; import { ConflictException, Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client'; import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service'; import { PrismaService } from '../prisma/prisma.service';
import { import { syncConstructeurLinks } from '../common/utils/constructeur-link.util';
fetchConstructeurIds,
syncConstructeurLinks,
} from '../common/utils/constructeur-link.util';
import { CreatePieceDto, UpdatePieceDto } from '../shared/dto/piece.dto'; import { CreatePieceDto, UpdatePieceDto } from '../shared/dto/piece.dto';
import { PieceModelStructureSchema } from '../shared/schemas/inventory'; import { PieceModelStructureSchema } from '../shared/schemas/inventory';
import type { PieceModelStructure } from '../shared/types/inventory'; import type { PieceModelStructure } from '../shared/types/inventory';
@@ -123,39 +120,30 @@ export class PiecesService {
include: PIECE_WITH_RELATIONS_INCLUDE, include: PIECE_WITH_RELATIONS_INCLUDE,
}); });
if (!refreshed) { if (refreshed && syncedConstructeurIds.length > 0) {
return null; (
refreshed as typeof refreshed & { constructeurIds?: string[] }
).constructeurIds = [...syncedConstructeurIds];
} }
const mapped = await this.mapPiece(refreshed); return refreshed;
if (syncedConstructeurIds.length > 0) {
mapped.constructeurIds = [...syncedConstructeurIds];
}
return mapped;
} catch (error) { } catch (error) {
this.handlePrismaError(error); this.handlePrismaError(error);
} }
} }
async findAll() { async findAll() {
const items = await this.prisma.piece.findMany({ return this.prisma.piece.findMany({
include: PIECE_WITH_RELATIONS_INCLUDE, include: PIECE_WITH_RELATIONS_INCLUDE,
orderBy: { name: 'asc' }, orderBy: { name: 'asc' },
}); });
const hydrated = await Promise.all(items.map((piece) => this.mapPiece(piece)));
return hydrated;
} }
async findOne(id: string) { async findOne(id: string) {
const piece = await this.prisma.piece.findUnique({ return this.prisma.piece.findUnique({
where: { id }, where: { id },
include: PIECE_WITH_RELATIONS_INCLUDE, include: PIECE_WITH_RELATIONS_INCLUDE,
}); });
if (!piece) {
return null;
}
return this.mapPiece(piece);
} }
async update(id: string, updatePieceDto: UpdatePieceDto) { async update(id: string, updatePieceDto: UpdatePieceDto) {
@@ -229,16 +217,13 @@ export class PiecesService {
include: PIECE_WITH_RELATIONS_INCLUDE, include: PIECE_WITH_RELATIONS_INCLUDE,
}); });
if (!refreshed) { if (refreshed && syncedConstructeurIds) {
return null; (
refreshed as typeof refreshed & { constructeurIds?: string[] }
).constructeurIds = [...syncedConstructeurIds];
} }
const mapped = await this.mapPiece(refreshed); return refreshed;
if (syncedConstructeurIds) {
mapped.constructeurIds = [...syncedConstructeurIds];
}
return mapped;
} catch (error) { } catch (error) {
this.handlePrismaError(error); this.handlePrismaError(error);
} }
@@ -683,43 +668,6 @@ export class PiecesService {
} }
return false; return false;
} }
private async mapPiece(piece: any) {
const idsFromConstructeurs = Array.isArray(piece.constructeurs)
? piece.constructeurs
.map((c) => (c && typeof c.id === 'string' ? c.id : null))
.filter((id): id is string => Boolean(id))
: [];
const idsFromPayload = Array.isArray(piece.constructeurIds)
? piece.constructeurIds
.map((value) => (typeof value === 'string' ? value.trim() : ''))
.filter((value) => value.length > 0)
: [];
let ids = Array.from(new Set([...idsFromConstructeurs, ...idsFromPayload]));
if (!ids.length) {
ids = await fetchConstructeurIds(
this.prisma,
'_PieceConstructeurs',
piece.id,
);
}
let constructeurs = piece.constructeurs;
if ((!constructeurs || !constructeurs.length) && ids.length) {
constructeurs = await this.prisma.constructeur.findMany({
where: { id: { in: ids } },
});
}
return {
...piece,
constructeurs,
constructeurIds: ids,
};
}
} }
type PieceTypeWithSkeleton = Prisma.ModelTypeGetPayload<{ type PieceTypeWithSkeleton = Prisma.ModelTypeGetPayload<{

View File

@@ -301,57 +301,9 @@ export class ProductsService {
} }
private mapProduct(product: ProductWithRelations) { private mapProduct(product: ProductWithRelations) {
const constructeurs = Array.isArray(product.constructeurs)
? product.constructeurs
.map((constructeur) => {
if (!constructeur || typeof constructeur !== 'object') {
return null;
}
const { id, name, email, phone, createdAt, updatedAt } =
constructeur as {
id?: string;
name?: string | null;
email?: string | null;
phone?: string | null;
createdAt?: Date;
updatedAt?: Date;
};
if (!id) {
return null;
}
return {
id,
name: name ?? null,
email: email ?? null,
phone: phone ?? null,
createdAt: createdAt ?? null,
updatedAt: updatedAt ?? null,
};
})
.filter(
(entry): entry is {
id: string;
name: string | null;
email: string | null;
phone: string | null;
createdAt: Date | null;
updatedAt: Date | null;
} => Boolean(entry),
)
: [];
const constructeurIds = constructeurs.map((item) => item.id);
const constructeursLabel = constructeurs
.map((item) => (item.name || '').trim())
.filter((name) => name.length > 0)
.join(', ');
return { return {
...product, ...product,
constructeurs, constructeurIds: product.constructeurs.map((item) => item.id),
constructeurIds,
constructeursLabel: constructeursLabel || null,
}; };
} }