@tewtawanc/loops-utils 1.0.0 → 1.0.2
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.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +11 -0
- package/dist/index.mjs +10 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -136,5 +136,23 @@ declare function isValidStockSku(sku: string): boolean;
|
|
|
136
136
|
* // Returns: "HD6600B H5490205B C/P 25kg Pallet"
|
|
137
137
|
*/
|
|
138
138
|
declare function generateInventoryName(params: InventorySkuParams): string;
|
|
139
|
+
/**
|
|
140
|
+
* Nullable params for SKU generation (used in validation/matching)
|
|
141
|
+
*/
|
|
142
|
+
interface NullableSkuParams {
|
|
143
|
+
grade?: string | null;
|
|
144
|
+
lotNumber?: string | null;
|
|
145
|
+
materialCode?: string | null;
|
|
146
|
+
netWeight?: number | null;
|
|
147
|
+
packageType?: string | null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Build SKU from nullable params (for validation/matching)
|
|
151
|
+
* Converts null/undefined to empty string and calls generateInventorySku
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* buildSkuFromParams({ grade: 'HD6600B', lotNumber: null, ... })
|
|
155
|
+
*/
|
|
156
|
+
declare function buildSkuFromParams(params: NullableSkuParams): string;
|
|
139
157
|
|
|
140
|
-
export { type InventorySkuParams, type StockSkuParams, extractInventorySku, formatWeight, generateInventoryName, generateInventorySku, generateStockSku, isValidInventorySku, isValidStockSku, normalizeSkuComponent, parseInventorySku, parseStockSku };
|
|
158
|
+
export { type InventorySkuParams, type NullableSkuParams, type StockSkuParams, buildSkuFromParams, extractInventorySku, formatWeight, generateInventoryName, generateInventorySku, generateStockSku, isValidInventorySku, isValidStockSku, normalizeSkuComponent, parseInventorySku, parseStockSku };
|
package/dist/index.d.ts
CHANGED
|
@@ -136,5 +136,23 @@ declare function isValidStockSku(sku: string): boolean;
|
|
|
136
136
|
* // Returns: "HD6600B H5490205B C/P 25kg Pallet"
|
|
137
137
|
*/
|
|
138
138
|
declare function generateInventoryName(params: InventorySkuParams): string;
|
|
139
|
+
/**
|
|
140
|
+
* Nullable params for SKU generation (used in validation/matching)
|
|
141
|
+
*/
|
|
142
|
+
interface NullableSkuParams {
|
|
143
|
+
grade?: string | null;
|
|
144
|
+
lotNumber?: string | null;
|
|
145
|
+
materialCode?: string | null;
|
|
146
|
+
netWeight?: number | null;
|
|
147
|
+
packageType?: string | null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Build SKU from nullable params (for validation/matching)
|
|
151
|
+
* Converts null/undefined to empty string and calls generateInventorySku
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* buildSkuFromParams({ grade: 'HD6600B', lotNumber: null, ... })
|
|
155
|
+
*/
|
|
156
|
+
declare function buildSkuFromParams(params: NullableSkuParams): string;
|
|
139
157
|
|
|
140
|
-
export { type InventorySkuParams, type StockSkuParams, extractInventorySku, formatWeight, generateInventoryName, generateInventorySku, generateStockSku, isValidInventorySku, isValidStockSku, normalizeSkuComponent, parseInventorySku, parseStockSku };
|
|
158
|
+
export { type InventorySkuParams, type NullableSkuParams, type StockSkuParams, buildSkuFromParams, extractInventorySku, formatWeight, generateInventoryName, generateInventorySku, generateStockSku, isValidInventorySku, isValidStockSku, normalizeSkuComponent, parseInventorySku, parseStockSku };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
buildSkuFromParams: () => buildSkuFromParams,
|
|
23
24
|
extractInventorySku: () => extractInventorySku,
|
|
24
25
|
formatWeight: () => formatWeight,
|
|
25
26
|
generateInventoryName: () => generateInventoryName,
|
|
@@ -109,8 +110,18 @@ function generateInventoryName(params) {
|
|
|
109
110
|
const capitalizedPackageType = packageType.toLowerCase().split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
110
111
|
return `${grade} ${lotNumber} ${materialCode} ${netWeight}kg ${capitalizedPackageType}`;
|
|
111
112
|
}
|
|
113
|
+
function buildSkuFromParams(params) {
|
|
114
|
+
return generateInventorySku({
|
|
115
|
+
grade: params.grade || "",
|
|
116
|
+
lotNumber: params.lotNumber || "",
|
|
117
|
+
materialCode: params.materialCode || "",
|
|
118
|
+
netWeight: params.netWeight ?? 0,
|
|
119
|
+
packageType: params.packageType || "PL"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
112
122
|
// Annotate the CommonJS export names for ESM import in node:
|
|
113
123
|
0 && (module.exports = {
|
|
124
|
+
buildSkuFromParams,
|
|
114
125
|
extractInventorySku,
|
|
115
126
|
formatWeight,
|
|
116
127
|
generateInventoryName,
|
package/dist/index.mjs
CHANGED
|
@@ -76,7 +76,17 @@ function generateInventoryName(params) {
|
|
|
76
76
|
const capitalizedPackageType = packageType.toLowerCase().split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
77
77
|
return `${grade} ${lotNumber} ${materialCode} ${netWeight}kg ${capitalizedPackageType}`;
|
|
78
78
|
}
|
|
79
|
+
function buildSkuFromParams(params) {
|
|
80
|
+
return generateInventorySku({
|
|
81
|
+
grade: params.grade || "",
|
|
82
|
+
lotNumber: params.lotNumber || "",
|
|
83
|
+
materialCode: params.materialCode || "",
|
|
84
|
+
netWeight: params.netWeight ?? 0,
|
|
85
|
+
packageType: params.packageType || "PL"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
79
88
|
export {
|
|
89
|
+
buildSkuFromParams,
|
|
80
90
|
extractInventorySku,
|
|
81
91
|
formatWeight,
|
|
82
92
|
generateInventoryName,
|