@hyperscale0/udl 1.0.251 → 1.0.256

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/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./schema.js";
2
+ export { sarCurrency, sarMinorUnitExponent, currencySchema } from "./money.js";
2
3
  export { serializeUdl, canonicalDigest } from "./canonical.js";
3
4
  export {
4
5
  validateUdl,
package/src/money.ts ADDED
@@ -0,0 +1,5 @@
1
+ import * as z from "zod";
2
+
3
+ export const sarCurrency = "SAR";
4
+ export const sarMinorUnitExponent = 2;
5
+ export const currencySchema = z.literal(sarCurrency);
package/src/reporting.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod";
2
+ import { currencySchema } from "./money.js";
2
3
 
3
4
  const name = z
4
5
  .string()
@@ -12,7 +13,7 @@ const integer = z.number().int().safe();
12
13
  export const reportTypeSchema = z.discriminatedUnion("kind", [
13
14
  z.strictObject({
14
15
  kind: z.literal("money"),
15
- currency: z.string().regex(/^[A-Z]{3}$/),
16
+ currency: currencySchema,
16
17
  }),
17
18
  z.strictObject({ kind: z.enum(["text", "integer", "boolean", "date"]) }),
18
19
  ]);
@@ -94,7 +95,7 @@ export const reportDefinitionSchema = z.strictObject({
94
95
  scope: z.strictObject({
95
96
  kind: z.enum(["product", "company"]),
96
97
  classification: z.enum(["internal", "personal", "restricted"]),
97
- currency: z.string().regex(/^[A-Z]{3}$/),
98
+ currency: currencySchema,
98
99
  }),
99
100
  datasets: z
100
101
  .array(
package/src/schema.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as z from "zod";
2
+ import { currencySchema } from "./money.js";
2
3
  import { reportDefinitionSchema } from "./reporting.js";
3
4
  import { writeJson } from "./json.js";
4
5
 
@@ -553,7 +554,7 @@ export const udlDocumentSchema = z.strictObject({
553
554
  version: integer.positive(),
554
555
  product: name,
555
556
  title: text,
556
- currency: z.literal("SAR"),
557
+ currency: currencySchema,
557
558
  parties: z.record(name, udlPartySchema),
558
559
  objects: z.array(udlObjectKindSchema).max(256),
559
560
  instruments: z.array(udlInstrumentSchema).max(256),
package/src/validation.ts CHANGED
@@ -1101,7 +1101,13 @@ export function validateUdl(value: unknown): UdlValidationResult {
1101
1101
  dependencies.set(
1102
1102
  c.target,
1103
1103
  operands.flatMap((v) =>
1104
- "field" in v && v.field.startsWith("self.")
1104
+ "field" in v &&
1105
+ v.field.startsWith("self.") &&
1106
+ !(
1107
+ act &&
1108
+ v.field === `self.${c.target}` &&
1109
+ !inst.calculate.some((node) => node.target === c.target)
1110
+ )
1105
1111
  ? [v.field.slice(5)]
1106
1112
  : [],
1107
1113
  ),