-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: no nullish in template literals (#868)
* fix: no nullish in template literals * test: can run non-local nuts from script * fix: nut failure (order of validations for describe * fix: truthy 0 mistake (thanks, NUTs!) * test: oh, the UT doesn't match the type. allow string or number
- Loading branch information
Showing
7 changed files
with
134 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import type { CustomField, CustomObject, CustomValue } from '@jsforce/jsforce-node/lib/api/metadata.js'; | ||
|
||
// I know, right? The jsforce types aren't the best. We expect some properties to be present that it doesn't guarantee. | ||
// All this might improve when jsforce starts using @salesforce/schemas for its md types (and then we can drop the dependency on jsforce-node here) | ||
|
||
export type CustomFieldWithFullNameTypeAndLabel = CustomField & | ||
NonNullableFields<Pick<Required<CustomField>, 'fullName' | 'type' | 'label'>>; | ||
|
||
export type CustomObjectWithFullName = CustomObject & { fullName: string }; | ||
|
||
export type CustomValueWithFullNameAndLabel = CustomValue & | ||
Required<NonNullableFields<Pick<CustomValue, 'fullName' | 'label'>>>; | ||
|
||
export const ensureFullName = (obj: CustomObject): CustomObjectWithFullName => { | ||
if (typeof obj.fullName === 'string') { | ||
return obj as CustomObjectWithFullName; | ||
} | ||
throw new Error('CustomObject must have a fullName'); | ||
}; | ||
|
||
export const customValueHasFullNameAndLabel = (cv: CustomValue): cv is CustomValueWithFullNameAndLabel => | ||
typeof cv.fullName === 'string' && typeof cv.label === 'string'; | ||
|
||
/** make all fields non-nullable and required */ | ||
type NonNullableFields<T> = { | ||
[P in keyof T]: NonNullable<T[P]>; | ||
}; |
Oops, something went wrong.