@cullet/erp-core 1.4.0 → 1.5.0
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/KIT_CONTEXT.md +6 -0
- package/dist/app-error.cjs +14 -6
- package/dist/app-error.cjs.map +1 -1
- package/dist/app-error.js +14 -6
- package/dist/app-error.js.map +1 -1
- package/dist/condition-evaluator.cjs +14 -0
- package/dist/condition-evaluator.cjs.map +1 -1
- package/dist/condition-evaluator.js +14 -0
- package/dist/condition-evaluator.js.map +1 -1
- package/dist/entity.cjs +2 -6
- package/dist/entity.cjs.map +1 -1
- package/dist/entity.js +2 -6
- package/dist/entity.js.map +1 -1
- package/dist/errors/index.cjs +2 -1
- package/dist/errors/index.js +2 -1
- package/dist/hashing.cjs +2 -44
- package/dist/hashing.cjs.map +1 -1
- package/dist/hashing.js +2 -38
- package/dist/hashing.js.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/policies/engines/v1/gate/index.d.cts +2 -0
- package/dist/policies/engines/v1/gate/index.d.ts +2 -0
- package/dist/policy-service.cjs +2 -1
- package/dist/policy-service.cjs.map +1 -1
- package/dist/policy-service.js +2 -1
- package/dist/policy-service.js.map +1 -1
- package/dist/requested-by.cjs +3 -3
- package/dist/requested-by.cjs.map +1 -1
- package/dist/requested-by.js +1 -1
- package/dist/requested-by.js.map +1 -1
- package/dist/stable-stringify.cjs +47 -0
- package/dist/stable-stringify.cjs.map +1 -0
- package/dist/stable-stringify.js +42 -0
- package/dist/stable-stringify.js.map +1 -0
- package/dist/temporal-use-case.cjs +5 -0
- package/dist/temporal-use-case.cjs.map +1 -1
- package/dist/temporal-use-case.d.cts +6 -1
- package/dist/temporal-use-case.d.ts +6 -1
- package/dist/temporal-use-case.js +5 -0
- package/dist/temporal-use-case.js.map +1 -1
- package/dist/use-case.cjs +2 -6
- package/dist/use-case.cjs.map +1 -1
- package/dist/use-case.js +2 -6
- package/dist/use-case.js.map +1 -1
- package/dist/uuid-identifier.cjs +2 -7
- package/dist/uuid-identifier.cjs.map +1 -1
- package/dist/uuid-identifier.js +1 -6
- package/dist/uuid-identifier.js.map +1 -1
- package/dist/uuid.cjs +18 -0
- package/dist/uuid.cjs.map +1 -0
- package/dist/uuid.js +13 -0
- package/dist/uuid.js.map +1 -0
- package/dist/validation-error.d.cts +10 -5
- package/dist/validation-error.d.ts +10 -5
- package/dist/value-object.cjs +12 -3
- package/dist/value-object.cjs.map +1 -1
- package/dist/value-object.d.cts +9 -1
- package/dist/value-object.d.ts +9 -1
- package/dist/value-object.js +12 -3
- package/dist/value-object.js.map +1 -1
- package/meta.json +4 -2
- package/package.json +1 -1
- package/src/core/application/commands/requested-by.ts +3 -4
- package/src/core/application/queries/query.ts +6 -1
- package/src/core/application/use-case.ts +1 -1
- package/src/core/domain/entity.ts +1 -1
- package/src/core/domain/uuid-identifier.ts +1 -8
- package/src/core/domain/value-object.ts +12 -3
- package/src/core/errors/utils/json-safe.ts +20 -11
- package/src/core/policies/engines/v1/condition-evaluator.ts +56 -1
- package/src/core/shared/hashing.ts +1 -55
- package/src/core/shared/stable-stringify.ts +57 -0
- package/src/core/shared/uuid.ts +11 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const CIRCULAR_STRUCTURE_MESSAGE =
|
|
2
|
+
"Cannot stably stringify a circular structure";
|
|
3
|
+
|
|
4
|
+
// `seen` holds the current traversal branch so true cycles are rejected while
|
|
5
|
+
// repeated (acyclic) references are still serialized — matching JSON.stringify.
|
|
6
|
+
function sortKeysDeep(value: unknown, seen: WeakSet<object>): unknown {
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
if (seen.has(value)) {
|
|
9
|
+
throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
|
|
10
|
+
}
|
|
11
|
+
seen.add(value);
|
|
12
|
+
const mapped = value.map((item) => sortKeysDeep(item, seen));
|
|
13
|
+
seen.delete(value);
|
|
14
|
+
return mapped;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value instanceof Date) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (value && typeof value === "object") {
|
|
22
|
+
if (seen.has(value)) {
|
|
23
|
+
throw new TypeError(CIRCULAR_STRUCTURE_MESSAGE);
|
|
24
|
+
}
|
|
25
|
+
seen.add(value);
|
|
26
|
+
const record = value as Record<string, unknown>;
|
|
27
|
+
const ordered = Object.create(null) as Record<string, unknown>;
|
|
28
|
+
|
|
29
|
+
for (const key of Object.keys(record).sort()) {
|
|
30
|
+
ordered[key] = sortKeysDeep(record[key], seen);
|
|
31
|
+
}
|
|
32
|
+
seen.delete(value);
|
|
33
|
+
|
|
34
|
+
return ordered;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Deterministic JSON string with object keys sorted recursively, so key order
|
|
42
|
+
* does not affect the output.
|
|
43
|
+
*
|
|
44
|
+
* Follows `JSON.stringify` semantics for the values it serializes: `undefined`,
|
|
45
|
+
* functions and symbols are dropped, non-finite numbers become `null`, `bigint`
|
|
46
|
+
* throws, and `Map`/`Set` serialize as `{}`. Distinct payloads can therefore
|
|
47
|
+
* collapse to the same string — for collision-resistant hashing use
|
|
48
|
+
* `PolicyHashing.canonicalJson` (policies/utils), which rejects those values
|
|
49
|
+
* up front.
|
|
50
|
+
*
|
|
51
|
+
* @throws {TypeError} On circular references (mirroring `JSON.stringify`).
|
|
52
|
+
*/
|
|
53
|
+
function stableStringify(value: unknown): string {
|
|
54
|
+
return JSON.stringify(sortKeysDeep(value, new WeakSet<object>()));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { stableStringify };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical RFC-4122 UUID (versions 1–5, variant 8/9/a/b), matched
|
|
3
|
+
* case-insensitively. The single source of truth for the UUID format —
|
|
4
|
+
* `UuidIdentifier` (domain ids) and `RequestedBy` (command actor) both
|
|
5
|
+
* validate against this pattern, so an identity accepted at the application
|
|
6
|
+
* boundary is always one the domain also considers valid.
|
|
7
|
+
*/
|
|
8
|
+
const UUID_PATTERN =
|
|
9
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
10
|
+
|
|
11
|
+
export { UUID_PATTERN };
|
package/src/version.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// Mantemos a versao aqui, dentro de src/, para que a copia full-control seja
|
|
5
5
|
// auto-contida: ao copiar so o conteudo de src/, o entry nao depende de um
|
|
6
6
|
// `../package.json` que deixaria de existir no projeto consumidor.
|
|
7
|
-
export const version = "1.
|
|
7
|
+
export const version = "1.5.0";
|