@carecard/validate 3.1.21 → 3.1.22

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.
@@ -36,6 +36,7 @@ on:
36
36
 
37
37
  permissions:
38
38
  contents: read
39
+ issues: write
39
40
  pull-requests: write
40
41
 
41
42
  jobs:
@@ -84,6 +85,8 @@ jobs:
84
85
  HEAD: ${{ steps.target.outputs.head }}
85
86
  BASE: ${{ steps.target.outputs.base }}
86
87
  REPO: ${{ github.repository }}
88
+ PR_ASSIGNEE: ${{ github.actor }}
89
+ PR_REVIEWER: singh-pankaj-k
87
90
  run: |
88
91
  set -euo pipefail
89
92
 
@@ -98,17 +101,73 @@ jobs:
98
101
  --jq '.[0].number' || true)
99
102
 
100
103
  if [[ -n "${EXISTING:-}" ]]; then
101
- echo "An open PR already exists for $HEAD -> $BASE (#$EXISTING). Nothing to do."
102
- exit 0
104
+ echo "An open PR already exists for $HEAD -> $BASE (#$EXISTING). Updating PR metadata."
105
+ PR_NUMBER="$EXISTING"
106
+ else
107
+ TITLE="Draft: merge \`$HEAD\` into \`$BASE\`"
108
+ BODY=$'Auto-created draft PR for branch `'"$HEAD"$'`.\n\nTarget base: `'"$BASE"$'`\n\nMark this PR as ready for review when you want it to be reviewed/merged.'
109
+
110
+ gh pr create \
111
+ --repo "$REPO" \
112
+ --draft \
113
+ --base "$BASE" \
114
+ --head "$HEAD" \
115
+ --title "$TITLE" \
116
+ --body "$BODY"
117
+
118
+ PR_NUMBER=$(gh pr list \
119
+ --repo "$REPO" \
120
+ --state open \
121
+ --head "$HEAD" \
122
+ --base "$BASE" \
123
+ --json number \
124
+ --jq '.[0].number')
103
125
  fi
104
126
 
105
- TITLE="Draft: merge \`$HEAD\` into \`$BASE\`"
106
- BODY=$'Auto-created draft PR for branch `'"$HEAD"$'`.\n\nTarget base: `'"$BASE"$'`\n\nMark this PR as ready for review when you want it to be reviewed/merged.'
127
+ gh pr edit "$PR_NUMBER" \
128
+ --repo "$REPO" \
129
+ --add-assignee "$PR_ASSIGNEE"
107
130
 
