ramda#omit TypeScript Examples
The following examples show how to use
ramda#omit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: open-api-helpers.ts From express-zod-api with MIT License | 6 votes |
depictIOExamples = <T extends IOSchema>(
schema: T,
isResponse: boolean,
omitProps: string[] = []
): MediaExamples => {
const examples = getExamples(schema, isResponse);
if (examples.length === 0) {
return {};
}
return {
examples: examples.reduce<ExamplesObject>(
(carry, example, index) => ({
...carry,
[`example${index + 1}`]: <ExampleObject>{
value: omit(omitProps, example),
},
}),
{}
),
};
}
Example #2
Source File: open-api-helpers.ts From express-zod-api with MIT License | 6 votes |
excludeParamsFromDepiction = (
depicted: SchemaObject,
pathParams: string[]
): SchemaObject => {
const properties = depicted.properties
? omit(pathParams, depicted.properties)
: undefined;
const example = depicted.example
? omit(pathParams, depicted.example)
: undefined;
const required = depicted.required
? depicted.required.filter((name) => !pathParams.includes(name))
: undefined;
const allOf = depicted.allOf
? depicted.allOf.map((entry) =>
excludeParamsFromDepiction(entry, pathParams)
)
: undefined;
const oneOf = depicted.oneOf
? depicted.oneOf.map((entry) =>
excludeParamsFromDepiction(entry, pathParams)
)
: undefined;
return omit(
Object.entries({ properties, required, example, allOf, oneOf })
.filter(([{}, value]) => value === undefined)
.map(([key]) => key),
{
...depicted,
properties,
required,
example,
allOf,
oneOf,
}
);
}
Example #3
Source File: inFranceAppReducer.ts From nosgestesclimat-site with MIT License | 6 votes |
function companyLegalStatus(
state: LegalStatusRequirements = {},
action: Action
): LegalStatusRequirements {
switch (action.type) {
case 'COMPANY_IS_SOLE_PROPRIETORSHIP':
return { ...state, soleProprietorship: action.isSoleProprietorship }
case 'DEFINE_DIRECTOR_STATUS':
return { ...state, directorStatus: action.status }
case 'COMPANY_HAS_MULTIPLE_ASSOCIATES':
return { ...state, multipleAssociates: action.multipleAssociates }
case 'COMPANY_IS_MICROENTERPRISE':
return { ...state, autoEntrepreneur: action.autoEntrepreneur }
case 'SPECIFY_DIRECTORS_SHARE':
return { ...state, minorityDirector: action.minorityDirector }
case 'RESET_COMPANY_STATUS_CHOICE':
return action.answersToReset ? omit(action.answersToReset, state) : {}
}
return state
}
Example #4
Source File: persistEverything.ts From nosgestesclimat-site with MIT License | 6 votes |
persistEverything = (options: OptionsType = {}) => (
store: Store<RootState, Action>
): void => {
const listener = () => {
const state = store.getState()
safeLocalStorage.setItem(
LOCAL_STORAGE_KEY,
JSON.stringify(omit(options.except || [], state))
)
}
store.subscribe(debounce(1000, listener))
}
Example #5
Source File: user.service.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
public async find(page = 1, pagesize = 200): Promise<Paginated<any>> {
const query = this.userRepository.createQueryBuilder('User')
.leftJoin('User.roles', 'Roles')
.leftJoin('User._userMeta', 'UserMeta')
.leftJoin('User.authenticationMethod', 'AuthenticationMethod')
.select(['User', 'Roles', 'UserMeta', 'AuthenticationMethod.name']);
const embedded = await query
.skip((page - 1) * pagesize)
.take(pagesize)
.getMany();
return {
_embedded: embedded
.map((user) => ({
...omit(['_userMeta'])(user),
...(user._userMeta.find((x) => x.key === 'customData') && { customData: propOr(null, 'value')(user._userMeta.find((x) => x.key === 'customData')) } )
}))
.sort((a, b) => {
return Math.max(...b.roles.map((r) => r.weight)) - Math.max(...a.roles.map((r) => r.weight));
}),
_page: {
totalEntities: await query.getCount(),
currentPage: page,
itemsPerPage: pagesize,
},
};
}
Example #6
Source File: slot.controller.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
@Put('/:slotUuid')
@Permissions('timetable/book')
@AuditLog('timetable/update')
public async update(@Request() req, @Param('slotUuid') slotUuid: string, @Body() slot: Slot): Promise<any> {
const existingSlot = await this.slotService.findOne({ uuid: slotUuid });
if (!existingSlot) {
throw new UnauthorizedException()
}
let sanitizedSlot: any = slot;
if (!this.permissionService.hasPermission(req.user?.uuid, ['timetable/book-other'])) {
sanitizedSlot = omit(['user', 'userUuid'])(slot);
}
if (this.permissionService.hasPermission(req.user?.uuid, ['timetable/update-other'])) {
return this.slotService.update(slotUuid, sanitizedSlot);
}
if (existingSlot.userUuid === req.user?.uuid) {
return this.slotService.update(slotUuid, sanitizedSlot);
}
throw new ForbiddenException();
}
Example #7
Source File: tenant.controller.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
@Put('/:tenantUuid')
@Permissions('settings/update')
@AuditLog('settings/update')
@ApiOkResponse({ type: Tenant })
public async update(@Body() updatedTenant: any): Promise<Tenant> {
const existingTenant = await this.tenantService.findOne();
return this.tenantService.update(existingTenant.uuid, omit(['users', 'features'])({
...existingTenant,
...updatedTenant,
updatedAt: new Date(),
}) as any);
}
Example #8
Source File: tenant.controller.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
@Patch('/:tenantUuid')
@Permissions('settings/update')
@AuditLog('settings/update')
@ApiOkResponse({ type: Tenant })
public async patch(@Body() updatedTenant: any): Promise<Tenant> {
const existingTenant = await this.tenantService.findOne();
return this.tenantService.update(existingTenant.uuid, omit(['users', 'features'])({
...existingTenant,
...updatedTenant,
settings: {
...existingTenant.settings,
...reject(equals('hidden'))({
...updatedTenant.settings,
something: "hidden"
})
},
updatedAt: new Date(),
}) as any);
}
Example #9
Source File: profile.controller.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
@Put()
public async updateSelf(@Body() updatedUser: any, @Request() req ): Promise<any> {
const currentUser = await this.userService.findOne({ uuid: req.user?.uuid });
await this.userService.assignMeta('customData', req.user?.uuid, updatedUser.customData || {})
return this.userService.update(req.user?.uuid, {
...currentUser,
...omit(['tenants', 'admin'])(updatedUser),
});
}
Example #10
Source File: detail.page.ts From radiopanel with GNU General Public License v3.0 | 6 votes |
public submit(e: Event) {
e.preventDefault();
this.apiKeyService.update(
this.activatedRoute.snapshot.params.id,
this.apiKeyFieldDisabled ? omit(['key'])(this.form.value) : this.form.value
)
.pipe(
first()
).subscribe(() => {
this.toastr.success('Api key updated', 'Success');
});
}
Example #11
Source File: open-api-helpers.ts From express-zod-api with MIT License | 5 votes |
excludeExampleFromDepiction = (
depicted: SchemaObject
): SchemaObject => omit(["example"], depicted)
Example #12
Source File: Button.tsx From OpenSourcerySite with GNU General Public License v3.0 | 5 votes |
LabeledButton = React.forwardRef<HTMLAnchorElement, LabeledButtonProps>( (props, ref) => <Button ref={ref} {...pick([ "url", "onClick" ], props)}> <IconLabel {...omit([ "url", "onClick" ], props)} > {props.children} </IconLabel> </Button > )
Example #13
Source File: dashboard-item-selector.component.ts From radiopanel with GNU General Public License v3.0 | 5 votes |
public ngOnInit(): void {
this.items = map(omit(['component']) as any)(DASHBOARD_COMPONENTS);
}
Example #14
Source File: rootReducer.ts From nosgestesclimat-site with MIT License | 4 votes |
function simulation(
state: Simulation | null = null,
action: Action
): Simulation | null {
if (action.type === 'SET_SIMULATION') {
const { config, url } = action
if (state && state.config && !action.situation === config) {
return state
}
return {
config,
url,
hiddenNotifications: state?.hiddenControls || [],
situation: action.situation || state?.situation || {},
targetUnit: config['unité par défaut'] || '€/mois',
foldedSteps: action.foldedSteps || state?.foldedSteps || [],
unfoldedStep: null,
persona: action.persona,
}
}
if (state === null) {
return state
}
switch (action.type) {
case 'HIDE_NOTIFICATION':
return {
...state,
hiddenNotifications: [...state.hiddenNotifications, action.id],
}
case 'RESET_SIMULATION':
return {
...state,
hiddenNotifications: [],
situation: state.initialSituation,
foldedSteps: [],
unfoldedStep: null,
persona: null,
}
case 'UPDATE_SITUATION': {
const targets = objectifsSelector({ simulation: state } as RootState)
const situation = state.situation
const { fieldName: dottedName, value } = action
return {
...state,
situation:
value === undefined
? omit([dottedName], situation)
: {
...(targets.includes(dottedName)
? omit(targets, situation)
: situation),
[dottedName]: value,
},
}
}
case 'STEP_ACTION': {
const { name, step } = action
if (name === 'fold')
return {
...state,
foldedSteps: state.foldedSteps.includes(step)
? state.foldedSteps
: [...state.foldedSteps, step],
unfoldedStep: null,
}
if (name === 'unfold') {
const previousUnfolded = state.unfoldedStep
return {
...state,
foldedSteps: state.foldedSteps,
unfoldedStep: step,
}
}
return state
}
case 'UPDATE_TARGET_UNIT':
return {
...state,
targetUnit: action.targetUnit,
}
}
return state
}