@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
156 lines • 7.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CategoryImagesResponseSchema = exports.CategoryFiltersResponseSchema = exports.CategoryAttributesResponseSchema = exports.CategoryItemsResponseSchema = exports.CategoryPreCacheResponseSchema = exports.CategoryLookupResponseSchema = exports.CategoryListResponseSchema = exports.CategoryResponseSchema = exports.CategoryImageSchema = exports.CategoryFilterSchema = exports.CategoryAttributeSchema = exports.CategoryItemSchema = exports.CategoryItemsParamsSchema = exports.CategoryDetailsParamsSchema = exports.CategoryPreCacheParamsSchema = exports.CategoryLookupParamsSchema = exports.CategoryListParamsSchema = exports.CategorySchema = exports.LookupCategoryWithSubsSchema = exports.SubCategorySchema = exports.LookupCategoryEntitySchema = exports.ItemCategoryEntitySchema = void 0;
const zod_1 = require("zod");
const schemas_1 = require("../../../core/schemas");
// Core category schemas based on ItemCategory.json
exports.ItemCategoryEntitySchema = zod_1.z.object({
itemCategoryUid: zod_1.z.number(),
itemCategoryId: zod_1.z.string().max(255),
itemCategoryDesc: zod_1.z.string().max(255),
masterCategoryFlag: zod_1.z.string().max(1),
parentCategoryFlag: zod_1.z.string().max(1),
displayOnWebFlag: zod_1.z.enum(['Y', 'N']),
displayMasterProductFlag: zod_1.z.string().max(1),
catalogPage: zod_1.z.string().max(255).nullable().optional(),
deleteFlag: zod_1.z.enum(['Y', 'N']),
dateCreated: zod_1.z.string(),
createdBy: zod_1.z.string().max(255),
dateLastModified: zod_1.z.string(),
lastMaintainedBy: zod_1.z.string().max(255),
subCategoryImageFile: zod_1.z.string().max(255).nullable().optional(),
updateCd: zod_1.z.number(),
statusCd: zod_1.z.number(),
processCd: zod_1.z.number(),
itemCount: zod_1.z.number(),
});
// Lookup category schema for hierarchical operations
exports.LookupCategoryEntitySchema = zod_1.z.object({
itemCategoryUid: zod_1.z.number(),
itemCategoryId: zod_1.z.string(),
itemCategoryDesc: zod_1.z.string(),
displayOnWebFlag: zod_1.z.enum(['Y', 'N']),
deleteFlag: zod_1.z.enum(['Y', 'N']),
itemCount: zod_1.z.number(),
fullPath: zod_1.z.string().nullable(),
});
// Sub-category schema for hierarchical display
exports.SubCategorySchema = zod_1.z.object({
itemCategoryUid: zod_1.z.number(),
itemCategoryId: zod_1.z.string(),
itemCategoryDesc: zod_1.z.string(),
displayOnWebFlag: zod_1.z.enum(['Y', 'N']),
deleteFlag: zod_1.z.enum(['Y', 'N']),
itemCount: zod_1.z.number(),
fullPath: zod_1.z.string().nullable(),
});
// Lookup response data with subcategories
exports.LookupCategoryWithSubsSchema = exports.LookupCategoryEntitySchema.extend({
subCategories: zod_1.z.array(exports.SubCategorySchema),
});
// Legacy category schema for backward compatibility
exports.CategorySchema = zod_1.z.lazy(() => zod_1.z.object({
itemCategoryUid: zod_1.z.number(),
itemCategoryDesc: zod_1.z.string(),
path: zod_1.z.string().optional(),
parentItemCategoryUid: zod_1.z.number().optional(),
level: zod_1.z.number().optional(),
children: zod_1.z.array(exports.CategorySchema).optional(),
attributes: zod_1.z.array(zod_1.z.unknown()).optional(),
images: zod_1.z.array(zod_1.z.unknown()).optional(),
itemCount: zod_1.z.number().optional(),
}));
// Parameter schemas for category endpoints
exports.CategoryListParamsSchema = zod_1.z.object({
limit: zod_1.z.coerce.number().int().positive().optional(),
offset: zod_1.z.coerce.number().int().min(0).optional(),
displayOnWebFlag: zod_1.z.enum(['Y', 'N']).optional(),
deleteFlag: zod_1.z.enum(['Y', 'N']).optional(),
masterCategoryFlag: zod_1.z.string().optional(),
parentCategoryFlag: zod_1.z.string().optional(),
orderBy: zod_1.z.string().optional(),
q: zod_1.z.string().optional(),
});
exports.CategoryLookupParamsSchema = zod_1.z.object({
itemCategoryUid: zod_1.z.coerce.number().optional(),
itemCategoryId: zod_1.z.string().optional(),
includeSubCategories: zod_1.z.boolean().optional(),
displayOnWebFlag: zod_1.z.enum(['Y', 'N']).optional(),
deleteFlag: zod_1.z.enum(['Y', 'N']).optional(),
});
exports.CategoryPreCacheParamsSchema = zod_1.z.object({
itemCategoryUid: zod_1.z.coerce.number(),
});
exports.CategoryDetailsParamsSchema = zod_1.z.object({
path: zod_1.z.string().optional(),
rootItemCategoryId: zod_1.z.string().optional(),
orderBy: zod_1.z.string().optional(),
classId5List: zod_1.z.string().optional(),
productCollection: zod_1.z.string().optional(),
filters: zod_1.z.string().optional(), // JSON string
childrenLimit: zod_1.z.coerce.number().int().positive().optional(),
childrenOffset: zod_1.z.coerce.number().int().min(0).optional(),
childrenFilter: zod_1.z.string().optional(),
});
exports.CategoryItemsParamsSchema = zod_1.z.object({
limit: zod_1.z.coerce.number().int().positive().optional(),
offset: zod_1.z.coerce.number().int().min(0).optional(),
sortBy: zod_1.z.string().optional(),
sortOrder: zod_1.z.enum(['asc', 'desc']).optional(),
filters: zod_1.z.string().optional(), // JSON string
fields: zod_1.z.string().optional(),
displayOnWebFlag: zod_1.z.string().optional(),
classId5List: zod_1.z.string().optional(),
classId5ExcludeList: zod_1.z.string().optional(),
tags: zod_1.z.string().optional(),
q: zod_1.z.string().optional(),
includeStock: zod_1.z.enum(['Y', 'N']).optional(),
cacheTtl: zod_1.z.coerce.number().int().min(7200).optional(), // Minimum 2 hours
});
exports.CategoryItemSchema = zod_1.z.object({
invMastUid: zod_1.z.number(),
itemId: zod_1.z.string(),
itemDesc: zod_1.z.string(),
listPrice: zod_1.z.number().optional(),
stdPrice: zod_1.z.number().optional(),
images: zod_1.z.array(zod_1.z.unknown()).optional(),
attributes: zod_1.z.array(zod_1.z.unknown()).optional(),
stock: zod_1.z
.object({
qtyOnHand: zod_1.z.number(),
qtyAvailable: zod_1.z.number(),
})
.optional(),
});
exports.CategoryAttributeSchema = zod_1.z.object({
attributeUid: zod_1.z.number(),
attributeId: zod_1.z.string(),
attributeDesc: zod_1.z.string(),
dataType: zod_1.z.string(),
values: zod_1.z.array(zod_1.z.string()).optional(),
});
exports.CategoryFilterSchema = zod_1.z.object({
attributeId: zod_1.z.string(),
attributeDesc: zod_1.z.string(),
filterType: zod_1.z.string(),
values: zod_1.z.array(zod_1.z.object({
value: zod_1.z.string(),
count: zod_1.z.number(),
})),
});
exports.CategoryImageSchema = zod_1.z.object({
imageUid: zod_1.z.number(),
imagePath: zod_1.z.string(),
imageType: zod_1.z.string(),
altText: zod_1.z.string().optional(),
});
// Response schemas using BaseResponseSchema (8-field format)
exports.CategoryResponseSchema = (0, schemas_1.BaseResponseSchema)(exports.CategorySchema);
exports.CategoryListResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.ItemCategoryEntitySchema));
exports.CategoryLookupResponseSchema = (0, schemas_1.BaseResponseSchema)(exports.LookupCategoryWithSubsSchema);
exports.CategoryPreCacheResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.boolean());
exports.CategoryItemsResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.CategoryItemSchema));
exports.CategoryAttributesResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.CategoryAttributeSchema));
exports.CategoryFiltersResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.CategoryFilterSchema));
exports.CategoryImagesResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.CategoryImageSchema));
//# sourceMappingURL=categories.js.map