108
- gh pr create \
131
+ PR_AUTHOR=$(gh pr view "$PR_NUMBER" \
109
132
  --repo "$REPO" \
110
- --draft \
111
- --base "$BASE" \
112
- --head "$HEAD" \
113
- --title "$TITLE" \
114
- --body "$BODY"
133
+ --json author \
134
+ --jq '.author.login')
135
+
136
+ if [[ "$PR_AUTHOR" == "$PR_REVIEWER" ]]; then
137
+ echo "Skipping reviewer request because $PR_REVIEWER is the PR author."
138
+ else
139
+ gh pr edit "$PR_NUMBER" \
140
+ --repo "$REPO" \
141
+ --add-reviewer "$PR_REVIEWER"
142
+ fi
143
+
144
+ - name: Assign matching issue ticket (best effort)
145
+ if: steps.target.outputs.skip == 'false'
146
+ env:
147
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148
+ HEAD: ${{ steps.target.outputs.head }}
149
+ REPO: ${{ github.repository }}
150
+ PR_ASSIGNEE: ${{ github.actor }}
151
+ run: |
152
+ set -euo pipefail
153
+
154
+ TICKET_NUMBER=""
155
+ if [[ "$HEAD" =~ (^|/)(iss|issue|issues)[/-]?#?([0-9]+)([^0-9]|$) ]]; then
156
+ TICKET_NUMBER="${BASH_REMATCH[3]}"
157
+ fi
158
+
159
+ if [[ -z "$TICKET_NUMBER" ]]; then
160
+ echo "No GitHub issue ticket number found in branch '$HEAD'. Skipping ticket assignment."
161
+ exit 0
162
+ fi
163
+
164
+ if ! gh issue view "$TICKET_NUMBER" --repo "$REPO" --json number >/dev/null 2>&1; then
165
+ echo "GitHub issue #$TICKET_NUMBER was not found. Skipping ticket assignment."
166
+ exit 0
167
+ fi
168
+
169
+ if gh issue edit "$TICKET_NUMBER" --repo "$REPO" --add-assignee "$PR_ASSIGNEE"; then
170
+ echo "Assigned issue ticket #$TICKET_NUMBER to $PR_ASSIGNEE."
171
+ else
172
+ echo "::warning::Could not assign issue ticket #$TICKET_NUMBER to $PR_ASSIGNEE."
173
+ fi
package/index.d.ts CHANGED
@@ -70,6 +70,8 @@ export function isValidIntegerString(str: any): boolean;
70
70
  export function isValidUuidString(str: any): boolean;
71
71
  /** Checks if the string contains only alphanumeric characters, spaces, underscores, or hyphens. */
72
72
  export function isCharactersString(str: any): boolean;
73
+ /** Checks if the string is a valid street address format. */
74
+ export function isStreetString(str: any): boolean;
73
75
  /** Checks if the string is a valid name format. */
74
76
  export function isNameString(str: any): boolean;
75
77
  /** Checks if the string is safe for search queries. */
@@ -131,6 +133,7 @@ export const validate: {
131
133
  isValidIntegerString: typeof isValidIntegerString;
132
134
  isValidUuidString: typeof isValidUuidString;
133
135
  isCharactersString: typeof isCharactersString;
136
+ isStreetString: typeof isStreetString;
134
137
  isNameString: typeof isNameString;
135
138
  isSafeSearchString: typeof isSafeSearchString;
136
139
  isEmailString: typeof isEmailString;
package/lib/validate.js CHANGED
@@ -36,6 +36,15 @@ const isCharactersString = str => {
36
36
  return /^[\da-zA-Z _-]+$/.test(str);
37
37
  };
38
38
 
39
+ const isStreetString = str => {
40
+ if (typeof str !== 'string' || str.trim().length === 0 || str.length > 1000) {
41
+ return false;
42
+ }
43
+ const value = str.trim();
44
+ const streetRegex = /^(?![,_-])[0-9a-zA-Z\s,./#-]+$/;
45
+ return streetRegex.test(value);
46
+ };
47
+
39
48
  const isNameString = str => {
40
49
  if (typeof str !== 'string' || str.length === 0 || str.length > 1000) {
41
50
  return false;
@@ -204,6 +213,7 @@ module.exports = {
204
213
  isValidIntegerString,
205
214
  isValidUuidString,
206
215
  isCharactersString,
216
+ isStreetString,
207
217
  isNameString,
208
218
  isSafeSearchString,
209
219
  isEmailString,
@@ -19,6 +19,7 @@ const {
19
19
  isBoolValue,
20
20
  isValidUrl,
21
21
  isValidArrayOfStrings,
22
+ isStreetString,
22
23
  } = require('./validate');
23
24
 
24
25
  function validateProperties(obj = {}) {
@@ -62,7 +63,6 @@ function validateProperties(obj = {}) {
62
63
  case 'entityType':
63
64
  case 'action_type':
64
65
  case 'actionType':
65
- case 'street':
66
66
  case 'city':
67
67
  case 'state':
68
68
  case 'country':
@@ -71,6 +71,11 @@ function validateProperties(obj = {}) {
71
71
  returnObj[key] = value;
72
72
  }
73
73
  break;
74
+ case 'street':
75
+ if (isStreetString(value)) {
76
+ returnObj[key] = value;
77
+ }
78
+ break;
74
79
  case 'postal_code':
75
80
  case 'postalCode':
76
81
  if (isCharactersString(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/validate",
3
- "version": "3.1.21",
3
+ "version": "3.1.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/CareCard-ca/pkg-validate.git"
package/readme.md CHANGED
@@ -42,6 +42,7 @@ a string on failure and `null` on success.
42
42
  | `isValidIntegerString(value)` | Digit-only string, 1 to 20 chars. No signs or decimals. |
43
43
  | `isValidUuidString(value)` | Canonical UUID string in `8-4-4-4-12` format, case-insensitive. |
44
44
  | `isCharactersString(value)` | 1 to 1000 chars containing letters, numbers, spaces, `_`, or `-`. |
45
+ | `isStreetString(value)` | Non-empty street-like string up to 1000 chars using letters, numbers, spaces, `,`, `.`, `/`, `#`, or `-`, and not starting with `,`, `_`, or `-`. |
45
46
  | `isNameString(value)` | 1 to 1000 char string that starts with a letter and uses letters, numbers, spaces, `_`, `-`, `.`, `,`, `'`, `(`, or `)`. Leading/trailing spaces are trimmed before pattern validation. |
46
47
  | `isSafeSearchString(value)` | Trimmed string that starts with a letter and then uses letters, numbers, spaces, `_`, `-`, `.`, `,`, `'`, `(`, `)`, or `@`. |
47
48
  | `isEmailString(value)` | Email-like string up to 320 chars using the package email regex. |
@@ -94,25 +95,26 @@ validateProperties(input);
94
95
  Keys are matched exactly. Both snake_case and camelCase variants are listed
95
96
  where the package supports both.
96
97
 
97
- | Validator | Keys |
98
- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
- | `isNameString` | `first_name`, `firstName`, `last_name`, `lastName`, `username`, `new_status`, `newStatus`, `description`, `comment`, `status`, `name`, `title`, `brand`, `short_description`, `shortDescription`, `college_name`, `collegeName`, `campus_name`, `campusName`, `role`, `role_id`, `roleId`, `campus`, `institution_name`, `institutionName`, `program_name`, `programName`, `role_name`, `roleName`, `document_type`, `documentType`, `reason`, `street`, `city`, `state`, `country`, `type` |
100
- | `isCharactersString` | `postal_code`, `postalCode`, `period` |
101
- | `isBoolValue` | `is_primary`, `isPrimary`, `active` |
102
- | `isSafeSearchString` | `search_string`, `searchString` |
103
- | `isString6To16CharacterLong` and `isSimplePasswordString` | `password`, `new_password`, `newPassword` |
104
- | `isString6To16CharacterLong` and `isPasswordString` | `strong_password`, `strongPassword` |
105
- | `isEmailString` | `email` |
106
- | `isPhoneNumber` | `phone_number`, `phoneNumber` |
107
- | `isUrlSafeString` | `token`, `email_confirm_token`, `emailConfirmToken`, `verification_token`, `verificationToken` |
108
- | `isValidUuidString` | `uuid`, `item_id`, `itemId`, `user_id`, `userId`, `address_id`, `addressId`, `image_id`, `imageId`, `order_id`, `orderId`, `category_id`, `categoryId`, `parent_id`, `parentId`, `college_id`, `collegeId`, `campus_id`, `campusId`, `program_id`, `programId`, `id`, `institution_id`, `institutionId`, `role_assignment_id`, `roleAssignmentId`, `user_role_id`, `userRoleId`, `phone_number_id`, `phoneNumberId` |
109
- | `isValidIntegerString` | `offset_number`, `offsetNumber`, `number_of_orders`, `numberOfOrders`, `price`, `from`, `number` |
110
- | `isValidJsonString` on the raw value | `about` |
111
- | `isValidJsonString(JSON.stringify(value))` | `weight`, `dimensions`, `permission`, `scope_data`, `scopeData`, `meta_data`, `metaData` |
112
- | `isValidArrayOfStrings` | `aliases` |
113
- | `isImageUrl` or `isValidUrl` | `image_url`, `imageUrl`, `website`, `file_url`, `fileUrl` |
114
- | `isValidDomainName` | `domain_name`, `domainName`, `domain`, `email_domain`, `emailDomain`, `email_domain_name`, `emailDomainName` |
115
- | `isValidTimestampzString` or `isValidTimestampString` | `expires_at`, `expiresAt` |
98
+ | Validator | Keys |
99
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
+ | `isNameString` | `first_name`, `firstName`, `last_name`, `lastName`, `username`, `new_status`, `newStatus`, `description`, `comment`, `status`, `name`, `title`, `brand`, `short_description`, `shortDescription`, `college_name`, `collegeName`, `campus_name`, `campusName`, `role`, `role_id`, `roleId`, `campus`, `institution_name`, `institutionName`, `program_name`, `programName`, `role_name`, `roleName`, `document_type`, `documentType`, `reason`, `entity_type`, `entityType`, `action_type`, `actionType`, `city`, `state`, `country`, `type` |
101
+ | `isStreetString` | `street` |
102
+ | `isCharactersString` | `postal_code`, `postalCode`, `period` |
103
+ | `isBoolValue` | `is_primary`, `isPrimary`, `active` |
104
+ | `isSafeSearchString` | `search_string`, `searchString` |
105
+ | `isString6To16CharacterLong` and `isSimplePasswordString` | `password`, `new_password`, `newPassword` |
106
+ | `isString6To16CharacterLong` and `isPasswordString` | `strong_password`, `strongPassword` |
107
+ | `isEmailString` | `email` |
108
+ | `isPhoneNumber` | `phone_number`, `phoneNumber` |
109
+ | `isUrlSafeString` | `token`, `email_confirm_token`, `emailConfirmToken`, `verification_token`, `verificationToken` |
110
+ | `isValidUuidString` | `uuid`, `item_id`, `itemId`, `user_id`, `userId`, `address_id`, `addressId`, `image_id`, `imageId`, `order_id`, `orderId`, `category_id`, `categoryId`, `parent_id`, `parentId`, `college_id`, `collegeId`, `campus_id`, `campusId`, `program_id`, `programId`, `id`, `institution_id`, `institutionId`, `role_assignment_id`, `roleAssignmentId`, `user_role_id`, `userRoleId`, `phone_number_id`, `phoneNumberId`, `entity_id`, `entityId`, `changed_by`, `changedBy`, `request_id`, `requestId` |
111
+ | `isValidIntegerString` | `offset_number`, `offsetNumber`, `number_of_orders`, `numberOfOrders`, `price`, `from`, `number`, `limit`, `offset` |
112
+ | `isValidJsonString` on the raw value | `about` |
113
+ | `isValidJsonString(JSON.stringify(value))` | `weight`, `dimensions`, `permission`, `scope_data`, `scopeData`, `meta_data`, `metaData` |
114
+ | `isValidArrayOfStrings` | `aliases` |
115
+ | `isImageUrl` or `isValidUrl` | `image_url`, `imageUrl`, `website`, `file_url`, `fileUrl` |
116
+ | `isValidDomainName` | `domain_name`, `domainName`, `domain`, `email_domain`, `emailDomain`, `email_domain_name`, `emailDomainName` |
117
+ | `isValidTimestampzString` or `isValidTimestampString` | `expires_at`, `expiresAt`, `start_time`, `startTime`, `end_time`, `endTime` |
116
118
 
117
119
  ## `validateWhitelistProperties(inputObject, requiredProperties, options)`
118
120