0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(schemas): improve regexp

This commit is contained in:
Gao Sun 2023-09-19 12:03:58 +08:00
parent d065cbc623
commit a856145f81
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
3 changed files with 8 additions and 5 deletions

View file

@ -6,13 +6,16 @@ import type { Field } from './types.js';
export const normalizeWhitespaces = (string: string): string =>
string.replaceAll(/\s+/g, ' ').trim();
// eslint-disable-next-line unicorn/prevent-abbreviations -- JSDoc is a term
const leadingJsDocRegex = /^\s*\/\*\*([^*]*?)\*\//;
// eslint-disable-next-line unicorn/prevent-abbreviations -- JSDoc is a term
export const stripLeadingJsDocComments = (string: string): string =>
string.replace(/^\s*\/\*\*[^*]+\*\//, '').trim();
string.replace(leadingJsDocRegex, '').trim();
// eslint-disable-next-line unicorn/prevent-abbreviations -- JSDoc is a term
const getLeadingJsDocComments = (string: string): Optional<string> =>
/^\s*\/\*\*([^*]+)\*\//g.exec(string)?.[1]?.trim();
leadingJsDocRegex.exec(string)?.[1];
// Remove all comments not start with @
export const removeUnrecognizedComments = (string: string): string =>

View file

@ -18,7 +18,7 @@ create table sentinel_activities (
payload jsonb /* @use SentinelActivityPayload */ not null,
/** The sentinel decision for the action. */
decision sentinel_decision not null,
/** The expiry date of the decision. */
/** The expiry date of the decision. For instant decisions, this is the date the activity was created. */
decision_expires_at timestamptz not null default(now()),
/** The time the activity was created. */
created_at timestamptz not null default(now()),