2024-11-12

This commit is contained in:
gcch 2024-11-12 11:01:34 +01:00
commit 837e363983
42 changed files with 665 additions and 281 deletions

View file

@ -20,10 +20,10 @@
],
"integrity": "sha512-jq2VqkmFq7qCXj0sEA6g969jMAwRb8i2zXXVrNjRWFEn6hj7sc2kc30RK+UOtV5zpVHicKVw4wNzTuF5nIgLMg=="
},
"_exports.CC-TXtMY.js": {
"file": "exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js": {
"file": "exports.DtgtFHVi.js",
"name": "exports",
"integrity": "sha512-bSrqVHn9BIkA0TFVrSaiCGDRayEtV7f4ZV2OaYJAdlQh1CeZ/XfXYWq85NYMFKgCIHYBKPre90UTT/Izj6+MpA=="
"integrity": "sha512-4cRVLOnpaeyA6k5R693OlrBhMVC+rhYTAHtn0u4057IvKs0PfWmjhBN1wkaEYJqrmLuI4lbosNuCqW6umZGNbw=="
},
"_index-0eef19ec.DjnU1cik.js": {
"file": "index-0eef19ec.DjnU1cik.js",
@ -98,10 +98,10 @@
"isEntry": true,
"imports": [
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_pipe.XPB0wEfw.js"
],
"integrity": "sha512-pYDBYBYTf6LEtCD0h4GkoWYDWMVyHJekoz/ZqMpGDa8dVqLthzxhOK0VuHAKVmZ5hZJvxvR0JDtBVUrFvBhkWg=="
"integrity": "sha512-879kPDiJLnXB+lzNRxL4ShyFPUmbSM13BV6whvCU+Iz0FdNICq8HXYUoGXnvrYBALbphqpGgy0qgZq+7cJpvfw=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts": {
"file": "dom2.js",
@ -112,9 +112,9 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_pipe.XPB0wEfw.js",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js"
"_exports.DtgtFHVi.js"
],
"integrity": "sha512-FhtYjHwl+tHgopysAJ/f1rDIRjfNOV3DPX07qSuk3xh6Y3BBHzCGr8ZKRGDqYSzWjUws+6wcrxo7ZaZrYV3qXA=="
"integrity": "sha512-MkD15qSuTmRpn0Wx1vE9hEAZnI+sjDf3VUqaOoiLWWzY0ZVpxNXwgSb+WmvsEi/Qqh699j5U7cm80F/u0BfSfA=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts": {
"file": "erreurs.js",
@ -122,9 +122,9 @@
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"isEntry": true,
"imports": [
"_exports.CC-TXtMY.js"
"_exports.DtgtFHVi.js"
],
"integrity": "sha512-K3/MQL854WKYe1FJGCJ51Y7gTE18zxwVCTgseqEBNR19iP3+UR79eiNB0zLJoi1BUi371Oeu8hePPdvYXpv9ng=="
"integrity": "sha512-b8Bd2KjSABlP1YIg9Ye5YaSyPmlazvDe1MKBS89/Hy5Ao31Yrh7HXPu+qqnHXAvEvhL4H1wIZSEKBdp1nufxEg=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts": {
"file": "gardes.js",
@ -156,13 +156,13 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/cart.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/adresses.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts"
],
"integrity": "sha512-28cjov0z8XVvwAsU5x7h0J2f15YJbIinn1Oflw0A6408y0JN5l0V+jRneEvzOnT5V3pSl9rSix08qS/AXd/xLQ=="
"integrity": "sha512-QAXhm7cuT2COvlqofJVbZ4t+7eExXtBJxAnub6i0uZLAPWDiNsKlzLjj/xeaDFcwvGCGX+Lwezerw5YJ3qGW3w=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/nombres.ts": {
"file": "nombres.js",
@ -183,9 +183,9 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/erreurs.ts",
"_pipe.XPB0wEfw.js",
"_exports.CC-TXtMY.js"
"_exports.DtgtFHVi.js"
],
"integrity": "sha512-Mhpyz8V2btd3UhEEweV3WxO0/IVyPlxq2PWMgWMafZgpJvrl1QUbVwqh6AqLLd+6uKA2iD/zEJbaPwOj6CS3ng=="
"integrity": "sha512-Kleti69vNizn9p7F18Vp1FJkVEsO7QPWUn+mXM5KBtWe6k0TJsJ7Sk1FVX1sLrQc3d1Kg7uADDh+tGRRDs8oog=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/adresses.ts": {
"file": "adresses.js",
@ -345,9 +345,9 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_pipe.XPB0wEfw.js",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js"
"_exports.DtgtFHVi.js"
],
"integrity": "sha512-o5h1EX5TlSm1gV42TNFEMz7022mH7HcdY/NEsGepRMDbYB8VWu5Sz9048ORxJ/H095+WIfcRJ7e/9TB30v6VoQ=="
"integrity": "sha512-h9Qawq0Y7PDPsiOQHoVjkrZU5r8lm8xsFo7s/Nxgbz9/ndkiN9P5ikp/sBdIkBf+pfoVJp9x8txTY4ncAkssTw=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/validation.ts": {
"file": "validation.js",
@ -373,7 +373,7 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"_pipe.XPB0wEfw.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_Either.wHNxn7Os.js",
"_index.BulDzU6h.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
@ -382,7 +382,7 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/adresses.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts"
],
"integrity": "sha512-TlWb9/HtwkxtVePTieDoT1qm8a8rS0R2UBn7LESrqru3JiY2Ce5JV+3KpNORS7QqMVV7aUu+VmFx3oUKfyCEQA=="
"integrity": "sha512-iVzK9QmdXDUkfvUfJAq8Z1BKC6x1uDEwZiuPmHr9KHkbfXtukW7xKL5kOh8KSKrkg8M/k3Izj/uf/5Tashp6hw=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-menu-categories.ts": {
"file": "scripts-menu-categories.js",
@ -395,11 +395,11 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_pipe.XPB0wEfw.js",
"_Either.wHNxn7Os.js"
],
"integrity": "sha512-D8nIe3wUn3uHQayGooZfigrXoFTycse4zeOZqa1q7h5YE1W0sKLAtvejdhrE0af1eQH1Nsm+o1J5CyV0cse1xg=="
"integrity": "sha512-RAN+4IVXl0wdb8e7p/F6UW3U8BHX7KXRZO1YypbdHRTNh9HgJ3dz8fytDdz2jA3XdhczDnRCOTDqF3vL2BEb8g=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-menu-mobile.ts": {
"file": "scripts-menu-mobile.js",
@ -411,11 +411,11 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_pipe.XPB0wEfw.js",
"_Either.wHNxn7Os.js"
],
"integrity": "sha512-LrK0O2wQ84HB+YNhLw9UnwvQHPEKb4isq9EaZMT09Wij+gefVUz1kGF+RbN6IluKOecodJo/hmit2GWUQf9cpQ=="
"integrity": "sha512-x0vjlFuSXzr3AkvtWyF9Z1LwW+pGeoOwj8n9qYm+vqajMMTlxTwYpbvVe2mSE/6Xmj14lWKnLu4wrKiJOqLPVA=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-a-propos.ts": {
"file": "scripts-page-a-propos.js",
@ -429,10 +429,10 @@
"_pipe.XPB0wEfw.js",
"_belt_Option-91f3b350.D8kNxoqg.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_Either.wHNxn7Os.js"
],
"integrity": "sha512-6L+sjNDtJGBwNIh0DZFPOJKtzdJ3Pj3cAQTKDyp2WRViXgTyphWLx2sVXBQWNlnq4xJI5V/83pORfkeA2AKh3Q=="
"integrity": "sha512-Ot2NrjxvJ3ovohcl4cUxwsglsSVLEPYxcCEmqQjWSrKW+4Hh16ZYq0S6aGLAk4BPIJwlyJN1TcNt0Vnfr8d0DQ=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-accueil.ts": {
"file": "scripts-page-accueil.js",
@ -445,11 +445,11 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"_pipe.XPB0wEfw.js",
"_Either.wHNxn7Os.js"
],
"integrity": "sha512-JTLZdoTTMhjEstTmmsFjN73lDgyVA9pvCb+9XwLKb1iHzm6PaGF9YHUvp9t4+lgh3gpQDEiRFi9VFRClyTCNqA=="
"integrity": "sha512-U+g0gq1deXRSXexG36LTOEvslcFj5v5s+nolLMfJipuSkTHifUpNU+fSTpFTEEZBynQTybTnNuGImWW4cgGrCg=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-boutique.ts": {
"file": "scripts-page-boutique.js",
@ -471,12 +471,12 @@
"_pipe.XPB0wEfw.js",
"_index-0eef19ec.DjnU1cik.js",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/products.ts",
"_belt_Option-91f3b350.D8kNxoqg.js"
],
"integrity": "sha512-IUuSY/ktzVZNLq12AsQX50FUZvBfBIBtIa4DDQ4Im8rFnHshDKQQOUFBjt0UUh1kkPIgpAs78QWsCt9RKpSe9w=="
"integrity": "sha512-bJw/FzsilZIfynZiM/W28WEuC0YgZpgucFWIlA9t/V6G2/RZM36Q3zyQ3OdB/YCNW+eYX6zwzyzViQjuc/xSBw=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts": {
"file": "scripts-page-panier.js",
@ -505,7 +505,7 @@
"_pipe.XPB0wEfw.js",
"_index-0eef19ec.DjnU1cik.js",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/cart.ts",
@ -513,7 +513,7 @@
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/orders.ts",
"_belt_Option-91f3b350.D8kNxoqg.js"
],
"integrity": "sha512-gnMp8KBNko1qUjH0T3YzqDDBOweR+ZuyzgtjqilxyAbkJkn4AUqI02Q9UamHlBX8ok4xFUMYq4HsBw+dcm1BBg=="
"integrity": "sha512-bdh3hOkICfduk3ISqD6YxxdK3Ewons0zTpRzr8tQ9gCZi/ZKkpT1XFCHbOgo2+B9r8sd/tvSChTd1TE3zwlSfA=="
},
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts": {
"file": "scripts-page-produit.js",
@ -536,7 +536,7 @@
"_pipe.XPB0wEfw.js",
"_index-0eef19ec.DjnU1cik.js",
"_Either.wHNxn7Os.js",
"_exports.CC-TXtMY.js",
"_exports.DtgtFHVi.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/cart.ts",
@ -544,6 +544,6 @@
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts",
"_belt_Option-91f3b350.D8kNxoqg.js"
],
"integrity": "sha512-nLujlBQnjXSqSwLuLR/5lXVo9FTJ8STli+143KePsbKvoLihTMmv1DqFZGE8A1Ib6egh5fjzzp6qaUs1u+V5bg=="
"integrity": "sha512-+lzTczsVRFSM6Gq6iaA6O/Xj1vaR+nL6PZAoNkR0AZiCaPEZjQG9fE7G/OJTia+ZWEKMiwIMoYmKm/X87nTtiw=="
}
}

