@calmlens/js-sdk 0.0.0 → 0.0.2

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.
Files changed (69) hide show
  1. package/README.md +190 -22
  2. package/cjs/ApiKey.d.ts +31 -0
  3. package/cjs/ApiKey.js +59 -0
  4. package/cjs/Asset.d.ts +83 -3
  5. package/cjs/Asset.js +198 -28
  6. package/cjs/Auth.d.ts +95 -0
  7. package/cjs/Auth.js +2 -0
  8. package/cjs/CalmLensClient.d.ts +28 -11
  9. package/cjs/CalmLensClient.js +138 -77
  10. package/cjs/CalmLensTypes.d.ts +2 -0
  11. package/cjs/Classification.js +40 -7
  12. package/cjs/DocMetaTypes.d.ts +7 -0
  13. package/cjs/DocMetaTypes.js +7 -0
  14. package/cjs/Page.d.ts +42 -0
  15. package/cjs/Page.js +94 -0
  16. package/cjs/PublicApiSchemas.d.ts +1593 -0
  17. package/cjs/PublicApiSchemas.js +334 -0
  18. package/cjs/RequestInfo.d.ts +23 -0
  19. package/cjs/RequestInfo.js +2 -0
  20. package/cjs/Roles.d.ts +21 -0
  21. package/cjs/Roles.js +84 -0
  22. package/cjs/SharedConstants.d.ts +134 -0
  23. package/cjs/SharedConstants.js +125 -0
  24. package/cjs/SharedTypes.d.ts +6 -1
  25. package/cjs/User.d.ts +17 -0
  26. package/cjs/User.js +51 -0
  27. package/cjs/UtilTypes.d.ts +30 -0
  28. package/cjs/UtilTypes.js +4 -0
  29. package/cjs/Workflow.d.ts +58 -0
  30. package/cjs/Workflow.js +83 -0
  31. package/cjs/ZodUtils.d.ts +39 -0
  32. package/cjs/ZodUtils.js +328 -0
  33. package/cjs/index.js +4 -1
  34. package/esm/ApiKey.d.ts +31 -0
  35. package/esm/ApiKey.js +23 -0
  36. package/esm/Asset.d.ts +83 -3
  37. package/esm/Asset.js +148 -12
  38. package/esm/Auth.d.ts +95 -0
  39. package/esm/Auth.js +1 -0
  40. package/esm/CalmLensClient.d.ts +28 -11
  41. package/esm/CalmLensClient.js +104 -55
  42. package/esm/CalmLensTypes.d.ts +2 -0
  43. package/esm/Classification.js +1 -1
  44. package/esm/DocMetaTypes.d.ts +7 -0
  45. package/esm/DocMetaTypes.js +4 -0
  46. package/esm/Page.d.ts +42 -0
  47. package/esm/Page.js +55 -0
  48. package/esm/PublicApiSchemas.d.ts +1593 -0
  49. package/esm/PublicApiSchemas.js +298 -0
  50. package/esm/RequestInfo.d.ts +23 -0
  51. package/esm/RequestInfo.js +1 -0
  52. package/esm/Roles.d.ts +21 -0
  53. package/esm/Roles.js +45 -0
  54. package/esm/SharedConstants.d.ts +134 -0
  55. package/esm/SharedConstants.js +122 -0
  56. package/esm/SharedTypes.d.ts +6 -1
  57. package/esm/User.d.ts +17 -0
  58. package/esm/User.js +15 -0
  59. package/esm/UtilTypes.d.ts +30 -0
  60. package/esm/UtilTypes.js +1 -0
  61. package/esm/Workflow.d.ts +58 -0
  62. package/esm/Workflow.js +46 -0
  63. package/esm/ZodUtils.d.ts +39 -0
  64. package/esm/ZodUtils.js +266 -0
  65. package/package.json +10 -10
  66. package/cjs/SchemaUtils.d.ts +0 -11
  67. package/cjs/SchemaUtils.js +0 -63
  68. package/esm/SchemaUtils.d.ts +0 -11
  69. package/esm/SchemaUtils.js +0 -46
