text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```xml import { type ConfigPlugin } from 'expo/config-plugins'; interface PatchPluginProps { /** The directory to search for patch files in. */ patchRoot?: string; /** The maximum changed lines allowed in the patch file, if exceeded the patch will show a warning. */ changedLinesLimit?: number; } export declare const withPatchPlugin: ConfigPlugin<PatchPluginProps | undefined>; export default withPatchPlugin; ```
/content/code_sandbox/packages/patch-project/build/withPatchPlugin.d.ts
xml
2016-08-15T17:14:25
2024-08-16T19:54:44
expo
expo/expo
32,004
88
```xml /*your_sha256_hash----------------------------- *your_sha256_hash----------------------------*/ import * as vscode from 'vscode'; import * as LocalizedConstants from '../constants/localizedConstants'; import * as Constants from '../constants/constants'; import { TreeNodeInfo } from './treeNodeInfo'; export class ConnectTreeNode extends vscode.TreeItem { constructor( private _parentNode: TreeNodeInfo ) { super(LocalizedConstants.msgConnect, vscode.TreeItemCollapsibleState.None); this.command = { title: LocalizedConstants.msgConnect, command: Constants.cmdConnectObjectExplorerNode, arguments: [this] }; } public get parentNode(): TreeNodeInfo { return this._parentNode; } } export type TreeNodeType = | TreeNodeInfo | ConnectTreeNode; ```
/content/code_sandbox/src/objectExplorer/connectTreeNode.ts
xml
2016-06-26T04:38:04
2024-08-16T20:04:12
vscode-mssql
microsoft/vscode-mssql
1,523
162
```xml // Adapted from path_to_url (function ($: JQueryStatic): void { $.extend(true, window, { 'Slick': { 'AutoColumnSize': autoColumnSize } }); function autoColumnSize(maxWidth): any { let grid: any; let $container: JQuery; let context: CanvasRenderingContext2D; function init(_grid): void { grid = _grid; maxWidth = maxWidth || 200; $container = $(grid.getContainerNode()); $container.on('dblclick.autosize', '.slick-resizable-handle', reSizeColumn); context = document.createElement('canvas').getContext('2d'); } function destroy(): void { $container.off(); } function reSizeColumn(e): void { let headerEl = $(e.currentTarget).closest('.slick-header-column'); let columnDef = headerEl.data('column'); if (!columnDef || !columnDef.resizable) { return; } e.preventDefault(); e.stopPropagation(); let headerWidth = getElementWidth(headerEl[0]); let colIndex = grid.getColumnIndex(columnDef.id); let origCols = grid.getColumns(); let allColumns = JSON.parse(JSON.stringify(origCols)); for (let [index, col] of allColumns.entries()) { col.formatter = origCols[index].formatter; col.asyncPostRender = origCols[index].asyncPostRender; } let column = allColumns[colIndex]; let autoSizeWidth = Math.max(headerWidth, getMaxColumnTextWidth(columnDef, colIndex)) + 1; if (autoSizeWidth !== column.width) { allColumns[colIndex].width = autoSizeWidth; grid.setColumns(allColumns); grid.onColumnsResized.notify(); } } function getMaxColumnTextWidth(columnDef, colIndex): number { let texts = []; let rowEl = createRow(columnDef); let data = grid.getData(); let viewPort = grid.getViewport(); let start = Math.max(0, viewPort.top + 1); let end = Math.min(data.getLength(), viewPort.bottom); for (let i = start; i < end; i++) { texts.push(data.getItem(i)[columnDef.field]); } let template = getMaxTextTemplate(texts, columnDef, colIndex, data, rowEl); let width = getTemplateWidth(rowEl, template); deleteRow(rowEl); return width; } function getTemplateWidth(rowEl, template): number { let cell = $(rowEl.find('.slick-cell')); cell.append(template); $(cell).find('*').css('position', 'relative'); return cell.outerWidth() + 1; } function getMaxTextTemplate(texts, columnDef, colIndex, data, rowEl): any { let max = 0, maxTemplate = undefined; let formatFun = columnDef.formatter; $.each<string>(texts, function (index, text): void { let template: JQuery; if (formatFun) { template = $('<span>' + formatFun(index, colIndex, text, columnDef, data[index]) + '</span>'); text = template.text() || text; } let length = text ? getElementWidthUsingCanvas(rowEl, text) : 0; if (length > max) { max = length; maxTemplate = template || text; } }); return maxTemplate; } function createRow(columnDef): JQuery { let rowEl = $('<div class="slick-row"><div class="slick-cell"></div></div>'); rowEl.find('.slick-cell').css({ 'visibility': 'hidden', 'text-overflow': 'initial', 'white-space': 'nowrap' }); let gridCanvas = $container.find('.grid-canvas'); $(gridCanvas).append(rowEl); return rowEl; } function deleteRow(rowEl): void { $(rowEl).remove(); } function getElementWidth(element): number { let width, clone = element.cloneNode(true); clone.style.cssText = 'position: absolute; visibility: hidden;right: auto;text-overflow: initial;white-space: nowrap;'; element.parentNode.insertBefore(clone, element); width = clone.offsetWidth; clone.parentNode.removeChild(clone); return width; } function getElementWidthUsingCanvas(element, text): number { context.font = element.css('font-size') + ' ' + element.css('font-family'); let metrics = context.measureText(text); return metrics.width; } return { init: init, destroy: destroy }; } }(jQuery)); ```
/content/code_sandbox/src/views/htmlcontent/src/js/slick.autosizecolumn.ts
xml
2016-06-26T04:38:04
2024-08-16T20:04:12
vscode-mssql
microsoft/vscode-mssql
1,523
1,033
```xml <vector xmlns:android="path_to_url" xmlns:aapt="path_to_url" android:width="48dp" android:height="48dp" android:viewportWidth="48" android:viewportHeight="48"> <path android:pathData="M37,6H11C9.343,6 8,7.343 8,9V39C8,40.657 9.343,42 11,42H37C38.657,42 40,40.657 40,39V9C40,7.343 38.657,6 37,6ZM10,9C10,8.448 10.448,8 11,8H37C37.552,8 38,8.448 38,9V39C38,39.552 37.552,40 37,40H11C10.448,40 10,39.552 10,39V9ZM22.703,30V25.866H23.992C25.442,25.866 26.601,25.494 27.469,24.749C28.336,24.004 28.77,23.029 28.77,21.824C28.77,19.275 27.258,18 24.234,18H20V30H22.703ZM22.703,23.816V20.075H23.766C25.205,20.075 25.925,20.692 25.925,21.925C25.925,23.185 25.205,23.816 23.766,23.816H22.703Z" android:fillType="evenOdd"> <aapt:attr name="android:fillColor"> <gradient android:startX="24" android:startY="6" android:endX="24" android:endY="42" android:type="linear"> <item android:offset="0" android:color="#FFFB6361"/> <item android:offset="1" android:color="#FFF23433"/> </gradient> </aapt:attr> </path> </vector> ```
/content/code_sandbox/icon-pack/src/main/res/drawable/ic_powerpoint_thumbnail_outline.xml
xml
2016-05-04T11:46:20
2024-08-15T16:29:10
android
meganz/android
1,537
487
```xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="path_to_url"> <item android:id="@+id/popup_song_detail" android:title="" /> <item android:id="@+id/popup_add_playlist" android:title="" /> <item android:id="@+id/popup_song_download" android:title="" /> </menu> ```
/content/code_sandbox/app/src/main/res/menu/popup_song_online.xml
xml
2016-04-09T15:47:45
2024-08-14T04:30:04
MusicLake
caiyonglong/MusicLake
2,654
88
```xml export default async () => { /** * The code to be executed should be placed within a default function that is * exported by the global script. Ensure all of the code in the global script * is wrapped in the function() that is exported. */ }; ```
/content/code_sandbox/packages/static-build/test/fixtures/stencil-v1/src/global/app.ts
xml
2016-09-09T01:12:08
2024-08-16T17:39:45
vercel
vercel/vercel
12,545
59
```xml /** * This file is part of OpenMediaVault. * * @license path_to_url GPL Version 3 * @author Volker Theile <volker.theile@openmediavault.org> * * OpenMediaVault is free software: you can redistribute it and/or modify * any later version. * * OpenMediaVault is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ import { HttpErrorResponse } from '@angular/common/http'; import { Component, Inject, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { marker as gettext } from '@ngneat/transloco-keys-manager/marker'; import * as _ from 'lodash'; import { EMPTY } from 'rxjs'; import { catchError, finalize } from 'rxjs/operators'; import { AbstractPageComponent } from '~/app/core/components/intuition/abstract-page-component'; import { RrdPageConfig, RrdPageGraphConfig } from '~/app/core/components/intuition/models/rrd-page-config.type'; import { format, formatDeep, unixTimeStamp } from '~/app/functions.helper'; import { Icon } from '~/app/shared/enum/icon.enum'; import { AuthSessionService } from '~/app/shared/services/auth-session.service'; import { BlockUiService } from '~/app/shared/services/block-ui.service'; import { DataStoreService } from '~/app/shared/services/data-store.service'; import { RpcService } from '~/app/shared/services/rpc.service'; @Component({ selector: 'omv-intuition-rrd-page', templateUrl: './rrd-page.component.html', styleUrls: ['./rrd-page.component.scss'] }) export class RrdPageComponent extends AbstractPageComponent<RrdPageConfig> implements OnInit { public monitoringEnabled = true; public error: HttpErrorResponse; public icon = Icon; public loading = false; public time: number; public tabs: Array<{ label: string; graphs: Array<RrdPageGraphConfig>; }> = []; public monitoringDisabledMessage: string = gettext( "System monitoring is disabled. To enable it, please go to the <a href='#/system/monitoring'>settings page</a>." ); constructor( @Inject(ActivatedRoute) activatedRoute: ActivatedRoute, @Inject(AuthSessionService) authSessionService: AuthSessionService, @Inject(Router) router: Router, private blockUiService: BlockUiService, private dataStoreService: DataStoreService, private rpcService: RpcService ) { super(activatedRoute, authSessionService, router); // Check if monitoring is enabled. this.rpcService.request('PerfStats', 'get').subscribe((resp) => { this.monitoringEnabled = _.get(resp, 'enable', false); }); } override ngOnInit(): void { super.ngOnInit(); this.time = unixTimeStamp(); if (this.config?.store) { this.loading = true; this.dataStoreService .load(this.config.store) .pipe( catchError((error) => { this.error = error; return EMPTY; }), finalize(() => { this.loading = false; }) ) .subscribe(() => { _.forEach(this.config.store.data, (item: Record<any, any>) => { const label = format(this.config.label, item); const graphs: RrdPageGraphConfig[] = _.map( this.config.graphs, (graph: RrdPageGraphConfig) => formatDeep(graph, item) as RrdPageGraphConfig ); this.tabs.push({ label, graphs }); }); }); } } onGenerate() { this.blockUiService.start(gettext('Please wait, the statistic graphs will be regenerated ...')); this.rpcService .requestTask('Rrd', 'generate') .pipe( finalize(() => { this.blockUiService.stop(); }) ) .subscribe(() => { // Force redrawing the images. this.time = unixTimeStamp(); }); } } ```
/content/code_sandbox/deb/openmediavault/workbench/src/app/core/components/intuition/rrd-page/rrd-page.component.ts
xml
2016-05-03T10:35:34
2024-08-16T08:03:04
openmediavault
openmediavault/openmediavault
4,954
880
```xml import { compose } from '@fluentui/react-bindings'; import { commonPropTypes } from '../../utils'; import { Box, BoxProps, BoxStylesProps } from '../Box/Box'; export interface AttachmentIconOwnProps {} export interface AttachmentIconProps extends AttachmentIconOwnProps, BoxProps {} export type AttachmentIconStylesProps = never; export const attachmentIconClassName = 'ui-attachment__icon'; /** * An AttachmentIcon provides a slot for a glyph that describes content in the Attachment. */ export const AttachmentIcon = compose< 'span', AttachmentIconOwnProps, AttachmentIconStylesProps, BoxProps, BoxStylesProps >(Box, { className: attachmentIconClassName, displayName: 'AttachmentIcon', overrideStyles: true, shorthandConfig: { mappedProp: 'content', }, }); AttachmentIcon.defaultProps = { as: 'span', }; AttachmentIcon.propTypes = commonPropTypes.createCommon(); ```
/content/code_sandbox/packages/fluentui/react-northstar/src/components/Attachment/AttachmentIcon.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
194
```xml import { nextTestSetup } from 'e2e-utils' import { findAllTelemetryEvents } from 'next-test-utils' // Turbopack hasn't fully enabled this option yet ;(process.env.TURBOPACK ? describe.skip : describe)( 'next-config-warnings - esm-externals-false', () => { const { next, isNextStart } = nextTestSetup({ files: __dirname, env: { NEXT_TELEMETRY_DEBUG: '1', }, }) it('should warn when using ESM externals: false', async () => { await next.fetch('/') expect(next.cliOutput).toContain( `The "experimental.esmExternals" option has been modified. experimental.esmExternals is not recommended to be modified as it may disrupt module resolution. Please update your next.config.js` ) }) if (isNextStart) { it('should contain esmExternals feature usage in telemetry', async () => { const featureUsageEvents = findAllTelemetryEvents( next.cliOutput, 'NEXT_BUILD_FEATURE_USAGE' ) expect(featureUsageEvents).toContainEqual({ featureName: 'esmExternals', invocationCount: 1, }) }) } } ) ```
/content/code_sandbox/test/e2e/next-config-warnings/esm-externals-false/esm-externals-false.test.ts
xml
2016-10-05T23:32:51
2024-08-16T19:44:30
next.js
vercel/next.js
124,056
274
```xml import { Base64String } from '@standardnotes/sncrypto-common' export type AsymmetricallyEncryptedString = Base64String export type SymmetricallyEncryptedString = Base64String ```
/content/code_sandbox/packages/encryption/src/Domain/Operator/Types/Types.ts
xml
2016-12-05T23:31:33
2024-08-16T06:51:19
app
standardnotes/app
5,180
42
```xml import { gql } from '@apollo/client'; import * as compose from 'lodash.flowright'; import { graphql } from '@apollo/client/react/hoc'; import React from 'react'; import { Alert, withProps } from '@erxes/ui/src/utils'; import Spinner from '@erxes/ui/src/components/Spinner'; import UpdateConfigs from '../components/UpdateConfigs'; import { mutations, queries } from '../graphql'; import { IConfigsMap } from '@erxes/ui-settings/src/general/types'; type Props = { history: any; }; type FinalProps = { getConfigsQuery: any; updateConfigsMutation: (configsMap: IConfigsMap) => Promise<void>; } & Props; const ConfigsContainer = (props: FinalProps) => { const { getConfigsQuery, updateConfigsMutation } = props; if (getConfigsQuery.loading) { return <Spinner />; } const configs = getConfigsQuery.callsGetConfigs; const configsMap = {}; for (const config of configs) { configsMap[config.code] = config.value; } const updateConfigs = (value: IConfigsMap) => { updateConfigsMutation({ variables: { configsMap: value } }) .then(() => { Alert.success('Successfully updated configs'); getConfigsQuery.refetch(); }) .catch((e) => Alert.error(e.message)); }; const updatedProps = { loading: getConfigsQuery.loading, updateConfigs, configsMap, }; return <UpdateConfigs {...updatedProps} />; }; export default withProps<Props>( compose( graphql(gql(queries.callsGetConfigs), { name: 'getConfigsQuery', options: () => ({ fetchPolicy: 'network-only', variables: { kind: 'calls' }, }), }), graphql(gql(mutations.callsUpdateConfigs), { name: 'updateConfigsMutation', }), )(ConfigsContainer), ); ```
/content/code_sandbox/packages/plugin-calls-ui/src/containers/UpdateConfigsContainer.tsx
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
409
```xml import { Expose } from 'class-transformer'; export class GraphPosition { @Expose({name: 'id_'}) id: string; x: number; y: number; } ```
/content/code_sandbox/api/client/src/app/models/playbook/graphPosition.ts
xml
2016-06-08T16:34:46
2024-08-16T18:12:30
WALKOFF
nsacyber/WALKOFF
1,198
40
```xml /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at path_to_url */ import { ApplicationRef, ComponentFactoryResolver, ComponentRef, EmbeddedViewRef, Injector, } from '@angular/core'; import {BasePortalOutlet, ComponentPortal, DomPortal, TemplatePortal} from './portal'; /** * A PortalOutlet for attaching portals to an arbitrary DOM element outside of the Angular * application context. */ export class DomPortalOutlet extends BasePortalOutlet { private _document: Document; /** * @param outletElement Element into which the content is projected. * @param _componentFactoryResolver Used to resolve the component factory. * Only required when attaching component portals. * @param _appRef Reference to the application. Only used in component portals when there * is no `ViewContainerRef` available. * @param _defaultInjector Injector to use as a fallback when the portal being attached doesn't * have one. Only used for component portals. * @param _document Reference to the document. Used when attaching a DOM portal. Will eventually * become a required parameter. */ constructor( /** Element into which the content is projected. */ public outletElement: Element, private _componentFactoryResolver?: ComponentFactoryResolver, private _appRef?: ApplicationRef, private _defaultInjector?: Injector, /** * @deprecated `_document` Parameter to be made required. * @breaking-change 10.0.0 */ _document?: any, ) { super(); this._document = _document; } /** * Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver. * @param portal Portal to be attached * @returns Reference to the created component. */ attachComponentPortal<T>(portal: ComponentPortal<T>): ComponentRef<T> { const resolver = (portal.componentFactoryResolver || this._componentFactoryResolver)!; if ((typeof ngDevMode === 'undefined' || ngDevMode) && !resolver) { throw Error('Cannot attach component portal to outlet without a ComponentFactoryResolver.'); } const componentFactory = resolver.resolveComponentFactory(portal.component); let componentRef: ComponentRef<T>; // If the portal specifies a ViewContainerRef, we will use that as the attachment point // for the component (in terms of Angular's component tree, not rendering). // When the ViewContainerRef is missing, we use the factory to create the component directly // and then manually attach the view to the application. if (portal.viewContainerRef) { componentRef = portal.viewContainerRef.createComponent( componentFactory, portal.viewContainerRef.length, portal.injector || portal.viewContainerRef.injector, portal.projectableNodes || undefined, ); this.setDisposeFn(() => componentRef.destroy()); } else { if ((typeof ngDevMode === 'undefined' || ngDevMode) && !this._appRef) { throw Error('Cannot attach component portal to outlet without an ApplicationRef.'); } componentRef = componentFactory.create( portal.injector || this._defaultInjector || Injector.NULL, ); this._appRef!.attachView(componentRef.hostView); this.setDisposeFn(() => { // Verify that the ApplicationRef has registered views before trying to detach a host view. // This check also protects the `detachView` from being called on a destroyed ApplicationRef. if (this._appRef!.viewCount > 0) { this._appRef!.detachView(componentRef.hostView); } componentRef.destroy(); }); } // At this point the component has been instantiated, so we move it to the location in the DOM // where we want it to be rendered. this.outletElement.appendChild(this._getComponentRootNode(componentRef)); this._attachedPortal = portal; return componentRef; } /** * Attaches a template portal to the DOM as an embedded view. * @param portal Portal to be attached. * @returns Reference to the created embedded view. */ attachTemplatePortal<C>(portal: TemplatePortal<C>): EmbeddedViewRef<C> { let viewContainer = portal.viewContainerRef; let viewRef = viewContainer.createEmbeddedView(portal.templateRef, portal.context, { injector: portal.injector, }); // The method `createEmbeddedView` will add the view as a child of the viewContainer. // But for the DomPortalOutlet the view can be added everywhere in the DOM // (e.g Overlay Container) To move the view to the specified host element. We just // re-append the existing root nodes. viewRef.rootNodes.forEach(rootNode => this.outletElement.appendChild(rootNode)); // Note that we want to detect changes after the nodes have been moved so that // any directives inside the portal that are looking at the DOM inside a lifecycle // hook won't be invoked too early. viewRef.detectChanges(); this.setDisposeFn(() => { let index = viewContainer.indexOf(viewRef); if (index !== -1) { viewContainer.remove(index); } }); this._attachedPortal = portal; // TODO(jelbourn): Return locals from view. return viewRef; } /** * Attaches a DOM portal by transferring its content into the outlet. * @param portal Portal to be attached. * @deprecated To be turned into a method. * @breaking-change 10.0.0 */ override attachDomPortal = (portal: DomPortal) => { // @breaking-change 10.0.0 Remove check and error once the // `_document` constructor parameter is required. if (!this._document && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('Cannot attach DOM portal without _document constructor parameter'); } const element = portal.element; if (!element.parentNode && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('DOM portal content must be attached to a parent node.'); } // Anchor used to save the element's previous position so // that we can restore it when the portal is detached. const anchorNode = this._document.createComment('dom-portal'); element.parentNode!.insertBefore(anchorNode, element); this.outletElement.appendChild(element); this._attachedPortal = portal; super.setDisposeFn(() => { // We can't use `replaceWith` here because IE doesn't support it. if (anchorNode.parentNode) { anchorNode.parentNode.replaceChild(element, anchorNode); } }); }; /** * Clears out a portal from the DOM. */ override dispose(): void { super.dispose(); this.outletElement.remove(); } /** Gets the root HTMLElement for an instantiated component. */ private _getComponentRootNode(componentRef: ComponentRef<any>): HTMLElement { return (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement; } } /** * @deprecated Use `DomPortalOutlet` instead. * @breaking-change 9.0.0 */ export class DomPortalHost extends DomPortalOutlet {} ```
/content/code_sandbox/src/cdk/portal/dom-portal-outlet.ts
xml
2016-01-04T18:50:02
2024-08-16T11:21:13
components
angular/components
24,263
1,568
```xml <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFrameworks>net452;net472</TargetFrameworks> <RootNamespace>Asp.Versioning</RootNamespace> </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net452' "> <Compile Include="$(BackportDir)Array.cs" Visible="false" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\src\Asp.Versioning.WebApi.OData.ApiExplorer\Asp.Versioning.WebApi.OData.ApiExplorer.csproj" /> </ItemGroup> <ItemGroup> <Reference Include="System.ComponentModel.DataAnnotations" /> </ItemGroup> <Import Project="..\..\..\..\Common\test\Common.OData.ApiExplorer.Tests\Common.OData.ApiExplorer.Tests.projitems" Label="Shared" /> </Project> ```
/content/code_sandbox/src/AspNet/OData/test/Asp.Versioning.WebApi.OData.ApiExplorer.Tests/Asp.Versioning.WebApi.OData.ApiExplorer.Tests.csproj
xml
2016-07-26T14:13:32
2024-08-15T14:35:11
aspnet-api-versioning
dotnet/aspnet-api-versioning
3,024
176
```xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="path_to_url" xmlns:tools="path_to_url" android:installLocation="internalOnly"> <application> <activity android:name=".HiltTestActivity" android:exported="false" /> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" tools:node="merge" tools:replace="android:authorities"> <meta-data android:name="mega.privacy.android.app.initializer.NocturnInitializer" android:value="androidx.startup" /> <meta-data android:name="mega.privacy.android.app.initializer.KarmaInitializer" android:value="androidx.startup" /> </provider> </application> </manifest> ```
/content/code_sandbox/app/src/debug/AndroidManifest.xml
xml
2016-05-04T11:46:20
2024-08-15T16:29:10
android
meganz/android
1,537
196
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ** ** ** Unless required by applicable law or agreed to in writing, software ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <resources> <string name="twofortyfouram_locale_breadcrumb_format">%1$s%2$s%3$s</string> <string name="twofortyfouram_locale_breadcrumb_separator">\u0020&gt;\u0020</string> <string name="twofortyfouram_locale_menu_dontsave">Avbryt</string> <string name="twofortyfouram_locale_menu_help">Hjlp</string> <string name="twofortyfouram_locale_menu_save">Klar</string> </resources> ```
/content/code_sandbox/localeapi/src/main/res/values-sv/strings-sv.xml
xml
2016-09-23T13:33:17
2024-08-15T09:51:19
xDrip
NightscoutFoundation/xDrip
1,365
172
```xml import { Component } from '@angular/core'; import { TemplateConfigurationModule } from 'src/app/showcase/layout/templates/templateconfiguration'; import { TemplateFeaturesModule } from 'src/app/showcase/layout/templates/templatefeatures'; import { TemplateFeaturesAnimationModule } from 'src/app/showcase/layout/templates/templatefeaturesanimation/templatefeaturesanimation'; import { TemplateHeroModule } from 'src/app/showcase/layout/templates/templatehero/templatehero'; import { TemplateRelatedModule } from 'src/app/showcase/layout/templates/templaterelated'; import { TemplateSeparatorModule } from 'src/app/showcase/layout/templates/templateseparator'; import { TemplateYoutubeModule } from 'src/app/showcase/layout/templates/templateyoutube'; import { ApolloLogo } from './apollologo'; import { ApolloSeparator } from './apolloseparator'; @Component({ standalone: true, selector: 'apollo-page', imports: [ TemplateHeroModule, TemplateSeparatorModule, TemplateFeaturesAnimationModule, TemplateFeaturesModule, TemplateConfigurationModule, TemplateFeaturesAnimationModule, TemplateRelatedModule, TemplateYoutubeModule, ApolloSeparator ], template: `<div class="apollo template"> <template-hero [templateHeroData]="templateHeroData" [templateLogo]="apolloLogo"></template-hero> <div [style.display]="'none'"> <apollo-separator></apollo-separator> <template-youtube imgSrc="path_to_url"></template-youtube> </div> <apollo-separator></apollo-separator> <template-license [license]="license"></template-license> <apollo-separator></apollo-separator> <template-features-animation [featuresData]="animationFeaturesData2" title="Features" displayType="horizontal"></template-features-animation> <apollo-separator></apollo-separator> <template-configuration title="Angular with CLI" description="Apollo is powered by Angular CLI to get started in no time following the best practices like service based component interaction modular design and strict mode support" ></template-configuration> <apollo-separator></apollo-separator> <template-features-animation [featuresData]="animationFeaturesData1"></template-features-animation> <apollo-separator></apollo-separator> <template-features [featuresData]="apolloFeatures2Data" displayType="vertical"></template-features> </div>` }) export class ApolloPage { apolloLogo = ApolloLogo; templateHeroData = { pattern: 'path_to_url dashboard1: 'path_to_url dashboard2: 'path_to_url description: 'An amazing Angular CLI application template with light-dim-dark modes, four menu layouts, various menu themes, sample apps, ready to use template pages and 24 PrimeNG themes.', liveHref: 'path_to_url docHref: 'path_to_url }; apolloRelatedData = [ { src: 'path_to_url href: '/templates/diamond' }, { src: 'path_to_url href: '/templates/avalon' }, { src: 'path_to_url href: '/templates/freya' } ]; apolloFeatures2Data = [ { title: 'Fully Responsive', description: 'Apollo is crafted to provide optimal viewing and interaction experience for a wide range of devices.', src: 'path_to_url }, { title: 'Support', description: `PrimeTek offers assistance with account management and licensing issues, with the expectation that users have the necessary technical knowledge to use our products, as we do not offer technical support or consulting. Users can seek assistance in our community via our public Discord and Forum.`, src: 'path_to_url }, { title: 'Top Notch Quality', description: 'Superior standards with 100% compatibility for strict mode and linting tools.', src: 'path_to_url darkSrc: 'path_to_url }, { title: 'Cross Browser Compatible', description: 'First class support for Firefox, Safari, Chrome and Edge.', src: 'path_to_url darkSrc: 'path_to_url }, { title: 'Customizable Design', description: 'Fully customizable with a mixture of Sass and CSS variables.', src: 'path_to_url darkSrc: 'path_to_url }, { title: 'Mobile Experience', description: 'Touch optimized enhanced mobile experience with responsive design.', src: 'path_to_url } ]; animationFeaturesData1 = [ { id: 1, title: 'PrimeFlex CSS Utilities', width: 1440, height: 1789, description: 'PrimeFlex is a CSS utility library featuring various helpers such as a grid system, flexbox, spacing, elevation and more.', src: 'path_to_url }, { id: 2, title: 'PrimeBlocks', width: 1440, height: 1789, description: 'Fully compatible with PrimeBlocks, choose from the wide range of blocks and customize the way you like. Note that PrimeBlocks is not included in the template and requires a separate purchase.', src: 'path_to_url }, { id: 3, title: 'PrimeIcons', width: 1440, height: 1789, description: 'Apollo ships with PrimeIcons, PrimeTeks modern icon library including a wide range of icons for your applications.', src: 'path_to_url }, { id: 4, title: 'Figma File', width: 1440, height: 1788, description: 'Apollo uses Figma as the design tool. It will be possible to download the Figma file after your purchase. You can preview the Figma file before the purchase. Note that PrimeNG UI components are excluded from the Apollo Figma file as they are available in PrimeOne for Figma only.', src: 'path_to_url } ]; apolloFeatures1Data = [ { height: 940, width: 960, src: 'path_to_url title: 'Ready to Use Applications', description: 'Mail, File System, Tasks, Calendar, Blog and Chat are the sample applications to get started with ease.' }, { height: 940, width: 960, src: 'path_to_url title: 'E-Commerce Pages', description: 'Apollo offers E-commerce pages to kickstart your e-commerce project powered by PrimeBlocks.' }, { height: 940, width: 960, src: 'path_to_url title: 'Ready to Use Pages', description: 'Landing, login, invoice, help, user management and error pages are provided as template pages to get started with building your app.' } ]; animationFeaturesData2 = [ { id: 1, title: 'Light / Dark / Dim Modes', description: 'Apollo has 3 display modes to choose from; Light, Dim and Dark.', height: 940, width: 960, src: 'path_to_url }, { id: 2, title: 'Component Themes', description: 'Apollo offers 24 built-in component themes and creating your own theme is a matter of defining couple of sass variables.', width: 940, height: 960, src: 'path_to_url }, { id: 3, title: '7 Menu Orientations', description: 'Static, Overlay, Slim, Slim+, Reveal, Drawer and Horizontal are the available menu layouts depending on your preference.', type: 'inline-animation', inlineFeaturesData: [ { id: 1, title: 'Static', width: 1440, height: 1789, src: 'path_to_url }, { id: 2, title: 'Slim', width: 1440, height: 1789, src: 'path_to_url }, { id: 3, title: 'Reveal', width: 1440, height: 1789, src: 'path_to_url }, { id: 4, title: 'Horizontal', width: 1440, height: 1789, src: 'path_to_url }, { id: 5, title: 'Overlay', width: 1440, height: 1789, src: 'path_to_url }, { id: 6, title: 'Slim+', width: 1440, height: 1789, src: 'path_to_url }, { id: 7, title: 'Drawer', width: 1440, height: 1789, src: 'path_to_url } ] }, { id: 4, title: 'Menu Themes', description: 'Stunning theming for the main menu with 3 alternatives; Color Scheme, Primary Color and Transparent.', width: 960, height: 940, src: 'path_to_url } ]; license = { documentLink: 'path_to_url description: 'The download package is an Angular CLI-based project containing all source code of the application deployed at the live demo. The project code is written in TypeScript.', licenseDetails: [ { price: '$49', included: ['Non Commercial Usage', 'Single End Product, No Multi-Use', '1 Year Free Updates'] }, { price: '$490', included: ['Commercial Usage', 'Multiple End Products', '1 Year Free Updates'] } ] }; } ```
/content/code_sandbox/src/app/showcase/pages/templates/apollo/apollo.ts
xml
2016-01-16T09:23:28
2024-08-16T19:58:20
primeng
primefaces/primeng
9,969
2,122
```xml import type { StorybookConfig } from './types'; export * from './types'; export const webpack: StorybookConfig['webpack'] = (config) => { const rules = [ ...(config.module?.rules || []), { type: 'javascript/auto', test: /\.stories\.json$/, use: require.resolve('@storybook/preset-server-webpack/dist/loader'), }, { type: 'javascript/auto', test: /\.stories\.ya?ml/, use: [ require.resolve('@storybook/preset-server-webpack/dist/loader'), { loader: require.resolve('yaml-loader'), options: { asJSON: true }, }, ], }, ]; config.module = config.module || {}; config.module.rules = rules; return config; }; ```
/content/code_sandbox/code/presets/server-webpack/src/index.ts
xml
2016-03-18T04:23:44
2024-08-16T19:22:08
storybook
storybookjs/storybook
83,755
163
```xml <FrameLayout xmlns:android="path_to_url" xmlns:tools="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/background_image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" /> <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" > </FrameLayout> <RelativeLayout android:id="@+id/popup_container" android:layout_width="match_parent" android:layout_height="match_parent" > </RelativeLayout> </FrameLayout> ```
/content/code_sandbox/subs/game/src/main/res/layout/activity_main.xml
xml
2016-08-08T08:52:10
2024-08-12T19:24:13
AndroidAnimationExercise
REBOOTERS/AndroidAnimationExercise
1,868
161
```xml import { formatUser } from '@proton/shared/lib/user/helpers'; export const userDefault = formatUser({ ID: your_sha256_hashjSKAtSNO39HEJh4_gmAWmg==', Name: 'proton154', Currency: 'CHF', Credit: 0, Type: 1, CreateTime: 1675856278, MaxSpace: 536870912000, MaxUpload: 26214400, UsedSpace: 464014, Subscribed: 7, Services: 7, MnemonicStatus: 1, Role: 2, Private: 1, Delinquent: 0, Keys: [ { ID: your_sha256_hashnYLQbsN1CYr5SaWX2NM6QA==', Version: 3, Primary: 1, RecoverySecret: 'LY1jHdyS5H31uscylnBSPhceRGy80EBQqXoVbAcIFOI=', RecoverySecretSignature: '-----BEGIN PGP SIGNATURE-----\nVersion: ProtonMail\n\nwnUEARYKACcFAmPjipkJED+xLzhLtLc+FiEEDRTuA1rCJc1UPXbMP7EvOEu0\ntz4AABoQAQDp1AI+xNPpt+MkxzhwznhKHhlqt+h/HRq7tcR0HGnPLQD/aO70\nUEP/t8za6JVedgNz27uC6JmN+IbQ1yREMuuiiwg=\n=hRI+\n-----END PGP SIGNATURE-----\n', PrivateKey: '-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxYYEY+OKWBYJKwYBBAHaRw8BAQdA6hN4OGIJ8cysIAQr0qI7PGitLIHWkWWe\n2sajNzKpwO7+CQMIYzF6xoLOujhgvO0hbo7Mnsb9eeTKSMaDOmBI3bgrS9m2\niMso3TfEgh6wf6m4oF/v+fDQBgUtlQbGeJZ6wis6o9FakY6VSKJ6mV10gWxB\ne807bm90X2Zvcl9lbWFpbF91c2VAZG9tYWluLnRsZCA8bm90X2Zvcl9lbWFp\nbF91c2VAZG9tYWluLnRsZD7CjAQQFgoAPgUCY+OKWAQLCQcICRA/sS84S7S3\nPgMVCAoEFgACAQIZAQIbAwIeARYhBA0U7gNawiXNVD12zD+xLzhLtLc+AACm\npgD/auHmvjKIWWXFfxakX7dT3tHFD5I1l+qsogdBj8bt8DcA/iMvnR1yTaT3\nt2JsEVOzEF54bvROCt2yUQoBSwfBm38Dx4sEY+OKWBIKKwYBBAGXVQEFAQEH\nQKnBCqr9XSsZfFdb1LiLtGN3EznGCfrrwqrtcVgQFwZIAwEIB/4JAwigxmYg\n0OJx9mBeFUbZtTj2ncQdwzvKfW0C0j3gYT6NjXwai+kZbSO7nrTTuggZec0k\ngRzHuoLY59IUxroQbpjMzMJXfm/KTTHE6d5SuJvgwngEGBYIACoFAmPjilgJ\nED+xLzhLtLc+AhsMFiEEDRTuA1rCJc1UPXbMP7EvOEu0tz4AADi8APsEziE2\nifdCFQZyGFNc3xbbguFyAWGB3UKWsKSTMp47ywD/bZFOayZtFbbIOHRDOuGK\nMk9bDrcx+UpCi5bAxLRq1QE=\n=RrlF\n-----END PGP PRIVATE KEY BLOCK-----\n', Fingerprint: '0d14ee035ac225cd543d76cc3fb12f384bb4b73e', Active: 1, }, ], ToMigrate: 0, Email: 'proton154@proton.black', DisplayName: 'proton154', } as any); ```
/content/code_sandbox/packages/components/hooks/helpers/test/useUser.ts
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
1,067
```xml import { SerializedServiceConnection } from '../../../interfaces/db/connections' import { useEffectOnce } from 'react-use' import { getUserServiceConnections, deleteUserServiceConnection, } from '../../../api/connections' import { useState, useRef, useCallback } from 'react' import { useToast } from '../../../../design/lib/stores/toast' interface Actions { removeConnection: ( serviceConnection: SerializedServiceConnection ) => Promise<void> addConnection: (serviceConnection: SerializedServiceConnection) => void } export type State = | { type: 'initialising' } | { type: 'working' connections: SerializedServiceConnection[] actions: Actions } | { type: 'initialised' connections: SerializedServiceConnection[] actions: Actions } export function useServiceConnectionsStore(): State { const { pushApiErrorMessage } = useToast() const [connections, setConnections] = useState<SerializedServiceConnection[]>( [] ) const initialise = useRef(false) const [isLoadingConnections, setIsLoadingConnections] = useState(true) useEffectOnce(() => { const getServiceConnections = async () => { try { const { connections } = await getUserServiceConnections() setConnections(connections) initialise.current = true } catch (err) { pushApiErrorMessage(err) } finally { setIsLoadingConnections(false) } } getServiceConnections() }) const removeConnection = useCallback( async (connection: SerializedServiceConnection) => { try { setIsLoadingConnections(true) await deleteUserServiceConnection(connection) setConnections((conns) => { return conns.filter((conn) => conn.id !== connection.id) }) } catch (err) { pushApiErrorMessage(err) } finally { setIsLoadingConnections(false) } }, [pushApiErrorMessage] ) const addConnection = useCallback( (connection: SerializedServiceConnection) => { setConnections((prevConns) => [connection, ...prevConns]) }, [] ) if (!initialise.current) { return { type: 'initialising' } } return { type: isLoadingConnections ? 'working' : 'initialised', connections, actions: { addConnection, removeConnection, }, } } ```
/content/code_sandbox/src/cloud/lib/stores/serviceConnections/store.ts
xml
2016-11-19T14:30:34
2024-08-16T03:13:45
BoostNote-App
BoostIO/BoostNote-App
3,745
495
```xml // // // Microsoft Bot Framework: path_to_url // // Bot Framework Emulator Github: // path_to_url // // All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // import { ConversationResourceResponse } from '@bfemulator/sdk-shared'; export function createConversationResponse(id: string, activityId: string | null): ConversationResourceResponse { const response: ConversationResourceResponse = { id }; if (activityId !== null) { response.activityId = activityId; } return response; } ```
/content/code_sandbox/packages/app/main/src/server/utils/createResponse/createConversationResponse.ts
xml
2016-11-11T23:15:09
2024-08-16T12:45:29
BotFramework-Emulator
microsoft/BotFramework-Emulator
1,803
323
```xml 'use strict'; import * as assert from 'assert'; import { expect } from 'chai'; import * as typemoq from 'typemoq'; import { ExtensionContext } from 'vscode'; import { BaseDiagnosticsService } from '../../../../client/application/diagnostics/base'; import { PylanceDefaultDiagnostic, PylanceDefaultDiagnosticService, PYLANCE_PROMPT_MEMENTO, } from '../../../../client/application/diagnostics/checks/pylanceDefault'; import { DiagnosticCodes } from '../../../../client/application/diagnostics/constants'; import { MessageCommandPrompt } from '../../../../client/application/diagnostics/promptHandler'; import { IDiagnostic, IDiagnosticFilterService, IDiagnosticHandlerService, } from '../../../../client/application/diagnostics/types'; import { IExtensionContext } from '../../../../client/common/types'; import { Common, Diagnostics } from '../../../../client/common/utils/localize'; import { IServiceContainer } from '../../../../client/ioc/types'; suite('Application Diagnostics - Pylance informational prompt', () => { let serviceContainer: typemoq.IMock<IServiceContainer>; let diagnosticService: PylanceDefaultDiagnosticService; let filterService: typemoq.IMock<IDiagnosticFilterService>; let messageHandler: typemoq.IMock<IDiagnosticHandlerService<MessageCommandPrompt>>; let context: typemoq.IMock<IExtensionContext>; let memento: typemoq.IMock<ExtensionContext['globalState']>; setup(() => { serviceContainer = typemoq.Mock.ofType<IServiceContainer>(); filterService = typemoq.Mock.ofType<IDiagnosticFilterService>(); messageHandler = typemoq.Mock.ofType<IDiagnosticHandlerService<MessageCommandPrompt>>(); context = typemoq.Mock.ofType<IExtensionContext>(); memento = typemoq.Mock.ofType<ExtensionContext['globalState']>(); serviceContainer .setup((s) => s.get(typemoq.It.isValue(IDiagnosticFilterService))) .returns(() => filterService.object); context.setup((c) => c.globalState).returns(() => memento.object); diagnosticService = new (class extends PylanceDefaultDiagnosticService { // eslint-disable-next-line class-methods-use-this public _clear() { while (BaseDiagnosticsService.handledDiagnosticCodeKeys.length > 0) { BaseDiagnosticsService.handledDiagnosticCodeKeys.shift(); } } })(serviceContainer.object, context.object, messageHandler.object, []); // eslint-disable-next-line @typescript-eslint/no-explicit-any (diagnosticService as any)._clear(); }); teardown(() => { context.reset(); memento.reset(); }); function setupMementos(version?: string, promptShown?: boolean) { diagnosticService.initialMementoValue = version; memento.setup((m) => m.get(PYLANCE_PROMPT_MEMENTO)).returns(() => promptShown); } test("Should display message if it's an existing installation of the extension and the prompt has not been shown yet", async () => { setupMementos('1.0.0', undefined); const diagnostics = await diagnosticService.diagnose(undefined); assert.deepStrictEqual(diagnostics, [ new PylanceDefaultDiagnostic(Diagnostics.pylanceDefaultMessage, undefined), ]); }); test("Should return empty diagnostics if it's an existing installation of the extension and the prompt has been shown before", async () => { setupMementos('1.0.0', true); const diagnostics = await diagnosticService.diagnose(undefined); assert.deepStrictEqual(diagnostics, []); }); test("Should return empty diagnostics if it's a fresh installation of the extension", async () => { setupMementos(undefined, undefined); const diagnostics = await diagnosticService.diagnose(undefined); assert.deepStrictEqual(diagnostics, []); }); test('Should display a prompt when handling the diagnostic code', async () => { const diagnostic = new PylanceDefaultDiagnostic(DiagnosticCodes.PylanceDefaultDiagnostic, undefined); let messagePrompt: MessageCommandPrompt | undefined; messageHandler .setup((f) => f.handle(typemoq.It.isValue(diagnostic), typemoq.It.isAny())) .callback((_d, prompt: MessageCommandPrompt) => { messagePrompt = prompt; }) .returns(() => Promise.resolve()) .verifiable(typemoq.Times.once()); await diagnosticService.handle([diagnostic]); filterService.verifyAll(); messageHandler.verifyAll(); assert.notDeepStrictEqual(messagePrompt, undefined); assert.notDeepStrictEqual(messagePrompt!.onClose, undefined); assert.deepStrictEqual(messagePrompt!.commandPrompts, [{ prompt: Common.ok }]); }); test('Should return empty diagnostics if the diagnostic code has been ignored', async () => { const diagnostic = new PylanceDefaultDiagnostic(DiagnosticCodes.PylanceDefaultDiagnostic, undefined); filterService .setup((f) => f.shouldIgnoreDiagnostic(typemoq.It.isValue(DiagnosticCodes.PylanceDefaultDiagnostic))) .returns(() => Promise.resolve(true)) .verifiable(typemoq.Times.once()); messageHandler.setup((f) => f.handle(typemoq.It.isAny(), typemoq.It.isAny())).verifiable(typemoq.Times.never()); await diagnosticService.handle([diagnostic]); filterService.verifyAll(); messageHandler.verifyAll(); }); test('PylanceDefaultDiagnosticService can handle PylanceDefaultDiagnostic diagnostics', async () => { const diagnostic = typemoq.Mock.ofType<IDiagnostic>(); diagnostic .setup((d) => d.code) .returns(() => DiagnosticCodes.PylanceDefaultDiagnostic) .verifiable(typemoq.Times.atLeastOnce()); const canHandle = await diagnosticService.canHandle(diagnostic.object); expect(canHandle).to.be.equal(true, 'Invalid value'); diagnostic.verifyAll(); }); test('PylanceDefaultDiagnosticService cannot handle non-PylanceDefaultDiagnostic diagnostics', async () => { const diagnostic = typemoq.Mock.ofType<IDiagnostic>(); diagnostic .setup((d) => d.code) .returns(() => DiagnosticCodes.your_sha256_hashostic) .verifiable(typemoq.Times.atLeastOnce()); const canHandle = await diagnosticService.canHandle(diagnostic.object); expect(canHandle).to.be.equal(false, 'Invalid value'); diagnostic.verifyAll(); }); }); ```
/content/code_sandbox/src/test/application/diagnostics/checks/pylanceDefault.unit.test.ts
xml
2016-01-19T10:50:01
2024-08-12T21:05:24
pythonVSCode
DonJayamanne/pythonVSCode
2,078
1,372
```xml namespace pxtmelody { export class MelodyInfo { name: string; notes: string; tempo: number; constructor(name: string, notes: string, tempo: number) { this.name = name; this.notes = notes; this.tempo = tempo; } } export const SampleMelodies = [ new MelodyInfo(lf("Scale"), "C5 B A G F E D C", 120), new MelodyInfo(lf("Reverse"), "C D E F G A B C5", 120), new MelodyInfo(lf("Mystery"), "E B C5 A B G A F", 120), new MelodyInfo(lf("Gilroy"), "A F E F D G E F", 120), new MelodyInfo(lf("Falling"), "C5 A B G A F G E", 120), new MelodyInfo(lf("Hopeful"), "G B A G C5 B A B", 120), new MelodyInfo(lf("Tokyo"), "B A G A G F A C5", 120), new MelodyInfo(lf("Paris"), "G F G A - F E D", 120), new MelodyInfo(lf("Rising"), "E D G F B A C5 B", 120), new MelodyInfo(lf("Sitka"), "C5 G B A F A C5 B", 120) ] } ```
/content/code_sandbox/pxtlib/melody-editor/sampleMelodies.ts
xml
2016-01-24T19:35:52
2024-08-16T16:39:39
pxt
microsoft/pxt
2,069
324
```xml <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ specific language governing permissions and limitations --> <FindBugsFilter> <Match> <Class name="io.ballerina.projects.internal.repositories.MavenPackageRepository"/> <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE, RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"/> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.codegen" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.interop" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.model" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.internal" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.methodgen" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.split" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.split.constants" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.split.types" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.codegen.split.values" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.bir.emit" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.desugar" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.bindingpatterns" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.matchpatterns" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.parser" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.expressions" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.util" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.semantics.analyzer" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.semantics.model" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.parser.antlr4" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.expressions" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.clauses" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.statements" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.tree.types" /> </Match> <Match> <Package name="org.wso2.ballerinalang.compiler.packaging.converters" /> </Match> <Match> <Package name="io.ballerina.compiler.api.impl" /> <Bug pattern="BC_UNCONFIRMED_CAST, UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR, BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" /> </Match> <Match> <Package name="io.ballerina.compiler.api.impl.symbols" /> <Bug pattern="BC_UNCONFIRMED_CAST, BC_UNCONFIRMED_CAST_OF_RETURN_VALUE, EQ_DOESNT_OVERRIDE_EQUALS" /> </Match> <Match> <Package name="io.ballerina.compiler.api.impl.type.builders" /> <Bug pattern="BC_UNCONFIRMED_CAST" /> </Match> <Match> <Class name="io.ballerina.compiler.api.Types" /> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" /> </Match> <Match> <Class name="io.ballerina.compiler.api.TypeBuilder" /> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" /> </Match> <Match> <Class name = "org.ballerinalang.toml.model.Library"/> <Bug pattern="UWF_UNWRITTEN_FIELD"/> </Match> <Match> <Class name = "org.ballerinalang.toml.model.Repository"/> <Bug pattern="UWF_UNWRITTEN_FIELD, NM_CONFUSING"/> </Match> <Match> <Class name = "org.ballerinalang.toml.model.Proxy"/> <Bug pattern="NM_CONFUSING"/> </Match> <Match> <Class name = "org.ballerinalang.toml.model.Platform"/> <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Package name="org.wso2.ballerinalang.programfile" /> </Match> <Match> <Package name="org.wso2.ballerinalang.programfile.attributes" /> </Match> <Match> <Package name="org.wso2.ballerinalang.programfile.cpentries" /> </Match> <Match> <Package name="org.wso2.ballerinalang.util" /> </Match> <Match> <Package name="org.ballerinalang.model" /> </Match> <Match> <Package name="org.ballerinalang.natives" /> </Match> <Match> <Package name="org.ballerinalang.repository.fs" /> </Match> <Match> <Package name="org.ballerinalang.util" /> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.packaging.converters.URIConverter"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.model.symbols.Symbols"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRVariableDcl"/> <Bug pattern="HE_EQUALS_USE_HASHCODE"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRFunctionParameter"/> <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRGlobalVariableDcl"/> <Bug pattern="EQ_DOESNT_OVERRIDE_EQUALS"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.BIRGen"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRTerminator"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNonTerminator"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIROperand"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.BIRBinaryWriter"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.BIRWriterUtils"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.internal.CompilerPhaseRunner"/> </Match> <Match> <Class name="io.ballerina.projects.ModuleCompilation"/> </Match> <Match> <Class name="io.ballerina.projects.BuildOptions"/> </Match> <Match> <Class name="io.ballerina.projects.Project"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.optimizer.BIRRecordValueOptimizer"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.ConstantPool"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.model.types.BField"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.BIRTypeWriter"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.CPEntry$FloatCPEntry"/> <Bug pattern="FE_FLOATING_POINT_EQUALITY"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.writer.BIRInstructionWriter"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.model.types.BObjectType"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRAnnotationAttachment"/> <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRFunction"/> <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRFunction"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRErrorEntry"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRTypeDefinition"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.model.BIRNode$BIRVariableDcl"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol"/> <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.analyzer.cyclefind.GlobalVariableRefAnalyzer"/> <Bug pattern="BC_UNCONFIRMED_CAST, BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.diagnostic.DiagnosticComparator"/> <Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE"/> </Match> <Match> <Class name="io.ballerina.projects.Project"/> <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="io.ballerina.projects.BuildOptions"/> <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/> </Match> <Match> <Class name="io.ballerina.projects.internal.CompilerPhaseRunner"/> <Bug pattern="URF_UNREAD_FIELD"/> </Match> <Match> <Class name="io.ballerina.projects.ModuleCompilation"/> <Bug pattern="URF_UNREAD_FIELD"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.bir.optimizer.BIROptimizer$OptimizerEnv"/> <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.packaging.repo.HomeBalaRepo"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.repositories.FileSystemRepository"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles" /> <Method name="loadPackageDataFromBalaFile" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles" /> <Method name="loadDocuments" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles" /> <Method name="loadOtherModules" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles" /> <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.ProjectFiles" /> <Method name="loadDocuments" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.ProjectFiles" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles"/> <Method name="createPackageManifestFromBalaFile"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles"/> <Method name="createManifest"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles"/> <Method name="createPackageDependencyGraph"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles"/> <Method name="readPackageJson"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.BalaFiles"/> <Method name="createDependencyManifestFromBalaFile"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.util.ProjectUtils"/> <Method name="extractBala"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.util.FileUtils" /> <Method name="getFilesInDirectory" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.projects.internal.model.BalToolDescriptor"/> <Method name="getToolJarsMatchingPattern"/> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/> </Match> <Match> <Class name="io.ballerina.projects.CodeAnalyzerManager$CompilationAnalysisTask"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="io.ballerina.projects.CodeAnalyzerManager$SyntaxNodeAnalysisTask"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="io.ballerina.projects.CompilerPluginManager"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.CodeActionManager"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.CodeGeneratorManager$SourceGeneratorTask"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.CodeModifierManager$SourceModifierTask"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.CodeModifierManager"/> <Method name="getSourceModifierTaskByPackage"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.CodeModifierManager"/> <Method name="populatePkgSyntaxNodeTaskMap"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE"/> </Match> <Match> <Class name="io.ballerina.projects.SyntaxNodeAnalysisTask"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.directory.BuildProject"/> <Method name="createBuildFile"/> <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/> </Match> <Match> <Class name="io.ballerina.projects.internal.ManifestBuilder"/> <Method name="getBooleanFromBuildOptionsTableNode"/> <Bug pattern="NP_BOOLEAN_RETURN_NULL"/> </Match> <Match> <Class name="io.ballerina.projects.internal.ManifestBuilder"/> <Method name="getBooleanValueFromPlatformEntry"/> <Bug pattern="NP_BOOLEAN_RETURN_NULL"/> </Match> <Match> <Class name="io.ballerina.projects.internal.plugins.CompilerPlugins"/> <Method name="getUri"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name = "org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType"/> <Method name="getReferredType"/> <Bug pattern="BC_UNCONFIRMED_CAST"/> </Match> <Match> <Class name="io.ballerina.projects.directory.BuildProject" /> <Method name="writePackageTableArrayWithPackageName"/> <Bug pattern="DM_DEFAULT_ENCODING" /> </Match> <Match> <Class name="io.ballerina.projects.directory.BuildProject" /> <Method name="writePackageNameInsideExistingEmptyPackageTable"/> <Bug pattern="DM_DEFAULT_ENCODING" /> </Match> <Match> <Class name="io.ballerina.projects.directory.BuildProject" /> <Method name="writePackageNameInsideExistingPackageTable"/> <Bug pattern="DM_DEFAULT_ENCODING" /> </Match> <Match> <Class name="io.ballerina.projects.internal.ManifestUtils" /> <Method name="getStringFromTomlTableNode"/> <Bug pattern="BC_UNCONFIRMED_CAST" /> </Match> <Match> <Class name="io.ballerina.projects.internal.ManifestUtils" /> <Method name="getBuildToolTomlValueType"/> <Bug pattern="BC_UNCONFIRMED_CAST" /> </Match> <Match> <Class name="io.ballerina.projects.util.ProjectUtils" /> <Method name="addMatchingIncludePaths" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" /> </Match> <Match> <Class name="io.ballerina.compiler.api.impl.util.SymbolUtils" /> <Bug pattern="BC_UNCONFIRMED_CAST" /> </Match> <Match> <Class name="io.ballerina.projects.plugins.completion.CompletionUtil" /> <OR> <Bug pattern="BC_UNCONFIRMED_CAST" /> </OR> </Match> <Match> <Class name="io.ballerina.projects.internal.repositories.FileSystemRepository" /> <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" /> </Match> <Match> <Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2,MS_EXPOSE_REP,MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR"/> </Match> <Match> <Class name="org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType" /> <Method name="getImpliedType"/> <Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" /> </Match> </FindBugsFilter> ```
/content/code_sandbox/compiler/ballerina-lang/spotbugs-exclude.xml
xml
2016-11-16T14:58:44
2024-08-15T15:15:21
ballerina-lang
ballerina-platform/ballerina-lang
3,561
4,834
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- ~ contributor license agreements. See the NOTICE file distributed with ~ this work for additional information regarding copyright ownership. ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <sql-parser-test-cases> <alter-server sql-case-id="alter_server_options" /> <alter-server sql-case-id="alter_server_version" /> </sql-parser-test-cases> ```
/content/code_sandbox/test/it/parser/src/main/resources/case/ddl/alter-server.xml
xml
2016-01-18T12:49:26
2024-08-16T15:48:11
shardingsphere
apache/shardingsphere
19,707
126
```xml import React from "react"; const gatsby = jest.requireActual("gatsby"); export default { ...gatsby, graphql: jest.fn(), Link: jest .fn() .mockImplementation( ({ activeClassName, activeStyle, getProps, innerRef, ref, replace, to, ...rest }) => React.createElement("a", { ...rest, href: to, }), ), StaticQuery: jest.fn(), useStaticQuery: jest.fn(), }; ```
/content/code_sandbox/internal/testing/__mocks__/gatsby.ts
xml
2016-03-11T21:02:37
2024-08-15T23:09:27
gatsby-starter-lumen
alxshelepenok/gatsby-starter-lumen
1,987
113
```xml import { IReadonlyTheme } from '@microsoft/sp-component-base'; import { WebPartContext } from "@microsoft/sp-webpart-base"; import { DisplayMode } from "@microsoft/sp-core-library"; import { IPropertyFieldSite } from '@pnp/spfx-property-controls/lib/PropertyFieldSitePicker'; export interface IMySitesProps { title: string; context: WebPartContext; themeVariant: IReadonlyTheme | undefined; displayMode: DisplayMode; updateProperty: (value: string) => void; itemsPerPage:number; defaultSitesToFilter: IPropertyFieldSite[]; enableFilterSharepointSites:boolean; enableFilterO365groups: boolean; enableFilterSitesWithSubWebs: boolean; } ```
/content/code_sandbox/samples/react-my-sites/src/webparts/mySites/components/MySites/IMySitesProps.ts
xml
2016-08-30T17:21:43
2024-08-16T18:41:32
sp-dev-fx-webparts
pnp/sp-dev-fx-webparts
2,027
160
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> </dict> </plist> ```
/content/code_sandbox/Demo/Untouched/Demo/Info.plist
xml
2016-02-14T16:08:40
2024-08-15T03:43:42
BartyCrouch
FlineDev/BartyCrouch
1,359
423
```xml import type { DisplayObject } from '@antv/g'; import { Category } from '@antv/component'; import { last } from '@antv/util'; import { format } from 'd3-format'; import { Identity } from '@antv/scale'; import type { FlexLayout, G2MarkState, GuideComponentComponent as GCC, GuideComponentOrientation as GCO, GuideComponentPosition as GCP, Scale, } from '../runtime'; import { GuideComponentContext } from '../runtime/types/component'; import type { G2Mark } from '../runtime/types/options'; import { useMarker } from '../utils/marker'; import { adaptor, domainOf, LegendCategoryLayout, inferComponentLayout, inferComponentShape, scaleOf, titleContent, } from './utils'; export type LegendCategoryOptions = { dx?: number; dy?: number; labelFormatter?: (d: any) => string; layout?: FlexLayout; orientation?: GCO; position?: GCP; title?: string | string[]; [key: string]: any; }; function inferShape(scales: Scale[], markState: Map<G2Mark, G2MarkState>) { const shapeScale = scaleOf(scales, 'shape'); const colorScale = scaleOf(scales, 'color'); // NOTE!!! // scaleOrdinal.map will mute domain. const shapeScale1 = shapeScale ? shapeScale.clone() : null; // Infer the main shape if multiple marks are used. const shapes: [string, string[]][] = []; for (const [mark, state] of markState) { const namespace = mark.type; const domain = colorScale?.getOptions().domain.length > 0 ? colorScale?.getOptions().domain : state.data; const shape: string[] = domain.map((d, i) => { if (shapeScale1) return shapeScale1.map(d || 'point'); return mark?.style?.shape || state.defaultShape || 'point'; }); if (typeof namespace === 'string') shapes.push([namespace, shape]); } if (shapes.length === 0) return ['point', ['point']]; if (shapes.length === 1) return shapes[0]; if (!shapeScale) return shapes[0]; // Evaluate the maximum likelihood of shape const { range } = shapeScale.getOptions(); return shapes .map(([namespace, shape]) => { let sum = 0; for (let i = 0; i < shapes.length; i++) { const targetShape = range[i % range.length]; if (shape[i] === targetShape) sum++; } return [sum / shape.length, [namespace, shape]] as const; }) .sort((a, b) => b[0] - a[0])[0][1]; } function inferItemMarker( options, context: GuideComponentContext, ): ((datum: any, i: number, data: any) => () => DisplayObject) | undefined { const { scales, library, markState } = context; const [mark, shapes] = inferShape(scales, markState); const { itemMarker, itemMarkerSize: size } = options; const create = (name, d) => { const marker = (library[`mark.${mark}`]?.props?.shape[name]?.props .defaultMarker as string) || last(name.split('.')); const radius = typeof size === 'function' ? size(d) : size; return () => useMarker(marker, { color: d.color })(0, 0, radius); }; const shapeOf = (i) => `${shapes[i]}`; const shapeScale = scaleOf(scales, 'shape'); if (shapeScale && !itemMarker) return (d, i) => create(shapeOf(i), d); if (typeof itemMarker === 'function') { return (d, i) => { // @todo Fix this in GUI. // It should pass primitive value rather object. const node = itemMarker(d.id, i); if (typeof node === 'string') return create(node, d); return node; }; } return (d, i) => create(itemMarker || shapeOf(i), d); } function inferItemMarkerOpacity(scales: Scale[]) { const scale = scaleOf(scales, 'opacity'); if (scale) { const { range } = scale.getOptions(); return (d, i) => range[i]; } return undefined; } function inferItemMarkerSize(scales: Scale[], defaults: number) { const scale = scaleOf(scales, 'size'); if (scale instanceof Identity) return scale.map(NaN) * 2; return defaults; } function inferCategoryStyle(options, context: GuideComponentContext) { const { labelFormatter = (d) => `${d}` } = options; const { scales, theme } = context; const defaultSize = theme.legendCategory.itemMarkerSize; const itemMarkerSize = inferItemMarkerSize(scales, defaultSize); const baseStyle = { itemMarker: inferItemMarker({ ...options, itemMarkerSize }, context), itemMarkerSize: itemMarkerSize, itemMarkerOpacity: inferItemMarkerOpacity(scales), }; const finalLabelFormatter = typeof labelFormatter === 'string' ? format(labelFormatter) : labelFormatter; const colorScale = scaleOf(scales, 'color'); const domain = domainOf(scales); const colorOf = colorScale ? (d) => colorScale.map(d) : () => context.theme.color; return { ...baseStyle, data: domain.map((d) => ({ id: d, label: finalLabelFormatter(d), color: colorOf(d), })), }; } function inferLegendShape( value: Record<string, any>, options: LegendCategoryOptions, component: GCC, ) { const { position } = options; if (position === 'center') { const { bbox } = value; // to be confirm: if position is center, we should use the width and height of user definition. const { width, height } = bbox; return { width, height }; } const { width, height } = inferComponentShape(value, options, component); return { width, height }; } /** * Guide Component for ordinal color scale. */ export const LegendCategory: GCC<LegendCategoryOptions> = (options) => { const { labelFormatter, layout, order, orientation, position, size, title, cols, itemMarker, ...style } = options; const { gridRow } = style; return (context) => { const { value, theme } = context; const { bbox } = value; const { width, height } = inferLegendShape(value, options, LegendCategory); const finalLayout = inferComponentLayout(position, layout); const legendStyle = { orientation: ['right', 'left', 'center'].includes(position) ? 'vertical' : 'horizontal', width, height, layout: cols !== undefined ? 'grid' : 'flex', ...(cols !== undefined && { gridCol: cols }), ...(gridRow !== undefined && { gridRow }), titleText: titleContent(title), ...inferCategoryStyle(options, context), }; const { legendCategory: legendTheme = {} } = theme; const categoryStyle = adaptor( Object.assign({}, legendTheme, legendStyle, style), ); const layoutWrapper = new LegendCategoryLayout({ style: { x: bbox.x, y: bbox.y, width: bbox.width, height: bbox.height, ...finalLayout, // @ts-ignore subOptions: categoryStyle, }, }); layoutWrapper.appendChild( new Category({ className: 'legend-category', style: categoryStyle, }), ); return layoutWrapper as unknown as DisplayObject; }; }; LegendCategory.props = { defaultPosition: 'top', defaultOrder: 1, defaultSize: 40, defaultCrossPadding: [12, 12], defaultPadding: [12, 12], }; ```
/content/code_sandbox/src/component/legendCategory.ts
xml
2016-05-26T09:21:04
2024-08-15T16:11:17
G2
antvis/G2
12,060
1,792
```xml import { BasePrimaryTextCardView, IPrimaryTextCardParameters, IExternalLinkCardAction, IQuickViewCardAction, ICardButton, IActionArguments, } from "@microsoft/sp-adaptive-card-extension-base"; import { IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState, QUICK_VIEW_REGISTRY_ID } from "../HolidayViewAdaptiveCardExtension"; export class CardView extends BasePrimaryTextCardView<IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState> { public get cardButtons(): [ICardButton] | [ICardButton, ICardButton] | undefined { const buttons: ICardButton[] = []; if (this.state.currentIndex > 0) { buttons.push({ title: "Previous", action: { type: "Submit", parameters: { id: "previous", op: -1, }, }, }); } if (this.state.currentIndex < this.state.holidayItems.length - 1) { buttons.push({ title: "Next", action: { type: "Submit", parameters: { id: "next", op: 1, // Increment the index }, }, }); } return buttons as [ICardButton] | [ICardButton, ICardButton]; } public onAction(action: IActionArguments): void { if (action.type === "Submit") { const { id, op } = action.data; switch (id) { case "previous": case "next": this.setState({ currentIndex: this.state.currentIndex + op }); break; } } } public get data(): IPrimaryTextCardParameters { const item = this.state.holidayItems[this.state.currentIndex]; return { primaryText: item.holidayTitle.label, description: item.holidayDay.label + " " + item.holidayDate.label, title: "Holidays", iconProperty: "Calendar", }; } public get onCardSelection(): IQuickViewCardAction | IExternalLinkCardAction | undefined { return { type: "QuickView", parameters: { view: QUICK_VIEW_REGISTRY_ID, }, }; } } ```
/content/code_sandbox/samples/react-holidays-calendar/src/adaptiveCardExtensions/holidayView/cardView/CardView.ts
xml
2016-08-30T17:21:43
2024-08-16T18:41:32
sp-dev-fx-webparts
pnp/sp-dev-fx-webparts
2,027
493
```xml import { type ProjectManifest, type DependenciesOrPeersField } from '@pnpm/types' export function getDependencyTypeFromManifest ( manifest: Pick<ProjectManifest, DependenciesOrPeersField>, depName: string ): DependenciesOrPeersField | null { if (manifest.optionalDependencies?.[depName]) return 'optionalDependencies' if (manifest.dependencies?.[depName]) return 'dependencies' if (manifest.devDependencies?.[depName]) return 'devDependencies' if (manifest.peerDependencies?.[depName]) return 'peerDependencies' return null } ```
/content/code_sandbox/pkg-manifest/manifest-utils/src/getDependencyTypeFromManifest.ts
xml
2016-01-28T07:40:43
2024-08-16T12:38:47
pnpm
pnpm/pnpm
28,869
123
```xml export { printExecutableGraphQLDocument } from './print-executable-graphql-document.js'; export { sortExecutableDocument } from './sort-executable-document.js'; ```
/content/code_sandbox/packages/documents/src/index.ts
xml
2016-03-22T00:14:38
2024-08-16T02:02:06
graphql-tools
ardatan/graphql-tools
5,331
32
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ --> <screen-config xmlns="path_to_url"> <include file="/com/haulmont/cuba/gui/cuba-screens.xml"/> <screen id="sec$User.changePasswordLauncher" class="com.haulmont.cuba.desktop.app.security.user.ChangePasswordLauncher"/> </screen-config> ```
/content/code_sandbox/modules/desktop/src/com/haulmont/cuba/desktop-screens.xml
xml
2016-03-24T07:55:56
2024-07-14T05:13:48
cuba
cuba-platform/cuba
1,342
127
```xml export * from './free-text-input.directive'; ```
/content/code_sandbox/npm/ng-packs/packages/feature-management/src/lib/directives/index.ts
xml
2016-12-03T22:56:24
2024-08-16T16:24:05
abp
abpframework/abp
12,657
10
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleDisplayName</key> <string>WatchAppExtension</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>XPC!</string> <key>CFBundleShortVersionString</key> <string>$(MARKETING_VERSION)</string> <key>CFBundleVersion</key> <string>$(CURRENT_PROJECT_VERSION)</string> <key>CLKComplicationPrincipalClass</key> <string>$(PRODUCT_MODULE_NAME).ComplicationController</string> <key>CLKComplicationSupportedFamilies</key> <array> <string>CLKComplicationFamilyModularSmall</string> <string>CLKComplicationFamilyModularLarge</string> <string>CLKComplicationFamilyUtilitarianSmall</string> <string>CLKComplicationFamilyUtilitarianSmallFlat</string> <string>CLKComplicationFamilyUtilitarianLarge</string> <string>CLKComplicationFamilyCircularSmall</string> <string>CLKComplicationFamilyExtraLarge</string> <string>CLKComplicationFamilyGraphicCorner</string> <string>CLKComplicationFamilyGraphicBezel</string> <string>CLKComplicationFamilyGraphicCircular</string> <string>CLKComplicationFamilyGraphicRectangular</string> </array> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> <key>NSExtension</key> <dict> <key>NSExtensionAttributes</key> <dict> <key>WKAppBundleIdentifier</key> <string>$(BUNDLE_ID_PREFIX).HomeAssistant$(BUNDLE_ID_SUFFIX).watchkitapp</string> </dict> <key>NSExtensionPointIdentifier</key> <string>com.apple.watchkit</string> </dict> <key>UIBackgroundModes</key> <array> <string>audio</string> </array> <key>WKExtensionDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).ExtensionDelegate</string> </dict> </plist> ```
/content/code_sandbox/Sources/Extensions/Watch/Resources/Info.plist
xml
2016-04-03T08:28:34
2024-08-16T19:21:00
iOS
home-assistant/iOS
1,514
618
```xml <?xml version="1.0" encoding="utf-8"?> <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <android.support.design.widget.CoordinatorLayout style="@style/root" xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/shadow" tools:context=".view.EditorActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include layout="@layout/view_common_toolbar_scroll"/> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/pager" android:background="@color/white" android:layout_width="match_parent" android:layout_height="match_parent"/> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/shadow"/> <ren.qinc.markdowneditors.lib.ExpandableLinearLayout android:id="@+id/action_other_operate" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/colorPrimary" android:elevation="4dp" android:orientation="vertical" app:el_duration="400" app:el_expanded="false"> <ren.qinc.markdowneditors.widget.TabIconView android:id="@+id/tabIconView" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_expandable="true"/> </ren.qinc.markdowneditors.lib.ExpandableLinearLayout> </FrameLayout> </LinearLayout> </android.support.design.widget.CoordinatorLayout> ```
/content/code_sandbox/app/src/main/res/layout/activity_editor.xml
xml
2016-06-30T10:37:13
2024-08-12T19:23:34
MarkdownEditors
qinci/MarkdownEditors
1,518
451
```xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="path_to_url"> <item android:state_activated="true" android:drawable="@color/selectedItemBackground" /> <item android:drawable="@android:color/transparent" /> </selector> ```
/content/code_sandbox/app/src/main/res/drawable/selectable_item_background.xml
xml
2016-04-16T22:20:07
2024-07-18T10:04:59
StickyHeaders
ShamylZakariya/StickyHeaders
1,404
64
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <project xmlns="path_to_url" xmlns:xsi="path_to_url" xsi:schemaLocation="path_to_url path_to_url"> <modelVersion>4.0.0</modelVersion> <groupId>com.google.training</groupId> <artifactId>quiz-backend</artifactId> <version>0.0.1</version> <packaging>jar</packaging> <name>appdev</name> <description>Quiz Application</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.6.RELEASE</version> <relativePath/> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <google.datastore.version>1.6.0</google.datastore.version> <google.pubsub.version>0.24.0-beta</google.pubsub.version> <google.languageapi.version>0.24.0-beta</google.languageapi.version> <google.spanner.version>0.24.0-beta</google.spanner.version> <google.cloudstorage.version>1.6.0</google.cloudstorage.version> <google-api-pubsub.version>v1-rev8-1.21.0</google-api-pubsub.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>com.vaadin.external.google</groupId> <artifactId>android-json</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-datastore</artifactId> <version>${google.datastore.version}</version> <exclusions> <exclusion> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-storage</artifactId> <version>${google.cloudstorage.version}</version> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-language</artifactId> <version>${google.languageapi.version}</version> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-spanner</artifactId> <version>${google.spanner.version}</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-tcnative-boringssl-static</artifactId> <version>2.0.3.Final</version> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-core</artifactId> <version>1.6.0</version> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-pubsub</artifactId> <version>0.24.0-beta</version> </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-core-grpc</artifactId> <version>1.6.0</version> </dependency> <dependency> <groupId>com.google.api.grpc</groupId> <artifactId>proto-google-cloud-pubsub-v1</artifactId> <version>0.1.20</version> </dependency> <dependency> <groupId>com.google.api.grpc</groupId> <artifactId>grpc-google-cloud-pubsub-v1</artifactId> <version>0.1.20</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-all</artifactId> <version>1.6.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.google.training.appdev.console.ConsoleApp</mainClass> </manifest> </archive> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- bind to the packaging phase --> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> ```
/content/code_sandbox/courses/developingapps/v1.2/java/kubernetesengine/start/pom-backend.xml
xml
2016-04-17T21:39:27
2024-08-16T17:22:27
training-data-analyst
GoogleCloudPlatform/training-data-analyst
7,726
1,460
```xml import { Box, Typography } from "@mui/material"; import React from "react"; import { RayStatusResp } from "../service/status"; const formatNodeStatus = (clusterStatus?: string) => { // ==== auto scaling status // Node status // .... // Resources // .... if (!clusterStatus) { return "No cluster status."; } try { // Try to parse the node status. const sections = clusterStatus.split("Resources"); return formatClusterStatus( "Node Status", sections[0].split("Node status")[1], ); } catch (e) { return "No cluster status."; } }; const formatResourcesStatus = (clusterStatus?: string) => { // ==== auto scaling status // Node status // .... // Resources // .... if (!clusterStatus) { return "No cluster status."; } try { const sections = clusterStatus.split("Resources"); return formatClusterStatus("Resource Status", sections[1]); } catch (e) { return "No cluster status."; } }; const formatClusterStatus = (title: string, clusterStatus: string) => { const clusterStatusRows = clusterStatus.split("\n"); return ( <div> <Box marginBottom={2}> <Typography variant="h3">{title}</Typography> </Box> {clusterStatusRows.map((i, key) => { // Format the output. // See format_info_string in util.py if (i.startsWith("-----") || i.startsWith("=====") || i === "") { // Ignore separators return null; } else if (i.endsWith(":")) { return ( <div key={key}> <b>{i}</b> </div> ); } else { return <div key={key}>{i}</div>; } })} </div> ); }; type StatusCardProps = { clusterStatus: RayStatusResp | undefined; }; export const NodeStatusCard = ({ clusterStatus }: StatusCardProps) => { return ( <Box style={{ overflow: "hidden", overflowY: "scroll", }} > {formatNodeStatus(clusterStatus?.data.clusterStatus)} </Box> ); }; export const ResourceStatusCard = ({ clusterStatus }: StatusCardProps) => { return ( <Box style={{ overflow: "hidden", overflowY: "scroll", }} > {formatResourcesStatus(clusterStatus?.data.clusterStatus)} </Box> ); }; ```
/content/code_sandbox/python/ray/dashboard/client/src/components/AutoscalerStatusCards.tsx
xml
2016-10-25T19:38:30
2024-08-16T19:46:34
ray
ray-project/ray
32,670
561
```xml import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewChild } from "@angular/core"; import { UntypedFormGroup, ReactiveFormsModule } from "@angular/forms"; import { NgbDatepicker, NgbDatepickerConfig, NgbDatepickerModule } from "@ng-bootstrap/ng-bootstrap"; import { DynamicDatePickerModel, DynamicFormControlComponent, DynamicFormControlCustomEvent, DynamicFormControlLayout, DynamicFormLayout, DynamicFormLayoutService, DynamicFormValidationService } from "@ng-dynamic-forms/core"; import { NgClass, NgIf } from "@angular/common"; @Component({ selector: "dynamic-ng-bootstrap-datepicker", templateUrl: "./dynamic-ng-bootstrap-datepicker.component.html", changeDetection: ChangeDetectionStrategy.Default, standalone: true, imports: [ReactiveFormsModule, NgbDatepickerModule, NgClass, NgIf] }) export class DynamicNGBootstrapDatePickerComponent extends DynamicFormControlComponent { @Input() formLayout?: DynamicFormLayout; @Input() group!: UntypedFormGroup; @Input() layout?: DynamicFormControlLayout; @Input() model!: DynamicDatePickerModel; @Output() blur: EventEmitter<any> = new EventEmitter(); @Output() change: EventEmitter<any> = new EventEmitter(); @Output() customEvent: EventEmitter<DynamicFormControlCustomEvent> = new EventEmitter(); @Output() focus: EventEmitter<any> = new EventEmitter(); @ViewChild(NgbDatepicker) ngbDatePicker!: NgbDatepicker; constructor(protected layoutService: DynamicFormLayoutService, protected validationService: DynamicFormValidationService, public config: NgbDatepickerConfig) { super(layoutService, validationService); } } ```
/content/code_sandbox/projects/ng-dynamic-forms/ui-ng-bootstrap/src/lib/datepicker/dynamic-ng-bootstrap-datepicker.component.ts
xml
2016-06-01T20:26:33
2024-08-05T16:40:39
ng-dynamic-forms
udos86/ng-dynamic-forms
1,315
346
```xml <?xml version='1.0' encoding='UTF-8'?> <wsdl:definitions name="Counter" targetNamespace="path_to_url" xmlns:ns1="path_to_url" xmlns:soap="path_to_url" xmlns:tns="path_to_url" xmlns:wsdl="path_to_url" xmlns:xsd="path_to_url"> <wsdl:types> <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="path_to_url" xmlns:tns="path_to_url" xmlns:xs="path_to_url"> <xs:element name="getCount" type="tns:getCount" /> <xs:element name="getCountResponse" type="tns:getCountResponse" /> <xs:element name="inc" type="tns:inc" /> <xs:element name="incResponse" type="tns:incResponse" /> <xs:element name="prettyPrintCount" type="tns:prettyPrintCount" /> <xs:element name="prettyPrintCountResponse" type="tns:prettyPrintCountResponse" /> <xs:element name="reset" type="tns:reset" /> <xs:element name="resetResponse" type="tns:resetResponse" /> <xs:element name="setTo" type="tns:setTo" /> <xs:element name="setToResponse" type="tns:setToResponse" /> <xs:complexType name="reset"> <xs:sequence /> </xs:complexType> <xs:complexType name="resetResponse"> <xs:sequence /> </xs:complexType> <xs:complexType name="setTo"> <xs:sequence> <xs:element name="value" type="xs:int" /> </xs:sequence> </xs:complexType> <xs:complexType name="setToResponse"> <xs:sequence /> </xs:complexType> <xs:complexType name="inc"> <xs:sequence /> </xs:complexType> <xs:complexType name="incResponse"> <xs:sequence /> </xs:complexType> <xs:complexType name="prettyPrintCount"> <xs:sequence> <xs:element minOccurs="0" name="prefix" type="xs:string" /> <xs:element minOccurs="0" name="suffix" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType name="prettyPrintCountResponse"> <xs:sequence> <xs:element minOccurs="0" name="prettyPrint" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType name="getCount"> <xs:sequence /> </xs:complexType> <xs:complexType name="getCountResponse"> <xs:sequence> <xs:element name="count" type="xs:int" /> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="getCount"> <wsdl:part element="tns:getCount" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="setTo"> <wsdl:part element="tns:setTo" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="prettyPrintCountResponse"> <wsdl:part element="tns:prettyPrintCountResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="resetResponse"> <wsdl:part element="tns:resetResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="reset"> <wsdl:part element="tns:reset" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="getCountResponse"> <wsdl:part element="tns:getCountResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="incResponse"> <wsdl:part element="tns:incResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="prettyPrintCount"> <wsdl:part element="tns:prettyPrintCount" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="inc"> <wsdl:part element="tns:inc" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="setToResponse"> <wsdl:part element="tns:setToResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="Counter"> <wsdl:operation name="reset"> <wsdl:input message="tns:reset" name="reset"> </wsdl:input> <wsdl:output message="tns:resetResponse" name="resetResponse"> </wsdl:output> </wsdl:operation> <wsdl:operation name="setTo"> <wsdl:input message="tns:setTo" name="setTo"> </wsdl:input> <wsdl:output message="tns:setToResponse" name="setToResponse"> </wsdl:output> </wsdl:operation> <wsdl:operation name="inc"> <wsdl:input message="tns:inc" name="inc"> </wsdl:input> <wsdl:output message="tns:incResponse" name="incResponse"> </wsdl:output> </wsdl:operation> <wsdl:operation name="prettyPrintCount"> <wsdl:input message="tns:prettyPrintCount" name="prettyPrintCount"> </wsdl:input> <wsdl:output message="tns:prettyPrintCountResponse" name="prettyPrintCountResponse"> </wsdl:output> </wsdl:operation> <wsdl:operation name="getCount"> <wsdl:input message="tns:getCount" name="getCount"> </wsdl:input> <wsdl:output message="tns:getCountResponse" name="getCountResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="CounterSoapBinding" type="tns:Counter"> <soap:binding style="document" transport="path_to_url" /> <wsdl:operation name="reset"> <soap:operation soapAction="" style="document" /> <wsdl:input name="reset"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="resetResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="setTo"> <soap:operation soapAction="" style="document" /> <wsdl:input name="setTo"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="setToResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="inc"> <soap:operation soapAction="" style="document" /> <wsdl:input name="inc"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="incResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="prettyPrintCount"> <soap:operation soapAction="" style="document" /> <wsdl:input name="prettyPrintCount"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="prettyPrintCountResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> <wsdl:operation name="getCount"> <soap:operation soapAction="" style="document" /> <wsdl:input name="getCount"> <soap:body use="literal" /> </wsdl:input> <wsdl:output name="getCountResponse"> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="Counter"> <wsdl:port binding="tns:CounterSoapBinding" name="CounterImplPort"> <soap:address location="path_to_url" /> </wsdl:port> </wsdl:service> </wsdl:definitions> ```
/content/code_sandbox/modules/flowable5-cxf-test/src/test/resources/org/activiti/engine/impl/webservice/counter.wsdl
xml
2016-10-13T07:21:43
2024-08-16T15:23:14
flowable-engine
flowable/flowable-engine
7,715
1,992
```xml export interface AutomationTestingProps { /** * Used by cypress to identify this property. * * Change with care and communicate this with QA */ 'data-cy': string; } declare module 'react' { interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T>, Partial<AutomationTestingProps> { // keep AutomationTestingProps 'data-cy' optional because HTMLAttributes covers non interactive elements } } export type WithRequiredProperties<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>; export type ValueOf<T extends Record<string, unknown>> = T[keyof T]; ```
/content/code_sandbox/app/types.ts
xml
2016-05-19T20:15:28
2024-08-16T19:15:14
portainer
portainer/portainer
30,083
144
```xml import * as React from 'react'; import { Source } from '@storybook/addon-docs'; import { makeStyles } from '@fluentui/react-components'; const useCodeComparisonStyles = makeStyles({ root: { display: 'flex', justifyContent: 'space-between', '> *': { width: '100%', }, '> :not(:last-child)': { marginRight: '5%', }, }, }); export const CodeComparison = (props: { children: React.ReactElement[] }) => { const { children } = props; const classes = useCodeComparisonStyles(); return <div className={classes.root}>{children}</div>; }; const codeLanguages = { html: 'HTML', css: 'CSS', js: 'JavaScript', jsx: 'React', }; export const CodeExample = (props: { title?: string; children: React.ReactElement }) => { const { title, children } = props; // Access the raw values from the markdown source code block const markdownCodeBlockValue: string | undefined = children?.props?.children?.props?.children; if (markdownCodeBlockValue === undefined) { return children; } const value: string = markdownCodeBlockValue.trim(); const codeBlockTag = '```'; // JSX source blocks are passed without the backticks const language = ( value.includes(codeBlockTag) ? value.substring(3, value.indexOf('\n')) : 'jsx' ) as keyof typeof codeLanguages; const code = value .replace(codeBlockTag + language, '') .replace(codeBlockTag, '') .trim(); return ( <div> <h3>{title ?? codeLanguages[language]}</h3> <Source language={language} code={code} /> </div> ); }; ```
/content/code_sandbox/apps/public-docsite-v9/src/Concepts/Migration/FromV8/Components/Flex/utils.stories.tsx
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
389
```xml <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="path_to_url"> <Import Project="..\..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\..\..\packages\xunit.runner.visualstudio.0.99.9-build1021\build\net20\xunit.runner.visualstudio.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion>9.0.21022</ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{D46D6FCD-03E4-499F-9ECF-A570E2E0EA51}</ProjectGuid> <OutputType>Exe</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>ConsoleApplication1</RootNamespace> <AssemblyName>setup</AssemblyName> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <FileUpgradeFlags> </FileUpgradeFlags> <UpgradeBackupLocation> </UpgradeBackupLocation> <OldToolsVersion>3.5</OldToolsVersion> <TargetFrameworkProfile /> <NuGetPackageImportStamp>50239e0f</NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE;CSS_PROJECT</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <UseVSHostingProcess>false</UseVSHostingProcess> <AllowUnsafeBlocks>false</AllowUnsafeBlocks> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <NoWarn> </NoWarn> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE;CSS_PROJECT</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <UseVSHostingProcess>false</UseVSHostingProcess> <AllowUnsafeBlocks>false</AllowUnsafeBlocks> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <ItemGroup> <Reference Include="Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL"> <HintPath>..\..\..\Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Core"> <RequiredTargetFramework>4.0</RequiredTargetFramework> </Reference> <Reference Include="System"> <SpecificVersion>False</SpecificVersion> <HintPath>System.dll</HintPath> </Reference> <Reference Include="System.Data" /> <Reference Include="System.Drawing"> <SpecificVersion>False</SpecificVersion> <HintPath>System.Drawing.dll</HintPath> </Reference> <Reference Include="System.Windows.Forms"> <SpecificVersion>False</SpecificVersion> <HintPath>System.Windows.Forms.dll</HintPath> </Reference> <Reference Include="System.Core"> <SpecificVersion>False</SpecificVersion> <HintPath>System.Core.dll</HintPath> </Reference> <Reference Include="System.Core"> <SpecificVersion>False</SpecificVersion> <HintPath>System.Core.dll</HintPath> </Reference> <Reference Include="System.Xml" /> <Reference Include="System.Xml.Linq" /> <Reference Include="Utils"> <HintPath>.\Utils.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> <Compile Include="EmptyDialog.cs"> <SubType>Form</SubType> </Compile> <Compile Include="EmptyDialog.Designer.cs"> <DependentUpon>EmptyDialog.cs</DependentUpon> </Compile> <Compile Include="MultiStepDialogSetup.cs" /> <Compile Include="EmptyDialogSetup.cs" /> <Compile Include="MultiStepCustomDialog.cs"> <SubType>Form</SubType> </Compile> <Compile Include="MultiStepCustomDialog.Designer.cs"> <DependentUpon>MultiStepCustomDialog.cs</DependentUpon> </Compile> <Compile Include="ProductActivationDialogSetup.cs" /> <Compile Include="setup.cs" /> <Compile Include="CustomDialog.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Step1Panel.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Step1Panel.Designer.cs"> <DependentUpon>Step1Panel.cs</DependentUpon> </Compile> <Compile Include="Step2Panel.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Step2Panel.Designer.cs"> <DependentUpon>Step2Panel.cs</DependentUpon> </Compile> </ItemGroup> <ItemGroup> <EmbeddedResource Include="CustomDialog.resx"> <DependentUpon>CustomDialog.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="EmptyDialog.resx"> <DependentUpon>EmptyDialog.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="MultiStepCustomDialog.resx"> <DependentUpon>MultiStepCustomDialog.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Step1Panel.resx"> <DependentUpon>Step1Panel.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Step2Panel.resx"> <DependentUpon>Step2Panel.cs</DependentUpon> </EmbeddedResource> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\..\WixSharp.UI\WixSharp.UI.csproj"> <Project>{79033a3e-565e-47a3-93f6-d95789b024fc}</Project> <Name>WixSharp.UI</Name> </ProjectReference> <ProjectReference Include="..\..\..\..\WixSharp\WixSharp.csproj"> <Project>{8860b29b-749f-4925-86c8-f9c4b93c9da5}</Project> <Name>WixSharp</Name> </ProjectReference> </ItemGroup> <ItemGroup> <None Include="app.config" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <PostBuildEvent>"$(TargetPath)"</PostBuildEvent> </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> --> </Project> ```
/content/code_sandbox/Source/src/WixSharp.Samples/Wix# Samples/Custom_UI/CustomCLRDialog/CustomCLRDialog.csproj
xml
2016-01-16T05:51:01
2024-08-16T12:26:25
wixsharp
oleg-shilo/wixsharp
1,077
1,737
```xml /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at path_to_url */ import {ClassNameUpgradeData, VersionChanges} from '@angular/cdk/schematics'; export const classNames: VersionChanges<ClassNameUpgradeData> = {}; ```
/content/code_sandbox/src/material/schematics/ng-update/data/class-names.ts
xml
2016-01-04T18:50:02
2024-08-16T11:21:13
components
angular/components
24,263
67
```xml const SharingPaths = { invite: '/v1/subscription-invites', acceptInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}/accept`, declineInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}/decline`, cancelInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}`, listInvites: '/v1/subscription-invites', } const UserSubscriptionPaths = { subscription: (userUuid: string) => `/v1/users/${userUuid}/subscription`, } const ApplePaths = { confirmAppleIAP: '/v1/subscriptions/apple_iap_confirm', } const UnauthenticatedSubscriptionsPaths = { availableSubscriptions: '/v2/subscriptions', } export const Paths = { v1: { ...SharingPaths, ...ApplePaths, ...UserSubscriptionPaths, ...UnauthenticatedSubscriptionsPaths, }, } ```
/content/code_sandbox/packages/api/src/Domain/Server/Subscription/Paths.ts
xml
2016-12-05T23:31:33
2024-08-16T06:51:19
app
standardnotes/app
5,180
208
```xml <?xml version="1.0" encoding="utf-8"?> <regress-exe> <test> <default> <files>cachedscope_1.js</files> <compile-flags>-force:cachedscope</compile-flags> <baseline>cachedscope_1.baseline</baseline> </default> </test> <test> <default> <files>cachedscope_2.js</files> </default> </test> <test> <default> <files>closure.js</files> <baseline>closure.baseline</baseline> <compile-flags>-Intl-</compile-flags> </default> </test> <test> <default> <files>closure-callback.js</files> <baseline>closure-callback.baseline</baseline> </default> </test> <test> <default> <files>closure_multiple_1.js</files> <baseline>closure_multiple_1.baseline</baseline> <compile-flags>-Intl-</compile-flags> </default> </test> <test> <default> <files>closure_multiple_2.js</files> <baseline>closure_multiple_2.baseline</baseline> <compile-flags>-Intl-</compile-flags> </default> </test> <test> <default> <files>closure_binding.js</files> <baseline>closure_binding.baseline</baseline> </default> </test> <test> <default> <files>closure_binding_2.js</files> <baseline>closure_binding_2.baseline</baseline> <compile-flags>-Intl-</compile-flags> </default> </test> <test> <default> <files>closure-funcexpr-eval.js</files> <baseline>closure-funcexpr-eval-3.baseline</baseline> </default> </test> <test> <default> <files>closure-qmark.js</files> <baseline>closure-qmark.baseline</baseline> <compile-flags>-Intl-</compile-flags> </default> </test> <test> <default> <files>closure_ole.js</files> </default> </test> <test> <default> <files>closure_ole.js</files> <compile-flags>-force:deferparse</compile-flags> </default> </test> <test> <default> <files>delaycapture-loopbody.js</files> <compile-flags>-lic:1 -off:simplejit -bgjit- -off:stackfunc -InitializeInterpreterSlotsWithInvalidStackVar</compile-flags> <tags>exclude_test</tags> </default> </test> <test> <default> <files>delaycapture-loopbody2.js</files> <compile-flags>-lic:1 -bgjit- -InitializeInterpreterSlotsWithInvalidStackVar</compile-flags> <tags>exclude_test</tags> </default> </test> <test> <default> <files>initcachedscope.js</files> <compile-flags>-recyclerstress -force:cachedscope</compile-flags> <baseline>initcachedscope.baseline</baseline> <tags>exclude_test,Slow</tags> </default> </test> <test> <default> <files>initcachedscope.js</files> <compile-flags>-force:deferparse</compile-flags> <baseline>initcachedscope.baseline</baseline> </default> </test> <test> <default> <files>invalcachedscope.js</files> <baseline>invalcachedscope.baseline</baseline> </default> </test> <test> <default> <compile-flags>-Serialized</compile-flags> <files>invalcachedscope.js</files> <baseline>invalcachedscope.baseline</baseline> <tags>exclude_forceserialized</tags> </default> </test> <test> <default> <files>invalcachedscope.js</files> <compile-flags>-force:deferparse -Intl-</compile-flags> <baseline>invalcachedscope.baseline</baseline> <tags>exclude_test</tags> </default> </test> <test> <default> <files>invalcachedscope-caller.js</files> <baseline>invalcachedscope-caller.baseline</baseline> </default> </test> <test> <default> <files>bug_OS_2299723.js</files> <baseline>bug_OS_2299723.baseline</baseline> <compile-flags>-force:cachedscope</compile-flags> </default> </test> <test> <default> <files>bug_OS_2671095.js</files> <compile-flags>-forcedeferparse -force:cachedscope</compile-flags> </default> </test> <test> <default> <files>bug_OS_2903083.js</files> <compile-flags>-force:cachedscope</compile-flags> </default> </test> <test> <default> <files>bug_OS_9781249.js</files> <compile-flags>-forcejitloopbody -force:inline -force:rejit</compile-flags> </default> </test> <test> <default> <files>bug_OS_9008744.js</files> <tags>exclude_dynapogo</tags> </default> </test> <test> <default> <files>bug_OS_10735999.js</files> </default> </test> <test> <default> <files>bug_OS_13412380.js</files> <tags>BugFix,exclude_dynapogo</tags> </default> </test> <test> <default> <files>copy-prop-stack-slot.js</files> <baseline>copy-prop-stack-slot.baseline</baseline> </default> </test> <test> <default> <files>bug_OS_13412380.js</files> <tags>exclude_dynapogo</tags> </default> </test> <test> <default> <files>update-funcexpr.js</files> </default> </test> </regress-exe> ```
/content/code_sandbox/test/Closures/rlexe.xml
xml
2016-01-05T19:05:31
2024-08-16T17:20:00
ChakraCore
chakra-core/ChakraCore
9,079
1,470
```xml import { defineQuery } from "groq"; export const settingsQuery = defineQuery(`*[_type == "settings"][0]`); const postFields = /* groq */ ` _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture}, `; export const heroQuery = defineQuery(` *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { content, ${postFields} } `); export const moreStoriesQuery = defineQuery(` *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { ${postFields} } `); export const postQuery = defineQuery(` *[_type == "post" && slug.current == $slug] [0] { content, ${postFields} } `); ```
/content/code_sandbox/examples/cms-sanity/sanity/lib/queries.ts
xml
2016-10-05T23:32:51
2024-08-16T19:44:30
next.js
vercel/next.js
124,056
255
```xml import path from 'path' import semver from 'semver' import partition from 'ramda/src/partition' import { type Dependencies, type PackageManifest, type ReadPackageHook } from '@pnpm/types' import { type VersionOverride as VersionOverrideBase } from '@pnpm/parse-overrides' import normalizePath from 'normalize-path' import { isIntersectingRange } from './isIntersectingRange' export type VersionOverrideWithoutRawSelector = Omit<VersionOverrideBase, 'selector'> export function createVersionsOverrider ( overrides: VersionOverrideWithoutRawSelector[], rootDir: string ): ReadPackageHook { const [versionOverrides, genericVersionOverrides] = partition(({ parentPkg }) => parentPkg != null, overrides .map((override) => { return { ...override, localTarget: createLocalTarget(override, rootDir), } }) ) as [VersionOverrideWithParent[], VersionOverride[]] return ((manifest: PackageManifest, dir?: string) => { const versionOverridesWithParent = versionOverrides.filter(({ parentPkg }) => { return ( parentPkg.name === manifest.name && (!parentPkg.pref || semver.satisfies(manifest.version, parentPkg.pref)) ) }) overrideDepsOfPkg({ manifest, dir }, versionOverridesWithParent, genericVersionOverrides) return manifest }) as ReadPackageHook } interface LocalTarget { protocol: LocalProtocol absolutePath: string specifiedViaRelativePath: boolean } type LocalProtocol = 'link:' | 'file:' function createLocalTarget (override: VersionOverrideWithoutRawSelector, rootDir: string): LocalTarget | undefined { let protocol: LocalProtocol | undefined if (override.newPref.startsWith('file:')) { protocol = 'file:' } else if (override.newPref.startsWith('link:')) { protocol = 'link:' } else { return undefined } const pkgPath = override.newPref.substring(protocol.length) const specifiedViaRelativePath = !path.isAbsolute(pkgPath) const absolutePath = specifiedViaRelativePath ? path.join(rootDir, pkgPath) : pkgPath return { absolutePath, specifiedViaRelativePath, protocol } } interface VersionOverride extends VersionOverrideBase { localTarget?: LocalTarget } type VersionOverrideWithParent = VersionOverride & Required<Pick<VersionOverride, 'parentPkg'>> function overrideDepsOfPkg ( { manifest, dir }: { manifest: PackageManifest, dir: string | undefined }, versionOverrides: VersionOverrideWithParent[], genericVersionOverrides: VersionOverride[] ): void { if (manifest.dependencies != null) overrideDeps(versionOverrides, genericVersionOverrides, manifest.dependencies, dir) if (manifest.optionalDependencies != null) overrideDeps(versionOverrides, genericVersionOverrides, manifest.optionalDependencies, dir) if (manifest.devDependencies != null) overrideDeps(versionOverrides, genericVersionOverrides, manifest.devDependencies, dir) if (manifest.peerDependencies != null) overrideDeps(versionOverrides, genericVersionOverrides, manifest.peerDependencies, dir) } function overrideDeps ( versionOverrides: VersionOverrideWithParent[], genericVersionOverrides: VersionOverride[], deps: Dependencies, dir: string | undefined ): void { for (const [name, pref] of Object.entries(deps)) { const versionOverride = pickMostSpecificVersionOverride( versionOverrides.filter( ({ targetPkg }) => targetPkg.name === name && isIntersectingRange(targetPkg.pref, pref) ) ) ?? pickMostSpecificVersionOverride( genericVersionOverrides.filter( ({ targetPkg }) => targetPkg.name === name && isIntersectingRange(targetPkg.pref, pref) ) ) if (!versionOverride) continue if (versionOverride.localTarget) { deps[versionOverride.targetPkg.name] = `${versionOverride.localTarget.protocol}${resolveLocalOverride(versionOverride.localTarget, dir)}` continue } deps[versionOverride.targetPkg.name] = versionOverride.newPref } } function resolveLocalOverride ({ specifiedViaRelativePath, absolutePath }: LocalTarget, pkgDir?: string): string { return specifiedViaRelativePath && pkgDir ? normalizePath(path.relative(pkgDir, absolutePath)) : absolutePath } function pickMostSpecificVersionOverride (versionOverrides: VersionOverride[]): VersionOverride | undefined { return versionOverrides.sort((a, b) => isIntersectingRange(b.targetPkg.pref ?? '', a.targetPkg.pref ?? '') ? -1 : 1)[0] } ```
/content/code_sandbox/hooks/read-package-hook/src/createVersionsOverrider.ts
xml
2016-01-28T07:40:43
2024-08-16T12:38:47
pnpm
pnpm/pnpm
28,869
995
```xml /************************************************************* * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ /** * @fileoverview Implements the SVGmtable wrapper for the MmlMtable object * * @author dpvc@mathjax.org (Davide Cervone) */ import {SVGWrapper, SVGConstructor} from '../Wrapper.js'; import {SVGWrapperFactory} from '../WrapperFactory.js'; import {CommonMtableMixin} from '../../common/Wrappers/mtable.js'; import {SVGmtr} from './mtr.js'; import {SVGmtd} from './mtd.js'; import {MmlMtable} from '../../../core/MmlTree/MmlNodes/mtable.js'; import {MmlNode} from '../../../core/MmlTree/MmlNode.js'; import {OptionList} from '../../../util/Options.js'; import {StyleList} from '../../../util/StyleList.js'; const CLASSPREFIX = 'mjx-'; /*****************************************************************/ /** * The SVGmtable wrapper for the MmlMtable object * * @template N The HTMLElement node class * @template T The Text node class * @template D The Document class */ export class SVGmtable<N, T, D> extends CommonMtableMixin<SVGmtd<any, any, any>, SVGmtr<any, any, any>, SVGConstructor<any, any, any>>(SVGWrapper) { /** * The mtable wrapper */ public static kind = MmlMtable.prototype.kind; /** * @override */ public static styles: StyleList = { 'g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line]': { 'stroke-width': '70px', fill: 'none' }, 'g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame]': { 'stroke-width': '70px', fill: 'none' }, 'g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed': { 'stroke-dasharray': '140' }, 'g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted': { 'stroke-linecap': 'round', 'stroke-dasharray': '0,140' }, 'g[data-mml-node="mtable"] > g > svg': { overflow: 'visible' } }; /** * The column for labels */ public labels: N; /******************************************************************/ /** * @override */ constructor(factory: SVGWrapperFactory<N, T, D>, node: MmlNode, parent: SVGWrapper<N, T, D> = null) { super(factory, node, parent); const def: OptionList = {'data-labels': true}; if (this.isTop) { def.transform = 'matrix(1 0 0 -1 0 0)'; } this.labels = this.svg('g', def); } /** * @override */ public toSVG(parent: N) { const svg = this.standardSVGnode(parent); this.placeRows(svg); this.handleColumnLines(svg); this.handleRowLines(svg); this.handleFrame(svg); const dx = this.handlePWidth(svg); this.handleLabels(svg, parent, dx); } /** * @param {N} svg The container in which to place the rows */ protected placeRows(svg: N) { const equal = this.node.attributes.get('equalrows') as boolean; const {H, D} = this.getTableData(); const HD = this.getEqualRowHeight(); const rSpace = this.getRowHalfSpacing(); const rLines = [this.fLine, ...this.rLines, this.fLine]; let y = this.getBBox().h - rLines[0]; for (let i = 0; i < this.numRows; i++) { const row = this.childNodes[i]; [row.H, row.D] = this.getRowHD(equal, HD, H[i], D[i]); [row.tSpace, row.bSpace] = [rSpace[i], rSpace[i + 1]]; [row.tLine, row.bLine] = [rLines[i], rLines[i + 1]]; row.toSVG(svg); row.place(0, y - rSpace[i] - row.H); y -= rSpace[i] + row.H + row.D + rSpace[i + 1] + rLines[i + 1]; } } /** * @param {boolean} equal True for equal-height rows * @param {number} HD The height of equal-height rows * @param {number} H The natural height of the row * @param {number} D The natural depth of the row * @returns {number[]} The (possibly scaled) height and depth to use */ protected getRowHD(equal: boolean, HD: number, H: number, D: number): [number, number] { return (equal ? [(HD + H - D) / 2, (HD - H + D) / 2] : [H, D]); } /******************************************************************/ /** * @override */ public handleColor() { super.handleColor(); const rect = this.firstChild(); if (rect) { this.adaptor.setAttribute(rect, 'width', this.fixed(this.getWidth())); } } /** * Add vertical lines between columns * * @param {N} svg The container for the table */ protected handleColumnLines(svg: N) { if (this.node.attributes.get('columnlines') === 'none') return; const lines = this.getColumnAttributes('columnlines'); if (!lines) return; const cSpace = this.getColumnHalfSpacing(); const cLines = this.cLines; const cWidth = this.getComputedWidths(); let x = this.fLine; for (let i = 0; i < lines.length; i++) { x += cSpace[i] + cWidth[i] + cSpace[i + 1]; if (lines[i] !== 'none') { this.adaptor.append(svg, this.makeVLine(x, lines[i], cLines[i])); } x += cLines[i]; } } /** * Add horizontal lines between rows * * @param {N} svg The container for the table */ protected handleRowLines(svg: N) { if (this.node.attributes.get('rowlines') === 'none') return; const lines = this.getRowAttributes('rowlines'); if (!lines) return; const equal = this.node.attributes.get('equalrows') as boolean; const {H, D} = this.getTableData(); const HD = this.getEqualRowHeight(); const rSpace = this.getRowHalfSpacing(); const rLines = this.rLines; let y = this.getBBox().h - this.fLine; for (let i = 0; i < lines.length; i++) { const [rH, rD] = this.getRowHD(equal, HD, H[i], D[i]); y -= rSpace[i] + rH + rD + rSpace[i + 1]; if (lines[i] !== 'none') { this.adaptor.append(svg, this.makeHLine(y, lines[i], rLines[i])); } y -= rLines[i]; } } /** * Add a frame to the mtable, if needed * * @param {N} svg The container for the table */ protected handleFrame(svg: N) { if (this.frame && this.fLine) { const {h, d, w} = this.getBBox(); const style = this.node.attributes.get('frame') as string; this.adaptor.append(svg, this.makeFrame(w, h, d, style)); } } /** * @returns {number} The x-adjustement needed to handle the true size of percentage-width tables */ protected handlePWidth(svg: N): number { if (!this.pWidth) { return 0; } const {w, L, R} = this.getBBox(); const W = L + this.pWidth + R; const align = this.getAlignShift()[0]; const CW = Math.max(this.isTop ? W : 0, this.container.getWrapWidth(this.containerI)) - L - R; const dw = w - (this.pWidth > CW ? CW : this.pWidth); const dx = (align === 'left' ? 0 : align === 'right' ? dw : dw / 2); if (dx) { const table = this.svg('g', {}, this.adaptor.childNodes(svg)); this.place(dx, 0, table); this.adaptor.append(svg, table); } return dx; } /******************************************************************/ /** * @param {string} style The line style whose class is to be obtained * @returns {string} The class name for the style */ protected lineClass(style: string): string { return CLASSPREFIX + style; } /** * @param {number} w The width of the frame * @param {number} h The height of the frame * @param {number} d The depth of the frame * @param {string} style The border style for the frame * @returns {N} The SVG element for the frame */ protected makeFrame(w: number, h: number, d: number, style: string): N { const t = this.fLine; return this.svg('rect', this.setLineThickness(t, style, { 'data-frame': true, 'class': this.lineClass(style), width: this.fixed(w - t), height: this.fixed(h + d - t), x: this.fixed(t / 2), y: this.fixed(t / 2 - d) })); } /** * @param {number} x The x location of the line * @param {string} style The border style for the line * @param {number} t The line thickness * @returns {N} The SVG element for the line */ protected makeVLine(x: number, style: string, t: number): N { const {h, d} = this.getBBox(); const dt = (style === 'dotted' ? t / 2 : 0); const X = this.fixed(x + t / 2); return this.svg('line', this.setLineThickness(t, style, { 'data-line': 'v', 'class': this.lineClass(style), x1: X, y1: this.fixed(dt - d), x2: X, y2: this.fixed(h - dt) })); } /** * @param {number} y The y location of the line * @param {string} style The border style for the line * @param {number} t The line thickness * @returns {N} The SVG element for the line */ protected makeHLine(y: number, style: string, t: number): N { const w = this.getBBox().w; const dt = (style === 'dotted' ? t / 2 : 0); const Y = this.fixed(y - t / 2); return this.svg('line', this.setLineThickness(t, style, { 'data-line': 'h', 'class': this.lineClass(style), x1: this.fixed(dt), y1: Y, x2: this.fixed(w - dt), y2: Y })); } /** * @param {number} t The thickness of the line * @param {string} style The border style for the line * @param {OptionList} properties The list of properties to modify * @param {OptionList} The modified properties */ protected setLineThickness(t: number, style: string, properties: OptionList) { if (t !== .07) { properties['stroke-thickness'] = this.fixed(t); if (style !== 'solid') { properties['stroke-dasharray'] = (style === 'dotted' ? '0,' : '') + this.fixed(2 * t); } } return properties; } /******************************************************************/ /** * Handle addition of labels to the table * * @param {N} svg The container for the table contents * @param {N} parent The parent containing the the table * @param {number} dx The adjustement for percentage width tables */ protected handleLabels(svg: N, _parent: N, dx: number) { if (!this.hasLabels) return; const labels = this.labels; const attributes = this.node.attributes; // // Set the side for the labels // const side = attributes.get('side') as string; // // Add the labels to the table // this.spaceLabels(); // // Handle top-level table to make it adapt to container size // but place subtables explicitly // this.isTop ? this.topTable(svg, labels, side) : this.subTable(svg, labels, side, dx); } /** * Add spacing elements between the label rows to align them with the rest of the table */ protected spaceLabels() { const adaptor = this.adaptor; const h = this.getBBox().h; const L = this.getTableData().L; const space = this.getRowHalfSpacing(); // // Start with frame size and add in spacing, height and depth, // and line thickness for each non-labeled row. // let y = h - this.fLine; let current = adaptor.firstChild(this.labels) as N; for (let i = 0; i < this.numRows; i++) { const row = this.childNodes[i] as SVGmtr<N, T, D>; if (row.node.isKind('mlabeledtr')) { const cell = row.childNodes[0]; y -= space[i] + row.H; row.placeCell(cell, {x: 0, y: y, w: L, lSpace: 0, rSpace: 0, lLine: 0, rLine: 0}); y -= row.D + space[i + 1] + this.rLines[i]; current = adaptor.next(current) as N; } else { y -= space[i] + row.H + row.D + space[i + 1] + this.rLines[i]; } } } /** * Handles tables with labels so that the label will move with the size of the container * * @param {N} svg The SVG container for the table * @param {N} labels The group of labels * @param {string} side The side alignment (left or right) */ protected topTable(svg: N, labels: N, side: string) { const adaptor = this.adaptor; const {h, d, w, L, R} = this.getBBox(); const W = L + (this.pWidth || w) + R; const LW = this.getTableData().L; const [ , align, shift] = this.getPadAlignShift(side); const dx = shift + (align === 'right' ? -W : align === 'center' ? -W / 2 : 0) + L; const matrix = 'matrix(1 0 0 -1 0 0)'; const scale = `scale(${this.jax.fixed((this.font.params.x_height * 1000) / this.metrics.ex, 2)})`; const transform = `translate(0 ${this.fixed(h)}) ${matrix} ${scale}`; let table = this.svg('svg', { 'data-table': true, preserveAspectRatio: (align === 'left' ? 'xMinYMid' : align === 'right' ? 'xMaxYMid' : 'xMidYMid'), viewBox: [this.fixed(-dx), this.fixed(-h), 1, this.fixed(h + d)].join(' ') }, [ this.svg('g', {transform: matrix}, adaptor.childNodes(svg)) ]); labels = this.svg('svg', { 'data-labels': true, preserveAspectRatio: (side === 'left' ? 'xMinYMid' : 'xMaxYMid'), viewBox: [side === 'left' ? 0 : this.fixed(LW), this.fixed(-h), 1, this.fixed(h + d)].join(' ') }, [labels]); adaptor.append(svg, this.svg('g', {transform: transform}, [table, labels])); this.place(-L, 0, svg); // remove spacing for L, which is added by the parent during appending } /** * @param {N} svg The SVG container for the table * @param {N} labels The group of labels * @param {string} side The side alignment (left or right) * @param {number} dx The adjustement for percentage width tables */ protected subTable(svg: N, labels: N, side: string, dx: number) { const adaptor = this.adaptor; const {w, L, R} = this.getBBox(); const W = L + (this.pWidth || w) + R; const labelW = this.getTableData().L; const align = this.getAlignShift()[0]; const CW = Math.max(W, this.container.getWrapWidth(this.containerI)); this.place(side === 'left' ? (align === 'left' ? 0 : align === 'right' ? W - CW + dx : (W - CW) / 2 + dx) - L : (align === 'left' ? CW : align === 'right' ? W + dx : (CW + W) / 2 + dx) - L - labelW, 0, labels); adaptor.append(svg, labels); } } ```
/content/code_sandbox/ts/output/svg/Wrappers/mtable.ts
xml
2016-02-23T09:52:03
2024-08-16T04:46:50
MathJax-src
mathjax/MathJax-src
2,017
4,041
```xml import { ComponentPropsWithoutRef, ForwardedRef, forwardRef, MouseEventHandler } from 'react' import Icon from '@/Components/Icon/Icon' import { IconType } from '@standardnotes/snjs' import { classNames } from '@standardnotes/utils' import StyledTooltip from '../StyledTooltip/StyledTooltip' type Props = { onClick: MouseEventHandler className?: string icon: IconType iconClassName?: string iconProps?: Partial<Parameters<typeof Icon>[0]> label: string id?: string } & ComponentPropsWithoutRef<'button'> const RoundIconButton = forwardRef( ( { onClick, className, icon: iconType, iconClassName, iconProps, id, label, ...props }: Props, ref: ForwardedRef<HTMLButtonElement>, ) => { const click: MouseEventHandler = (e) => { e.preventDefault() onClick(e) } return ( <StyledTooltip label={label}> <button className={classNames( 'bg-text-padding m-0 flex h-10 min-w-10 cursor-pointer items-center justify-center rounded-full border', 'border-solid border-border bg-clip-padding text-neutral hover:bg-contrast hover:text-text focus:bg-contrast', 'focus:text-text focus:outline-none focus:ring-info md:h-8 md:min-w-8', className, )} onClick={click} ref={ref} id={id} aria-label={label} {...props} > <Icon {...iconProps} type={iconType} className={iconClassName} /> </button> </StyledTooltip> ) }, ) export default RoundIconButton ```
/content/code_sandbox/packages/web/src/javascripts/Components/Button/RoundIconButton.tsx
xml
2016-12-05T23:31:33
2024-08-16T06:51:19
app
standardnotes/app
5,180
356
```xml import type { MutableRefObject } from 'react'; import React, { useEffect, useImperativeHandle, useRef, useState } from 'react'; import { addHours } from 'date-fns'; import { c } from 'ttag'; import { APPS } from '@proton/shared/lib/constants'; import * as sessionStorageWrapper from '@proton/shared/lib/helpers/sessionStorage'; import * as localStorageWrapper from '@proton/shared/lib/helpers/storage'; import { getApiSubdomainUrl } from '@proton/shared/lib/helpers/url'; import type { UserModel } from '@proton/shared/lib/interfaces'; import { useConfig, useNotifications } from '../../hooks'; // The sizes for these are hardcoded since the widget calculates it based on the viewport, and since it's in // an iframe it needs to have something reasonable. // The main chat widget. const OPENED_SIZE = { height: `${572 / 16}rem`, width: `${374 / 16}rem`, }; // The small button to toggle the chat. const CLOSED_SIZE = { height: `${70 / 16}rem`, width: `${140 / 16}rem`, }; const SINGLE_CHAT_KEY = 'zk_state'; const SINGLE_CHAT_TIMEOUT = 10000; const getIframeUrl = (zendeskKey: string) => { const url = getApiSubdomainUrl('/core/v4/resources/zendesk', window.location.origin); url.searchParams.set('Key', zendeskKey); return url; }; export const getIsSelfChat = () => { return sessionStorageWrapper.getItem(SINGLE_CHAT_KEY); }; const removeSelfActiveMarker = () => { return sessionStorageWrapper.removeItem(SINGLE_CHAT_KEY); }; const getIsActiveInAnotherWindow = () => { return !getIsSelfChat() && +(localStorageWrapper.getItem(SINGLE_CHAT_KEY) || 0) > Date.now(); }; const setActiveMarker = () => { localStorageWrapper.setItem(SINGLE_CHAT_KEY, `${+Date.now() + SINGLE_CHAT_TIMEOUT}`); sessionStorageWrapper.setItem(SINGLE_CHAT_KEY, '1'); }; const clearPaidMarkers = () => { if (!localStorageWrapper.hasStorage()) { return; } for (let i = 0; i < localStorage.length; i++) { const key = localStorage.key(i); if (key?.startsWith('LiveChat')) { if (+(localStorage.getItem(key) || 0) < Date.now()) { localStorage.removeItem(key); } } } }; const setPaidMarker = (userID: string) => { return localStorageWrapper.setItem(`LiveChat-${userID}`, addHours(new Date(), 24).getTime().toString()); }; const getPaidMarker = (userID: string) => { return +(localStorageWrapper.getItem(`LiveChat-${userID}`) || 0); }; export const useCanEnableChat = (user: UserModel) => { const hasCachedChat = getPaidMarker(user.ID) > Date.now(); const canEnableChat = user.hasPaidVpn || hasCachedChat; const { APP_NAME } = useConfig(); useEffect(() => { if (APP_NAME === APPS.PROTONVPN_SETTINGS) { return; } clearPaidMarkers(); if (!user.hasPaidVpn) { return; } const setMarker = () => { // Clear old items clearPaidMarkers(); // Enable the user to access chat 24 hours after in case she unsubscribes setPaidMarker(user.ID); }; setMarker(); const handle = window.setInterval(setMarker, 60000); return () => window.clearInterval(handle); }, [user.hasPaidVpn]); return APP_NAME === APPS.PROTONVPN_SETTINGS && canEnableChat; }; export interface ZendeskRef { run: (data: object) => void; toggle: () => void; } interface Props { zendeskKey: string; zendeskRef?: MutableRefObject<ZendeskRef | undefined>; name?: string; email?: string; onLoaded: () => void; onUnavailable: () => void; locale: string; tags: string[]; } const LiveChatZendesk = ({ zendeskKey, zendeskRef, name, email, onLoaded, onUnavailable, locale, tags }: Props) => { const [style, setStyle] = useState({ position: 'absolute', bottom: 0, right: 0, maxHeight: '100%', maxWidth: '100%', zIndex: '999999', ...CLOSED_SIZE, }); const [state, setState] = useState({ loaded: false, connected: false }); const stateRef = useRef({ loaded: false, connected: false }); const iframeRef = useRef<HTMLIFrameElement>(null); const pendingLoadingRef = useRef<{ toggle?: boolean; locale?: string }>({}); const iframeUrl = getIframeUrl(zendeskKey); const src = iframeUrl.toString(); const targetOrigin = iframeUrl.origin; const handleRun = (args: any) => { const contentWindow = iframeRef.current?.contentWindow; if (!contentWindow || !stateRef.current.loaded) { return; } contentWindow.postMessage({ args }, targetOrigin); }; const handleToggle = () => { // Using the ref instead of state to not have to wait for re-render if (!stateRef.current.connected) { onUnavailable(); return; } pendingLoadingRef.current.toggle = true; handleRun(['webWidget', 'toggle']); }; useImperativeHandle(zendeskRef, () => ({ run: handleRun, toggle: handleToggle, })); useEffect(() => { if (!state.loaded) { return; } handleRun([ 'webWidget', 'prefill', { name: { value: name, readOnly: false }, email: { value: email, readOnly: Boolean(email) }, }, ]); }, [state.loaded, name, email]); useEffect(() => { if (!state.loaded) { return; } handleRun(['webWidget', 'setLocale', locale]); }, [state.loaded, locale]); useEffect(() => { if (!state.loaded || !tags.length) { return; } handleRun(['webWidget', 'chat:addTags', tags]); return () => { handleRun(['webWidget', 'chat:removeTags', tags]); }; }, [state.loaded, tags]); useEffect(() => { if (!state.loaded || !pendingLoadingRef.current) { return; } const oldPending = pendingLoadingRef.current; pendingLoadingRef.current = {}; if (oldPending.toggle) { handleToggle(); } }, [state.loaded]); useEffect(() => { let globalId = 1; const handlers: { [key: string]: [(value: any) => void, (reason?: any) => void, number] } = {}; const sendMessage = (contentWindow: Window, args: any) => { contentWindow.postMessage({ args }, targetOrigin); }; const sendMessageWithReply = <T,>(contentWindow: Window, args: any): Promise<T> => { const id = globalId++; contentWindow.postMessage({ id, args }, targetOrigin); return new Promise((resolve, reject) => { const intervalId = window.setTimeout(() => { delete handlers[id]; }, 30000); handlers[id] = [resolve, reject, intervalId]; }); }; const handleMessage = (event: MessageEvent) => { const contentWindow = iframeRef.current?.contentWindow; const { origin, data, source } = event; if (!contentWindow || origin !== targetOrigin || !data || source !== contentWindow) { return; } const departmentName = 'Support'; if (data.type === 'on') { if (data.payload?.event === 'open') { setStyle((oldStyle) => ({ ...oldStyle, ...OPENED_SIZE })); } if (data.payload?.event === 'close') { setStyle((oldStyle) => ({ ...oldStyle, ...CLOSED_SIZE })); } if (data.payload?.event === 'chat:connected') { sendMessage(contentWindow, [ 'webWidget', 'updateSettings', { webWidget: { chat: { departments: { enabled: [departmentName], select: departmentName, }, }, }, }, ]); sendMessageWithReply<any>(contentWindow, ['webWidget:get', 'chat:department', departmentName]) .then((result) => { const connected = result?.status === 'online'; stateRef.current = { loaded: true, connected }; setState({ loaded: true, connected }); onLoaded(); }) .catch(() => { stateRef.current = { loaded: true, connected: false }; setState({ loaded: true, connected: false }); onLoaded(); }); } if (data.payload?.event === 'chat:departmentStatus') { const { chatDepartment } = data.payload; if (!chatDepartment) { return; } const connected = chatDepartment?.status === 'online'; stateRef.current = { loaded: true, connected }; setState({ loaded: true, connected }); } } if (data.type === 'response') { if (data.payload.id !== undefined) { const handler = handlers[data.payload.id]; if (handler) { delete handlers[data.payload.id]; handler[0](data.payload.result); } } } if (data.type === 'loaded') { sendMessage(contentWindow, [ 'webWidget', 'updateSettings', { webWidget: { color: { launcher: '#6d4aff', button: '#6d4aff', header: '#261b57', }, }, }, ]); } }; window.addEventListener('message', handleMessage, false); return () => { window.removeEventListener('message', handleMessage, false); for (const handlerKey of Object.keys(handlers)) { const handler = handlers[handlerKey]; handler[1](new Error('Unmount')); window.clearTimeout(handler[2]); delete handlers[handlerKey]; } }; }, []); return ( <div className={!state.connected ? 'hidden' : ''}> <iframe title="Zendesk" src={src} style={style} ref={iframeRef} sandbox="allow-scripts allow-same-origin allow-popups allow-forms" /> </div> ); }; const LiveChatZendeskSingleton = ({ zendeskRef, ...rest }: Props) => { const { createNotification } = useNotifications(); const [isActive, setIsActive] = useState(() => !getIsActiveInAnotherWindow()); const actualZendeskRef = useRef<ZendeskRef>(); useEffect(() => { const interval = window.setInterval(() => { if (getIsActiveInAnotherWindow()) { return; } setIsActive(true); setActiveMarker(); }, SINGLE_CHAT_TIMEOUT / 2); return () => { clearInterval(interval); removeSelfActiveMarker(); }; }, []); useImperativeHandle(zendeskRef, () => ({ run: (...args) => actualZendeskRef.current?.run(...args), toggle: (...args) => { if (getIsActiveInAnotherWindow()) { createNotification({ text: c('Info') .t`You can only have one chat instance open at a time. Please close previous conversations before starting a new one.`, type: 'error', }); return; } actualZendeskRef.current?.toggle(...args); }, })); useEffect(() => { if (!isActive) { rest.onLoaded(); } }, []); if (!isActive) { return null; } return <LiveChatZendesk zendeskRef={actualZendeskRef} {...rest} />; }; export default LiveChatZendeskSingleton; ```
/content/code_sandbox/packages/components/containers/zendesk/LiveChatZendesk.tsx
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
2,576
```xml <!-- or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file path_to_url Unless required by applicable law or agreed to in writing, "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY specific language governing permissions and limitations --> <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"> <item name="elevation">0dp</item> </style> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> <style name="FullscreenTheme" parent="AppTheme"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:windowActionBarOverlay">true</item> <item name="android:windowBackground">@null</item> <item name="android:windowFullscreen">true</item> </style> <style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar"> <item name="android:background">@color/black_overlay</item> </style> </resources> ```
/content/code_sandbox/playground/android/playground/src/main/res/values/styles.xml
xml
2016-03-11T10:18:11
2024-08-16T06:43:02
weex
alibaba/weex
18,250
372
```xml /** * @license * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import { registerProvider } from "#src/datasource/default_provider.js"; import { VtkDataSource } from "#src/datasource/vtk/frontend.js"; registerProvider("vtk", () => new VtkDataSource()); ```
/content/code_sandbox/src/datasource/vtk/register_default.ts
xml
2016-05-27T02:37:25
2024-08-16T07:24:25
neuroglancer
google/neuroglancer
1,045
87
```xml /* tslint:disable:no-unused-variable */ import { Component } from '@angular/core'; import { RouterTestingModule } from '@angular/router/testing'; import { TestBed, async } from '@angular/core/testing'; import { TermsComponent } from './terms.component'; import { Store, StateObservable } from '@ngrx/store'; @Component({ selector: 'app-navbar', template: '' }) class AppNavbarStubComponent { } @Component({ selector: 'app-footer', template: '' }) class AppFooterStubComponent { } describe('Component: Terms', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ TermsComponent, AppNavbarStubComponent, AppFooterStubComponent ], providers: [ { provide: Store, useValue: {} }, { provide: StateObservable, useValue: {} } ] }); }); it('should create an instance', () => { const fixture = TestBed.createComponent(TermsComponent); const component = fixture.debugElement.componentInstance; expect(component).toBeTruthy(); }); it('should have an app-footer component', async(() => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('app-footer')).toBeTruthy(); })); it('should have an app-navbar component', async(() => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('app-navbar')).toBeTruthy(); })); it('should have a div with id left', () => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('div#left')); }); it('should have a div with id right', () => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('div#right')); }); it('should have a sidebar menu', () => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('ul.sidebar-list')); }); it('should have an active list on sidebar menu', () => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; expect(compiled.querySelector('ul.sidebar-list li.active')); }); it('should scroll', async(() => { const fixture = TestBed.createComponent(TermsComponent); const compiled = fixture.debugElement.nativeElement; const element = compiled.querySelector('li.element4 a'); element.click(); fixture.whenStable().then(() => { expect(compiled.querySelector('li.element4.active')).toBeTruthy(); }); })); }); ```
/content/code_sandbox/src/app/terms/terms.component.spec.ts
xml
2016-09-20T13:50:42
2024-08-06T13:58:18
loklak_search
fossasia/loklak_search
1,829
585
```xml import {Component} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {FlatTreeControl, NestedTreeControl} from '@angular/cdk/tree'; import { MatTreeFlatDataSource, MatTreeFlattener, MatTreeModule, MatTreeNestedDataSource, } from '@angular/material/tree'; import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; import {MatTreeHarness} from './tree-harness'; describe('MatTreeHarness', () => { let fixture: ComponentFixture<TreeHarnessTest>; let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ imports: [MatTreeModule, TreeHarnessTest], }); fixture = TestBed.createComponent(TreeHarnessTest); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); it('should load harness with 2 tress', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); expect(trees.length).toBe(2); }); it('should get correct number of children and descendants', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const flatTree = trees[0]; const nestedTree = trees[1]; const flatTreeDescendants = await flatTree.getNodes(); const nestedDescendants = await nestedTree.getNodes(); // flat nodes are not rendered until expanded expect(flatTreeDescendants.length).toBe(2); await flatTreeDescendants[0].expand(); expect((await flatTree.getNodes()).length).toBe(5); expect(nestedDescendants.length).toBe(8); }); it('should correctly get correct node with text (flat tree)', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const flatTree = trees[0]; const flatTreeNodes = await flatTree.getNodes({text: /Flat Group/}); expect(flatTreeNodes.length).toBe(2); const secondGroup = flatTreeNodes[0]; expect(await secondGroup.getText()).toBe('Flat Group 1'); expect(await secondGroup.getLevel()).toBe(1); expect(await secondGroup.isDisabled()).toBe(false); expect(await secondGroup.isExpanded()).toBe(false); }); it('should correctly get correct node with text (nested tree)', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const nestedTree = trees[1]; const nestedTreeNodes = await nestedTree.getNodes({text: /2./}); expect(nestedTreeNodes.length).toBe(3); const thirdGroup = nestedTreeNodes[1]; expect(await thirdGroup.getText()).toBe('Nested Leaf 2.1.1'); expect(await thirdGroup.getLevel()).toBe(3); expect(await thirdGroup.isDisabled()).toBe(false); expect(await thirdGroup.isExpanded()).toBe(false); }); it('should toggle expansion', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const nestedTree = trees[1]; const nestedTreeNodes = await nestedTree.getNodes(); const firstGroup = nestedTreeNodes[0]; expect(await firstGroup.isExpanded()).toBe(false); await firstGroup.expand(); expect(await firstGroup.isExpanded()).toBe(true); await firstGroup.expand(); // no-op if already expanded expect(await firstGroup.isExpanded()).toBe(true); await firstGroup.collapse(); expect(await firstGroup.isExpanded()).toBe(false); await firstGroup.collapse(); // no-op if already collapsed expect(await firstGroup.isExpanded()).toBe(false); }); it('should correctly get tree structure', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const flatTree = trees[0]; expect(await flatTree.getTreeStructure()).toEqual({ children: [{text: 'Flat Group 1'}, {text: 'Flat Group 2'}], }); const firstGroup = (await flatTree.getNodes({text: /Flat Group 1/}))[0]; await firstGroup.expand(); expect(await flatTree.getTreeStructure()).toEqual({ children: [ { text: 'Flat Group 1', children: [{text: 'Flat Leaf 1.1'}, {text: 'Flat Leaf 1.2'}, {text: 'Flat Leaf 1.3'}], }, {text: 'Flat Group 2'}, ], }); const secondGroup = (await flatTree.getNodes({text: /Flat Group 2/}))[0]; await secondGroup.expand(); expect(await flatTree.getTreeStructure()).toEqual({ children: [ { text: 'Flat Group 1', children: [{text: 'Flat Leaf 1.1'}, {text: 'Flat Leaf 1.2'}, {text: 'Flat Leaf 1.3'}], }, { text: 'Flat Group 2', children: [{text: 'Flat Group 2.1'}], }, ], }); }); it('should correctly get tree structure', async () => { const trees = await loader.getAllHarnesses(MatTreeHarness); const nestedTree = trees[1]; expect(await nestedTree.getTreeStructure()).toEqual({ children: [{text: 'Nested Group 1'}, {text: 'Nested Group 2'}], }); const firstGroup = (await nestedTree.getNodes({text: /Nested Group 1/}))[0]; await firstGroup.expand(); expect(await nestedTree.getTreeStructure()).toEqual({ children: [ { text: 'Nested Group 1', children: [ {text: 'Nested Leaf 1.1'}, {text: 'Nested Leaf 1.2'}, {text: 'Nested Leaf 1.3'}, ], }, {text: 'Nested Group 2'}, ], }); const secondGroup = (await nestedTree.getNodes({text: /Nested Group 2/}))[0]; await secondGroup.expand(); expect(await nestedTree.getTreeStructure()).toEqual({ children: [ { text: 'Nested Group 1', children: [ {text: 'Nested Leaf 1.1'}, {text: 'Nested Leaf 1.2'}, {text: 'Nested Leaf 1.3'}, ], }, { text: 'Nested Group 2', children: [{text: 'Nested Group 2.1'}], }, ], }); }); }); interface Node { name: string; children?: Node[]; } const FLAT_TREE_DATA: Node[] = [ { name: 'Flat Group 1', children: [{name: 'Flat Leaf 1.1'}, {name: 'Flat Leaf 1.2'}, {name: 'Flat Leaf 1.3'}], }, { name: 'Flat Group 2', children: [ { name: 'Flat Group 2.1', children: [{name: 'Flat Leaf 2.1.1'}, {name: 'Flat Leaf 2.1.2'}, {name: 'Flat Leaf 2.1.3'}], }, ], }, ]; const NESTED_TREE_DATA: Node[] = [ { name: 'Nested Group 1', children: [{name: 'Nested Leaf 1.1'}, {name: 'Nested Leaf 1.2'}, {name: 'Nested Leaf 1.3'}], }, { name: 'Nested Group 2', children: [ { name: 'Nested Group 2.1', children: [{name: 'Nested Leaf 2.1.1'}, {name: 'Nested Leaf 2.1.2'}], }, ], }, ]; interface ExampleFlatNode { expandable: boolean; name: string; level: number; } @Component({ template: ` <mat-tree [dataSource]="flatTreeDataSource" [treeControl]="flatTreeControl"> <!-- This is the tree node template for leaf nodes --> <mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding> {{node.name}} </mat-tree-node> <!-- This is the tree node template for expandable nodes --> <mat-tree-node *matTreeNodeDef="let node;when: flatTreeHasChild" matTreeNodePadding isExpandable> <button matTreeNodeToggle> Toggle </button> {{node.name}} </mat-tree-node> </mat-tree> <mat-tree [dataSource]="nestedTreeDataSource" [treeControl]="nestedTreeControl"> <!-- This is the tree node template for leaf nodes --> <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle> {{node.name}} </mat-tree-node> <!-- This is the tree node template for expandable nodes --> <mat-nested-tree-node *matTreeNodeDef="let node; when: nestedTreeHasChild" isExpandable> <button matTreeNodeToggle> Toggle </button> {{node.name}} <ul [class.example-tree-invisible]="!nestedTreeControl.isExpanded(node)"> <ng-container matTreeNodeOutlet></ng-container> </ul> </mat-nested-tree-node> </mat-tree> `, standalone: true, imports: [MatTreeModule], }) class TreeHarnessTest { private _transformer = (node: Node, level: number) => { return { expandable: !!node.children && node.children.length > 0, name: node.name, level: level, }; }; treeFlattener = new MatTreeFlattener( this._transformer, node => node.level, node => node.expandable, node => node.children, ); flatTreeControl = new FlatTreeControl<ExampleFlatNode>( node => node.level, node => node.expandable, ); flatTreeDataSource = new MatTreeFlatDataSource(this.flatTreeControl, this.treeFlattener); nestedTreeControl = new NestedTreeControl<Node>(node => node.children); nestedTreeDataSource = new MatTreeNestedDataSource<Node>(); constructor() { this.flatTreeDataSource.data = FLAT_TREE_DATA; this.nestedTreeDataSource.data = NESTED_TREE_DATA; } flatTreeHasChild = (_: number, node: ExampleFlatNode) => node.expandable; nestedTreeHasChild = (_: number, node: Node) => !!node.children && node.children.length > 0; } ```
/content/code_sandbox/src/material/tree/testing/tree-harness.spec.ts
xml
2016-01-04T18:50:02
2024-08-16T11:21:13
components
angular/components
24,263
2,279
```xml nsim_isa_family=av2hs nsim_isa_core=2 arcver=0x52 nsim_isa_rgf_num_banks=2 nsim_isa_rgf_banked_regs=32 nsim_isa_rgf_num_regs=32 nsim_isa_rgf_num_wr_ports=2 nsim_isa_big_endian=0 nsim_isa_lpc_size=32 nsim_isa_pc_size=32 nsim_isa_addr_size=32 nsim_isa_atomic_option=1 nsim_isa_ll64_option=1 nsim_isa_unaligned_option=1 nsim_isa_code_density_option=2 nsim_isa_div_rem_option=2 nsim_isa_swap_option=1 nsim_isa_bitscan_option=1 nsim_isa_mpy_option=9 nsim_isa_shift_option=3 nsim_isa_fpud_div_option=1 nsim_isa_fpu_mac_option=1 nsim_isa_enable_timer_0=1 nsim_isa_timer_0_int_level=1 nsim_isa_enable_timer_1=1 nsim_isa_timer_1_int_level=0 nsim_isa_rtc_option=1 nsim_isa_num_actionpoints=8 nsim_isa_stack_checking=1 nsim_isa_number_of_interrupts=72 nsim_isa_number_of_levels=2 nsim_isa_number_of_external_interrupts=70 nsim_isa_fast_irq=1 nsim_isa_intvbase_preset=0x0 dcache=65536,64,2,a nsim_isa_dc_feature_level=2 nsim_isa_dc_uncached_region=1 nsim_isa_dc_mem_cycles=2 icache=65536,64,4,a nsim_isa_ic_feature_level=2 dccm_size=0x100000 dccm_base=0x80000000 nsim_isa_dccm_mem_cycles=2 iccm0_size=0x40000 iccm0_base=0x70000000 mpu_regions=16 mpu_version=3 ```
/content/code_sandbox/boards/snps/nsim/arc_classic/support/nsim_hs_hostlink.props
xml
2016-05-26T17:54:19
2024-08-16T18:09:06
zephyr
zephyrproject-rtos/zephyr
10,307
484
```xml import { hasNext, noNext } from '../asynciterablehelpers.js'; import { skipWhile } from 'ix/asynciterable/operators/index.js'; import { of } from 'ix/asynciterable/index.js'; test('AsyncIterable#skipWhile skips some', async () => { const xs = of(1, 2, 3, 4); const ys = xs.pipe(skipWhile(async (x) => x < 3)); const it = ys[Symbol.asyncIterator](); await hasNext(it, 3); await hasNext(it, 4); await noNext(it); }); test('AsyncIterable#skipWhile skips none', async () => { const xs = of(1, 2, 3, 4); const ys = xs.pipe(skipWhile(async () => false)); const it = ys[Symbol.asyncIterator](); await hasNext(it, 1); await hasNext(it, 2); await hasNext(it, 3); await hasNext(it, 4); await noNext(it); }); test('AsyncIterable#skipWhile skips all', async () => { const xs = of(1, 2, 3, 4); const ys = xs.pipe(skipWhile(async () => true)); const it = ys[Symbol.asyncIterator](); await noNext(it); }); test('AsyncIterable#skipWhile skips some another run', async () => { const xs = of(1, 2, 3, 4, 3, 2, 1); const ys = xs.pipe(skipWhile((x) => x < 3)); const it = ys[Symbol.asyncIterator](); await hasNext(it, 3); await hasNext(it, 4); await hasNext(it, 3); await hasNext(it, 2); await hasNext(it, 1); await noNext(it); }); test('AsyncIterable#skipWhile predicate throws', async () => { const err = new Error(); const xs = of(1, 2, 3, 4); const ys = xs.pipe( skipWhile(() => { throw err; }) ); const it = ys[Symbol.asyncIterator](); await expect(it.next()).rejects.toThrow(err); }); test('AsyncIterable#skipWhile with index', async () => { const xs = of(1, 2, 3, 4); const ys = xs.pipe(skipWhile(async (_, i) => i < 2)); const it = ys[Symbol.asyncIterator](); await hasNext(it, 3); await hasNext(it, 4); await noNext(it); }); ```
/content/code_sandbox/spec/asynciterable-operators/skipwhile-spec.ts
xml
2016-02-22T20:04:19
2024-08-09T18:46:41
IxJS
ReactiveX/IxJS
1,319
568
```xml import { ViewConfig } from '@statoscope/types'; import { StatoscopeWidget } from '../../types'; export type Options = { display?: 'block' | 'flex' | 'inline-flex'; direction?: 'row' | 'column'; shrink?: string; grow?: string; alignItems: string; justifyItems: string; alignContent: string; justifyContent: string; width?: string; height?: string; padding?: string; margin?: string; }; const stylesMap: Record<keyof Options, keyof CSSStyleDeclaration> = { display: 'display', direction: 'flexDirection', shrink: 'flexShrink', grow: 'flexGrow', alignItems: 'alignItems', justifyItems: 'justifyItems', alignContent: 'alignContent', justifyContent: 'justifyContent', width: 'width', height: 'height', padding: 'padding', margin: 'margin', }; export default function (discovery: StatoscopeWidget): void { discovery.view.define('box', (el, config, data?: Options, context?: unknown) => { el.style.display = data?.display ?? 'flex'; // @ts-ignore for (const [name, value] of Object.entries(config.options ?? {})) { // eslint-disable-next-line no-prototype-builtins if (stylesMap.hasOwnProperty(name)) { // @ts-ignore el.style[stylesMap[name]] = value; } } // @ts-ignore const content: ViewConfig<unknown, unknown> = config.content ?? []; return discovery.view.render(el, content, data, context); }); } ```
/content/code_sandbox/packages/webpack-ui/src/views/box.ts
xml
2016-11-30T14:09:21
2024-08-15T18:52:57
statoscope
statoscope/statoscope
1,423
356
```xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name"> </string> <string name="app_launcher_name"> </string> <string name="press_back_again"> </string> <string name="go_to_home_folder"> </string> <string name="set_as_home_folder"> </string> <string name="home_folder_updated"> </string> <string name="copy_path"> </string> <string name="path_copied"> </string> <string name="select_audio_file"> </string> <string name="search_folder"> </string> <string name="rooted_device_only"> .</string> <string name="recents"></string> <string name="show_recents"> </string> <string name="pdf_viewer"> PDF</string> <string name="invert_colors"> </string> <!-- Open as --> <string name="open_as"> </string> <string name="text_file"> </string> <string name="image_file"> </string> <string name="audio_file"> </string> <string name="video_file"> </string> <string name="other_file"> </string> <!-- Compression --> <string name="compress"></string> <string name="compress_pro"> (Pro)</string> <string name="decompress"></string> <string name="compress_as"> </string> <string name="compressing"></string> <string name="decompressing"></string> <string name="compression_successful"> </string> <string name="decompression_successful"> </string> <string name="compressing_failed"> </string> <string name="decompressing_failed"> </string> <!-- Favorites --> <string name="manage_favorites"> </string> <string name="go_to_favorite"> </string> <string name="favorites_activity_placeholder"> .</string> <!-- File Editor --> <string name="file_editor"> </string> <!-- Storage analysis --> <string name="storage_analysis"> </string> <string name="images"></string> <string name="videos"></string> <string name="audio"></string> <string name="documents"></string> <string name="downloads"></string> <string name="archives"></string> <string name="others"></string> <string name="storage_free"></string> <string name="total_storage">: %s</string> <!-- Settings --> <string name="enable_root_access"> </string> <string name="press_back_twice"> \"\" </string> <!-- Haven't found some strings? There's more at path_to_url --> </resources> ```
/content/code_sandbox/app/src/main/res/values-el/strings.xml
xml
2016-07-12T20:06:21
2024-08-16T13:08:21
Simple-File-Manager
SimpleMobileTools/Simple-File-Manager
1,490
616
```xml import * as React from 'react'; import { View } from 'react-native'; export default React.forwardRef<View>((props, ref) => ( <View ref={ref} accessibilityRole="button" {...props} /> )); ```
/content/code_sandbox/src/components/GestureHandlerButton.web.tsx
xml
2016-10-27T08:31:38
2024-08-16T12:03:40
react-native-gesture-handler
software-mansion/react-native-gesture-handler
5,989
48
```xml import { Component } from '@angular/core'; import { StyleDoc } from '@doc/toolbar/styledoc'; import { ImportDoc } from '@doc/toolbar/importdoc'; import { BasicDoc } from '@doc/toolbar/basicdoc'; import { TemplateDoc } from '@doc/toolbar/templatedoc'; import { AccessibilityDoc } from '@doc/toolbar/accessibilitydoc'; @Component({ templateUrl: './toolbardemo.html' }) export class ToolbarDemo { docs = [ { id: 'import', label: 'Import', component: ImportDoc }, { id: 'basic', label: 'Basic', component: BasicDoc }, { id: 'template', label: 'Template', component: TemplateDoc }, { id: 'style', label: 'Style', component: StyleDoc }, { id: 'accessibility', label: 'Accessibility', component: AccessibilityDoc } ]; } ```
/content/code_sandbox/src/app/showcase/pages/toolbar/toolbardemo.ts
xml
2016-01-16T09:23:28
2024-08-16T19:58:20
primeng
primefaces/primeng
9,969
214
```xml export { default as Box } from './Box'; export type { IBoxProps } from './Box'; export { default as Text } from './Text'; export type { ITextProps } from './Text'; export { Input, InputGroup, InputLeftAddon, InputRightAddon } from './Input'; export type { IInputProps } from './Input'; // export { default as View } from './View'; export { Checkbox } from './Checkbox'; export type { ICheckboxProps, ICheckboxGroupProps } from './Checkbox'; export { Radio, RadioContext } from './Radio'; export type { IRadioProps, IRadioGroupProps, IRadioValue, IRadioContext, IRadioComponentType, } from './Radio'; export { Icon, createIcon } from './Icon'; export type { IIconProps } from './Icon'; export { Column } from './Column'; export { Row } from './Row'; export { Button } from './Button'; export type { IButtonProps } from './Button'; export { Slider } from './Slider'; export type { ISliderProps } from './Slider'; export { Stack, VStack, HStack } from './Stack'; export type { IStackProps } from './Stack'; export { default as Image } from './Image'; export type { IImageProps } from './Image'; export { default as Select } from './Select'; export type { ISelectProps, ISelectItemProps } from './Select'; export { default as Spinner } from './Spinner'; export type { ISpinnerProps } from './Spinner'; export { default as Heading } from './Heading'; export type { IHeadingProps } from './Heading'; export { useFocus, useHover, useIsPressed, Pressable } from './Pressable'; export type { IPressableProps } from './Pressable'; export { default as Flex, Spacer } from './Flex'; export type { IFlexProps } from './Flex'; export { default as Switch } from './Switch'; export type { ISwitchProps } from './Switch'; export { default as TextArea } from './TextArea'; export type { ITextAreaProps } from './TextArea'; export { default as Link } from './Link'; export type { ILinkProps } from './Link'; export { List } from './List'; export type { IListProps, IListItemProps } from './List'; export { Hidden } from './Hidden'; export type { IHiddenProps } from './Hidden'; export { VisuallyHidden } from './VisuallyHidden'; export { default as ZStack } from './ZStack'; export type { IZStackProps } from './ZStack'; export { Overlay } from './Overlay'; export type { IOverlayProps } from './Overlay'; ```
/content/code_sandbox/src/components/primitives/index.ts
xml
2016-04-15T11:37:23
2024-08-14T16:16:44
NativeBase
GeekyAnts/NativeBase
20,132
560
```xml <vector xmlns:android="path_to_url" android:height="24dp" android:viewportHeight="200.0" android:viewportWidth="200.0" android:width="24dp"> <path android:fillColor="@color/defaultTextColor" android:pathData="M150.97,187.01 L46.98,187.01c-10.61,0 -17.87,-9.13 -17.87,-19.34L29.11,30.98c0,-10.95 8.09,-18.47 17.87,-18.47l54.84,0c1.46,0 2.85,0.67 3.88,1.7l62.42,62.03c1.01,1.02 2.77,2.44 2.77,3.87l0,87.56C170.89,178.79 160.97,187.01 150.97,187.01zM46.98,23.42c-4.42,0 -6.97,3.33 -6.97,7.56l0,136.7c0,4.26 2.34,8.43 6.97,8.43l103.98,0c4.35,0 9.02,-4.16 9.02,-8.43l0,-85.32L99.55,23.42 46.98,23.42zM164.41,83.4 L115.27,83.4c-9.08,0 -15.27,-8.04 -15.27,-16.73L100,17.53c0,-1.1 -0.53,-2.09 0.48,-2.52 1.02,-0.42 1.59,-0.2 2.37,0.58L166.63,78.9c0.79,0.77 0.88,1.87 0.46,2.89C166.66,82.81 165.52,83.4 164.41,83.4zM105.45,24.06l0,42.61c0,5.78 3.66,11.28 9.82,11.28l42.5,0L105.45,24.06zM78.53,107.94 L56.71,107.94c-1.5,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l21.81,0c1.51,0 2.73,1.22 2.73,2.73C81.25,106.72 80.03,107.94 78.53,107.94zM116.7,107.94 L89.43,107.94c-1.51,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l27.26,0c1.51,0 2.73,1.22 2.73,2.73C119.43,106.72 118.21,107.94 116.7,107.94zM138.51,107.94l-10.91,0c-1.51,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l10.91,0c1.51,0 2.73,1.22 2.73,2.73C141.24,106.72 140.02,107.94 138.51,107.94zM67.62,121.57l-10.91,0c-1.5,0 -2.73,-1.22 -2.73,-2.73s1.22,-2.73 2.73,-2.73l10.91,0c1.51,0 2.73,1.22 2.73,2.73S69.13,121.57 67.62,121.57zM100.34,121.57 L78.53,121.57c-1.5,0 -2.73,-1.22 -2.73,-2.73s1.22,-2.73 2.73,-2.73L100.34,116.12c1.51,0 2.73,1.22 2.73,2.73S101.85,121.57 100.34,121.57zM138.51,121.57 L111.25,121.57c-1.51,0 -2.73,-1.22 -2.73,-2.73s1.22,-2.73 2.73,-2.73l27.26,0c1.51,0 2.73,1.22 2.73,2.73S140.02,121.57 138.51,121.57zM83.98,137.93 L56.71,137.93c-1.5,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l27.26,0c1.51,0 2.73,1.22 2.73,2.73C86.71,136.71 85.49,137.93 83.98,137.93zM122.15,137.93 L94.89,137.93c-1.51,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l27.26,0c1.51,0 2.73,1.22 2.73,2.73C124.88,136.71 123.66,137.93 122.15,137.93zM138.51,137.93 L133.06,137.93c-1.51,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l5.45,0c1.51,0 2.73,1.22 2.73,2.73C141.24,136.71 140.02,137.93 138.51,137.93zM67.62,151.56l-10.91,0c-1.5,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l10.91,0c1.51,0 2.73,1.22 2.73,2.73C70.35,150.34 69.13,151.56 67.62,151.56zM97.61,151.56l-19.09,0c-1.5,0 -2.73,-1.22 -2.73,-2.73 0,-1.51 1.22,-2.73 2.73,-2.73l19.09,0c1.5,0 2.73,1.22 2.73,2.73C100.34,150.34 99.12,151.56 97.61,151.56z"/> </vector> ```
/content/code_sandbox/app/src/main/res/drawable/bug.xml
xml
2016-02-20T13:10:14
2024-08-14T07:53:05
SeeWeather
xcc3641/SeeWeather
3,448
1,734
```xml export { getSortedRoutes } from './sorted-routes' export { isDynamicRoute } from './is-dynamic' ```
/content/code_sandbox/packages/next/src/shared/lib/router/utils/index.ts
xml
2016-10-05T23:32:51
2024-08-16T19:44:30
next.js
vercel/next.js
124,056
25
```xml import type * as webpack from 'webpack'; export interface IAddWorkerEntryPointPluginOptions { id: string; entry: string; filename: string; chunkFilename?: string; plugins: webpack.WebpackPluginInstance[]; } function getCompilerHook( compiler: webpack.Compiler, { id, entry, filename, chunkFilename, plugins }: IAddWorkerEntryPointPluginOptions ) { const webpack = compiler.webpack ?? require('webpack'); return function ( compilation: webpack.Compilation, callback: (error?: Error | null | false) => void ) { const outputOptions = { filename, chunkFilename, publicPath: compilation.outputOptions.publicPath, // HACK: globalObject is necessary to fix path_to_url globalObject: 'this' }; const childCompiler = compilation.createChildCompiler(id, outputOptions, [ new webpack.webworker.WebWorkerTemplatePlugin(), new webpack.LoaderTargetPlugin('webworker') ]); const SingleEntryPlugin = webpack.EntryPlugin ?? webpack.SingleEntryPlugin; new SingleEntryPlugin(compiler.context, entry, 'main').apply(childCompiler); plugins.forEach((plugin) => plugin.apply(childCompiler)); childCompiler.runAsChild((err?: Error | null) => callback(err)); }; } export class AddWorkerEntryPointPlugin implements webpack.WebpackPluginInstance { private readonly options: IAddWorkerEntryPointPluginOptions; constructor({ id, entry, filename, chunkFilename = undefined, plugins }: IAddWorkerEntryPointPluginOptions) { this.options = { id, entry, filename, chunkFilename, plugins }; } apply(compiler: webpack.Compiler) { const webpack = compiler.webpack ?? require('webpack'); const compilerHook = getCompilerHook(compiler, this.options); const majorVersion = webpack.version.split('.')[0]; if (parseInt(majorVersion) < 4) { (<any>compiler).plugin('make', compilerHook); } else { compiler.hooks.make.tapAsync('AddWorkerEntryPointPlugin', compilerHook); } } } ```
/content/code_sandbox/webpack-plugin/src/plugins/AddWorkerEntryPointPlugin.ts
xml
2016-06-07T16:56:31
2024-08-16T17:17:05
monaco-editor
microsoft/monaco-editor
39,508
449
```xml <!-- Description: rss channel title - cdata naked markup --> <rss version="2.0"> <channel> <title><![CDATA[<p>Feed Title</p>]]></title> </channel> </rss> ```
/content/code_sandbox/testdata/parser/rss/rss_channel_title_cdata_naked_markup.xml
xml
2016-01-23T02:44:34
2024-08-16T15:16:03
gofeed
mmcdole/gofeed
2,547
50
```xml /************************************************************* * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ /** * @fileoverview Generic WrapperFactory class for creating Wrapper objects * * @author dpvc@mathjax.org (Davide Cervone) */ import {Node} from './Node.js'; import {Wrapper, WrapperClass} from './Wrapper.js'; import {Factory, AbstractFactory} from './Factory.js'; /*****************************************************************/ /** * The generic WrapperFactory class * * @template N The Node type being created by the factory * @template W The Wrapper type being produced (instance type) * @template C The Wrapper class (for static values) */ export interface WrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>> extends Factory<W, C> { /** * @param {N} node The node to be wrapped * @param {any[]} args Any additional arguments needed when wrapping the node * @return {W} The newly wrapped node */ wrap(node: N, ...args: any[]): W; } /*****************************************************************/ /** * The generic WrapperFactory class * * @template N The Node type being created by the factory * @template W The Wrapper type being produced (instance type) * @template C The Wrapper class (for static values) */ export abstract class AbstractWrapperFactory<N extends Node, W extends Wrapper<N, W>, C extends WrapperClass<N, W>> extends AbstractFactory<W, C> implements WrapperFactory<N, W, C> { /** * @param {N} node The node to be wrapped * @param {any[]} args Any additional arguments needed when wrapping the node * @return {W} The newly wrapped node */ public wrap(node: N, ...args: any[]): W { return this.create(node.kind, node, ...args); } } ```
/content/code_sandbox/ts/core/Tree/WrapperFactory.ts
xml
2016-02-23T09:52:03
2024-08-16T04:46:50
MathJax-src
mathjax/MathJax-src
2,017
432
```xml // // // path_to_url // // Unless required by applicable law or agreed to in writing, software // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. const magic = 42; export const fun = () => { return magic; } ```
/content/code_sandbox/tests/integration/nodejs/codepaths-workspaces/packages/my-dynamic-provider/relative.ts
xml
2016-10-31T21:02:47
2024-08-16T19:47:04
pulumi
pulumi/pulumi
20,743
56
```xml <?xml version="1.0" encoding="UTF-8"?> <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ --> <beans xmlns="path_to_url" xmlns:context="path_to_url" xmlns:task="path_to_url" xmlns:gui="path_to_url"> <bean class="com.haulmont.cuba.core.sys.CubaPropertyPlaceholderConfigurer"/> <!-- Annotation-based beans --> <context:component-scan base-package="com.haulmont.cuba"> <context:exclude-filter type="regex" expression="com\.haulmont\.cuba\.web\.widgets\..*"/> <!--exclude dispatcher--> <context:exclude-filter type="regex" expression="com\.haulmont\.cuba\.web\.controllers\..*"/> </context:component-scan> <bean id="vaadinSessionScope" class="com.haulmont.cuba.web.sys.VaadinSessionScope"/> <!-- Various beans with non-standard configuration --> <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer"> <property name="scopes"> <map> <entry key="vaadin" value-ref="vaadinSessionScope"/> </map> </property> </bean> <bean id="cuba_UserSession" factory-bean="cuba_UserSessionSource" factory-method="getUserSession" scope="prototype"/> <bean id="cuba_PasswordEncryption" class="com.haulmont.cuba.core.sys.PasswordEncryptionImpl"> <property name="encryptionModule" ref="${cuba.passwordEncryptionModule}"/> <property name="legacyEncryptionModule" ref="${cuba.legacyPasswordEncryptionModule}"/> </bean> <bean id="cuba_Events" class="com.haulmont.cuba.web.sys.WebEvents"/> <!-- Screens registry --> <gui:screens base-packages="com.haulmont.cuba.gui.screen.actions,com.haulmont.cuba.gui.app,com.haulmont.cuba.web.app"/> <gui:actions base-packages="com.haulmont.cuba.gui.actions"/> <!-- MBeans registration --> <bean id="cuba_web_MBeanExporter" class="com.haulmont.cuba.core.sys.jmx.MBeanExporter" lazy-init="false"> <property name="beans"> <map> <entry key="${cuba.webContextName}.cuba:type=ConfigStorage" value-ref="cuba_ConfigStorageMBean"/> <entry key="${cuba.webContextName}.cuba:type=CachingFacade" value-ref="cuba_CachingFacadeMBean"/> <entry key="${cuba.webContextName}.cuba:type=FileUploading" value-ref="cuba_FileUploading"/> <entry key="${cuba.webContextName}.cuba:type=JmxNodeIdentifier" value-ref="cuba_JmxNodeIdentifierMBean"/> <entry key="${cuba.webContextName}.cuba:type=JmxLogControl" value-ref="cuba_JmxLogControlMBean"/> <entry key="${cuba.webContextName}.cuba:type=ClassLoaderManager" value-ref="cuba_ClassLoaderManager"/> <entry key="${cuba.webContextName}.cuba:type=StatisticsCounter" value-ref="cuba_StatisticsCounterMBean"/> </map> </property> </bean> <bean id="cuba_AnnotationMBeanExporter" class="com.haulmont.cuba.core.sys.jmx.AnnotationMBeanExporter" lazy-init="false"/> <!-- Remote stubs --> <bean id="cuba_ServerSorter" class="com.haulmont.cuba.core.sys.remoting.discovery.RandomServerSorter"/> <bean id="cuba_AnonymousSessionUrlsHolder" class="com.haulmont.cuba.web.sys.remoting.discovery.WebHttpSessionUrlsHolder"/> <bean id="cuba_ServerSelector" class="com.haulmont.cuba.core.sys.remoting.discovery.StaticServerSelector" init-method="init"> <property name="baseUrl" value="${cuba.connectionUrlList}"/> <property name="serverSorter" ref="cuba_ServerSorter"/> <property name="anonymousSessionUrlsHolder" ref="cuba_AnonymousSessionUrlsHolder"/> <property name="servletPath" value="remoting"/> </bean> <bean id="cuba_proxyCreator" class="com.haulmont.cuba.web.sys.remoting.WebRemoteProxyBeanCreator"> <property name="serverSelector" ref="cuba_ServerSelector"/> <property name="remoteServices"> <map> <entry key="cuba_AuthenticationService" value="com.haulmont.cuba.security.auth.AuthenticationService"/> <entry key="cuba_TrustedClientService" value="com.haulmont.cuba.security.app.TrustedClientService"/> <entry key="cuba_ServerInfoService" value="com.haulmont.cuba.core.app.ServerInfoService"/> <entry key="cuba_UserSettingService" value="com.haulmont.cuba.security.app.UserSettingService"/> <entry key="cuba_UserManagementService" value="com.haulmont.cuba.security.app.UserManagementService"/> <entry key="cuba_DataService" value="com.haulmont.cuba.core.app.DataService"/> <entry key="cuba_ConfigStorageService" value="com.haulmont.cuba.core.app.ConfigStorageService"/> <entry key="cuba_PersistenceManagerService" value="com.haulmont.cuba.core.app.PersistenceManagerService"/> <entry key="cuba_LockService" value="com.haulmont.cuba.core.app.LockService"/> <entry key="cuba_UserSessionService" value="com.haulmont.cuba.security.app.UserSessionService"/> <entry key="cuba_FoldersService" value="com.haulmont.cuba.core.app.FoldersService"/> <entry key="cuba_EmailService" value="com.haulmont.cuba.core.app.EmailService"/> <entry key="cuba_FileStorageService" value="com.haulmont.cuba.core.app.FileStorageService"/> <entry key="cuba_EntitySnapshotService" value="com.haulmont.cuba.core.app.EntitySnapshotService"/> <entry key="cuba_UniqueNumbersService" value="com.haulmont.cuba.core.app.UniqueNumbersService"/> <entry key="cuba_LocalizedMessageService" value="com.haulmont.cuba.core.app.LocalizedMessageService"/> <entry key="cuba_ResourceService" value="com.haulmont.cuba.core.app.ResourceService"/> <entry key="cuba_ScheduledTasksService" value="com.haulmont.cuba.core.app.SchedulingService"/> <entry key="cuba_EntityLogService" value="com.haulmont.cuba.core.app.EntityLogService"/> <entry key="cuba_TestingService" value="com.haulmont.cuba.core.app.TestingService"/> <entry key="cuba_DomainDescriptionService" value="com.haulmont.cuba.core.app.DomainDescriptionService"/> <entry key="cuba_RelatedEntitiesService" value="com.haulmont.cuba.core.app.RelatedEntitiesService"/> <entry key="cuba_EntitySqlGenerationService" value="com.haulmont.cuba.core.app.EntitySqlGenerationService"/> <entry key="cuba_NumberIdService" value="com.haulmont.cuba.core.app.NumberIdService"/> <entry key="cuba_QueryResultsService" value="com.haulmont.cuba.core.app.QueryResultsService"/> <entry key="cuba_DynamicAttributesCacheService" value="com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesCacheService"/> <entry key="cuba_EntityRestoreService" value="com.haulmont.cuba.core.app.EntityRestoreService"/> <entry key="cuba_LocalFileExchangeService" value="com.haulmont.cuba.core.sys.remoting.LocalFileExchangeService"/> <entry key="cuba_EntityImportExportService" value="com.haulmont.cuba.core.app.importexport.EntityImportExportService"/> <entry key="cuba_ConstraintLocalizationService" value="com.haulmont.cuba.core.app.ConstraintLocalizationService"/> <entry key="cuba_AttributeAccessService" value="com.haulmont.cuba.core.app.AttributeAccessService"/> <entry key="cuba_ExceptionReportService" value="com.haulmont.cuba.core.app.ExceptionReportService"/> <entry key="cuba_BulkEditorDataService" value="com.haulmont.cuba.core.app.BulkEditorDataService"/> <entry key="cuba_PersistenceSecurityService" value="com.haulmont.cuba.security.group.PersistenceSecurityService"/> <entry key="cuba_AccessGroupsService" value="com.haulmont.cuba.security.group.AccessGroupsService"/> <entry key="cuba_AttributeOptionsLoaderService" value="com.haulmont.cuba.core.app.dynamicattributes.AttributeOptionsLoaderService"/> <entry key="cuba_RolesService" value="com.haulmont.cuba.security.role.RolesService"/> <entry key="cuba_SecurityScopesService" value="com.haulmont.cuba.security.app.SecurityScopesService"/> <entry key="cuba_ScreenProfilerService" value="com.haulmont.cuba.core.app.ScreenProfilerService"/> </map> </property> </bean> <!-- Web-level exception handlers --> <bean id="cuba_exceptionHandlersConf" class="com.haulmont.cuba.web.exception.ExceptionHandlersConfiguration"> <property name="handlerClasses"> <list> <value>com.haulmont.cuba.web.exception.NoUserSessionHandler</value> <value>com.haulmont.cuba.web.exception.InvalidValueExceptionHandler</value> <value>com.haulmont.cuba.web.exception.MismatchedUserSessionHandler</value> </list> </property> </bean> <!-- Spring scheduling setup --> <bean id="scheduler" class="com.haulmont.cuba.core.sys.CubaThreadPoolTaskScheduler"> <property name="daemon" value="true"/> <property name="poolSize" value="10"/> <property name="statisticsAccumulator" ref="cuba_WebStatisticsAccumulator"/> <property name="threadNamePrefix" value="cuba_web_scheduler-"/> </bean> <task:scheduled-tasks scheduler="scheduler"> <task:scheduled ref="cuba_TriggerFilesProcessor" method="process" fixed-delay="${cuba.triggerFilesCheckInterval?:5000}"/> <task:scheduled ref="cuba_WebStatisticsAccumulator" method="gatherParameters" fixed-rate="5000"/> <task:scheduled ref="cuba_FileUploading" method="clearTempDirectory" cron="0 0 0 * * 2,4,6"/> </task:scheduled-tasks> <!-- Background Tasks --> <bean id="backgroundWorkerScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"> <property name="daemon" value="true"/> <property name="poolSize" value="1"/> <property name="threadNamePrefix" value="cuba_web_backgroundScheduler-"/> </bean> <task:scheduled-tasks scheduler="backgroundWorkerScheduler"> <task:scheduled ref="cuba_BackgroundWorker_WatchDog" method="cleanupTasks" fixed-delay="${cuba.backgroundWorker.timeoutCheckInterval?:5000}"/> </task:scheduled-tasks> </beans> ```
/content/code_sandbox/modules/web/src/com/haulmont/cuba/web-spring.xml
xml
2016-03-24T07:55:56
2024-07-14T05:13:48
cuba
cuba-platform/cuba
1,342
2,479
```xml import { mocked } from 'ts-jest/utils'; import fs from 'fs'; import { sync } from 'mkdirp'; import signale from 'signale'; import chalk from 'chalk'; import createTemplate from '../template'; jest.mock('mkdirp'); jest.mock('chalk', () => { return { green: jest.fn() }; }); const syncMocked = mocked(sync); const chalkGreenMocked = mocked(chalk.green); describe('template', () => { afterAll(() => { jest.restoreAllMocks(); jest.resetAllMocks(); }); afterEach(() => { jest.clearAllMocks(); }); describe('#createTemplate', () => { it('should create react component code snippet', () => { chalkGreenMocked.mockImplementation((str: any) => str); const openSyncMocked = jest.spyOn(fs, 'openSync').mockReturnValue(1); const writeSyncMocked = jest.spyOn(fs, 'writeSync').mockReturnValue(1); const infoStub = jest.spyOn(console, 'info').mockReturnValue(); const signaleSuccessStub = jest.spyOn(signale, 'success').mockReturnValue(1); createTemplate({ compName: 'primary button' }); expect(syncMocked).toBeCalledWith('src/primary-button'); expect(syncMocked).toBeCalledWith('src/primary-button/style'); expect(syncMocked).toBeCalledWith('src/primary-button/__tests__'); expect(infoStub).toBeCalledWith(expect.stringMatching('create src/primary-button/index.ts')); expect(infoStub).toBeCalledWith(expect.stringMatching('create src/primary-button/demo.md')); expect(infoStub).toBeCalledWith( expect.stringMatching('create src/primary-button/interface.ts'), ); expect(infoStub).toBeCalledWith( expect.stringMatching('create src/primary-button/primary button.tsx'), ); expect(infoStub).toBeCalledWith( expect.stringMatching('create src/primary-button/style/index.ts'), ); expect(infoStub).toBeCalledWith( expect.stringMatching('create src/primary-button/style/index.scss'), ); expect(infoStub).toBeCalledWith( expect.stringMatching('create src/primary-button/__tests__/index.test.tsx'), ); expect(infoStub).toBeCalledTimes(7); expect(openSyncMocked).toBeCalledTimes(7); expect(writeSyncMocked).toBeCalledTimes(7); expect(signaleSuccessStub).toBeCalledWith('create component templates successfully!!'); }); }); }); ```
/content/code_sandbox/packages/zarm-cli/src/__tests__/template.spec.ts
xml
2016-07-13T11:45:37
2024-08-12T19:23:48
zarm
ZhongAnTech/zarm
1,707
536
```xml <clickhouse> <profiles> <default> <max_memory_usage>10000000000</max_memory_usage> <use_uncompressed_cache>0</use_uncompressed_cache> <load_balancing>random</load_balancing> <max_concurrent_queries_for_all_users>2</max_concurrent_queries_for_all_users> </default> <someuser> <max_memory_usage>10000000000</max_memory_usage> <use_uncompressed_cache>0</use_uncompressed_cache> <load_balancing>random</load_balancing> </someuser> </profiles> <users> <default> <password></password> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>default</profile> <quota>default</quota> </default> <someuser> <password></password> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>someuser</profile> <quota>default</quota> </someuser> </users> <quotas> <default> </default> </quotas> </clickhouse> ```
/content/code_sandbox/tests/integration/test_concurrent_queries_for_all_users_restriction/configs/user_restrictions.xml
xml
2016-06-02T08:28:18
2024-08-16T18:39:33
ClickHouse
ClickHouse/ClickHouse
36,234
280
```xml <?xml version="1.0"?> <!-- ~ ~ ~ path_to_url ~ ~ Unless required by applicable law or agreed to in writing, software ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <project xsi:schemaLocation="path_to_url path_to_url" xmlns="path_to_url" xmlns:xsi="path_to_url"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.weibo</groupId> <artifactId>motan-demo</artifactId> <version>1.2.4-SNAPSHOT</version> </parent> <artifactId>motan-demo-api</artifactId> <name>motan-demo-api</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.10</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-sources/annotations</source> </sources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${java.source.jdk}</source> <target>${java.source.jdk}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> <executions> <execution> <id>process-annotations</id> <phase>generate-sources</phase> <goals> <goal>compile</goal> </goals> <configuration> <fork>true</fork> <!-- if true, jvm options -DmotanGeneratePath=xxx maybe not work --> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> ```
/content/code_sandbox/motan-demo/motan-demo-api/pom.xml
xml
2016-04-20T10:56:17
2024-08-16T01:20:43
motan
weibocom/motan
5,882
510
```xml import type { IconName } from '@proton/components/components'; import type { ColorRGB } from '@proton/pass/types'; import { VaultColor, VaultIcon } from '@proton/pass/types/protobuf/vault-v1'; const numericEntries = <T extends Record<number, any>>( obj: T ): [number, T extends Record<any, infer U> ? U : never][] => Object.keys(obj).map((key) => [Number(key), obj[Number(key)]]); export const VAULT_COLOR_MAP: Record<number, ColorRGB> = { [VaultColor.COLOR_UNSPECIFIED]: '140 140 147', [VaultColor.COLOR_CUSTOM]: '167 121 255', [VaultColor.COLOR1]: '167 121 255', [VaultColor.COLOR2]: '242 146 146', [VaultColor.COLOR3]: '247 215 117', [VaultColor.COLOR4]: '145 199 153', [VaultColor.COLOR5]: '146 179 242', [VaultColor.COLOR6]: '235 141 214', [VaultColor.COLOR7]: '205 90 111', [VaultColor.COLOR8]: '228 163 103', [VaultColor.COLOR9]: '230 230 230', [VaultColor.COLOR10]: '158 226 230', }; export const VAULT_COLORS = numericEntries(VAULT_COLOR_MAP); export const VAULT_ICON_MAP: Record<number, IconName> = { [VaultIcon.ICON_UNSPECIFIED]: 'pass-home', [VaultIcon.ICON_CUSTOM]: 'pass-home', [VaultIcon.ICON1]: 'pass-home', [VaultIcon.ICON2]: 'pass-work', [VaultIcon.ICON3]: 'pass-gift', [VaultIcon.ICON4]: 'pass-shop', [VaultIcon.ICON5]: 'pass-heart', [VaultIcon.ICON6]: 'pass-bear', [VaultIcon.ICON7]: 'pass-circles', [VaultIcon.ICON8]: 'pass-flower', [VaultIcon.ICON9]: 'pass-group', [VaultIcon.ICON10]: 'pass-pacman', [VaultIcon.ICON11]: 'pass-shopping-cart', [VaultIcon.ICON12]: 'pass-leaf', [VaultIcon.ICON13]: 'pass-shield', [VaultIcon.ICON14]: 'pass-basketball', [VaultIcon.ICON15]: 'pass-credit-card', [VaultIcon.ICON16]: 'pass-fish', [VaultIcon.ICON17]: 'pass-smile', [VaultIcon.ICON18]: 'pass-lock', [VaultIcon.ICON19]: 'pass-mushroom', [VaultIcon.ICON20]: 'pass-star', [VaultIcon.ICON21]: 'pass-fire', [VaultIcon.ICON22]: 'pass-wallet', [VaultIcon.ICON23]: 'pass-bookmark', [VaultIcon.ICON24]: 'pass-cream', [VaultIcon.ICON25]: 'pass-laptop', [VaultIcon.ICON26]: 'pass-json', [VaultIcon.ICON27]: 'pass-book', [VaultIcon.ICON28]: 'pass-box', [VaultIcon.ICON29]: 'pass-atom', [VaultIcon.ICON30]: 'pass-cheque', }; export const VAULT_ICONS = numericEntries(VAULT_ICON_MAP); ```
/content/code_sandbox/packages/pass/components/Vault/constants.ts
xml
2016-06-08T11:16:51
2024-08-16T14:14:27
WebClients
ProtonMail/WebClients
4,300
742
```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="path_to_url" xmlns:xsi="path_to_url" xsi:schemaLocation="path_to_url path_to_url"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>io.camunda</groupId> <artifactId>tasklist-parent</artifactId> <version>8.6.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <name>Tasklist Webjar</name> <artifactId>tasklist-webjar</artifactId> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <configuration> <installDirectory>target</installDirectory> </configuration> <executions> <execution> <id>install node and yarn</id> <goals> <goal>install-node-and-yarn</goal> </goals> <configuration> <skip>${skip.fe.build}</skip> <nodeVersion>${version.node}</nodeVersion> <yarnVersion>${version.yarn}</yarnVersion> </configuration> </execution> <execution> <id>update package.json version</id> <goals> <goal>yarn</goal> </goals> <configuration> <skip>${skip.fe.build}</skip> <arguments>version --new-version=${project.version} --no-git-tag-version</arguments> </configuration> </execution> <execution> <id>yarn install</id> <goals> <goal>yarn</goal> </goals> <configuration> <failOnError>false</failOnError> <skip>${skip.fe.build}</skip> </configuration> </execution> <execution> <id>yarn build</id> <goals> <goal>yarn</goal> </goals> <configuration> <failOnError>false</failOnError> <skip>${skip.fe.build}</skip> <arguments>build</arguments> </configuration> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <!-- skip spotless formatter as client has its own formatter --> <plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </pluginManagement> <resources> <resource> <directory>build</directory> <targetPath>${project.build.outputDirectory}/META-INF/resources/tasklist</targetPath> </resource> </resources> </build> <profiles> <profile> <id>skipFrontendBuild</id> <properties> <skip.fe.build>true</skip.fe.build> </properties> </profile> </profiles> </project> ```
/content/code_sandbox/tasklist/client/pom.xml
xml
2016-03-20T03:38:04
2024-08-16T19:59:58
camunda
camunda/camunda
3,172
681
```xml import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import WalletsWrapper from '../_utils/WalletsWrapper'; import ExportWalletToFileDialog from '../../../../source/renderer/app/components/wallet/settings/ExportWalletToFileDialog'; storiesOf('Wallets / Export to File', module) .addDecorator(WalletsWrapper) // ====== Stories ====== .add('default', () => ( <div> <ExportWalletToFileDialog walletName="Test Wallet" isSubmitting={false} // @ts-ignore ts-migrate(2322) FIXME: Type 'HandlerFunction' is not assignable to type '... Remove this comment to see the full error message onSubmit={action('onSubmit')} onClose={action('onClose')} /> </div> )) .add('submitting', () => ( <div> <ExportWalletToFileDialog walletName="Test Wallet" isSubmitting // @ts-ignore ts-migrate(2322) FIXME: Type 'HandlerFunction' is not assignable to type '... Remove this comment to see the full error message onSubmit={action('onSubmit')} onClose={action('onClose')} /> </div> )) .add('spending password', () => ( <div> <ExportWalletToFileDialog walletName="Test Wallet" isSubmitting={false} // @ts-ignore ts-migrate(2322) FIXME: Type 'HandlerFunction' is not assignable to type '... Remove this comment to see the full error message onSubmit={action('onSubmit')} onClose={action('onClose')} /> </div> )); ```
/content/code_sandbox/storybook/stories/wallets/export/WalletExportToFile.stories.tsx
xml
2016-10-05T13:48:54
2024-08-13T22:03:19
daedalus
input-output-hk/daedalus
1,230
368
```xml import { StorybookError } from './storybook-error'; /** * If you can't find a suitable category for your error, create one based on the package name/file * path of which the error is thrown. For instance: If it's from `@storybook/client-logger`, then * MANAGER_CLIENT-LOGGER * * Categories are prefixed by a logical grouping, e.g. MANAGER_ to prevent manager and preview * errors from having the same category and error code. */ export enum Category { MANAGER_UNCAUGHT = 'MANAGER_UNCAUGHT', MANAGER_UI = 'MANAGER_UI', MANAGER_API = 'MANAGER_API', MANAGER_CLIENT_LOGGER = 'MANAGER_CLIENT-LOGGER', MANAGER_CHANNELS = 'MANAGER_CHANNELS', MANAGER_CORE_EVENTS = 'MANAGER_CORE-EVENTS', MANAGER_ROUTER = 'MANAGER_ROUTER', MANAGER_THEMING = 'MANAGER_THEMING', } export class ProviderDoesNotExtendBaseProviderError extends StorybookError { constructor() { super({ category: Category.MANAGER_UI, code: 1, message: `The Provider passed into Storybook's UI is not extended from the base Provider. Please check your Provider implementation.`, }); } } export class UncaughtManagerError extends StorybookError { constructor( public data: { error: Error; } ) { super({ category: Category.MANAGER_UNCAUGHT, code: 1, message: data.error.message, }); this.stack = data.error.stack; } } ```
/content/code_sandbox/code/core/src/manager-errors.ts
xml
2016-03-18T04:23:44
2024-08-16T19:22:08
storybook
storybookjs/storybook
83,755
337
```xml import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { DatePipe } from '@angular/common'; import { Artifact } from '../../../../../../../ng-swagger-gen/models/artifact'; enum Types { CREATED = 'created', TYPE = 'type', MEDIA_TYPE = 'media_type', MANIFEST_MEDIA_TYPE = 'manifest_media_type', DIGEST = 'digest', SIZE = 'size', PUSH_TIME = 'push_time', PULL_TIME = 'pull_time', } @Component({ selector: 'artifact-common-properties', templateUrl: './artifact-common-properties.component.html', styleUrls: ['./artifact-common-properties.component.scss'], }) export class ArtifactCommonPropertiesComponent implements OnChanges { @Input() artifactDetails: Artifact; commonProperties: { [key: string]: any } = {}; constructor() {} ngOnChanges(changes: SimpleChanges) { if (changes && changes['artifactDetails']) { if (this.artifactDetails) { Object.assign( this.commonProperties, this.artifactDetails.extra_attrs, this.artifactDetails.annotations ); for (let name in this.commonProperties) { if (this.commonProperties.hasOwnProperty(name)) { if (typeof this.commonProperties[name] === 'object') { if (this.commonProperties[name] === null) { this.commonProperties[name] = ''; } else { this.commonProperties[name] = JSON.stringify( this.commonProperties[name] ); } } if (name === Types.CREATED) { this.commonProperties[name] = new DatePipe( 'en-us' ).transform(this.commonProperties[name], 'short'); } } } } } } hasCommonProperties(): boolean { return JSON.stringify(this.commonProperties) !== '{}'; } } ```
/content/code_sandbox/src/portal/src/app/base/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.ts
xml
2016-01-28T21:10:28
2024-08-16T15:28:34
harbor
goharbor/harbor
23,335
381
```xml import { IOption, IQueryParams } from "../../types"; import { IUser, IUserDetails } from "../../../auth/types"; import React from "react"; import SelectWithSearch from "../../SelectWithSearch"; import { queries } from "../graphql"; export default (props: { queryParams?: IQueryParams; filterParams?: { ids?: string[]; status?: string }; label: string; onSelect: (value: string[] | string, name: string) => void; multi?: boolean; customOption?: IOption; customField?: string; initialValue?: string | string[]; name: string; }) => { const { queryParams, onSelect, customOption, customField, initialValue, multi = true, label, filterParams, name, } = props; const defaultValue = queryParams ? queryParams[name] : initialValue; // get user options for react-select-plus function generateUserOptions(array: IUser[] = []): IOption[] { return array.map((item) => { const user = item || ({} as IUser); const details = item.details || ({} as IUserDetails); const includeCustomFieldOnSelectLabel = customField && user[customField] ? user[customField] : ""; const generateLabel = (details.fullName || user.email) + "\t" + includeCustomFieldOnSelectLabel; return { value: user._id, label: generateLabel, avatar: details.avatar, }; }); } return ( <SelectWithSearch label={label} queryName="users" name={name} filterParams={filterParams} initialValue={defaultValue} generateOptions={generateUserOptions} onSelect={onSelect} customQuery={queries.users} customOption={customOption} multi={multi} /> ); }; ```
/content/code_sandbox/exm/modules/common/team/containers/SelectTeamMembers.tsx
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
400
```xml import { LoanSchedule } from '../interface/LoanContract'; type Params = { tenor: number; customPayment?: number; customInterest?: number; interestRate: number; isPayFirstMonth?: boolean; leaseAmount: number; dateRange: number[]; startDate: Date; skipAmountCalcMonth: number; firstPayDate?: Date; }; export const getDiffDay = (fromDate: Date, toDate: Date) => { const date1 = fromDate; const date2 = toDate; return (date2.getTime() - date1.getTime()) / (1000 * 3600 * 24); }; export function generateCustomGraphic({ dateRange, interestRate, leaseAmount, startDate, tenor, customInterest, customPayment, isPayFirstMonth, skipAmountCalcMonth, firstPayDate }: Params) { let schedules: LoanSchedule[] = []; let payment = (customPayment ?? 0) || (leaseAmount ?? 0) / (tenor * dateRange.length); let sumAmount = 0; dateRange = dateRange.sort((a, b) => a - b); let mainDate = startDate; let balance = leaseAmount; for (let index = 0; index < tenor + 1; index++) { dateRange.map((day, i) => { const nDate = new Date(mainDate); const year = nDate.getFullYear(); let month = nDate.getMonth(); if (i === 0 && (index !== 0 || isPayFirstMonth !== true)) month = nDate.getMonth() + 1; if (day > 28 && new Date(year, month, day).getDate() !== day) mainDate = new Date(year, month + 1, 0); else mainDate = new Date(year, month, day); if (isPayFirstMonth === true && mainDate < startDate) { return; } if(index == 0 && mainDate !== firstPayDate && firstPayDate){ mainDate = firstPayDate } let amount = skipAmountCalcMonth > index ? 0 : payment; if ( sumAmount + amount > leaseAmount || tenor * dateRange.length == schedules.length + 1 ) amount = leaseAmount - sumAmount; amount = Number(amount.toFixed(0)); const diffDay = Number(getDiffDay(nDate, mainDate).toFixed(0)); const mustPayinterest = Number(customInterest) || Number( Number(((balance * interestRate) / 100 / 365) * diffDay).toFixed(0), ) || 0; const mustpayment = amount || 0; const element: LoanSchedule = { order: schedules.length + 1, payment: mustpayment, interestNonce: mustPayinterest, balance, diffDay, payDate: mainDate, total: mustpayment + mustPayinterest, }; balance -= amount; sumAmount += amount; if (tenor * dateRange.length > schedules.length) schedules.push(element); }); } return schedules; } ```
/content/code_sandbox/packages/plugin-loans-ui/src/contracts/utils/customGraphic.ts
xml
2016-11-11T06:54:50
2024-08-16T10:26:06
erxes
erxes/erxes
3,479
688
```xml import "reflect-metadata" import { expect } from "chai" import { createTestingConnections, closeTestingConnections, reloadTestingDatabases, } from "../../../utils/test-utils" import { Foo } from "./entity/foo" import { filterByCteCapabilities } from "./helpers" import { DataSource } from "../../../../src/index.js" describe("query builder > cte > simple", () => { let dataSources: DataSource[] before( async () => (dataSources = await createTestingConnections({ entities: [__dirname + "/entity/*{.js,.ts}"], schemaCreate: true, dropSchema: true, })), ) beforeEach(() => reloadTestingDatabases(dataSources)) after(() => closeTestingConnections(dataSources)) it("show allow select from CTE", () => Promise.all( dataSources .filter(filterByCteCapabilities("enabled")) .map(async (dataSource) => { await dataSource .getRepository(Foo) .insert( [1, 2, 3].map((i) => ({ id: i, bar: String(i) })), ) let cteSelection = dataSource.driver.options.type === "oracle" ? `"foo"."bar"` : `foo.bar` const cteQuery = dataSource .createQueryBuilder() .select() .addSelect(cteSelection, "bar") .from(Foo, "foo") .where(`${cteSelection} = :value`, { value: "2" }) // Spanner does not support column names in CTE const cteOptions = dataSource.driver.options.type === "spanner" ? undefined : { columnNames: ["raz"], } cteSelection = dataSource.driver.options.type === "spanner" ? "qaz.bar" : dataSource.driver.options.type === "oracle" ? `"qaz"."raz"` : "qaz.raz" const qb = dataSource .createQueryBuilder() .addCommonTableExpression(cteQuery, "qaz", cteOptions) .from("qaz", "qaz") .select([]) .addSelect(cteSelection, "raz") expect(await qb.getRawMany()).to.deep.equal([{ raz: "2" }]) }), )) it("should allow join with CTE", () => Promise.all( dataSources .filter(filterByCteCapabilities("enabled")) .map(async (dataSource) => { await dataSource .getRepository(Foo) .insert( [1, 2, 3].map((i) => ({ id: i, bar: String(i) })), ) let cteSelection = dataSource.driver.options.type === "oracle" ? `"foo"."bar"` : `foo.bar` const cteQuery = dataSource .createQueryBuilder() .select() .addSelect( dataSource.driver.options.type === "oracle" ? `"bar"` : "bar", "bar", ) .from(Foo, "foo") .where(`${cteSelection} = '2'`) // Spanner does not support column names in CTE const cteOptions = dataSource.driver.options.type === "spanner" ? undefined : { columnNames: ["raz"], } cteSelection = dataSource.driver.options.type === "spanner" ? "qaz.bar" : dataSource.driver.options.type === "oracle" ? `"qaz"."raz"` : "qaz.raz" const results = await dataSource .createQueryBuilder(Foo, "foo") .addCommonTableExpression(cteQuery, "qaz", cteOptions) .innerJoin( "qaz", "qaz", `${cteSelection} = ${ dataSource.driver.options.type === "oracle" ? `"foo"."bar"` : `foo.bar` }`, ) .getMany() expect(results).to.have.length(1) expect(results[0]).to.include({ bar: "2", }) }), )) it("should allow to use INSERT with RETURNING clause in CTE", () => Promise.all( dataSources .filter(filterByCteCapabilities("writable")) .map(async (connection) => { const bar = Math.random().toString() const cteQuery = connection .createQueryBuilder() .insert() .into(Foo) .values({ id: 7, bar, }) .returning(["id", "bar"]) const results = await connection .createQueryBuilder() .select() .addCommonTableExpression(cteQuery, "insert_result") .from("insert_result", "insert_result") .getRawMany() expect(results).to.have.length(1) expect(results[0]).to.include({ bar, }) }), )) it("should allow string for CTE", () => Promise.all( dataSources .filter(filterByCteCapabilities("enabled")) .map(async (dataSource) => { // Spanner does not support column names in CTE let results: { row: any }[] if (dataSource.driver.options.type === "spanner") { results = await dataSource .createQueryBuilder() .select() .addCommonTableExpression( ` SELECT 1 AS foo UNION ALL SELECT 2 AS foo `, "cte", ) .from("cte", "cte") .addSelect("foo", "row") .getRawMany<{ row: any }>() } else if (dataSource.driver.options.type === "oracle") { results = await dataSource .createQueryBuilder() .select() .addCommonTableExpression( ` SELECT 1 FROM DUAL UNION SELECT 2 FROM DUAL `, "cte", { columnNames: ["foo"] }, ) .from("cte", "cte") .addSelect(`"foo"`, "row") .getRawMany<{ row: any }>() } else { results = await dataSource .createQueryBuilder() .select() .addCommonTableExpression( ` SELECT 1 UNION SELECT 2 `, "cte", { columnNames: ["foo"] }, ) .from("cte", "cte") .addSelect("foo", "row") .getRawMany<{ row: any }>() } const [rowWithOne, rowWithTwo] = results expect(String(rowWithOne.row)).to.equal("1") expect(String(rowWithTwo.row)).to.equal("2") }), )) }) ```
/content/code_sandbox/test/functional/query-builder/cte/simple-cte.ts
xml
2016-02-29T07:41:14
2024-08-16T18:28:52
typeorm
typeorm/typeorm
33,875
1,466
```xml <clickhouse> <placement> <use_imds>0</use_imds> <availability_zone_from_file>/tmp/node-zone</availability_zone_from_file> </placement> </clickhouse> ```
/content/code_sandbox/tests/integration/test_placement_info/configs/file_value.xml
xml
2016-06-02T08:28:18
2024-08-16T18:39:33
ClickHouse
ClickHouse/ClickHouse
36,234
45
```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="path_to_url" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingEnd="15dp" android:paddingStart="15dp"> <CheckBox android:id="@+id/dialogCheckbox" style="?android:attr/textAppearanceMedium" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5dp" /> <TextView android:id="@+id/dialogCheckboxTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="" /> </LinearLayout> ```
/content/code_sandbox/app/src/main/res/layout/dialog_checkbox.xml
xml
2016-09-23T13:33:17
2024-08-15T09:51:19
xDrip
NightscoutFoundation/xDrip
1,365
159
```xml import { simpleGit } from 'simple-git'; export const git = simpleGit({ config: [ /** * Ensures that prereleases are listed as earlier than stable releases. WITHOUT the config, this * is the list of tags: v7.1.0-rc.2 v7.1.0-rc.1 v7.1.0-rc.0 v7.1.0-beta.3 ... v7.1.0 v7.0.2 * * WITH the config, v7.1.0 is correctly on the top: v7.1.0 v7.1.0-rc.2 v7.1.0-rc.1 v7.1.0-rc.0 * v7.1.0-beta.3 ... v7.0.2 * * The top most tag is considered the "latest", which is used as a starting point for looking * for changes for upcoming releases See path_to_url */ 'versionsort.suffix=-', ], }); export async function getLatestTag() { return (await git.tags(['v*', '--sort=-v:refname', '--merged'])).latest; } ```
/content/code_sandbox/scripts/release/utils/git-client.ts
xml
2016-03-18T04:23:44
2024-08-16T19:22:08
storybook
storybookjs/storybook
83,755
263
```xml /// /// /// /// path_to_url /// /// Unless required by applicable law or agreed to in writing, software /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// import { Component, forwardRef, Input, OnInit } from '@angular/core'; import { ControlValueAccessor, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator, Validators } from '@angular/forms'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { TranslateService } from '@ngx-translate/core'; import { TencentMapProviderSettings, TencentMapType, tencentMapTypeProviderTranslationMap } from '@home/components/widget/lib/maps/map-models'; @Component({ selector: 'tb-tencent-map-provider-settings', templateUrl: './tencent-map-provider-settings.component.html', styleUrls: ['./../widget-settings.scss'], providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => TencentMapProviderSettingsComponent), multi: true }, { provide: NG_VALIDATORS, useExisting: forwardRef(() => TencentMapProviderSettingsComponent), multi: true } ] }) export class TencentMapProviderSettingsComponent extends PageComponent implements OnInit, ControlValueAccessor, Validator { @Input() disabled: boolean; private modelValue: TencentMapProviderSettings; private propagateChange = null; public providerSettingsFormGroup: UntypedFormGroup; tencentMapTypes = Object.values(TencentMapType); tencentMapTypeTranslations = tencentMapTypeProviderTranslationMap; constructor(protected store: Store<AppState>, private translate: TranslateService, private fb: UntypedFormBuilder) { super(store); } ngOnInit(): void { this.providerSettingsFormGroup = this.fb.group({ tmApiKey: [null, [Validators.required]], tmDefaultMapType: [null, [Validators.required]] }); this.providerSettingsFormGroup.valueChanges.subscribe(() => { this.updateModel(); }); } registerOnChange(fn: any): void { this.propagateChange = fn; } registerOnTouched(fn: any): void { } setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; if (isDisabled) { this.providerSettingsFormGroup.disable({emitEvent: false}); } else { this.providerSettingsFormGroup.enable({emitEvent: false}); } } writeValue(value: TencentMapProviderSettings): void { this.modelValue = value; this.providerSettingsFormGroup.patchValue( value, {emitEvent: false} ); } public validate(c: UntypedFormControl) { return this.providerSettingsFormGroup.valid ? null : { tencentMapProviderSettings: { valid: false, }, }; } private updateModel() { const value: TencentMapProviderSettings = this.providerSettingsFormGroup.value; this.modelValue = value; this.propagateChange(this.modelValue); } } ```
/content/code_sandbox/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/tencent-map-provider-settings.component.ts
xml
2016-12-01T09:33:30
2024-08-16T19:58:25
thingsboard
thingsboard/thingsboard
16,820
666
```xml import { Component, OnInit } from 'angular-ts-decorators'; import { ApiServiceStatus } from '../../../../shared/api/api.enum'; import { ApiSyncInfo } from '../../../../shared/api/api.interface'; import { ApiXbrowsersyncServiceInfo, ApiXbrowsersyncSyncInfo } from '../../../../shared/api/api-xbrowsersync/api-xbrowsersync.interface'; import { ApiXbrowsersyncService } from '../../../../shared/api/api-xbrowsersync/api-xbrowsersync.service'; import { ServiceOfflineError } from '../../../../shared/errors/errors'; import { PlatformService } from '../../../../shared/global-shared.interface'; import { StoreKey } from '../../../../shared/store/store.enum'; import { StoreService } from '../../../../shared/store/store.service'; import { SyncService } from '../../../../shared/sync/sync.service'; import { UtilityService } from '../../../../shared/utility/utility.service'; import { AppEventType } from '../../../app.enum'; import { AppHelperService } from '../../../shared/app-helper/app-helper.service'; @Component({ controllerAs: 'vm', selector: 'apiXbrowsersyncServiceInfo', styles: [require('./api-xbrowsersync-service-info.component.scss')], template: require('./api-xbrowsersync-service-info.component.html') }) export class ApiXbrowsersyncServiceInfoComponent implements OnInit { Strings = require('../../../../../../res/strings/en.json'); $q: ng.IQService; $timeout: ng.ITimeoutService; apiSvc: ApiXbrowsersyncService; appHelperSvc: AppHelperService; platformSvc: PlatformService; storeSvc: StoreService; syncSvc: SyncService; utilitySvc: UtilityService; apiServiceStatus = ApiServiceStatus; dataUsageProgressWidth = 0; maxSyncSize = 0; serviceInfo: ApiXbrowsersyncServiceInfo; syncDataSize: number; syncDataUsed: number; syncEnabled: boolean; static $inject = [ '$q', '$timeout', '$scope', 'ApiXbrowsersyncService', 'AppHelperService', 'PlatformService', 'StoreService', 'SyncService', 'UtilityService' ]; constructor( $q: ng.IQService, $timeout: ng.ITimeoutService, $scope: ng.IScope, ApiSvc: ApiXbrowsersyncService, AppHelperSvc: AppHelperService, PlatformSvc: PlatformService, StoreSvc: StoreService, SyncSvc: SyncService, UtilitySvc: UtilityService ) { this.$q = $q; this.$timeout = $timeout; this.apiSvc = ApiSvc; this.appHelperSvc = AppHelperSvc; this.platformSvc = PlatformSvc; this.storeSvc = StoreSvc; this.syncSvc = SyncSvc; this.utilitySvc = UtilitySvc; $scope.$on(AppEventType.RefreshSyncDataUsage, () => this.refreshSyncDataUsage()); } ngOnInit(): void { this.$q.all([this.storeSvc.get<ApiSyncInfo>(StoreKey.SyncInfo), this.utilitySvc.isSyncEnabled()]).then((data) => { const [syncInfo, syncEnabled] = data; this.syncEnabled = syncEnabled; this.serviceInfo = { url: (syncInfo as ApiXbrowsersyncSyncInfo).serviceUrl }; // Update displayed service info this.refreshServiceStatus().then(() => this.refreshSyncDataUsage()); }); } refreshServiceStatus(): ng.IPromise<void> { return this.apiSvc .checkServiceStatus() .then((serviceInfoResponse) => { this.serviceInfo = { ...this.serviceInfo, ...this.apiSvc.formatServiceInfo(serviceInfoResponse) }; // Set service message links to open in new tabs this.appHelperSvc.attachClickEventsToNewTabLinks(document.querySelector('.service-message')); }) .catch((err) => { const status = err instanceof ServiceOfflineError ? ApiServiceStatus.Offline : ApiServiceStatus.Error; this.serviceInfo = { ...this.serviceInfo, status }; }); } refreshSyncDataUsage(): ng.IPromise<void> { return this.utilitySvc.isSyncEnabled().then((syncEnabled) => { // Return if not synced if (!syncEnabled) { return; } // Get bookmarks sync size and calculate sync data percentage used return this.syncSvc.getSyncSize().then((bookmarksSyncSize) => { this.maxSyncSize = this.serviceInfo.maxSyncSize * 1024; this.syncDataSize = bookmarksSyncSize; this.syncDataUsed = Math.ceil((this.syncDataSize / this.maxSyncSize) * 100); this.$timeout(() => { // Add a slight delay when setting progress bar width to ensure transitions are enabled this.dataUsageProgressWidth = this.syncDataUsed; }, 250); }); }); } } ```
/content/code_sandbox/src/modules/app/app-settings/sync-settings/api-xbrowsersync-service-info/api-xbrowsersync-service-info.component.ts
xml
2016-05-05T20:59:25
2024-08-13T14:13:34
app
xbrowsersync/app
1,478
1,053
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "path_to_url"> <mapper namespace="com.zheng.upms.rpc.mapper.UpmsApiMapper"> <!-- --> <resultMap id="UpmsPermissionResultMap" type="com.zheng.upms.dao.model.UpmsPermission"> <id column="permission_id" jdbcType="INTEGER" property="permissionId" /> <result column="system_id" jdbcType="INTEGER" property="systemId" /> <result column="pid" jdbcType="INTEGER" property="pid" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="type" jdbcType="TINYINT" property="type" /> <result column="permission_value" jdbcType="VARCHAR" property="permissionValue" /> <result column="uri" jdbcType="VARCHAR" property="uri" /> <result column="icon" jdbcType="VARCHAR" property="icon" /> <result column="status" jdbcType="TINYINT" property="status" /> <result column="ctime" jdbcType="BIGINT" property="ctime" /> <result column="orders" jdbcType="BIGINT" property="orders" /> </resultMap> <!-- --> <resultMap id="UpmsRoleResultMap" type="com.zheng.upms.dao.model.UpmsRole"> <id column="role_id" jdbcType="INTEGER" property="roleId" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="title" jdbcType="VARCHAR" property="title" /> <result column="description" jdbcType="VARCHAR" property="description" /> <result column="ctime" jdbcType="BIGINT" property="ctime" /> <result column="orders" jdbcType="BIGINT" property="orders" /> </resultMap> <!-- --> <sql id="UpmsPermission_Column_List"> permission_id, system_id, pid, name, type, permission_value, uri, icon, status, ctime, orders </sql> <!-- --> <sql id="UpmsRole_Column_List"> role_id, name, title, description, ctime, orders </sql> <!-- --> <select id="selectUpmsPermissionByUpmsUserId" parameterType="java.lang.Integer" resultMap="UpmsPermissionResultMap"> select <include refid="UpmsPermission_Column_List" /> from upms_permission up where up.`status`=1 and up.permission_id in ( select permission_id from upms_role_permission urp where urp.role_id in ( select uur.role_id role_id from upms_user_role uur where uur.user_id=#{upmsUserId,jdbcType=INTEGER} ) union select permission_id from upms_user_permission uup1 where uup1.user_id=#{upmsUserId,jdbcType=INTEGER} and uup1.type=1 ) and up.permission_id not in ( select permission_id from upms_user_permission uup2 where uup2.user_id=#{upmsUserId,jdbcType=INTEGER} and uup2.type=-1 ) order by up.orders asc </select> <!-- id --> <select id="selectUpmsRoleByUpmsUserId" parameterType="java.lang.Integer" resultMap="UpmsRoleResultMap"> select <include refid="UpmsRole_Column_List" /> from upms_role ur where ur.role_id in ( select uur.role_id from upms_user_role uur where uur.user_id=#{upmsUserId,jdbcType=INTEGER} ) </select> <!-- --> <cache type="org.mybatis.caches.ehcache.LoggingEhcache" /> </mapper> ```
/content/code_sandbox/zheng-upms/zheng-upms-rpc-service/src/main/java/com/zheng/upms/rpc/mapper/UpmsApiMapper.xml
xml
2016-10-04T10:07:06
2024-08-16T07:00:44
zheng
shuzheng/zheng
16,660
857
```xml // See LICENSE.txt for license information. import type PostModel from './post'; import type ThreadInTeamModel from './thread_in_team'; import type ThreadParticipantsModel from './thread_participant'; import type {Query, Relation, Model} from '@nozbe/watermelondb'; import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Thread model contains thread information of a post. */ declare class ThreadModel extends Model { /** table (name) : Thread */ static table: string; /** associations : Describes every relationship to this table. */ static associations: Associations; /** lastReplyAt : The timestamp of when user last replied to the thread. */ lastReplyAt: number; /** last_last_fetched_at_at : The timestamp when we successfully last fetched post on this channel */ lastFetchedAt: number; /** lastViewedAt : The timestamp of when user last viewed the thread. */ lastViewedAt: number; /** reply_count : The total replies to the thread by all the participants. */ replyCount: number; /** isFollowing: If user is following this thread or not */ isFollowing: boolean; /** unread_replies : The number of replies that are not read by the user. */ unreadReplies: number; /** unread_mentions : The number of mentions that are not read by the user. */ unreadMentions: number; /** viewed_at : The timestamp showing when the user's last opened this thread (this is used for the new line message indicator) */ viewedAt: number; /** participants: All the participants of the thread */ participants: Query<ThreadParticipantsModel>; /** threadsInTeam : All the threadsInTeam associated with this Thread */ threadsInTeam: Query<ThreadInTeamModel>; /** post : Query returning the post data for the current thread */ post: Relation<PostModel>; } export default ThreadModel; ```
/content/code_sandbox/types/database/models/servers/thread.ts
xml
2016-10-07T16:52:32
2024-08-16T12:08:38
mattermost-mobile
mattermost/mattermost-mobile
2,155
414
```xml import type { ImportRequest } from './entities'; export const setDefaults = (obj: ImportRequest | null) => { if (!obj || !obj._type) { return obj; } switch (obj._type) { case 'request': return { parentId: '__WORKSPACE_ID__', name: 'Imported', url: '', body: '', parameters: [], headers: [], authentication: {}, ...obj, method: (obj.method || 'GET').toUpperCase(), }; case 'request_group': return { parentId: '__WORKSPACE_ID__', name: 'Imported', environment: {}, ...obj, }; case 'environment': return { parentId: '__BASE_ENVIRONMENT_ID__', name: 'Imported Environment', data: {}, ...obj, }; default: return obj; } }; export const unthrowableParseJson = (rawData: string) => { try { return JSON.parse(rawData); } catch (err) { return null; } }; ```
/content/code_sandbox/packages/insomnia/src/utils/importers/utils.ts
xml
2016-04-23T03:54:26
2024-08-16T16:50:44
insomnia
Kong/insomnia
34,054
234
```xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="path_to_url"> <item android:drawable="@drawable/shape_check" android:state_checked="true"></item> <item android:drawable="@drawable/shape_normol" android:state_checked="false"></item> </selector> ```
/content/code_sandbox/Prj-Android/app/src/main/res/drawable/select_options.xml
xml
2016-08-26T06:35:48
2024-08-15T03:26:11
anyRTC-RTMP-OpenSource
anyrtcIO-Community/anyRTC-RTMP-OpenSource
4,672
71
```xml /* * @license Apache-2.0 * * * * path_to_url * * Unless required by applicable law or agreed to in writing, software * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import itermean = require( './index' ); /** * Returns an iterator protocol-compliant object. * * @returns iterator protocol-compliant object */ function iterator() { return { 'next': next }; /** * Implements the iterator protocol `next` method. * * @returns iterator protocol-compliant object */ function next() { return { 'value': true, 'done': false }; } } // TESTS // // The function returns either a number or null... { itermean( iterator() ); // $ExpectType number | null } // The compiler throws an error if the function is provided a value other than an iterator protocol-compliant object... { itermean( '5' ); // $ExpectError itermean( 5 ); // $ExpectError itermean( true ); // $ExpectError itermean( false ); // $ExpectError itermean( null ); // $ExpectError itermean( undefined ); // $ExpectError itermean( [] ); // $ExpectError itermean( {} ); // $ExpectError itermean( ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { itermean(); // $ExpectError } ```
/content/code_sandbox/lib/node_modules/@stdlib/stats/iter/mean/docs/types/test.ts
xml
2016-03-24T04:19:52
2024-08-16T09:03:19
stdlib
stdlib-js/stdlib
4,266
327
```xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="path_to_url" xmlns:app="path_to_url" xmlns:tools="path_to_url" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#EEEEEE"> <com.github.florent37.diagonallayout.DiagonalLayout android:id="@+id/diagonalLayout" android:layout_width="match_parent" android:layout_height="250dp" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentBottom="true" android:elevation="10dp" app:diagonal_angle="15" app:diagonal_position="top" app:diagonal_direction="right" > <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/diagonallayout_mountains" /> </com.github.florent37.diagonallayout.DiagonalLayout> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:titleTextColor="@android:color/white" android:elevation="11dp" app:title="DiagonalLayout"/> </RelativeLayout> ```
/content/code_sandbox/app/src/main/res/layout/activity_main_simple.xml
xml
2016-10-14T14:59:59
2024-07-10T06:26:01
DiagonalLayout
florent37/DiagonalLayout
2,564
318
```xml import foo from "foo.json" with type: "json"; ```
/content/code_sandbox/tests/format/misc/errors/typescript/module-attributes-static.ts
xml
2016-11-29T17:13:37
2024-08-16T17:29:57
prettier
prettier/prettier
48,913
14
```xml import { UseQueryOptions, useQuery } from '@tanstack/react-query'; import axios, { parseAxiosError } from '@/portainer/services/axios'; import { isBE } from '../feature-flags/feature-flags.service'; import { buildUrl } from './build-url'; import { queryKeys } from './query-keys'; export const queryKey = [...queryKeys.base(), 'status'] as const; export interface StatusResponse { Edition: string; Version: string; InstanceID: string; } export async function getSystemStatus() { try { const { data } = await axios.get<StatusResponse>(buildUrl('status')); data.Edition = isBE ? 'Business Edition' : 'Community Edition'; return data; } catch (error) { throw parseAxiosError(error as Error); } } export function useSystemStatus<T = StatusResponse>({ select, enabled, retry, onSuccess, }: { select?: (status: StatusResponse) => T; enabled?: boolean; retry?: UseQueryOptions['retry']; onSuccess?: (data: T) => void; } = {}) { return useQuery(queryKey, () => getSystemStatus(), { select, enabled, retry, retryDelay: 1000, onSuccess, }); } ```
/content/code_sandbox/app/react/portainer/system/useSystemStatus.ts
xml
2016-05-19T20:15:28
2024-08-16T19:15:14
portainer
portainer/portainer
30,083
280
```xml export * from './ColorArea'; export * from './ColorArea.types'; export * from './renderColorArea'; export * from './useColorArea'; export * from './useColorAreaStyles.styles'; ```
/content/code_sandbox/packages/react-components/react-color-picker-preview/library/src/components/ColorArea/index.ts
xml
2016-06-06T15:03:44
2024-08-16T18:49:29
fluentui
microsoft/fluentui
18,221
42
```xml import { mergeOutputs, Types } from '@graphql-codegen/plugin-helpers'; import { resolversTestingSchema, resolversTestingValidate } from '@graphql-codegen/testing'; import { buildSchema } from 'graphql'; import { plugin } from '../src/index.js'; describe('TypeScript Resolvers Plugin - Mapping', () => { it('Should build ResolversTypes object when there are no mappers', async () => { const result = await plugin(resolversTestingSchema, [], {}, { outputFile: '' }); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType ); MyUnion: ( Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> } ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should build ResolversTypes with simple mappers', async () => { const result = (await plugin( resolversTestingSchema, [], { mappers: { MyType: 'MyTypeDb', AnotherNodeWithChild: 'AnotherNodeWithChildMapper', String: 'number', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'bar' | 'parent'> & { bar: _RefType['String'], parent?: Maybe<_RefType['MyType']> } ) | ( Omit<MyOtherType, 'bar'> & { bar: _RefType['String'] } ); MyUnion: ( MyTypeDb ) | ( Omit<MyOtherType, 'bar'> & { bar: _RefType['String'] } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyTypeDb>; String: ResolverTypeWrapper<number>; Child: ResolverTypeWrapper<Omit<Child, 'bar' | 'parent'> & { bar: ResolversTypes['String'], parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<Omit<MyOtherType, 'bar'> & { bar: ResolversTypes['String'] }>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyTypeDb; String: number; Child: Omit<Child, 'bar' | 'parent'> & { bar: ResolversParentTypes['String'], parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: Omit<MyOtherType, 'bar'> & { bar: ResolversParentTypes['String'] }; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: AnotherNodeWithChildMapper; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should allow to map custom type that refers itself (issue #1770)', async () => { const testSchema = buildSchema(/* GraphQL */ ` type Movie { id: ID! title: String! } type Book { id: ID! author: String! } union MovieLike = Movie | Book type NonInterfaceHasNarrative { narrative: MovieLike! movie: Movie! } `); const result = (await plugin( testSchema, [], { noSchemaStitching: true, mappers: { Movie: 'MovieEntity', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; const content = mergeOutputs([result]); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { MovieLike: ( MovieEntity ) | ( Book ); }; `); expect(content).toBeSimilarStringTo(` export type ResolversTypes = { Movie: ResolverTypeWrapper<MovieEntity>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; String: ResolverTypeWrapper<Scalars['String']['output']>; Book: ResolverTypeWrapper<Book>; MovieLike: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MovieLike']>; NonInterfaceHasNarrative: ResolverTypeWrapper<Omit<NonInterfaceHasNarrative, 'narrative' | 'movie'> & { narrative: ResolversTypes['MovieLike'], movie: ResolversTypes['Movie'] }>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(content).toBeSimilarStringTo(` export type ResolversParentTypes = { Movie: MovieEntity; ID: Scalars['ID']['output']; String: Scalars['String']['output']; Book: Book; MovieLike: ResolversUnionTypes<ResolversParentTypes>['MovieLike']; NonInterfaceHasNarrative: Omit<NonInterfaceHasNarrative, 'narrative' | 'movie'> & { narrative: ResolversParentTypes['MovieLike'], movie: ResolversParentTypes['Movie'] }; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should allow to map custom type that refers itself (issue #1770, attempt #2)', async () => { const testSchema = buildSchema(/* GraphQL */ ` type Movie { id: ID! title: String! } type Book { id: ID! author: String! } union MovieLike = Movie | Book type NonInterfaceHasNarrative { narrative: MovieLike! movie: Movie! } type LayerOfIndirection { id: ID! movies: [NonInterfaceHasNarrative!]! } type AnotherLayerOfIndirection { inner: LayerOfIndirection! } `); const result = (await plugin( testSchema, [], { noSchemaStitching: true, mappers: { Movie: 'MovieEntity', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; const content = mergeOutputs([result]); expect(content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { MovieLike: ( MovieEntity ) | ( Book ); }; `); expect(content).toBeSimilarStringTo(`export type ResolversTypes = { Movie: ResolverTypeWrapper<MovieEntity>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; String: ResolverTypeWrapper<Scalars['String']['output']>; Book: ResolverTypeWrapper<Book>; MovieLike: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MovieLike']>; NonInterfaceHasNarrative: ResolverTypeWrapper<Omit<NonInterfaceHasNarrative, 'narrative' | 'movie'> & { narrative: ResolversTypes['MovieLike'], movie: ResolversTypes['Movie'] }>; LayerOfIndirection: ResolverTypeWrapper<Omit<LayerOfIndirection, 'movies'> & { movies: Array<ResolversTypes['NonInterfaceHasNarrative']> }>; AnotherLayerOfIndirection: ResolverTypeWrapper<Omit<AnotherLayerOfIndirection, 'inner'> & { inner: ResolversTypes['LayerOfIndirection'] }>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(content).toBeSimilarStringTo(` export type ResolversParentTypes = { Movie: MovieEntity; ID: Scalars['ID']['output']; String: Scalars['String']['output']; Book: Book; MovieLike: ResolversUnionTypes<ResolversParentTypes>['MovieLike']; NonInterfaceHasNarrative: Omit<NonInterfaceHasNarrative, 'narrative' | 'movie'> & { narrative: ResolversParentTypes['MovieLike'], movie: ResolversParentTypes['Movie'] }; LayerOfIndirection: Omit<LayerOfIndirection, 'movies'> & { movies: Array<ResolversParentTypes['NonInterfaceHasNarrative']> }; AnotherLayerOfIndirection: Omit<AnotherLayerOfIndirection, 'inner'> & { inner: ResolversParentTypes['LayerOfIndirection'] }; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should allow to map custom type that refers itself (issue #1770, attempt #3 - circular)', async () => { const testSchema = buildSchema(/* GraphQL */ ` type Account { id: ID! name: String! programs: [Program!]! } type Program { id: ID! name: String! account: Account! } `); const result = (await plugin( testSchema, [], { typesPrefix: 'Gql', defaultMapper: 'Partial<{T}>', namingConvention: { typeNames: 'change-case-all#pascalCase', enumValues: 'change-case-all#upperCase', }, noSchemaStitching: true, }, { outputFile: '' } )) as Types.ComplexPluginOutput; const content = mergeOutputs([result]); expect(content).toBeSimilarStringTo(`export type GqlResolversTypes = { Account: ResolverTypeWrapper<Partial<GqlAccount>>; ID: ResolverTypeWrapper<Partial<Scalars['ID']['output']>>; String: ResolverTypeWrapper<Partial<Scalars['String']['output']>>; Program: ResolverTypeWrapper<Partial<GqlProgram>>; Boolean: ResolverTypeWrapper<Partial<Scalars['Boolean']['output']>>; };`); }); it('should map to a custom type on every level (+ actual usage in code)', async () => { const testSchema = buildSchema(/* GraphQL */ ` type User { id: ID! name: String! chats: [Chat!] } type Chat { id: ID! owner: User! members: [User!] } type Query { me: User } `); const result = (await plugin( testSchema, [], { noSchemaStitching: true, mappers: { ID: 'number', Chat: 'number', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; const usage = ` const resolvers: Resolvers = { Query: { me() { return { id: 1, name: 'Foo', chats: [0,1,2], }; } }, Chat: { id(parent) { const id: number = parent; return id; } } } `; await resolversTestingValidate( mergeOutputs([usage, result]), { scalars: { ID: 'number', }, }, testSchema ); }); it('Should build ResolversTypes with defaultMapper set using {T}', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, defaultMapper: 'Partial<{T}>', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Partial<Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> }> ) | ( Partial<MyOtherType> ); MyUnion: ( Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> }> ) | ( Partial<MyOtherType> ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( Partial<SomeNode> ); AnotherNode: ( Partial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Partial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChild: ( Partial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Partial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChildren: ( Partial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>>; String: ResolverTypeWrapper<Partial<Scalars['String']['output']>>; Child: ResolverTypeWrapper<Partial<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>>; MyOtherType: ResolverTypeWrapper<Partial<MyOtherType>>; ChildUnion: Partial<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Partial<Scalars['ID']['output']>>; SomeNode: ResolverTypeWrapper<Partial<SomeNode>>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<Partial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>>; AnotherNodeWithAll: ResolverTypeWrapper<Partial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>>; MyUnion: Partial<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>>; MyScalar: ResolverTypeWrapper<Partial<Scalars['MyScalar']['output']>>; Int: ResolverTypeWrapper<Partial<Scalars['Int']['output']>>; Boolean: ResolverTypeWrapper<Partial<Scalars['Boolean']['output']>>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }>; String: Partial<Scalars['String']['output']>; Child: Partial<Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }>; MyOtherType: Partial<MyOtherType>; ChildUnion: Partial<ResolversUnionTypes<ResolversParentTypes>['ChildUnion']>; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Partial<Scalars['ID']['output']>; SomeNode: Partial<SomeNode>; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: Partial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }>; AnotherNodeWithAll: Partial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }>; MyUnion: Partial<ResolversUnionTypes<ResolversParentTypes>['MyUnion']>; MyScalar: Partial<Scalars['MyScalar']['output']>; Int: Partial<Scalars['Int']['output']>; Boolean: Partial<Scalars['Boolean']['output']>; }; `); }); it('Should build ResolversTypes with defaultMapper set using {T} with external identifier', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, defaultMapper: './my-wrapper#CustomPartial<{T}>', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { CustomPartial } from './my-wrapper';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( CustomPartial<Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> }> ) | ( CustomPartial<MyOtherType> ); MyUnion: ( CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> }> ) | ( CustomPartial<MyOtherType> ); } `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( CustomPartial<SomeNode> ); AnotherNode: ( CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( CustomPartial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChild: ( CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( CustomPartial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChildren: ( CustomPartial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>>; String: ResolverTypeWrapper<CustomPartial<Scalars['String']['output']>>; Child: ResolverTypeWrapper<CustomPartial<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>>; MyOtherType: ResolverTypeWrapper<CustomPartial<MyOtherType>>; ChildUnion: CustomPartial<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<CustomPartial<Scalars['ID']['output']>>; SomeNode: ResolverTypeWrapper<CustomPartial<SomeNode>>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>>; AnotherNodeWithAll: ResolverTypeWrapper<CustomPartial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>>; MyUnion: CustomPartial<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>>; MyScalar: ResolverTypeWrapper<CustomPartial<Scalars['MyScalar']['output']>>; Int: ResolverTypeWrapper<CustomPartial<Scalars['Int']['output']>>; Boolean: ResolverTypeWrapper<CustomPartial<Scalars['Boolean']['output']>>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }>; String: CustomPartial<Scalars['String']['output']>; Child: CustomPartial<Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }>; MyOtherType: CustomPartial<MyOtherType>; ChildUnion: CustomPartial<ResolversUnionTypes<ResolversParentTypes>['ChildUnion']>; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: CustomPartial<Scalars['ID']['output']>; SomeNode: CustomPartial<SomeNode>; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }>; AnotherNodeWithAll: CustomPartial<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }>; MyUnion: CustomPartial<ResolversUnionTypes<ResolversParentTypes>['MyUnion']>; MyScalar: CustomPartial<Scalars['MyScalar']['output']>; Int: CustomPartial<Scalars['Int']['output']>; Boolean: CustomPartial<Scalars['Boolean']['output']>; }; `); }); it('Should build ResolversTypes with mapper set for concrete type using {T} with external identifier', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyType: './my-wrapper#CustomPartial<{T}>', AnotherNodeWithChild: './my-wrapper#CustomPartial<{T}>', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { CustomPartial } from './my-wrapper';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType ); MyUnion: ( CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> }> ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: CustomPartial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }>; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: CustomPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }>; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should map to a custom type on every level when {T} is used as default mapper', async () => { const config = { scalars: { ID: 'number', }, noSchemaStitching: true, defaultMapper: 'Partial<{T}>', mappers: { User: 'number', }, }; const testSchema = buildSchema(/* GraphQL */ ` type User { id: ID! name: String! chats: [Chat!] } type Chat { id: ID! owner: User! members: [User!] } type Query { me: User } `); const result = await plugin(testSchema, [], config, { outputFile: '' }); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { User: ResolverTypeWrapper<number>; ID: ResolverTypeWrapper<Partial<Scalars['ID']['output']>>; String: ResolverTypeWrapper<Partial<Scalars['String']['output']>>; Chat: ResolverTypeWrapper<Partial<Omit<Chat, 'owner' | 'members'> & { owner: ResolversTypes['User'], members?: Maybe<Array<ResolversTypes['User']>> }>>; Query: ResolverTypeWrapper<{}>; Boolean: ResolverTypeWrapper<Partial<Scalars['Boolean']['output']>>; }; `); const usage = ` const resolvers: Resolvers = { Query: { me() { return 1; } }, Chat: { id(chat) { return chat.id; }, owner(chat) { const id: number = chat.owner; return id; }, members(chat) { const ids: number[] = chat.members; return ids; } }, User: { id(parent) { const id: number = parent; return id; } } } `; await resolversTestingValidate(mergeOutputs([result, usage]), config, testSchema); }); it('Should build ResolversTypes with mapper set for concrete type using renamed external identifier', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyType: './my-type#MyType as DatabaseMyType', AnotherNodeWithChild: './my-interface#AnotherNodeWithChild as AnotherNodeWithChildMapper', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyType as DatabaseMyType } from './my-type';`); expect(result.prepend).toContain( `import { AnotherNodeWithChild as AnotherNodeWithChildMapper } from './my-interface';` ); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType ); MyUnion: ( DatabaseMyType ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<DatabaseMyType>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: DatabaseMyType; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: AnotherNodeWithChildMapper; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should build ResolversTypes with mapper set for concrete type using renamed external identifier (with default)', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: './my-type#default as DatabaseMyOtherType', MyType: './my-type#MyType as DatabaseMyType', AnotherNodeWithChild: './my-interface#default as AnotherNodeWithChildMapper', AnotherNodeWithAll: './my-interface#AnotherNodeWithAll as AnotherNodeWithAllMapper', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import DatabaseMyOtherType, { MyType as DatabaseMyType } from './my-type';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( DatabaseMyOtherType ); MyUnion: ( DatabaseMyType ) | ( DatabaseMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChildren: ( AnotherNodeWithAllMapper ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<DatabaseMyType>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<DatabaseMyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<AnotherNodeWithAllMapper>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: DatabaseMyType; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: DatabaseMyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: AnotherNodeWithChildMapper; AnotherNodeWithAll: AnotherNodeWithAllMapper; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should build ResolversTypes with mapper set for concrete type using renamed external identifier (with default) and type import', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: './my-type#default as DatabaseMyOtherType', MyType: './my-type#MyType as DatabaseMyType', AnotherNodeWithChild: './my-interface#default as AnotherNodeWithChildMapper', AnotherNodeWithAll: './my-interface#AnotherNodeWithAll as AnotherNodeWithAllMapper', }, useTypeImports: true, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain( `import type { default as DatabaseMyOtherType, MyType as DatabaseMyType } from './my-type';` ); expect(result.prepend).toContain( `import type { default as AnotherNodeWithChildMapper, AnotherNodeWithAll as AnotherNodeWithAllMapper } from './my-interface';` ); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( DatabaseMyOtherType ); MyUnion: ( DatabaseMyType ) | ( DatabaseMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChildren: ( AnotherNodeWithAllMapper ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<DatabaseMyType>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<DatabaseMyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<AnotherNodeWithAllMapper>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: DatabaseMyType; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: DatabaseMyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: AnotherNodeWithChildMapper; AnotherNodeWithAll: AnotherNodeWithAllMapper; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should build ResolversTypes with defaultMapper set', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyType: 'MyTypeDb', String: 'string', }, defaultMapper: 'any', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).not.toBeSimilarStringTo(`export type ResolversUnionTypes`); expect(result.content).not.toBeSimilarStringTo(`export type ResolversInterfaceTypes`); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyTypeDb>; String: ResolverTypeWrapper<string>; Child: ResolverTypeWrapper<any>; MyOtherType: ResolverTypeWrapper<any>; ChildUnion: ResolverTypeWrapper<any>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<any>; ID: ResolverTypeWrapper<any>; SomeNode: ResolverTypeWrapper<any>; AnotherNode: ResolverTypeWrapper<any>; WithChild: ResolverTypeWrapper<any>; WithChildren: ResolverTypeWrapper<any>; AnotherNodeWithChild: ResolverTypeWrapper<any>; AnotherNodeWithAll: ResolverTypeWrapper<any>; MyUnion: ResolverTypeWrapper<any>; MyScalar: ResolverTypeWrapper<any>; Int: ResolverTypeWrapper<any>; Boolean: ResolverTypeWrapper<any>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyTypeDb; String: string; Child: any; MyOtherType: any; ChildUnion: any; Query: {}; Subscription: {}; Node: any; ID: any; SomeNode: any; AnotherNode: any; WithChild: any; WithChildren: any; AnotherNodeWithChild: any; AnotherNodeWithAll: any; MyUnion: any; MyScalar: any; Int: any; Boolean: any; };`); }); it('Should build ResolversTypes with external mappers', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: './my-module#CustomMyOtherType', MyType: 'MyTypeDb', AnotherNodeWithChild: './my-interface#AnotherNodeWithChildMapper', AnotherNodeWithAll: 'AnotherNodeWithAllMapper', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( CustomMyOtherType ); MyUnion: ( MyTypeDb ) | ( CustomMyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChild: ( AnotherNodeWithChildMapper ) | ( AnotherNodeWithAllMapper ); WithChildren: ( AnotherNodeWithAllMapper ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyTypeDb>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<CustomMyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<AnotherNodeWithAllMapper>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyTypeDb; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: CustomMyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: AnotherNodeWithChildMapper; AnotherNodeWithAll: AnotherNodeWithAllMapper; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('Should handle {T} in a mapper', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyType: 'Partial<{T}>', AnotherNodeWithChild: 'ExtraPartial<{T}>', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType ); MyUnion: ( Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> }> ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( ExtraPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( ExtraPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<ExtraPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Partial<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }>; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: ExtraPartial<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }>; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('should warn about unused mappers by default', async () => { const spy = jest.spyOn(console, 'warn').mockImplementation(); const testSchema = buildSchema(/* GraphQL */ ` type Query { comments: [Comment!]! } type User { id: ID! name: String! } type Comment { id: ID! text: String! author: User! } `); await plugin( testSchema, [], { noSchemaStitching: true, mappers: { Comment: 'number', Post: 'string', }, }, { outputFile: 'graphql.ts', } ); expect(spy).toHaveBeenCalledWith('Unused mappers: Post'); spy.mockRestore(); }); it('should be able not to warn about unused mappers', async () => { const spy = jest.spyOn(console, 'warn').mockImplementation(); const testSchema = buildSchema(/* GraphQL */ ` type Query { comments: [Comment!]! } type User { id: ID! name: String! } type Comment { id: ID! text: String! author: User! } `); await plugin( testSchema, [], { noSchemaStitching: true, mappers: { Comment: 'number', Post: 'string', }, showUnusedMappers: false, }, { outputFile: 'graphql.ts', } ); expect(spy).not.toHaveBeenCalled(); spy.mockRestore(); }); it('Should generate basic type resolvers with external mappers', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: './my-file#MyCustomOtherType', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyCustomOtherType } from './my-file';`); expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveArgs = { arg: Scalars['Int']['input']; arg2: Scalars['String']['input']; arg3: Scalars['Boolean']['input']; }; `); expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveResolver<Result, Parent, ContextType = any, Args = MyDirectiveDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;`); expect(result.content).toBeSimilarStringTo(` export type MyOtherTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyOtherType'] = ResolversParentTypes['MyOtherType']> = { bar?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content) .toBeSimilarStringTo(`export interface MyScalarScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['MyScalar'], any> { name: 'MyScalar'; } `); expect(result.content).toBeSimilarStringTo(` export type MyTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyType'] = ResolversParentTypes['MyType']> = { foo?: Resolver<ResolversTypes['String'], ParentType, ContextType>; otherType?: Resolver<Maybe<ResolversTypes['MyOtherType']>, ParentType, ContextType>; withArgs?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType, RequireFields<MyTypeWithArgsArgs, 'arg2'>>; unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = { __resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type NodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['Node'] = ResolversParentTypes['Node']> = { __resolveType: TypeResolveFn<'SomeNode', ParentType, ContextType>; id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = { something?: Resolver<ResolversTypes['MyType'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['SomeNode'] = ResolversParentTypes['SomeNode']> = { id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SubscriptionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = { somethingChanged?: SubscriptionResolver<Maybe<ResolversTypes['MyOtherType']>, "somethingChanged", ParentType, ContextType>; }; `); await resolversTestingValidate(result); }); it('Should generate basic type resolvers with external mappers using same imported type', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyType: './my-file#MyCustomOtherType', MyOtherType: './my-file#MyCustomOtherType', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyCustomOtherType } from './my-file';`); expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveArgs = { arg: Scalars['Int']['input']; arg2: Scalars['String']['input']; arg3: Scalars['Boolean']['input']; }; `); expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveResolver<Result, Parent, ContextType = any, Args = MyDirectiveDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;`); expect(result.content).toBeSimilarStringTo(` export type MyOtherTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyOtherType'] = ResolversParentTypes['MyOtherType']> = { bar?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content) .toBeSimilarStringTo(`export interface MyScalarScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['MyScalar'], any> { name: 'MyScalar'; } `); expect(result.content).toBeSimilarStringTo(` export type MyTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyType'] = ResolversParentTypes['MyType']> = { foo?: Resolver<ResolversTypes['String'], ParentType, ContextType>; otherType?: Resolver<Maybe<ResolversTypes['MyOtherType']>, ParentType, ContextType>; withArgs?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType, RequireFields<MyTypeWithArgsArgs, 'arg2'>>; unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = { __resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type NodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['Node'] = ResolversParentTypes['Node']> = { __resolveType: TypeResolveFn<'SomeNode', ParentType, ContextType>; id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = { something?: Resolver<ResolversTypes['MyType'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['SomeNode'] = ResolversParentTypes['SomeNode']> = { id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SubscriptionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = { somethingChanged?: SubscriptionResolver<Maybe<ResolversTypes['MyOtherType']>, "somethingChanged", ParentType, ContextType>; }; `); await resolversTestingValidate(result); }); it('Should generate the correct resolvers when used with mappers with interfaces', async () => { const spy = jest.spyOn(console, 'warn').mockImplementation(); const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { Node: 'MyNodeType', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveArgs = { arg: Scalars['Int']['input']; arg2: Scalars['String']['input']; arg3: Scalars['Boolean']['input']; }; `); expect(result.content).toBeSimilarStringTo(` export type MyDirectiveDirectiveResolver<Result, Parent, ContextType = any, Args = MyDirectiveDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;`); expect(result.content).toBeSimilarStringTo(` export type MyOtherTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyOtherType'] = ResolversParentTypes['MyOtherType']> = { bar?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export interface MyScalarScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['MyScalar'], any> { name: 'MyScalar'; } `); expect(result.content).toBeSimilarStringTo(` export type MyTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyType'] = ResolversParentTypes['MyType']> = { foo?: Resolver<ResolversTypes['String'], ParentType, ContextType>; otherType?: Resolver<Maybe<ResolversTypes['MyOtherType']>, ParentType, ContextType>; withArgs?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType, RequireFields<MyTypeWithArgsArgs, 'arg2'>>; unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = { __resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type NodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['Node'] = ResolversParentTypes['Node']> = { __resolveType: TypeResolveFn<'SomeNode', ParentType, ContextType>; id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = { something?: Resolver<ResolversTypes['MyType'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['SomeNode'] = ResolversParentTypes['SomeNode']> = { id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SubscriptionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = { somethingChanged?: SubscriptionResolver<Maybe<ResolversTypes['MyOtherType']>, "somethingChanged", ParentType, ContextType>; }; `); await resolversTestingValidate(mergeOutputs([result, `type MyNodeType = {};`])); spy.mockRestore(); }); it('Should generate basic type resolvers with defaultMapper set to any', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, defaultMapper: 'any', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type MyOtherTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyOtherType'] = ResolversParentTypes['MyOtherType']> = { bar?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export interface MyScalarScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['MyScalar'], any> { name: 'MyScalar'; } `); expect(result.content).toBeSimilarStringTo(` export type MyTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyType'] = ResolversParentTypes['MyType']> = { foo?: Resolver<ResolversTypes['String'], ParentType, ContextType>; otherType?: Resolver<Maybe<ResolversTypes['MyOtherType']>, ParentType, ContextType>; withArgs?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType, RequireFields<MyTypeWithArgsArgs, 'arg2'>>; unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = { __resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type NodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['Node'] = ResolversParentTypes['Node']> = { __resolveType: TypeResolveFn<'SomeNode', ParentType, ContextType>; id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = { something?: Resolver<ResolversTypes['MyType'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['SomeNode'] = ResolversParentTypes['SomeNode']> = { id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SubscriptionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = { somethingChanged?: SubscriptionResolver<Maybe<ResolversTypes['MyOtherType']>, "somethingChanged", ParentType, ContextType>; }; `); await resolversTestingValidate(result); }); it('Should generate basic type resolvers with defaultMapper set to external identifier', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, defaultMapper: './my-file#MyBaseType', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyBaseType } from './my-file';`); expect(result.content).toBeSimilarStringTo(` export type MyOtherTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyOtherType'] = ResolversParentTypes['MyOtherType']> = { bar?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export interface MyScalarScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['MyScalar'], any> { name: 'MyScalar'; } `); expect(result.content).toBeSimilarStringTo(` export type MyTypeResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyType'] = ResolversParentTypes['MyType']> = { foo?: Resolver<ResolversTypes['String'], ParentType, ContextType>; otherType?: Resolver<Maybe<ResolversTypes['MyOtherType']>, ParentType, ContextType>; withArgs?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType, RequireFields<MyTypeWithArgsArgs, 'arg2'>>; unionChild?: Resolver<Maybe<ResolversTypes['ChildUnion']>, ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type MyUnionResolvers<ContextType = any, ParentType extends ResolversParentTypes['MyUnion'] = ResolversParentTypes['MyUnion']> = { __resolveType: TypeResolveFn<'MyType' | 'MyOtherType', ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type NodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['Node'] = ResolversParentTypes['Node']> = { __resolveType: TypeResolveFn<'SomeNode', ParentType, ContextType>; id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = { something?: Resolver<ResolversTypes['MyType'], ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SomeNodeResolvers<ContextType = any, ParentType extends ResolversParentTypes['SomeNode'] = ResolversParentTypes['SomeNode']> = { id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; `); expect(result.content).toBeSimilarStringTo(` export type SubscriptionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription']> = { somethingChanged?: SubscriptionResolver<Maybe<ResolversTypes['MyOtherType']>, "somethingChanged", ParentType, ContextType>; }; `); await resolversTestingValidate(result); }); it('Should replace using Omit when non-mapped type is pointing to mapped type', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: 'MyOtherTypeCustom', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherTypeCustom ); MyUnion: ( Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<_RefType['MyOtherType']>, unionChild?: Maybe<_RefType['ChildUnion']> } ) | ( MyOtherTypeCustom ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<ResolversTypes['MyOtherType']>, unionChild?: Maybe<ResolversTypes['ChildUnion']> }>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherTypeCustom>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<ResolversParentTypes['MyOtherType']>, unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherTypeCustom; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); await resolversTestingValidate(mergeOutputs([result, 'type MyOtherTypeCustom = {};'])); }); it('Should not replace using Omit when non-mapped type is pointing to mapped type', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: 'MyOtherTypeCustom', MyType: 'MyTypeCustom', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherTypeCustom ); MyUnion: ( MyTypeCustom ) | ( MyOtherTypeCustom ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyTypeCustom>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherTypeCustom>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; };`); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyTypeCustom; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherTypeCustom; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); await resolversTestingValidate(mergeOutputs([result, `type MyTypeCustom = {}; type MyOtherTypeCustom = {};`])); }); it('should support namespaces', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, mappers: { MyOtherType: './my-file#MyNamespace#MyCustomOtherType', AnotherNodeWithChild: './my-interface#InterfaceNamespace#AnotherNodeWithChildMapper', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.prepend).toContain(`import { InterfaceNamespace } from './my-interface';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyNamespace.MyCustomOtherType ); MyUnion: ( Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<_RefType['MyOtherType']>, unionChild?: Maybe<_RefType['ChildUnion']> } ) | ( MyNamespace.MyCustomOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( InterfaceNamespace.AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( InterfaceNamespace.AnotherNodeWithChildMapper ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<ResolversTypes['MyOtherType']>, unionChild?: Maybe<ResolversTypes['ChildUnion']> }>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyNamespace.MyCustomOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<InterfaceNamespace.AnotherNodeWithChildMapper>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Omit<MyType, 'otherType' | 'unionChild'> & { otherType?: Maybe<ResolversParentTypes['MyOtherType']>, unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyNamespace.MyCustomOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: InterfaceNamespace.AnotherNodeWithChildMapper; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('should support namespaces in contextType', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, contextType: './my-file#MyNamespace#MyContextType', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).toContain(`<ContextType = MyNamespace.MyContextType>`); expect(result.content).not.toContain(`<ContextType = MyNamespace>`); expect(result.content).not.toContain(`<ContextType = MyContextType>`); }); it('should support namespaces in defaultMapper', async () => { const result = (await plugin( resolversTestingSchema, [], { defaultMapper: './my-file#MyNamespace#MyDefaultMapper', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).not.toBeSimilarStringTo(`export type ResolversUnionTypes`); expect(result.content).not.toBeSimilarStringTo(`export type ResolversParentUnionTypes`); expect(result.content).not.toBeSimilarStringTo(`export type ResolversInterfaceTypes`); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; String: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; Child: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; MyOtherType: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; ChildUnion: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; ID: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; SomeNode: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; AnotherNode: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; WithChild: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; WithChildren: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; AnotherNodeWithChild: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; AnotherNodeWithAll: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; MyUnion: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; MyScalar: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; Int: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; Boolean: ResolverTypeWrapper<MyNamespace.MyDefaultMapper>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyNamespace.MyDefaultMapper; String: MyNamespace.MyDefaultMapper; Child: MyNamespace.MyDefaultMapper; MyOtherType: MyNamespace.MyDefaultMapper; ChildUnion: MyNamespace.MyDefaultMapper; Query: {}; Subscription: {}; Node: MyNamespace.MyDefaultMapper; ID: MyNamespace.MyDefaultMapper; SomeNode: MyNamespace.MyDefaultMapper; AnotherNode: MyNamespace.MyDefaultMapper; WithChild: MyNamespace.MyDefaultMapper; WithChildren: MyNamespace.MyDefaultMapper; AnotherNodeWithChild: MyNamespace.MyDefaultMapper; AnotherNodeWithAll: MyNamespace.MyDefaultMapper; MyUnion: MyNamespace.MyDefaultMapper; MyScalar: MyNamespace.MyDefaultMapper; Int: MyNamespace.MyDefaultMapper; Boolean: MyNamespace.MyDefaultMapper; }; `); }); it('should support namespaces in rootValueType', async () => { const result = (await plugin( resolversTestingSchema, [], { noSchemaStitching: true, rootValueType: './my-file#MyNamespace#MyRootType', }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> } ) | ( MyOtherType ); MyUnion: ( Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> } ) | ( MyOtherType ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( SomeNode ); AnotherNode: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChild: ( Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> } ) | ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); WithChildren: ( Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> } ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>; String: ResolverTypeWrapper<Scalars['String']['output']>; Child: ResolverTypeWrapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>; MyOtherType: ResolverTypeWrapper<MyOtherType>; ChildUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>; Query: ResolverTypeWrapper<MyNamespace.MyRootType>; Subscription: ResolverTypeWrapper<MyNamespace.MyRootType>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<Scalars['ID']['output']>; SomeNode: ResolverTypeWrapper<SomeNode>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>; AnotherNodeWithAll: ResolverTypeWrapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>; MyUnion: ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>; MyScalar: ResolverTypeWrapper<Scalars['MyScalar']['output']>; Int: ResolverTypeWrapper<Scalars['Int']['output']>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }; String: Scalars['String']['output']; Child: Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }; MyOtherType: MyOtherType; ChildUnion: ResolversUnionTypes<ResolversParentTypes>['ChildUnion']; Query: MyNamespace.MyRootType; Subscription: MyNamespace.MyRootType; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: Scalars['ID']['output']; SomeNode: SomeNode; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }; AnotherNodeWithAll: Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }; MyUnion: ResolversUnionTypes<ResolversParentTypes>['MyUnion']; MyScalar: Scalars['MyScalar']['output']; Int: Scalars['Int']['output']; Boolean: Scalars['Boolean']['output']; }; `); }); it('should support namespaces and {T} placeholder', async () => { const result = (await plugin( resolversTestingSchema, [], { defaultMapper: './my-file#MyNamespace#MyDefaultMapper<{T}>', mappers: { MyType: './my-file#MyNamespace#MyType<{T}>', AnotherNodeWithChild: './my-inteface#InterfaceNamespace#MyInterface<{T}>', }, }, { outputFile: '' } )) as Types.ComplexPluginOutput; expect(result.prepend).toContain(`import { MyNamespace } from './my-file';`); expect(result.content).toBeSimilarStringTo(` export type ResolversUnionTypes<_RefType extends Record<string, unknown>> = { ChildUnion: ( MyNamespace.MyDefaultMapper<Omit<Child, 'parent'> & { parent?: Maybe<_RefType['MyType']> }> ) | ( MyNamespace.MyDefaultMapper<MyOtherType> ); MyUnion: ( MyNamespace.MyType<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<_RefType['ChildUnion']> }> ) | ( MyNamespace.MyDefaultMapper<MyOtherType> ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = { Node: ( MyNamespace.MyDefaultMapper<SomeNode> ); AnotherNode: ( InterfaceNamespace.MyInterface<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( MyNamespace.MyDefaultMapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChild: ( InterfaceNamespace.MyInterface<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']> }> ) | ( MyNamespace.MyDefaultMapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); WithChildren: ( MyNamespace.MyDefaultMapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<_RefType['ChildUnion']>, unionChildren: Array<_RefType['ChildUnion']>, interfaceChild?: Maybe<_RefType['Node']>, interfaceChildren: Array<_RefType['Node']> }> ); }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversTypes = { MyType: ResolverTypeWrapper<MyNamespace.MyType<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']> }>>; String: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Scalars['String']['output']>>; Child: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversTypes['MyType']> }>>; MyOtherType: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<MyOtherType>>; ChildUnion: MyNamespace.MyDefaultMapper<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['ChildUnion']>>; Query: ResolverTypeWrapper<{}>; Subscription: ResolverTypeWrapper<{}>; Node: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['Node']>; ID: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Scalars['ID']['output']>>; SomeNode: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<SomeNode>>; AnotherNode: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['AnotherNode']>; WithChild: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChild']>; WithChildren: ResolverTypeWrapper<ResolversInterfaceTypes<ResolversTypes>['WithChildren']>; AnotherNodeWithChild: ResolverTypeWrapper<InterfaceNamespace.MyInterface<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']> }>>; AnotherNodeWithAll: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversTypes['ChildUnion']>, unionChildren: Array<ResolversTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversTypes['Node']>, interfaceChildren: Array<ResolversTypes['Node']> }>>; MyUnion: MyNamespace.MyDefaultMapper<ResolverTypeWrapper<ResolversUnionTypes<ResolversTypes>['MyUnion']>>; MyScalar: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Scalars['MyScalar']['output']>>; Int: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Scalars['Int']['output']>>; Boolean: ResolverTypeWrapper<MyNamespace.MyDefaultMapper<Scalars['Boolean']['output']>>; }; `); expect(result.content).toBeSimilarStringTo(` export type ResolversParentTypes = { MyType: MyNamespace.MyType<Omit<MyType, 'unionChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']> }>; String: MyNamespace.MyDefaultMapper<Scalars['String']['output']>; Child: MyNamespace.MyDefaultMapper<Omit<Child, 'parent'> & { parent?: Maybe<ResolversParentTypes['MyType']> }>; MyOtherType: MyNamespace.MyDefaultMapper<MyOtherType>; ChildUnion: MyNamespace.MyDefaultMapper<ResolversUnionTypes<ResolversParentTypes>['ChildUnion']>; Query: {}; Subscription: {}; Node: ResolversInterfaceTypes<ResolversParentTypes>['Node']; ID: MyNamespace.MyDefaultMapper<Scalars['ID']['output']>; SomeNode: MyNamespace.MyDefaultMapper<SomeNode>; AnotherNode: ResolversInterfaceTypes<ResolversParentTypes>['AnotherNode']; WithChild: ResolversInterfaceTypes<ResolversParentTypes>['WithChild']; WithChildren: ResolversInterfaceTypes<ResolversParentTypes>['WithChildren']; AnotherNodeWithChild: InterfaceNamespace.MyInterface<Omit<AnotherNodeWithChild, 'unionChild' | 'interfaceChild'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']> }>; AnotherNodeWithAll: MyNamespace.MyDefaultMapper<Omit<AnotherNodeWithAll, 'unionChild' | 'unionChildren' | 'interfaceChild' | 'interfaceChildren'> & { unionChild?: Maybe<ResolversParentTypes['ChildUnion']>, unionChildren: Array<ResolversParentTypes['ChildUnion']>, interfaceChild?: Maybe<ResolversParentTypes['Node']>, interfaceChildren: Array<ResolversParentTypes['Node']> }>; MyUnion: MyNamespace.MyDefaultMapper<ResolversUnionTypes<ResolversParentTypes>['MyUnion']>; MyScalar: MyNamespace.MyDefaultMapper<Scalars['MyScalar']['output']>; Int: MyNamespace.MyDefaultMapper<Scalars['Int']['output']>; Boolean: MyNamespace.MyDefaultMapper<Scalars['Boolean']['output']>; }; `); }); }); ```
/content/code_sandbox/packages/plugins/typescript/resolvers/tests/ts-resolvers.mapping.spec.ts
xml
2016-12-05T19:15:11
2024-08-15T14:56:08
graphql-code-generator
dotansimha/graphql-code-generator
10,759
27,981
```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "path_to_url"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> <key>UISceneStoryboardFile</key> <string>Main</string> </dict> </array> </dict> </dict> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> </dict> </plist> ```
/content/code_sandbox/cleansec/Sandbox/Sandbox/Info.plist
xml
2016-06-08T00:24:36
2024-07-27T11:01:50
Cleanse
square/Cleanse
1,784
586
```xml import { join } from 'path' import webdriver, { BrowserInterface } from 'next-webdriver' import { FileRef, nextTestSetup } from 'e2e-utils' import { check, shouldRunTurboDevTest } from 'next-test-utils' // [TODO]: It is unclear why turbopack takes longer to run this test // remove once it's fixed if (shouldRunTurboDevTest()) { jest.setTimeout(1000 * 60 * 5) } describe('TailwindCSS JIT', () => { const { next } = nextTestSetup({ files: { 'postcss.config.js': new FileRef( join(__dirname, 'tailwind-jit/postcss.config.js') ), 'tailwind.config.js': new FileRef( join(__dirname, 'tailwind-jit/tailwind.config.js') ), pages: new FileRef(join(__dirname, 'tailwind-jit/pages')), }, dependencies: { tailwindcss: '2.2.19', postcss: '8.3.5', }, }) it('works with JIT enabled', async () => { let browser: BrowserInterface try { browser = await webdriver(next.url, '/') const text = await browser.elementByCss('.text-6xl').text() expect(text).toMatch(/Welcome to/) const cssBlue = await browser .elementByCss('#test-link') .getComputedCss('color') expect(cssBlue).toBe('rgb(37, 99, 235)') const aboutPagePath = join('pages', 'index.js') const originalContent = await next.readFile(aboutPagePath) const editedContent = originalContent.replace( '<a className="text-blue-600" href="path_to_url" id="test-link">', '<a className="text-red-600" href="path_to_url" id="test-link">' ) await browser.eval('window.REAL_HMR = 1;') // change the content try { await next.patchFile(aboutPagePath, editedContent) await check( () => browser.elementByCss('#test-link').getComputedCss('color'), /rgb\(220, 38, 38\)/ ) expect(await browser.eval('window.REAL_HMR')).toBe(1) } finally { // add the original content await next.patchFile(aboutPagePath, originalContent) } } finally { if (browser) { await browser.close() } } }) }) ```
/content/code_sandbox/test/development/basic/tailwind-jit.test.ts
xml
2016-10-05T23:32:51
2024-08-16T19:44:30
next.js
vercel/next.js
124,056
553
```xml import { type DefaultIcon } from '../defaultIcon'; import type { FileIcon } from './fileIcon'; export type FileIcons = { /** * Define the default icon for folders. */ defaultIcon: DefaultIcon; /** * Defines all folder icons. */ icons: FileIcon[]; }; ```
/content/code_sandbox/src/core/models/icons/files/fileTypes.ts
xml
2016-09-09T20:41:42
2024-08-16T07:38:46
vscode-material-icon-theme
material-extensions/vscode-material-icon-theme
2,007
67