@hyperscale0/udl 1.0.248 → 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),
@@ -563,14 +564,10 @@ export type UdlFamily = z.infer<typeof udlFamilySchema>;
563
564
  export type UdlDocument = z.infer<typeof udlDocumentSchema>;
564
565
  export type UdlInstrument = z.infer<typeof udlInstrumentSchema>;
565
566
  export type UdlField = z.infer<typeof udlFieldSchema>;
566
- export type UdlParty = z.infer<typeof udlPartySchema>;
567
567
  export type UdlValue = z.infer<typeof udlValueSchema>;
568
568
  export type UdlCalculation = z.infer<typeof udlCalculationSchema>;
569
569
  export type UdlRequirement = z.infer<typeof udlRequirementSchema>;
570
570
  export type UdlAction = z.infer<typeof udlActionSchema>;
571
- export type UdlMove = z.infer<typeof udlMoveSchema>;
572
- export type UdlLifecycle = z.infer<typeof udlLifecycleSchema>;
573
- export type UdlKernelOperation = z.infer<typeof udlKernelOperationSchema>;
574
571
 
575
572
  export type UdlSelection = z.infer<typeof selection>;
576
573
 
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
  ),