repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
tianji
github_2023
msgbyte
typescript
SurveyService.surveyUpdate
public static surveyUpdate(data: $OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/update']['patch']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/update']['patch']['res'][200]> { return __request(OpenAPI, { method: 'PATCH', url: '/workspace/{work...
/** * @param data The data for the request. * @param data.workspaceId * @param data.surveyId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1297-L1308
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
SurveyService.surveyDelete
public static surveyDelete(data: $OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/delete']['delete']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/delete']['delete']['res'][200]> { return __request(OpenAPI, { method: 'DELETE', url: '/workspace/{w...
/** * @param data The data for the request. * @param data.workspaceId * @param data.surveyId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1317-L1326
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
SurveyService.surveyResultList
public static surveyResultList(data: $OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/result/list']['get']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/survey/{surveyId}/result/list']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/workspa...
/** * @param data The data for the request. * @param data.workspaceId * @param data.surveyId * @param data.limit * @param data.cursor * @param data.startAt * @param data.endAt * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1339-L1354
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
AuditLogService.auditLogFetchByCursor
public static auditLogFetchByCursor(data: $OpenApiTs['/audit/fetchByCursor']['get']['req']): CancelablePromise<$OpenApiTs['/audit/fetchByCursor']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/audit/fetchByCursor', query: { workspaceId...
/** * Fetch workspace audit log * @param data The data for the request. * @param data.workspaceId * @param data.limit * @param data.cursor * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1368-L1378
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
AuditLogService.auditLogClear
public static auditLogClear(data: $OpenApiTs['/audit/clear']['delete']['req']): CancelablePromise<$OpenApiTs['/audit/clear']['delete']['res'][200]> { return __request(OpenAPI, { method: 'DELETE', url: '/audit/clear', query: { workspaceId: data.workspaceId ...
/** * clear all workspace audit log * @param data The data for the request. * @param data.workspaceId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1387-L1395
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
BillingService.billingUsage
public static billingUsage(data: $OpenApiTs['/billing/usage']['get']['req']): CancelablePromise<$OpenApiTs['/billing/usage']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/billing/usage', query: { workspaceId: data.workspaceId, ...
/** * get workspace usage * @param data The data for the request. * @param data.workspaceId * @param data.startAt * @param data.endAt * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1409-L1419
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
BillingService.billingLimit
public static billingLimit(data: $OpenApiTs['/billing/limit']['get']['req']): CancelablePromise<$OpenApiTs['/billing/limit']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/billing/limit', query: { workspaceId: data.workspaceId ...
/** * get workspace subscription limit * @param data The data for the request. * @param data.workspaceId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1428-L1436
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
BillingService.billingCurrentTier
public static billingCurrentTier(data: $OpenApiTs['/billing/currentTier']['get']['req']): CancelablePromise<$OpenApiTs['/billing/currentTier']['get']['res'][200] | $OpenApiTs['/billing/currentTier']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/billing/currentTi...
/** * get workspace current tier * @param data The data for the request. * @param data.workspaceId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1446-L1454
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
BillingService.billingCurrentSubscription
public static billingCurrentSubscription(data: $OpenApiTs['/billing/currentSubscription']['get']['req']): CancelablePromise<$OpenApiTs['/billing/currentSubscription']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/billing/currentSubscription', query: ...
/** * get workspace current subscription * @param data The data for the request. * @param data.workspaceId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1463-L1471
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedChannels
public static feedChannels(data: $OpenApiTs['/workspace/{workspaceId}/feed/channels']['get']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/channels']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/workspace/{workspaceId}/feed/channels', ...
/** * @param data The data for the request. * @param data.workspaceId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1482-L1490
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedChannelInfo
public static feedChannelInfo(data: $OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/info']['get']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/info']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', url: '/workspace/{workspaceId}/...
/** * @param data The data for the request. * @param data.workspaceId * @param data.channelId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1499-L1508
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedUpdateChannelInfo
public static feedUpdateChannelInfo(data: $OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/update']['post']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/update']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: '/workspace/{...
/** * @param data The data for the request. * @param data.workspaceId * @param data.channelId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1518-L1529
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedFetchEventsByCursor
public static feedFetchEventsByCursor(data: $OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/fetchEventsByCursor']['get']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/fetchEventsByCursor']['get']['res'][200]> { return __request(OpenAPI, { method: 'GET', ...
/** * Fetch workspace feed channel events * @param data The data for the request. * @param data.workspaceId * @param data.channelId * @param data.limit * @param data.cursor * @param data.archived * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1542-L1556
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedCreateChannel
public static feedCreateChannel(data: $OpenApiTs['/workspace/{workspaceId}/feed/createChannel']['post']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/createChannel']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: '/workspace/{workspaceId}/f...
/** * @param data The data for the request. * @param data.workspaceId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1565-L1575
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedDeleteChannel
public static feedDeleteChannel(data: $OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/del']['delete']['req']): CancelablePromise<$OpenApiTs['/workspace/{workspaceId}/feed/{channelId}/del']['delete']['res'][200]> { return __request(OpenAPI, { method: 'DELETE', url: '/workspace/{work...
/** * @param data The data for the request. * @param data.workspaceId * @param data.channelId * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1584-L1593
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedSendEvent
public static feedSendEvent(data: $OpenApiTs['/feed/{channelId}/send']['post']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/send']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: '/feed/{channelId}/send', path: { channelId: ...
/** * @param data The data for the request. * @param data.channelId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1602-L1612
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedArchiveEvent
public static feedArchiveEvent(data: $OpenApiTs['/feed/{channelId}/{eventId}/archive']['patch']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/{eventId}/archive']['patch']['res'][200]> { return __request(OpenAPI, { method: 'PATCH', url: '/feed/{channelId}/{eventId}/archive', ...
/** * @param data The data for the request. * @param data.channelId * @param data.eventId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1622-L1633
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedUnarchiveEvent
public static feedUnarchiveEvent(data: $OpenApiTs['/feed/{channelId}/{eventId}/unarchive']['patch']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/{eventId}/unarchive']['patch']['res'][200]> { return __request(OpenAPI, { method: 'PATCH', url: '/feed/{channelId}/{eventId}/unarch...
/** * @param data The data for the request. * @param data.channelId * @param data.eventId * @param data.requestBody * @returns unknown Successful response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1643-L1654
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedClearAllArchivedEvents
public static feedClearAllArchivedEvents(data: $OpenApiTs['/feed/{channelId}/clearAllArchivedEvents']['patch']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/clearAllArchivedEvents']['patch']['res'][200] | $OpenApiTs['/feed/{channelId}/clearAllArchivedEvents']['patch']['res'][200]> { return __request(...
/** * @param data The data for the request. * @param data.channelId * @param data.requestBody * @returns number Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1664-L1674
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedIntegrationPlayground
public static feedIntegrationPlayground(data: $OpenApiTs['/feed/playground/{workspaceId}']['post']['req']): CancelablePromise<$OpenApiTs['/feed/playground/{workspaceId}']['post']['res'][200] | $OpenApiTs['/feed/playground/{workspaceId}']['post']['res'][200]> { return __request(OpenAPI, { method: 'PO...
/** * webhook playground * @param data The data for the request. * @param data.workspaceId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1684-L1692
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedIntegrationGithub
public static feedIntegrationGithub(data: $OpenApiTs['/feed/{channelId}/github']['post']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/github']['post']['res'][200] | $OpenApiTs['/feed/{channelId}/github']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: ...
/** * integrate with github webhook * @param data The data for the request. * @param data.channelId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1702-L1710
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedIntegrationStripe
public static feedIntegrationStripe(data: $OpenApiTs['/feed/{channelId}/stripe']['post']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/stripe']['post']['res'][200] | $OpenApiTs['/feed/{channelId}/stripe']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: ...
/** * integrate with stripe webhook * @param data The data for the request. * @param data.channelId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1720-L1728
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedIntegrationTencentCloudAlarm
public static feedIntegrationTencentCloudAlarm(data: $OpenApiTs['/feed/{channelId}/tencent-cloud/alarm']['post']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/tencent-cloud/alarm']['post']['res'][200] | $OpenApiTs['/feed/{channelId}/tencent-cloud/alarm']['post']['res'][200]> { return __request(OpenAP...
/** * integrate with tencent-cloud webhook * @param data The data for the request. * @param data.channelId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1738-L1746
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
FeedService.feedIntegrationSentry
public static feedIntegrationSentry(data: $OpenApiTs['/feed/{channelId}/sentry']['post']['req']): CancelablePromise<$OpenApiTs['/feed/{channelId}/sentry']['post']['res'][200] | $OpenApiTs['/feed/{channelId}/sentry']['post']['res'][200]> { return __request(OpenAPI, { method: 'POST', url: ...
/** * integrate with sentry webhook * @param data The data for the request. * @param data.channelId * @returns string Successful response * @returns unknown Error response * @throws ApiError */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/packages/client-sdk/src/open/client/services.gen.ts#L1756-L1764
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
clearMonitorDataDaily
async function clearMonitorDataDaily() { if (env.disableAutoClear) { return; } const date = dayjs().subtract(1, 'months').toDate(); logger.info( '[clearMonitorDataDaily] Start clear monitor data before:', date.toISOString() ); const res = await prisma.monitorData.deleteMany({ where: { ...
/** * Clear over 1 month data */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/cronjob/index.ts#L252-L274
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
clearMonitorEventDaily
async function clearMonitorEventDaily() { if (env.disableAutoClear) { return; } const date = dayjs().subtract(1, 'month').toDate(); logger.info( '[clearMonitorEventDaily] Start clear monitor data before:', date.toISOString() ); const res = await prisma.monitorEvent.deleteMany({ where: { ...
/** * Clear over 1 month data */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/cronjob/index.ts#L279-L301
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
clearAuditLogDaily
async function clearAuditLogDaily() { if (env.disableAutoClear) { return; } const date = dayjs().subtract(4, 'weeks').toDate(); logger.info( '[clearAuditLogDaily] Start clear log data before:', date.toISOString() ); const res = await prisma.workspaceAuditLog.deleteMany({ where: { crea...
/** * Clear over 4 week data */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/cronjob/index.ts#L306-L328
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
dailyHTTPCertCheckNotify
async function dailyHTTPCertCheckNotify() { logger.info('[dailyHTTPCertCheckNotify] Start run dailyHTTPCertCheckNotify'); const start = Date.now(); const res = await prisma.$queryRaw< { monitorId: string; daysRemaining: number }[] >` SELECT "monitorId", (payload -> 'certInfo' ->> 'daysRemaining')::int ...
/** * Https notify */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/cronjob/index.ts#L334-L392
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
checkFeedEventsNotify
async function checkFeedEventsNotify( notifyFrequency: FeedChannelNotifyFrequency ) { logger.info( '[checkFeedEventsNotify] Start run checkFeedEventsNotify with:', notifyFrequency ); const channels = await prisma.feedChannel.findMany({ where: { notifyFrequency, }, include: { not...
/** * Check feed events notify */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/cronjob/index.ts#L397-L454
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorManager.upsert
async upsert(data: MonitorUpsertData): Promise<MonitorWithNotification> { let monitor: MonitorWithNotification; const { id, workspaceId, notificationIds = [], ...others } = data; if (id) { // update monitor = await prisma.monitor.update({ where: { id, workspaceId, ...
/** * create or update */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/manager.ts#L25-L71
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorManager.startAll
async startAll() { if (this.isStarted === true) { logger.warn('MonitorManager.startAll should only call once, skipped.'); return; } this.isStarted = true; const monitors = await prisma.monitor.findMany({ where: { active: true, }, include: { notifications: ...
/** * Get and start all monitors */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/manager.ts#L93-L123
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorManager.restartWithWorkspaceId
restartWithWorkspaceId(workspaceId: string) { Object.values(this.monitorRunner).map((runner) => { if (runner.workspace.id === workspaceId) { this.createRunner(runner.monitor); } }); }
/** * Restart all runner basic on workspace id */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/manager.ts#L132-L138
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorManager.createRunner
async createRunner(monitor: MonitorWithNotification) { if (this.monitorRunner[monitor.id]) { this.monitorRunner[monitor.id].stopMonitor(); } const workspace = await prisma.workspace.findUniqueOrThrow({ where: { id: monitor.workspaceId, }, }); const runner = (this.monitorRu...
/** * create runner */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/manager.ts#L143-L161
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorRunner.startMonitor
async startMonitor() { const monitor = this.monitor; const { type, interval, workspaceId, maxRetries } = monitor; const provider = monitorProviders[type]; if (!provider) { throw new Error(`Unknown monitor type: ${type}`); } let currentStatus: 'UP' | 'DOWN' = 'UP'; const nextAction =...
/** * Start single monitor */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/runner.ts#L35-L142
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorPageManager.constructor
constructor() { prisma.monitorStatusPage .findMany({ where: { domain: { not: null, }, }, select: { id: true, domain: true, workspaceId: true, slug: true, }, }) .then((res) => { res.forEa...
// key: domain
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/page/manager.ts#L14-L47
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
MonitorPageManager.checkDomain
async checkDomain(domain: string, excludeMonitorId?: string) { const res = await prisma.monitorStatusPage.findFirst({ where: { domain, id: { notIn: excludeMonitorId ? [excludeMonitorId] : [], }, }, }); return !res; }
/** * check domain existed * if domain not been used, return true */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/page/manager.ts#L53-L64
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
getDaysRemaining
function getDaysRemaining(validFrom: Date, validTo: Date) { const daysRemaining = dayjs(validTo).diff(validFrom, 'days'); return daysRemaining; }
/** * Get days remaining from a time range * @param {Date} validFrom Start date * @param {Date} validTo End date * @returns {number} Number of days remaining */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/model/monitor/provider/http.ts#L173-L177
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
main
async function main() { console.log(`[populate-ip-location] start scan`); const start = Date.now(); const noParseWebsiteSessions = await prisma.websiteSession.findMany({ where: { ip: { not: null, }, latitude: null, }, }); console.log( `[populate-ip-location] find ${noPar...
/** * Update ip latitude and longitude */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/prisma/scripts/populate-ip-location.ts#L10-L94
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
createWorkspacePermissionMiddleware
function createWorkspacePermissionMiddleware(roles: ROLES[] = []) { return isUser.unstable_pipe(async (opts) => { const { ctx, input } = opts; const workspaceId = get(input, 'workspaceId', ''); if (!workspaceId) { throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Payloa...
/** * Create a trpc middleware which help user check workspace permission * NOTE: this middleware already include user auth, so we dont need use it under protectProedure which will trigger user auth twice. */
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/trpc/trpc.ts#L153-L193
0755f8419c557f8a1b3c89620695eb260ca0ae1b
tianji
github_2023
msgbyte
typescript
isSemiTransferable
function isSemiTransferable(data: any) { return data instanceof ArrayBuffer; }
// Semi-transferable data can be copied with an ivm.ExternalCopy without needing any manipulation.
https://github.com/msgbyte/tianji/blob/0755f8419c557f8a1b3c89620695eb260ca0ae1b/src/server/utils/sandbox.ts#L74-L76
0755f8419c557f8a1b3c89620695eb260ca0ae1b
devtools
github_2023
vuejs
typescript
internalSearchObject
function internalSearchObject(obj, searchTerm, seen, depth) { if (depth > SEARCH_MAX_DEPTH) return false let match = false const keys = Object.keys(obj) let key, value for (let i = 0; i < keys.length; i++) { key = keys[i] value = obj[key] match = internalSearchCheck(searchTerm, key, value, se...
/** * Executes a search on each field of the provided object * @param {*} obj Search target * @param {string} searchTerm Search string * @param {Map<any,boolean>} seen Map containing the search result to prevent stack overflow by walking on the same object multiple times * @param {number} depth Deep search depth l...
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/applet/src/utils/search.ts#L26-L41
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
internalSearchCheck
function internalSearchCheck(searchTerm, key, value, seen, depth) { let match = false let result if (key === '_custom') { key = value.display value = value.value } (result = specialTokenToString(value)) && (value = result) if (key && compare(key, searchTerm)) { match = true seen.set(value, t...
/** * Checks if the provided field matches the search terms * @param {string} searchTerm Search string * @param {string} key Field key (null if from array) * @param {*} value Field value * @param {Map<any,boolean>} seen Map containing the search result to prevent stack overflow by walking on the same object multip...
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/applet/src/utils/search.ts#L52-L82
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
compare
function compare(value, searchTerm) { return (`${value}`).toLowerCase().includes(searchTerm) }
/** * Compares two values * @param {*} value Mixed type value that will be cast to string * @param {string} searchTerm Search string * @returns {boolean} Search match */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/applet/src/utils/search.ts#L90-L92
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
internalSearchArray
function internalSearchArray(array, searchTerm, seen, depth) { if (depth > SEARCH_MAX_DEPTH) return false let match = false let value for (let i = 0; i < array.length; i++) { value = array[i] match = internalSearchCheck(searchTerm, null, value, seen, depth + 1) if (match) break } retu...
/** * Executes a search on each value of the provided array * @param {*} array Search target * @param {string} searchTerm Search string * @param {Map<any,boolean>} seen Map containing the search result to prevent stack overflow by walking on the same object multiple times * @param {number} depth Deep search depth ...
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/applet/src/utils/search.ts#L121-L134
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
init
function init() { injectScript(chrome.runtime.getURL('dist/user-app.js'), () => { initDevTools() createRpcClient(functions, { preset: 'extension', }) }) chrome.devtools.network.onNavigated.addListener(() => { disconnectDevToolsClient() injectScript(chrome.runtime.getURL('dist/user-app.j...
// function connect() {
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/chrome-extension/src/devtools-panel.ts#L42-L58
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
checkReferenceIsValid
function checkReferenceIsValid(modId: string) { const refer = moduleReferences.get(modId) return refer ? refer.some(ref => checkIsValidModule(ref.mod)) : true }
// check valid module need also check it's reference is valid
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/client/src/composables/graph.ts#L175-L178
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
getEdge
function getEdge(modId: string, dep: string) { return { from: modId, to: dep, arrows: { to: { enabled: true, scaleFactor: 0.8, }, }, } }
// #endregion
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/client/src/composables/graph.ts#L258-L269
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
recursivelyGetGraphNodeData
function recursivelyGetGraphNodeData(nodeId: string, depth = 0): GraphNodesTotalData[] { const node = modulesMap.get(nodeId) depth += 1 if (!node || depth > 20) return [] const result = [node] node.mod.deps.forEach((dep) => { const node = modulesMap.get(dep) if (node) result.push(...recursiv...
// max depth is 20
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/client/src/composables/graph.ts#L475-L492
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
DevToolsV6PluginAPI.notifyComponentUpdate
notifyComponentUpdate(instance?: ComponentInstance) { if (devtoolsState.highPerfModeEnabled) { return } const inspector = getActiveInspectors().find(i => i.packageName === this.plugin.descriptor.packageName) if (inspector?.id) { // @TODO: handler if (instance) { const args = [ ...
// component inspector
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/api/v6/index.ts#L59-L81
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
DevToolsV6PluginAPI.addInspector
addInspector(options: CustomInspectorOptions) { this.hooks.callHook(DevToolsContextHookKeys.ADD_INSPECTOR, { inspector: options, plugin: this.plugin }) if (this.plugin.descriptor.settings) { initPluginSettings(options.id, this.plugin.descriptor.settings) } }
// custom inspector
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/api/v6/index.ts#L84-L89
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
DevToolsV6PluginAPI.now
now(): number { if (devtoolsState.highPerfModeEnabled) { return 0 } return Date.now() }
// timeline
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/api/v6/index.ts#L114-L119
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
DevToolsV6PluginAPI.getSettings
getSettings(pluginId?: string) { return getPluginSettings((pluginId ?? this.plugin.descriptor.id)!, this.plugin.descriptor.settings) }
// settings
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/api/v6/index.ts#L133-L135
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
DevToolsV6PluginAPI.getComponentInstances
getComponentInstances(app: App): Promise<ComponentInstance[]> { return this.hooks.callHook(DevToolsContextHookKeys.GET_COMPONENT_INSTANCES, { app }) }
// utilities
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/api/v6/index.ts#L138-L140
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
createRect
function createRect() { const rect = { top: 0, bottom: 0, left: 0, right: 0, get width() { return rect.right - rect.left }, get height() { return rect.bottom - rect.top }, } return rect }
// #region rect util
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/bounding-rect.ts#L6-L16
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
tryGetRefValue
function tryGetRefValue(ref: { _value?: unknown } | { value?: unknown }) { if (ensurePropertyExists<{ _value?: unknown }>(ref, '_value', true)) { return ref._value } if (ensurePropertyExists(ref, 'value', true)) { return ref.value } }
/** * - ObjectRefImpl, toRef({ foo: 'foo' }, 'foo'), `value` is the actual value * - GetterRefImpl, toRef(() => state.foo), `value` is the actual value * - RefImpl, ref('foo') / computed(() => 'foo'), `_value` is the actual value */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/custom.ts#L226-L233
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
resolveMergedOptions
function resolveMergedOptions( instance: VueAppInstance, ) { const raw = instance?.type if (!raw) return {} const { mixins, extends: extendsOptions } = raw const globalMixins = instance.appContext.mixins if (!globalMixins.length && !mixins && !extendsOptions) return raw const options = {} global...
// @TODO: maybe should be exported from vue core?
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/process.ts#L40-L54
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
processProps
function processProps(instance: VueAppInstance) { const props: InspectorState[] = [] const propDefinitions = instance?.type?.props for (const key in instance?.props) { const propDefinition = propDefinitions ? propDefinitions[key] : null const camelizeKey = camelize(key) props.push({ type: 'prop...
/** * Process the props of an instance. * Make sure return a plain object because window.postMessage() * will throw an Error if the passed object contains Functions. * */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/process.ts#L62-L89
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
processState
function processState(instance: VueAppInstance) { const type = instance.type const props = type?.props const getters = type.vuex && type.vuex.getters const computedDefs = type.computed const data = { ...instance.data, ...instance.renderContext, } return Object.keys(data) .filter(key ...
/** * Process state, filtering out props and "clean" the result * with a JSON dance. This removes functions which can cause * errors during structured clone used by window.postMessage. * */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/process.ts#L97-L122
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
processComputed
function processComputed(instance: VueAppInstance, mergedType: Record<string, unknown>) { const type = mergedType const computed: InspectorState[] = [] const defs = type.computed || {} // use for...in here because if 'computed' is not defined // on component, computed properties will be placed in prototype ...
/** * Process the computed properties of an instance. */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/state/process.ts#L195-L217
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentFilter.isQualified
isQualified(instance: VueAppInstance): boolean { const name = getInstanceName(instance) return classify(name).toLowerCase().includes(this.filter) || kebabize(name).toLowerCase().includes(this.filter) }
/** * Check if an instance is qualified. * * @param {Vue|Vnode} instance * @return {boolean} */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/filter.ts#L18-L22
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentWalker.capture
private async capture(instance: VueAppInstance, depth: number): Promise<ComponentTreeNode> { if (!instance) return null as unknown as ComponentTreeNode const id = this.captureId(instance)! const name = getInstanceName(instance) const children = this.getInternalInstanceChildren(instance.subTree)...
/** * Capture the meta information of an instance. (recursive) * * @param {Vue} instance * @return {object} */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/walker.ts#L79-L171
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentWalker.findQualifiedChildren
private async findQualifiedChildren(instance: VueAppInstance, depth: number): Promise<ComponentTreeNode[]> { if (this.componentFilter.isQualified(instance) && !instance.type.devtools?.hide) { return [await this.capture(instance, depth)] } else if (instance.subTree) { // TODO functional component...
/** * Find qualified children from a single instance. * If the instance itself is qualified, just return itself. * This is ok because [].concat works in both cases. * * @param {Vue|Vnode} instance * @return {Vue|Array} */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/walker.ts#L181-L195
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentWalker.findQualifiedChildrenFromList
private async findQualifiedChildrenFromList(instances: VueAppInstance[], depth: number): Promise<ComponentTreeNode[]> { instances = instances .filter(child => !isBeingDestroyed(child) && !child.type.devtools?.hide) if (!this.componentFilter.filter) return Promise.all(instances.map(child => this.capt...
/** * Iterate through an array of instances and flatten it into * an array of qualified instances. This is a depth-first * traversal - e.g. if an instance is not matched, we will * recursively go deeper until a qualified child is found. * * @param {Array} instances * @return {Array} */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/walker.ts#L206-L214
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentWalker.getInternalInstanceChildren
private getInternalInstanceChildren(subTree: VueAppInstance['subTree'], suspense: (SuspenseBoundary & { suspenseKey: string }) | null = null): VueAppInstance[] { const list: Array<VueAppInstance & { suspense?: SuspenseBoundary }> = [] if (subTree) { if (subTree.component) { !suspense ? list.push(s...
/** * Get children from a component instance. */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/walker.ts#L219-L240
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
ComponentWalker.mark
private mark(instance: VueAppInstance, force = false) { const instanceMap = getAppRecord(instance)!.instanceMap if (force || !instanceMap.has(instance.__VUE_DEVTOOLS_NEXT_UID__)) { instanceMap.set(instance.__VUE_DEVTOOLS_NEXT_UID__, instance) // force sync appRecord instanceMap activeAppRecor...
/** * Mark an instance as captured and store it in the instance map. * * @param {Vue} instance */
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/component/tree/walker.ts#L247-L255
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
getRoutes
function getRoutes(router?: Router) { const routesMap = new Map() return (router?.getRoutes() || []).filter(i => !routesMap.has(i.path) && routesMap.set(i.path, 1)) }
// import { DevToolsEvents, apiHooks } from '../../api/hook'
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/core/router/index.ts#L10-L13
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
updateAllStates
function updateAllStates() { callStateUpdatedHook({ ...global[STATE_KEY], appRecords: devtoolsAppRecords.value, activeAppRecordId: activeAppRecord.id, tabs: global.__VUE_DEVTOOLS_KIT_CUSTOM_TABS__, commands: global.__VUE_DEVTOOLS_KIT_CUSTOM_COMMANDS__, }) }
// @TODO: refactor
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/ctx/state.ts#L91-L99
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
isVueReactiveLinkNode
function isVueReactiveLinkNode(node) { const constructorName = node?.constructor?.name return (constructorName === 'Dep' && 'activeLink' in node) || (constructorName === 'Link' && 'dep' in node) }
// See https://github1s.com/vuejs/core/blob/HEAD/packages/reactivity/src/dep.ts#L32-L33
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/shared/transfer.ts#L15-L18
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
devtools
github_2023
vuejs
typescript
encode
function encode(data: unknown, replacer: Replacer | null, list: unknown[], seen: Map<unknown, number>, depth = 0, seenVueInstance = new Map<any, number>()): number { let stored: Record<string, number> | number[] let key: string let value: unknown let i: number let l: number const seenIndex = seen.get(data)...
/** * This function is used to serialize object with handling circular references. * * ```ts * const obj = { a: 1, b: { c: 2 }, d: obj } * const result = stringifyCircularAutoChunks(obj) // call `encode` inside * console.log(result) // [{"a":1,"b":2,"d":0},1,{"c":4},2] * ``` * * Each object is stored in a list...
https://github.com/vuejs/devtools/blob/93c6bb8bf738a66f81687a15a21a27194c4c7ba1/packages/devtools-kit/src/shared/transfer.ts#L36-L100
93c6bb8bf738a66f81687a15a21a27194c4c7ba1
documate
github_2023
aircodelabs
typescript
streamToString
async function streamToString(body: OpenAIResponseBody|null, assistantId: number) { const reader = body?.pipeThrough(new TextDecoderStream()).getReader(); while (reader) { const stream = await reader.read() if (stream.done) break const chunks = stream.value if ...
// eslint-disable-next-line no-inner-declarations
https://github.com/aircodelabs/documate/blob/b3a0c5210426f06cffef20380952f5c739b9c77b/ui/react/src/components/Documate/dialog.tsx#L107-L132
b3a0c5210426f06cffef20380952f5c739b9c77b
formsnap
github_2023
svecosystem
typescript
splitArrayPath
function splitArrayPath<T extends Record<string, unknown>>(name: string) { const [path, index] = name.split(/[[\]]/); return [path, index] as [FormPathArrays<T>, string]; }
// takes a string like "urls[0]" and returns ["urls", "0"]
https://github.com/svecosystem/formsnap/blob/0dbaf874913ef6f8fd54e0898f73af58fdbc6e46/packages/formsnap/src/lib/formsnap.svelte.ts#L441-L444
0dbaf874913ef6f8fd54e0898f73af58fdbc6e46
lobe-chat-agents
github_2023
lobehub
typescript
Builder.buildSingleLocaleAgents
private buildSingleLocaleAgents = (locale: string) => { const agentIndex: LobeAgent[] = []; for (const file of this.agents) { // if file is not json ,skip it if (!checkJSON(file)) continue; const { content, locale: defaultLocale, id } = Parser.parseFile(file.name); const localeFileName ...
/** * build single locale agents * @param locale */
https://github.com/lobehub/lobe-chat-agents/blob/f98dcf98185759ea73e71347b792e4f538233828/scripts/build.ts
f98dcf98185759ea73e71347b792e4f538233828
PeaNUT
github_2023
Brandawg93
typescript
testTimeout
const testTimeout = async (operation: Promise<any>, timeout: number = 100) => { jest.useFakeTimers() const promise = operation jest.advanceTimersByTime(timeout) await expect(promise).rejects.toThrow('Operation timeout') jest.useRealTimers() }
// Helper function for timeout tests
https://github.com/Brandawg93/PeaNUT/blob/096478eed00e379b478c2cdb6dce5ad46235ab8c/__tests__/unit/server/promise-socket.test.ts#L31-L37
096478eed00e379b478c2cdb6dce5ad46235ab8c
PeaNUT
github_2023
Brandawg93
typescript
mockSocketEvents
const mockSocketEvents = () => { const callbacks: Record<string, any> = {} mockSocket.on.mockImplementation((event: string, callback: any) => { callbacks[event] = callback }) return callbacks }
// Helper function for socket event mocking
https://github.com/Brandawg93/PeaNUT/blob/096478eed00e379b478c2cdb6dce5ad46235ab8c/__tests__/unit/server/promise-socket.test.ts#L40-L46
096478eed00e379b478c2cdb6dce5ad46235ab8c
PeaNUT
github_2023
Brandawg93
typescript
toMetricName
function toMetricName(key: string): string { // Convert to lowercase and replace dots/spaces with underscores return `ups_${key.toLowerCase().replace(/[\s.]/g, '_')}` }
/** * Retrieves device metrics in Prometheus format from the NUT server. * * @swagger * /api/v1/metrics: * get: * summary: Retrieves Prometheus metrics from all UPS devices * responses: * '200': * description: Successful response with Prometheus formatted metrics * content: * ...
https://github.com/Brandawg93/PeaNUT/blob/096478eed00e379b478c2cdb6dce5ad46235ab8c/src/app/api/v1/metrics/route.ts#L23-L26
096478eed00e379b478c2cdb6dce5ad46235ab8c
PeaNUT
github_2023
Brandawg93
typescript
isNumeric
function isNumeric(value: string | number): boolean { return !isNaN(Number(value)) }
// Helper function to check if value is numeric
https://github.com/Brandawg93/PeaNUT/blob/096478eed00e379b478c2cdb6dce5ad46235ab8c/src/app/api/v1/metrics/route.ts#L29-L31
096478eed00e379b478c2cdb6dce5ad46235ab8c
PeaNUT
github_2023
Brandawg93
typescript
createTask
const createTask = () => new Task('influx writer', () => { const taskSettings = new YamlSettings(settingsFile) const influxHost = taskSettings.get('INFLUX_HOST') const influxToken = taskSettings.get('INFLUX_TOKEN') const influxOrg = taskSettings.get('INFLUX_ORG') const influxBucket = taskSettings....
// Define the task to write data to InfluxDB
https://github.com/Brandawg93/PeaNUT/blob/096478eed00e379b478c2cdb6dce5ad46235ab8c/src/server/scheduler.ts#L18-L38
096478eed00e379b478c2cdb6dce5ad46235ab8c
haha-funny-leetcode-extension
github_2023
The-CodingSloth
typescript
updateProblemSolvedState
async function updateProblemSolvedState(isSolved: boolean) { await storage.set("leetCodeProblemSolved", isSolved) }
// TODO: Maybe this needs to be exported for clarity (instead of being used in updateProblem and updateStreak)
https://github.com/The-CodingSloth/haha-funny-leetcode-extension/blob/2a0cf9e81226734b75ec1e2968866120232c9843/storage.ts#L42-L44
2a0cf9e81226734b75ec1e2968866120232c9843
biliLive-tools
github_2023
renmu123
typescript
sortAndFilterSourcesByPriority
function sortAndFilterSourcesByPriority( sources: SourceProfile[], sourcePriorities: Recorder["sourcePriorities"], ): (SourceProfile & { priority: number; })[] { if (sourcePriorities.length === 0) return []; return sortBy( // 分配优先级属性,数字越大优先级越高 sources .map((source) => ({ ...source, ...
/** * 按提供的源优先级去给源列表排序,并过滤掉不在优先级配置中的源 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/BilibiliRecorder/src/stream.ts#L168-L186
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
sortAndFilterStreamsByPriority
function sortAndFilterStreamsByPriority( streams: StreamProfile[], streamPriorities: Recorder["streamPriorities"], ): (StreamProfile & { priority: number; })[] { if (streamPriorities.length === 0) return []; return sortBy( // 分配优先级属性,数字越大优先级越高 streams .map((stream) => ({ ...stream, ...
/** * 按提供的流优先级去给流列表排序,并过滤掉不在优先级配置中的流 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/DouYuRecorder/src/stream.ts#L160-L178
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
sortAndFilterSourcesByPriority
function sortAndFilterSourcesByPriority( sources: SourceProfile[], sourcePriorities: Recorder["sourcePriorities"], ): (SourceProfile & { priority: number; })[] { if (sourcePriorities.length === 0) return []; return sortBy( // 分配优先级属性,数字越大优先级越高 sources .map((source) => ({ ...source, ...
/** * 按提供的源优先级去给源列表排序,并过滤掉不在优先级配置中的源 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/DouYuRecorder/src/stream.ts#L183-L200
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
sortAndFilterStreamsByPriority
function sortAndFilterStreamsByPriority( streams: StreamProfile[], streamPriorities: Recorder["streamPriorities"], ): (StreamProfile & { priority: number; })[] { if (streamPriorities.length === 0) return []; return sortBy( // 分配优先级属性,数字越大优先级越高 streams .map((stream) => ({ ...stream, ...
/** * 按提供的流优先级去给流列表排序,并过滤掉不在优先级配置中的流 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/HuYaRecorder/src/stream.ts#L75-L93
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
sortAndFilterSourcesByPriority
function sortAndFilterSourcesByPriority( sources: SourceProfile[], sourcePriorities: Recorder["sourcePriorities"], ): (SourceProfile & { priority: number; })[] { if (sourcePriorities.length === 0) return []; return sortBy( // 分配优先级属性,数字越大优先级越高 sources .map((source) => ({ ...source, ...
/** * 按提供的源优先级去给源列表排序,并过滤掉不在优先级配置中的源 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/HuYaRecorder/src/stream.ts#L98-L116
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
quit
const quit = async () => { try { Object.assign( windowConfig, { isMaximized: mainWin.isMaximized(), }, mainWin.getNormalBounds(), ); WindowState.set("winBounds", windowConfig); // saves window's properties using electron-store const canQuited = await canQuit(); if...
// 退出应用时检测任务
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/main/index.ts#L338-L361
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
appInit
const appInit = async () => { fs.ensureDir(getTempPath()); const { APP_CONFIG_PATH, FFMPEG_PRESET_PATH, VIDEO_PRESET_PATH, DANMU_PRESET_PATH, userDataPath, } = await getConfigPath(); const globalConfig: GlobalConfig = { videoPresetPath: VIDEO_PRESET_PATH, ffmpegPresetPath: FFMPEG_P...
// 业务相关的初始化
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/main/index.ts#L450-L492
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
infoList
const infoList = async ( params: RecorderAPI["getRecorders"]["Args"], ): Promise<RecorderAPI["getRecorders"]["Resp"]> => { const res = await request.get(`/recorder/list`, { params }); return res.data.payload; };
/** * 获取录制器列表,非配置信息 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/recoder.ts#L9-L14
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
get
const get = async (id: string): Promise<LocalRecordr> => { const res = await request.get(`/recorder/${id}`); return res.data.payload; };
/** * 获取录制器配置信息 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/recoder.ts#L19-L22
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
list
const list = async (params: { type?: string; }): Promise<{ list: Task[]; runningTaskNum: number }> => { const res = await request.get(`/task`, { params }); return res.data; };
/** * 获取任务列表 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/task.ts#L9-L14
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
get
const get = async (id: string): Promise<Task> => { const res = await request.get(`/task/${id}`); return res.data; };
/** * 获取任务 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/task.ts#L19-L22
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
removeBatch
const removeBatch = async (ids: string[]): Promise<string> => { const res = await request.post(`/task/removeBatch`, { ids }); return res.data; };
// 批量删除
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/task.ts#L49-L52
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
refresh
const refresh = async (uid: number) => { const res = await request.post(`/user/update`, { uid, }); return res.data; };
/** * @description Refresh user info */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/user.ts#L21-L26
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
deleteUser
const deleteUser = async (uid: number) => { const res = await request.post(`/user/delete`, { uid, }); return res.data; };
/** * @description Delete user */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/apis/user.ts#L31-L36
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
draw
const draw = async (options: { width: number; height: number; sampling: number; duration: number; }) => { let fData = ininData.sort((a, b) => a - b); const countData = countByIntervalInSeconds(fData, options.sampling, art.duration); danmaPoints = normalizePo...
/** * 生成高能弹幕进度条所需参数 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/components/Artplayer/artplayer-plugin-heatmap.ts#L136-L161
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
drawSmoothCurve
function drawSmoothCurve( canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D, width: number, ) { if (danmaPoints.length === 0) return; ctx.clearRect(0, 0, canvas.width, canvas.height); // 绘制红色部分 ctx.save(); ctx.beginPath(); ctx.rect(0...
/** * 绘制平滑曲线 * @param points 点集 * @param ctx 画布上下文 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/components/Artplayer/artplayer-plugin-heatmap.ts#L168-L192
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
importProject
const importProject = async () => { const files = await window.api.openFile({ multi: false, filters: [ { name: "file", extensions: ["llc"], }, ], }); if (!files) return; const file = files[0]; handleProject(file); };
/** * 导入项目文件 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L18-L31
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
handleProject
const handleProject = async (file: string) => { llcProjectPath.value = file; const data = JSON5.parse(await window.api.common.readFile(file)); init( data.cutSegments.map((item: any) => { return { ...item, checked: true, }; }), ); const mediaFileName = ...
/** * 处理项目文件 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L36-L49
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
loadProject
const loadProject = async () => { if (options.value.find((item) => item.key === "refresh")?.disabled) return; clearHistory(); handleProject(llcProjectPath.value); };
/** * 从本地重新加载项目文件,项目文件可能已经被更新 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L54-L59
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
saveProject
const saveProject = async () => { if (options.value.find((item) => item.key === "save")?.disabled) return; save(); };
/** * 保存项目按钮 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L64-L68
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
save
const save = async () => { const mediaFileName = mediaPath.value || files.value.videoPath; if (!mediaFileName) { notice.error({ title: "请先选择视频文件", duration: 2000, }); return; } const projectData = { version: 1, mediaFileName: window.path.basename(mediaFileNa...
/** * 保存项目 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L73-L89
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0
biliLive-tools
github_2023
renmu123
typescript
openProject
const openProject = async () => { if (!llcProjectPath.value) { return; } if (appConfig.value.losslessCutPath) { // 使用用户设置的lossless-cut路径打开项目文件 window.api.common.execFile(appConfig.value.losslessCutPath, [llcProjectPath.value]); console.log("openProject", appConfig.value.losslessCutPa...
/** * 使用lossless-cut打开项目文件 */
https://github.com/renmu123/biliLive-tools/blob/9f087eae07db85a57851ec9d9cf2f0bb304bb1d0/packages/app/src/renderer/src/pages/Tools/pages/VideoCut/hooks/index.ts#L94-L109
9f087eae07db85a57851ec9d9cf2f0bb304bb1d0