package/esm/User.js ADDED
@@ -0,0 +1,15 @@
1
+ import * as zod from "zod/v4";
2
+ import { metaStore, primaryKey } from "zodbase";
3
+ import { ROLE_SCHEMA } from "./Roles";
4
+ import { createdAtField, saneStringField, updatedAtField } from "./ZodUtils";
5
+ export const USER_SCHEMA = zod.object({
6
+ id: zod.string().meta(metaStore([primaryKey()])),
7
+ createdAt: createdAtField(),
8
+ updatedAt: updatedAtField(),
9
+ email: saneStringField().nullish(),
10
+ firstName: saneStringField().nullish(),
11
+ lastName: saneStringField().nullish(),
12
+ customerId: saneStringField().nullish(),
13
+ roles: zod.array(ROLE_SCHEMA).nullish(),
14
+ freeUploadsUsed: zod.number().int().nonnegative().nullish(),
15
+ });
@@ -0,0 +1,30 @@
1
+ import type React from "react";
2
+ import type { HTMLProps } from "react";
3
+ import type { User } from "./User";
4
+ export type AppEnvironment = "local" | "dev" | "main";
5
+ export type Breakpoint = "mobile" | "desktop";
6
+ export type CommonHtmlProps = Omit<HTMLProps<HTMLDivElement>, "ref" | "as"> & {
7
+ ref?: React.Ref<HTMLDivElement>;
8
+ };
9
+ export type Class<T> = new (...args: any[]) => T;
10
+ export interface AuthState {
11
+ user: User;
12
+ subscription?: any | null;
13
+ }
14
+ export declare const FIT_TYPES: readonly ["contain", "cover", "fill"];
15
+ export type Fit = (typeof FIT_TYPES)[number];
16
+ export interface FieldSettings {
17
+ name: string;
18
+ disabled?: boolean;
19
+ value?: any;
20
+ }
21
+ export interface ImpersonationData {
22
+ originalUserId: string;
23
+ targetUser: {
24
+ id: string;
25
+ email: string | undefined | null;
26
+ firstName: string | undefined | null;
27
+ lastName: string | undefined | null;
28
+ };
29
+ startedAt: number;
30
+ }
@@ -0,0 +1 @@
1
+ export const FIT_TYPES = ["contain", "cover", "fill"];
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Workflow system for tracking asset processing pipelines
3
+ */
4
+ import * as zod from "zod/v4";
5
+ export type WorkflowStepStatus = "pending" | "in_progress" | "completed" | "skipped" | "error";
6
+ export declare const WORKFLOW_STEP_STATUS_SCHEMA: zod.ZodEnum<{
7
+ error: "error";
8
+ pending: "pending";
9
+ in_progress: "in_progress";
10
+ completed: "completed";
11
+ skipped: "skipped";
12
+ }>;
13
+ export declare const WORKFLOW_STEP_SCHEMA: zod.ZodObject<{
14
+ id: zod.ZodString;
15
+ label: zod.ZodString;
16
+ status: zod.ZodEnum<{
17
+ error: "error";
18
+ pending: "pending";
19
+ in_progress: "in_progress";
20
+ completed: "completed";
21
+ skipped: "skipped";
22
+ }>;
23
+ optional: zod.ZodOptional<zod.ZodBoolean>;
24
+ startedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
25
+ completedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
26
+ error: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
27
+ }, zod.z.core.$strip>;
28
+ export declare const WORKFLOW_SCHEMA: zod.ZodObject<{
29
+ id: zod.ZodString;
30
+ name: zod.ZodString;
31
+ steps: zod.ZodArray<zod.ZodObject<{
32
+ id: zod.ZodString;
33
+ label: zod.ZodString;
34
+ status: zod.ZodEnum<{
35
+ error: "error";
36
+ pending: "pending";
37
+ in_progress: "in_progress";
38
+ completed: "completed";
39
+ skipped: "skipped";
40
+ }>;
41
+ optional: zod.ZodOptional<zod.ZodBoolean>;
42
+ startedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
43
+ completedAt: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
44
+ error: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
45
+ }, zod.z.core.$strip>>;
46
+ createdAt: zod.ZodString;
47
+ updatedAt: zod.ZodString;
48
+ }, zod.z.core.$strip>;
49
+ export type WorkflowStep = zod.infer<typeof WORKFLOW_STEP_SCHEMA>;
50
+ export type Workflow = zod.infer<typeof WORKFLOW_SCHEMA>;
51
+ /**
52
+ * Create a new workflow
53
+ */
54
+ export declare function createWorkflow(id: string, name: string, stepDefinitions: Array<{
55
+ id: string;
56
+ label: string;
57
+ optional?: boolean;
58
+ }>): Workflow;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Workflow system for tracking asset processing pipelines
3
+ */
4
+ import * as zod from "zod/v4";
5
+ export const WORKFLOW_STEP_STATUS_SCHEMA = zod.enum([
6
+ "pending",
7
+ "in_progress",
8
+ "completed",
9
+ "skipped",
10
+ "error",
11
+ ]);
12
+ export const WORKFLOW_STEP_SCHEMA = zod.object({
13
+ id: zod.string(),
14
+ label: zod.string(),
15
+ status: WORKFLOW_STEP_STATUS_SCHEMA,
16
+ optional: zod.boolean().optional(),
17
+ startedAt: zod.string().nullish(),
18
+ completedAt: zod.string().nullish(),
19
+ error: zod.string().nullish(),
20
+ });
21
+ export const WORKFLOW_SCHEMA = zod.object({
22
+ id: zod.string(),
23
+ name: zod.string(),
24
+ steps: zod.array(WORKFLOW_STEP_SCHEMA),
25
+ createdAt: zod.string(),
26
+ updatedAt: zod.string(),
27
+ });
28
+ /**
29
+ * Create a new workflow
30
+ */
31
+ export function createWorkflow(id, name, stepDefinitions) {
32
+ const now = new Date().toISOString();
33
+ return {
34
+ id,
35
+ name,
36
+ steps: stepDefinitions.map((def, index) => ({
37
+ id: def.id,
38
+ label: def.label,
39
+ status: index === 0 ? "in_progress" : "pending",
40
+ optional: def.optional,
41
+ startedAt: index === 0 ? now : undefined,
42
+ })),
43
+ createdAt: now,
44
+ updatedAt: now,
45
+ };
46
+ }
@@ -0,0 +1,39 @@
1
+ import * as zod from "zod/v4";
2
+ import type { Class } from "./UtilTypes";
3
+ export declare const isZodRequired: (type: zod.ZodType) => boolean;
4
+ export interface SchemaDisplayInfo {
5
+ type?: string;
6
+ mainType: string;
7
+ optional?: boolean;
8
+ description?: string;
9
+ defaultValue?: string | number | boolean;
10
+ placeholder?: string;
11
+ enumValues?: string[];
12
+ namedType?: string;
13
+ }
14
+ export declare const getZodTypeChain: (type: zod.ZodType) => zod.ZodType[];
15
+ export declare const getSchemaDisplayInfo: (type: zod.ZodType) => SchemaDisplayInfo;
16
+ export declare const isZodTypeExtends: (type: zod.ZodType, zodType: Class<zod.ZodType>) => zod.ZodType | false;
17
+ export type NonNullableObject<T> = {
18
+ [K in keyof T]: NonNullable<T[K]>;
19
+ };
20
+ export declare const nonNullable: <T extends zod.ZodRawShape>(schema: zod.ZodObject<T>) => zod.ZodObject<NonNullableObject<T>>;
21
+ export interface SaneStringOptions {
22
+ type?: "small" | "medium" | "large";
23
+ minWidth?: number;
24
+ }
25
+ export declare const primaryUuidField: () => zod.ZodString;
26
+ export declare const uuidField: () => zod.ZodString;
27
+ export declare const createdAtField: () => zod.ZodNumber;
28
+ export declare const updatedAtField: () => zod.ZodOptional<zod.ZodNumber>;
29
+ export interface SaneStringOptions {
30
+ type?: "small" | "medium" | "large";
31
+ minWidth?: number;
32
+ }
33
+ export declare const saneStringField: (options?: SaneStringOptions) => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
34
+ export declare const urlField: () => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
35
+ export declare const rsqlField: () => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
36
+ /**
37
+ * Converts a Zod schema to a TypeScript type definition string
38
+ */
39
+ export declare const zodSchemaToTypeScript: (schema: zod.ZodType, indent?: number) => string;
@@ -0,0 +1,266 @@
1
+ import * as zod from "zod/v4";
2
+ import { getMetaItem } from "zod-meta";
3
+ import { metaStore, primaryKey, updatedAt } from "zodbase";
4
+ import { docPropertyInfo } from "./DocMetaTypes";
5
+ import { validateUrl } from "./ValidationUtils";
6
+ export const isZodRequired = (type) => {
7
+ return !isZodTypeExtends(type, zod.ZodOptional);
8
+ };
9
+ export const getZodTypeChain = (type) => {
10
+ var _a;
11
+ const chain = [];
12
+ let current = type;
13
+ while (current === null || current === void 0 ? void 0 : current.def) {
14
+ chain.push(current);
15
+ const innerType = (_a = current.def.innerType) !== null && _a !== void 0 ? _a : current.def.in;
16
+ current = innerType === current ? null : innerType;
17
+ }
18
+ return chain;
19
+ };
20
+ export const getSchemaDisplayInfo = (type) => {
21
+ const chain = getZodTypeChain(type);
22
+ const metaItem = getMetaItem(type, docPropertyInfo);
23
+ const description = (metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.description) || type.description;
24
+ const defaultValue = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.defaultValue;
25
+ const placeholder = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.placeholder;
26
+ const namedType = metaItem === null || metaItem === void 0 ? void 0 : metaItem.data.namedType;
27
+ let mainType = type;
28
+ const qualifierTypes = new Set();
29
+ let enumValues;
30
+ for (const item of chain) {
31
+ if (item.def.innerType) {
32
+ if (item.def.type === "nullable" || item.def.type === "optional") {
33
+ qualifierTypes.add("optional");
34
+ }
35
+ }
36
+ else {
37
+ mainType = item;
38
+ }
39
+ // Check for enum values
40
+ if (item.def.type === "enum") {
41
+ // @ts-expect-error
42
+ enumValues = Object.values(item.def.entries);
43
+ }
44
+ }
45
+ let typeDisplay = mainType.def.type;
46
+ // If it's an enum, show the enum values
47
+ if (enumValues && enumValues.length > 0) {
48
+ typeDisplay = "enum";
49
+ }
50
+ return {
51
+ mainType: mainType.def.type,
52
+ description,
53
+ defaultValue,
54
+ placeholder,
55
+ optional: !isZodRequired(type),
56
+ enumValues,
57
+ namedType,
58
+ type: `${typeDisplay}${qualifierTypes.size > 0 ? ` (${Array.from(qualifierTypes).join(", ")})` : ""}`,
59
+ };
60
+ };
61
+ export const isZodTypeExtends = (type, zodType) => {
62
+ if (type instanceof zodType) {
63
+ return type;
64
+ }
65
+ // @ts-expect-error
66
+ if (type.def.type === "union") {
67
+ // @ts-expect-error
68
+ for (const option of type.def.options) {
69
+ if (isZodTypeExtends(option, zodType)) {
70
+ return option;
71
+ }
72
+ }
73
+ return false;
74
+ }
75
+ // @ts-expect-error
76
+ const rootType = type.def.innerType;
77
+ if (rootType) {
78
+ return isZodTypeExtends(rootType, zodType);
79
+ }
80
+ return false;
81
+ };
82
+ export const nonNullable = (schema) => {
83
+ return schema.refine((data) => {
84
+ if (data === null || data === undefined) {
85
+ return false;
86
+ }
87
+ for (const key in data) {
88
+ if (data[key] === null || data[key] === undefined) {
89
+ return false;
90
+ }
91
+ }
92
+ return true;
93
+ }, {
94
+ message: "Value cannot contain null or undefined",
95
+ });
96
+ };
97
+ export const primaryUuidField = () => zod
98
+ .string()
99
+ .uuid({
100
+ version: "v4",
101
+ })
102
+ .meta(metaStore([primaryKey()]));
103
+ export const uuidField = () => zod.string().uuid({
104
+ version: "v4",
105
+ });
106
+ export const createdAtField = () => zod.number().int();
107
+ export const updatedAtField = () => zod
108
+ .number()
109
+ .int()
110
+ .optional()
111
+ .meta(metaStore([updatedAt()]));
112
+ const SIZE_LIMITS = {
113
+ small: 64,
114
+ medium: 200,
115
+ large: 1500,
116
+ };
117
+ export const saneStringField = (options) => {
118
+ return zod
119
+ .string()
120
+ .transform((value) => value.trim())
121
+ .refine((value) => {
122
+ if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) {
123
+ return false;
124
+ }
125
+ return true;
126
+ }, "Not long enough")
127
+ .refine((value) => {
128
+ var _a;
129
+ const sizeLimit = SIZE_LIMITS[(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : "medium"];
130
+ return typeof value === "string" && value.length < sizeLimit;
131
+ }, "Too long");
132
+ };
133
+ export const urlField = () => saneStringField().refine((value) => {
134
+ /*if (encodeURI(value) !== value) {
135
+ return false;
136
+ }*/
137
+ const parsedUrl = validateUrl(value);
138
+ return Boolean(parsedUrl);
139
+ }, "Invalid link");
140
+ export const rsqlField = () => {
141
+ return saneStringField({
142
+ type: "large",
143
+ }).meta(metaStore([
144
+ docPropertyInfo({
145
+ description: "RSQL filter string for filtering results. See [REST API Documentation](/docs/rest) for detailed syntax.\n\n**Examples:**\n- `status==rejected;parentId==null` (AND conditions)\n- `status==rejected,status==error` (OR conditions)\n- `price>100;price<500` (range filtering)\n- `tags=in=(react,typescript)` (array membership)\n\n**Supported operators:** `==`, `!=`, `>`, `>=`, `<`, `<=`, `=in=`, `=out=`, `=like=`\n\n**Logical operators:** `;` (AND), `,` (OR)",
146
+ placeholder: "status==approved;type==image",
147
+ }),
148
+ ]));
149
+ };
150
+ /**
151
+ * Converts a Zod schema to a TypeScript type definition string
152
+ */
153
+ export const zodSchemaToTypeScript = (schema, indent = 0) => {
154
+ const spaces = " ".repeat(indent);
155
+ const chain = getZodTypeChain(schema);
156
+ // Check for optional/nullable
157
+ const isOptional = chain.some((s) => s.def.type === "optional");
158
+ const isNullable = chain.some((s) => s.def.type === "nullable");
159
+ // Get the core type
160
+ let coreSchema = schema;
161
+ for (const s of chain) {
162
+ if (s.def.innerType) {
163
+ coreSchema = s.def.innerType;
164
+ }
165
+ }
166
+ let typeStr = "";
167
+ // Handle different types
168
+ if (coreSchema.def.type === "string") {
169
+ typeStr = "string";
170
+ }
171
+ else if (coreSchema.def.type === "number") {
172
+ typeStr = "number";
173
+ }
174
+ else if (coreSchema.def.type === "boolean") {
175
+ typeStr = "boolean";
176
+ }
177
+ else if (coreSchema.def.type === "bigint") {
178
+ typeStr = "bigint";
179
+ }
180
+ else if (coreSchema.def.type === "date") {
181
+ typeStr = "Date";
182
+ }
183
+ else if (coreSchema.def.type === "null") {
184
+ typeStr = "null";
185
+ }
186
+ else if (coreSchema.def.type === "undefined") {
187
+ typeStr = "undefined";
188
+ }
189
+ else if (coreSchema.def.type === "any") {
190
+ typeStr = "any";
191
+ }
192
+ else if (coreSchema.def.type === "unknown") {
193
+ typeStr = "unknown";
194
+ }
195
+ else if (coreSchema.def.type === "never") {
196
+ typeStr = "never";
197
+ }
198
+ else if (coreSchema.def.type === "void") {
199
+ typeStr = "void";
200
+ }
201
+ else if (coreSchema.def.type === "literal") {
202
+ const value = coreSchema.def.value;
203
+ typeStr = typeof value === "string" ? `"${value}"` : String(value);
204
+ }
205
+ else if (coreSchema.def.type === "enum") {
206
+ const entries = Object.values(coreSchema.def.entries);
207
+ typeStr = entries.map((e) => `"${e}"`).join(" | ");
208
+ }
209
+ else if (coreSchema.def.type === "array") {
210
+ const element = coreSchema.def.element;
211
+ const elementType = zodSchemaToTypeScript(element, indent);
212
+ typeStr = `${elementType}[]`;
213
+ }
214
+ else if (coreSchema.def.type === "object") {
215
+ const shape = coreSchema.def.shape || {};
216
+ const fields = Object.entries(shape).map(([key, fieldSchema]) => {
217
+ const fieldInfo = getSchemaDisplayInfo(fieldSchema);
218
+ const fieldType = zodSchemaToTypeScript(fieldSchema, indent + 1);
219
+ const optional = fieldInfo.optional ? "?" : "";
220
+ return `${spaces} ${key}${optional}: ${fieldType};`;
221
+ });
222
+ if (fields.length === 0) {
223
+ typeStr = "{}";
224
+ }
225
+ else {
226
+ typeStr = `{\n${fields.join("\n")}\n${spaces}}`;
227
+ }
228
+ }
229
+ else if (coreSchema.def.type === "union") {
230
+ const options = coreSchema.def.options || [];
231
+ const types = options.map((opt) => zodSchemaToTypeScript(opt, indent));
232
+ typeStr = types.join(" | ");
233
+ }
234
+ else if (coreSchema.def.type === "intersection") {
235
+ const left = coreSchema.def.left;
236
+ const right = coreSchema.def.right;
237
+ const leftType = zodSchemaToTypeScript(left, indent);
238
+ const rightType = zodSchemaToTypeScript(right, indent);
239
+ typeStr = `${leftType} & ${rightType}`;
240
+ }
241
+ else if (coreSchema.def.type === "record") {
242
+ const keyType = coreSchema.def.keyType
243
+ ? zodSchemaToTypeScript(coreSchema.def.keyType, indent)
244
+ : "string";
245
+ const valueType = coreSchema.def.valueType
246
+ ? zodSchemaToTypeScript(coreSchema.def.valueType, indent)
247
+ : "any";
248
+ typeStr = `Record<${keyType}, ${valueType}>`;
249
+ }
250
+ else if (coreSchema.def.type === "tuple") {
251
+ const items = coreSchema.def.items || [];
252
+ const types = items.map((item) => zodSchemaToTypeScript(item, indent));
253
+ typeStr = `[${types.join(", ")}]`;
254
+ }
255
+ else {
256
+ typeStr = "unknown";
257
+ }
258
+ // Add optional/nullable modifiers
259
+ if (isNullable && !typeStr.includes("null")) {
260
+ typeStr = `${typeStr} | null`;
261
+ }
262
+ if (isOptional && indent === 0) {
263
+ typeStr = `${typeStr} | undefined`;
264
+ }
265
+ return typeStr;
266
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calmlens/js-sdk",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "main": "cjs/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "module": "esm/index.js",
@@ -15,7 +15,7 @@
15
15
  "cleanup": "rimraf esm && rimraf cjs",
16
16
  "build": "npm run cleanup && npm run build:esm && npm run build:cjs",
17
17
  "build:esm": "tsc --module es2015 --target es2016 --outDir esm --preserveWatchOutput && rm -rf esm/tests && node scripts/post-build.js esm",
18
- "build:cjs": "tsc --module commonjs --target es5 --outDir cjs --preserveWatchOutput && rm -rf cjs/tests && node scripts/post-build.js cjs",
18
+ "build:cjs": "tsc --module commonjs --moduleResolution node --target es5 --outDir cjs --preserveWatchOutput && rm -rf cjs/tests && node scripts/post-build.js cjs",
19
19
  "website:dev": "cd website && npm run start",
20
20
  "website:deploy": "cd website && npm run deploy"
21
21
  },
@@ -49,23 +49,23 @@
49
49
  }
50
50
  },
51
51
  "devDependencies": {
52
- "@biomejs/biome": "^2.2.5",
53
- "@swc/core": "^1.13.5",
52
+ "@biomejs/biome": "^2.3.11",
53
+ "@swc/core": "^1.15.8",
54
54
  "@swc/jest": "^0.2.39",
55
- "@types/bun": "^1.2.22",
55
+ "@types/bun": "^1.3.6",
56
56
  "@types/jest": "^30.0.0",
57
- "@types/lodash": "^4.17.20",
58
- "@types/node": "24.6.2",
57
+ "@types/lodash": "^4.17.23",
58
+ "@types/node": "25.0.9",
59
59
  "chalk": "4.1.2",
60
60
  "cross-env": "10.1.0",
61
- "esbuild": "^0.25.10",
61
+ "esbuild": "^0.27.2",
62
62
  "jest": "30.2.0",
63
63
  "npm-run-all": "4.1.5",
64
- "rimraf": "6.0.1",
64
+ "rimraf": "6.1.2",
65
65
  "typescript": "^5.9.3",
66
66
  "zod": "4.1.3"
67
67
  },
68
68
  "dependencies": {
69
- "api-def": "^0.12.0-alpha.55"
69
+ "api-def": "^0.12.0"
70
70
  }
