@open-dpp/dto 5.2.0 → 6.0.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/dist/index.d.ts CHANGED
@@ -69,6 +69,7 @@ export * from "./bulk-import/bulk-import-run.dto";
69
69
  export * from "./bulk-import/bulk-import-run-item.dto";
70
70
  export * from "./bulk-import/bulk-import-parse-result.dto";
71
71
  export * from "./organizations/member.dto";
72
+ export * from "./organizations/organization.dto";
72
73
  export * from "./passports/passport.dto";
73
74
  export * from "./permalinks/permalink.dto";
74
75
  export * from "./presentation-configurations/presentation-configuration.dto";
@@ -95,4 +96,5 @@ export * from "./unique-product-identifiers/unique-product-identifier-list-item.
95
96
  export * from "./unique-product-identifiers/create-unique-product-identifier.dto";
96
97
  export * from "./unique-product-identifiers/create-internal-unique-product-identifier.dto";
97
98
  export * from "./unique-product-identifiers/update-unique-product-identifier.dto";
99
+ export * from "./policy/policy.dto";
98
100
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AAEvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yDAAyD,CAAC;AAExE,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+B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k-import/bulk-import-run-item.dto"), exports);
86
86
  __exportStar(require("./bulk-import/bulk-import-parse-result.dto"), exports);
87
87
  __exportStar(require("./organizations/member.dto"), exports);
88
+ __exportStar(require("./organizations/organization.dto"), exports);
88
89
  __exportStar(require("./passports/passport.dto"), exports);
89
90
  __exportStar(require("./permalinks/permalink.dto"), exports);
90
91
  __exportStar(require("./presentation-configurations/presentation-configuration.dto"), exports);
