@atomic-solutions/schemas 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Atomic Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # @atomic-solutions/schemas
2
+
3
+ Shared Zod schemas for WooCommerce, WordPress, and common types. Tree-shakeable with zero React dependencies.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @atomic-solutions/schemas zod
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Import specific modules (recommended for tree-shaking)
14
+
15
+ ```typescript
16
+ // WooCommerce schemas
17
+ import { cartSchema, Cart, orderStatusEnum } from '@atomic-solutions/schemas/woocommerce';
18
+
19
+ // WordPress schemas
20
+ import { UserSchema, CurrentUser, JwtTokenResponseSchema } from '@atomic-solutions/schemas/wordpress';
21
+
22
+ // Common schemas (address, money, pagination)
23
+ import { addressSchema, Address, moneySchema } from '@atomic-solutions/schemas/common';
24
+ ```
25
+
26
+ ### Import everything
27
+
28
+ ```typescript
29
+ import {
30
+ // WooCommerce
31
+ cartSchema,
32
+ Cart,
33
+ storeApiOrderSchema,
34
+
35
+ // WordPress
36
+ UserSchema,
37
+ JwtLoginInputSchema,
38
+
39
+ // Common
40
+ addressSchema,
41
+ Address,
42
+ } from '@atomic-solutions/schemas';
43
+ ```
44
+
45
+ ## Available Schemas
46
+
47
+ ### Common (`@atomic-solutions/schemas/common`)
48
+
49
+ - `addressSchema` / `Address` - Shipping/billing address
50
+ - `billingAddressSchemaMandatory` / `BillingAddress` - Billing address with email
51
+ - `moneySchema` / `Money` - Currency formatting
52
+ - `paginationParamsSchema` / `PaginationParams` - Pagination query params
53
+ - `paginationMetaSchema` / `PaginationMeta` - Pagination response metadata
54
+
55
+ ### WooCommerce (`@atomic-solutions/schemas/woocommerce`)
56
+
57
+ **Cart:**
58
+ - `cartSchema` / `Cart`
59
+ - `cartItemSchema` / `CartItem`
60
+ - `addToCartInputSchema` / `AddToCartInput`
61
+ - `updateCartItemInputSchema` / `UpdateCartItemInput`
62
+
63
+ **Orders:**
64
+ - `storeApiOrderSchema` / `StoreApiOrder`
65
+ - `orderStatusEnum` / `OrderStatus`
66
+ - `orderItemSchema` / `OrderItem`
67
+ - `orderTotalsSchema` / `OrderTotals`
68
+
69
+ **Checkout:**
70
+ - `checkoutSchema` / `Checkout`
71
+ - `checkoutInputSchema` / `CheckoutInput`
72
+
73
+ **Products:**
74
+ - `productSchema` / `Product`
75
+ - `productCategorySchema` / `ProductCategory`
76
+ - `pricesSchema` / `Prices`
77
+
78
+ **Shipping:**
79
+ - `shippingRateSchema` / `ShippingRate`
80
+ - `shippingPackageSchema` / `ShippingPackage`
81
+
82
+ ### WordPress (`@atomic-solutions/schemas/wordpress`)
83
+
84
+ **Auth (JWT):**
85
+ - `JwtLoginInputSchema` / `JwtLoginInput`
86
+ - `JwtTokenResponseSchema` / `JwtTokenResponse`
87
+ - `JwtValidateResponseSchema` / `JwtValidateResponse`
88
+
89
+ **Users:**
90
+ - `UserSchema` / `User`
91
+ - `CurrentUserSchema` / `CurrentUser`
92
+
93
+ **Posts:**
94
+ - `PostSchema` / `Post`
95
+ - `PostParamsSchema` / `PostParams`
96
+
97
+ **Categories:**
98
+ - `CategorySchema` / `Category`
99
+ - `TagSchema` / `Tag`
100
+
101
+ **Media:**
102
+ - `MediaSchema` / `Media`
103
+ - `MediaDetailsSchema` / `MediaDetails`
104
+
105
+ ## Use with NestJS
106
+
107
+ ```typescript
108
+ import { createZodDto } from 'nestjs-zod';
109
+ import { addressSchema, JwtLoginInputSchema } from '@atomic-solutions/schemas';
110
+
111
+ // Create NestJS DTOs from Zod schemas
112
+ export class AddressDto extends createZodDto(addressSchema) {}
113
+ export class LoginDto extends createZodDto(JwtLoginInputSchema) {}
114
+ ```
115
+
116
+ ## Use with React Native / React
117
+
118
+ These schemas are also used by:
119
+ - `@atomic-solutions/woocommerce-utils`
120
+ - `@atomic-solutions/wordpress-utils`
121
+
122
+ ## License
123
+
124
+ MIT
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+
5
+ // src/common/address.schema.ts
6
+ var addressSchema = zod.z.object({
7
+ /** First name */
8
+ first_name: zod.z.string().min(1, "First name is required"),
9
+ /** Last name */
10
+ last_name: zod.z.string().min(1, "Last name is required"),
11
+ /** Company name (optional) */
12
+ company: zod.z.string(),
13
+ /** Address line 1 */
14
+ address_1: zod.z.string().min(1, "Address is required"),
15
+ /** Address line 2 (optional) */
16
+ address_2: zod.z.string(),
17
+ /** City */
18
+ city: zod.z.string().min(1, "City is required"),
19
+ /** State/Province/Region */
20
+ state: zod.z.string(),
21
+ /** Postal code */
22
+ postcode: zod.z.string().min(1, "Postal code is required"),
23
+ /** Country code (ISO 3166-1 alpha-2) */
24
+ country: zod.z.string(),
25
+ /** Phone number */
26
+ phone: zod.z.string().min(1, "Phone number is required")
27
+ });
28
+ var addressSchemaNonMandatory = zod.z.object({
29
+ /** First name */
30
+ first_name: zod.z.string(),
31
+ /** Last name */
32
+ last_name: zod.z.string(),
33
+ /** Company name (optional) */
34
+ company: zod.z.string(),
35
+ /** Address line 1 */
36
+ address_1: zod.z.string(),
37
+ /** Address line 2 (optional) */
38
+ address_2: zod.z.string(),
39
+ /** City */
40
+ city: zod.z.string(),
41
+ /** State/Province/Region */
42
+ state: zod.z.string(),
43
+ /** Postal code */
44
+ postcode: zod.z.string(),
45
+ /** Country code (ISO 3166-1 alpha-2) */
46
+ country: zod.z.string(),
47
+ /** Phone number */
48
+ phone: zod.z.string()
49
+ });
50
+ var billingAddressSchemaMandatory = addressSchema.extend({
51
+ /** Email address (required for billing) */
52
+ email: zod.z.string().email("Valid email is required")
53
+ });
54
+ var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
55
+ /** Email address (can be null for guest carts) */
56
+ email: zod.z.string().nullable()
57
+ });
58
+ var moneySchema = zod.z.object({
59
+ /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
60
+ currency_code: zod.z.string(),
61
+ /** Currency symbol (e.g., '$', '€', 'KM') */
62
+ currency_symbol: zod.z.string(),
63
+ /** Number of decimal places (e.g., 2 for dollars/euros) */
64
+ currency_minor_unit: zod.z.number(),
65
+ /** Decimal separator character (e.g., '.', ',') */
66
+ currency_decimal_separator: zod.z.string(),
67
+ /** Thousands separator character (e.g., ',', '.') */
68
+ currency_thousand_separator: zod.z.string(),
69
+ /** Currency symbol prefix (empty if symbol is suffix) */
70
+ currency_prefix: zod.z.string(),
71
+ /** Currency symbol suffix (empty if symbol is prefix) */
72
+ currency_suffix: zod.z.string()
73
+ });
74
+ var paginationParamsSchema = zod.z.object({
75
+ /** Current page number */
76
+ page: zod.z.number().int().positive().optional(),
77
+ /** Items per page */
78
+ per_page: zod.z.number().int().positive().max(100).optional(),
79
+ /** Offset for pagination */
80
+ offset: zod.z.number().int().nonnegative().optional(),
81
+ /** Sort order */
82
+ order: zod.z.enum(["asc", "desc"]).optional(),
83
+ /** Field to sort by */
84
+ orderby: zod.z.string().optional()
85
+ });
86
+ var paginationMetaSchema = zod.z.object({
87
+ /** Total number of items */
88
+ total: zod.z.number(),
89
+ /** Total number of pages */
90
+ totalPages: zod.z.number(),
91
+ /** Current page */
92
+ currentPage: zod.z.number(),
93
+ /** Items per page */
94
+ perPage: zod.z.number()
95
+ });
96
+
97
+ exports.addressSchema = addressSchema;
98
+ exports.addressSchemaNonMandatory = addressSchemaNonMandatory;
99
+ exports.billingAddressSchemaMandatory = billingAddressSchemaMandatory;
100
+ exports.billingAddressSchemaNonMandatory = billingAddressSchemaNonMandatory;
101
+ exports.moneySchema = moneySchema;
102
+ exports.paginationMetaSchema = paginationMetaSchema;
103
+ exports.paginationParamsSchema = paginationParamsSchema;
104
+ //# sourceMappingURL=index.cjs.map
105
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/common/address.schema.ts","../../src/common/money.schema.ts","../../src/common/pagination.schema.ts"],"names":["z"],"mappings":";;;;;AAOO,IAAM,aAAA,GAAgBA,MAAE,MAAA,CAAO;AAAA;AAAA,EAEpC,YAAYA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,wBAAwB,CAAA;AAAA;AAAA,EAGtD,WAAWA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,uBAAuB,CAAA;AAAA;AAAA,EAGpD,OAAA,EAASA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGlB,WAAWA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,qBAAqB,CAAA;AAAA;AAAA,EAGlD,SAAA,EAAWA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGpB,MAAMA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,kBAA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,MAAE,MAAA,EAAO;AAAA;AAAA,EAG1B,mBAAA,EAAqBA,MAAE,MAAA,EAAO;AAAA;AAAA,EAG9B,0BAAA,EAA4BA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGrC,2BAAA,EAA6BA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGtC,eAAA,EAAiBA,MAAE,MAAA,EAAO;AAAA;AAAA,EAG1B,eAAA,EAAiBA,MAAE,MAAA;AACrB,CAAC;ACxBM,IAAM,sBAAA,GAAyBA,MAAE,MAAA,CAAO;AAAA;AAAA,EAE7C,IAAA,EAAMA,MAAE,MAAA,EAAO,CAAE,KAAI,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA;AAAA,EAG3C,QAAA,EAAUA,KAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,QAAA,EAAS,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA;AAAA,EAGxD,MAAA,EAAQA,MAAE,MAAA,EAAO,CAAE,KAAI,CAAE,WAAA,GAAc,QAAA,EAAS;AAAA;AAAA,EAGhD,KAAA,EAAOA,MAAE,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,EAAE,QAAA,EAAS;AAAA;AAAA,EAGxC,OAAA,EAASA,KAAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACtB,CAAC;AAKM,IAAM,oBAAA,GAAuBA,MAAE,MAAA,CAAO;AAAA;AAAA,EAE3C,KAAA,EAAOA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGhB,UAAA,EAAYA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGrB,WAAA,EAAaA,MAAE,MAAA,EAAO;AAAA;AAAA,EAGtB,OAAA,EAASA,MAAE,MAAA;AACb,CAAC","file":"index.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * Base address schema for WooCommerce addresses\n *\n * Used for both billing and shipping addresses in checkout\n */\nexport const addressSchema = z.object({\n /** First name */\n first_name: z.string().min(1, 'First name is required'),\n\n /** Last name */\n last_name: z.string().min(1, 'Last name is required'),\n\n /** Company name (optional) */\n company: z.string(),\n\n /** Address line 1 */\n address_1: z.string().min(1, 'Address is required'),\n\n /** Address line 2 (optional) */\n address_2: z.string(),\n\n /** City */\n city: z.string().min(1, 'City is required'),\n\n /** State/Province/Region */\n state: z.string(),\n\n /** Postal code */\n postcode: z.string().min(1, 'Postal code is required'),\n\n /** Country code (ISO 3166-1 alpha-2) */\n country: z.string(),\n\n /** Phone number */\n phone: z.string().min(1, 'Phone number is required'),\n});\n\n/**\n * Non-mandatory address schema for API responses\n *\n * Used for parsing cart shipping/billing addresses from API responses.\n * No validation constraints - accepts whatever the API returns.\n */\nexport const addressSchemaNonMandatory = z.object({\n /** First name */\n first_name: z.string(),\n\n /** Last name */\n last_name: z.string(),\n\n /** Company name (optional) */\n company: z.string(),\n\n /** Address line 1 */\n address_1: z.string(),\n\n /** Address line 2 (optional) */\n address_2: z.string(),\n\n /** City */\n city: z.string(),\n\n /** State/Province/Region */\n state: z.string(),\n\n /** Postal code */\n postcode: z.string(),\n\n /** Country code (ISO 3166-1 alpha-2) */\n country: z.string(),\n\n /** Phone number */\n phone: z.string(),\n});\n\n/**\n * Billing address schema\n *\n * Extends base address with email field (required for billing)\n */\nexport const billingAddressSchemaMandatory = addressSchema.extend({\n /** Email address (required for billing) */\n email: z.string().email('Valid email is required'),\n});\n\nexport const billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({\n /** Email address (can be null for guest carts) */\n email: z.string().nullable(),\n});\n\n// Type exports\nexport type Address = z.infer<typeof addressSchema>;\nexport type BillingAddress = z.infer<typeof billingAddressSchemaMandatory>;\nexport type AddressNonOptional = z.infer<typeof addressSchemaNonMandatory>;\nexport type BillingAddressNonOptional = z.infer<typeof billingAddressSchemaNonMandatory>;\n","import { z } from 'zod';\n\n/**\n * WooCommerce money/currency formatting schema\n *\n * Contains currency information and formatting rules used throughout\n * WooCommerce responses for prices, totals, and monetary values.\n */\nexport const moneySchema = z.object({\n /** Currency code (e.g., 'USD', 'EUR', 'BAM') */\n currency_code: z.string(),\n\n /** Currency symbol (e.g., '$', '€', 'KM') */\n currency_symbol: z.string(),\n\n /** Number of decimal places (e.g., 2 for dollars/euros) */\n currency_minor_unit: z.number(),\n\n /** Decimal separator character (e.g., '.', ',') */\n currency_decimal_separator: z.string(),\n\n /** Thousands separator character (e.g., ',', '.') */\n currency_thousand_separator: z.string(),\n\n /** Currency symbol prefix (empty if symbol is suffix) */\n currency_prefix: z.string(),\n\n /** Currency symbol suffix (empty if symbol is prefix) */\n currency_suffix: z.string(),\n});\n\n// Type export\nexport type Money = z.infer<typeof moneySchema>;\n","import { z } from 'zod';\n\n/**\n * Base pagination parameters schema\n */\nexport const paginationParamsSchema = z.object({\n /** Current page number */\n page: z.number().int().positive().optional(),\n\n /** Items per page */\n per_page: z.number().int().positive().max(100).optional(),\n\n /** Offset for pagination */\n offset: z.number().int().nonnegative().optional(),\n\n /** Sort order */\n order: z.enum(['asc', 'desc']).optional(),\n\n /** Field to sort by */\n orderby: z.string().optional(),\n});\n\n/**\n * Pagination metadata schema (for responses)\n */\nexport const paginationMetaSchema = z.object({\n /** Total number of items */\n total: z.number(),\n\n /** Total number of pages */\n totalPages: z.number(),\n\n /** Current page */\n currentPage: z.number(),\n\n /** Items per page */\n perPage: z.number(),\n});\n\n// Type exports\nexport type PaginationParams = z.infer<typeof paginationParamsSchema>;\nexport type PaginationMeta = z.infer<typeof paginationMetaSchema>;\n"]}
@@ -0,0 +1,57 @@
1
+ export { A as Address, e as AddressNonOptional, B as BillingAddress, f as BillingAddressNonOptional, M as Money, a as addressSchema, b as addressSchemaNonMandatory, c as billingAddressSchemaMandatory, d as billingAddressSchemaNonMandatory, m as moneySchema } from '../money.schema-BeHADrsV.cjs';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * Base pagination parameters schema
6
+ */
7
+ declare const paginationParamsSchema: z.ZodObject<{
8
+ /** Current page number */
9
+ page: z.ZodOptional<z.ZodNumber>;
10
+ /** Items per page */
11
+ per_page: z.ZodOptional<z.ZodNumber>;
12
+ /** Offset for pagination */
13
+ offset: z.ZodOptional<z.ZodNumber>;
14
+ /** Sort order */
15
+ order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
16
+ /** Field to sort by */
17
+ orderby: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ page?: number | undefined;
20
+ per_page?: number | undefined;
21
+ offset?: number | undefined;
22
+ order?: "asc" | "desc" | undefined;
23
+ orderby?: string | undefined;
24
+ }, {
25
+ page?: number | undefined;
26
+ per_page?: number | undefined;
27
+ offset?: number | undefined;
28
+ order?: "asc" | "desc" | undefined;
29
+ orderby?: string | undefined;
30
+ }>;
31
+ /**
32
+ * Pagination metadata schema (for responses)
33
+ */
34
+ declare const paginationMetaSchema: z.ZodObject<{
35
+ /** Total number of items */
36
+ total: z.ZodNumber;
37
+ /** Total number of pages */
38
+ totalPages: z.ZodNumber;
39
+ /** Current page */
40
+ currentPage: z.ZodNumber;
41
+ /** Items per page */
42
+ perPage: z.ZodNumber;
43
+ }, "strip", z.ZodTypeAny, {
44
+ total: number;
45
+ totalPages: number;
46
+ currentPage: number;
47
+ perPage: number;
48
+ }, {
49
+ total: number;
50
+ totalPages: number;
51
+ currentPage: number;
52
+ perPage: number;
53
+ }>;
54
+ type PaginationParams = z.infer<typeof paginationParamsSchema>;
55
+ type PaginationMeta = z.infer<typeof paginationMetaSchema>;
56
+
57
+ export { type PaginationMeta, type PaginationParams, paginationMetaSchema, paginationParamsSchema };
@@ -0,0 +1,57 @@
1
+ export { A as Address, e as AddressNonOptional, B as BillingAddress, f as BillingAddressNonOptional, M as Money, a as addressSchema, b as addressSchemaNonMandatory, c as billingAddressSchemaMandatory, d as billingAddressSchemaNonMandatory, m as moneySchema } from '../money.schema-BeHADrsV.js';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * Base pagination parameters schema
6
+ */
7
+ declare const paginationParamsSchema: z.ZodObject<{
8
+ /** Current page number */
9
+ page: z.ZodOptional<z.ZodNumber>;
10
+ /** Items per page */
11
+ per_page: z.ZodOptional<z.ZodNumber>;
12
+ /** Offset for pagination */
13
+ offset: z.ZodOptional<z.ZodNumber>;
14
+ /** Sort order */
15
+ order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
16
+ /** Field to sort by */
17
+ orderby: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ page?: number | undefined;
20
+ per_page?: number | undefined;
21
+ offset?: number | undefined;
22
+ order?: "asc" | "desc" | undefined;
23
+ orderby?: string | undefined;
24
+ }, {
25
+ page?: number | undefined;
26
+ per_page?: number | undefined;
27
+ offset?: number | undefined;
28
+ order?: "asc" | "desc" | undefined;
29
+ orderby?: string | undefined;
30
+ }>;
31
+ /**
32
+ * Pagination metadata schema (for responses)
33
+ */
34
+ declare const paginationMetaSchema: z.ZodObject<{
35
+ /** Total number of items */
36
+ total: z.ZodNumber;
37
+ /** Total number of pages */
38
+ totalPages: z.ZodNumber;
39
+ /** Current page */
40
+ currentPage: z.ZodNumber;
41
+ /** Items per page */
42
+ perPage: z.ZodNumber;
43
+ }, "strip", z.ZodTypeAny, {
44
+ total: number;
45
+ totalPages: number;
46
+ currentPage: number;
47
+ perPage: number;
48
+ }, {
49
+ total: number;
50
+ totalPages: number;
51
+ currentPage: number;
52
+ perPage: number;
53
+ }>;
54
+ type PaginationParams = z.infer<typeof paginationParamsSchema>;
55
+ type PaginationMeta = z.infer<typeof paginationMetaSchema>;
56
+
57
+ export { type PaginationMeta, type PaginationParams, paginationMetaSchema, paginationParamsSchema };
@@ -0,0 +1,97 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/common/address.schema.ts
4
+ var addressSchema = z.object({
5
+ /** First name */
6
+ first_name: z.string().min(1, "First name is required"),
7
+ /** Last name */
8
+ last_name: z.string().min(1, "Last name is required"),
9
+ /** Company name (optional) */
10
+ company: z.string(),
11
+ /** Address line 1 */
12
+ address_1: z.string().min(1, "Address is required"),
13
+ /** Address line 2 (optional) */
14
+ address_2: z.string(),
15
+ /** City */
16
+ city: z.string().min(1, "City is required"),
17
+ /** State/Province/Region */
18
+ state: z.string(),
19
+ /** Postal code */
20
+ postcode: z.string().min(1, "Postal code is required"),
21
+ /** Country code (ISO 3166-1 alpha-2) */
22
+ country: z.string(),
23
+ /** Phone number */
24
+ phone: z.string().min(1, "Phone number is required")
25
+ });
26
+ var addressSchemaNonMandatory = z.object({
27
+ /** First name */
28
+ first_name: z.string(),
29
+ /** Last name */
30
+ last_name: z.string(),
31
+ /** Company name (optional) */
32
+ company: z.string(),
33
+ /** Address line 1 */
34
+ address_1: z.string(),
35
+ /** Address line 2 (optional) */
36
+ address_2: z.string(),
37
+ /** City */
38
+ city: z.string(),
39
+ /** State/Province/Region */
40
+ state: z.string(),
41
+ /** Postal code */
42
+ postcode: z.string(),
43
+ /** Country code (ISO 3166-1 alpha-2) */
44
+ country: z.string(),
45
+ /** Phone number */
46
+ phone: z.string()
47
+ });
48
+ var billingAddressSchemaMandatory = addressSchema.extend({
49
+ /** Email address (required for billing) */
50
+ email: z.string().email("Valid email is required")
51
+ });
52
+ var billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({
53
+ /** Email address (can be null for guest carts) */
54
+ email: z.string().nullable()
55
+ });
56
+ var moneySchema = z.object({
57
+ /** Currency code (e.g., 'USD', 'EUR', 'BAM') */
58
+ currency_code: z.string(),
59
+ /** Currency symbol (e.g., '$', '€', 'KM') */
60
+ currency_symbol: z.string(),
61
+ /** Number of decimal places (e.g., 2 for dollars/euros) */
62
+ currency_minor_unit: z.number(),
63
+ /** Decimal separator character (e.g., '.', ',') */
64
+ currency_decimal_separator: z.string(),
65
+ /** Thousands separator character (e.g., ',', '.') */
66
+ currency_thousand_separator: z.string(),
67
+ /** Currency symbol prefix (empty if symbol is suffix) */
68
+ currency_prefix: z.string(),
69
+ /** Currency symbol suffix (empty if symbol is prefix) */
70
+ currency_suffix: z.string()
71
+ });
72
+ var paginationParamsSchema = z.object({
73
+ /** Current page number */
74
+ page: z.number().int().positive().optional(),
75
+ /** Items per page */
76
+ per_page: z.number().int().positive().max(100).optional(),
77
+ /** Offset for pagination */
78
+ offset: z.number().int().nonnegative().optional(),
79
+ /** Sort order */
80
+ order: z.enum(["asc", "desc"]).optional(),
81
+ /** Field to sort by */
82
+ orderby: z.string().optional()
83
+ });
84
+ var paginationMetaSchema = z.object({
85
+ /** Total number of items */
86
+ total: z.number(),
87
+ /** Total number of pages */
88
+ totalPages: z.number(),
89
+ /** Current page */
90
+ currentPage: z.number(),
91
+ /** Items per page */
92
+ perPage: z.number()
93
+ });
94
+
95
+ export { addressSchema, addressSchemaNonMandatory, billingAddressSchemaMandatory, billingAddressSchemaNonMandatory, moneySchema, paginationMetaSchema, paginationParamsSchema };
96
+ //# sourceMappingURL=index.js.map
97
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/common/address.schema.ts","../../src/common/money.schema.ts","../../src/common/pagination.schema.ts"],"names":["z"],"mappings":";;;AAOO,IAAM,aAAA,GAAgB,EAAE,MAAA,CAAO;AAAA;AAAA,EAEpC,YAAY,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,wBAAwB,CAAA;AAAA;AAAA,EAGtD,WAAW,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,uBAAuB,CAAA;AAAA;AAAA,EAGpD,OAAA,EAAS,EAAE,MAAA,EAAO;AAAA;AAAA,EAGlB,WAAW,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,qBAAqB,CAAA;AAAA;AAAA,EAGlD,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA;AAAA,EAGpB,MAAM,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAG,kBAAkB,CAAA;AAAA;AAAA,EAG1C,KAAA,EAAO,EAAE,MAAA,EAAO;AAAA;AAAA,EAG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0BAAA,EAA4BA,EAAE,MAAA,EAAO;AAAA;AAAA,EAGrC,2BAAA,EAA6BA,EAAE,MAAA,EAAO;AAAA;AAAA,EAGtC,eAAA,EAAiBA,EAAE,MAAA,EAAO;AAAA;AAAA,EAG1B,eAAA,EAAiBA,EAAE,MAAA;AACrB,CAAC;ACxBM,IAAM,sBAAA,GAAyBA,EAAE,MAAA,CAAO;AAAA;AAAA,EAE7C,IAAA,EAAMA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,QAAA,GAAW,QAAA,EAAS;AAAA;AAAA,EAG3C,QAAA,EAAUA,CAAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI,CAAE,QAAA,EAAS,CAAE,GAAA,CAAI,GAAG,CAAA,CAAE,QAAA,EAAS;AAAA;AAAA,EAGxD,MAAA,EAAQA,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,WAAA,GAAc,QAAA,EAAS;AAAA;AAAA,EAGhD,KAAA,EAAOA,EAAE,IAAA,CAAK,CAAC,OAAO,MAAM,CAAC,EAAE,QAAA,EAAS;AAAA;AAAA,EAGxC,OAAA,EAASA,CAAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACtB,CAAC;AAKM,IAAM,oBAAA,GAAuBA,EAAE,MAAA,CAAO;AAAA;AAAA,EAE3C,KAAA,EAAOA,EAAE,MAAA,EAAO;AAAA;AAAA,EAGhB,UAAA,EAAYA,EAAE,MAAA,EAAO;AAAA;AAAA,EAGrB,WAAA,EAAaA,EAAE,MAAA,EAAO;AAAA;AAAA,EAGtB,OAAA,EAASA,EAAE,MAAA;AACb,CAAC","file":"index.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * Base address schema for WooCommerce addresses\n *\n * Used for both billing and shipping addresses in checkout\n */\nexport const addressSchema = z.object({\n /** First name */\n first_name: z.string().min(1, 'First name is required'),\n\n /** Last name */\n last_name: z.string().min(1, 'Last name is required'),\n\n /** Company name (optional) */\n company: z.string(),\n\n /** Address line 1 */\n address_1: z.string().min(1, 'Address is required'),\n\n /** Address line 2 (optional) */\n address_2: z.string(),\n\n /** City */\n city: z.string().min(1, 'City is required'),\n\n /** State/Province/Region */\n state: z.string(),\n\n /** Postal code */\n postcode: z.string().min(1, 'Postal code is required'),\n\n /** Country code (ISO 3166-1 alpha-2) */\n country: z.string(),\n\n /** Phone number */\n phone: z.string().min(1, 'Phone number is required'),\n});\n\n/**\n * Non-mandatory address schema for API responses\n *\n * Used for parsing cart shipping/billing addresses from API responses.\n * No validation constraints - accepts whatever the API returns.\n */\nexport const addressSchemaNonMandatory = z.object({\n /** First name */\n first_name: z.string(),\n\n /** Last name */\n last_name: z.string(),\n\n /** Company name (optional) */\n company: z.string(),\n\n /** Address line 1 */\n address_1: z.string(),\n\n /** Address line 2 (optional) */\n address_2: z.string(),\n\n /** City */\n city: z.string(),\n\n /** State/Province/Region */\n state: z.string(),\n\n /** Postal code */\n postcode: z.string(),\n\n /** Country code (ISO 3166-1 alpha-2) */\n country: z.string(),\n\n /** Phone number */\n phone: z.string(),\n});\n\n/**\n * Billing address schema\n *\n * Extends base address with email field (required for billing)\n */\nexport const billingAddressSchemaMandatory = addressSchema.extend({\n /** Email address (required for billing) */\n email: z.string().email('Valid email is required'),\n});\n\nexport const billingAddressSchemaNonMandatory = addressSchemaNonMandatory.extend({\n /** Email address (can be null for guest carts) */\n email: z.string().nullable(),\n});\n\n// Type exports\nexport type Address = z.infer<typeof addressSchema>;\nexport type BillingAddress = z.infer<typeof billingAddressSchemaMandatory>;\nexport type AddressNonOptional = z.infer<typeof addressSchemaNonMandatory>;\nexport type BillingAddressNonOptional = z.infer<typeof billingAddressSchemaNonMandatory>;\n","import { z } from 'zod';\n\n/**\n * WooCommerce money/currency formatting schema\n *\n * Contains currency information and formatting rules used throughout\n * WooCommerce responses for prices, totals, and monetary values.\n */\nexport const moneySchema = z.object({\n /** Currency code (e.g., 'USD', 'EUR', 'BAM') */\n currency_code: z.string(),\n\n /** Currency symbol (e.g., '$', '€', 'KM') */\n currency_symbol: z.string(),\n\n /** Number of decimal places (e.g., 2 for dollars/euros) */\n currency_minor_unit: z.number(),\n\n /** Decimal separator character (e.g., '.', ',') */\n currency_decimal_separator: z.string(),\n\n /** Thousands separator character (e.g., ',', '.') */\n currency_thousand_separator: z.string(),\n\n /** Currency symbol prefix (empty if symbol is suffix) */\n currency_prefix: z.string(),\n\n /** Currency symbol suffix (empty if symbol is prefix) */\n currency_suffix: z.string(),\n});\n\n// Type export\nexport type Money = z.infer<typeof moneySchema>;\n","import { z } from 'zod';\n\n/**\n * Base pagination parameters schema\n */\nexport const paginationParamsSchema = z.object({\n /** Current page number */\n page: z.number().int().positive().optional(),\n\n /** Items per page */\n per_page: z.number().int().positive().max(100).optional(),\n\n /** Offset for pagination */\n offset: z.number().int().nonnegative().optional(),\n\n /** Sort order */\n order: z.enum(['asc', 'desc']).optional(),\n\n /** Field to sort by */\n orderby: z.string().optional(),\n});\n\n/**\n * Pagination metadata schema (for responses)\n */\nexport const paginationMetaSchema = z.object({\n /** Total number of items */\n total: z.number(),\n\n /** Total number of pages */\n totalPages: z.number(),\n\n /** Current page */\n currentPage: z.number(),\n\n /** Items per page */\n perPage: z.number(),\n});\n\n// Type exports\nexport type PaginationParams = z.infer<typeof paginationParamsSchema>;\nexport type PaginationMeta = z.infer<typeof paginationMetaSchema>;\n"]}