raktajs 0.1.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.
Files changed (172) hide show
  1. package/README.md +90 -0
  2. package/dist/auto-import/generator.d.ts +4 -0
  3. package/dist/auto-import/generator.d.ts.map +1 -0
  4. package/dist/auto-import/index.d.ts +5 -0
  5. package/dist/auto-import/index.d.ts.map +1 -0
  6. package/dist/auto-import/index.js +153 -0
  7. package/dist/auto-import/index.js.map +11 -0
  8. package/dist/auto-import/scanner.d.ts +9 -0
  9. package/dist/auto-import/scanner.d.ts.map +1 -0
  10. package/dist/auto-import/types.d.ts +20 -0
  11. package/dist/auto-import/types.d.ts.map +1 -0
  12. package/dist/cli/build.d.ts +2 -0
  13. package/dist/cli/build.d.ts.map +1 -0
  14. package/dist/cli/dev.d.ts +2 -0
  15. package/dist/cli/dev.d.ts.map +1 -0
  16. package/dist/cli/doctor.d.ts +2 -0
  17. package/dist/cli/doctor.d.ts.map +1 -0
  18. package/dist/cli/imports.d.ts +2 -0
  19. package/dist/cli/imports.d.ts.map +1 -0
  20. package/dist/cli/index.d.ts +3 -0
  21. package/dist/cli/index.d.ts.map +1 -0
  22. package/dist/cli/make.d.ts +4 -0
  23. package/dist/cli/make.d.ts.map +1 -0
  24. package/dist/cli/rakta.d.ts +3 -0
  25. package/dist/cli/rakta.d.ts.map +1 -0
  26. package/dist/cli/rakta.js +1511 -0
  27. package/dist/cli/rakta.js.map +33 -0
  28. package/dist/cli/routes.d.ts +2 -0
  29. package/dist/cli/routes.d.ts.map +1 -0
  30. package/dist/cli/rpcTypes.d.ts +2 -0
  31. package/dist/cli/rpcTypes.d.ts.map +1 -0
  32. package/dist/cli/seo.d.ts +2 -0
  33. package/dist/cli/seo.d.ts.map +1 -0
  34. package/dist/cli/start.d.ts +2 -0
  35. package/dist/cli/start.d.ts.map +1 -0
  36. package/dist/components/Click.d.ts +11 -0
  37. package/dist/components/Click.d.ts.map +1 -0
  38. package/dist/components/Picture.d.ts +22 -0
  39. package/dist/components/Picture.d.ts.map +1 -0
  40. package/dist/components/index.d.ts +5 -0
  41. package/dist/components/index.d.ts.map +1 -0
  42. package/dist/components/index.js +1383 -0
  43. package/dist/components/index.js.map +15 -0
  44. package/dist/config/defineConfig.d.ts +64 -0
  45. package/dist/config/defineConfig.d.ts.map +1 -0
  46. package/dist/config/index.d.ts +4 -0
  47. package/dist/config/index.d.ts.map +1 -0
  48. package/dist/config/index.js +104 -0
  49. package/dist/config/index.js.map +11 -0
  50. package/dist/config/loadConfig.d.ts +4 -0
  51. package/dist/config/loadConfig.d.ts.map +1 -0
  52. package/dist/forge/build.d.ts +7 -0
  53. package/dist/forge/build.d.ts.map +1 -0
  54. package/dist/forge/devServer.d.ts +7 -0
  55. package/dist/forge/devServer.d.ts.map +1 -0
  56. package/dist/forge/index.d.ts +6 -0
  57. package/dist/forge/index.d.ts.map +1 -0
  58. package/dist/forge/index.js +579 -0
  59. package/dist/forge/index.js.map +17 -0
  60. package/dist/forge/inspect.d.ts +9 -0
  61. package/dist/forge/inspect.d.ts.map +1 -0
  62. package/dist/forge/types.d.ts +55 -0
  63. package/dist/forge/types.d.ts.map +1 -0
  64. package/dist/http/errors.d.ts +17 -0
  65. package/dist/http/errors.d.ts.map +1 -0
  66. package/dist/http/index.d.ts +4 -0
  67. package/dist/http/index.d.ts.map +1 -0
  68. package/dist/http/index.js +154 -0
  69. package/dist/http/index.js.map +11 -0
  70. package/dist/http/panturaFetch.d.ts +33 -0
  71. package/dist/http/panturaFetch.d.ts.map +1 -0
  72. package/dist/http/types.d.ts +24 -0
  73. package/dist/http/types.d.ts.map +1 -0
  74. package/dist/index.d.ts +30 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +3872 -0
  77. package/dist/index.js.map +50 -0
  78. package/dist/pwa/cache.d.ts +6 -0
  79. package/dist/pwa/cache.d.ts.map +1 -0
  80. package/dist/pwa/index.d.ts +5 -0
  81. package/dist/pwa/index.d.ts.map +1 -0
  82. package/dist/pwa/index.js +136 -0
  83. package/dist/pwa/index.js.map +12 -0
  84. package/dist/pwa/manifest.d.ts +11 -0
  85. package/dist/pwa/manifest.d.ts.map +1 -0
  86. package/dist/pwa/serviceWorker.d.ts +11 -0
  87. package/dist/pwa/serviceWorker.d.ts.map +1 -0
  88. package/dist/pwa/types.d.ts +45 -0
  89. package/dist/pwa/types.d.ts.map +1 -0
  90. package/dist/render/index.d.ts +5 -0
  91. package/dist/render/index.d.ts.map +1 -0
  92. package/dist/render/index.js +183 -0
  93. package/dist/render/index.js.map +11 -0
  94. package/dist/render/modes.d.ts +13 -0
  95. package/dist/render/modes.d.ts.map +1 -0
  96. package/dist/render/renderer.d.ts +15 -0
  97. package/dist/render/renderer.d.ts.map +1 -0
  98. package/dist/render/types.d.ts +72 -0
  99. package/dist/render/types.d.ts.map +1 -0
  100. package/dist/router/index.d.ts +5 -0
  101. package/dist/router/index.d.ts.map +1 -0
  102. package/dist/router/index.js +228 -0
  103. package/dist/router/index.js.map +12 -0
  104. package/dist/router/manifest.d.ts +6 -0
  105. package/dist/router/manifest.d.ts.map +1 -0
  106. package/dist/router/matcher.d.ts +5 -0
  107. package/dist/router/matcher.d.ts.map +1 -0
  108. package/dist/router/scanner.d.ts +6 -0
  109. package/dist/router/scanner.d.ts.map +1 -0
  110. package/dist/router/types.d.ts +45 -0
  111. package/dist/router/types.d.ts.map +1 -0
  112. package/dist/rpc/client.d.ts +24 -0
  113. package/dist/rpc/client.d.ts.map +1 -0
  114. package/dist/rpc/index.d.ts +6 -0
  115. package/dist/rpc/index.d.ts.map +1 -0
  116. package/dist/rpc/index.js +179 -0
  117. package/dist/rpc/index.js.map +13 -0
  118. package/dist/rpc/procedure.d.ts +28 -0
  119. package/dist/rpc/procedure.d.ts.map +1 -0
  120. package/dist/rpc/router.d.ts +12 -0
  121. package/dist/rpc/router.d.ts.map +1 -0
  122. package/dist/rpc/types.d.ts +48 -0
  123. package/dist/rpc/types.d.ts.map +1 -0
  124. package/dist/schema/array.d.ts +15 -0
  125. package/dist/schema/array.d.ts.map +1 -0
  126. package/dist/schema/boolean.d.ts +7 -0
  127. package/dist/schema/boolean.d.ts.map +1 -0
  128. package/dist/schema/errors.d.ts +21 -0
  129. package/dist/schema/errors.d.ts.map +1 -0
  130. package/dist/schema/index.d.ts +11 -0
  131. package/dist/schema/index.d.ts.map +1 -0
  132. package/dist/schema/index.js +393 -0
  133. package/dist/schema/index.js.map +16 -0
  134. package/dist/schema/number.d.ts +17 -0
  135. package/dist/schema/number.d.ts.map +1 -0
  136. package/dist/schema/object.d.ts +19 -0
  137. package/dist/schema/object.d.ts.map +1 -0
  138. package/dist/schema/string.d.ts +18 -0
  139. package/dist/schema/string.d.ts.map +1 -0
  140. package/dist/schema/types.d.ts +27 -0
  141. package/dist/schema/types.d.ts.map +1 -0
  142. package/dist/seo/head.d.ts +8 -0
  143. package/dist/seo/head.d.ts.map +1 -0
  144. package/dist/seo/index.d.ts +9 -0
  145. package/dist/seo/index.d.ts.map +1 -0
  146. package/dist/seo/index.js +1578 -0
  147. package/dist/seo/index.js.map +17 -0
  148. package/dist/seo/metadata.d.ts +106 -0
  149. package/dist/seo/metadata.d.ts.map +1 -0
  150. package/dist/seo/robots.d.ts +14 -0
  151. package/dist/seo/robots.d.ts.map +1 -0
  152. package/dist/seo/sitemap.d.ts +27 -0
  153. package/dist/seo/sitemap.d.ts.map +1 -0
  154. package/dist/store/createStore.d.ts +18 -0
  155. package/dist/store/createStore.d.ts.map +1 -0
  156. package/dist/store/index.d.ts +3 -0
  157. package/dist/store/index.d.ts.map +1 -0
  158. package/dist/store/index.js +925 -0
  159. package/dist/store/index.js.map +12 -0
  160. package/dist/store/types.d.ts +14 -0
  161. package/dist/store/types.d.ts.map +1 -0
  162. package/dist/tide/adapter.d.ts +8 -0
  163. package/dist/tide/adapter.d.ts.map +1 -0
  164. package/dist/tide/index.d.ts +4 -0
  165. package/dist/tide/index.d.ts.map +1 -0
  166. package/dist/tide/index.js +477 -0
  167. package/dist/tide/index.js.map +16 -0
  168. package/dist/tide/runtime.d.ts +8 -0
  169. package/dist/tide/runtime.d.ts.map +1 -0
  170. package/dist/tide/types.d.ts +40 -0
  171. package/dist/tide/types.d.ts.map +1 -0
  172. package/package.json +128 -0