71
71
  }
@@ -1,11 +0,0 @@
1
- import * as zod from "zod/v4";
2
- export declare const primaryUuidField: () => zod.ZodString;
3
- export declare const uuidField: () => zod.ZodString;
4
- export declare const createdAtField: () => zod.ZodNumber;
5
- export declare const updatedAtField: () => zod.ZodOptional<zod.ZodNumber>;
6
- export interface SaneStringOptions {
7
- type?: "small" | "medium" | "large";
8
- minWidth?: number;
9
- }
10
- export declare const saneStringField: (options?: SaneStringOptions) => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
11
- export declare const urlField: () => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.urlField = exports.saneStringField = exports.updatedAtField = exports.createdAtField = exports.uuidField = exports.primaryUuidField = void 0;
4
- var zod = require("zod/v4");
5
- var zodbase_1 = require("zodbase");
6
- var ValidationUtils_1 = require("./ValidationUtils");
7
- var primaryUuidField = function () {
8
- return zod
9
- .string()
10
- .uuid({
11
- version: "v4",
12
- })
13
- .meta((0, zodbase_1.meta)([(0, zodbase_1.primaryKey)()]));
14
- };
15
- exports.primaryUuidField = primaryUuidField;
16
- var uuidField = function () {
17
- return zod.string().uuid({
18
- version: "v4",
19
- });
20
- };
21
- exports.uuidField = uuidField;
22
- var createdAtField = function () { return zod.number().int(); };
23
- exports.createdAtField = createdAtField;
24
- var updatedAtField = function () {
25
- return zod
26
- .number()
27
- .int()
28
- .optional()
29
- .meta((0, zodbase_1.meta)([(0, zodbase_1.updatedAt)()]));
30
- };
31
- exports.updatedAtField = updatedAtField;
32
- var SIZE_LIMITS = {
33
- small: 64,
34
- medium: 200,
35
- large: 1500,
36
- };
37
- var saneStringField = function (options) {
38
- return zod
39
- .string()
40
- .transform(function (value) { return value.trim(); })
41
- .refine(function (value) {
42
- if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) {
43
- return false;
44
- }
45
- return true;
46
- }, "Not long enough")
47
- .refine(function (value) {
48
- var _a;
49
- var sizeLimit = SIZE_LIMITS[(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : "medium"];
50
- return typeof value === "string" && value.length < sizeLimit;
51
- }, "Too long");
52
- };
53
- exports.saneStringField = saneStringField;
54
- var urlField = function () {
55
- return (0, exports.saneStringField)().refine(function (value) {
56
- /*if (encodeURI(value) !== value) {
57
- return false;
58
- }*/
59
- var parsedUrl = (0, ValidationUtils_1.validateUrl)(value);
60
- return Boolean(parsedUrl);
61
- }, "Invalid link");
62
- };
63
- exports.urlField = urlField;
@@ -1,11 +0,0 @@
1
- import * as zod from "zod/v4";
2
- export declare const primaryUuidField: () => zod.ZodString;
3
- export declare const uuidField: () => zod.ZodString;
4
- export declare const createdAtField: () => zod.ZodNumber;
5
- export declare const updatedAtField: () => zod.ZodOptional<zod.ZodNumber>;
6
- export interface SaneStringOptions {
7
- type?: "small" | "medium" | "large";
8
- minWidth?: number;
9
- }
10
- export declare const saneStringField: (options?: SaneStringOptions) => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
11
- export declare const urlField: () => zod.ZodPipe<zod.ZodString, zod.ZodTransform<string, string>>;
@@ -1,46 +0,0 @@
1
- import * as zod from "zod/v4";
2
- import { meta, primaryKey, updatedAt } from "zodbase";
3
- import { validateUrl } from "./ValidationUtils";
4
- export const primaryUuidField = () => zod
5
- .string()
6
- .uuid({
7
- version: "v4",
8
- })
9
- .meta(meta([primaryKey()]));
10
- export const uuidField = () => zod.string().uuid({
11
- version: "v4",
12
- });
13
- export const createdAtField = () => zod.number().int();
14
- export const updatedAtField = () => zod
15
- .number()
16
- .int()
17
- .optional()
18
- .meta(meta([updatedAt()]));
19
- const SIZE_LIMITS = {
20
- small: 64,
21
- medium: 200,
22
- large: 1500,
23
- };
24
- export const saneStringField = (options) => {
25
- return zod
26
- .string()
27
- .transform((value) => value.trim())
28
- .refine((value) => {
29
- if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) {
30
- return false;
31
- }
32
- return true;
33
- }, "Not long enough")
34
- .refine((value) => {
35
- var _a;
36
- const sizeLimit = SIZE_LIMITS[(_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : "medium"];
37
- return typeof value === "string" && value.length < sizeLimit;
38
- }, "Too long");
39
- };
40
- export const urlField = () => saneStringField().refine((value) => {
41
- /*if (encodeURI(value) !== value) {
42
- return false;
43
- }*/
44
- const parsedUrl = validateUrl(value);
45
- return Boolean(parsedUrl);
46
- }, "Invalid link");