@cosmneo/onion-lasagna-arktype 0.2.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.cjs ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ arktypeSchema: () => arktypeSchema,
24
+ pagination: () => pagination
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/arktype.adapter.ts
29
+ var import_arktype = require("arktype");
30
+ function arktypeSchema(schema) {
31
+ return {
32
+ validate(data) {
33
+ const out = schema(data);
34
+ if (out instanceof import_arktype.type.errors) {
35
+ return {
36
+ success: false,
37
+ issues: out.map((error) => ({
38
+ path: [...error.path].map(String),
39
+ message: error.message,
40
+ code: error.code,
41
+ expected: error.expected,
42
+ received: error.actual
43
+ }))
44
+ };
45
+ }
46
+ return { success: true, data: out };
47
+ },
48
+ toJsonSchema(_options) {
49
+ const result = schema.toJsonSchema({
50
+ // Morphs (e.g. string→number coercion via .pipe().to()) have no JSON Schema
51
+ // equivalent. Use the output schema so OpenAPI documents the validated shape.
52
+ // Falls back to the input schema if no typed output is available.
53
+ fallback: { morph: (ctx) => ctx.out ?? ctx.base }
54
+ });
55
+ const { $schema, ...schemaWithoutMeta } = result;
56
+ return schemaWithoutMeta;
57
+ },
58
+ _output: void 0,
59
+ _input: void 0,
60
+ _schema: schema
61
+ };
62
+ }
63
+
64
+ // src/schemas/pagination.ts
65
+ var import_arktype2 = require("arktype");
66
+ var coercedPage = (0, import_arktype2.type)("string | number").pipe((v) => Number(v)).to("number%1 >= 1").default(1);
67
+ var coercedPageSize = (0, import_arktype2.type)("string | number").pipe((v) => Number(v)).to("1 <= number%1 <= 100").default(10);
68
+ var pagination = {
69
+ /**
70
+ * Query params schema for paginated list requests.
71
+ *
72
+ * Coerces string query params to numbers via morphs,
73
+ * validates constraints, and applies defaults.
74
+ */
75
+ input: (0, import_arktype2.type)({ page: coercedPage, pageSize: coercedPageSize }),
76
+ /**
77
+ * Factory for paginated response schemas.
78
+ *
79
+ * @param itemSchema - ArkType schema for individual items in the list
80
+ * @returns ArkType schema for `{ items: T[], total: number }`
81
+ */
82
+ response: (itemSchema) => (0, import_arktype2.type)({ items: itemSchema.array(), total: "number%1 >= 0" })
83
+ };
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ arktypeSchema,
87
+ pagination
88
+ });
89
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/arktype.adapter.ts","../src/schemas/pagination.ts"],"sourcesContent":["export { arktypeSchema } from './arktype.adapter';\nexport { pagination } from './schemas/pagination';\n","/**\n * @fileoverview ArkType schema adapter for the unified route system.\n *\n * This adapter wraps ArkType schemas to provide a consistent interface\n * for validation and JSON Schema generation. Uses ArkType's built-in\n * `.toJsonSchema()` for JSON Schema conversion.\n *\n * ArkType offers the fastest runtime validation among TypeScript schema\n * libraries (~20x faster than Zod) with a concise string-based DSL\n * and built-in type inference.\n *\n * @module unified/schema/adapters/arktype\n */\n\nimport { type, Type } from 'arktype';\nimport type {\n JsonSchema,\n JsonSchemaOptions,\n SchemaAdapter,\n ValidationResult,\n} from '@cosmneo/onion-lasagna/http/schema/types';\n\n/**\n * Creates a SchemaAdapter from an ArkType schema.\n *\n * Wraps an ArkType `Type` to provide validation via direct invocation\n * and JSON Schema generation via the built-in `.toJsonSchema()` method.\n * ArkType's string-based DSL enables concise schema definitions with\n * best-in-class runtime performance.\n *\n * @param schema - An ArkType schema to wrap\n * @returns A SchemaAdapter that validates using ArkType and generates JSON Schema\n *\n * @example Basic usage\n * ```typescript\n * import { type } from 'arktype';\n * import { arktypeSchema } from '@cosmneo/onion-lasagna-arktype';\n *\n * const userSchema = arktypeSchema(type({\n * name: '1 <= string <= 100',\n * email: 'string.email',\n * 'age?': '0 <= integer <= 150',\n * }));\n *\n * // Validate data\n * const result = userSchema.validate({\n * name: 'John Doe',\n * email: 'john@example.com',\n * });\n *\n * // Generate JSON Schema\n * const jsonSchema = userSchema.toJsonSchema();\n * ```\n */\nexport function arktypeSchema<T extends Type>(schema: T): SchemaAdapter<T['infer'], T['inferIn']> {\n type TOutput = T['infer'];\n type TInput = T['inferIn'];\n\n return {\n validate(data: unknown): ValidationResult<TOutput> {\n const out = schema(data);\n\n if (out instanceof type.errors) {\n return {\n success: false,\n issues: out.map((error) => ({\n path: [...error.path].map(String),\n message: error.message,\n code: error.code,\n expected: error.expected,\n received: error.actual,\n })),\n };\n }\n\n return { success: true, data: out as TOutput };\n },\n\n toJsonSchema(_options?: JsonSchemaOptions): JsonSchema {\n const result = schema.toJsonSchema({\n // Morphs (e.g. string→number coercion via .pipe().to()) have no JSON Schema\n // equivalent. Use the output schema so OpenAPI documents the validated shape.\n // Falls back to the input schema if no typed output is available.\n fallback: { morph: (ctx) => ctx.out ?? ctx.base },\n });\n\n // Remove $schema to avoid conflicts with OpenAPI\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars\n const { $schema, ...schemaWithoutMeta } = result as Record<string, unknown>;\n\n return schemaWithoutMeta as JsonSchema;\n },\n\n _output: undefined as TOutput,\n _input: undefined as TInput,\n _schema: schema,\n };\n}\n","/**\n * @fileoverview Pre-built ArkType pagination schemas.\n *\n * Provides reusable schemas for paginated list endpoints,\n * matching the core `PaginationInput` and `PaginatedData<T>` types.\n *\n * ArkType uses `.pipe().to()` morphs for string→number coercion\n * and `.default()` for default values.\n *\n * @module schemas/pagination\n */\n\nimport { type, Type } from 'arktype';\n\nconst coercedPage = type('string | number')\n .pipe((v) => Number(v))\n .to('number%1 >= 1')\n .default(1);\n\nconst coercedPageSize = type('string | number')\n .pipe((v) => Number(v))\n .to('1 <= number%1 <= 100')\n .default(10);\n\nexport const pagination = {\n /**\n * Query params schema for paginated list requests.\n *\n * Coerces string query params to numbers via morphs,\n * validates constraints, and applies defaults.\n */\n input: type({ page: coercedPage, pageSize: coercedPageSize }),\n\n /**\n * Factory for paginated response schemas.\n *\n * @param itemSchema - ArkType schema for individual items in the list\n * @returns ArkType schema for `{ items: T[], total: number }`\n */\n response: <T extends Type>(itemSchema: T) =>\n type({ items: itemSchema.array(), total: 'number%1 >= 0' }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcA,qBAA2B;AAwCpB,SAAS,cAA8B,QAAoD;AAIhG,SAAO;AAAA,IACL,SAAS,MAA0C;AACjD,YAAM,MAAM,OAAO,IAAI;AAEvB,UAAI,eAAe,oBAAK,QAAQ;AAC9B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,IAAI,IAAI,CAAC,WAAW;AAAA,YAC1B,MAAM,CAAC,GAAG,MAAM,IAAI,EAAE,IAAI,MAAM;AAAA,YAChC,SAAS,MAAM;AAAA,YACf,MAAM,MAAM;AAAA,YACZ,UAAU,MAAM;AAAA,YAChB,UAAU,MAAM;AAAA,UAClB,EAAE;AAAA,QACJ;AAAA,MACF;AAEA,aAAO,EAAE,SAAS,MAAM,MAAM,IAAe;AAAA,IAC/C;AAAA,IAEA,aAAa,UAA0C;AACrD,YAAM,SAAS,OAAO,aAAa;AAAA;AAAA;AAAA;AAAA,QAIjC,UAAU,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,IAAI,KAAK;AAAA,MAClD,CAAC;AAID,YAAM,EAAE,SAAS,GAAG,kBAAkB,IAAI;AAE1C,aAAO;AAAA,IACT;AAAA,IAEA,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ACrFA,IAAAA,kBAA2B;AAE3B,IAAM,kBAAc,sBAAK,iBAAiB,EACvC,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,EACrB,GAAG,eAAe,EAClB,QAAQ,CAAC;AAEZ,IAAM,sBAAkB,sBAAK,iBAAiB,EAC3C,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,EACrB,GAAG,sBAAsB,EACzB,QAAQ,EAAE;AAEN,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,WAAO,sBAAK,EAAE,MAAM,aAAa,UAAU,gBAAgB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5D,UAAU,CAAiB,mBACzB,sBAAK,EAAE,OAAO,WAAW,MAAM,GAAG,OAAO,gBAAgB,CAAC;AAC9D;","names":["import_arktype"]}
@@ -0,0 +1,77 @@
1
+ import { Type } from 'arktype';
2
+ import { SchemaAdapter } from '@cosmneo/onion-lasagna/http/schema/types';
3
+ import * as arktype_internal_variants_object_ts from 'arktype/internal/variants/object.ts';
4
+ import * as arktype_internal_attributes_ts from 'arktype/internal/attributes.ts';
5
+
6
+ /**
7
+ * @fileoverview ArkType schema adapter for the unified route system.
8
+ *
9
+ * This adapter wraps ArkType schemas to provide a consistent interface
10
+ * for validation and JSON Schema generation. Uses ArkType's built-in
11
+ * `.toJsonSchema()` for JSON Schema conversion.
12
+ *
13
+ * ArkType offers the fastest runtime validation among TypeScript schema
14
+ * libraries (~20x faster than Zod) with a concise string-based DSL
15
+ * and built-in type inference.
16
+ *
17
+ * @module unified/schema/adapters/arktype
18
+ */
19
+
20
+ /**
21
+ * Creates a SchemaAdapter from an ArkType schema.
22
+ *
23
+ * Wraps an ArkType `Type` to provide validation via direct invocation
24
+ * and JSON Schema generation via the built-in `.toJsonSchema()` method.
25
+ * ArkType's string-based DSL enables concise schema definitions with
26
+ * best-in-class runtime performance.
27
+ *
28
+ * @param schema - An ArkType schema to wrap
29
+ * @returns A SchemaAdapter that validates using ArkType and generates JSON Schema
30
+ *
31
+ * @example Basic usage
32
+ * ```typescript
33
+ * import { type } from 'arktype';
34
+ * import { arktypeSchema } from '@cosmneo/onion-lasagna-arktype';
35
+ *
36
+ * const userSchema = arktypeSchema(type({
37
+ * name: '1 <= string <= 100',
38
+ * email: 'string.email',
39
+ * 'age?': '0 <= integer <= 150',
40
+ * }));
41
+ *
42
+ * // Validate data
43
+ * const result = userSchema.validate({
44
+ * name: 'John Doe',
45
+ * email: 'john@example.com',
46
+ * });
47
+ *
48
+ * // Generate JSON Schema
49
+ * const jsonSchema = userSchema.toJsonSchema();
50
+ * ```
51
+ */
52
+ declare function arktypeSchema<T extends Type>(schema: T): SchemaAdapter<T['infer'], T['inferIn']>;
53
+
54
+ declare const pagination: {
55
+ /**
56
+ * Query params schema for paginated list requests.
57
+ *
58
+ * Coerces string query params to numbers via morphs,
59
+ * validates constraints, and applies defaults.
60
+ */
61
+ input: arktype_internal_variants_object_ts.ObjectType<{
62
+ page: (In: arktype_internal_attributes_ts.Default<string | number, 1>) => arktype_internal_attributes_ts.To<number>;
63
+ pageSize: (In: arktype_internal_attributes_ts.Default<string | number, 10>) => arktype_internal_attributes_ts.To<number>;
64
+ }, {}>;
65
+ /**
66
+ * Factory for paginated response schemas.
67
+ *
68
+ * @param itemSchema - ArkType schema for individual items in the list
69
+ * @returns ArkType schema for `{ items: T[], total: number }`
70
+ */
71
+ response: <T extends Type>(itemSchema: T) => arktype_internal_variants_object_ts.ObjectType<{
72
+ items: unknown[];
73
+ total: number;
74
+ }, {}>;
75
+ };
76
+
77
+ export { arktypeSchema, pagination };
@@ -0,0 +1,77 @@
1
+ import { Type } from 'arktype';
2
+ import { SchemaAdapter } from '@cosmneo/onion-lasagna/http/schema/types';
3
+ import * as arktype_internal_variants_object_ts from 'arktype/internal/variants/object.ts';
4
+ import * as arktype_internal_attributes_ts from 'arktype/internal/attributes.ts';
5
+
6
+ /**
7
+ * @fileoverview ArkType schema adapter for the unified route system.
8
+ *
9
+ * This adapter wraps ArkType schemas to provide a consistent interface
10
+ * for validation and JSON Schema generation. Uses ArkType's built-in
11
+ * `.toJsonSchema()` for JSON Schema conversion.
12
+ *
13
+ * ArkType offers the fastest runtime validation among TypeScript schema
14
+ * libraries (~20x faster than Zod) with a concise string-based DSL
15
+ * and built-in type inference.
16
+ *
17
+ * @module unified/schema/adapters/arktype
18
+ */
19
+
20
+ /**
21
+ * Creates a SchemaAdapter from an ArkType schema.
22
+ *
23
+ * Wraps an ArkType `Type` to provide validation via direct invocation
24
+ * and JSON Schema generation via the built-in `.toJsonSchema()` method.
25
+ * ArkType's string-based DSL enables concise schema definitions with
26
+ * best-in-class runtime performance.
27
+ *
28
+ * @param schema - An ArkType schema to wrap
29
+ * @returns A SchemaAdapter that validates using ArkType and generates JSON Schema
30
+ *
31
+ * @example Basic usage
32
+ * ```typescript
33
+ * import { type } from 'arktype';
34
+ * import { arktypeSchema } from '@cosmneo/onion-lasagna-arktype';
35
+ *
36
+ * const userSchema = arktypeSchema(type({
37
+ * name: '1 <= string <= 100',
38
+ * email: 'string.email',
39
+ * 'age?': '0 <= integer <= 150',
40
+ * }));
41
+ *
42
+ * // Validate data
43
+ * const result = userSchema.validate({
44
+ * name: 'John Doe',
45
+ * email: 'john@example.com',
46
+ * });
47
+ *
48
+ * // Generate JSON Schema
49
+ * const jsonSchema = userSchema.toJsonSchema();
50
+ * ```
51
+ */
52
+ declare function arktypeSchema<T extends Type>(schema: T): SchemaAdapter<T['infer'], T['inferIn']>;
53
+
54
+ declare const pagination: {
55
+ /**
56
+ * Query params schema for paginated list requests.
57
+ *
58
+ * Coerces string query params to numbers via morphs,
59
+ * validates constraints, and applies defaults.
60
+ */
61
+ input: arktype_internal_variants_object_ts.ObjectType<{
62
+ page: (In: arktype_internal_attributes_ts.Default<string | number, 1>) => arktype_internal_attributes_ts.To<number>;
63
+ pageSize: (In: arktype_internal_attributes_ts.Default<string | number, 10>) => arktype_internal_attributes_ts.To<number>;
64
+ }, {}>;
65
+ /**
66
+ * Factory for paginated response schemas.
67
+ *
68
+ * @param itemSchema - ArkType schema for individual items in the list
69
+ * @returns ArkType schema for `{ items: T[], total: number }`
70
+ */
71
+ response: <T extends Type>(itemSchema: T) => arktype_internal_variants_object_ts.ObjectType<{
72
+ items: unknown[];
73
+ total: number;
74
+ }, {}>;
75
+ };
76
+
77
+ export { arktypeSchema, pagination };
package/dist/index.js ADDED
@@ -0,0 +1,61 @@
1
+ // src/arktype.adapter.ts
2
+ import { type } from "arktype";
3
+ function arktypeSchema(schema) {
4
+ return {
5
+ validate(data) {
6
+ const out = schema(data);
7
+ if (out instanceof type.errors) {
8
+ return {
9
+ success: false,
10
+ issues: out.map((error) => ({
11
+ path: [...error.path].map(String),
12
+ message: error.message,
13
+ code: error.code,
14
+ expected: error.expected,
15
+ received: error.actual
16
+ }))
17
+ };
18
+ }
19
+ return { success: true, data: out };
20
+ },
21
+ toJsonSchema(_options) {
22
+ const result = schema.toJsonSchema({
23
+ // Morphs (e.g. string→number coercion via .pipe().to()) have no JSON Schema
24
+ // equivalent. Use the output schema so OpenAPI documents the validated shape.
25
+ // Falls back to the input schema if no typed output is available.
26
+ fallback: { morph: (ctx) => ctx.out ?? ctx.base }
27
+ });
28
+ const { $schema, ...schemaWithoutMeta } = result;
29
+ return schemaWithoutMeta;
30
+ },
31
+ _output: void 0,
32
+ _input: void 0,
33
+ _schema: schema
34
+ };
35
+ }
36
+
37
+ // src/schemas/pagination.ts
38
+ import { type as type2 } from "arktype";
39
+ var coercedPage = type2("string | number").pipe((v) => Number(v)).to("number%1 >= 1").default(1);
40
+ var coercedPageSize = type2("string | number").pipe((v) => Number(v)).to("1 <= number%1 <= 100").default(10);
41
+ var pagination = {
42
+ /**
43
+ * Query params schema for paginated list requests.
44
+ *
45
+ * Coerces string query params to numbers via morphs,
46
+ * validates constraints, and applies defaults.
47
+ */
48
+ input: type2({ page: coercedPage, pageSize: coercedPageSize }),
49
+ /**
50
+ * Factory for paginated response schemas.
51
+ *
52
+ * @param itemSchema - ArkType schema for individual items in the list
53
+ * @returns ArkType schema for `{ items: T[], total: number }`
54
+ */
55
+ response: (itemSchema) => type2({ items: itemSchema.array(), total: "number%1 >= 0" })
56
+ };
57
+ export {
58
+ arktypeSchema,
59
+ pagination
60
+ };
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/arktype.adapter.ts","../src/schemas/pagination.ts"],"sourcesContent":["/**\n * @fileoverview ArkType schema adapter for the unified route system.\n *\n * This adapter wraps ArkType schemas to provide a consistent interface\n * for validation and JSON Schema generation. Uses ArkType's built-in\n * `.toJsonSchema()` for JSON Schema conversion.\n *\n * ArkType offers the fastest runtime validation among TypeScript schema\n * libraries (~20x faster than Zod) with a concise string-based DSL\n * and built-in type inference.\n *\n * @module unified/schema/adapters/arktype\n */\n\nimport { type, Type } from 'arktype';\nimport type {\n JsonSchema,\n JsonSchemaOptions,\n SchemaAdapter,\n ValidationResult,\n} from '@cosmneo/onion-lasagna/http/schema/types';\n\n/**\n * Creates a SchemaAdapter from an ArkType schema.\n *\n * Wraps an ArkType `Type` to provide validation via direct invocation\n * and JSON Schema generation via the built-in `.toJsonSchema()` method.\n * ArkType's string-based DSL enables concise schema definitions with\n * best-in-class runtime performance.\n *\n * @param schema - An ArkType schema to wrap\n * @returns A SchemaAdapter that validates using ArkType and generates JSON Schema\n *\n * @example Basic usage\n * ```typescript\n * import { type } from 'arktype';\n * import { arktypeSchema } from '@cosmneo/onion-lasagna-arktype';\n *\n * const userSchema = arktypeSchema(type({\n * name: '1 <= string <= 100',\n * email: 'string.email',\n * 'age?': '0 <= integer <= 150',\n * }));\n *\n * // Validate data\n * const result = userSchema.validate({\n * name: 'John Doe',\n * email: 'john@example.com',\n * });\n *\n * // Generate JSON Schema\n * const jsonSchema = userSchema.toJsonSchema();\n * ```\n */\nexport function arktypeSchema<T extends Type>(schema: T): SchemaAdapter<T['infer'], T['inferIn']> {\n type TOutput = T['infer'];\n type TInput = T['inferIn'];\n\n return {\n validate(data: unknown): ValidationResult<TOutput> {\n const out = schema(data);\n\n if (out instanceof type.errors) {\n return {\n success: false,\n issues: out.map((error) => ({\n path: [...error.path].map(String),\n message: error.message,\n code: error.code,\n expected: error.expected,\n received: error.actual,\n })),\n };\n }\n\n return { success: true, data: out as TOutput };\n },\n\n toJsonSchema(_options?: JsonSchemaOptions): JsonSchema {\n const result = schema.toJsonSchema({\n // Morphs (e.g. string→number coercion via .pipe().to()) have no JSON Schema\n // equivalent. Use the output schema so OpenAPI documents the validated shape.\n // Falls back to the input schema if no typed output is available.\n fallback: { morph: (ctx) => ctx.out ?? ctx.base },\n });\n\n // Remove $schema to avoid conflicts with OpenAPI\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, unused-imports/no-unused-vars\n const { $schema, ...schemaWithoutMeta } = result as Record<string, unknown>;\n\n return schemaWithoutMeta as JsonSchema;\n },\n\n _output: undefined as TOutput,\n _input: undefined as TInput,\n _schema: schema,\n };\n}\n","/**\n * @fileoverview Pre-built ArkType pagination schemas.\n *\n * Provides reusable schemas for paginated list endpoints,\n * matching the core `PaginationInput` and `PaginatedData<T>` types.\n *\n * ArkType uses `.pipe().to()` morphs for string→number coercion\n * and `.default()` for default values.\n *\n * @module schemas/pagination\n */\n\nimport { type, Type } from 'arktype';\n\nconst coercedPage = type('string | number')\n .pipe((v) => Number(v))\n .to('number%1 >= 1')\n .default(1);\n\nconst coercedPageSize = type('string | number')\n .pipe((v) => Number(v))\n .to('1 <= number%1 <= 100')\n .default(10);\n\nexport const pagination = {\n /**\n * Query params schema for paginated list requests.\n *\n * Coerces string query params to numbers via morphs,\n * validates constraints, and applies defaults.\n */\n input: type({ page: coercedPage, pageSize: coercedPageSize }),\n\n /**\n * Factory for paginated response schemas.\n *\n * @param itemSchema - ArkType schema for individual items in the list\n * @returns ArkType schema for `{ items: T[], total: number }`\n */\n response: <T extends Type>(itemSchema: T) =>\n type({ items: itemSchema.array(), total: 'number%1 >= 0' }),\n};\n"],"mappings":";AAcA,SAAS,YAAkB;AAwCpB,SAAS,cAA8B,QAAoD;AAIhG,SAAO;AAAA,IACL,SAAS,MAA0C;AACjD,YAAM,MAAM,OAAO,IAAI;AAEvB,UAAI,eAAe,KAAK,QAAQ;AAC9B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,IAAI,IAAI,CAAC,WAAW;AAAA,YAC1B,MAAM,CAAC,GAAG,MAAM,IAAI,EAAE,IAAI,MAAM;AAAA,YAChC,SAAS,MAAM;AAAA,YACf,MAAM,MAAM;AAAA,YACZ,UAAU,MAAM;AAAA,YAChB,UAAU,MAAM;AAAA,UAClB,EAAE;AAAA,QACJ;AAAA,MACF;AAEA,aAAO,EAAE,SAAS,MAAM,MAAM,IAAe;AAAA,IAC/C;AAAA,IAEA,aAAa,UAA0C;AACrD,YAAM,SAAS,OAAO,aAAa;AAAA;AAAA;AAAA;AAAA,QAIjC,UAAU,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,IAAI,KAAK;AAAA,MAClD,CAAC;AAID,YAAM,EAAE,SAAS,GAAG,kBAAkB,IAAI;AAE1C,aAAO;AAAA,IACT;AAAA,IAEA,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ACrFA,SAAS,QAAAA,aAAkB;AAE3B,IAAM,cAAcA,MAAK,iBAAiB,EACvC,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,EACrB,GAAG,eAAe,EAClB,QAAQ,CAAC;AAEZ,IAAM,kBAAkBA,MAAK,iBAAiB,EAC3C,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,EACrB,GAAG,sBAAsB,EACzB,QAAQ,EAAE;AAEN,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOxB,OAAOA,MAAK,EAAE,MAAM,aAAa,UAAU,gBAAgB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5D,UAAU,CAAiB,eACzBA,MAAK,EAAE,OAAO,WAAW,MAAM,GAAG,OAAO,gBAAgB,CAAC;AAC9D;","names":["type"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@cosmneo/onion-lasagna-arktype",
3
+ "version": "0.2.0",
4
+ "description": "ArkType schema adapter for onion-lasagna",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Cosmneo",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Cosmneo/onion-lasagna.git",
11
+ "directory": "packages/schemas/onion-lasagna-arktype"
12
+ },
13
+ "engines": {
14
+ "node": ">=18.0.0"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": false,
20
+ "devDependencies": {
21
+ "tsup": "^8.5.1",
22
+ "vitest": "^4.0.16",
23
+ "arktype": "2.1.29",
24
+ "@cosmneo/onion-lasagna": "workspace:*"
25
+ },
26
+ "peerDependencies": {
27
+ "arktype": "^2.0.0",
28
+ "@cosmneo/onion-lasagna": ">=0.2.0"
29
+ },
30
+ "scripts": {
31
+ "build": "tsup",
32
+ "dev": "tsup --watch",
33
+ "test": "vitest",
34
+ "test:run": "vitest run",
35
+ "prepublishOnly": "bun run build"
36
+ },
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js",
41
+ "require": "./dist/index.cjs",
42
+ "default": "./dist/index.js"
43
+ }
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }