@carecard/validate 3.10.0 → 3.11.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.
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Purpose
@@ -85,7 +87,7 @@ config.
85
87
  - Never suppress errors, TypeScript errors, linter warnings, authorization
86
88
  failures, RLS failures, build failures, hydration issues, or failing tests.
87
89
  Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or
88
- similar suppression unless explicitly requested.
90
+ similar suppression. Fix the root cause.
89
91
  - Do not add dependencies unless clearly necessary. If one might be needed, ask
90
92
  first with the reason, tradeoff, and why existing code cannot solve it.
91
93
  - Before finalizing repository work, run the affected repository's relevant
@@ -215,7 +217,7 @@ build artifacts, logs, or `.DS_Store`.
215
217
  Most JavaScript `ms-*` services use CommonJS, Mocha, Supertest, Docker Compose
216
218
  database tests, `@carecard/*` packages, and `sub-apps`
217
219
  controller/router/model patterns. TypeScript services such as `ms-messages`
218
- and `ms-template-ts` use Jest or TypeScript tooling and should keep their
220
+ use Jest or TypeScript tooling and should keep their
219
221
  existing TypeScript style.
220
222
 
221
223
  - Keep environment-specific files explicit: `.env.development`, `.env.test`,
@@ -380,7 +382,7 @@ the authenticated dashboard.
380
382
 
381
383
  ## Auth Service RLS Contract
382
384
 
383
- - `ms-auth` follows the shared PostgreSQL/RLS pattern from `ms-template-js`: auth tables live in the `carecard` schema, RLS is enabled and forced on every auth table, and application runtime queries use the unprivileged database role.
385
+ - `ms-auth` follows the shared PostgreSQL/RLS pattern: auth tables live in the `carecard` schema, RLS is enabled and forced on every auth table, and application runtime queries use the unprivileged database role.
384
386
  - Auth table policies allow normal JWT users to access only self-owned rows. Do not add redundant `user_id = <jwt sub>` SQL predicates to duplicate self-row checks when RLS owns the authorization decision.
385
387
  - A JWT payload containing `roles: ["ad"]` is the auth-service super-admin signal and can perform any action on auth tables. Dashboard code may map that role to `super_admin`, but backend auth RLS must not require a separate database role row for that bypass.
386
388
  - Public auth flows such as registration, login, confirmation, recovery, visitor creation, and service user lookup must use narrow system contexts (`system_create`, `system_login`, `system_confirm`, `system_recovery`, `system_visitor`, `system_service`) instead of privileged runtime queries.
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Purpose
@@ -77,14 +79,20 @@ Do not continue automatically when:
77
79
  when `origin/development` is absent:
78
80
 
79
81
  ```sh
80
- if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then
81
- base="development"
82
- elif git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
83
- base="main"
84
- else
85
- echo "No origin/development or origin/main branch exists."
86
- exit 1
82
+ remote_base_refs="$(git ls-remote --heads origin development main)"
83
+ remote_query_status=$?
84
+ if [ "$remote_query_status" -ne 0 ]; then
85
+ printf 'Unable to inspect origin base branches (exit %s).\n' "$remote_query_status" >&2
86
+ exit "$remote_query_status"
87
87
  fi
88
+ case "$remote_base_refs" in
89
+ *"refs/heads/development") base="development" ;;
90
+ *"refs/heads/main") base="main" ;;
91
+ *)
92
+ printf '%s\n' "No origin/development or origin/main branch exists." >&2
93
+ exit 1
94
+ ;;
95
+ esac
88
96
  git fetch origin "$base" --prune
89
97
  ```
90
98
 
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Purpose
@@ -74,14 +76,20 @@ completion.
74
76
 
75
77
  ```sh
76
78
  gh auth status
77
- if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then
78
- base="development"
79
- elif git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then
80
- base="main"
81
- else
82
- echo "No origin/development or origin/main branch exists."
83
- exit 1
79
+ remote_base_refs="$(git ls-remote --heads origin development main)"
80
+ remote_query_status=$?
81
+ if [ "$remote_query_status" -ne 0 ]; then
82
+ printf 'Unable to inspect origin base branches (exit %s).\n' "$remote_query_status" >&2
83
+ exit "$remote_query_status"
84
84
  fi
85
+ case "$remote_base_refs" in
86
+ *"refs/heads/development") base="development" ;;
87
+ *"refs/heads/main") base="main" ;;
88
+ *)
89
+ printf '%s\n' "No origin/development or origin/main branch exists." >&2
90
+ exit 1
91
+ ;;
92
+ esac
85
93
  target_branch="$(git branch --show-current)"
86
94
  test -n "$target_branch"
87
95
  test "$target_branch" != "$base"
@@ -171,7 +179,19 @@ completion.
171
179
  not protected:
172
180
 
173
181
  ```sh
174
- protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected' 2>/dev/null || echo false)"
182
+ protected="$(gh api "repos/{owner}/{repo}/branches/$target_branch" --jq '.protected')"
183
+ protection_query_status=$?
184
+ if [ "$protection_query_status" -ne 0 ]; then
185
+ printf 'Unable to inspect branch protection (exit %s).\n' "$protection_query_status" >&2
186
+ exit "$protection_query_status"
187
+ fi
188
+ case "$protected" in
189
+ true|false) ;;
190
+ *)
191
+ printf 'Unexpected branch protection value: %s\n' "$protected" >&2
192
+ exit 1
193
+ ;;
194
+ esac
175
195
  if [ "$protected" = true ]; then
176
196
  gh pr merge "$pr_number" --squash --admin
177
197
  else
@@ -183,8 +203,16 @@ completion.
183
203
  delete it explicitly:
184
204
 
185
205
  ```sh
186
- if [ "$protected" != true ] && git ls-remote --exit-code --heads origin "$target_branch" >/dev/null 2>&1; then
187
- git push origin --delete "$target_branch"
206
+ if [ "$protected" != true ]; then
207
+ remote_target_ref="$(git ls-remote --heads origin "$target_branch")"
208
+ remote_query_status=$?
209
+ if [ "$remote_query_status" -ne 0 ]; then
210
+ printf 'Unable to inspect the remote target branch (exit %s).\n' "$remote_query_status" >&2
211
+ exit "$remote_query_status"
212
+ fi
213
+ if [ -n "$remote_target_ref" ]; then
214
+ git push origin --delete "$target_branch"
215
+ fi
188
216
  fi
189
217
  ```
190
218
 
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Scope
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Trigger
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Purpose
@@ -9,6 +9,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
9
9
 
10
10
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
11
11
 
12
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
13
+
12
14
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
13
15
 
14
16
  ## Purpose
package/.codex/AGENTS.md CHANGED
@@ -4,6 +4,8 @@ Non-negotiable code organization rule: Functions with the same or equivalent beh
4
4
 
5
5
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
6
6
 
7
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
8
+
7
9
  These instructions apply to the `pkg-validate` repository. This file is self-contained:
8
10
  it includes the workspace-level instructions that were previously read from
9
11
  `/Users/pankajpriscilla/SO_CareCardCa/.codex/AGENTS.md`, followed by
@@ -21,7 +23,7 @@ These instructions apply to the whole workspace. The workspace is a collection o
21
23
  - **Always follow the owner's naming conventions.** Use meaningful function, variable, file, test, and type names that match the surrounding code.
22
24
  - **Always follow the existing project structure.** Put code, tests, docs, services, validation, transforms, components, and helpers where the current repository already expects them.
23
25
  - **Always use Test-Driven Development.** Write or update focused tests first, verify they fail for the missing behavior when practical, then implement the code.
24
- - **Never suppress errors, TypeScript errors, linter warnings, or failing tests.** Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or other suppression unless the user explicitly requests it. Handle the issue properly.
26
+ - **Never suppress errors, TypeScript errors, linter warnings, or failing tests.** Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or other suppression. Fix the root cause.
25
27
  - **Do not add new dependencies unless they are clearly necessary.** If a dependency might be needed, stop and ask for confirmation first, with a clear reason, tradeoff, and why existing code cannot reasonably solve it.
26
28
  - **Before finalizing any response for a repository, run every script in that repository's `.husky` directory.** Do not bypass hooks. If a `.husky` script fails, fix the underlying issue and rerun it. If it cannot run because of environment constraints, report the exact script and reason.
27
29
 
@@ -102,7 +102,7 @@ jobs:
102
102
  --head "$HEAD" \
103
103
  --base "$BASE" \
104
104
  --json number \
105
- --jq '.[0].number' || true)
105
+ --jq '.[0].number')
106
106
 
107
107
  if [[ -n "${EXISTING:-}" ]]; then
108
108
  echo "An open PR already exists for $HEAD -> $BASE (#$EXISTING). Updating PR metadata."
@@ -165,7 +165,7 @@ jobs:
165
165
  exit 0
166
166
  fi
167
167
 
168
- if ! gh issue view "$TICKET_NUMBER" --repo "$REPO" --json number >/dev/null 2>&1; then
168
+ if ! gh issue view "$TICKET_NUMBER" --repo "$REPO" --json number; then
169
169
  echo "GitHub issue #$TICKET_NUMBER was not found. Skipping ticket assignment."
170
170
  exit 0
171
171
  fi
@@ -45,7 +45,8 @@ jobs:
45
45
  echo "package_name=${package_name}" >> "$GITHUB_OUTPUT"
46
46
  echo "package_version=${package_version}" >> "$GITHUB_OUTPUT"
47
47
 
48
- if npm view "${package_name}@${package_version}" version >/dev/null 2>&1; then
48
+ published_versions="$(npm view "${package_name}" versions --json)"
49
+ if node -e 'const value=JSON.parse(process.argv[1]); const versions=Array.isArray(value) ? value : [value]; process.exit(versions.includes(process.argv[2]) ? 0 : 1);' "$published_versions" "$package_version"; then
49
50
  echo "${package_name}@${package_version} is already published."
50
51
  echo "should_publish=false" >> "$GITHUB_OUTPUT"
51
52
  else
package/lib/validate.js CHANGED
@@ -15,7 +15,8 @@ const isValidJsonString = str => {
15
15
  try {
16
16
  const json = JSON.parse(str);
17
17
  return typeof json === 'object' && json !== null;
18
- } catch {
18
+ } catch (error) {
19
+ if (!(error instanceof SyntaxError)) throw error;
19
20
  return false;
20
21
  }
21
22
  };
@@ -229,12 +230,10 @@ const isValidDateString = str => {
229
230
 
230
231
  const isValidUrl = url => {
231
232
  if (typeof url !== 'string' || url.length === 0 || url.length > 2048) return false;
232
- try {
233
- const parsedUrl = new URL(url);
234
- return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
235
- } catch {
236
- return false;
237
- }
233
+ if (!URL.canParse(url)) return false;
234
+
235
+ const parsedUrl = new URL(url);
236
+ return parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:';
238
237
  };
239
238
  const isValidArrayOfStrings = arr => {
240
239
  if (!Array.isArray(arr)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/validate",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/CareCard-ca/pkg-validate.git"
@@ -38,7 +38,7 @@
38
38
  "typescript": "6.0.3"
39
39
  },
40
40
  "dependencies": {
41
- "@carecard/common-util": "3.10.0"
41
+ "@carecard/common-util": "3.11.0"
42
42
  },
43
43
  "nyc": {
44
44
  "all": true,
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "overrides": {
56
56
  "diff": "8.0.4",
57
+ "glob": "13.0.6",
57
58
  "serialize-javascript": "7.0.5",
58
59
  "js-yaml": "4.2.0"
59
60
  }
package/readme.md CHANGED
@@ -15,6 +15,8 @@ Non-negotiable TDD rule: Always write the failing test first, run it to confirm
15
15
 
16
16
  Non-negotiable repository isolation rule: Every repository must run its Husky hooks and tests using only files, code, fixtures, dependencies, and services contained within that repository. Tests and Husky scripts must not import, require, read, execute, or otherwise depend on sibling repositories or paths outside the repository root. app-e2e-tests is the only exception because cross-repository end-to-end testing is its explicit responsibility.
17
17
 
18
+ Non-negotiable error and warning rule: Never suppress, silence, hide, downgrade, filter, ignore, skip, or bypass errors or warnings from code, tests, tools, compilers, linters, or validation. Fix the root cause, then rerun the affected check and require a clean result. Expected error-path tests may assert errors, but must not conceal unexpected failures.
19
+
18
20
  Non-negotiable code organization rule: Functions with the same or equivalent behavior must use the same or clearly corresponding descriptive names across CareCard repositories, and equivalent functionality must live in files with the same names within each repository's established architecture. No backward compatibility names, aliases, or duplicate locations are allowed.
19
21
 
20
22
  ## Installation