View file

@ -1,7 +1,7 @@
import { e as creeSyntaxError, f as reporteEtLeveErreur, g as ERREUR_SYNTAXE_INVALIDE, h as ERREUR_SELECTEUR_INEXISTANT } from "./erreurs.js";
import { e as creeSyntaxError, f as reporteEtLeveErreur, g as ErreurEntreeInexistante, h as ERREUR_SYNTAXE_INVALIDE, i as ERREUR_SELECTEUR_INEXISTANT } from "./erreurs.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { E as Either, r as right, l as left, M as Maybe } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
function int_compare(e, r) {
if (e < r) {
return -1;
@ -2033,7 +2033,7 @@ const html = (strings, ...args) => pipe(
(template) => majElementInnerHtml(template)(args.reduce((prev, value, i2) => prev + value + strings[i2 + 1], strings[0])),
(template) => template.content
);
const eitherSessionStorageGet = (cle) => Maybe.fromNullable(sessionStorage.getItem(cle)).toEither(new Error("Clé absente dans le stockage de session."));
const eitherSessionStorageGet = (cle) => Maybe.fromNullable(sessionStorage.getItem(cle)).toEither(ErreurEntreeInexistante(`Clé ${cle} absente dans le stockage de session.`));
const eitherJsonParse = (chaine) => Either.encase(() => JSON.parse(chaine));
export {
Ra as R,

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
import { c as captureException } from "./exports.CC-TXtMY.js";
import { c as captureException } from "./exports.DtgtFHVi.js";
const ERREUR_SYNTAXE_INVALIDE = (selecteur) => `Le selecteur "${selecteur}" est invalide`;
const ERREUR_SELECTEUR_INEXISTANT = (selecteur) => `La requête "${selecteur}" n'a retourné aucun Élément.`;
const creeSyntaxError = (message) => new SyntaxError(message);
@ -38,7 +38,14 @@ class CleNonTrouveError extends Error {
this.name = "CleNonTrouveError";
}
}
class NonExistingKeyError extends Error {
constructor(message) {
super(JSON.stringify(message));
this.name = "NonExistingKeyError";
}
}
const ErreurInconnue = (erreur) => new UnknownError(erreur);
const ErreurEntreeInexistante = (message) => new NonExistingKeyError(message);
const leveErreur = (erreur) => {
throw erreur;
};
@ -65,14 +72,15 @@ const reporteEtLeveErreur = (erreur) => {
export {
CleNonTrouveError as C,
ErreurInconnue as E,
leveBadRequestError as a,
leveUnauthorizedError as b,
leveNotFoundError as c,
leveErreur as d,
leveErreur as a,
leveBadRequestError as b,
leveUnauthorizedError as c,
leveNotFoundError as d,
creeSyntaxError as e,
reporteEtLeveErreur as f,
ERREUR_SYNTAXE_INVALIDE as g,
ERREUR_SELECTEUR_INEXISTANT as h,
ErreurEntreeInexistante as g,
ERREUR_SYNTAXE_INVALIDE as h,
ERREUR_SELECTEUR_INEXISTANT as i,
leveServerError as l,
reporteErreur as r
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -81,7 +81,7 @@ function safeJoin(input, delimiter) {
}
return output.join(delimiter);
}
const SDK_VERSION = "8.37.1";
const SDK_VERSION = "8.38.0";
const GLOBAL_OBJ = globalThis;
function getGlobalSingleton(name, creator, obj) {
const gbl = GLOBAL_OBJ;
@ -946,6 +946,40 @@ function generatePropagationContext() {
spanId: uuid4().substring(16)
};
}
const debugIdStackParserCache = /* @__PURE__ */ new WeakMap();
function getFilenameToDebugIdMap(stackParser) {
const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
if (!debugIdMap) {
return {};
}
let debugIdStackFramesCache;
const cachedDebugIdStackFrameCache = debugIdStackParserCache.get(stackParser);
if (cachedDebugIdStackFrameCache) {
debugIdStackFramesCache = cachedDebugIdStackFrameCache;
} else {
debugIdStackFramesCache = /* @__PURE__ */ new Map();
debugIdStackParserCache.set(stackParser, debugIdStackFramesCache);
}
return Object.keys(debugIdMap).reduce((acc, debugIdStackTrace) => {
let parsedStack;
const cachedParsedStack = debugIdStackFramesCache.get(debugIdStackTrace);
if (cachedParsedStack) {
parsedStack = cachedParsedStack;
} else {
parsedStack = stackParser(debugIdStackTrace);
debugIdStackFramesCache.set(debugIdStackTrace, parsedStack);
}
for (let i = parsedStack.length - 1; i >= 0; i--) {
const stackFrame = parsedStack[i];
const file = stackFrame && stackFrame.filename;
if (stackFrame && file) {
acc[file] = debugIdMap[debugIdStackTrace];
break;
}
}
return acc;
}, {});
}
const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
function getMainCarrier() {
getSentryCarrier(GLOBAL_OBJ);
@ -1970,41 +2004,8 @@ function applyClientOptions(event, options) {
request.url = truncate(request.url, maxValueLength);
}
}
const debugIdStackParserCache = /* @__PURE__ */ new WeakMap();
function applyDebugIds(event, stackParser) {
const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
if (!debugIdMap) {
return;
}
let debugIdStackFramesCache;
const cachedDebugIdStackFrameCache = debugIdStackParserCache.get(stackParser);
if (cachedDebugIdStackFrameCache) {
debugIdStackFramesCache = cachedDebugIdStackFrameCache;
} else {
debugIdStackFramesCache = /* @__PURE__ */ new Map();
debugIdStackParserCache.set(stackParser, debugIdStackFramesCache);
}
const filenameDebugIdMap = Object.entries(debugIdMap).reduce(
(acc, [debugIdStackTrace, debugIdValue]) => {
let parsedStack;
const cachedParsedStack = debugIdStackFramesCache.get(debugIdStackTrace);
if (cachedParsedStack) {
parsedStack = cachedParsedStack;
} else {
parsedStack = stackParser(debugIdStackTrace);
debugIdStackFramesCache.set(debugIdStackTrace, parsedStack);
}
for (let i = parsedStack.length - 1; i >= 0; i--) {
const stackFrame = parsedStack[i];
if (stackFrame.filename) {
acc[stackFrame.filename] = debugIdValue;
break;
}
}
return acc;
},
{}
);
const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
try {
event.exception.values.forEach((exception) => {
exception.stacktrace.frames.forEach((frame) => {
@ -2170,4 +2171,4 @@ export {
getIsolationScope as y,
isThenable as z
};
//# sourceMappingURL=exports.CC-TXtMY.js.map
//# sourceMappingURL=exports.DtgtFHVi.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
import { g as ENTETE_GLITCHTIP_RATE_LIMITS, h as ENTETE_GLITCHTIP_RETRY_AFTER } from "./api.js";
import { i as isInstanceOf, t as truncate, a as consoleSandbox, D as DEBUG_BUILD$1, l as logger, g as getFunctionName, G as GLOBAL_OBJ, C as CONSOLE_LEVELS, f as fill, o as originalConsoleMethods, b as timestampInSeconds, d as isError, e as addNonEnumerableProperty, r as rejectedSyncPromise, S as SyncPromise, h as resolvedSyncPromise, j as dropUndefinedKeys, n as normalize, k as dateTimestampInSeconds, m as DEBUG_BUILD$2, u as urlEncode, p as uuid4, q as checkOrSetAlreadyCaught, s as isPrimitive, v as updateSession, w as prepareEvent, x as getDynamicSamplingContextFromClient, y as getIsolationScope, z as isThenable, A as isPlainObject, B as isParameterizedString, E as SDK_VERSION, F as getClient, H as getOriginalFunction, I as getFramesFromEvent, J as addExceptionMechanism, K as isErrorEvent$1, L as isDOMError, M as isDOMException, N as addExceptionTypeValue, O as isEvent, P as normalizeToSize, Q as extractExceptionKeysForMessage, R as isString, T as createStackParser, U as UNKNOWN_FUNCTION, V as getEventDescription, W as htmlTreeAsString, X as safeJoin, Y as getComponentName, Z as captureEvent, _ as getLocationHref, $ as getCurrentScope } from "./exports.CC-TXtMY.js";
import { i as isInstanceOf, t as truncate, a as consoleSandbox, D as DEBUG_BUILD$1, l as logger, g as getFunctionName, G as GLOBAL_OBJ, C as CONSOLE_LEVELS, f as fill, o as originalConsoleMethods, b as timestampInSeconds, d as isError, e as addNonEnumerableProperty, r as rejectedSyncPromise, S as SyncPromise, h as resolvedSyncPromise, j as dropUndefinedKeys, n as normalize, k as dateTimestampInSeconds, m as DEBUG_BUILD$2, u as urlEncode, p as uuid4, q as checkOrSetAlreadyCaught, s as isPrimitive, v as updateSession, w as prepareEvent, x as getDynamicSamplingContextFromClient, y as getIsolationScope, z as isThenable, A as isPlainObject, B as isParameterizedString, E as SDK_VERSION, F as getClient, H as getOriginalFunction, I as getFramesFromEvent, J as addExceptionMechanism, K as isErrorEvent$1, L as isDOMError, M as isDOMException, N as addExceptionTypeValue, O as isEvent, P as normalizeToSize, Q as extractExceptionKeysForMessage, R as isString, T as createStackParser, U as UNKNOWN_FUNCTION, V as getEventDescription, W as htmlTreeAsString, X as safeJoin, Y as getComponentName, Z as captureEvent, _ as getLocationHref, $ as getCurrentScope } from "./exports.DtgtFHVi.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
function applyAggregateErrorsToEvent(exceptionFromErrorImplementation, parser, maxValueLimit = 250, key, limit, event, hint) {
if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@ import { N as NOM_CANAL_BOUTON_PANIER, T as TYPES_MESSAGES, a as NOM_CANAL_CONTE
import { r as reporteErreur } from "./erreurs.js";
import { M as MessageMajBoutonPanierSchema, a as MessageMajContenuPanierSchema } from "./messages2.js";
import { E as Either } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./cart.js";
import "./cart2.js";
import "./adresses.js";

View file

@ -1,10 +1,10 @@
import { z, N } from "./index.CeK6pfoJ.js";
import { p as parse } from "./index.BulDzU6h.js";
import { E as ENTETE_WC_NONCE } from "./api.js";
import { a as leveBadRequestError, b as leveUnauthorizedError, c as leveNotFoundError, E as ErreurInconnue, d as leveErreur } from "./erreurs.js";
import { b as leveBadRequestError, c as leveUnauthorizedError, d as leveNotFoundError, E as ErreurInconnue, a as leveErreur } from "./erreurs.js";
import { e as estWCError } from "./erreurs2.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
const getBackend = (args) => fetch(
`${args.route}?${args.searchParams}`,
{

File diff suppressed because one or more lines are too long

View file

@ -5,7 +5,7 @@ import { v as valideMessageMajBoutonPanier } from "./messages.js";
import { r as recupereElementDocumentEither } from "./utils.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import "./erreurs.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./Either.wHNxn7Os.js";
import "./index.BulDzU6h.js";
import "./messages2.js";

View file

@ -3,7 +3,7 @@ import { a as SELECTEUR_MENU_CATEGORIES_PRODUITS, b as SELECTEUR_ENTREE_MENU_CAT
import { a as recupereElementDansDocumentOuLeve, b as recupereElementsDansDocumentOuLeve } from "./utils.js";
import { R as Ra } from "./dom2.js";
import "./erreurs.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./pipe.XPB0wEfw.js";
import "./Either.wHNxn7Os.js";
document.addEventListener("DOMContentLoaded", () => {

View file

@ -5,7 +5,7 @@ import { R as SELECTEUR_BOUTON_MENU_MOBILE, T as SELECTEUR_MENU_MOBILE, U as ATT
import { a as recupereElementDansDocumentOuLeve } from "./utils.js";
import "./dom2.js";
import "./erreurs.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./pipe.XPB0wEfw.js";
import "./Either.wHNxn7Os.js";
const not = {

View file

@ -4,7 +4,7 @@ import { i as some, o as reduceU, q as nullable_to_opt, v as valFromOption, f as
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { _ as _1, i as is_extension, c as create, g as getExn, b as getWithDefault$1, d as isNone, a as isSome, f as flatMap$1, e as mapU, h as flatMapU, m as mapWithDefaultU } from "./belt_Option-91f3b350.D8kNxoqg.js";
import "./erreurs.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./Either.wHNxn7Os.js";
var t = create("Promise.JsError");
function $$catch(r, s) {

View file

@ -3,7 +3,7 @@ import { e as estEntreDeuxNombres } from "./nombres.js";
import { a as recupereElementDansDocumentOuLeve, b as recupereElementsDansDocumentOuLeve } from "./utils.js";
import "./dom2.js";
import "./erreurs.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./pipe.XPB0wEfw.js";
import "./Either.wHNxn7Os.js";
const initialiseScrollStorytelling = () => {

View file

@ -12,7 +12,7 @@ import { E as EitherAsync } from "./MaybeAsync.AE1jnxuc.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { t as tap } from "./index-0eef19ec.DjnU1cik.js";
import { E as Either } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./erreurs2.js";
import "./products2.js";
import "./belt_Option-91f3b350.D8kNxoqg.js";

View file

@ -4,7 +4,7 @@ import { a as ROUTE_API_RETIRE_ARTICLE_PANIER, b as ROUTE_API_MAJ_ARTICLE_PANIER
import { l as SELECTEUR_ENTREES_PANIER, m as SELECTEUR_CONTENEUR_PANIER, n as SELECTEUR_SOUS_TOTAL_PRODUITS, o as SELECTEUR_SOUS_TOTAL_LIVRAISON_COUT, p as SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE, q as SELECTEUR_TOTAL_PANIER, r as SELECTEUR_BOUTON_SEPARATION_ADRESSES, s as SELECTEUR_FORMULAIRE_PANIER, t as SELECTEUR_FORMULAIRE_FACTURATION, u as SELECTEUR_BOUTON_ACTIONS_FORMULAIRE, v as ATTRIBUT_CLE_PANIER, w as SELECTEUR_BOUTON_SOUSTRACTION_QUANTITE, x as SELECTEUR_CHAMP_QUANTITE_LIGNE_PANIER, y as SELECTEUR_BOUTON_ADDITION_QUANTITE, z as SELECTEUR_BOUTON_SUPPRESSION_PANIER, A as ATTRIBUT_CONTIENT_ARTICLES, B as SELECTEUR_PRIX_LIGNE_PANIER, k as ATTRIBUT_HIDDEN, C as ATTRIBUT_DESACTIVE } from "./dom.js";
import { N as NOM_CANAL_BOUTON_PANIER, a as NOM_CANAL_CONTENU_PANIER } from "./messages3.js";
import { r as recupereElementOuLeve, a as recupereElementsAvecSelecteur, e as eitherSessionStorageGet, b as eitherJsonParse, c as recupereElementAvecSelecteur } from "./dom2.js";
import { l as leveServerError, r as reporteErreur } from "./erreurs.js";
import { l as leveServerError, r as reporteErreur, a as leveErreur } from "./erreurs.js";
import { e as estReponse500, a as estError } from "./gardes.js";
import { e as emetMessageMajBoutonPanier, a as emetMessageMajContenuPanier, v as valideMessageMajBoutonPanier, b as valideMessageMajContenuPanier } from "./messages.js";
import { p as postBackend, t as traiteReponseBackendWCSelonCodesHTTP } from "./reseau.js";
@ -19,7 +19,7 @@ import { e as eitherParse } from "./validation.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { l } from "./index-0eef19ec.DjnU1cik.js";
import { M as Maybe, E as Either } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./messages2.js";
import "./erreurs2.js";
import "./cart2.js";
@ -365,20 +365,17 @@ const initialiseBoutonCreationCommande = () => {
BOUTON_ACTIONS_FORMULAIRE.textContent = "Submitting...";
}).ifJust(() => {
const donneesFormulaire = Object.fromEntries(new FormData(FORMULAIRE_PANIER));
const methodeLivraison = pipe(
eitherSessionStorageGet("shipping_rates"),
(chaine) => chaine.chain(eitherJsonParse),
(inconnu) => inconnu.chain(
(a) => eitherParse(
a,
WCStoreShippingRateShippingRateSchema
)
).ifLeft((e) => {
if (e instanceof ValiError) console.error(e.issues);
console.error(e);
throw e;
}).unsafeCoerce()
);
const methodeLivraison = eitherSessionStorageGet("shipping_rates").chain(eitherJsonParse).chain(
(json) => eitherParse(
json,
WCStoreShippingRateShippingRateSchema
)
).ifLeft((e) => {
if (e instanceof ValiError) console.error(e.issues);
console.error("methodeLivraison", e);
BOUTON_ACTIONS_FORMULAIRE.textContent = "Check-out";
leveErreur(e);
}).unsafeCoerce();
const articlesPanier = ENTREES_PANIER_EITHER.orDefault([]).map((entree) => ({
product_id: Number(entree.getAttribute("data-id-produit")),
quantity: Number(entree.getAttribute("data-quantite")),
@ -444,8 +441,11 @@ const initialiseBoutonCreationCommande = () => {
)
);
},
(reponse2) => reponse2.ifRight(() => {
window.location = "/checkout";
(reponse2) => reponse2.ifRight((r) => {
const url = new URL(`https://${window.location.host}/checkout`);
url.searchParams.append("order_key", r.order_key);
url.searchParams.append("order_id", String(r.id));
window.location = url;
}),
(reponse2) => reponse2.ifLeft((a) => console.error(a.issues))
);

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@ import { p as parse } from "./index.BulDzU6h.js";
import { e as ROUTE_API_AJOUTE_ARTICLE_PANIER, E as ENTETE_WC_NONCE } from "./api.js";
import { D as SELECTEUR_BOUTON_AJOUT_PANIER, E as SELECTEUR_SELECTEUR_QUANTITE, F as SELECTEUR_LIENS_ONGLETS, G as SELECTEUR_SECTIONS_CONTENUS, H as SELECTEUR_PRIX_PRODUIT, I as SELECTEUR_CONTENEUR_FLECHES_DEFILEMENT, J as SELECTEUR_FLECHE_DEFILEMENT_GAUCHE, K as SELECTEUR_FLECHE_DEFILEMENT_DROITE, L as SELECTEUR_PHOTOS_PRODUIT, M as SELECTEUR_IMAGE_COLONNE_GAUCHE, N as SELECTEUR_IMAGES_COLONNE_DROITE, O as ATTRIBUT_INDEX_IMAGE_ACTIVE, P as ATTRIBUT_ARIA_SELECTED, k as ATTRIBUT_HIDDEN, C as ATTRIBUT_DESACTIVE, Q as ATTRIBUT_PRIX } from "./dom.js";
import { r as recupereElementOuLeve, d as recupereElementsOuLeve, R as Ra } from "./dom2.js";
import { l as leveServerError, a as leveBadRequestError, b as leveUnauthorizedError, c as leveNotFoundError, E as ErreurInconnue, d as leveErreur, r as reporteErreur } from "./erreurs.js";
import { l as leveServerError, b as leveBadRequestError, c as leveUnauthorizedError, d as leveNotFoundError, E as ErreurInconnue, a as leveErreur, r as reporteErreur } from "./erreurs.js";
import { b as estHTMLSelectElement, e as estReponse500, a as estError } from "./gardes.js";
import { e as emetMessageMajBoutonPanier } from "./messages.js";
import { W as WCStoreCartSchema } from "./cart.js";
@ -13,7 +13,7 @@ import { r as recupereElementDocumentEither, a as recupereElementDansDocumentOuL
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { l } from "./index-0eef19ec.DjnU1cik.js";
import { M as Maybe, E as Either } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
import "./messages3.js";
import "./messages2.js";
import "./cart2.js";

View file

@ -2,7 +2,7 @@ import { j as values, k as fromArray, f as equal, l as get$1, u as unsafeDeleteK
import { C as CleNonTrouveError } from "./erreurs.js";
import { p as pipe } from "./pipe.XPB0wEfw.js";
import { M as Maybe } from "./Either.wHNxn7Os.js";
import "./exports.CC-TXtMY.js";
import "./exports.DtgtFHVi.js";
function placeholder(e) {
}
function makeEmpty(e) {

View file

@ -1 +1 @@
{"version":3,"file":"validation.js","sources":["../../src/scripts/lib/validation.ts"],"sourcesContent":["/**\n * Fonctions utilitaires de validation via Valibot.\n */\n\nimport { Either } from \"purify-ts\";\nimport { type GenericSchema, parse, type ValiError } from \"valibot\";\n\nexport const eitherParse = <Valeur, Schema extends GenericSchema<Valeur>>(\n valeur: unknown,\n schema: Schema,\n): Either<ValiError<Schema>, Valeur> => Either.encase(() => parse(schema, valeur));\n"],"names":[],"mappings":";;AAOa,MAAA,cAAc,CACzB,QACA,WACsC,OAAO,OAAO,MAAM,MAAM,QAAQ,MAAM,CAAC;"}
{"version":3,"file":"validation.js","sources":["../../src/scripts/lib/validation.ts"],"sourcesContent":["/**\n * Fonctions utilitaires de validation via Valibot.\n */\n\nimport { Either } from \"purify-ts\";\nimport { type GenericSchema, InferOutput, parse, type ValiError } from \"valibot\";\n\nexport const eitherParse = <Schema extends GenericSchema>(\n valeur: unknown,\n schema: Schema,\n): Either<ValiError<Schema>, InferOutput<Schema>> => Either.encase(() => parse(schema, valeur));\n"],"names":[],"mappings":";;AAOa,MAAA,cAAc,CACzB,QACA,WACmD,OAAO,OAAO,MAAM,MAAM,QAAQ,MAAM,CAAC;"}

View file

@ -7,7 +7,7 @@ declare(strict_types=1);
use Timber\Timber;
/* Contexte et modèles */
// Contexte et modèles
$contexte = Timber::context();
$modeles = ["accueil.twig"];
@ -29,5 +29,5 @@ function charge_scripts_styles_page_accueil(): void {
}
add_action("wp_enqueue_scripts", "charge_scripts_styles_page_accueil");
/* Rendu */
// Rendu
Timber::render(filenames: $modeles, data: $contexte);

View file

@ -5,6 +5,7 @@
declare(strict_types=1);
use Ramsey\Uuid\Uuid;
use Roots\WPConfig\Config;
header("Content-Type: application/json; charset=utf-8");
@ -16,6 +17,10 @@ $session_wc = WC()->session;
$possede_session_wc = $session_wc->has_session();
/** @var string */
$url_accueil = get_page_link(get_page_by_path("home")->ID);
/** @var string */
$url_succes_commande = get_page_link(get_page_by_path("successful-order"));
/** @var string */
$url_echec_commande = get_page_link(get_page_by_path("failed-order"));
// Retourne une 403 si l'Utilisateur n'a pas de session WooCommerce
if (!$possede_session_wc) {
@ -61,16 +66,60 @@ foreach ($panier->get_cart() as $cle_panier => $article_panier) {
]);
}
$order_id = $_GET["order_id"];
if (!$order_id) {
$reponse = ["succes" => false, "status" => "order_key is missing"];
echo json_encode($reponse);
http_response_code(400);
return;
}
$order_key = $_GET["order_key"];
if (!$order_key) {
$reponse = ["succes" => false, "status" => "order_key is missing"];
echo json_encode($reponse);
http_response_code(400);
return;
}
/** @var WC_Order */
$order = wc_get_order($order_id);
$methode_livraison = [
"nom" => $order->get_shipping_method(),
"cout" => $order->get_shipping_total(),
];
// Sélectionne la clé API Stripe
\Stripe\Stripe::setApiKey(Config::get("STRIPE_API_SECRET"));
$session_checkout_stripe = \Stripe\Checkout\Session::create([
"cancel_url" => $url_accueil,
"customer_email" => $email_client,
"line_items" => $articles,
"mode" => "payment",
"success_url" => $url_accueil,
]);
$session_checkout_stripe = \Stripe\Checkout\Session::create(
[
"cancel_url" => "$url_accueil",
"customer_email" => $email_client,
"line_items" => $articles,
"mode" => "payment",
"success_url" => "$url_succes_commande?session_id={CHECKOUT_SESSION_ID}",
"metadata" => [
"order_id" => $order_id,
"order_key" => $order_key,
],
"shipping_options" => [
[
"shipping_rate_data" => [
"display_name" => $methode_livraison["nom"],
"fixed_amount" => [
"amount" => $methode_livraison["cout"],
"currency" => "EUR",
],
"tax_behavior" => "inclusive",
"type" => "fixed_amount",
],
],
],
],
[
"idempotency_key" => Uuid::uuid4(),
],
);
// echo json_encode($session_checkout_stripe);
header("HTTP/1.1 303 See Other");
header("Location: " . $session_checkout_stripe->url);

View file

@ -1,6 +0,0 @@
<?php
/**
* Route pour la préparation du paiement via Stripe (« Checkout »)
*/
declare(strict_types=1);

View file

@ -0,0 +1,47 @@
<?php
/**
* Route pour la préparation du paiement via Stripe (« Checkout »)
*/
declare(strict_types=1);
use Roots\WPConfig\Config;
use Timber\Timber;
/** @var string */
$url_accueil = get_page_link(get_page_by_path("home")->ID);
/** @var string */
$session_id = $_GET["session_id"];
// Redirige à l'Accueil si le paramètre d'ID de Session Stripe n'est pas présent
if (!$session_id) {
header("Location: $url_accueil");
return;
}
// Instancie un Client Stripe
$client_stripe = new \Stripe\StripeClient(Config::get("STRIPE_API_SECRET"));
try {
$session = $client_stripe->checkout->sessions->retrieve($session_id);
$order_id = $session->metadata["order_id"];
$commande = wc_get_order("$order_id");
// Contexte et modèles
$contexte = Timber::context();
$modeles = ["succes-commande.twig"];
echo "<pre>";
print_r($session);
print_r($commande);
echo "</pre>";
http_response_code(200);
// Rendu
Timber::render(filenames: $modeles, data: $contexte);
} catch (Error $e) {
http_response_code(500);
echo json_encode(["error" => $e->getMessage()]);
}

View file

@ -73,10 +73,12 @@ class StarterSite extends Site {
"about" => $recupere_informations_page("about"),
"account" => $recupere_informations_page("account"),
"cart" => $recupere_informations_page("cart"),
"contact" => $recupere_informations_page("contact"),
"checkout" => $recupere_informations_page("checkout"),
"contact" => $recupere_informations_page("contact"),
"failed_order" => $recupere_informations_page("failed_order"),
"home" => $recupere_informations_page("home"),
"shop" => $recupere_informations_page("shop"),
"successful_order" => $recupere_informations_page("successful_order"),
];
// Récupère la Page courante

View file

@ -3,7 +3,14 @@ import { Either, identity, Left, Maybe, Right } from "purify-ts";
import type { ElementParent } from "./types/dom.d.ts";
import { creeSyntaxError, ERREUR_SELECTEUR_INEXISTANT, ERREUR_SYNTAXE_INVALIDE, reporteEtLeveErreur } from "./erreurs";
import {
creeSyntaxError,
ERREUR_SELECTEUR_INEXISTANT,
ERREUR_SYNTAXE_INVALIDE,
ErreurEntreeInexistante,
type NonExistingKeyError,
reporteEtLeveErreur,
} from "./erreurs";
/**
* @param parent L'Élément parent dans lequel l'Élément souhaité sera recherché.
@ -102,14 +109,15 @@ export const html = (strings: TemplateStringsArray, ...args: Array<string>) =>
/**
* Récupère une entrée dans le Stockage de Session (`storageSession`) sous forme d'`Either`.
*
* @param cle La clé de l'entrée.
* @returns Un `Either` avec une erreur si la clé est absente (`Left`), la valeur de l'entrée sinon
* (`Right`).
* @returns Un `Either` avec une `NonExistingKeyError` si la clé est absente (`Left`), la
* valeur de l'entrée sinon (`Right`).
*/
export const eitherSessionStorageGet = (cle: string): Either<Error, string> =>
export const eitherSessionStorageGet = (cle: string): Either<NonExistingKeyError, string> =>
Maybe
.fromNullable(sessionStorage.getItem(cle))
.toEither(new Error("Clé absente dans le stockage de session."));
.toEither(ErreurEntreeInexistante(`Clé ${cle} absente dans le stockage de session.`));
/**
* Convertis une chaîne JSON en un objet JavaScript sous forme d'`Either`.

View file

@ -2,7 +2,6 @@
* Fonctions pour la création d'Erreurs.
*/
import { pipe } from "@mobily/ts-belt";
import { captureException } from "@sentry/browser";
import type { WCErrorBody } from "./types/api/erreurs";
@ -58,10 +57,17 @@ export class CleNonTrouveError extends Error {
this.name = "CleNonTrouveError";
}
}
export class NonExistingKeyError extends Error {
constructor(message: unknown) {
super(JSON.stringify(message));
this.name = "NonExistingKeyError";
}
}
/* Fonction utilitaire pour créer ou lever des Erreurs */
export const Erreur = (message: string): Error => new Error(message);
export const ErreurInconnue = (erreur: unknown): UnknownError => new UnknownError(erreur);
export const ErreurEntreeInexistante = (message: string): NonExistingKeyError => new NonExistingKeyError(message);
export const leveErreur = <E extends Error = Error>(erreur: E): never => {
throw erreur;
@ -81,6 +87,9 @@ export const leveServerError = (message: string): never => {
export const leveUnknownError = (erreur: unknown): never => {
throw new UnknownError(erreur);
};
export const leveNonExistingKeyError = (message: string): never => {
throw new NonExistingKeyError(message);
};
/**
* Reporte une Erreur, sous forme d'erreur console et au service GlitchTip.
@ -88,7 +97,6 @@ export const leveUnknownError = (erreur: unknown): never => {
* @param erreur
* @returns L'ID Sentry de l'évènement capturé.
*/
export const reporteErreur = <E extends Error>(erreur: E): string => {
console.error(erreur);
return captureException(erreur);
@ -101,19 +109,7 @@ export const reporteErreur = <E extends Error>(erreur: E): string => {
* @param erreur
* @returns never Lève une Erreur et ne retourne donc rien.
*/
export const reporteEtLeveErreur = <E extends Error>(erreur: E): never => {
reporteErreur<E>(erreur);
throw erreur;
};
/**
* Fonction utilitaire pour rapidement créer et reporter une Erreur DOMElementAbsent.
*
* @param message
* @returns L'ID Sentry de l'évènement capturé.
*/
export const reporteErreurDOMElementAbsent = (message: string): string =>
pipe(
new DOMElementAbsentError(message),
reporteErreur,
);

View file

@ -1,14 +1,18 @@
import { pipe } from "@mobily/ts-belt";
import { Either } from "purify-ts";
import { match, P } from "ts-pattern";
import { type GenericSchema, parse } from "valibot";
import { type GenericSchema, parse, type ValiError } from "valibot";
import { ENTETE_WC_NONCE } from "../constantes/api.ts";
import {
type BadRequestError,
ErreurInconnue,
leveBadRequestError,
leveErreur,
leveNotFoundError,
leveUnauthorizedError,
type NotFoundError,
type UnauthorizedError,
type UnknownError,
} from "./erreurs.ts";
import { estWCError } from "./schemas/api/erreurs.ts";
@ -70,6 +74,8 @@ export const postBackend = (args: ArgumentsPostBackendWC) =>
},
);
// TODO: Ne traite pas du tout les Erreurs
// TODO: Utiliser un Either
export const traiteReponseBackendWCSelonCodesHTTP = <R, S extends GenericSchema<R>>(
corpsReponse: unknown,
schemaReponse: S,
@ -83,3 +89,23 @@ export const traiteReponseBackendWCSelonCodesHTTP = <R, S extends GenericSchema<
.with(P._, corpsOkInconnu => parse<S>(schemaReponse, corpsOkInconnu))
// Réponses inconnues
.otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>));
type TraitementReponseBackend<R, S extends GenericSchema<R>> = Either<
BadRequestError | NotFoundError | UnauthorizedError | UnknownError | ValiError<S>,
R
>;
export const eitherTraiteReponseBackend = <R, S extends GenericSchema<R>>(
corpsReponse: unknown,
schemaReponse: S,
): TraitementReponseBackend<R, S> =>
Either.encase(() =>
match(corpsReponse)
.with({ body: P.select(), status: 400 }, estWCError, leveBadRequestError)
.with({ body: P.select(), status: 401 }, estWCError, leveUnauthorizedError)
.with({ body: P.select(), status: 404 }, estWCError, leveNotFoundError)
// Réponse OK (201)
.with(P._, corpsOkInconnu => parse<S>(schemaReponse, corpsOkInconnu))
// Réponses inconnues
.otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>))
);

View file

@ -3,9 +3,9 @@
*/
import { Either } from "purify-ts";
import { type GenericSchema, parse, type ValiError } from "valibot";
import { type GenericSchema, InferOutput, parse, type ValiError } from "valibot";
export const eitherParse = <Valeur, Schema extends GenericSchema<Valeur>>(
export const eitherParse = <Schema extends GenericSchema>(
valeur: unknown,
schema: Schema,
): Either<ValiError<Schema>, Valeur> => Either.encase(() => parse(schema, valeur));
): Either<ValiError<Schema>, InferOutput<Schema>> => Either.encase(() => parse(schema, valeur));

View file

@ -46,7 +46,7 @@ import {
recupereElementOuLeve,
recupereElementsAvecSelecteur,
} from "./lib/dom.ts";
import { type CleNonTrouveError, leveServerError, reporteErreur } from "./lib/erreurs.ts";
import { type CleNonTrouveError, leveErreur, leveServerError, reporteErreur } from "./lib/erreurs.ts";
import { estError, estReponse500 } from "./lib/gardes.ts";
import {
emetMessageMajBoutonPanier,
@ -562,7 +562,9 @@ const initialiseBoutonActions = (): void => {
const initialiseBoutonCreationCommande = (): void => {
// Permet de supprimer tout Écouteur d'Évènement assigné au Bouton
BOUTON_ACTIONS_FORMULAIRE.outerHTML = BOUTON_ACTIONS_FORMULAIRE.outerHTML;
// Réassigne le Bouton
BOUTON_ACTIONS_FORMULAIRE = recupereElementDansDocumentOuLeve<HTMLButtonElement>(SELECTEUR_BOUTON_ACTIONS_FORMULAIRE);
// Créé la Commande au clic sur le Bouton
BOUTON_ACTIONS_FORMULAIRE.addEventListener("click", (evenement: Event) => {
Maybe
// Ne fais rien si le Formulaire n'est pas valide
@ -572,38 +574,34 @@ const initialiseBoutonCreationCommande = (): void => {
BOUTON_ACTIONS_FORMULAIRE.textContent = "Submitting...";
})
.ifJust(() => {
// Récupère les données du Formulaire
const donneesFormulaire: Record<string, string> = Object.fromEntries(new FormData(FORMULAIRE_PANIER)) as Record<
string,
string
>;
// Récupère les données du Formulaire sous forme d'Objet
const donneesFormulaire = Object.fromEntries(new FormData(FORMULAIRE_PANIER)) as Record<string, string>;
const methodeLivraison = pipe(
eitherSessionStorageGet("shipping_rates"),
chaine => chaine.chain(eitherJsonParse),
inconnu =>
inconnu
.chain(a =>
eitherParse<WCStoreShippingRateShippingRate, typeof WCStoreShippingRateShippingRateSchema>(
a,
WCStoreShippingRateShippingRateSchema,
)
)
.ifLeft(e => {
if (e instanceof ValiError) console.error(e.issues);
console.error(e);
throw e;
})
.unsafeCoerce(),
);
const methodeLivraison: WCStoreShippingRateShippingRate = eitherSessionStorageGet("shipping_rates")
.chain(eitherJsonParse)
.chain((json: JSONValue) =>
eitherParse<typeof WCStoreShippingRateShippingRateSchema>(
json,
WCStoreShippingRateShippingRateSchema,
)
)
.ifLeft(e => {
if (e instanceof ValiError) console.error(e.issues);
console.error("methodeLivraison", e);
BOUTON_ACTIONS_FORMULAIRE.textContent = "Check-out";
leveErreur(e);
})
.unsafeCoerce();
const articlesPanier = ENTREES_PANIER_EITHER.orDefault([]).map(entree => ({
product_id: Number(entree.getAttribute("data-id-produit")),
quantity: Number(entree.getAttribute("data-quantite")),
...(entree.getAttribute("data-id-variation") && {
variation_id: Number(entree.getAttribute("data-id-variation")),
}),
}));
const articlesPanier = ENTREES_PANIER_EITHER
.orDefault([])
.map((entree: HTMLElement) => ({
product_id: Number(entree.getAttribute("data-id-produit")),
quantity: Number(entree.getAttribute("data-quantite")),
...(entree.getAttribute("data-id-variation") && {
variation_id: Number(entree.getAttribute("data-id-variation")),
}),
}));
const argumentsFormulaire: WCV3OrdersArgs = {
billing: {
@ -643,7 +641,7 @@ const initialiseBoutonCreationCommande = (): void => {
};
console.debug(argumentsFormulaire);
eitherParse<WCV3OrdersArgs, typeof WCV3OrdersArgsSchema>(argumentsFormulaire, WCV3OrdersArgsSchema)
eitherParse<typeof WCV3OrdersArgsSchema>(argumentsFormulaire, WCV3OrdersArgsSchema)
.map(async (args: WCV3OrdersArgs) => {
await postBackend({
authString: ETATS_PAGE.authString,
@ -668,8 +666,11 @@ const initialiseBoutonCreationCommande = (): void => {
);
},
reponse =>
reponse.ifRight(() => {
window.location = "/checkout";
reponse.ifRight(r => {
const url = new URL(`https://${window.location.host}/checkout`);
url.searchParams.append("order_key", r.order_key);
url.searchParams.append("order_id", String(r.id));
window.location = url;
}),
reponse => reponse.ifLeft(a => console.error(a.issues)),
);

View file

@ -0,0 +1,17 @@
{% extends "base.twig" %}
{% block contenu %}
<main id="page-success-commande">
<div class="contenu">
<header class="contenu__en-tete">
<h2>Successful order!</h2>
</header>
<div class="contenu__textuel">
<p>
<h1>Thanks for your order, {{ session.name }}!</h1>
</p>
</div>
</div>
</main>
{% endblock contenu %}