storemw-core-api 1.0.75 → 1.0.77

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.
@@ -1,7 +1,7 @@
1
1
  import { user_props, Prisma } from "@prisma/client";
2
2
  import { DefaultOmitFields } from "../../lib";
3
3
  import { DefaultServiceProps } from "../../utils";
4
- declare const primaryKey = "user_props_id";
4
+ declare const primaryKey = "user_prop_id";
5
5
  export declare const ModelUserPropFields: {
6
6
  type: "type";
7
7
  createdatetime: "createdatetime";
@@ -12,7 +12,7 @@ export declare const ModelUserPropFields: {
12
12
  istrash: "istrash";
13
13
  accountid: "accountid";
14
14
  user_id: "user_id";
15
- user_props_id: "user_props_id";
15
+ user_prop_id: "user_prop_id";
16
16
  props_value: "props_value";
17
17
  props_id: "props_id";
18
18
  props_numeric: "props_numeric";
@@ -44,7 +44,7 @@ export type ModelUserPropListProps = {
44
44
  limit?: number;
45
45
  };
46
46
  export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
47
- primaryKey: "type" | "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "user_id" | "user_props_id" | "props_value" | "props_id" | "props_numeric" | "props_timestamp" | "props_integer";
47
+ primaryKey: "type" | "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "user_id" | "user_prop_id" | "props_value" | "props_id" | "props_numeric" | "props_timestamp" | "props_integer";
48
48
  getFields: (prefix?: string, excludeKeywords?: string[]) => Promise<{
49
49
  name: string;
50
50
  type: string;
@@ -61,7 +61,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
61
61
  istrash: boolean | null;
62
62
  accountid: bigint;
63
63
  user_id: bigint | null;
64
- user_props_id: bigint;
64
+ user_prop_id: bigint;
65
65
  props_value: string | null;
66
66
  props_id: bigint;
67
67
  props_numeric: Prisma.Decimal;
@@ -81,7 +81,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
81
81
  istrash: boolean | null;
82
82
  accountid: bigint;
83
83
  user_id: bigint | null;
84
- user_props_id: bigint;
84
+ user_prop_id: bigint;
85
85
  props_value: string | null;
86
86
  props_id: bigint;
87
87
  props_numeric: Prisma.Decimal;
@@ -102,7 +102,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
102
102
  istrash: boolean | null;
103
103
  accountid: bigint;
104
104
  user_id: bigint | null;
105
- user_props_id: bigint;
105
+ user_prop_id: bigint;
106
106
  props_value: string | null;
107
107
  props_id: bigint;
108
108
  props_numeric: Prisma.Decimal;
@@ -119,7 +119,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
119
119
  istrash: boolean | null;
120
120
  accountid: bigint;
121
121
  user_id: bigint | null;
122
- user_props_id: bigint;
122
+ user_prop_id: bigint;
123
123
  props_value: string | null;
124
124
  props_id: bigint;
125
125
  props_numeric: Prisma.Decimal;
@@ -130,7 +130,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
130
130
  where?: Record<string, any>;
131
131
  }) => Promise<number>;
132
132
  aggregate: ({ field, operation, where, }: {
133
- field: "type" | "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "user_id" | "user_props_id" | "props_value" | "props_id" | "props_numeric" | "props_timestamp" | "props_integer";
133
+ field: "type" | "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "user_id" | "user_prop_id" | "props_value" | "props_id" | "props_numeric" | "props_timestamp" | "props_integer";
134
134
  operation?: "sum" | "avg" | "min" | "max" | "count";
135
135
  where?: Record<string, any>;
136
136
  }) => Promise<number>;
@@ -147,7 +147,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
147
147
  istrash: boolean | null;
148
148
  accountid: bigint;
149
149
  user_id: bigint | null;
150
- user_props_id: bigint;
150
+ user_prop_id: bigint;
151
151
  props_value: string | null;
152
152
  props_id: bigint;
153
153
  props_numeric: Prisma.Decimal;
@@ -165,7 +165,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
165
165
  istrash: boolean | null;
166
166
  accountid: bigint;
167
167
  user_id: bigint | null;
168
- user_props_id: bigint;
168
+ user_prop_id: bigint;
169
169
  props_value: string | null;
170
170
  props_id: bigint;
171
171
  props_numeric: Prisma.Decimal;
@@ -185,7 +185,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
185
185
  istrash: boolean | null;
186
186
  accountid: bigint;
187
187
  user_id: bigint | null;
188
- user_props_id: bigint;
188
+ user_prop_id: bigint;
189
189
  props_value: string | null;
190
190
  props_id: bigint;
191
191
  props_numeric: Prisma.Decimal;
@@ -204,7 +204,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
204
204
  istrash: boolean | null;
205
205
  accountid: bigint;
206
206
  user_id: bigint | null;
207
- user_props_id: bigint;
207
+ user_prop_id: bigint;
208
208
  props_value: string | null;
209
209
  props_id: bigint;
210
210
  props_numeric: Prisma.Decimal;
@@ -223,7 +223,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
223
223
  istrash: boolean | null;
224
224
  accountid: bigint;
225
225
  user_id: bigint | null;
226
- user_props_id: bigint;
226
+ user_prop_id: bigint;
227
227
  props_value: string | null;
228
228
  props_id: bigint;
229
229
  props_numeric: Prisma.Decimal;
@@ -243,7 +243,7 @@ export declare const UserPropModel: ({ ...rest }: DefaultServiceProps) => {
243
243
  istrash: boolean | null;
244
244
  accountid: bigint;
245
245
  user_id: bigint | null;
246
- user_props_id: bigint;
246
+ user_prop_id: bigint;
247
247
  props_value: string | null;
248
248
  props_id: bigint;
249
249
  props_numeric: Prisma.Decimal;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserPropModel = exports.ModelUserPropFields = void 0;
4
4
  const lib_1 = require("../../lib");
5
- const primaryKey = "user_props_id";
5
+ const primaryKey = "user_prop_id";
6
6
  exports.ModelUserPropFields = (0, lib_1.getFieldsByType)();
7
7
  const UserPropModel = ({ ...rest }) => (0, lib_1.ModelFactory)({
8
8
  ...rest,
@@ -1 +1 @@
1
- {"version":3,"file":"UserPropModel.js","sourceRoot":"","sources":["../../../src/models/user/UserPropModel.ts"],"names":[],"mappings":";;;AACA,+BAAyE;AAGzE,MAAM,UAAU,GAAG,eAAe,CAAC;AAEtB,QAAA,mBAAmB,GAAG,IAAA,qBAAe,GAAc,CAAC;AAkC1D,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,IAAI,EAAuB,EAAE,EAAE,CAC9D,IAAA,kBAAY,EAAqE;IAC7E,GAAG,IAAI;IACP,SAAS,EAAE,YAAY;IACvB,UAAU;CACb,CAAC,CAAC;AALM,QAAA,aAAa,iBAKnB","sourcesContent":["import { PrismaClient, user_props, Prisma } from \"@prisma/client\";\nimport { ModelFactory, DefaultOmitFields, getFieldsByType } from \"@/lib\";\nimport { DefaultServiceProps } from \"@/utils\";\n\nconst primaryKey = \"user_props_id\";\n\nexport const ModelUserPropFields = getFieldsByType<user_props>();\n\nexport type ModelUserProp = user_props;\n\nexport type ModelUserPropOmitFields = typeof primaryKey | DefaultOmitFields;\n\nexport type ModelUserPropCreateProps = {\n data: Omit<Prisma.user_propsUncheckedCreateInput, ModelUserPropOmitFields>;\n};\n\nexport type ModelUserPropUpdateProps = {\n id: number;\n data: Omit<Prisma.user_propsUncheckedUpdateInput, ModelUserPropOmitFields>;\n};\n\nexport type ModelUserPropTrashProps = {\n ids: number[];\n};\n\nexport type ModelUserPropRemoveProps = {\n id: number;\n};\n\nexport type ModelUserPropGetProps = {\n id: number;\n};\n\nexport type ModelUserPropListProps = {\n where?: Prisma.user_propsWhereInput;\n orderBy?: Prisma.user_propsOrderByWithRelationInput | Prisma.user_propsOrderByWithRelationInput[];\n offset?: number;\n limit?: number;\n};\n\nexport const UserPropModel = ({ ...rest }: DefaultServiceProps) =>\n ModelFactory<PrismaClient, \"user_props\", PrismaClient[\"user_props\"], user_props>({\n ...rest,\n modelName: \"user_props\",\n primaryKey\n });\n"]}
1
+ {"version":3,"file":"UserPropModel.js","sourceRoot":"","sources":["../../../src/models/user/UserPropModel.ts"],"names":[],"mappings":";;;AACA,+BAAyE;AAGzE,MAAM,UAAU,GAAG,cAAc,CAAC;AAErB,QAAA,mBAAmB,GAAG,IAAA,qBAAe,GAAc,CAAC;AAkC1D,MAAM,aAAa,GAAG,CAAC,EAAE,GAAG,IAAI,EAAuB,EAAE,EAAE,CAC9D,IAAA,kBAAY,EAAqE;IAC7E,GAAG,IAAI;IACP,SAAS,EAAE,YAAY;IACvB,UAAU;CACb,CAAC,CAAC;AALM,QAAA,aAAa,iBAKnB","sourcesContent":["import { PrismaClient, user_props, Prisma } from \"@prisma/client\";\nimport { ModelFactory, DefaultOmitFields, getFieldsByType } from \"@/lib\";\nimport { DefaultServiceProps } from \"@/utils\";\n\nconst primaryKey = \"user_prop_id\";\n\nexport const ModelUserPropFields = getFieldsByType<user_props>();\n\nexport type ModelUserProp = user_props;\n\nexport type ModelUserPropOmitFields = typeof primaryKey | DefaultOmitFields;\n\nexport type ModelUserPropCreateProps = {\n data: Omit<Prisma.user_propsUncheckedCreateInput, ModelUserPropOmitFields>;\n};\n\nexport type ModelUserPropUpdateProps = {\n id: number;\n data: Omit<Prisma.user_propsUncheckedUpdateInput, ModelUserPropOmitFields>;\n};\n\nexport type ModelUserPropTrashProps = {\n ids: number[];\n};\n\nexport type ModelUserPropRemoveProps = {\n id: number;\n};\n\nexport type ModelUserPropGetProps = {\n id: number;\n};\n\nexport type ModelUserPropListProps = {\n where?: Prisma.user_propsWhereInput;\n orderBy?: Prisma.user_propsOrderByWithRelationInput | Prisma.user_propsOrderByWithRelationInput[];\n offset?: number;\n limit?: number;\n};\n\nexport const UserPropModel = ({ ...rest }: DefaultServiceProps) =>\n ModelFactory<PrismaClient, \"user_props\", PrismaClient[\"user_props\"], user_props>({\n ...rest,\n modelName: \"user_props\",\n primaryKey\n });\n"]}
@@ -59,7 +59,7 @@ let itemSqlSelect = {
59
59
  [`catg.${models_1.ModelCategoryFields.status}`]: "category_status",
60
60
  [`catg.${models_1.ModelCategoryFields.description}`]: "category_description",
61
61
  [`catg.${models_1.ModelCategoryFields.parent_category_id}`]: "parent_category_id",
62
- [`brd.${models_1.ModelBrandFields.name}`]: "brand_status",
62
+ [`brd.${models_1.ModelBrandFields.name}`]: "brand_name",
63
63
  [`brd.${models_1.ModelBrandFields.status}`]: "brand_status",
64
64
  [`brd.${models_1.ModelBrandFields.description}`]: "brand_description"
65
65
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ItemProductService.js","sourceRoot":"","sources":["../../../src/services/item/ItemProductService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCASkB;AAElB,yCAAmD;AAMnD,+BAAgK;AAInJ,QAAA,gBAAgB,GAAG;IAC5B,sBAAsB,EAAE,0BAA0B;IAClD,mBAAmB,EAAE,uBAAuB;IAC5C,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,cAAc;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACrB,CAAA;AAsDD,MAAM,gBAAgB,GAAG,CAAC,IAAoC,EAAE,EAAE;IAE9D,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QAEpB,OAAO;YACH,CAAC,GAAG,2BAAkB,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YACxD,CAAC,GAAG,2BAAkB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YAC9D,CAAC,GAAG,2BAAkB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;YAC/D,CAAC,GAAG,2BAAkB,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;YAChE,CAAC,GAAG,2BAAkB,CAAC,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,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1D,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,UAAU,EAA0B,EAAE,EAAE;QAEpE,IAAI,CAAC,UAAU,CAAC,MAAM;YAAE,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,2BAAkB,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAEpH,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC;IAC3C,CAAC,CAAA;IAED,OAAO;QACH,iBAAiB;QACjB,iBAAiB;QACjB,cAAc;QACd,gBAAgB;QAChB,cAAc;QACd,YAAY;KACf,CAAA;AAEL,CAAC,CAAA;AA3QY,QAAA,kBAAkB,sBA2Q9B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n ProductModel,\n ModelProductFields,\n ModelCategoryFields,\n ModelBrandFields,\n ModelUomFields,\n ModelItemFields,\n ModelFileFields,\n} from \"@/models\";\n\nimport { InjectionFieldService } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nexport type ItemType = \"product\"\n\nexport const productDataTypes = {\n productInjectionFields: \"product_injection_fields\",\n itemInjectionFields: \"item_injection_fields\",\n allCategory: \"all_category\",\n allSupplier: \"all_supplier\",\n file: \"file\",\n product: \"product\"\n}\n\nexport type ItemProductDataType = keyof typeof productDataTypes;\n\nexport type ItemProductServiceProps = DefaultServiceProps & {};\n\nexport type ItemProductGetProps = QueryGet & {\n id: number,\n datatypes: ItemProductDataType[]\n};\n\nexport type ItemProductListProps = QueryList & {\n datatypes: ItemProductDataType[]\n};\n\nexport type ItemProductRemoveProps = {\n productIds: BigInt[]\n};\n\nexport type ItemProductCreateProps = {\n data:\n // product\n {\n product: {\n brandId: number\n categoryId: number\n productName: string\n model: string\n productCode: string\n description: string\n summary: string\n status: Boolean\n }\n }\n}\n\nexport type ItemProductUpdateProps = {\n productId: number,\n data:\n // product\n {\n product: {\n brandId: number\n categoryId: number\n productName: string\n model: string\n productCode: string\n description: string\n summary: string\n status: Boolean\n }\n }\n}\n\nconst getCreatePayload = (data: ItemProductCreateProps[\"data\"]) => {\n\n if (\"product\" in data) {\n\n return {\n [`${ModelProductFields.brand_id}`]: data.product.brandId,\n [`${ModelProductFields.category_id}`]: data.product.categoryId,\n [`${ModelProductFields.description}`]: data.product.description,\n [`${ModelProductFields.product_name}`]: data.product.productName,\n [`${ModelProductFields.model}`]: data.product.model,\n [`${ModelProductFields.product_code}`]: data.product.productCode,\n [`${ModelProductFields.summary}`]: data.product.summary,\n [`${ModelProductFields.status}`]: data.product.status ? 1 : 0\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = (data: ItemProductUpdateProps[\"data\"]) => {\n\n if (\"product\" in data) {\n\n return {\n [`${ModelProductFields.brand_id}`]: data.product.brandId,\n [`${ModelProductFields.category_id}`]: data.product.categoryId,\n [`${ModelProductFields.description}`]: data.product.description,\n [`${ModelProductFields.product_name}`]: data.product.productName,\n [`${ModelProductFields.model}`]: data.product.model,\n [`${ModelProductFields.product_code}`]: data.product.productCode,\n [`${ModelProductFields.summary}`]: data.product.summary,\n [`${ModelProductFields.status}`]: data.product.status ? 1 : 0\n }\n }\n\n return false\n\n}\n\nlet mainSqlSelect = {\n [`prd.${ModelProductFields.product_id}`]: \"product_id\",\n [`prd.${ModelProductFields.brand_id}`]: \"brand_id\",\n [`prd.${ModelProductFields.category_id}`]: \"category_id\",\n [`prd.${ModelProductFields.description}`]: \"description\",\n [`prd.${ModelProductFields.product_name}`]: \"product_name\",\n [`prd.${ModelProductFields.model}`]: \"model\",\n [`prd.${ModelProductFields.product_code}`]: \"product_code\",\n [`prd.${ModelProductFields.status}`]: \"status\",\n [`prd.${ModelProductFields.summary}`]: \"summary\",\n}\n\nlet itemSqlSelect = {\n [`catg.${ModelCategoryFields.name}`]: \"category_name\",\n [`catg.${ModelCategoryFields.status}`]: \"category_status\",\n [`catg.${ModelCategoryFields.description}`]: \"category_description\",\n [`catg.${ModelCategoryFields.parent_category_id}`]: \"parent_category_id\",\n [`brd.${ModelBrandFields.name}`]: \"brand_status\",\n [`brd.${ModelBrandFields.status}`]: \"brand_status\",\n [`brd.${ModelBrandFields.description}`]: \"brand_description\"\n}\n\nconst getItemsSqlSelect = async (datatypes: any, injectionFieldService: any) => {\n\n let iif2Select = ``\n\n if (datatypes.includes(productDataTypes.itemInjectionFields)) {\n\n const currentActiveFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"item\")\n\n let bbb = currentActiveFields.map((col: any) => `'inf_${col}', iif2.${col}`).join(\", \")\n\n iif2Select = bbb.length > 0 ? `, ${bbb}` : ``\n\n }\n\n let itemsSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelItemFields.item_id}', itm.item_id,\n '${ModelItemFields.cbm}', itm.cbm,\n '${ModelItemFields.item_code}', itm.item_code,\n '${ModelItemFields.cost}', itm.cost,\n '${ModelItemFields.dimension_height}', itm.dimension_height::float,\n '${ModelItemFields.dimension_length}', itm.dimension_length::float,\n '${ModelItemFields.dimension_width}', itm.dimension_width::float,\n '${ModelItemFields.floor_price}', itm.floor_price::float,\n '${ModelItemFields.gross_weight}', itm.gross_weight::float,\n '${ModelItemFields.is_package}', itm.is_package,\n '${ModelItemFields.item_description}', itm.item_description,\n '${ModelItemFields.net_weight}', itm.net_weight::float,\n '${ModelItemFields.remark}', itm.remark,\n '${ModelItemFields.status}', itm.status,\n '${ModelItemFields.summary}', itm.summary,\n '${ModelItemFields.uom_id}', itm.uom_id,\n '${ModelItemFields.uom_price}', itm.uom_price::float,\n '${ModelItemFields.uom_bal}', itm.uom_bal::float,\n 'uom_description', uom.${ModelUomFields.description},\n 'uom_decimal_digit', uom.${ModelUomFields.decimal_digit}::float,\n 'uom_name', uom.${ModelUomFields.name},\n 'uom_status', uom.${ModelUomFields.status},\n 'uom_metric_type', uom.${ModelUomFields.metric_type},\n 'uom_metric_type_display_name', uom.${ModelUomFields.metric_type_display_name},\n '${ModelItemFields.volume_weight}', itm.volume_weight\n ${iif2Select}\n )\n ) FILTER (WHERE itm.item_id IS NOT NULL AND itm.isdelete = false AND itm.istrash = false),\n '[]'\n )`]: \"items\"\n }\n\n return itemsSqlSelect\n}\n\nlet defaultSqlSelect = {\n [`prd.${ModelProductFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`prd.${ModelProductFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`prd.${ModelProductFields.isdelete}`]: \"isdelete\",\n [`prd.${ModelProductFields.istrash}`]: \"istrash\",\n [`prd.${ModelProductFields.accountid}`]: \"accountid\",\n}\n\nexport const ItemProductService = (props: ItemProductServiceProps) => {\n\n const {\n // prisma,\n // accountId = 0,\n // actionUserId = 0\n ...rest\n } = props\n\n const injectionFieldService = InjectionFieldService({ ...rest, injectionFieldType: \"item\" })\n\n const productModel = ProductModel({ ...rest })\n\n const createItemProduct = async ({ data }: ItemProductCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create product payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await productModel.create({ data: _data })\n\n return response\n }\n\n const updateItemProduct = async ({ productId, data }: ItemProductUpdateProps) => {\n\n const _data = getUpdatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid update product payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await productModel.update({ where: { [`${ModelProductFields.product_id}`]: productId }, data: _data })\n\n return response\n }\n\n const getItemProduct = async ({ id, datatypes = [] }: ItemProductGetProps) => {\n\n let { data } = await listItemProducts({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelProductFields.product_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelProductFields.product_id}`,\n sortorder: \"ASC\",\n datatypes\n })\n\n return data[0] ?? null;\n\n };\n\n const listItemProducts = async ({\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = []\n }: ItemProductListProps) => {\n\n let itemsSqlSelect = await getItemsSqlSelect(datatypes, injectionFieldService)\n\n let data = []\n\n let sqlSelect = [\n `COUNT(prd.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, itemSqlSelect),\n buildSqlSelect(``, itemsSqlSelect),\n buildSqlSelect(``, defaultSqlSelect),\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"prd\", \"categories\", \"catg\", [\"prd.category_id = catg.category_id\", \"catg.isdelete = false\", \"catg.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"brands\", \"brd\", [\"prd.brand_id = brd.brand_id\", \"brd.isdelete = false\", \"brd.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"items\", \"itm\", [\"prd.product_id = itm.product_id\", \"itm.isdelete = false\", \"itm.istrash = false\"]),\n buildSqlRelation(\"left\", \"itm\", \"uoms\", \"uom\", [\"itm.uom_id = uom.uom_id\", \"uom.isdelete = false\", \"uom.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"users\", \"creator\", [\"prd.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"users\", \"updater\", [\"prd.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(itemSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...itemSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(productDataTypes.productInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"product\")\n\n const productInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"iif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...productInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, productInjectionFieldSqlSelect)]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"prd\", \"item_injection_fields\", \"iif\", [\"prd.product_id = iif.product_id\", \"iif.field_ref = 'item'\", \"iif.field_module = 'product'\", \"iif.isdelete = false\", \"iif.istrash = false\"])]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(productInjectionFieldSqlSelect)]\n }\n\n // if (datatypes.includes(productDataTypes.itemInjectionFields)) {\n\n // let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"item\")\n\n // const productItemInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"iif2\", activeInjectionFields)\n\n // filterColumns = { ...filterColumns, ...productItemInjectionFieldSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, productItemInjectionFieldSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"itm\", \"item_injection_fields\", \"iif2\", [\"itm.item_id = iif2.item_id\", \"iif2.field_ref = 'item'\", \"iif2.field_module = 'item'\", \"iif2.isdelete = false\", \"iif2.istrash = false\"])]\n // // sqlGroupBy = [...sqlGroupBy, ...Object.keys(itemInjectionFieldSqlSelect)]\n // }\n\n // if (datatypes.includes(productDataTypes.location)) {\n\n // let locationSqlSelect = {\n // [`COALESCE(\n // JSON_AGG(\n // DISTINCT JSONB_BUILD_OBJECT(\n // '${ModelLocationFields.location_id}', location.location_id,\n // '${ModelLocationFields.location_code}', location.location_code,\n // '${ModelLocationFields.location_name}', location.location_name,\n // '${ModelLocationFields.location_type}', location.location_type,\n // '${ModelLocationFields.address_1}', location.address_1,\n // '${ModelLocationFields.address_2}', location.address_2,\n // '${ModelLocationFields.area}', location.area,\n // '${ModelLocationFields.area_id}', location.area_id,\n // '${ModelLocationFields.country_id}', location.country_id,\n // '${ModelLocationFields.state_id}', location.state_id,\n // '${ModelLocationFields.postcode}', location.postcode,\n // '${ModelLocationFields.is_default}', location.is_default,\n // '${ModelLocationFields.person_contact}', location.person_contact,\n // '${ModelLocationFields.person_name}', location.person_contact,\n // '${ModelLocationFields.person_email}', location.person_email,\n // '${ModelLocationFields.isdelete}', location.isdelete,\n // '${ModelLocationFields.istrash}', location.istrash\n // )\n // ) FILTER (WHERE location.location_id IS NOT NULL AND location.isdelete = false AND location.istrash = false), \n // '[]'\n // )`]: \"locations\"\n // }\n\n // filterColumns = { ...filterColumns, ...locationSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, locationSqlSelect)]\n // // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"usrprop_location\", \"location\", \"brn\", [\"prd.user_id = brn.user_id\", \"brn.isdelete = false\", \"brn.istrash = false\"])]\n\n // }\n\n if (datatypes.includes(productDataTypes.file)) {\n\n let fileSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelFileFields.file_id}', files.file_id,\n '${ModelFileFields.asset_url}', files.asset_url,\n '${ModelFileFields.asset_path}', files.asset_path,\n '${ModelFileFields.batch_code}', files.batch_code,\n '${ModelFileFields.content_type}', files.content_type,\n '${ModelFileFields.description}', files.description,\n '${ModelFileFields.field_module}', files.field_module,\n '${ModelFileFields.field_ref}', files.field_ref,\n '${ModelFileFields.file_compress_format}', files.file_compress_format,\n '${ModelFileFields.file_label}', files.file_label,\n '${ModelFileFields.file_name}', files.file_name,\n '${ModelFileFields.file_size_bytes}', files.file_size_bytes,\n '${ModelFileFields.foldername_day}', files.foldername_day,\n '${ModelFileFields.foldername_month}', files.foldername_month,\n '${ModelFileFields.foldername_year}', files.foldername_year,\n '${ModelFileFields.input_file_name}', files.input_file_name,\n '${ModelFileFields.input_file_size_bytes}', files.input_file_size_bytes,\n '${ModelFileFields.input_type}', files.input_type,\n '${ModelFileFields.refer_id_1}', files.refer_id_1,\n '${ModelFileFields.refer_id_2}', files.refer_id_2,\n '${ModelFileFields.remark}', files.remark,\n '${ModelFileFields.storage_provider_name}', files.storage_provider_name,\n '${ModelFileFields.tag_name}', files.tag_name\n )\n ) FILTER (WHERE files.file_id IS NOT NULL AND files.isdelete = false AND files.istrash = false), \n '[]'\n )`]: \"files\"\n }\n\n // filterColumns = { ...filterColumns, ...fileSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, fileSqlSelect)]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"prd\", \"files\", \"files\", [\"prd.product_id = files.refer_id_1\", \"files.field_ref = 'item'\", \"files.field_module = 'product'\", \"files.isdelete = false\", \"files.istrash = false\"])]\n\n }\n\n // if (datatypes.includes(customerDataTypes.branchUserCount)) {\n\n // let branchUserCountSqlSelect = {\n // [`COUNT(DISTINCT brnusrcount.${ModelBranchUserFields.branch_user_id})::INT`]: \"branch_user_count\"\n // }\n\n // filterColumns = { ...filterColumns, ...branchUserCountSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, branchUserCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branch_users\", \"brnusrcount\", [\"prd.user_id = brnusrcount.user_id\", \"brnusrcount.isdelete = false\", \"brnusrcount.istrash = false\"])]\n\n // }\n\n let sqlWhere = [\n `prd.isdelete = false`,\n `prd.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"products\",\n mainAlias: \"prd\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n data = await productModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n\n };\n\n const removeProducts = async ({ productIds }: ItemProductRemoveProps) => {\n\n if (!productIds.length) throwError('productIds is required');\n\n const response = await productModel.remove({ where: { [`${ModelProductFields.product_id}`]: { in: productIds } } });\n\n return response\n };\n\n const getDataTypes = () => {\n return Object.values(productDataTypes);\n }\n\n return {\n createItemProduct,\n updateItemProduct,\n getItemProduct,\n listItemProducts,\n removeProducts,\n getDataTypes\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"ItemProductService.js","sourceRoot":"","sources":["../../../src/services/item/ItemProductService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCASkB;AAElB,yCAAmD;AAMnD,+BAAgK;AAInJ,QAAA,gBAAgB,GAAG;IAC5B,sBAAsB,EAAE,0BAA0B;IAClD,mBAAmB,EAAE,uBAAuB;IAC5C,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,cAAc;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACrB,CAAA;AAsDD,MAAM,gBAAgB,GAAG,CAAC,IAAoC,EAAE,EAAE;IAE9D,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QAEpB,OAAO;YACH,CAAC,GAAG,2BAAkB,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YACxD,CAAC,GAAG,2BAAkB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YAC9D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IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YACrD,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1D,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,UAAU,EAA0B,EAAE,EAAE;QAEpE,IAAI,CAAC,UAAU,CAAC,MAAM;YAAE,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,2BAAkB,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;QAEpH,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC;IAC3C,CAAC,CAAA;IAED,OAAO;QACH,iBAAiB;QACjB,iBAAiB;QACjB,cAAc;QACd,gBAAgB;QAChB,cAAc;QACd,YAAY;KACf,CAAA;AAEL,CAAC,CAAA;AA3QY,QAAA,kBAAkB,sBA2Q9B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n ProductModel,\n ModelProductFields,\n ModelCategoryFields,\n ModelBrandFields,\n ModelUomFields,\n ModelItemFields,\n ModelFileFields,\n} from \"@/models\";\n\nimport { InjectionFieldService } from \"@/services\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nexport type ItemType = \"product\"\n\nexport const productDataTypes = {\n productInjectionFields: \"product_injection_fields\",\n itemInjectionFields: \"item_injection_fields\",\n allCategory: \"all_category\",\n allSupplier: \"all_supplier\",\n file: \"file\",\n product: \"product\"\n}\n\nexport type ItemProductDataType = keyof typeof productDataTypes;\n\nexport type ItemProductServiceProps = DefaultServiceProps & {};\n\nexport type ItemProductGetProps = QueryGet & {\n id: number,\n datatypes: ItemProductDataType[]\n};\n\nexport type ItemProductListProps = QueryList & {\n datatypes: ItemProductDataType[]\n};\n\nexport type ItemProductRemoveProps = {\n productIds: BigInt[]\n};\n\nexport type ItemProductCreateProps = {\n data:\n // product\n {\n product: {\n brandId: number\n categoryId: number\n productName: string\n model: string\n productCode: string\n description: string\n summary: string\n status: Boolean\n }\n }\n}\n\nexport type ItemProductUpdateProps = {\n productId: number,\n data:\n // product\n {\n product: {\n brandId: number\n categoryId: number\n productName: string\n model: string\n productCode: string\n description: string\n summary: string\n status: Boolean\n }\n }\n}\n\nconst getCreatePayload = (data: ItemProductCreateProps[\"data\"]) => {\n\n if (\"product\" in data) {\n\n return {\n [`${ModelProductFields.brand_id}`]: data.product.brandId,\n [`${ModelProductFields.category_id}`]: data.product.categoryId,\n [`${ModelProductFields.description}`]: data.product.description,\n [`${ModelProductFields.product_name}`]: data.product.productName,\n [`${ModelProductFields.model}`]: data.product.model,\n [`${ModelProductFields.product_code}`]: data.product.productCode,\n [`${ModelProductFields.summary}`]: data.product.summary,\n [`${ModelProductFields.status}`]: data.product.status ? 1 : 0\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = (data: ItemProductUpdateProps[\"data\"]) => {\n\n if (\"product\" in data) {\n\n return {\n [`${ModelProductFields.brand_id}`]: data.product.brandId,\n [`${ModelProductFields.category_id}`]: data.product.categoryId,\n [`${ModelProductFields.description}`]: data.product.description,\n [`${ModelProductFields.product_name}`]: data.product.productName,\n [`${ModelProductFields.model}`]: data.product.model,\n [`${ModelProductFields.product_code}`]: data.product.productCode,\n [`${ModelProductFields.summary}`]: data.product.summary,\n [`${ModelProductFields.status}`]: data.product.status ? 1 : 0\n }\n }\n\n return false\n\n}\n\nlet mainSqlSelect = {\n [`prd.${ModelProductFields.product_id}`]: \"product_id\",\n [`prd.${ModelProductFields.brand_id}`]: \"brand_id\",\n [`prd.${ModelProductFields.category_id}`]: \"category_id\",\n [`prd.${ModelProductFields.description}`]: \"description\",\n [`prd.${ModelProductFields.product_name}`]: \"product_name\",\n [`prd.${ModelProductFields.model}`]: \"model\",\n [`prd.${ModelProductFields.product_code}`]: \"product_code\",\n [`prd.${ModelProductFields.status}`]: \"status\",\n [`prd.${ModelProductFields.summary}`]: \"summary\",\n}\n\nlet itemSqlSelect = {\n [`catg.${ModelCategoryFields.name}`]: \"category_name\",\n [`catg.${ModelCategoryFields.status}`]: \"category_status\",\n [`catg.${ModelCategoryFields.description}`]: \"category_description\",\n [`catg.${ModelCategoryFields.parent_category_id}`]: \"parent_category_id\",\n [`brd.${ModelBrandFields.name}`]: \"brand_name\",\n [`brd.${ModelBrandFields.status}`]: \"brand_status\",\n [`brd.${ModelBrandFields.description}`]: \"brand_description\"\n}\n\nconst getItemsSqlSelect = async (datatypes: any, injectionFieldService: any) => {\n\n let iif2Select = ``\n\n if (datatypes.includes(productDataTypes.itemInjectionFields)) {\n\n const currentActiveFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"item\")\n\n let bbb = currentActiveFields.map((col: any) => `'inf_${col}', iif2.${col}`).join(\", \")\n\n iif2Select = bbb.length > 0 ? `, ${bbb}` : ``\n\n }\n\n let itemsSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelItemFields.item_id}', itm.item_id,\n '${ModelItemFields.cbm}', itm.cbm,\n '${ModelItemFields.item_code}', itm.item_code,\n '${ModelItemFields.cost}', itm.cost,\n '${ModelItemFields.dimension_height}', itm.dimension_height::float,\n '${ModelItemFields.dimension_length}', itm.dimension_length::float,\n '${ModelItemFields.dimension_width}', itm.dimension_width::float,\n '${ModelItemFields.floor_price}', itm.floor_price::float,\n '${ModelItemFields.gross_weight}', itm.gross_weight::float,\n '${ModelItemFields.is_package}', itm.is_package,\n '${ModelItemFields.item_description}', itm.item_description,\n '${ModelItemFields.net_weight}', itm.net_weight::float,\n '${ModelItemFields.remark}', itm.remark,\n '${ModelItemFields.status}', itm.status,\n '${ModelItemFields.summary}', itm.summary,\n '${ModelItemFields.uom_id}', itm.uom_id,\n '${ModelItemFields.uom_price}', itm.uom_price::float,\n '${ModelItemFields.uom_bal}', itm.uom_bal::float,\n 'uom_description', uom.${ModelUomFields.description},\n 'uom_decimal_digit', uom.${ModelUomFields.decimal_digit}::float,\n 'uom_name', uom.${ModelUomFields.name},\n 'uom_status', uom.${ModelUomFields.status},\n 'uom_metric_type', uom.${ModelUomFields.metric_type},\n 'uom_metric_type_display_name', uom.${ModelUomFields.metric_type_display_name},\n '${ModelItemFields.volume_weight}', itm.volume_weight\n ${iif2Select}\n )\n ) FILTER (WHERE itm.item_id IS NOT NULL AND itm.isdelete = false AND itm.istrash = false),\n '[]'\n )`]: \"items\"\n }\n\n return itemsSqlSelect\n}\n\nlet defaultSqlSelect = {\n [`prd.${ModelProductFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`prd.${ModelProductFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`prd.${ModelProductFields.isdelete}`]: \"isdelete\",\n [`prd.${ModelProductFields.istrash}`]: \"istrash\",\n [`prd.${ModelProductFields.accountid}`]: \"accountid\",\n}\n\nexport const ItemProductService = (props: ItemProductServiceProps) => {\n\n const {\n // prisma,\n // accountId = 0,\n // actionUserId = 0\n ...rest\n } = props\n\n const injectionFieldService = InjectionFieldService({ ...rest, injectionFieldType: \"item\" })\n\n const productModel = ProductModel({ ...rest })\n\n const createItemProduct = async ({ data }: ItemProductCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create product payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await productModel.create({ data: _data })\n\n return response\n }\n\n const updateItemProduct = async ({ productId, data }: ItemProductUpdateProps) => {\n\n const _data = getUpdatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid update product payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await productModel.update({ where: { [`${ModelProductFields.product_id}`]: productId }, data: _data })\n\n return response\n }\n\n const getItemProduct = async ({ id, datatypes = [] }: ItemProductGetProps) => {\n\n let { data } = await listItemProducts({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelProductFields.product_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelProductFields.product_id}`,\n sortorder: \"ASC\",\n datatypes\n })\n\n return data[0] ?? null;\n\n };\n\n const listItemProducts = async ({\n limit,\n offset,\n filters,\n sortfield,\n sortorder,\n datatypes = []\n }: ItemProductListProps) => {\n\n let itemsSqlSelect = await getItemsSqlSelect(datatypes, injectionFieldService)\n\n let data = []\n\n let sqlSelect = [\n `COUNT(prd.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, itemSqlSelect),\n buildSqlSelect(``, itemsSqlSelect),\n buildSqlSelect(``, defaultSqlSelect),\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"prd\", \"categories\", \"catg\", [\"prd.category_id = catg.category_id\", \"catg.isdelete = false\", \"catg.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"brands\", \"brd\", [\"prd.brand_id = brd.brand_id\", \"brd.isdelete = false\", \"brd.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"items\", \"itm\", [\"prd.product_id = itm.product_id\", \"itm.isdelete = false\", \"itm.istrash = false\"]),\n buildSqlRelation(\"left\", \"itm\", \"uoms\", \"uom\", [\"itm.uom_id = uom.uom_id\", \"uom.isdelete = false\", \"uom.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"users\", \"creator\", [\"prd.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"prd\", \"users\", \"updater\", [\"prd.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(itemSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...itemSqlSelect,\n ...defaultSqlSelect\n }\n\n if (datatypes.includes(productDataTypes.productInjectionFields)) {\n\n let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"product\")\n\n const productInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"iif\", activeInjectionFields)\n\n filterColumns = { ...filterColumns, ...productInjectionFieldSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, productInjectionFieldSqlSelect)]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"prd\", \"item_injection_fields\", \"iif\", [\"prd.product_id = iif.product_id\", \"iif.field_ref = 'item'\", \"iif.field_module = 'product'\", \"iif.isdelete = false\", \"iif.istrash = false\"])]\n sqlGroupBy = [...sqlGroupBy, ...Object.keys(productInjectionFieldSqlSelect)]\n }\n\n // if (datatypes.includes(productDataTypes.itemInjectionFields)) {\n\n // let activeInjectionFields = await injectionFieldService.listActiveInjectionFields(\"item\", \"item\")\n\n // const productItemInjectionFieldSqlSelect = buildInjectionFieldsSqlSelect(\"iif2\", activeInjectionFields)\n\n // filterColumns = { ...filterColumns, ...productItemInjectionFieldSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, productItemInjectionFieldSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"itm\", \"item_injection_fields\", \"iif2\", [\"itm.item_id = iif2.item_id\", \"iif2.field_ref = 'item'\", \"iif2.field_module = 'item'\", \"iif2.isdelete = false\", \"iif2.istrash = false\"])]\n // // sqlGroupBy = [...sqlGroupBy, ...Object.keys(itemInjectionFieldSqlSelect)]\n // }\n\n // if (datatypes.includes(productDataTypes.location)) {\n\n // let locationSqlSelect = {\n // [`COALESCE(\n // JSON_AGG(\n // DISTINCT JSONB_BUILD_OBJECT(\n // '${ModelLocationFields.location_id}', location.location_id,\n // '${ModelLocationFields.location_code}', location.location_code,\n // '${ModelLocationFields.location_name}', location.location_name,\n // '${ModelLocationFields.location_type}', location.location_type,\n // '${ModelLocationFields.address_1}', location.address_1,\n // '${ModelLocationFields.address_2}', location.address_2,\n // '${ModelLocationFields.area}', location.area,\n // '${ModelLocationFields.area_id}', location.area_id,\n // '${ModelLocationFields.country_id}', location.country_id,\n // '${ModelLocationFields.state_id}', location.state_id,\n // '${ModelLocationFields.postcode}', location.postcode,\n // '${ModelLocationFields.is_default}', location.is_default,\n // '${ModelLocationFields.person_contact}', location.person_contact,\n // '${ModelLocationFields.person_name}', location.person_contact,\n // '${ModelLocationFields.person_email}', location.person_email,\n // '${ModelLocationFields.isdelete}', location.isdelete,\n // '${ModelLocationFields.istrash}', location.istrash\n // )\n // ) FILTER (WHERE location.location_id IS NOT NULL AND location.isdelete = false AND location.istrash = false), \n // '[]'\n // )`]: \"locations\"\n // }\n\n // filterColumns = { ...filterColumns, ...locationSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, locationSqlSelect)]\n // // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"usrprop_location\", \"location\", \"brn\", [\"prd.user_id = brn.user_id\", \"brn.isdelete = false\", \"brn.istrash = false\"])]\n\n // }\n\n if (datatypes.includes(productDataTypes.file)) {\n\n let fileSqlSelect = {\n [`COALESCE(\n JSON_AGG(\n DISTINCT JSONB_BUILD_OBJECT(\n '${ModelFileFields.file_id}', files.file_id,\n '${ModelFileFields.asset_url}', files.asset_url,\n '${ModelFileFields.asset_path}', files.asset_path,\n '${ModelFileFields.batch_code}', files.batch_code,\n '${ModelFileFields.content_type}', files.content_type,\n '${ModelFileFields.description}', files.description,\n '${ModelFileFields.field_module}', files.field_module,\n '${ModelFileFields.field_ref}', files.field_ref,\n '${ModelFileFields.file_compress_format}', files.file_compress_format,\n '${ModelFileFields.file_label}', files.file_label,\n '${ModelFileFields.file_name}', files.file_name,\n '${ModelFileFields.file_size_bytes}', files.file_size_bytes,\n '${ModelFileFields.foldername_day}', files.foldername_day,\n '${ModelFileFields.foldername_month}', files.foldername_month,\n '${ModelFileFields.foldername_year}', files.foldername_year,\n '${ModelFileFields.input_file_name}', files.input_file_name,\n '${ModelFileFields.input_file_size_bytes}', files.input_file_size_bytes,\n '${ModelFileFields.input_type}', files.input_type,\n '${ModelFileFields.refer_id_1}', files.refer_id_1,\n '${ModelFileFields.refer_id_2}', files.refer_id_2,\n '${ModelFileFields.remark}', files.remark,\n '${ModelFileFields.storage_provider_name}', files.storage_provider_name,\n '${ModelFileFields.tag_name}', files.tag_name\n )\n ) FILTER (WHERE files.file_id IS NOT NULL AND files.isdelete = false AND files.istrash = false), \n '[]'\n )`]: \"files\"\n }\n\n // filterColumns = { ...filterColumns, ...fileSqlSelect }\n\n sqlSelect = [...sqlSelect, buildSqlSelect(``, fileSqlSelect)]\n sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"prd\", \"files\", \"files\", [\"prd.product_id = files.refer_id_1\", \"files.field_ref = 'item'\", \"files.field_module = 'product'\", \"files.isdelete = false\", \"files.istrash = false\"])]\n\n }\n\n // if (datatypes.includes(customerDataTypes.branchUserCount)) {\n\n // let branchUserCountSqlSelect = {\n // [`COUNT(DISTINCT brnusrcount.${ModelBranchUserFields.branch_user_id})::INT`]: \"branch_user_count\"\n // }\n\n // filterColumns = { ...filterColumns, ...branchUserCountSqlSelect }\n\n // sqlSelect = [...sqlSelect, buildSqlSelect(``, branchUserCountSqlSelect)]\n // sqlRelation = [...sqlRelation, buildSqlRelation(\"left\", \"cus\", \"branch_users\", \"brnusrcount\", [\"prd.user_id = brnusrcount.user_id\", \"brnusrcount.isdelete = false\", \"brnusrcount.istrash = false\"])]\n\n // }\n\n let sqlWhere = [\n `prd.isdelete = false`,\n `prd.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"products\",\n mainAlias: \"prd\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n data = await productModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n\n };\n\n const removeProducts = async ({ productIds }: ItemProductRemoveProps) => {\n\n if (!productIds.length) throwError('productIds is required');\n\n const response = await productModel.remove({ where: { [`${ModelProductFields.product_id}`]: { in: productIds } } });\n\n return response\n };\n\n const getDataTypes = () => {\n return Object.values(productDataTypes);\n }\n\n return {\n createItemProduct,\n updateItemProduct,\n getItemProduct,\n listItemProducts,\n removeProducts,\n getDataTypes\n }\n\n}\n\n"]}
@@ -30,7 +30,7 @@ export declare const UserPropService: (props: UserPropServiceProps) => {
30
30
  istrash: boolean | null;
31
31
  accountid: bigint;
32
32
  user_id: bigint | null;
33
- user_props_id: bigint;
33
+ user_prop_id: bigint;
34
34
  props_value: string | null;
35
35
  props_id: bigint;
36
36
  props_numeric: Prisma.Decimal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.75",
3
+ "version": "1.0.77",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",
@@ -288,7 +288,7 @@ model locations {
288
288
  }
289
289
 
290
290
  model user_props {
291
- user_props_id BigInt @id(map: "cl_user_props_pkey") @default(autoincrement())
291
+ user_prop_id BigInt @id(map: "cl_user_props_pkey") @default(autoincrement())
292
292
  user_id BigInt?
293
293
  type String? @db.VarChar(256)
294
294
  props_value String? @db.VarChar(256)