type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
() => { this.setState({ showModal: true }); }
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
ArrowFunction
() => { this.setState({ showModal: false }); }
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
ArrowFunction
() => { const { showModal } = this.state; const { pendingPlugins } = this.props; if (showModal) { return <ExecutePendingModal pendingPlugins={pendingPlugins} onClose={this.closeModal} />; } return null; }
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
ClassDeclaration
class ExecutePendingAction extends React.Component<Props, State> { constructor(props: Props) { super(props); this.state = { showModal: false }; } openModal = () => { this.setState({ showModal: true }); }; closeModal = () => { this.setState({ showModal: false }); }; renderModal = () => { const { showModal } = this.state; const { pendingPlugins } = this.props; if (showModal) { return <ExecutePendingModal pendingPlugins={pendingPlugins} onClose={this.closeModal} />; } return null; }; render() { const { t } = this.props; return ( <> {this.renderModal()} <Button color="primary" label={t("plugins.executePending")} action={this.openModal} /> </> ); } }
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
TypeAliasDeclaration
type Props = WithTranslation & { pendingPlugins: PendingPlugins; };
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
TypeAliasDeclaration
type State = { showModal: boolean; };
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
MethodDeclaration
render() { const { t } = this.props; return ( <> {this.renderModal()} <Button color="primary" label={t("plugins.executePending")} action={this.openModal} /> </> ); }
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
MethodDeclaration
t("plugins.executePending")
schnatterer/scm-manager
scm-ui/ui-webapp/src/admin/plugins/components/ExecutePendingAction.tsx
TypeScript
ArrowFunction
user => user !== null
aleksanderbies/Singles-Planet-Dating-Web-App
src/app/guards/chat.guard.ts
TypeScript
ArrowFunction
value => { if(!value){ this.router.navigateByUrl('/login').then(); return value; } else{ return value; } }
aleksanderbies/Singles-Planet-Dating-Web-App
src/app/guards/chat.guard.ts
TypeScript
ClassDeclaration
@Injectable({ providedIn: 'root' }) export class ChatGuard implements CanActivate { constructor(private afAuth : AngularFireAuth, private router: Router){ } canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { return this.afAuth.authState.pipe( map(user => user !== null), tap(value => { if(!value){ this.router.navigateByUrl('/login').then(); return value; } else{ return value; } }) ); } }
aleksanderbies/Singles-Planet-Dating-Web-App
src/app/guards/chat.guard.ts
TypeScript
MethodDeclaration
canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { return this.afAuth.authState.pipe( map(user => user !== null), tap(value => { if(!value){ this.router.navigateByUrl('/login').then(); return value; } else{ return value; } }) ); }
aleksanderbies/Singles-Planet-Dating-Web-App
src/app/guards/chat.guard.ts
TypeScript
ClassDeclaration
export class TableArrayProvider<T extends Record<string, unknown>> extends TableDataProvider<T> { rawData: Array<T>; constructor({ data, ...options }: TableProviderOptions & { data: Array<T> }) { super(options); this.rawData = data; this.data.set(this.rawData.slice(0, this.options.itemsPerPage)); } // eslint-disable-next-line @typescript-eslint/no-empty-function async update(): Promise<void> {} async page(i: number): Promise<void> { this.data.set( this.rawData.slice( (i - 1) * this.options.itemsPerPage, Math.min(i * this.options.itemsPerPage, this.rawData.length), ), ); } async sort(sorting: { col: string; ascending: boolean }): Promise<void> { console.log('[provider] sort with', sorting); } async delete(i: number): Promise<T> { console.log('[provider] delete item', i); return null; } }
ISIR-MAP/marcelle
src/ui/components/table-array-provider.ts
TypeScript
MethodDeclaration
// eslint-disable-next-line @typescript-eslint/no-empty-function async update(): Promise<void> {}
ISIR-MAP/marcelle
src/ui/components/table-array-provider.ts
TypeScript
MethodDeclaration
async page(i: number): Promise<void> { this.data.set( this.rawData.slice( (i - 1) * this.options.itemsPerPage, Math.min(i * this.options.itemsPerPage, this.rawData.length), ), ); }
ISIR-MAP/marcelle
src/ui/components/table-array-provider.ts
TypeScript
MethodDeclaration
async sort(sorting: { col: string; ascending: boolean }): Promise<void> { console.log('[provider] sort with', sorting); }
ISIR-MAP/marcelle
src/ui/components/table-array-provider.ts
TypeScript
MethodDeclaration
async delete(i: number): Promise<T> { console.log('[provider] delete item', i); return null; }
ISIR-MAP/marcelle
src/ui/components/table-array-provider.ts
TypeScript
ArrowFunction
() => ({ api1Data: [APIData[0]] })
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
ArrowFunction
() => ({ api2Data: [APIData[1]] })
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
ArrowFunction
data => [...data.api1Data, ...data.api2Data].map(data => data.configuration.path)
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
ArrowFunction
data => data.configuration.path
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
ArrowFunction
async (path, data) => { const page = [...data.api1Data, ...data.api2Data].find(el => el.configuration.path === path); if (!page) { return null; } return { url: path, content: `${page.title}\n\n${page.content}`, }; }
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
ArrowFunction
el => el.configuration.path === path
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
InterfaceDeclaration
interface PipelineData { api1Data: typeof APIData[0][]; api2Data: typeof APIData[1][]; }
SavoirBot/hydro-gen
examples/parallel-fetching/index.ts
TypeScript
InterfaceDeclaration
export interface ValidationResult { errors: string[]; valid: boolean; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FieldMeta<TValue> { touched: boolean; dirty: boolean; valid: boolean; validated: boolean; pending: boolean; initialValue?: TValue; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FieldState<TValue = unknown> { value: TValue; touched: boolean; errors: string[]; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface PrivateFieldComposite<TValue = unknown> { fid: number; idx: number; name: MaybeRef<string>; value: WritableRef<TValue>; meta: FieldMeta<TValue>; errors: Ref<string[]>; errorMessage: ComputedRef<string | undefined>; label?: MaybeRef<string | undefined>; type?: string; checkedValue?: MaybeRef<TValue>; uncheckedValue?: MaybeRef<TValue>; checked?: ComputedRef<boolean>; resetField(state?: FieldState<TValue>): void; handleReset(state?: FieldState<TValue>): void; validate(): Promise<ValidationResult>; handleChange(e: Event | unknown, shouldValidate?: boolean): void; handleBlur(e?: Event): void; handleInput(e?: Event | unknown): void; setValidationState(state: ValidationResult): void; setTouched(isTouched: boolean): void; setErrors(message: string | string[]): void; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FormState<TValues> { values: TValues; errors: Partial<Record<keyof TValues, string | undefined>>; touched: Partial<Record<keyof TValues, boolean>>; submitCount: number; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface SetFieldValueOptions { force: boolean; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FormActions<TValues extends Record<string, unknown>> { setFieldValue<T extends keyof TValues>(field: T, value: TValues[T], opts?: Partial<SetFieldValueOptions>): void; setFieldError: (field: keyof TValues, message: string | string[] | undefined) => void; setErrors: (fields: FormErrors<TValues>) => void; setValues<T extends keyof TValues>(fields: Partial<Record<T, TValues[T]>>): void; setFieldTouched: (field: keyof TValues, isTouched: boolean) => void; setTouched: (fields: Partial<Record<keyof TValues, boolean>>) => void; resetForm: (state?: Partial<FormState<TValues>>) => void; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FormValidationResult<TValues> { valid: boolean; results: Partial<Record<keyof TValues, ValidationResult>>; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface SubmissionContext<TValues extends Record<string, unknown> = Record<string, unknown>> extends FormActions<TValues> { evt?: Event; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface FormContext<TValues extends Record<string, any> = Record<string, any>> extends FormActions<TValues> { register(field: PrivateFieldComposite): void; unregister(field: PrivateFieldComposite): void; values: TValues; fieldsById: ComputedRef<Record<keyof TValues, PrivateFieldComposite | PrivateFieldComposite[]>>; submitCount: Ref<number>; schema?: MaybeRef<RawFormSchema<TValues> | SchemaOf<TValues>>; validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues>>; validate(): Promise<FormValidationResult<TValues>>; validateField(field: keyof TValues): Promise<ValidationResult>; errorBag: Ref<FormErrorBag<TValues>>; setFieldErrorBag(field: string, messages: string | string[]): void; stageInitialValue(path: string, value: unknown): void; meta: ComputedRef<{ dirty: boolean; touched: boolean; valid: boolean; pending: boolean; initialValues: TValues; }>; isSubmitting: Ref<boolean>; handleSubmit(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<void>; setFieldInitialValue(path: string, value: unknown): void; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
InterfaceDeclaration
export interface PublicFormContext<TValues extends Record<string, any> = Record<string, any>> extends Omit< FormContext<TValues>, | 'register' | 'unregister' | 'fieldsById' | 'schema' | 'validateSchema' | 'errorBag' | 'setFieldErrorBag' | 'stageInitialValue' | 'setFieldInitialValue' > { errors: ComputedRef<FormErrors<TValues>>; handleReset: () => void; submitForm: (e?: unknown) => Promise<void>; }
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type YupValidator = AnySchema | AnyObjectSchema;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type Locator = { __locatorRef: string } & ((values: Record<string, unknown>) => unknown);
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
// Extracts explicit keys of an interface without index signature // https://stackoverflow.com/questions/51465182/typescript-remove-index-signature-using-mapped-types export type KnownKeys<T> = { [K in keyof T]: string extends K ? never : number extends K ? never : K; } extends { [_ in keyof T]: infer U } ? U : never;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type MaybeRef<T> = Ref<T> | ComputedRef<T> | T;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type WritableRef<TValue> = Ref<TValue> | WritableComputedRef<TValue>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type FieldComposable<TValue = unknown> = Omit<PrivateFieldComposite<TValue>, 'idx' | 'fid'>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type GenericValidateFunction = ( value: unknown, ctx: FieldContext ) => boolean | string | Promise<boolean | string>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type FormErrors<TValues extends Record<string, unknown>> = Partial<Record<keyof TValues, string | undefined>>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type FormErrorBag<TValues extends Record<string, unknown>> = Partial<Record<keyof TValues, string[]>>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type SubmissionHandler<TValues extends Record<string, unknown> = Record<string, unknown>> = ( values: TValues, ctx: SubmissionContext<TValues> ) => unknown;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
export type RawFormSchema<TValues> = Record<keyof TValues, string | GenericValidateFunction | Record<string, any>>;
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
TypeAliasDeclaration
/** * validated-only: only mutate the previously validated fields * silent: do not mutate any field * force: validate all fields and mutate their state */ export type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
Andrevwv/vee-validate
packages/vee-validate/src/types.ts
TypeScript
ArrowFunction
({ size = 15, width = 21, height = 15, ...props }: Props) => { if (size !== height) { width = width * (size / height); height = height * (size / height); } return ( <Svg width={width} height={height} viewBox="0 0 21 15" {...props}> <Defs> <LinearGradient id="prefix__a" x1="50%" x2="50%" y1="0%" y2="100%"> <Stop offset="0%" stopColor="#FFF" /> <Stop offset="100%" stopColor="#F0F0F0" /> </LinearGradient> <LinearGradient id="prefix__b" x1="50%" x2="50%" y1="0%" y2="100%"> <Stop offset="0%" stopColor="#262626" /> <Stop offset="100%" stopColor="#0D0D0D" /> </LinearGradient> <LinearGradient id="prefix__c" x1="50%" x2="50%" y1="0%" y2="100%"> <Stop offset="0%" stopColor="#E42038" /> <Stop offset="100%" stopColor="#CC162C" /> </LinearGradient> <LinearGradient id="prefix__d" x1="50%" x2="50%" y1="0%" y2="100%"> <Stop offset="0%" stopColor="#47B849" /> <Stop offset="100%" stopColor="#399E3B" /> </LinearGradient> </Defs> <G fill="none" fillRule="evenodd"> <Path fill="url(#prefix__a)" d="M0 0h21v15H0z" /> <Path fill="url(#prefix__b)" d="M0 0h21v5H0z" /> <Circle cx={10.5} cy={5.5} r={3.5} fill="url(#prefix__c)" /> <Path fill="url(#prefix__c)" d="M0 5h21v5H0z" /> <Path fill="url(#prefix__d)" d="M0 10h21v5H0z" /> </G> </Svg>
ecklf/flagkit
src/react-native/flags/FlagIconMW.tsx
TypeScript
InterfaceDeclaration
interface Props extends SvgProps { size?: number; width?: number; height?: number; }
ecklf/flagkit
src/react-native/flags/FlagIconMW.tsx
TypeScript
ArrowFunction
(e) => { e.preventDefault(); $("#btnPricingIndividual").addClass("btn-primary").removeClass("btn-notSelected"); $("#btnPricingOrgs").removeClass("btn-primary").addClass("btn-notSelected"); $("#pricingIndividuals").show(0); $("#pricingOrgs").hide(0); }
memucho/webapp
src/TrueOrFalse.Frontend.Web/Views/Help/Js/WidgetPricing.ts
TypeScript
ArrowFunction
(e) => { e.preventDefault(); $("#btnPricingOrgs").addClass("btn-primary").removeClass("btn-notSelected"); $("#btnPricingIndividual").removeClass("btn-primary").addClass("btn-notSelected"); $("#pricingIndividuals").hide(0); $("#pricingOrgs").show(0); }
memucho/webapp
src/TrueOrFalse.Frontend.Web/Views/Help/Js/WidgetPricing.ts
TypeScript
ClassDeclaration
class WidgetPricing { constructor() { var self = this; $("#btnPricingIndividual") .click((e) => { e.preventDefault(); $("#btnPricingIndividual").addClass("btn-primary").removeClass("btn-notSelected"); $("#btnPricingOrgs").removeClass("btn-primary").addClass("btn-notSelected"); $("#pricingIndividuals").show(0); $("#pricingOrgs").hide(0); }); $("#btnPricingOrgs") .click((e) => { e.preventDefault(); $("#btnPricingOrgs").addClass("btn-primary").removeClass("btn-notSelected"); $("#btnPricingIndividual").removeClass("btn-primary").addClass("btn-notSelected"); $("#pricingIndividuals").hide(0); $("#pricingOrgs").show(0); }); } }
memucho/webapp
src/TrueOrFalse.Frontend.Web/Views/Help/Js/WidgetPricing.ts
TypeScript
FunctionDeclaration
export function MatchShowcasePage(){ }
feelja-tech/feelja-frontend
pages/signup/match_showcase.tsx
TypeScript
ArrowFunction
questionSets => { this.questionSets = questionSets; if (questionSets) { this.currentQuestionSet = this.getCurrentQuestionSet(); } }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
q => q.id
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
q => q.id !== question.id
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
q => q.id === question.id
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
question => question.id
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
qs => qs.questions.find(q => selectedIds.indexOf(q.id) !== -1) !== undefined
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
q => selectedIds.indexOf(q.id) !== -1
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-questions-browser', templateUrl: './app-questions-browser.component.html', styleUrls: ['./app-questions-browser.component.scss'] }) export class AppQuestionsBrowserComponent implements OnInit, OnDestroy { allQuestionsSubscription: Subscription; questionSets; currentQuestionSet; selectedQuestions; initialSelection; constructor( private questionStoreService: QuestionStoreService, public dialogRef: MatDialogRef<AppQuestionsBrowserComponent>, @Inject(MAT_DIALOG_DATA) public data: any ) { } ngOnInit() { this.initialSelection = this.data.selectedQuestions; this.selectedQuestions = this.data.selectedQuestions; this.questionStoreService.getAll(); this.allQuestionsSubscription = this.questionStoreService.questions$ .subscribe(questionSets => { this.questionSets = questionSets; if (questionSets) { this.currentQuestionSet = this.getCurrentQuestionSet(); } }); } ngOnDestroy() { this.allQuestionsSubscription.unsubscribe(); } safeClose() { const noDifference = isEqual( this.selectedQuestions.map(q => q.id), this.initialSelection.map(q => q.id) ); this.dialogRef.close(noDifference ? undefined : this.selectedQuestions); } toggleSelectedQuestion(question) { if (this.isSelectedQuestion(question)) { this.selectedQuestions = this.selectedQuestions.filter( q => q.id !== question.id ); } else { this.selectedQuestions = [...this.selectedQuestions, question]; } } isSelectedQuestion(question) { return this.selectedQuestions.find(q => q.id === question.id); } getCurrentQuestionSet() { const selectedIds = this.selectedQuestions.map(question => question.id); const questionSet = this.questionSets.find( qs => qs.questions.find(q => selectedIds.indexOf(q.id) !== -1) !== undefined ); return questionSet ? questionSet : this.questionSets.length ? this.questionSets[0] : {}; } }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.initialSelection = this.data.selectedQuestions; this.selectedQuestions = this.data.selectedQuestions; this.questionStoreService.getAll(); this.allQuestionsSubscription = this.questionStoreService.questions$ .subscribe(questionSets => { this.questionSets = questionSets; if (questionSets) { this.currentQuestionSet = this.getCurrentQuestionSet(); } }); }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
ngOnDestroy() { this.allQuestionsSubscription.unsubscribe(); }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
safeClose() { const noDifference = isEqual( this.selectedQuestions.map(q => q.id), this.initialSelection.map(q => q.id) ); this.dialogRef.close(noDifference ? undefined : this.selectedQuestions); }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
toggleSelectedQuestion(question) { if (this.isSelectedQuestion(question)) { this.selectedQuestions = this.selectedQuestions.filter( q => q.id !== question.id ); } else { this.selectedQuestions = [...this.selectedQuestions, question]; } }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
isSelectedQuestion(question) { return this.selectedQuestions.find(q => q.id === question.id); }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
MethodDeclaration
getCurrentQuestionSet() { const selectedIds = this.selectedQuestions.map(question => question.id); const questionSet = this.questionSets.find( qs => qs.questions.find(q => selectedIds.indexOf(q.id) !== -1) !== undefined ); return questionSet ? questionSet : this.questionSets.length ? this.questionSets[0] : {}; }
WakeUpCallApp/wakeup
src/app/pages/quote-details/components/app-questions-browser/app-questions-browser.component.ts
TypeScript
ArrowFunction
({ tablename }) => tablename
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
ArrowFunction
(rawTable: RawTable): Table => { return { name: rawTable.table_name, schema: rawTable.table_schema, comment: rawTable.table_comment, }; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
ArrowFunction
({ table_name, column_name }) => ({ table: table_name, column: column_name, })
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
ArrowFunction
(rawColumn): Column => { return { name: rawColumn.column_name, table: rawColumn.table_name, type: rawColumn.data_type, default_value: rawColumn.column_default ? this.parseDefaultValue(rawColumn.column_default) : null, max_length: rawColumn.character_maximum_length, precision: rawColumn.numeric_precision, scale: rawColumn.numeric_scale, is_nullable: rawColumn.is_nullable === 'YES', is_primary_key: rawColumn.is_primary === 'YES', has_auto_increment: rawColumn.serial !== null, foreign_key_column: rawColumn.referenced_column_name, foreign_key_table: rawColumn.referenced_table_name, comment: rawColumn.column_comment, schema: rawColumn.table_schema, foreign_key_schema: rawColumn.referenced_table_schema, }; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
TypeAliasDeclaration
type RawTable = { table_name: string; table_schema: 'public' | string; table_comment: string | null; };
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
TypeAliasDeclaration
type RawColumn = { column_name: string; table_name: string; table_schema: string; data_type: string; column_default: any | null; character_maximum_length: number | null; is_nullable: 'YES' | 'NO'; is_primary: null | 'YES'; numeric_precision: null | number; numeric_scale: null | number; serial: null | string; column_comment: string | null; referenced_table_schema: null | string; referenced_table_name: null | string; referenced_column_name: null | string; };
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
// Postgres specific // =============================================================================================== /** * Set the schema to be used in other methods */ withSchema(schema: string) { this.schema = schema; this.explodedSchema = [this.schema]; return this; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Converts Postgres default value to JS * Eg `'example'::character varying` => `example` */ parseDefaultValue(type: string) { if (type.startsWith('nextval(')) return null; // auto-increment const parts = type.split('::'); let value = parts[0]; if (value.startsWith("'") && value.endsWith("'")) { value = value.slice(1, -1); } if (parts[1] && parts[1].includes('json')) return JSON.parse(value); if (parts[1] && (parts[1].includes('char') || parts[1].includes('text'))) return String(value); if (Number.isNaN(Number(value))) return value; return Number(value); }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
// Tables // =============================================================================================== /** * List all existing tables in the current schema/database */ async tables() { const records = await this.knex .select<{ tablename: string }[]>('tablename') .from('pg_catalog.pg_tables') .whereIn('schemaname', this.explodedSchema); return records.map(({ tablename }) => tablename); }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Get the table info for a given table. If table parameter is undefined, it will return all tables * in the current schema/database */ tableInfo(): Promise<Table[]>;
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
tableInfo(table: string): Promise<Table>;
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
async tableInfo(table?: string) { const query = this.knex .select( 'table_name', 'table_schema', this.knex .select(this.knex.raw('obj_description(oid)')) .from('pg_class') .where({ relkind: 'r' }) .andWhere({ relname: 'table_name ' }) .as('table_comment') ) .from('information_schema.tables') .whereIn('table_schema', this.explodedSchema) .andWhere({ table_catalog: this.knex.client.database() }) .andWhere({ table_type: 'BASE TABLE' }) .orderBy('table_name', 'asc'); if (table) { const rawTable: RawTable = await query .andWhere({ table_name: table }) .limit(1) .first(); return { name: rawTable.table_name, schema: rawTable.table_schema, comment: rawTable.table_comment, } as Table; } const records = await query; return records.map( (rawTable: RawTable): Table => { return { name: rawTable.table_name, schema: rawTable.table_schema, comment: rawTable.table_comment, }; } ); }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Check if a table exists in the current schema/database */ async hasTable(table: string) { const subquery = this.knex .select() .from('information_schema.tables') .whereIn('table_schema', this.explodedSchema) .andWhere({ table_name: table }); const record = await this.knex .select<{ exists: boolean }>(this.knex.raw('exists (?)', [subquery])) .first(); return record?.exists || false; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
// Columns // =============================================================================================== /** * Get all the available columns in the current schema/database. Can be filtered to a specific table */ async columns(table?: string) { const query = this.knex .select<{ table_name: string; column_name: string }[]>( 'table_name', 'column_name' ) .from('information_schema.columns') .whereIn('table_schema', this.explodedSchema); if (table) { query.andWhere({ table_name: table }); } const records = await query; return records.map(({ table_name, column_name }) => ({ table: table_name, column: column_name, })); }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Get the column info for all columns, columns in a given table, or a specific column. */ columnInfo(): Promise<Column[]>;
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
columnInfo(table: string): Promise<Column[]>;
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
columnInfo(table: string, column: string): Promise<Column>;
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
async columnInfo<T>(table?: string, column?: string) { const { knex } = this; const query = knex .select( 'c.column_name', 'c.table_name', 'c.data_type', 'c.column_default', 'c.character_maximum_length', 'c.is_nullable', 'c.numeric_precision', 'c.numeric_scale', 'c.table_schema', knex .select(knex.raw(`'YES'`)) .from('pg_index') .join('pg_attribute', function () { this.on('pg_attribute.attrelid', '=', 'pg_index.indrelid').andOn( knex.raw('pg_attribute.attnum = any(pg_index.indkey)') ); }) .whereRaw('pg_index.indrelid = c.table_name::regclass') .andWhere(knex.raw('pg_attribute.attname = c.column_name')) .andWhere(knex.raw('pg_index.indisprimary')) .as('is_primary'), knex .select( knex.raw( 'pg_catalog.col_description(pg_catalog.pg_class.oid, c.ordinal_position:: int)' ) ) .from('pg_catalog.pg_class') .whereRaw( `pg_catalog.pg_class.oid = (select('"' || c.table_name || '"'):: regclass:: oid)` ) .andWhere({ 'pg_catalog.pg_class.relname': 'c.table_name' }) .as('column_comment'), knex.raw( 'pg_get_serial_sequence(c.table_name, c.column_name) as serial' ), 'ffk.referenced_table_schema', 'ffk.referenced_table_name', 'ffk.referenced_column_name' ) .from(knex.raw('information_schema.columns c')) .joinRaw( ` LEFT JOIN ( SELECT k1.table_schema, k1.table_name, k1.column_name, k2.table_schema AS referenced_table_schema, k2.table_name AS referenced_table_name, k2.column_name AS referenced_column_name FROM information_schema.key_column_usage k1 JOIN information_schema.referential_constraints fk using ( constraint_schema, constraint_name ) JOIN information_schema.key_column_usage k2 ON k2.constraint_schema = fk.unique_constraint_schema AND k2.constraint_name = fk.unique_constraint_name AND k2.ordinal_position = k1.position_in_unique_constraint ) ffk ON ffk.table_name = c.table_name AND ffk.column_name = c.column_name ` ) .whereIn('c.table_schema', this.explodedSchema); if (table) { query.andWhere({ 'c.table_name': table }); } if (column) { const rawColumn = await query .andWhere({ 'c.column_name': column }) .first(); return { name: rawColumn.column_name, table: rawColumn.table_name, type: rawColumn.data_type, default_value: rawColumn.column_default ? this.parseDefaultValue(rawColumn.column_default) : null, max_length: rawColumn.character_maximum_length, precision: rawColumn.numeric_precision, scale: rawColumn.numeric_scale, is_nullable: rawColumn.is_nullable === 'YES', is_primary_key: rawColumn.is_primary === 'YES', has_auto_increment: rawColumn.serial !== null, foreign_key_column: rawColumn.referenced_column_name, foreign_key_table: rawColumn.referenced_table_name, comment: rawColumn.column_comment, schema: rawColumn.table_schema, foreign_key_schema: rawColumn.referenced_table_schema, } as T extends string ? Column : Column[]; } const records: RawColumn[] = await query; return records.map( (rawColumn): Column => { return { name: rawColumn.column_name, table: rawColumn.table_name, type: rawColumn.data_type, default_value: rawColumn.column_default ? this.parseDefaultValue(rawColumn.column_default) : null, max_length: rawColumn.character_maximum_length, precision: rawColumn.numeric_precision, scale: rawColumn.numeric_scale, is_nullable: rawColumn.is_nullable === 'YES', is_primary_key: rawColumn.is_primary === 'YES', has_auto_increment: rawColumn.serial !== null, foreign_key_column: rawColumn.referenced_column_name, foreign_key_table: rawColumn.referenced_table_name, comment: rawColumn.column_comment, schema: rawColumn.table_schema, foreign_key_schema: rawColumn.referenced_table_schema, }; } ) as T extends string ? Column : Column[]; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Check if the given table contains the given column */ async hasColumn(table: string, column: string) { const subquery = this.knex .select() .from('information_schema.columns') .whereIn('table_schema', this.explodedSchema) .andWhere({ table_name: table, column_name: column, }); const record = await this.knex .select<{ exists: boolean }>(this.knex.raw('exists (?)', [subquery])) .first(); return record?.exists || false; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
MethodDeclaration
/** * Get the primary key column for the given table */ async primary(table: string): Promise<string> { const result = await this.knex .select('information_schema.key_column_usage.column_name') .from('information_schema.key_column_usage') .leftJoin( 'information_schema.table_constraints', 'information_schema.table_constraints.constraint_name', 'information_schema.key_column_usage.constraint_name' ) .whereIn( 'information_schema.table_constraints.table_schema', this.explodedSchema ) .andWhere({ 'information_schema.table_constraints.constraint_type': 'PRIMARY KEY', 'information_schema.table_constraints.table_name': table, }) .first(); return result ? result.column_name : null; }
Idered/knex-schema-inspector
lib/dialects/postgres.ts
TypeScript
ClassDeclaration
/** * User Agent Core. * @remarks * Core designates the functions specific to a particular type * of SIP entity, i.e., specific to either a stateful or stateless * proxy, a user agent or registrar. All cores, except those for * the stateless proxy, are transaction users. * https://tools.ietf.org/html/rfc3261#section-6 * * UAC Core: The set of processing functions required of a UAC that * reside above the transaction and transport layers. * https://tools.ietf.org/html/rfc3261#section-6 * * UAS Core: The set of processing functions required at a UAS that * resides above the transaction and transport layers. * https://tools.ietf.org/html/rfc3261#section-6 * @public */ export declare class UserAgentCore { /** Configuration. */ configuration: UserAgentCoreConfiguration; /** Delegate. */ delegate: UserAgentCoreDelegate; /** Dialogs. */ dialogs: Map<string, Dialog>; /** Subscribers. */ subscribers: Map<string, SubscribeUserAgentClient>; /** UACs. */ userAgentClients: Map<string, UserAgentClient>; /** UASs. */ userAgentServers: Map<string, UserAgentServer>; private logger; /** * Constructor. * @param configuration - Configuration. * @param delegate - Delegate. */ constructor(configuration: UserAgentCoreConfiguration, delegate?: UserAgentCoreDelegate); /** Destructor. */ dispose(): void; /** Reset. */ reset(): void; /** Logger factory. */ get loggerFactory(): LoggerFactory; /** Transport. */ get transport(): Transport; /** * Send INVITE. * @param request - Outgoing request. * @param delegate - Request delegate. */ invite(request: OutgoingRequestMessage, delegate?: OutgoingInviteRequestDelegate): OutgoingInviteRequest; /** * Send MESSAGE. * @param request - Outgoing request. * @param delegate - Request delegate. */ message(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingMessageRequest; /** * Send PUBLISH. * @param request - Outgoing request. * @param delegate - Request delegate. */ publish(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingPublishRequest; /** * Send REGISTER. * @param request - Outgoing request. * @param delegate - Request delegate. */ register(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRegisterRequest; /** * Send SUBSCRIBE. * @param request - Outgoing request. * @param delegate - Request delegate. */ subscribe(request: OutgoingRequestMessage, delegate?: OutgoingSubscribeRequestDelegate): OutgoingSubscribeRequest; /** * Send a request. * @param request - Outgoing request. * @param delegate - Request delegate. */ request(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRequest; /** * Outgoing request message factory function. * @param method - Method. * @param requestURI - Request-URI. * @param fromURI - From URI. * @param toURI - To URI. * @param options - Request options. * @param extraHeaders - Extra headers to add. * @param body - Message body. */ makeOutgoingRequestMessage(method: string, requestURI: URI, fromURI: URI, toURI: URI, options: OutgoingRequestMessageOptions, extraHeaders?: Array<string>, body?: Body): OutgoingRequestMessage; /** * Handle an incoming request message from the transport. * @param message - Incoming request message from transport layer. */ receiveIncomingRequestFromTransport(message: IncomingRequestMessage): void; /** * Handle an incoming response message from the transport. * @param message - Incoming response message from transport layer. */ receiveIncomingResponseFromTransport(message: IncomingResponseMessage): void; /** * A stateless UAS is a UAS that does not maintain transaction state. * It replies to requests normally, but discards any state that would * ordinarily be retained by a UAS after a response has been sent. If a * stateless UAS receives a retransmission of a request, it regenerates * the response and re-sends it, just as if it were replying to the first * instance of the request. A UAS cannot be stateless unless the request * processing for that method would always result in the same response * if the requests are identical. This rules out stateless registrars, * for example. Stateless UASs do not use a transaction layer; they * receive requests directly from the transport layer and send responses * directly to the transport layer. * https://tools.ietf.org/html/rfc3261#section-8.2.7 * @param message - Incoming request message to reply to. * @param statusCode - Status code to reply with. */ replyStateless(message: IncomingRequestMessage, options: ResponseOptions): OutgoingResponse; /** * In Section 18.2.1, replace the last paragraph with: * * Next, the server transport attempts to match the request to a * server transaction. It does so using the matching rules described * in Section 17.2.3. If a matching server transaction is found, the * request is passed to that transaction for processing. If no match * is found, the request is passed to the core, which may decide to * construct a new server transaction for that request. * https://tools.ietf.org/html/rfc6026#section-8.10 * @param message - Incoming request message from transport layer. */ private receiveRequestFromTransport; /** * UAC and UAS procedures depend strongly on two factors. First, based * on whether the request or response is inside or outside of a dialog, * and second, based on the method of a request. Dialogs are discussed * thoroughly in Section 12; they represent a peer-to-peer relationship * between user agents and are established by specific SIP methods, such * as INVITE. * @param message - Incoming request message. */ private receiveRequest; /** * Once a dialog has been established between two UAs, either of them * MAY initiate new transactions as needed within the dialog. The UA * sending the request will take the UAC role for the transaction. The * UA receiving the request will take the UAS role. Note that these may * be different roles than the UAs held during the transaction that * established the dialog. * https://tools.ietf.org/html/rfc3261#section-12.2 * @param message - Incoming request message. */ private receiveInsideDialogRequest; /** * Assuming all of the checks in the previous subsections are passed, * the UAS processing becomes method-specific. * https://tools.ietf.org/html/rfc3261#section-8.2.5 * @param message - Incoming request message. */ private receiveOutsideDialogRequest; /** * Responses are first processed by the transport layer and then passed * up to the transaction layer. The transaction layer performs its * processing and then passes the response up to the TU. The majority * of response processing in the TU is method specific. However, there * are some general behaviors independent of the method. * https://tools.ietf.org/html/rfc3261#section-8.1.3 * @param message - Incoming response message from transport layer. */ private receiveResponseFromTransport; }
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** Destructor. */ dispose(): void;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** Reset. */ reset(): void;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send INVITE. * @param request - Outgoing request. * @param delegate - Request delegate. */ invite(request: OutgoingRequestMessage, delegate?: OutgoingInviteRequestDelegate): OutgoingInviteRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send MESSAGE. * @param request - Outgoing request. * @param delegate - Request delegate. */ message(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingMessageRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send PUBLISH. * @param request - Outgoing request. * @param delegate - Request delegate. */ publish(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingPublishRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send REGISTER. * @param request - Outgoing request. * @param delegate - Request delegate. */ register(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRegisterRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send SUBSCRIBE. * @param request - Outgoing request. * @param delegate - Request delegate. */ subscribe(request: OutgoingRequestMessage, delegate?: OutgoingSubscribeRequestDelegate): OutgoingSubscribeRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Send a request. * @param request - Outgoing request. * @param delegate - Request delegate. */ request(request: OutgoingRequestMessage, delegate?: OutgoingRequestDelegate): OutgoingRequest;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Outgoing request message factory function. * @param method - Method. * @param requestURI - Request-URI. * @param fromURI - From URI. * @param toURI - To URI. * @param options - Request options. * @param extraHeaders - Extra headers to add. * @param body - Message body. */ makeOutgoingRequestMessage(method: string, requestURI: URI, fromURI: URI, toURI: URI, options: OutgoingRequestMessageOptions, extraHeaders?: Array<string>, body?: Body): OutgoingRequestMessage;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Handle an incoming request message from the transport. * @param message - Incoming request message from transport layer. */ receiveIncomingRequestFromTransport(message: IncomingRequestMessage): void;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * Handle an incoming response message from the transport. * @param message - Incoming response message from transport layer. */ receiveIncomingResponseFromTransport(message: IncomingResponseMessage): void;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript
MethodDeclaration
/** * A stateless UAS is a UAS that does not maintain transaction state. * It replies to requests normally, but discards any state that would * ordinarily be retained by a UAS after a response has been sent. If a * stateless UAS receives a retransmission of a request, it regenerates * the response and re-sends it, just as if it were replying to the first * instance of the request. A UAS cannot be stateless unless the request * processing for that method would always result in the same response * if the requests are identical. This rules out stateless registrars, * for example. Stateless UASs do not use a transaction layer; they * receive requests directly from the transport layer and send responses * directly to the transport layer. * https://tools.ietf.org/html/rfc3261#section-8.2.7 * @param message - Incoming request message to reply to. * @param statusCode - Status code to reply with. */ replyStateless(message: IncomingRequestMessage, options: ResponseOptions): OutgoingResponse;
samadlol/SIP.js
lib/core/user-agent-core/user-agent-core.d.ts
TypeScript