@open-mercato/core 0.6.5-develop.4498.1.55dc06a57c → 0.6.5-develop.4516.1.88e6ab71a9
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.
package/.turbo/turbo-build.log
CHANGED
|
@@ -12,6 +12,54 @@ async function createCurrencyFixture(request, token, input) {
|
|
|
12
12
|
expect(typeof body.id === "string" && body.id.length > 0).toBeTruthy();
|
|
13
13
|
return body.id;
|
|
14
14
|
}
|
|
15
|
+
const SEEDED_CURRENCY_CODES = /* @__PURE__ */ new Set([
|
|
16
|
+
"USD",
|
|
17
|
+
"EUR",
|
|
18
|
+
"JPY",
|
|
19
|
+
"GBP",
|
|
20
|
+
"CHF",
|
|
21
|
+
"CAD",
|
|
22
|
+
"AUD",
|
|
23
|
+
"CNY",
|
|
24
|
+
"CNH",
|
|
25
|
+
"PLN"
|
|
26
|
+
]);
|
|
27
|
+
const reservedCurrencyCodes = /* @__PURE__ */ new Set();
|
|
28
|
+
function generateUniqueCurrencyCode() {
|
|
29
|
+
const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
|
30
|
+
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
31
|
+
const code = `${letter()}${letter()}${letter()}`;
|
|
32
|
+
if (!SEEDED_CURRENCY_CODES.has(code) && !reservedCurrencyCodes.has(code)) {
|
|
33
|
+
reservedCurrencyCodes.add(code);
|
|
34
|
+
return code;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw new Error("[internal] exhausted unique currency code space");
|
|
38
|
+
}
|
|
39
|
+
async function createRandomCurrencyFixture(request, token, input) {
|
|
40
|
+
const { organizationId, tenantId } = getTokenContext(token);
|
|
41
|
+
let lastStatus = 0;
|
|
42
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
43
|
+
const code = generateUniqueCurrencyCode();
|
|
44
|
+
const data = {
|
|
45
|
+
organizationId,
|
|
46
|
+
tenantId,
|
|
47
|
+
code,
|
|
48
|
+
name: input.name,
|
|
49
|
+
symbol: input.symbol ?? null
|
|
50
|
+
};
|
|
51
|
+
if (typeof input.isActive === "boolean") data.isActive = input.isActive;
|
|
52
|
+
const response = await apiRequest(request, "POST", "/api/currencies/currencies", { token, data });
|
|
53
|
+
if (response.status() === 201) {
|
|
54
|
+
const body = await response.json();
|
|
55
|
+
if (typeof body.id === "string" && body.id.length > 0) {
|
|
56
|
+
return { id: body.id, code };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
lastStatus = response.status();
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`[internal] failed to create currency fixture after retries (last status ${lastStatus})`);
|
|
62
|
+
}
|
|
15
63
|
async function createFetchConfigFixture(request, token, input) {
|
|
16
64
|
const response = await apiRequest(request, "POST", "/api/currencies/fetch-configs", {
|
|
17
65
|
token,
|
|
@@ -34,6 +82,8 @@ async function deleteCurrenciesEntityIfExists(request, token, path, id) {
|
|
|
34
82
|
export {
|
|
35
83
|
createCurrencyFixture,
|
|
36
84
|
createFetchConfigFixture,
|
|
37
|
-
|
|
85
|
+
createRandomCurrencyFixture,
|
|
86
|
+
deleteCurrenciesEntityIfExists,
|
|
87
|
+
generateUniqueCurrencyCode
|
|
38
88
|
};
|
|
39
89
|
//# sourceMappingURL=currenciesFixtures.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/integration/currenciesFixtures.ts"],
|
|
4
|
-
"sourcesContent": ["import { expect, type APIRequestContext } from '@playwright/test';\nimport { apiRequest } from './api';\nimport { getTokenContext } from './generalFixtures';\n\nexport async function createCurrencyFixture(\n request: APIRequestContext,\n token: string,\n input: { code: string; name: string; symbol?: string },\n): Promise<string> {\n const { organizationId, tenantId } = getTokenContext(token);\n const response = await apiRequest(request, 'POST', '/api/currencies/currencies', {\n token,\n data: { organizationId, tenantId, code: input.code, name: input.name, symbol: input.symbol ?? null },\n });\n expect(response.ok(), `Failed to create currency fixture: ${response.status()}`).toBeTruthy();\n const body = (await response.json()) as { id?: string };\n expect(typeof body.id === 'string' && body.id.length > 0).toBeTruthy();\n return body.id as string;\n}\n\nexport async function createFetchConfigFixture(\n request: APIRequestContext,\n token: string,\n input: { provider: string; isEnabled: boolean },\n): Promise<string> {\n const response = await apiRequest(request, 'POST', '/api/currencies/fetch-configs', {\n token,\n data: input,\n });\n expect(response.ok(), `Failed to create fetch config fixture: ${response.status()}`).toBeTruthy();\n const body = (await response.json()) as { config?: { id?: string } };\n const id = body.config?.id;\n expect(typeof id === 'string' && id.length > 0).toBeTruthy();\n return id as string;\n}\n\nexport async function deleteCurrenciesEntityIfExists(\n request: APIRequestContext,\n token: string | null,\n path: string,\n id: string | null,\n): Promise<void> {\n if (!token || !id) return;\n try {\n await apiRequest(request, 'DELETE', `${path}?id=${encodeURIComponent(id)}`, { token });\n } catch {\n return;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAsC;AAC/C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,eAAsB,sBACpB,SACA,OACA,OACiB;AACjB,QAAM,EAAE,gBAAgB,SAAS,IAAI,gBAAgB,KAAK;AAC1D,QAAM,WAAW,MAAM,WAAW,SAAS,QAAQ,8BAA8B;AAAA,IAC/E;AAAA,IACA,MAAM,EAAE,gBAAgB,UAAU,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,QAAQ,MAAM,UAAU,KAAK;AAAA,EACrG,CAAC;AACD,SAAO,SAAS,GAAG,GAAG,sCAAsC,SAAS,OAAO,CAAC,EAAE,EAAE,WAAW;AAC5F,QAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,SAAO,OAAO,KAAK,OAAO,YAAY,KAAK,GAAG,SAAS,CAAC,EAAE,WAAW;AACrE,SAAO,KAAK;AACd;AAEA,eAAsB,yBACpB,SACA,OACA,OACiB;AACjB,QAAM,WAAW,MAAM,WAAW,SAAS,QAAQ,iCAAiC;AAAA,IAClF;AAAA,IACA,MAAM;AAAA,EACR,CAAC;AACD,SAAO,SAAS,GAAG,GAAG,0CAA0C,SAAS,OAAO,CAAC,EAAE,EAAE,WAAW;AAChG,QAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,QAAM,KAAK,KAAK,QAAQ;AACxB,SAAO,OAAO,OAAO,YAAY,GAAG,SAAS,CAAC,EAAE,WAAW;AAC3D,SAAO;AACT;AAEA,eAAsB,+BACpB,SACA,OACA,MACA,IACe;AACf,MAAI,CAAC,SAAS,CAAC,GAAI;AACnB,MAAI;AACF,UAAM,WAAW,SAAS,UAAU,GAAG,IAAI,OAAO,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC;AAAA,EACvF,QAAQ;AACN;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import { expect, type APIRequestContext } from '@playwright/test';\nimport { apiRequest } from './api';\nimport { getTokenContext } from './generalFixtures';\n\nexport async function createCurrencyFixture(\n request: APIRequestContext,\n token: string,\n input: { code: string; name: string; symbol?: string },\n): Promise<string> {\n const { organizationId, tenantId } = getTokenContext(token);\n const response = await apiRequest(request, 'POST', '/api/currencies/currencies', {\n token,\n data: { organizationId, tenantId, code: input.code, name: input.name, symbol: input.symbol ?? null },\n });\n expect(response.ok(), `Failed to create currency fixture: ${response.status()}`).toBeTruthy();\n const body = (await response.json()) as { id?: string };\n expect(typeof body.id === 'string' && body.id.length > 0).toBeTruthy();\n return body.id as string;\n}\n\n// Codes seeded by the currencies module (seedExampleCurrencies). Generated test\n// codes avoid these so fixtures never collide with seeded rows.\nconst SEEDED_CURRENCY_CODES = new Set([\n 'USD', 'EUR', 'JPY', 'GBP', 'CHF', 'CAD', 'AUD', 'CNY', 'CNH', 'PLN',\n]);\n// Reserved across the worker so two fixtures never draw the same code in one run.\nconst reservedCurrencyCodes = new Set<string>();\n\n/** Draws an ISO-style three-letter code unused by seeds or earlier fixtures. */\nexport function generateUniqueCurrencyCode(): string {\n const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));\n for (let attempt = 0; attempt < 200; attempt += 1) {\n const code = `${letter()}${letter()}${letter()}`;\n if (!SEEDED_CURRENCY_CODES.has(code) && !reservedCurrencyCodes.has(code)) {\n reservedCurrencyCodes.add(code);\n return code;\n }\n }\n throw new Error('[internal] exhausted unique currency code space');\n}\n\n/**\n * Creates a currency with a generated unique code and returns its id and code.\n *\n * Currency DELETE is a soft delete, but the (organization, tenant, code) unique\n * constraint still counts soft-deleted rows \u2014 re-using a code an earlier test\n * soft-deleted makes the create fail. Drawing from the full three-letter space\n * (minus seeds) and retrying with a fresh code on an accidental collision keeps\n * fixture setup deterministic across runs that share a database.\n */\nexport async function createRandomCurrencyFixture(\n request: APIRequestContext,\n token: string,\n input: { name: string; symbol?: string; isActive?: boolean },\n): Promise<{ id: string; code: string }> {\n const { organizationId, tenantId } = getTokenContext(token);\n let lastStatus = 0;\n for (let attempt = 0; attempt < 8; attempt += 1) {\n const code = generateUniqueCurrencyCode();\n const data: Record<string, unknown> = {\n organizationId,\n tenantId,\n code,\n name: input.name,\n symbol: input.symbol ?? null,\n };\n if (typeof input.isActive === 'boolean') data.isActive = input.isActive;\n const response = await apiRequest(request, 'POST', '/api/currencies/currencies', { token, data });\n if (response.status() === 201) {\n const body = (await response.json()) as { id?: string };\n if (typeof body.id === 'string' && body.id.length > 0) {\n return { id: body.id, code };\n }\n }\n lastStatus = response.status();\n }\n throw new Error(`[internal] failed to create currency fixture after retries (last status ${lastStatus})`);\n}\n\nexport async function createFetchConfigFixture(\n request: APIRequestContext,\n token: string,\n input: { provider: string; isEnabled: boolean },\n): Promise<string> {\n const response = await apiRequest(request, 'POST', '/api/currencies/fetch-configs', {\n token,\n data: input,\n });\n expect(response.ok(), `Failed to create fetch config fixture: ${response.status()}`).toBeTruthy();\n const body = (await response.json()) as { config?: { id?: string } };\n const id = body.config?.id;\n expect(typeof id === 'string' && id.length > 0).toBeTruthy();\n return id as string;\n}\n\nexport async function deleteCurrenciesEntityIfExists(\n request: APIRequestContext,\n token: string | null,\n path: string,\n id: string | null,\n): Promise<void> {\n if (!token || !id) return;\n try {\n await apiRequest(request, 'DELETE', `${path}?id=${encodeURIComponent(id)}`, { token });\n } catch {\n return;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAsC;AAC/C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,eAAsB,sBACpB,SACA,OACA,OACiB;AACjB,QAAM,EAAE,gBAAgB,SAAS,IAAI,gBAAgB,KAAK;AAC1D,QAAM,WAAW,MAAM,WAAW,SAAS,QAAQ,8BAA8B;AAAA,IAC/E;AAAA,IACA,MAAM,EAAE,gBAAgB,UAAU,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,QAAQ,MAAM,UAAU,KAAK;AAAA,EACrG,CAAC;AACD,SAAO,SAAS,GAAG,GAAG,sCAAsC,SAAS,OAAO,CAAC,EAAE,EAAE,WAAW;AAC5F,QAAM,OAAQ,MAAM,SAAS,KAAK;AAClC,SAAO,OAAO,KAAK,OAAO,YAAY,KAAK,GAAG,SAAS,CAAC,EAAE,WAAW;AACrE,SAAO,KAAK;AACd;AAIA,MAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AAAA,EAAO;AACjE,CAAC;AAED,MAAM,wBAAwB,oBAAI,IAAY;AAGvC,SAAS,6BAAqC;AACnD,QAAM,SAAS,MAAM,OAAO,aAAa,KAAK,KAAK,MAAM,KAAK,OAAO,IAAI,EAAE,CAAC;AAC5E,WAAS,UAAU,GAAG,UAAU,KAAK,WAAW,GAAG;AACjD,UAAM,OAAO,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AAC9C,QAAI,CAAC,sBAAsB,IAAI,IAAI,KAAK,CAAC,sBAAsB,IAAI,IAAI,GAAG;AACxE,4BAAs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GAAI;AACnB,MAAI;AACF,UAAM,WAAW,SAAS,UAAU,GAAG,IAAI,OAAO,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC;AAAA,EACvF,QAAQ;AACN;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.6.5-develop.
|
|
3
|
+
"version": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -244,16 +244,16 @@
|
|
|
244
244
|
"zod": "^4.4.3"
|
|
245
245
|
},
|
|
246
246
|
"peerDependencies": {
|
|
247
|
-
"@open-mercato/ai-assistant": "0.6.5-develop.
|
|
248
|
-
"@open-mercato/shared": "0.6.5-develop.
|
|
249
|
-
"@open-mercato/ui": "0.6.5-develop.
|
|
247
|
+
"@open-mercato/ai-assistant": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
248
|
+
"@open-mercato/shared": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
249
|
+
"@open-mercato/ui": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
250
250
|
"react": "^19.0.0",
|
|
251
251
|
"react-dom": "^19.0.0"
|
|
252
252
|
},
|
|
253
253
|
"devDependencies": {
|
|
254
|
-
"@open-mercato/ai-assistant": "0.6.5-develop.
|
|
255
|
-
"@open-mercato/shared": "0.6.5-develop.
|
|
256
|
-
"@open-mercato/ui": "0.6.5-develop.
|
|
254
|
+
"@open-mercato/ai-assistant": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
255
|
+
"@open-mercato/shared": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
256
|
+
"@open-mercato/ui": "0.6.5-develop.4516.1.88e6ab71a9",
|
|
257
257
|
"@testing-library/dom": "^10.4.1",
|
|
258
258
|
"@testing-library/jest-dom": "^6.9.1",
|
|
259
259
|
"@testing-library/react": "^16.3.1",
|
|
@@ -18,6 +18,65 @@ export async function createCurrencyFixture(
|
|
|
18
18
|
return body.id as string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// Codes seeded by the currencies module (seedExampleCurrencies). Generated test
|
|
22
|
+
// codes avoid these so fixtures never collide with seeded rows.
|
|
23
|
+
const SEEDED_CURRENCY_CODES = new Set([
|
|
24
|
+
'USD', 'EUR', 'JPY', 'GBP', 'CHF', 'CAD', 'AUD', 'CNY', 'CNH', 'PLN',
|
|
25
|
+
]);
|
|
26
|
+
// Reserved across the worker so two fixtures never draw the same code in one run.
|
|
27
|
+
const reservedCurrencyCodes = new Set<string>();
|
|
28
|
+
|
|
29
|
+
/** Draws an ISO-style three-letter code unused by seeds or earlier fixtures. */
|
|
30
|
+
export function generateUniqueCurrencyCode(): string {
|
|
31
|
+
const letter = () => String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
|
32
|
+
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
33
|
+
const code = `${letter()}${letter()}${letter()}`;
|
|
34
|
+
if (!SEEDED_CURRENCY_CODES.has(code) && !reservedCurrencyCodes.has(code)) {
|
|
35
|
+
reservedCurrencyCodes.add(code);
|
|
36
|
+
return code;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error('[internal] exhausted unique currency code space');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates a currency with a generated unique code and returns its id and code.
|
|
44
|
+
*
|
|
45
|
+
* Currency DELETE is a soft delete, but the (organization, tenant, code) unique
|
|
46
|
+
* constraint still counts soft-deleted rows — re-using a code an earlier test
|
|
47
|
+
* soft-deleted makes the create fail. Drawing from the full three-letter space
|
|
48
|
+
* (minus seeds) and retrying with a fresh code on an accidental collision keeps
|
|
49
|
+
* fixture setup deterministic across runs that share a database.
|
|
50
|
+
*/
|
|
51
|
+
export async function createRandomCurrencyFixture(
|
|
52
|
+
request: APIRequestContext,
|
|
53
|
+
token: string,
|
|
54
|
+
input: { name: string; symbol?: string; isActive?: boolean },
|
|
55
|
+
): Promise<{ id: string; code: string }> {
|
|
56
|
+
const { organizationId, tenantId } = getTokenContext(token);
|
|
57
|
+
let lastStatus = 0;
|
|
58
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
59
|
+
const code = generateUniqueCurrencyCode();
|
|
60
|
+
const data: Record<string, unknown> = {
|
|
61
|
+
organizationId,
|
|
62
|
+
tenantId,
|
|
63
|
+
code,
|
|
64
|
+
name: input.name,
|
|
65
|
+
symbol: input.symbol ?? null,
|
|
66
|
+
};
|
|
67
|
+
if (typeof input.isActive === 'boolean') data.isActive = input.isActive;
|
|
68
|
+
const response = await apiRequest(request, 'POST', '/api/currencies/currencies', { token, data });
|
|
69
|
+
if (response.status() === 201) {
|
|
70
|
+
const body = (await response.json()) as { id?: string };
|
|
71
|
+
if (typeof body.id === 'string' && body.id.length > 0) {
|
|
72
|
+
return { id: body.id, code };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
lastStatus = response.status();
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`[internal] failed to create currency fixture after retries (last status ${lastStatus})`);
|
|
78
|
+
}
|
|
79
|
+
|
|
21
80
|
export async function createFetchConfigFixture(
|
|
22
81
|
request: APIRequestContext,
|
|
23
82
|
token: string,
|