@@ -111,3 +112,4 @@ __exportStar(require("./unique-product-identifiers/unique-product-identifier-lis
111
112
  __exportStar(require("./unique-product-identifiers/create-unique-product-identifier.dto"), exports);
112
113
  __exportStar(require("./unique-product-identifiers/create-internal-unique-product-identifier.dto"), exports);
113
114
  __exportStar(require("./unique-product-identifiers/update-unique-product-identifier.dto"), exports);
115
+ __exportStar(require("./policy/policy.dto"), exports);
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Wire shape of an organization. The internal `slug` (always equal to `id`)
4
+ * and better-auth's `members` array are deliberately not part of it.
5
+ */
6
+ export declare const OrganizationDtoSchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ name: z.ZodString;
9
+ logo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
11
+ createdAt: z.ZodISODateTime;
12
+ }, z.core.$strip>;
13
+ export type OrganizationDto = z.infer<typeof OrganizationDtoSchema>;
14
+ /**
15
+ * Body of `POST /organizations`. A `slug` sent by legacy callers is stripped:
16
+ * the server derives it from the organization id.
17
+ */
18
+ export declare const OrganizationCreateDtoSchema: z.ZodObject<{
19
+ name: z.ZodString;
20
+ }, z.core.$strip>;
21
+ export type OrganizationCreateDto = z.infer<typeof OrganizationCreateDtoSchema>;
22
+ //# sourceMappingURL=organization.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.dto.d.ts","sourceRoot":"","sources":["../../src/organizations/organization.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;iBAOhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;iBAEtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationCreateDtoSchema = exports.OrganizationDtoSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Wire shape of an organization. The internal `slug` (always equal to `id`)
7
+ * and better-auth's `members` array are deliberately not part of it.
8
+ */
9
+ exports.OrganizationDtoSchema = zod_1.z.object({
10
+ id: zod_1.z.string(),
11
+ name: zod_1.z.string(),
12
+ /** @deprecated Use the organization's Branding logo instead. */
13
+ logo: zod_1.z.string().nullable().optional(),
14
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
15
+ createdAt: zod_1.z.iso.datetime(),
16
+ });
17
+ /**
18
+ * Body of `POST /organizations`. A `slug` sent by legacy callers is stripped:
19
+ * the server derives it from the organization id.
20
+ */
21
+ exports.OrganizationCreateDtoSchema = zod_1.z.object({
22
+ name: zod_1.z.string().trim().min(1),
23
+ });
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ export declare const PolicyKeyList: {
3
+ readonly AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA";
4
+ readonly MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT";
5
+ readonly PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT";
6
+ readonly ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT";
7
+ };
8
+ export declare const PolicyKeyEnum: z.ZodEnum<{
9
+ readonly AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA";
10
+ readonly MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT";
11
+ readonly PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT";
12
+ readonly ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT";
13
+ }>;
14
+ export type PolicyKey = z.infer<typeof PolicyKeyEnum>;
15
+ export declare const PolicyUtilizationDtoSchema: z.ZodObject<{
16
+ limit: z.ZodNumber;
17
+ used: z.ZodNumber;
18
+ reset: z.ZodOptional<z.ZodISODateTime>;
19
+ }, z.core.$strip>;
20
+ export type PolicyUtilizationDto = z.infer<typeof PolicyUtilizationDtoSchema>;
21
+ export declare const PolicyUtilizationsDtoSchema: z.ZodRecord<z.ZodEnum<{
22
+ readonly AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA";
23
+ readonly MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT";
24
+ readonly PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT";
25
+ readonly ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT";
26
+ }>, z.ZodObject<{
27
+ limit: z.ZodNumber;
28
+ used: z.ZodNumber;
29
+ reset: z.ZodOptional<z.ZodISODateTime>;
30
+ }, z.core.$strip>>;
31
+ export type PolicyUtilizationDtoType = z.infer<typeof PolicyUtilizationsDtoSchema>;
32
+ export declare const PolicyLimitDtoSchema: z.ZodNumber;
33
+ /**
34
+ * New limits keyed by policy key. Omitted keys keep the limit they already
35
+ * have, so a caller only sends what it wants to change.
36
+ */
37
+ export declare const SetPolicyLimitsDtoSchema: z.ZodRecord<z.ZodEnum<{
38
+ readonly AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA";
39
+ readonly MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT";
40
+ readonly PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT";
41
+ readonly ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT";
42
+ }> & z.core.$partial, z.ZodNumber>;
43
+ export type SetPolicyLimitsDto = z.infer<typeof SetPolicyLimitsDtoSchema>;
44
+ //# sourceMappingURL=policy.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.dto.d.ts","sourceRoot":"","sources":["../../src/policy/policy.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;EAAwB,CAAC;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEtD,eAAO,MAAM,0BAA0B;;;;iBASrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,2BAA2B;;;;;;;;;kBAAsD,CAAC;AAE/F,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEnF,eAAO,MAAM,oBAAoB,aAI4D,CAAC;AAE9F;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;kCAQjC,CAAC;AAEL,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetPolicyLimitsDtoSchema = exports.PolicyLimitDtoSchema = exports.PolicyUtilizationsDtoSchema = exports.PolicyUtilizationDtoSchema = exports.PolicyKeyEnum = exports.PolicyKeyList = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PolicyKeyList = {
6
+ AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA",
7
+ MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT",
8
+ PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT",
9
+ ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT",
10
+ };
11
+ exports.PolicyKeyEnum = zod_1.z.enum(exports.PolicyKeyList);
12
+ exports.PolicyUtilizationDtoSchema = zod_1.z.object({
13
+ limit: zod_1.z
14
+ .number()
15
+ .meta({ description: "The cap for this policy. 0 means unlimited.", example: 50 }),
16
+ used: zod_1.z.number().meta({ description: "How much of the cap is currently used.", example: 12 }),
17
+ reset: zod_1.z.iso
18
+ .datetime()
19
+ .optional()
20
+ .meta({ description: "When the counter resets. Absent for limits, which never reset." }),
21
+ });
22
+ exports.PolicyUtilizationsDtoSchema = zod_1.z.record(exports.PolicyKeyEnum, exports.PolicyUtilizationDtoSchema);
23
+ exports.PolicyLimitDtoSchema = zod_1.z
24
+ .number()
25
+ .int()
26
+ .min(0)
27
+ .meta({ description: "The new cap for this policy key. 0 means unlimited.", example: 100 });
28
+ /**
29
+ * New limits keyed by policy key. Omitted keys keep the limit they already
30
+ * have, so a caller only sends what it wants to change.
31
+ */
32
+ exports.SetPolicyLimitsDtoSchema = zod_1.z
33
+ .partialRecord(exports.PolicyKeyEnum, exports.PolicyLimitDtoSchema)
34
+ .refine((limits) => Object.keys(limits).length > 0, {
35
+ message: "At least one policy key must be provided",
36
+ })
37
+ .meta({
38
+ description: "New limits keyed by policy key. Keys that are omitted keep their current limit. At least one key is required.",
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-dpp/dto",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/open-dpp/open-dpp#readme",
@@ -42,7 +42,7 @@
42
42
  "@tsconfig/node-lts": "^24.0.0",
43
43
  "@tsconfig/node-ts": "^23.6.4",
44
44
  "@types/jest": "^30.0.0",
45
- "@types/node": "^22.0.0",
45
+ "@types/node": "^22.20.3",
46
46
  "jest": "^30.4.2",
47
47
  "typescript": "^5.9.3"
48
48
  },
package/src/index.ts CHANGED
@@ -75,6 +75,7 @@ export * from "./bulk-import/bulk-import-run.dto";
75
75
  export * from "./bulk-import/bulk-import-run-item.dto";
76
76
  export * from "./bulk-import/bulk-import-parse-result.dto";
77
77
  export * from "./organizations/member.dto";
78
+ export * from "./organizations/organization.dto";
78
79
  export * from "./passports/passport.dto";
79
80
  export * from "./permalinks/permalink.dto";
80
81
  export * from "./presentation-configurations/presentation-configuration.dto";
@@ -102,3 +103,4 @@ export * from "./unique-product-identifiers/unique-product-identifier-list-item.
102
103
  export * from "./unique-product-identifiers/create-unique-product-identifier.dto";
103
104
  export * from "./unique-product-identifiers/create-internal-unique-product-identifier.dto";
104
105
  export * from "./unique-product-identifiers/update-unique-product-identifier.dto";
106
+ export * from "./policy/policy.dto";
@@ -0,0 +1,60 @@
1
+ import { describe, expect, it } from "@jest/globals";
2
+ import { OrganizationCreateDtoSchema, OrganizationDtoSchema } from "./organization.dto";
3
+
4
+ const validOrganization = {
5
+ id: "690cf22459cdae7ce188c1f8",
6
+ name: "ACME GmbH",
7
+ logo: "https://example.com/logo.png",
8
+ metadata: { reference: "mollie:tr_123" },
9
+ createdAt: "2026-09-14T10:00:00.000Z",
10
+ };
11
+
12
+ describe("OrganizationDtoSchema", () => {
13
+ it("parses a full organization", () => {
14
+ expect(OrganizationDtoSchema.parse(validOrganization)).toEqual(validOrganization);
15
+ });
16
+
17
+ it("accepts a null or missing logo", () => {
18
+ expect(OrganizationDtoSchema.parse({ ...validOrganization, logo: null }).logo).toBeNull();
19
+ const { logo: _logo, ...withoutLogo } = validOrganization;
20
+ expect(OrganizationDtoSchema.parse(withoutLogo).logo).toBeUndefined();
21
+ });
22
+
23
+ it("strips slug and members from a response", () => {
24
+ const parsed = OrganizationDtoSchema.parse({
25
+ ...validOrganization,
26
+ slug: validOrganization.id,
27
+ members: [],
28
+ });
29
+ expect(parsed).toEqual(validOrganization);
30
+ expect(parsed).not.toHaveProperty("slug");
31
+ expect(parsed).not.toHaveProperty("members");
32
+ });
33
+
34
+ it("rejects a missing id", () => {
35
+ const { id: _id, ...rest } = validOrganization;
36
+ expect(() => OrganizationDtoSchema.parse(rest)).toThrow();
37
+ });
38
+ });
39
+
40
+ describe("OrganizationCreateDtoSchema", () => {
41
+ it("accepts a name and trims it", () => {
42
+ expect(OrganizationCreateDtoSchema.parse({ name: " ACME GmbH " })).toEqual({
43
+ name: "ACME GmbH",
44
+ });
45
+ });
46
+
47
+ it("ignores a provided slug", () => {
48
+ expect(OrganizationCreateDtoSchema.parse({ name: "ACME GmbH", slug: "acme" })).toEqual({
49
+ name: "ACME GmbH",
50
+ });
51
+ });
52
+
53
+ it.each(["", " "])("rejects the name %j", (name) => {
54
+ expect(() => OrganizationCreateDtoSchema.parse({ name })).toThrow();
55
+ });
56
+
57
+ it("rejects a missing name", () => {
58
+ expect(() => OrganizationCreateDtoSchema.parse({})).toThrow();
59
+ });
60
+ });
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * Wire shape of an organization. The internal `slug` (always equal to `id`)
5
+ * and better-auth's `members` array are deliberately not part of it.
6
+ */
7
+ export const OrganizationDtoSchema = z.object({
8
+ id: z.string(),
9
+ name: z.string(),
10
+ /** @deprecated Use the organization's Branding logo instead. */
11
+ logo: z.string().nullable().optional(),
12
+ metadata: z.record(z.string(), z.unknown()),
13
+ createdAt: z.iso.datetime(),
14
+ });
15
+
16
+ export type OrganizationDto = z.infer<typeof OrganizationDtoSchema>;
17
+
18
+ /**
19
+ * Body of `POST /organizations`. A `slug` sent by legacy callers is stripped:
20
+ * the server derives it from the organization id.
21
+ */
22
+ export const OrganizationCreateDtoSchema = z.object({
23
+ name: z.string().trim().min(1),
24
+ });
25
+
26
+ export type OrganizationCreateDto = z.infer<typeof OrganizationCreateDtoSchema>;
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+
3
+ export const PolicyKeyList = {
4
+ AI_TOKEN_QUOTA: "AI_TOKEN_QUOTA",
5
+ MEDIA_STORAGE_LIMIT: "MEDIA_STORAGE_LIMIT",
6
+ PASSPORT_CREATE_LIMIT: "PASSPORT_CREATE_LIMIT",
7
+ ORGANIZATION_MEMBER_LIMIT: "ORGANIZATION_MEMBER_LIMIT",
8
+ } as const;
9
+
10
+ export const PolicyKeyEnum = z.enum(PolicyKeyList);
11
+ export type PolicyKey = z.infer<typeof PolicyKeyEnum>;
12
+
13
+ export const PolicyUtilizationDtoSchema = z.object({
14
+ limit: z
15
+ .number()
16
+ .meta({ description: "The cap for this policy. 0 means unlimited.", example: 50 }),
17
+ used: z.number().meta({ description: "How much of the cap is currently used.", example: 12 }),
18
+ reset: z.iso
19
+ .datetime()
20
+ .optional()
21
+ .meta({ description: "When the counter resets. Absent for limits, which never reset." }),
22
+ });
23
+
24
+ export type PolicyUtilizationDto = z.infer<typeof PolicyUtilizationDtoSchema>;
25
+
26
+ export const PolicyUtilizationsDtoSchema = z.record(PolicyKeyEnum, PolicyUtilizationDtoSchema);
27
+
28
+ export type PolicyUtilizationDtoType = z.infer<typeof PolicyUtilizationsDtoSchema>;
29
+
30
+ export const PolicyLimitDtoSchema = z
31
+ .number()
32
+ .int()
33
+ .min(0)
34
+ .meta({ description: "The new cap for this policy key. 0 means unlimited.", example: 100 });
35
+
36
+ /**
37
+ * New limits keyed by policy key. Omitted keys keep the limit they already
38
+ * have, so a caller only sends what it wants to change.
39
+ */
40
+ export const SetPolicyLimitsDtoSchema = z
41
+ .partialRecord(PolicyKeyEnum, PolicyLimitDtoSchema)
42
+ .refine((limits) => Object.keys(limits).length > 0, {
43
+ message: "At least one policy key must be provided",
44
+ })
45
+ .meta({
46
+ description:
47
+ "New limits keyed by policy key. Keys that are omitted keep their current limit. At least one key is required.",
48
+ });
49
+
50
+ export type SetPolicyLimitsDto = z.infer<typeof SetPolicyLimitsDtoSchema>;
@@ -0,0 +1,60 @@
1
+ import { PolicyKeyList, SetPolicyLimitsDtoSchema } from "./policy.dto";
2
+
3
+ describe("setPolicyLimitsDtoSchema", () => {
4
+ it("accepts a single policy key", () => {
5
+ const result = SetPolicyLimitsDtoSchema.safeParse({
6
+ [PolicyKeyList.AI_TOKEN_QUOTA]: 1000,
7
+ });
8
+
9
+ expect(result.success).toBe(true);
10
+ expect(result.data).toEqual({ [PolicyKeyList.AI_TOKEN_QUOTA]: 1000 });
11
+ });
12
+
13
+ it("accepts several policy keys at once", () => {
14
+ const result = SetPolicyLimitsDtoSchema.safeParse({
15
+ [PolicyKeyList.AI_TOKEN_QUOTA]: 1000,
16
+ [PolicyKeyList.MEDIA_STORAGE_LIMIT]: 500,
17
+ [PolicyKeyList.PASSPORT_CREATE_LIMIT]: 0,
18
+ });
19
+
20
+ expect(result.success).toBe(true);
21
+ });
22
+
23
+ it("leaves unspecified keys out instead of demanding every key", () => {
24
+ const result = SetPolicyLimitsDtoSchema.safeParse({
25
+ [PolicyKeyList.MEDIA_STORAGE_LIMIT]: 500,
26
+ });
27
+
28
+ expect(result.success).toBe(true);
29
+ expect(Object.keys(result.data!)).toEqual([PolicyKeyList.MEDIA_STORAGE_LIMIT]);
30
+ });
31
+
32
+ it("rejects an empty record", () => {
33
+ const result = SetPolicyLimitsDtoSchema.safeParse({});
34
+
35
+ expect(result.success).toBe(false);
36
+ expect(result.error!.issues[0].message).toBe("At least one policy key must be provided");
37
+ });
38
+
39
+ it("rejects an unknown policy key", () => {
40
+ const result = SetPolicyLimitsDtoSchema.safeParse({ NOT_A_POLICY: 10 });
41
+
42
+ expect(result.success).toBe(false);
43
+ });
44
+
45
+ it("rejects a negative limit", () => {
46
+ const result = SetPolicyLimitsDtoSchema.safeParse({
47
+ [PolicyKeyList.AI_TOKEN_QUOTA]: -1,
48
+ });
49
+
50
+ expect(result.success).toBe(false);
51
+ });
52
+
53
+ it("rejects a fractional limit", () => {
54
+ const result = SetPolicyLimitsDtoSchema.safeParse({
55
+ [PolicyKeyList.AI_TOKEN_QUOTA]: 1.5,
56
+ });
57
+
58
+ expect(result.success).toBe(false);
59
+ });
60
+ });