@@ -0,0 +1,12 @@
1
+ import type { RouterDefinition } from "./types";
2
+ /**
3
+ * CarubanWire - Creates a Rakta RPC router from a map of procedure definitions.
4
+ * The return value is typed as `TRouter` so TypeScript can infer procedure types.
5
+ */
6
+ export declare function createRaktaRouter<TRouter extends RouterDefinition>(procedures: TRouter): TRouter;
7
+ /**
8
+ * Creates an HTTP request handler for the given router.
9
+ * Mount at your chosen base path, e.g. POST /rpc
10
+ */
11
+ export declare function createRpcHandler<TRouter extends RouterDefinition>(router: TRouter): (request: Request) => Promise<Response>;
12
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/rpc/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,SAAS,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,gBAAgB,EACjE,UAAU,EAAE,OAAO,GACjB,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,gBAAgB,EAChE,MAAM,EAAE,OAAO,GACb,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAsGzC"}
@@ -0,0 +1,48 @@
1
+ export type ProcedureKind = "query" | "mutation";
2
+ export interface RpcPayload {
3
+ readonly procedure: string;
4
+ readonly input: unknown;
5
+ }
6
+ export interface RpcSuccessEnvelope<TData> {
7
+ readonly ok: true;
8
+ readonly data: TData;
9
+ }
10
+ export interface RpcErrorEnvelope {
11
+ readonly ok: false;
12
+ readonly error: string;
13
+ readonly code: string;
14
+ readonly details?: ReadonlyArray<{
15
+ readonly path: ReadonlyArray<string>;
16
+ readonly message: string;
17
+ }>;
18
+ }
19
+ export type RpcEnvelope<TData> = RpcSuccessEnvelope<TData> | RpcErrorEnvelope;
20
+ /** A single defined procedure with kind, input schema, and handler. */
21
+ export interface ProcedureDefinition<TInput, TOutput> {
22
+ readonly kind: ProcedureKind;
23
+ readonly inputSchema?: {
24
+ _run(value: unknown): ReadonlyArray<{
25
+ readonly path: ReadonlyArray<string>;
26
+ readonly message: string;
27
+ readonly code: string;
28
+ }>;
29
+ parse(value: unknown): TInput;
30
+ };
31
+ readonly handler: (ctx: {
32
+ readonly input: TInput;
33
+ }) => Promise<TOutput>;
34
+ }
35
+ /** A record of named procedure definitions forming a router. */
36
+ export type RouterDefinition = Record<string, ProcedureDefinition<unknown, unknown>>;
37
+ /** Extracts the inferred input type of a procedure. */
38
+ export type InferInput<TProcedure> = TProcedure extends ProcedureDefinition<infer TInput, unknown> ? TInput : never;
39
+ /** Extracts the inferred output type of a procedure. */
40
+ export type InferOutput<TProcedure> = TProcedure extends ProcedureDefinition<unknown, infer TOutput> ? TOutput : never;
41
+ /** Produces a typed client shape from a router definition. */
42
+ export type RouterClient<TRouter extends RouterDefinition> = {
43
+ [K in keyof TRouter]: {
44
+ query: (input: InferInput<TRouter[K]>) => Promise<InferOutput<TRouter[K]>>;
45
+ mutate: (input: InferInput<TRouter[K]>) => Promise<InferOutput<TRouter[K]>>;
46
+ };
47
+ };
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rpc/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,CAAC;AAEjD,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK;IACxC,QAAQ,CAAC,EAAE,EAAE,IAA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,SAAS,mBAAmB,CAAC,MAAM,MAAM,EAAE,OAAO,CAAC,GAC1D,MAAM,GACN,KAAK,CAAC;AAEV,wDAAwD;AACxD,MAAM,MAAM,WAAW,CAAC,UAAU,IACjC,UAAU,SAAS,mBAAmB,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,GAC3D,OAAO,GACP,KAAK,CAAC;AAEV,8DAA8D;AAC9D,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,gBAAgB,IAAI;KAC3D,CAAC,IAAI,MAAM,OAAO,GAAG;QACrB,KAAK,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5E;CACD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ValidationError } from "./errors";
2
+ import { type Infer, RaktaType } from "./types";
3
+ export declare class ArrayType<TItem extends RaktaType<unknown>> extends RaktaType<Array<Infer<TItem>>> {
4
+ private readonly itemSchema;
5
+ private readonly minLength?;
6
+ private readonly maxLength?;
7
+ constructor(itemSchema: TItem, minLength?: number, maxLength?: number);
8
+ private clone;
9
+ min(length: number): ArrayType<TItem>;
10
+ max(length: number): ArrayType<TItem>;
11
+ nonempty(): ArrayType<TItem>;
12
+ _run(value: unknown): ReadonlyArray<ValidationError>;
13
+ }
14
+ export declare function array<TItem extends RaktaType<unknown>>(itemSchema: TItem): ArrayType<TItem>;
15
+ //# sourceMappingURL=array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/schema/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD,qBAAa,SAAS,CAAC,KAAK,SAAS,SAAS,CAAC,OAAO,CAAC,CAAE,SAAQ,SAAS,CACzE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CACnB;IACA,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;gBAExB,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAcrE,OAAO,CAAC,KAAK;IAIb,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;IAIrC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC;IAIrC,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC;IAI5B,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC,eAAe,CAAC;CA2CpD;AAED,wBAAgB,KAAK,CAAC,KAAK,SAAS,SAAS,CAAC,OAAO,CAAC,EACrD,UAAU,EAAE,KAAK,GACf,SAAS,CAAC,KAAK,CAAC,CAElB"}
@@ -0,0 +1,7 @@
1
+ import type { ValidationError } from "./errors";
2
+ import { RaktaType } from "./types";
3
+ export declare class BooleanType extends RaktaType<boolean> {
4
+ _run(value: unknown): ReadonlyArray<ValidationError>;
5
+ }
6
+ export declare function boolean(): BooleanType;
7
+ //# sourceMappingURL=boolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/schema/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,qBAAa,WAAY,SAAQ,SAAS,CAAC,OAAO,CAAC;IAClD,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC,eAAe,CAAC;CAapD;AAED,wBAAgB,OAAO,IAAI,WAAW,CAErC"}
@@ -0,0 +1,21 @@
1
+ export interface ValidationError {
2
+ readonly path: ReadonlyArray<string>;
3
+ readonly message: string;
4
+ readonly code: string;
5
+ }
6
+ export interface ParseSuccess<TOutput> {
7
+ readonly kind: "success";
8
+ readonly data: TOutput;
9
+ }
10
+ export interface ParseFailure {
11
+ readonly kind: "failure";
12
+ readonly errors: ReadonlyArray<ValidationError>;
13
+ }
14
+ export type ParseResult<TOutput> = ParseSuccess<TOutput> | ParseFailure;
15
+ export declare class RaktaSchemaError extends Error {
16
+ readonly errors: ReadonlyArray<ValidationError>;
17
+ constructor(errors: ReadonlyArray<ValidationError>);
18
+ }
19
+ export declare function prefixErrors(errors: ReadonlyArray<ValidationError>, key: string): ValidationError[];
20
+ export declare const preFixErrors: typeof prefixErrors;
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/schema/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY,CAAC,OAAO;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,WAAW,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC;AAExE,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;gBAEpC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC;CAgBlD;AAED,wBAAgB,YAAY,CAC3B,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,EACtC,GAAG,EAAE,MAAM,GACT,eAAe,EAAE,CAKnB;AAED,eAAO,MAAM,YAAY,qBAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { ArrayType, array, } from "./array";
2
+ export { BooleanType, boolean, } from "./boolean";
3
+ export type { ParseFailure, ParseResult, ParseSuccess, ValidationError, } from "./errors";
4
+ export { preFixErrors, RaktaSchemaError, } from "./errors";
5
+ export { NumberType, number, } from "./number";
6
+ export type { InferShape, ShapeRecord, } from "./object";
7
+ export { ObjectType, object, } from "./object";
8
+ export { StringType, string, } from "./string";
9
+ export type { Infer } from "./types";
10
+ export { OptionalType, RaktaType, } from "./types";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,KAAK,GACL,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,WAAW,EACX,OAAO,GACP,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,YAAY,EACZ,gBAAgB,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,UAAU,EACV,MAAM,GACN,MAAM,UAAU,CAAC;AAClB,YAAY,EACX,UAAU,EACV,WAAW,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,UAAU,EACV,MAAM,GACN,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,UAAU,EACV,MAAM,GACN,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACN,YAAY,EACZ,SAAS,GACT,MAAM,SAAS,CAAC"}
@@ -0,0 +1,393 @@
1
+ // @bun
2
+ // src/schema/errors.ts
3
+ class RaktaSchemaError extends Error {
4
+ errors;
5
+ constructor(errors) {
6
+ const first = errors[0];
7
+ const prefix = first ? `[${first.path.join(".") || "root"}] ${first.message}` : "Validation failed";
8
+ super(`Rakta Schema: ${prefix}${errors.length > 1 ? ` (and ${errors.length - 1} more)` : ""}`);
9
+ this.name = "RaktaSchemaError";
10
+ this.errors = errors;
11
+ }
12
+ }
13
+ function prefixErrors(errors, key) {
14
+ return errors.map((error) => ({
15
+ ...error,
16
+ path: [key, ...error.path]
17
+ }));
18
+ }
19
+ var preFixErrors = prefixErrors;
20
+
21
+ // src/schema/types.ts
22
+ class RaktaType {
23
+ parse(value) {
24
+ const result = this.safeParse(value);
25
+ if (result.kind === "failure") {
26
+ throw new RaktaSchemaError(result.errors);
27
+ }
28
+ return result.data;
29
+ }
30
+ safeParse(value) {
31
+ const errors = this._run(value);
32
+ if (errors.length > 0) {
33
+ return {
34
+ kind: "failure",
35
+ errors
36
+ };
37
+ }
38
+ return {
39
+ kind: "success",
40
+ data: value
41
+ };
42
+ }
43
+ optional() {
44
+ return new OptionalType(this);
45
+ }
46
+ }
47
+
48
+ class OptionalType extends RaktaType {
49
+ inner;
50
+ constructor(inner) {
51
+ super();
52
+ this.inner = inner;
53
+ }
54
+ _run(value) {
55
+ if (typeof value === "undefined") {
56
+ return [];
57
+ }
58
+ return this.inner._run(value);
59
+ }
60
+ }
61
+
62
+ // src/schema/array.ts
63
+ class ArrayType extends RaktaType {
64
+ itemSchema;
65
+ minLength;
66
+ maxLength;
67
+ constructor(itemSchema, minLength, maxLength) {
68
+ super();
69
+ this.itemSchema = itemSchema;
70
+ if (typeof minLength === "number") {
71
+ this.minLength = minLength;
72
+ }
73
+ if (typeof maxLength === "number") {
74
+ this.maxLength = maxLength;
75
+ }
76
+ }
77
+ clone(minLength, maxLength) {
78
+ return new ArrayType(this.itemSchema, minLength, maxLength);
79
+ }
80
+ min(length) {
81
+ return this.clone(length, this.maxLength);
82
+ }
83
+ max(length) {
84
+ return this.clone(this.minLength, length);
85
+ }
86
+ nonempty() {
87
+ return this.min(1);
88
+ }
89
+ _run(value) {
90
+ if (!Array.isArray(value)) {
91
+ return [
92
+ {
93
+ path: [],
94
+ message: "Expected an array",
95
+ code: "invalid_type"
96
+ }
97
+ ];
98
+ }
99
+ const errors = [];
100
+ if (typeof this.minLength === "number" && value.length < this.minLength) {
101
+ errors.push({
102
+ path: [],
103
+ message: `Array must contain at least ${this.minLength} item(s)`,
104
+ code: "too_small"
105
+ });
106
+ }
107
+ if (typeof this.maxLength === "number" && value.length > this.maxLength) {
108
+ errors.push({
109
+ path: [],
110
+ message: `Array must contain at most ${this.maxLength} item(s)`,
111
+ code: "too_big"
112
+ });
113
+ }
114
+ for (let index = 0;index < value.length; index += 1) {
115
+ const itemValue = value[index];
116
+ const itemErrors = this.itemSchema._run(itemValue);
117
+ errors.push(...itemErrors.map((error) => ({
118
+ ...error,
119
+ path: [String(index), ...error.path]
120
+ })));
121
+ }
122
+ return errors;
123
+ }
124
+ }
125
+ function array(itemSchema) {
126
+ return new ArrayType(itemSchema);
127
+ }
128
+ // src/schema/boolean.ts
129
+ class BooleanType extends RaktaType {
130
+ _run(value) {
131
+ if (typeof value !== "boolean") {
132
+ return [
133
+ {
134
+ path: [],
135
+ message: "Expected a boolean",
136
+ code: "invalid_type"
137
+ }
138
+ ];
139
+ }
140
+ return [];
141
+ }
142
+ }
143
+ function boolean() {
144
+ return new BooleanType;
145
+ }
146
+ // src/schema/number.ts
147
+ class NumberType extends RaktaType {
148
+ rules;
149
+ constructor(rules = []) {
150
+ super();
151
+ this.rules = rules;
152
+ }
153
+ addRule(rule) {
154
+ return new NumberType([...this.rules, rule]);
155
+ }
156
+ _run(value) {
157
+ if (typeof value !== "number" || Number.isNaN(value)) {
158
+ return [
159
+ {
160
+ path: [],
161
+ message: "Expected a number",
162
+ code: "invalid_type"
163
+ }
164
+ ];
165
+ }
166
+ const errors = [];
167
+ for (const rule of this.rules) {
168
+ const result = rule(value);
169
+ if (result) {
170
+ errors.push(result);
171
+ }
172
+ }
173
+ return errors;
174
+ }
175
+ min(threshold) {
176
+ return this.addRule((value) => value < threshold ? {
177
+ path: [],
178
+ message: `Must be at least ${threshold}`,
179
+ code: "too_small"
180
+ } : undefined);
181
+ }
182
+ max(threshold) {
183
+ return this.addRule((value) => value > threshold ? {
184
+ path: [],
185
+ message: `Must be at most ${threshold}`,
186
+ code: "too_big"
187
+ } : undefined);
188
+ }
189
+ int() {
190
+ return this.addRule((value) => !Number.isInteger(value) ? {
191
+ path: [],
192
+ message: "Expected an integer",
193
+ code: "not_integer"
194
+ } : undefined);
195
+ }
196
+ positive() {
197
+ return this.addRule((value) => value <= 0 ? {
198
+ path: [],
199
+ message: "Must be a positive number",
200
+ code: "not_positive"
201
+ } : undefined);
202
+ }
203
+ nonnegative() {
204
+ return this.addRule((value) => value < 0 ? {
205
+ path: [],
206
+ message: "Must be zero or positive",
207
+ code: "not_nonnegative"
208
+ } : undefined);
209
+ }
210
+ }
211
+ function number() {
212
+ return new NumberType;
213
+ }
214
+ // src/schema/object.ts
215
+ class ObjectType extends RaktaType {
216
+ shape;
217
+ constructor(shape) {
218
+ super();
219
+ this.shape = shape;
220
+ }
221
+ _run(value) {
222
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
223
+ return [
224
+ {
225
+ path: [],
226
+ message: "Expected an object",
227
+ code: "invalid_type"
228
+ }
229
+ ];
230
+ }
231
+ const errors = [];
232
+ const record = value;
233
+ for (const key of Object.keys(this.shape)) {
234
+ const fieldSchema = this.shape[key];
235
+ if (typeof fieldSchema === "undefined") {
236
+ continue;
237
+ }
238
+ const fieldValue = record[key];
239
+ const fieldErrors = fieldSchema._run(fieldValue);
240
+ errors.push(...prefixErrors(fieldErrors, key));
241
+ }
242
+ return errors;
243
+ }
244
+ extend(extension) {
245
+ return new ObjectType({
246
+ ...this.shape,
247
+ ...extension
248
+ });
249
+ }
250
+ pick(keys) {
251
+ const picked = {};
252
+ for (const key of keys) {
253
+ if (key in this.shape) {
254
+ picked[key] = this.shape[key];
255
+ }
256
+ }
257
+ return new ObjectType(picked);
258
+ }
259
+ omit(keys) {
260
+ const result = { ...this.shape };
261
+ for (const key of keys) {
262
+ delete result[key];
263
+ }
264
+ return new ObjectType(result);
265
+ }
266
+ }
267
+ function object(shape) {
268
+ return new ObjectType(shape);
269
+ }
270
+ // src/schema/string.ts
271
+ var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
272
+ var URL_PATTERN = /^https?:\/\/[^\s$.?#].[^\s]*$/i;
273
+
274
+ class StringType extends RaktaType {
275
+ rules;
276
+ constructor(rules = []) {
277
+ super();
278
+ this.rules = rules;
279
+ }
280
+ addRule(rule) {
281
+ return new StringType([...this.rules, rule]);
282
+ }
283
+ _run(value) {
284
+ if (typeof value !== "string") {
285
+ return [
286
+ {
287
+ path: [],
288
+ message: "Expected a string",
289
+ code: "invalid_type"
290
+ }
291
+ ];
292
+ }
293
+ const errors = [];
294
+ for (const rule of this.rules) {
295
+ errors.push(...rule(value));
296
+ }
297
+ return errors;
298
+ }
299
+ min(length) {
300
+ return this.addRule((value) => {
301
+ if (value.length >= length) {
302
+ return [];
303
+ }
304
+ return [
305
+ {
306
+ path: [],
307
+ message: `Must be at least ${length} character(s)`,
308
+ code: "too_small"
309
+ }
310
+ ];
311
+ });
312
+ }
313
+ max(length) {
314
+ return this.addRule((value) => {
315
+ if (value.length <= length) {
316
+ return [];
317
+ }
318
+ return [
319
+ {
320
+ path: [],
321
+ message: `Must be at most ${length} character(s)`,
322
+ code: "too_big"
323
+ }
324
+ ];
325
+ });
326
+ }
327
+ email() {
328
+ return this.addRule((value) => {
329
+ if (EMAIL_PATTERN.test(value)) {
330
+ return [];
331
+ }
332
+ return [
333
+ {
334
+ path: [],
335
+ message: "Invalid email address",
336
+ code: "invalid_email"
337
+ }
338
+ ];
339
+ });
340
+ }
341
+ url() {
342
+ return this.addRule((value) => {
343
+ if (URL_PATTERN.test(value)) {
344
+ return [];
345
+ }
346
+ return [
347
+ {
348
+ path: [],
349
+ message: "Invalid URL",
350
+ code: "invalid_url"
351
+ }
352
+ ];
353
+ });
354
+ }
355
+ regex(pattern, customMessage) {
356
+ return this.addRule((value) => {
357
+ if (pattern.test(value)) {
358
+ return [];
359
+ }
360
+ return [
361
+ {
362
+ path: [],
363
+ message: customMessage ?? `Did not match pattern ${pattern.toString()}`,
364
+ code: "invalid_pattern"
365
+ }
366
+ ];
367
+ });
368
+ }
369
+ nonempty() {
370
+ return this.min(1);
371
+ }
372
+ }
373
+ function string() {
374
+ return new StringType;
375
+ }
376
+ export {
377
+ string,
378
+ preFixErrors,
379
+ object,
380
+ number,
381
+ boolean,
382
+ array,
383
+ StringType,
384
+ RaktaType,
385
+ RaktaSchemaError,
386
+ OptionalType,
387
+ ObjectType,
388
+ NumberType,
389
+ BooleanType,
390
+ ArrayType
391
+ };
392
+
393
+ //# debugId=95925175164ED77F64756E2164756E21
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["..\\..\\src\\schema\\errors.ts", "..\\..\\src\\schema\\types.ts", "..\\..\\src\\schema\\array.ts", "..\\..\\src\\schema\\boolean.ts", "..\\..\\src\\schema\\number.ts", "..\\..\\src\\schema\\object.ts", "..\\..\\src\\schema\\string.ts"],
4
+ "sourcesContent": [
5
+ "export interface ValidationError {\n\treadonly path: ReadonlyArray<string>;\n\treadonly message: string;\n\treadonly code: string;\n}\n\nexport interface ParseSuccess<TOutput> {\n\treadonly kind: \"success\";\n\treadonly data: TOutput;\n}\n\nexport interface ParseFailure {\n\treadonly kind: \"failure\";\n\treadonly errors: ReadonlyArray<ValidationError>;\n}\n\nexport type ParseResult<TOutput> = ParseSuccess<TOutput> | ParseFailure;\n\nexport class RaktaSchemaError extends Error {\n\treadonly errors: ReadonlyArray<ValidationError>;\n\n\tconstructor(errors: ReadonlyArray<ValidationError>) {\n\t\tconst first = errors[0];\n\n\t\tconst prefix = first\n\t\t\t? `[${first.path.join(\".\") || \"root\"}] ${first.message}`\n\t\t\t: \"Validation failed\";\n\n\t\tsuper(\n\t\t\t`Rakta Schema: ${prefix}${\n\t\t\t\terrors.length > 1 ? ` (and ${errors.length - 1} more)` : \"\"\n\t\t\t}`,\n\t\t);\n\n\t\tthis.name = \"RaktaSchemaError\";\n\t\tthis.errors = errors;\n\t}\n}\n\nexport function prefixErrors(\n\terrors: ReadonlyArray<ValidationError>,\n\tkey: string,\n): ValidationError[] {\n\treturn errors.map((error) => ({\n\t\t...error,\n\t\tpath: [key, ...error.path],\n\t}));\n}\n\nexport const preFixErrors = prefixErrors;\n",
6
+ "import type { ParseResult, ValidationError } from \"./errors\";\nimport { RaktaSchemaError } from \"./errors\";\n\n/** Extracts the output type from any RaktaType. */\nexport type Infer<TSchema> =\n\tTSchema extends RaktaType<infer TOutput> ? TOutput : never;\n\n/** Base class for all Rakta Schema validators. */\nexport abstract class RaktaType<TOutput> {\n\t/** Internal validation — returns errors array (empty = valid). */\n\tabstract _run(value: unknown): ReadonlyArray<ValidationError>;\n\n\t/**\n\t * Validates `value` and returns `TOutput`.\n\t * Throws `RaktaSchemaError` if validation fails.\n\t */\n\tparse(value: unknown): TOutput {\n\t\tconst result = this.safeParse(value);\n\n\t\tif (result.kind === \"failure\") {\n\t\t\tthrow new RaktaSchemaError(result.errors);\n\t\t}\n\n\t\treturn result.data;\n\t}\n\n\t/**\n\t * Validates `value` and returns a discriminated union result.\n\t * Never throws.\n\t */\n\tsafeParse(value: unknown): ParseResult<TOutput> {\n\t\tconst errors = this._run(value);\n\n\t\tif (errors.length > 0) {\n\t\t\treturn {\n\t\t\t\tkind: \"failure\",\n\t\t\t\terrors,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tkind: \"success\",\n\t\t\tdata: value as TOutput,\n\t\t};\n\t}\n\n\t/** Wraps this schema in an optional wrapper. */\n\toptional(): OptionalType<TOutput> {\n\t\treturn new OptionalType(this);\n\t}\n}\n\n/** Wraps any RaktaType to make it accept missing values. */\nexport class OptionalType<TOutput> extends RaktaType<TOutput | undefined> {\n\tprivate readonly inner: RaktaType<TOutput>;\n\n\tconstructor(inner: RaktaType<TOutput>) {\n\t\tsuper();\n\t\tthis.inner = inner;\n\t}\n\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (typeof value === \"undefined\") {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn this.inner._run(value);\n\t}\n}\n",
7
+ "import type { ValidationError } from \"./errors\";\nimport { type Infer, RaktaType } from \"./types\";\n\nexport class ArrayType<TItem extends RaktaType<unknown>> extends RaktaType<\n\tArray<Infer<TItem>>\n> {\n\tprivate readonly itemSchema: TItem;\n\tprivate readonly minLength?: number;\n\tprivate readonly maxLength?: number;\n\n\tconstructor(itemSchema: TItem, minLength?: number, maxLength?: number) {\n\t\tsuper();\n\n\t\tthis.itemSchema = itemSchema;\n\n\t\tif (typeof minLength === \"number\") {\n\t\t\tthis.minLength = minLength;\n\t\t}\n\n\t\tif (typeof maxLength === \"number\") {\n\t\t\tthis.maxLength = maxLength;\n\t\t}\n\t}\n\n\tprivate clone(minLength?: number, maxLength?: number): ArrayType<TItem> {\n\t\treturn new ArrayType(this.itemSchema, minLength, maxLength);\n\t}\n\n\tmin(length: number): ArrayType<TItem> {\n\t\treturn this.clone(length, this.maxLength);\n\t}\n\n\tmax(length: number): ArrayType<TItem> {\n\t\treturn this.clone(this.minLength, length);\n\t}\n\n\tnonempty(): ArrayType<TItem> {\n\t\treturn this.min(1);\n\t}\n\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (!Array.isArray(value)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Expected an array\",\n\t\t\t\t\tcode: \"invalid_type\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst errors: ValidationError[] = [];\n\n\t\tif (typeof this.minLength === \"number\" && value.length < this.minLength) {\n\t\t\terrors.push({\n\t\t\t\tpath: [],\n\t\t\t\tmessage: `Array must contain at least ${this.minLength} item(s)`,\n\t\t\t\tcode: \"too_small\",\n\t\t\t});\n\t\t}\n\n\t\tif (typeof this.maxLength === \"number\" && value.length > this.maxLength) {\n\t\t\terrors.push({\n\t\t\t\tpath: [],\n\t\t\t\tmessage: `Array must contain at most ${this.maxLength} item(s)`,\n\t\t\t\tcode: \"too_big\",\n\t\t\t});\n\t\t}\n\n\t\tfor (let index = 0; index < value.length; index += 1) {\n\t\t\tconst itemValue = value[index];\n\t\t\tconst itemErrors = this.itemSchema._run(itemValue);\n\n\t\t\terrors.push(\n\t\t\t\t...itemErrors.map((error: ValidationError) => ({\n\t\t\t\t\t...error,\n\t\t\t\t\tpath: [String(index), ...error.path],\n\t\t\t\t})),\n\t\t\t);\n\t\t}\n\n\t\treturn errors;\n\t}\n}\n\nexport function array<TItem extends RaktaType<unknown>>(\n\titemSchema: TItem,\n): ArrayType<TItem> {\n\treturn new ArrayType(itemSchema);\n}\n",
8
+ "import type { ValidationError } from \"./errors\";\nimport { RaktaType } from \"./types\";\n\nexport class BooleanType extends RaktaType<boolean> {\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (typeof value !== \"boolean\") {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Expected a boolean\",\n\t\t\t\t\tcode: \"invalid_type\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [];\n\t}\n}\n\nexport function boolean(): BooleanType {\n\treturn new BooleanType();\n}\n",
9
+ "import type { ValidationError } from \"./errors\";\nimport { RaktaType } from \"./types\";\n\ntype NumberRule = (value: number) => ValidationError | undefined;\n\nexport class NumberType extends RaktaType<number> {\n\tprivate readonly rules: ReadonlyArray<NumberRule>;\n\n\tconstructor(rules: ReadonlyArray<NumberRule> = []) {\n\t\tsuper();\n\t\tthis.rules = rules;\n\t}\n\n\tprivate addRule(rule: NumberRule): NumberType {\n\t\treturn new NumberType([...this.rules, rule]);\n\t}\n\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (typeof value !== \"number\" || Number.isNaN(value)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Expected a number\",\n\t\t\t\t\tcode: \"invalid_type\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst errors: ValidationError[] = [];\n\n\t\tfor (const rule of this.rules) {\n\t\t\tconst result = rule(value);\n\n\t\t\tif (result) {\n\t\t\t\terrors.push(result);\n\t\t\t}\n\t\t}\n\n\t\treturn errors;\n\t}\n\n\tmin(threshold: number): NumberType {\n\t\treturn this.addRule((value: number): ValidationError | undefined =>\n\t\t\tvalue < threshold\n\t\t\t\t? {\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tmessage: `Must be at least ${threshold}`,\n\t\t\t\t\t\tcode: \"too_small\",\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tmax(threshold: number): NumberType {\n\t\treturn this.addRule((value: number): ValidationError | undefined =>\n\t\t\tvalue > threshold\n\t\t\t\t? {\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tmessage: `Must be at most ${threshold}`,\n\t\t\t\t\t\tcode: \"too_big\",\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tint(): NumberType {\n\t\treturn this.addRule((value: number): ValidationError | undefined =>\n\t\t\t!Number.isInteger(value)\n\t\t\t\t? {\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tmessage: \"Expected an integer\",\n\t\t\t\t\t\tcode: \"not_integer\",\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tpositive(): NumberType {\n\t\treturn this.addRule((value: number): ValidationError | undefined =>\n\t\t\tvalue <= 0\n\t\t\t\t? {\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tmessage: \"Must be a positive number\",\n\t\t\t\t\t\tcode: \"not_positive\",\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tnonnegative(): NumberType {\n\t\treturn this.addRule((value: number): ValidationError | undefined =>\n\t\t\tvalue < 0\n\t\t\t\t? {\n\t\t\t\t\t\tpath: [],\n\t\t\t\t\t\tmessage: \"Must be zero or positive\",\n\t\t\t\t\t\tcode: \"not_nonnegative\",\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t}\n}\n\nexport function number(): NumberType {\n\treturn new NumberType();\n}\n",
10
+ "import type { ValidationError } from \"./errors\";\nimport { prefixErrors } from \"./errors\";\nimport { type Infer, RaktaType } from \"./types\";\n\nexport type ShapeRecord = Record<string, RaktaType<unknown>>;\n\nexport type InferShape<TShape extends ShapeRecord> = {\n\t[K in keyof TShape]: Infer<TShape[K]>;\n};\n\nexport class ObjectType<TShape extends ShapeRecord> extends RaktaType<\n\tInferShape<TShape>\n> {\n\tprivate readonly shape: TShape;\n\n\tconstructor(shape: TShape) {\n\t\tsuper();\n\t\tthis.shape = shape;\n\t}\n\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Expected an object\",\n\t\t\t\t\tcode: \"invalid_type\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst errors: ValidationError[] = [];\n\t\tconst record = value as Record<string, unknown>;\n\n\t\tfor (const key of Object.keys(this.shape)) {\n\t\t\tconst fieldSchema = this.shape[key];\n\n\t\t\tif (typeof fieldSchema === \"undefined\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fieldValue = record[key];\n\t\t\tconst fieldErrors = fieldSchema._run(fieldValue);\n\n\t\t\terrors.push(...prefixErrors(fieldErrors, key));\n\t\t}\n\n\t\treturn errors;\n\t}\n\n\t/** Merge additional fields into this schema. */\n\textend<TExtension extends ShapeRecord>(\n\t\textension: TExtension,\n\t): ObjectType<TShape & TExtension> {\n\t\treturn new ObjectType({\n\t\t\t...this.shape,\n\t\t\t...extension,\n\t\t});\n\t}\n\n\t/** Create a new schema with only the specified keys. */\n\tpick<TKey extends keyof TShape>(\n\t\tkeys: ReadonlyArray<TKey>,\n\t): ObjectType<Pick<TShape, TKey>> {\n\t\tconst picked = {} as Pick<TShape, TKey>;\n\n\t\tfor (const key of keys) {\n\t\t\tif (key in this.shape) {\n\t\t\t\tpicked[key] = this.shape[key];\n\t\t\t}\n\t\t}\n\n\t\treturn new ObjectType(picked);\n\t}\n\n\t/** Create a new schema omitting the specified keys. */\n\tomit<TKey extends keyof TShape>(\n\t\tkeys: ReadonlyArray<TKey>,\n\t): ObjectType<Omit<TShape, TKey>> {\n\t\tconst result = { ...this.shape };\n\n\t\tfor (const key of keys) {\n\t\t\tdelete result[key];\n\t\t}\n\n\t\treturn new ObjectType(result);\n\t}\n}\n\nexport function object<TShape extends ShapeRecord>(\n\tshape: TShape,\n): ObjectType<TShape> {\n\treturn new ObjectType(shape);\n}\n",
11
+ "import type { ValidationError } from \"./errors\";\nimport { RaktaType } from \"./types\";\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\n\nconst URL_PATTERN = /^https?:\\/\\/[^\\s$.?#].[^\\s]*$/i;\n\ntype StringRule = (value: string) => ReadonlyArray<ValidationError>;\n\nexport class StringType extends RaktaType<string> {\n\tprivate readonly rules: ReadonlyArray<StringRule>;\n\n\tconstructor(rules: ReadonlyArray<StringRule> = []) {\n\t\tsuper();\n\t\tthis.rules = rules;\n\t}\n\n\tprivate addRule(rule: StringRule): StringType {\n\t\treturn new StringType([...this.rules, rule]);\n\t}\n\n\t_run(value: unknown): ReadonlyArray<ValidationError> {\n\t\tif (typeof value !== \"string\") {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Expected a string\",\n\t\t\t\t\tcode: \"invalid_type\",\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\tconst errors: ValidationError[] = [];\n\n\t\tfor (const rule of this.rules) {\n\t\t\terrors.push(...rule(value));\n\t\t}\n\n\t\treturn errors;\n\t}\n\n\tmin(length: number): StringType {\n\t\treturn this.addRule((value: string): ReadonlyArray<ValidationError> => {\n\t\t\tif (value.length >= length) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: `Must be at least ${length} character(s)`,\n\t\t\t\t\tcode: \"too_small\",\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\tmax(length: number): StringType {\n\t\treturn this.addRule((value: string): ReadonlyArray<ValidationError> => {\n\t\t\tif (value.length <= length) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: `Must be at most ${length} character(s)`,\n\t\t\t\t\tcode: \"too_big\",\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\temail(): StringType {\n\t\treturn this.addRule((value: string): ReadonlyArray<ValidationError> => {\n\t\t\tif (EMAIL_PATTERN.test(value)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Invalid email address\",\n\t\t\t\t\tcode: \"invalid_email\",\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\turl(): StringType {\n\t\treturn this.addRule((value: string): ReadonlyArray<ValidationError> => {\n\t\t\tif (URL_PATTERN.test(value)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage: \"Invalid URL\",\n\t\t\t\t\tcode: \"invalid_url\",\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\tregex(pattern: RegExp, customMessage?: string): StringType {\n\t\treturn this.addRule((value: string): ReadonlyArray<ValidationError> => {\n\t\t\tif (pattern.test(value)) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath: [],\n\t\t\t\t\tmessage:\n\t\t\t\t\t\tcustomMessage ?? `Did not match pattern ${pattern.toString()}`,\n\t\t\t\t\tcode: \"invalid_pattern\",\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\t}\n\n\tnonempty(): StringType {\n\t\treturn this.min(1);\n\t}\n}\n\nexport function string(): StringType {\n\treturn new StringType();\n}\n"
12
+ ],
13
+ "mappings": ";;AAkBO,MAAM,yBAAyB,MAAM;AAAA,EAClC;AAAA,EAET,WAAW,CAAC,QAAwC;AAAA,IACnD,MAAM,QAAQ,OAAO;AAAA,IAErB,MAAM,SAAS,QACZ,IAAI,MAAM,KAAK,KAAK,GAAG,KAAK,WAAW,MAAM,YAC7C;AAAA,IAEH,MACC,iBAAiB,SAChB,OAAO,SAAS,IAAI,SAAS,OAAO,SAAS,YAAY,IAE3D;AAAA,IAEA,KAAK,OAAO;AAAA,IACZ,KAAK,SAAS;AAAA;AAEhB;AAEO,SAAS,YAAY,CAC3B,QACA,KACoB;AAAA,EACpB,OAAO,OAAO,IAAI,CAAC,WAAW;AAAA,OAC1B;AAAA,IACH,MAAM,CAAC,KAAK,GAAG,MAAM,IAAI;AAAA,EAC1B,EAAE;AAAA;AAGI,IAAM,eAAe;;;ACzCrB,MAAe,UAAmB;AAAA,EAQxC,KAAK,CAAC,OAAyB;AAAA,IAC9B,MAAM,SAAS,KAAK,UAAU,KAAK;AAAA,IAEnC,IAAI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AoC;AAAA,IAC1D,OAAO,KAAK,QAAQ,CAAC,UAAkD;AAAA,MACtE,IAAI,QAAQ,KAAK,KAAK,GAAG;AAAA,QACxB,OAAO,CAAC;AAAA,MACT;AAAA,MAEA,OAAO;AAAA,QACN;AAAA,UACC,MAAM,CAAC;AAAA,UACP,SACC,iBAAiB,yBAAyB,QAAQ,SAAS;AAAA,UAC5D,MAAM;AAAA,QACP;AAAA,MACD;AAAA,KACA;AAAA;AAAA,EAGF,QAAQ,GAAe;AAAA,IACtB,OAAO,KAAK,IAAI,CAAC;AAAA;AAEnB;AAEO,SAAS,MAAM,GAAe;AAAA,EACpC,OAAO,IAAI;AAAA;",
14
+ "debugId": "95925175164ED77F64756E2164756E21",
15
+ "names": []
16
+ }
@@ -0,0 +1,17 @@
1
+ import type { ValidationError } from "./errors";
2
+ import { RaktaType } from "./types";
3
+ type NumberRule = (value: number) => ValidationError | undefined;
4
+ export declare class NumberType extends RaktaType<number> {
5
+ private readonly rules;
6
+ constructor(rules?: ReadonlyArray<NumberRule>);
7
+ private addRule;
8
+ _run(value: unknown): ReadonlyArray<ValidationError>;
9
+ min(threshold: number): NumberType;
10
+ max(threshold: number): NumberType;
11
+ int(): NumberType;
12
+ positive(): NumberType;
13
+ nonnegative(): NumberType;
14
+ }
15
+ export declare function number(): NumberType;
16
+ export {};
17
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/schema/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;AAEjE,qBAAa,UAAW,SAAQ,SAAS,CAAC,MAAM,CAAC;IAChD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;gBAEtC,KAAK,GAAE,aAAa,CAAC,UAAU,CAAM;IAKjD,OAAO,CAAC,OAAO;IAIf,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC,eAAe,CAAC;IAwBpD,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAYlC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAYlC,GAAG,IAAI,UAAU;IAYjB,QAAQ,IAAI,UAAU;IAYtB,WAAW,IAAI,UAAU;CAWzB;AAED,wBAAgB,MAAM,IAAI,UAAU,CAEnC"}
@@ -0,0 +1,19 @@
1
+ import type { ValidationError } from "./errors";
2
+ import { type Infer, RaktaType } from "./types";
3
+ export type ShapeRecord = Record<string, RaktaType<unknown>>;
4
+ export type InferShape<TShape extends ShapeRecord> = {
5
+ [K in keyof TShape]: Infer<TShape[K]>;
6
+ };
7
+ export declare class ObjectType<TShape extends ShapeRecord> extends RaktaType<InferShape<TShape>> {
8
+ private readonly shape;
9
+ constructor(shape: TShape);
10
+ _run(value: unknown): ReadonlyArray<ValidationError>;
11
+ /** Merge additional fields into this schema. */
12
+ extend<TExtension extends ShapeRecord>(extension: TExtension): ObjectType<TShape & TExtension>;
13
+ /** Create a new schema with only the specified keys. */
14
+ pick<TKey extends keyof TShape>(keys: ReadonlyArray<TKey>): ObjectType<Pick<TShape, TKey>>;
15
+ /** Create a new schema omitting the specified keys. */
16
+ omit<TKey extends keyof TShape>(keys: ReadonlyArray<TKey>): ObjectType<Omit<TShape, TKey>>;
17
+ }
18
+ export declare function object<TShape extends ShapeRecord>(shape: TShape): ObjectType<TShape>;
19
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/schema/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,KAAK,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AAE7D,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,WAAW,IAAI;KACnD,CAAC,IAAI,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC;AAEF,qBAAa,UAAU,CAAC,MAAM,SAAS,WAAW,CAAE,SAAQ,SAAS,CACpE,UAAU,CAAC,MAAM,CAAC,CAClB;IACA,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,KAAK,EAAE,MAAM;IAKzB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC,eAAe,CAAC;IA8BpD,gDAAgD;IAChD,MAAM,CAAC,UAAU,SAAS,WAAW,EACpC,SAAS,EAAE,UAAU,GACnB,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC;IAOlC,wDAAwD;IACxD,IAAI,CAAC,IAAI,SAAS,MAAM,MAAM,EAC7B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,GACvB,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAYjC,uDAAuD;IACvD,IAAI,CAAC,IAAI,SAAS,MAAM,MAAM,EAC7B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,GACvB,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CASjC;AAED,wBAAgB,MAAM,CAAC,MAAM,SAAS,WAAW,EAChD,KAAK,EAAE,MAAM,GACX,UAAU,CAAC,MAAM,CAAC,CAEpB"}
@@ -0,0 +1,18 @@
1
+ import type { ValidationError } from "./errors";
2
+ import { RaktaType } from "./types";
3
+ type StringRule = (value: string) => ReadonlyArray<ValidationError>;
4
+ export declare class StringType extends RaktaType<string> {
5
+ private readonly rules;
6
+ constructor(rules?: ReadonlyArray<StringRule>);
7
+ private addRule;
8
+ _run(value: unknown): ReadonlyArray<ValidationError>;
9
+ min(length: number): StringType;
10
+ max(length: number): StringType;
11
+ email(): StringType;
12
+ url(): StringType;
13
+ regex(pattern: RegExp, customMessage?: string): StringType;
14
+ nonempty(): StringType;
15
+ }
16
+ export declare function string(): StringType;
17
+ export {};
18
+ //# sourceMappingURL=string.d.ts.map