@synnaxlabs/x 0.53.0 → 0.54.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/.turbo/turbo-build.log +14 -8
- package/dist/src/array/nullable.d.ts +10 -1
- package/dist/src/array/nullable.d.ts.map +1 -1
- package/dist/src/binary/codec.d.ts +5 -5
- package/dist/src/binary/codec.d.ts.map +1 -1
- package/dist/src/caseconv/caseconv.bench.d.ts +2 -0
- package/dist/src/caseconv/caseconv.bench.d.ts.map +1 -0
- package/dist/src/caseconv/caseconv.d.ts +19 -1
- package/dist/src/caseconv/caseconv.d.ts.map +1 -1
- package/dist/src/color/color.d.ts +22 -24
- package/dist/src/color/color.d.ts.map +1 -1
- package/dist/src/color/gradient.d.ts +10 -10
- package/dist/src/color/palette.d.ts +16 -16
- package/dist/src/control/control.d.ts +21 -37
- package/dist/src/control/control.d.ts.map +1 -1
- package/dist/src/control/external.d.ts +3 -0
- package/dist/src/control/external.d.ts.map +1 -0
- package/dist/src/control/index.d.ts +1 -1
- package/dist/src/control/index.d.ts.map +1 -1
- package/dist/src/control/types.gen.d.ts +34 -0
- package/dist/src/control/types.gen.d.ts.map +1 -0
- package/dist/src/deep/merge.d.ts.map +1 -1
- package/dist/src/label/index.d.ts +1 -1
- package/dist/src/label/index.d.ts.map +1 -1
- package/dist/src/label/types.gen.d.ts +51 -0
- package/dist/src/label/types.gen.d.ts.map +1 -0
- package/dist/src/math/constants.d.ts +1 -0
- package/dist/src/math/constants.d.ts.map +1 -1
- package/dist/src/record/record.d.ts +12 -12
- package/dist/src/record/record.d.ts.map +1 -1
- package/dist/src/spatial/base.d.ts +40 -43
- package/dist/src/spatial/base.d.ts.map +1 -1
- package/dist/src/spatial/bounds/bounds.d.ts +2 -2
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
- package/dist/src/spatial/box/box.d.ts +4 -16
- package/dist/src/spatial/box/box.d.ts.map +1 -1
- package/dist/src/spatial/dimensions/dimensions.d.ts +3 -7
- package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
- package/dist/src/spatial/direction/direction.d.ts +3 -3
- package/dist/src/spatial/direction/direction.d.ts.map +1 -1
- package/dist/src/spatial/external.d.ts +1 -0
- package/dist/src/spatial/external.d.ts.map +1 -1
- package/dist/src/spatial/location/location.d.ts +9 -3
- package/dist/src/spatial/location/location.d.ts.map +1 -1
- package/dist/src/spatial/spatial.d.ts +2 -1
- package/dist/src/spatial/spatial.d.ts.map +1 -1
- package/dist/src/spatial/types.gen.d.ts +20 -0
- package/dist/src/spatial/types.gen.d.ts.map +1 -0
- package/dist/src/spatial/xy/xy.d.ts +3 -2
- package/dist/src/spatial/xy/xy.d.ts.map +1 -1
- package/dist/src/status/external.d.ts +3 -0
- package/dist/src/status/external.d.ts.map +1 -0
- package/dist/src/status/index.d.ts +1 -1
- package/dist/src/status/index.d.ts.map +1 -1
- package/dist/src/status/status.d.ts +5 -35
- package/dist/src/status/status.d.ts.map +1 -1
- package/dist/src/status/types.gen.d.ts +74 -0
- package/dist/src/status/types.gen.d.ts.map +1 -0
- package/dist/src/telem/external.d.ts +4 -0
- package/dist/src/telem/external.d.ts.map +1 -0
- package/dist/src/telem/index.d.ts +2 -3
- package/dist/src/telem/index.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +62 -0
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/zod/nullToUndefined.d.ts +1 -1
- package/dist/src/zod/nullToUndefined.d.ts.map +1 -1
- package/dist/src/zod/schemas.d.ts +6 -0
- package/dist/src/zod/schemas.d.ts.map +1 -1
- package/dist/x.cjs +8 -13
- package/dist/x.js +4393 -5591
- package/package.json +8 -8
- package/src/array/nullable.ts +10 -1
- package/src/binary/codec.spec.ts +31 -0
- package/src/binary/codec.ts +9 -8
- package/src/caseconv/caseconv.bench.ts +270 -0
- package/src/caseconv/caseconv.spec.ts +534 -0
- package/src/caseconv/caseconv.ts +186 -41
- package/src/color/color.spec.ts +51 -36
- package/src/color/color.ts +7 -8
- package/src/control/control.ts +7 -32
- package/src/{label/label.ts → control/external.ts} +2 -13
- package/src/control/index.ts +1 -1
- package/src/control/types.gen.ts +52 -0
- package/src/deep/merge.ts +2 -1
- package/src/deep/path.ts +1 -1
- package/src/deep/remove.ts +1 -1
- package/src/label/index.ts +1 -1
- package/src/label/types.gen.ts +35 -0
- package/src/math/constants.ts +1 -0
- package/src/migrate/migrate.ts +2 -2
- package/src/record/record.spec.ts +31 -7
- package/src/record/record.ts +17 -17
- package/src/spatial/base.ts +63 -39
- package/src/spatial/bounds/bounds.ts +2 -2
- package/src/spatial/box/box.ts +2 -2
- package/src/spatial/dimensions/dimensions.ts +11 -5
- package/src/spatial/direction/direction.ts +2 -2
- package/src/spatial/external.ts +1 -0
- package/src/spatial/location/location.ts +15 -13
- package/src/spatial/spatial.ts +29 -2
- package/src/spatial/sticky/sticky.ts +1 -1
- package/src/spatial/types.gen.ts +28 -0
- package/src/spatial/xy/xy.ts +9 -10
- package/src/status/external.ts +11 -0
- package/src/status/index.ts +1 -1
- package/src/status/status.ts +11 -59
- package/src/status/types.gen.ts +118 -0
- package/src/strings/deduplicateFileName.ts +3 -3
- package/src/telem/external.ts +12 -0
- package/src/telem/index.ts +2 -3
- package/src/telem/telem.ts +30 -5
- package/src/zod/nullToUndefined.ts +4 -4
- package/src/zod/schemas.ts +9 -2
- package/src/zod/util.ts +2 -2
- package/tsconfig.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +8 -1
- package/dist/src/label/label.d.ts +0 -25
- package/dist/src/label/label.d.ts.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
// Code generated by Oracle. DO NOT EDIT.
|
|
11
|
+
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import { zod } from "@/zod";
|
|
15
|
+
|
|
16
|
+
export const authorityZ = zod.uint8;
|
|
17
|
+
export type Authority = z.infer<typeof authorityZ>;
|
|
18
|
+
|
|
19
|
+
export enum Concurrency {
|
|
20
|
+
exclusive = 0,
|
|
21
|
+
shared = 1,
|
|
22
|
+
}
|
|
23
|
+
export const concurrencyZ = z.enum(Concurrency);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Subject is an entity that can hold control authority over a resource. Typically
|
|
27
|
+
* represents a user, process, or service.
|
|
28
|
+
*/
|
|
29
|
+
export const subjectZ = z.object({
|
|
30
|
+
/** key is a unique identifier for the subject. */
|
|
31
|
+
key: z.string(),
|
|
32
|
+
/** name is a human-readable name for the subject. */
|
|
33
|
+
name: z.string(),
|
|
34
|
+
/**
|
|
35
|
+
* group optional identifier shared by subjects from the same logical group
|
|
36
|
+
* (e.g.) all writers from the same Driver rack.
|
|
37
|
+
*/
|
|
38
|
+
group: z.uint32().optional(),
|
|
39
|
+
});
|
|
40
|
+
export interface Subject extends z.infer<typeof subjectZ> {}
|
|
41
|
+
|
|
42
|
+
export const stateZ = <R extends z.ZodType>(r: R) =>
|
|
43
|
+
z.object({
|
|
44
|
+
subject: subjectZ,
|
|
45
|
+
resource: r,
|
|
46
|
+
authority: authorityZ,
|
|
47
|
+
});
|
|
48
|
+
export interface State<R extends z.ZodType> {
|
|
49
|
+
subject: Subject;
|
|
50
|
+
resource: z.infer<R>;
|
|
51
|
+
authority: Authority;
|
|
52
|
+
}
|
package/src/deep/merge.ts
CHANGED
|
@@ -30,7 +30,8 @@ export const override = <T>(base: T, ...overrides: Array<Partial<T>>): T => {
|
|
|
30
30
|
override(base[key], source[key]);
|
|
31
31
|
} else Object.assign(base, { [key]: source[key] });
|
|
32
32
|
} catch (e) {
|
|
33
|
-
if (e instanceof TypeError)
|
|
33
|
+
if (e instanceof TypeError)
|
|
34
|
+
throw new TypeError(`.${key}: ${e.message}`, { cause: e });
|
|
34
35
|
throw e;
|
|
35
36
|
}
|
|
36
37
|
|
package/src/deep/path.ts
CHANGED
|
@@ -110,7 +110,7 @@ export const pathsMatch = (path: string, pattern: string): boolean => {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
export const getIndex = (part: string): number | null => {
|
|
113
|
-
const num = parseInt(part);
|
|
113
|
+
const num = parseInt(part, 10);
|
|
114
114
|
if (isNaN(num) || num < 0 || num.toString() !== part) return null;
|
|
115
115
|
return num;
|
|
116
116
|
};
|
package/src/deep/remove.ts
CHANGED
|
@@ -21,7 +21,7 @@ export const remove = <V>(obj: V, path: string): void => {
|
|
|
21
21
|
const lastPart = parts[i];
|
|
22
22
|
|
|
23
23
|
if (Array.isArray(result)) {
|
|
24
|
-
const index = parseInt(lastPart);
|
|
24
|
+
const index = parseInt(lastPart, 10);
|
|
25
25
|
if (!isNaN(index) && index < result.length) {
|
|
26
26
|
result.splice(index, 1);
|
|
27
27
|
return;
|
package/src/label/index.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
// Code generated by Oracle. DO NOT EDIT.
|
|
11
|
+
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
import { color } from "@/color";
|
|
15
|
+
|
|
16
|
+
export const keyZ = z.uuid();
|
|
17
|
+
export type Key = z.infer<typeof keyZ>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Label is a tagging and categorization entity with a name and associated color.
|
|
21
|
+
* Labels can be attached to resources like ranges for organization and
|
|
22
|
+
* filtering.
|
|
23
|
+
*/
|
|
24
|
+
export const labelZ = z.object({
|
|
25
|
+
/** key is the unique identifier for this label. */
|
|
26
|
+
key: keyZ,
|
|
27
|
+
/** name is a human-readable name for the label. */
|
|
28
|
+
name: z.string().min(1),
|
|
29
|
+
/** color is the display color for visual identification of the label. */
|
|
30
|
+
color: color.colorZ,
|
|
31
|
+
});
|
|
32
|
+
export interface Label extends z.infer<typeof labelZ> {}
|
|
33
|
+
|
|
34
|
+
export const newZ = labelZ.partial({ key: true });
|
|
35
|
+
export interface New extends z.input<typeof newZ> {}
|
package/src/math/constants.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export const MAX_UINT8 = 2 ** 8 - 1;
|
|
11
11
|
export const MAX_UINT12 = 2 ** 12 - 1;
|
|
12
12
|
export const MAX_UINT16 = 2 ** 16 - 1;
|
|
13
|
+
export const MAX_UINT20 = 2 ** 20 - 1;
|
|
13
14
|
export const MAX_UINT32 = 2 ** 32 - 1;
|
|
14
15
|
export const MAX_UINT64 = 2n ** 64n - 1n;
|
|
15
16
|
export const MAX_UINT64_NUMBER = 2 ** 64 - 1;
|
package/src/migrate/migrate.ts
CHANGED
|
@@ -64,8 +64,8 @@ const comparePreRelease = (a: string, b: string): number => {
|
|
|
64
64
|
|
|
65
65
|
if (aIsNumeric && bIsNumeric) {
|
|
66
66
|
// Compare numerically
|
|
67
|
-
const aNum = parseInt(aPart);
|
|
68
|
-
const bNum = parseInt(bPart);
|
|
67
|
+
const aNum = parseInt(aPart, 10);
|
|
68
|
+
const bNum = parseInt(bPart, 10);
|
|
69
69
|
if (aNum < bNum) return compare.LESS_THAN;
|
|
70
70
|
if (aNum > bNum) return compare.GREATER_THAN;
|
|
71
71
|
} else {
|
|
@@ -74,15 +74,15 @@ describe("record", () => {
|
|
|
74
74
|
});
|
|
75
75
|
it("should reject symbol keys", () => {
|
|
76
76
|
const symbolKey = Symbol("test");
|
|
77
|
-
expect(() => record.keyZ.parse(symbolKey)).
|
|
77
|
+
expect(() => record.keyZ.parse(symbolKey)).toThrow(z.ZodError);
|
|
78
78
|
});
|
|
79
79
|
it("should reject undefined keys", () => {
|
|
80
80
|
const undefinedKey = undefined;
|
|
81
|
-
expect(() => record.keyZ.parse(undefinedKey)).
|
|
81
|
+
expect(() => record.keyZ.parse(undefinedKey)).toThrow(z.ZodError);
|
|
82
82
|
});
|
|
83
83
|
it("should reject null keys", () => {
|
|
84
84
|
const nullKey = null;
|
|
85
|
-
expect(() => record.keyZ.parse(nullKey)).
|
|
85
|
+
expect(() => record.keyZ.parse(nullKey)).toThrow(z.ZodError);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
describe("unknownZ", () => {
|
|
@@ -95,16 +95,16 @@ describe("record", () => {
|
|
|
95
95
|
2: [1, 2, 3],
|
|
96
96
|
function: () => {},
|
|
97
97
|
};
|
|
98
|
-
expect(record.unknownZ.parse(validRecord)).toEqual(validRecord);
|
|
98
|
+
expect(record.unknownZ().parse(validRecord)).toEqual(validRecord);
|
|
99
99
|
});
|
|
100
100
|
it("should reject symbol keys", () => {
|
|
101
101
|
const invalidRecord = { [Symbol("test")]: "value" };
|
|
102
|
-
expect(() => record.unknownZ.parse(invalidRecord)).
|
|
102
|
+
expect(() => record.unknownZ().parse(invalidRecord)).toThrow(z.ZodError);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
it("should accept empty objects", () => {
|
|
106
106
|
const emptyRecord = {};
|
|
107
|
-
expect(record.unknownZ.parse(emptyRecord)).toEqual(emptyRecord);
|
|
107
|
+
expect(record.unknownZ().parse(emptyRecord)).toEqual(emptyRecord);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it("should accept null and undefined values", () => {
|
|
@@ -114,7 +114,7 @@ describe("record", () => {
|
|
|
114
114
|
string: "value",
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
expect(record.unknownZ.parse(recordWithNulls)).toEqual(recordWithNulls);
|
|
117
|
+
expect(record.unknownZ().parse(recordWithNulls)).toEqual(recordWithNulls);
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
|
|
@@ -331,6 +331,30 @@ describe("record", () => {
|
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
333
|
|
|
334
|
+
describe("nullishToEmpty", () => {
|
|
335
|
+
it("should coerce null to empty object", () => {
|
|
336
|
+
expect(record.nullishToEmpty().parse(null)).toEqual({});
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("should coerce undefined to empty object", () => {
|
|
340
|
+
expect(record.nullishToEmpty().parse(undefined)).toEqual({});
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it("should pass through empty object", () => {
|
|
344
|
+
expect(record.nullishToEmpty().parse({})).toEqual({});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("should pass through object with data", () => {
|
|
348
|
+
const obj = { a: 1, b: "hello", c: true };
|
|
349
|
+
expect(record.nullishToEmpty().parse(obj)).toEqual(obj);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
it("should pass through object with nested values", () => {
|
|
353
|
+
const obj = { nested: { key: "value" }, arr: [1, 2, 3] };
|
|
354
|
+
expect(record.nullishToEmpty().parse(obj)).toEqual(obj);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
334
358
|
describe("omit", () => {
|
|
335
359
|
type Object = { [key: string]: number };
|
|
336
360
|
it("should return the object if no keys are provided", () =>
|
package/src/record/record.ts
CHANGED
|
@@ -23,28 +23,13 @@ export type Key = z.infer<typeof keyZ>;
|
|
|
23
23
|
* Zod schema for validating unknown records. Accepts objects with string or number keys
|
|
24
24
|
* and unknown values.
|
|
25
25
|
*/
|
|
26
|
-
export const unknownZ = z.record(keyZ, z.unknown());
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* For required JSON/record fields: coerces null/undefined to empty object {}.
|
|
30
|
-
* Use when the record must always be present and iterable.
|
|
31
|
-
*
|
|
32
|
-
* - null → {}
|
|
33
|
-
* - undefined → {}
|
|
34
|
-
* - {} → {}
|
|
35
|
-
* - {data} → {data}
|
|
36
|
-
*/
|
|
37
|
-
export const nullishToEmpty = (): z.ZodType<Unknown> =>
|
|
38
|
-
z.union([
|
|
39
|
-
z.union([z.null(), z.undefined()]).transform<Unknown>(() => ({})),
|
|
40
|
-
unknownZ,
|
|
41
|
-
]);
|
|
26
|
+
export const unknownZ = () => z.record(keyZ, z.unknown());
|
|
42
27
|
|
|
43
28
|
/**
|
|
44
29
|
* Represents a record with unknown values and string/number keys.
|
|
45
30
|
* This is a generic type for objects where the value types are not known.
|
|
46
31
|
*/
|
|
47
|
-
export interface Unknown extends z.infer<typeof unknownZ
|
|
32
|
+
export interface Unknown extends z.infer<ReturnType<typeof unknownZ>> {}
|
|
48
33
|
|
|
49
34
|
/**
|
|
50
35
|
* Interface for objects that have a key property.
|
|
@@ -155,3 +140,18 @@ export const omit = <T, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K> =>
|
|
|
155
140
|
for (const key of keys) delete result[key];
|
|
156
141
|
return result;
|
|
157
142
|
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* For required JSON/record fields: coerces null/undefined to empty object {}.
|
|
146
|
+
* Use when the record must always be present and iterable.
|
|
147
|
+
*
|
|
148
|
+
* - null → {}
|
|
149
|
+
* - undefined → {}
|
|
150
|
+
* - {} → {}
|
|
151
|
+
* - {data} → {data}
|
|
152
|
+
*/
|
|
153
|
+
export const nullishToEmpty = (): z.ZodType<Unknown> =>
|
|
154
|
+
z.union([
|
|
155
|
+
z.union([z.null(), z.undefined()]).transform<Unknown>(() => ({})),
|
|
156
|
+
unknownZ(),
|
|
157
|
+
]);
|
package/src/spatial/base.ts
CHANGED
|
@@ -9,63 +9,75 @@
|
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
|
+
// Tuples
|
|
13
|
+
|
|
12
14
|
export const numberCouple = z.tuple([z.number(), z.number()]);
|
|
13
15
|
export type NumberCouple<T extends number | bigint = number> = [T, T];
|
|
14
16
|
|
|
15
|
-
// Dimensions
|
|
16
|
-
|
|
17
|
-
export const dimensions = z.object({ width: z.number(), height: z.number() });
|
|
18
|
-
export type Dimensions = z.infer<typeof dimensions>;
|
|
19
|
-
export const signedDimensions = z.object({
|
|
20
|
-
signedWidth: z.number(),
|
|
21
|
-
signedHeight: z.number(),
|
|
22
|
-
});
|
|
23
|
-
export type Dimension = "width" | "height";
|
|
24
|
-
export const ALIGNMENTS = ["start", "center", "end"] as const;
|
|
25
|
-
export type SignedDimension = "signedWidth" | "signedHeight";
|
|
26
|
-
|
|
27
|
-
// XY
|
|
28
|
-
|
|
29
|
-
export const xy = z.object({ x: z.number(), y: z.number() });
|
|
30
|
-
export type XY = z.infer<typeof xy>;
|
|
31
|
-
export const clientXY = z.object({ clientX: z.number(), clientY: z.number() });
|
|
32
|
-
export type ClientXY = z.infer<typeof clientXY>;
|
|
33
|
-
|
|
34
17
|
// Direction
|
|
35
18
|
|
|
36
19
|
export const DIRECTIONS = ["x", "y"] as const;
|
|
37
|
-
export const
|
|
38
|
-
export type Direction = z.infer<typeof
|
|
20
|
+
export const directionZ = z.enum(DIRECTIONS);
|
|
21
|
+
export type Direction = z.infer<typeof directionZ>;
|
|
39
22
|
|
|
40
23
|
// Location
|
|
41
24
|
|
|
42
25
|
export const OUTER_LOCATIONS = ["top", "right", "bottom", "left"] as const;
|
|
43
|
-
export const
|
|
44
|
-
export type OuterLocation =
|
|
26
|
+
export const outerLocationZ = z.enum(OUTER_LOCATIONS);
|
|
27
|
+
export type OuterLocation = z.infer<typeof outerLocationZ>;
|
|
28
|
+
|
|
45
29
|
export const X_LOCATIONS = ["left", "right"] as const;
|
|
46
|
-
export const
|
|
47
|
-
export type XLocation =
|
|
30
|
+
export const xLocationZ = z.enum(X_LOCATIONS);
|
|
31
|
+
export type XLocation = z.infer<typeof xLocationZ>;
|
|
32
|
+
|
|
48
33
|
export const Y_LOCATIONS = ["top", "bottom"] as const;
|
|
49
|
-
export const
|
|
50
|
-
export type YLocation =
|
|
34
|
+
export const yLocationZ = z.enum(Y_LOCATIONS);
|
|
35
|
+
export type YLocation = z.infer<typeof yLocationZ>;
|
|
36
|
+
|
|
51
37
|
export const CENTER_LOCATIONS = ["center"] as const;
|
|
52
|
-
export const
|
|
53
|
-
export type CenterLocation =
|
|
54
|
-
|
|
55
|
-
export const
|
|
56
|
-
export
|
|
38
|
+
export const centerLocationZ = z.enum(CENTER_LOCATIONS);
|
|
39
|
+
export type CenterLocation = z.infer<typeof centerLocationZ>;
|
|
40
|
+
|
|
41
|
+
export const LOCATIONS = ["top", "right", "bottom", "left", "center"] as const;
|
|
42
|
+
export const locationZ = z.enum(LOCATIONS);
|
|
43
|
+
export type Location = z.infer<typeof locationZ>;
|
|
57
44
|
|
|
58
45
|
// Alignment
|
|
59
46
|
|
|
60
|
-
export const
|
|
61
|
-
export
|
|
47
|
+
export const ALIGNMENTS = ["start", "center", "end"] as const;
|
|
48
|
+
export const alignmentZ = z.enum(ALIGNMENTS);
|
|
49
|
+
export type Alignment = z.infer<typeof alignmentZ>;
|
|
50
|
+
|
|
51
|
+
// Order
|
|
52
|
+
|
|
62
53
|
export const ORDERS = ["first", "last"] as const;
|
|
63
|
-
export const
|
|
64
|
-
export type Order =
|
|
54
|
+
export const orderZ = z.enum(ORDERS);
|
|
55
|
+
export type Order = z.infer<typeof orderZ>;
|
|
56
|
+
|
|
57
|
+
// XY
|
|
58
|
+
|
|
59
|
+
export const clientXyZ = z.object({ clientX: z.number(), clientY: z.number() });
|
|
60
|
+
export type ClientXY = z.infer<typeof clientXyZ>;
|
|
61
|
+
|
|
62
|
+
// Dimensions
|
|
63
|
+
|
|
64
|
+
export const dimensionsZ = z.object({ width: z.number(), height: z.number() });
|
|
65
|
+
export type Dimensions = z.infer<typeof dimensionsZ>;
|
|
66
|
+
|
|
67
|
+
export const signedDimensionsZ = z.object({
|
|
68
|
+
signedWidth: z.number(),
|
|
69
|
+
signedHeight: z.number(),
|
|
70
|
+
});
|
|
71
|
+
export type SignedDimensions = z.infer<typeof signedDimensionsZ>;
|
|
72
|
+
|
|
73
|
+
export type Dimension = "width" | "height";
|
|
74
|
+
export type SignedDimension = "signedWidth" | "signedHeight";
|
|
65
75
|
|
|
66
76
|
// Bounds
|
|
67
77
|
|
|
68
|
-
export const
|
|
78
|
+
export const boundsZ = z.object({ lower: z.number(), upper: z.number() });
|
|
79
|
+
|
|
80
|
+
// Generic bounds interface (supports bigint)
|
|
69
81
|
export interface Bounds<T extends number | bigint = number> {
|
|
70
82
|
lower: T;
|
|
71
83
|
upper: T;
|
|
@@ -74,10 +86,22 @@ export interface Bounds<T extends number | bigint = number> {
|
|
|
74
86
|
export type CrudeBounds<T extends number | bigint = number> =
|
|
75
87
|
| Bounds<T>
|
|
76
88
|
| NumberCouple<T>;
|
|
77
|
-
|
|
89
|
+
|
|
90
|
+
// Derived/complex types
|
|
91
|
+
|
|
92
|
+
export const crudeDirection = z.enum([
|
|
93
|
+
"x",
|
|
94
|
+
"y",
|
|
95
|
+
...OUTER_LOCATIONS,
|
|
96
|
+
...CENTER_LOCATIONS,
|
|
97
|
+
]);
|
|
78
98
|
export type CrudeDirection = z.infer<typeof crudeDirection>;
|
|
79
99
|
export type CrudeXDirection = "x" | "left" | "right";
|
|
80
100
|
export type CrudeYDirection = "y" | "top" | "bottom";
|
|
81
101
|
export type AngularDirection = "clockwise" | "counterclockwise";
|
|
82
|
-
export const crudeLocation = z.union([
|
|
102
|
+
export const crudeLocation = z.union([
|
|
103
|
+
directionZ,
|
|
104
|
+
z.enum([...OUTER_LOCATIONS, ...CENTER_LOCATIONS]),
|
|
105
|
+
z.instanceof(String),
|
|
106
|
+
]);
|
|
83
107
|
export type CrudeLocation = z.infer<typeof crudeLocation>;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import { abs, add, equal as mathEqual, min as mathMin, sub } from "@/math/math";
|
|
11
11
|
import { type numeric } from "@/numeric";
|
|
12
|
-
import { type Bounds,
|
|
12
|
+
import { type Bounds, boundsZ, type CrudeBounds } from "@/spatial/base";
|
|
13
13
|
|
|
14
|
-
export { type Bounds,
|
|
14
|
+
export { type Bounds, boundsZ };
|
|
15
15
|
|
|
16
16
|
export type Crude<T extends numeric.Value = number> = CrudeBounds<T>;
|
|
17
17
|
|
package/src/spatial/box/box.ts
CHANGED
|
@@ -9,12 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
type Dimensions,
|
|
14
|
+
dimensionsZ,
|
|
15
|
+
numberCouple,
|
|
16
|
+
type SignedDimensions,
|
|
17
|
+
signedDimensionsZ,
|
|
18
|
+
} from "@/spatial/base";
|
|
19
|
+
import { xyZ } from "@/spatial/types.gen";
|
|
13
20
|
|
|
14
|
-
export { type Dimensions,
|
|
21
|
+
export { type Dimensions, dimensionsZ, type SignedDimensions, signedDimensionsZ };
|
|
15
22
|
|
|
16
|
-
export const
|
|
17
|
-
export const crude = z.union([dimensions, signed, xy, numberCouple]);
|
|
23
|
+
export const crude = z.union([dimensionsZ, signedDimensionsZ, xyZ, numberCouple]);
|
|
18
24
|
export type Crude = z.infer<typeof crude>;
|
|
19
25
|
|
|
20
26
|
export const ZERO = { width: 0, height: 0 };
|
|
@@ -29,7 +35,7 @@ export const construct = (width: number | Crude, height?: number): Dimensions =>
|
|
|
29
35
|
return { ...width };
|
|
30
36
|
};
|
|
31
37
|
|
|
32
|
-
export type Signed = z.infer<typeof
|
|
38
|
+
export type Signed = z.infer<typeof signedDimensionsZ>;
|
|
33
39
|
|
|
34
40
|
export const equals = (ca: Crude, cb?: Crude | null): boolean => {
|
|
35
41
|
if (cb == null) return false;
|
|
@@ -15,15 +15,15 @@ import {
|
|
|
15
15
|
type CrudeYDirection,
|
|
16
16
|
type Dimension,
|
|
17
17
|
type Direction,
|
|
18
|
-
direction,
|
|
19
18
|
DIRECTIONS,
|
|
19
|
+
directionZ,
|
|
20
20
|
type Location,
|
|
21
21
|
type SignedDimension,
|
|
22
22
|
Y_LOCATIONS,
|
|
23
23
|
type YLocation,
|
|
24
24
|
} from "@/spatial/base";
|
|
25
25
|
|
|
26
|
-
export { Direction,
|
|
26
|
+
export { type Direction, DIRECTIONS, directionZ };
|
|
27
27
|
|
|
28
28
|
export const crude = crudeDirection;
|
|
29
29
|
|
package/src/spatial/external.ts
CHANGED
|
@@ -14,37 +14,39 @@ import {
|
|
|
14
14
|
type AngularDirection,
|
|
15
15
|
CENTER_LOCATIONS,
|
|
16
16
|
type CenterLocation,
|
|
17
|
-
|
|
17
|
+
centerLocationZ,
|
|
18
18
|
type CrudeLocation,
|
|
19
19
|
crudeLocation,
|
|
20
20
|
type Direction,
|
|
21
21
|
DIRECTIONS,
|
|
22
22
|
type Location,
|
|
23
|
-
|
|
23
|
+
LOCATIONS,
|
|
24
|
+
locationZ,
|
|
24
25
|
OUTER_LOCATIONS,
|
|
25
26
|
type OuterLocation,
|
|
26
|
-
|
|
27
|
+
outerLocationZ,
|
|
27
28
|
X_LOCATIONS,
|
|
28
29
|
type XLocation,
|
|
29
|
-
|
|
30
|
+
xLocationZ,
|
|
30
31
|
Y_LOCATIONS,
|
|
31
32
|
type YLocation,
|
|
32
|
-
|
|
33
|
+
yLocationZ,
|
|
33
34
|
} from "@/spatial/base";
|
|
34
35
|
|
|
35
36
|
export {
|
|
36
37
|
CENTER_LOCATIONS,
|
|
37
38
|
type Location,
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
LOCATIONS,
|
|
40
|
+
locationZ,
|
|
40
41
|
OUTER_LOCATIONS,
|
|
41
42
|
X_LOCATIONS,
|
|
42
43
|
Y_LOCATIONS,
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
export const x =
|
|
46
|
-
export const y =
|
|
47
|
-
export const center =
|
|
46
|
+
export const x = xLocationZ;
|
|
47
|
+
export const y = yLocationZ;
|
|
48
|
+
export const center = centerLocationZ;
|
|
49
|
+
export const outerZ = outerLocationZ;
|
|
48
50
|
|
|
49
51
|
export type X = XLocation;
|
|
50
52
|
export type Y = YLocation;
|
|
@@ -88,10 +90,10 @@ export const direction = (cl: Crude): Direction => {
|
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
export const xy = z.object({
|
|
91
|
-
x:
|
|
92
|
-
y:
|
|
93
|
+
x: xLocationZ.or(centerLocationZ),
|
|
94
|
+
y: yLocationZ.or(centerLocationZ),
|
|
93
95
|
});
|
|
94
|
-
export const corner = z.object({ x:
|
|
96
|
+
export const corner = z.object({ x: xLocationZ, y: yLocationZ });
|
|
95
97
|
|
|
96
98
|
export type XY = z.infer<typeof xy>;
|
|
97
99
|
export type CornerXY = z.infer<typeof corner>;
|
package/src/spatial/spatial.ts
CHANGED
|
@@ -9,9 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
type Alignment,
|
|
12
|
-
alignment,
|
|
13
12
|
ALIGNMENTS,
|
|
13
|
+
alignmentZ,
|
|
14
|
+
type Bounds,
|
|
15
|
+
boundsZ,
|
|
16
|
+
CENTER_LOCATIONS,
|
|
17
|
+
type CenterLocation,
|
|
18
|
+
centerLocationZ,
|
|
19
|
+
type ClientXY,
|
|
20
|
+
clientXyZ,
|
|
21
|
+
type Dimensions,
|
|
22
|
+
dimensionsZ,
|
|
23
|
+
type Direction,
|
|
24
|
+
DIRECTIONS,
|
|
25
|
+
directionZ,
|
|
26
|
+
type Location,
|
|
27
|
+
LOCATIONS,
|
|
28
|
+
locationZ,
|
|
14
29
|
type Order,
|
|
15
|
-
order,
|
|
16
30
|
ORDERS,
|
|
31
|
+
orderZ,
|
|
32
|
+
OUTER_LOCATIONS,
|
|
33
|
+
type OuterLocation,
|
|
34
|
+
outerLocationZ,
|
|
35
|
+
type SignedDimensions,
|
|
36
|
+
signedDimensionsZ,
|
|
37
|
+
X_LOCATIONS,
|
|
38
|
+
type XLocation,
|
|
39
|
+
xLocationZ,
|
|
40
|
+
Y_LOCATIONS,
|
|
41
|
+
type YLocation,
|
|
42
|
+
yLocationZ,
|
|
17
43
|
} from "@/spatial/base";
|
|
44
|
+
export { type XY, xyZ } from "@/spatial/types.gen";
|
|
@@ -13,7 +13,7 @@ import { box } from "@/spatial/box";
|
|
|
13
13
|
import { location } from "@/spatial/location";
|
|
14
14
|
import { xy as base } from "@/spatial/xy";
|
|
15
15
|
|
|
16
|
-
export const completeXY = base.
|
|
16
|
+
export const completeXY = base.xyZ.extend({
|
|
17
17
|
root: location.corner,
|
|
18
18
|
units: z.object({
|
|
19
19
|
x: z.enum(["px", "decimal"]),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2026 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
// Code generated by Oracle. DO NOT EDIT.
|
|
11
|
+
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
export const OUTER_LOCATIONS = ["top", "right", "bottom", "left"] as const;
|
|
15
|
+
export const outerLocationZ = z.enum(OUTER_LOCATIONS);
|
|
16
|
+
export type OuterLocation = z.infer<typeof outerLocationZ>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* XY is a 2D coordinate point with x and y values. Used for positioning
|
|
20
|
+
* elements in two-dimensional space.
|
|
21
|
+
*/
|
|
22
|
+
export const xyZ = z.object({
|
|
23
|
+
/** x is the horizontal coordinate. */
|
|
24
|
+
x: z.number(),
|
|
25
|
+
/** y is the vertical coordinate. */
|
|
26
|
+
y: z.number(),
|
|
27
|
+
});
|
|
28
|
+
export interface XY extends z.infer<typeof xyZ> {}
|