@forwardslashns/taskit-validation-messages 1.0.64 → 1.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/package.json CHANGED
@@ -1,14 +1,9 @@
1
1
  {
2
2
  "name": "@forwardslashns/taskit-validation-messages",
3
- "version": "1.0.64",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "commonjs",
7
- "scripts": {
8
- "build": "rimraf ./dist && tsc",
9
- "prepublishOnly": "npm run build",
10
- "format:fix": "prettier --write --ignore-path .gitignore ."
11
- },
12
7
  "engines": {
13
8
  "node": ">=22.0.0"
14
9
  },
@@ -31,5 +26,10 @@
31
26
  "bugs": {
32
27
  "url": "https://github.com/fws-solutions/taskit-validation-messages/issues"
33
28
  },
34
- "homepage": "https://github.com/fws-solutions/taskit-validation-messages#readme"
35
- }
29
+ "homepage": "https://github.com/fws-solutions/taskit-validation-messages#readme",
30
+ "scripts": {
31
+ "build": "rimraf ./dist && tsc",
32
+ "format:fix": "prettier --write --ignore-path .gitignore .",
33
+ "publish:token": "powershell -ExecutionPolicy Bypass -File ./publish.ps1"
34
+ }
35
+ }
package/publish.ps1 ADDED
@@ -0,0 +1,37 @@
1
+ # Load environment variables from .env file
2
+ if (Test-Path .env) {
3
+ Get-Content .env | ForEach-Object {
4
+ if ($_ -match '^([^=]+)=(.*)$') {
5
+ $key = $matches[1].Trim()
6
+ $value = $matches[2].Trim()
7
+ Set-Item -Path "env:$key" -Value $value
8
+ Write-Host "Loaded $key from .env"
9
+ }
10
+ }
11
+ } else {
12
+ Write-Host "Error: .env file not found. Copy .env.example to .env and add your NPM_TOKEN" -ForegroundColor Red
13
+ exit 1
14
+ }
15
+
16
+ # Verify NPM_TOKEN is set
17
+ if (-not $env:NPM_TOKEN) {
18
+ Write-Host "Error: NPM_TOKEN not set in .env file" -ForegroundColor Red
19
+ exit 1
20
+ }
21
+
22
+ Write-Host "NPM_TOKEN loaded (length: $($env:NPM_TOKEN.Length) chars)" -ForegroundColor Cyan
23
+
24
+ # Backup original .npmrc
25
+ Copy-Item .npmrc .npmrc.backup -Force
26
+
27
+ # Replace ${NPM_TOKEN} with actual token in .npmrc
28
+ $npmrcContent = Get-Content .npmrc -Raw
29
+ $npmrcContent = $npmrcContent -replace '\$\{NPM_TOKEN\}', $env:NPM_TOKEN
30
+ Set-Content .npmrc $npmrcContent
31
+
32
+ Write-Host "Publishing package from current branch..." -ForegroundColor Green
33
+ pnpm publish --no-git-checks
34
+
35
+ # Restore original .npmrc
36
+ Move-Item .npmrc.backup .npmrc -Force
37
+ Write-Host "Restored .npmrc" -ForegroundColor Cyan
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getValidationMessage } from './validation/validation-message.formatter';
1
+ import { getValidationMessage, ValidationMessageResult } from './validation/validation-message.formatter';
2
2
  import { VALIDATION_MESSAGES } from './validation/validation-messages';
3
3
 
4
- export { VALIDATION_MESSAGES, getValidationMessage };
4
+ export { VALIDATION_MESSAGES, getValidationMessage, ValidationMessageResult };
@@ -11,13 +11,19 @@ type MessageParams<T extends readonly string[]> = { [K in T[number]]: string };
11
11
  type MessageConfig = {
12
12
  message: string;
13
13
  params?: readonly string[];
14
+ affectedFields?: readonly string[];
15
+ };
16
+
17
+ export type ValidationMessageResult = {
18
+ content: string;
19
+ affectedFields: string[];
14
20
  };
15
21
 
16
22
  export const getValidationMessage = <FeatureType extends Features, FeatureErrorType extends ErrorType<FeatureType>>(
17
23
  feature: FeatureType,
18
24
  featureError: FeatureErrorType,
19
25
  params?: MessageParams<ErrorMessageParams<FeatureType, FeatureErrorType>>
20
- ): string => {
26
+ ): ValidationMessageResult => {
21
27
  const messageConfig = VALIDATION_MESSAGES[feature][featureError] as MessageConfig;
22
28
 
23
29
  if (!messageConfig) {
@@ -60,5 +66,8 @@ export const getValidationMessage = <FeatureType extends Features, FeatureErrorT
60
66
  message = message.replaceAll(`{${param}}`, (inputParams as Record<string, string>)[param]);
61
67
  });
62
68
 
63
- return message;
69
+ return {
70
+ content: message,
71
+ affectedFields: messageConfig.affectedFields ? [...messageConfig.affectedFields] : [],
72
+ };
64
73
  };