@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
90 lines • 4.49 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductFindResponseSchema = exports.ProductResponseSchema = exports.ProductListResponseSchema = exports.EnableProductRequestSchema = exports.UpdateProductRequestSchema = exports.CreateProductRequestSchema = exports.ProductFindParamsSchema = exports.ProductListParamsSchema = exports.ProductFindItemSchema = exports.ProductSchema = exports.DistributorResponseSchema = exports.DistributorListResponseSchema = exports.EnableDistributorRequestSchema = exports.UpdateDistributorRequestSchema = exports.CreateDistributorRequestSchema = exports.DistributorListParamsSchema = exports.DistributorSchema = void 0;
const zod_1 = require("zod");
const schemas_1 = require("../../../core/schemas");
const common_1 = require("./common");
// Distributor schemas
exports.DistributorSchema = zod_1.z.object({
distributors_uid: zod_1.z.number(),
distributor_name: zod_1.z.string(),
distributor_desc: zod_1.z.string().optional(),
customer_id: zod_1.z.number(),
contact_email: zod_1.z.string().optional(),
contact_phone: zod_1.z.string().optional(),
status_cd: zod_1.z.number(),
create_cd: zod_1.z.string(),
update_cd: zod_1.z.string(),
});
exports.DistributorListParamsSchema = schemas_1.BaseGetParamsSchema.extend({
customerId: zod_1.z.number().optional(),
statusCd: zod_1.z.number().optional().default(704),
});
exports.CreateDistributorRequestSchema = zod_1.z.object({
distributor_name: zod_1.z.string().min(1, 'Distributor name is required'),
distributor_desc: zod_1.z.string().optional(),
customer_id: zod_1.z.number(),
contact_email: zod_1.z.string().optional(),
contact_phone: zod_1.z.string().optional(),
});
exports.UpdateDistributorRequestSchema = zod_1.z.object({
distributor_name: zod_1.z.string().optional(),
distributor_desc: zod_1.z.string().optional(),
contact_email: zod_1.z.string().optional(),
contact_phone: zod_1.z.string().optional(),
});
exports.EnableDistributorRequestSchema = zod_1.z.object({
status_cd: common_1.StatusCdSchema,
});
exports.DistributorListResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.DistributorSchema));
exports.DistributorResponseSchema = (0, schemas_1.BaseResponseSchema)(exports.DistributorSchema);
// Product schemas
exports.ProductSchema = zod_1.z.object({
products_uid: zod_1.z.number(),
product_id: zod_1.z.string(),
product_name: zod_1.z.string(),
product_desc: zod_1.z.string().optional(),
distributors_uid: zod_1.z.number(),
customer_id: zod_1.z.number(),
status_cd: zod_1.z.number(),
create_cd: zod_1.z.string(),
update_cd: zod_1.z.string(),
});
exports.ProductFindItemSchema = zod_1.z.object({
inv_mast_uid: zod_1.z.number(),
item_id: zod_1.z.string(),
description: zod_1.z.string(),
default_selling_unit: zod_1.z.string(),
type: zod_1.z.union([zod_1.z.literal('prophet21'), zod_1.z.literal('products')]),
});
exports.ProductListParamsSchema = schemas_1.BaseGetParamsSchema.extend({
customerId: zod_1.z.number().optional(),
distributorsUid: zod_1.z.number().optional(),
limit: zod_1.z.number().optional().default(10),
offset: zod_1.z.number().optional().default(0),
prefix: zod_1.z.string().optional(),
q: zod_1.z.string().optional(),
statusCd: zod_1.z.number().optional().default(704),
});
exports.ProductFindParamsSchema = schemas_1.BaseGetParamsSchema.extend({
customerId: zod_1.z.number().optional(),
prefix: zod_1.z.string().optional(),
});
exports.CreateProductRequestSchema = zod_1.z.object({
product_id: zod_1.z.string().min(1, 'Product ID is required'),
product_name: zod_1.z.string().min(1, 'Product name is required'),
product_desc: zod_1.z.string().optional(),
distributors_uid: zod_1.z.number(),
customer_id: zod_1.z.number(),
});
exports.UpdateProductRequestSchema = zod_1.z.object({
product_name: zod_1.z.string().optional(),
product_desc: zod_1.z.string().optional(),
});
exports.EnableProductRequestSchema = zod_1.z.object({
status_cd: common_1.StatusCdSchema,
});
exports.ProductListResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.ProductSchema));
exports.ProductResponseSchema = (0, schemas_1.BaseResponseSchema)(exports.ProductSchema);
exports.ProductFindResponseSchema = (0, schemas_1.BaseResponseSchema)(zod_1.z.array(exports.ProductFindItemSchema));
//# sourceMappingURL=products.js.map