repo stringlengths 7 64 | file_url stringlengths 81 338 | file_path stringlengths 5 257 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:25:31 2026-01-05 01:50:38 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/posts-application/src/posts/posts.interfaces.ts | sample/32-graphql-federation-schema-first/posts-application/src/posts/posts.interfaces.ts | import { Directive, Field, ID, Int, ObjectType } from '@nestjs/graphql';
export interface Post {
id: number;
title: string;
authorId: number;
}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/posts-application/src/posts/models/user.model.ts | sample/32-graphql-federation-schema-first/posts-application/src/posts/models/user.model.ts | import { Directive, Field, ID, ObjectType } from '@nestjs/graphql';
import { Post } from './post.model';
@ObjectType()
@Directive('@extends')
@Directive('@key(fields: "id")')
export class User {
@Field((type) => ID)
@Directive('@external')
id: number;
@Field((type) => [Post])
posts?: Post[];
}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/posts-application/src/posts/models/post.model.ts | sample/32-graphql-federation-schema-first/posts-application/src/posts/models/post.model.ts | import { Directive, Field, ID, Int, ObjectType } from '@nestjs/graphql';
import { User } from './user.model';
@ObjectType()
@Directive('@key(fields: "id")')
export class Post {
@Field((type) => ID)
id: number;
@Field()
title: string;
@Field((type) => Int)
authorId: number;
@Field((type) => User)
use... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/gateway/src/app.module.ts | sample/32-graphql-federation-schema-first/gateway/src/app.module.ts | import { IntrospectAndCompose } from '@apollo/gateway';
import { ApolloGatewayDriver, ApolloGatewayDriverConfig } from '@nestjs/apollo';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
@Module({
imports: [
GraphQLModule.forRoot<ApolloGatewayDriverConfig>({
driver: ... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/gateway/src/main.ts | sample/32-graphql-federation-schema-first/gateway/src/main.ts | import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3002);
}
bootstrap();
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/app.module.ts | sample/32-graphql-federation-schema-first/users-application/src/app.module.ts | import { Module } from '@nestjs/common';
import { UsersModule } from './users/users.module';
@Module({
imports: [UsersModule],
controllers: [],
providers: [],
})
export class AppModule {}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/main.ts | sample/32-graphql-federation-schema-first/users-application/src/main.ts | import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/users.service.ts | sample/32-graphql-federation-schema-first/users-application/src/users/users.service.ts | import { Injectable } from '@nestjs/common';
@Injectable()
export class UsersService {
private users = [
{ id: 1, name: 'John Doe' },
{ id: 2, name: 'Richard Roe' },
];
findById(id: number) {
return this.users.find((user) => user.id === Number(id));
}
}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/users.module.ts | sample/32-graphql-federation-schema-first/users-application/src/users/users.module.ts | import {
ApolloFederationDriver,
ApolloFederationDriverConfig,
} from '@nestjs/apollo';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { UsersResolver } from './users.resolver';
import { UsersService } from './users.service';
@Module({
providers: [UsersResolver, ... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/users.service.spec.ts | sample/32-graphql-federation-schema-first/users-application/src/users/users.service.spec.ts | import { Test, TestingModule } from '@nestjs/testing';
import { UsersService } from './users.service';
describe('UsersService', () => {
let service: UsersService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UsersService],
}).compile();
ser... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/users.resolver.spec.ts | sample/32-graphql-federation-schema-first/users-application/src/users/users.resolver.spec.ts | import { Test, TestingModule } from '@nestjs/testing';
import { User } from './models/user.model';
import { UsersResolver } from './users.resolver';
import { UsersService } from './users.service';
const usersServiceMock = {
findById: jest.fn((id: number): User => {
return { id, name: 'Mocked User' };
}),
};
d... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/users.resolver.ts | sample/32-graphql-federation-schema-first/users-application/src/users/users.resolver.ts | import { Args, ID, Query, Resolver, ResolveReference } from '@nestjs/graphql';
import { UsersService } from './users.service';
@Resolver('User')
export class UsersResolver {
constructor(private usersService: UsersService) {}
@Query()
getUser(@Args({ name: 'id', type: () => ID }) id: number) {
return this.us... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/32-graphql-federation-schema-first/users-application/src/users/models/user.model.ts | sample/32-graphql-federation-schema-first/users-application/src/users/models/user.model.ts | import { Directive, Field, ID, ObjectType } from '@nestjs/graphql';
@ObjectType()
@Directive('@key(fields: "id")')
export class User {
@Field((type) => ID)
id: number;
@Field()
name: string;
}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/prisma.config.ts | sample/22-graphql-prisma/prisma.config.ts | import { defineConfig } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
datasource: {
url: 'file:./prisma/dev.db',
},
});
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/generate-typings.ts | sample/22-graphql-prisma/generate-typings.ts | import { GraphQLDefinitionsFactory } from '@nestjs/graphql';
import { join } from 'path';
const definitionsFactory = new GraphQLDefinitionsFactory();
definitionsFactory.generate({
typePaths: ['./src/**/*.graphql'],
path: join(process.cwd(), 'src/graphql.schema.ts'),
outputAs: 'class',
});
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/app.module.ts | sample/22-graphql-prisma/src/app.module.ts | import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { PostsModule } from './posts/posts.module';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
@Module({
imports: [
PostsModule,
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDr... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/graphql.schema.ts | sample/22-graphql-prisma/src/graphql.schema.ts | /*
* -------------------------------------------------------
* THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY)
* -------------------------------------------------------
*/
/* tslint:disable */
export class NewPost {
title: string;
text: string;
}
export class UpdatePost {
id: string;
title?: Nullab... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/main.ts | sample/22-graphql-prisma/src/main.ts | import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
console.log(`Application is run... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/posts/posts.module.ts | sample/22-graphql-prisma/src/posts/posts.module.ts | import { Module } from '@nestjs/common';
import { PostsResolvers } from './posts.resolvers';
import { PostsService } from './posts.service';
import { PrismaModule } from '../prisma/prisma.module';
@Module({
providers: [PostsResolvers, PostsService],
imports: [PrismaModule],
})
export class PostsModule {}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/posts/posts.service.ts | sample/22-graphql-prisma/src/posts/posts.service.ts | import { Injectable } from '@nestjs/common';
import { Post } from '@prisma/client';
import { NewPost, UpdatePost } from 'src/graphql.schema';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class PostsService {
constructor(private prisma: PrismaService) {}
async findOne(id: string):... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/posts/posts.resolvers.ts | sample/22-graphql-prisma/src/posts/posts.resolvers.ts | import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
import { PubSub } from 'graphql-subscriptions';
import { NewPost, Post, UpdatePost } from 'src/graphql.schema';
import { PostsService } from './posts.service';
const pubSub = new PubSub();
@Resolver('Post')
export class PostsResolvers {
... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/prisma/prisma.service.ts | sample/22-graphql-prisma/src/prisma/prisma.service.ts | import { Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
import { PrismaClient } from '@prisma/client';
const adapter = new PrismaBetterSqlite3({
url: 'file:./prisma/dev.db',
});
@Injectable()
export class PrismaService extends PrismaClient imp... | typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
nestjs/nest | https://github.com/nestjs/nest/blob/4500f04525c4cdde6bf98507d3d21fa9ef68082b/sample/22-graphql-prisma/src/prisma/prisma.module.ts | sample/22-graphql-prisma/src/prisma/prisma.module.ts | import { Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}
| typescript | MIT | 4500f04525c4cdde6bf98507d3d21fa9ef68082b | 2026-01-04T15:26:03.786460Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/vitest.config.ts | packages/tools-ai-sdk/vitest.config.ts | import { defineConfig } from "vitest/config";
import path from "path";
import { config } from "dotenv";
config();
export default defineConfig({
test: {
globals: true,
environment: "node",
include: ["src/**/*.test.ts"],
},
resolve: {
alias: {
"@tools": path.resolve(__dirname, "./src/tools/i... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/tsup.config.ts | packages/tools-ai-sdk/tsup.config.ts | import { defineConfig } from "tsup";
export default defineConfig({
entry: {
index: "./src/index.ts",
agent: "./src/agents/index.ts",
},
format: ["cjs", "esm"],
clean: true,
dts: true,
esbuildOptions(options) {
options.alias = {
"@tools": "./src/tools/index.ts",
"@agents": "./src/age... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/index.test.ts | packages/tools-ai-sdk/src/index.test.ts | import { describe, test, expect } from "vitest";
import { generateText, stepCountIs, tool } from "ai";
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
import { z } from "zod";
import {
resolveLibrary,
getLibraryDocs,
Context7Agent,
SYSTEM_PROMPT,
AGENT_PROMPT,
RESOLVE_LIBRARY_DESCRIPTION,
} fr... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/index.ts | packages/tools-ai-sdk/src/index.ts | // Agents
export { Context7Agent, type Context7AgentConfig } from "@agents";
// Tools
export { resolveLibrary, getLibraryDocs, type Context7ToolsConfig } from "@tools";
// Prompts
export {
SYSTEM_PROMPT,
AGENT_PROMPT,
RESOLVE_LIBRARY_DESCRIPTION,
GET_LIBRARY_DOCS_DESCRIPTION,
} from "@prompts";
// Re-export ... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/tools/resolve-library.ts | packages/tools-ai-sdk/src/tools/resolve-library.ts | import { tool } from "ai";
import { z } from "zod";
import { Context7 } from "@upstash/context7-sdk";
import { RESOLVE_LIBRARY_DESCRIPTION } from "@prompts";
import type { Context7ToolsConfig } from "./types";
/**
* Tool to resolve a library name to a Context7-compatible library ID.
*
* Can be called with or withou... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/tools/types.ts | packages/tools-ai-sdk/src/tools/types.ts | /**
* Configuration for Context7 tools
*/
export interface Context7ToolsConfig {
/**
* Context7 API key. If not provided, will use CONTEXT7_API_KEY environment variable.
*/
apiKey?: string;
/**
* Default maximum number of documentation results per page.
* @default 10
*/
defaultMaxResults?: numb... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/tools/index.ts | packages/tools-ai-sdk/src/tools/index.ts | export { resolveLibrary } from "./resolve-library";
export { getLibraryDocs } from "./get-library-docs";
export type { Context7ToolsConfig } from "./types";
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/tools/get-library-docs.ts | packages/tools-ai-sdk/src/tools/get-library-docs.ts | import { tool } from "ai";
import { z } from "zod";
import { Context7 } from "@upstash/context7-sdk";
import type { Context7ToolsConfig } from "./types";
import { GET_LIBRARY_DOCS_DESCRIPTION } from "@prompts";
/**
* Tool to fetch documentation for a library using its Context7 library ID.
*
* Can be called with or ... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/agents/context7.ts | packages/tools-ai-sdk/src/agents/context7.ts | import {
Experimental_Agent as Agent,
type Experimental_AgentSettings as AgentSettings,
type ToolSet,
stepCountIs,
} from "ai";
import { resolveLibrary, getLibraryDocs } from "@tools";
import { AGENT_PROMPT } from "@prompts";
/**
* Configuration for Context7 agent.
*/
export interface Context7AgentConfig ext... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/agents/index.ts | packages/tools-ai-sdk/src/agents/index.ts | export { Context7Agent, type Context7AgentConfig } from "./context7";
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/prompts/system.ts | packages/tools-ai-sdk/src/prompts/system.ts | /**
* System prompts for Context7 AI SDK agents
*/
/**
* Basic documentation assistant prompt
*/
export const SYSTEM_PROMPT = `You are a documentation search assistant powered by Context7.
Your role is to help users find accurate, up-to-date documentation for libraries and frameworks.
When answering questions:
1... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/tools-ai-sdk/src/prompts/index.ts | packages/tools-ai-sdk/src/prompts/index.ts | export {
SYSTEM_PROMPT,
AGENT_PROMPT,
RESOLVE_LIBRARY_DESCRIPTION,
GET_LIBRARY_DOCS_DESCRIPTION,
} from "./system";
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/vitest.config.ts | packages/sdk/vitest.config.ts | import { defineConfig } from "vitest/config";
import path from "path";
import dotenv from "dotenv";
dotenv.config();
export default defineConfig({
test: {
globals: true,
environment: "node",
include: ["src/**/*.test.ts"],
env: process.env,
},
resolve: {
alias: {
"@commands": path.resol... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/tsup.config.ts | packages/sdk/tsup.config.ts | import { defineConfig } from "tsup";
export default defineConfig({
entry: ["./src/client.ts"],
format: ["cjs", "esm"],
clean: true,
dts: true,
});
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/client.ts | packages/sdk/src/client.ts | import type {
Context7Config,
SearchLibraryResponse,
GetDocsOptions,
CodeDocsResponse,
InfoDocsResponse,
TextDocsResponse,
} from "@commands/types";
import { Context7Error } from "@error";
import { HttpClient } from "@http";
import { SearchLibraryCommand, GetDocsCommand } from "@commands/index";
const DEFA... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/client.test.ts | packages/sdk/src/client.test.ts | import { describe, test, expect } from "vitest";
import { Context7 } from "./client";
import { Context7Error } from "@error";
import type { CodeDocsResponse, InfoDocsResponse } from "@commands/types";
describe("Context7 Client", () => {
const apiKey = process.env.CONTEXT7_API_KEY || process.env.API_KEY!;
describe... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/error/index.ts | packages/sdk/src/error/index.ts | export class Context7Error extends Error {
constructor(message: string) {
super(message);
this.name = "Context7Error";
}
}
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/command.ts | packages/sdk/src/commands/command.ts | import type { Requester } from "@http";
export const _ENDPOINTS = ["v2/search", "v2/docs/info", "v2/docs/code"];
export type EndpointVariants = (typeof _ENDPOINTS)[number];
export interface CommandRequest {
method?: "GET" | "POST";
body?: unknown;
query?: Record<string, string | number | boolean | undefined>;
... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/types.ts | packages/sdk/src/commands/types.ts | export interface Context7Config {
apiKey?: string;
}
export interface SearchResult {
id: string;
title: string;
description: string;
branch: string;
lastUpdateDate: string;
state: "initial" | "finalized" | "processing" | "error" | "delete";
totalTokens: number;
totalSnippets: number;
stars?: number... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/index.ts | packages/sdk/src/commands/index.ts | export * from "./get-docs";
export * from "./search-library";
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/search-library/index.test.ts | packages/sdk/src/commands/search-library/index.test.ts | import { describe, test, expect } from "vitest";
import { SearchLibraryCommand } from "./index";
import { newHttpClient } from "../../utils/test-utils";
import { Context7 } from "../../client";
const httpClient = newHttpClient();
describe("SearchLibraryCommand", () => {
test("should search for a library", async () ... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/search-library/index.ts | packages/sdk/src/commands/search-library/index.ts | import { Command } from "@commands/command";
import type { SearchLibraryResponse } from "@commands/types";
export class SearchLibraryCommand extends Command<SearchLibraryResponse> {
constructor(query: string) {
const queryParams: Record<string, string | number | undefined> = {};
if (query) {
queryPara... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/get-docs/index.test.ts | packages/sdk/src/commands/get-docs/index.test.ts | import { describe, test, expect } from "vitest";
import { GetDocsCommand } from "./index";
import { newHttpClient } from "../../utils/test-utils";
import { Context7 } from "../../client";
import { CodeDocsResponse, TextDocsResponse } from "@commands/types";
const httpClient = newHttpClient();
describe("GetDocsCommand... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/commands/get-docs/index.ts | packages/sdk/src/commands/get-docs/index.ts | import { Command } from "@commands/command";
import type {
GetDocsOptions,
CodeDocsResponse,
InfoDocsResponse,
TextDocsResponse,
QueryParams,
} from "@commands/types";
import type { Requester } from "@http";
const DEFAULT_DOC_TYPE = "code";
const DEFAULT_FORMAT = "json";
export class GetDocsCommand extends ... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/utils/test-utils.ts | packages/sdk/src/utils/test-utils.ts | import { HttpClient } from "@http";
export function newHttpClient(): HttpClient {
const apiKey = process.env.CONTEXT7_API_KEY || process.env.API_KEY;
if (!apiKey) {
throw new Error("CONTEXT7_API_KEY or API_KEY environment variable is required for tests");
}
return new HttpClient({
baseUrl: process.en... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/sdk/src/http/index.ts | packages/sdk/src/http/index.ts | import { Context7Error } from "@error";
type CacheSetting =
| "default"
| "force-cache"
| "no-cache"
| "no-store"
| "only-if-cached"
| "reload"
| false;
export type Context7Request = {
path?: string[];
/**
* Request body will be serialized to json
*/
body?: unknown;
/**
* HTTP method to... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/index.ts | packages/mcp/src/index.ts | #!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import { searchLibraries, fetchLibraryContext } from "./lib/api.js";
import { ClientContext } from "./lib/encryption.js";
i... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/lib/utils.ts | packages/mcp/src/lib/utils.ts | import { SearchResponse, SearchResult } from "./types.js";
/**
* Maps numeric source reputation score to an interpretable label for LLM consumption.
*
* @returns One of: "High", "Medium", "Low", or "Unknown"
*/
function getSourceReputationLabel(
sourceReputation?: number
): "High" | "Medium" | "Low" | "Unknown" ... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/lib/api.ts | packages/mcp/src/lib/api.ts | import { SearchResponse, ContextRequest, ContextResponse } from "./types.js";
import { ClientContext, generateHeaders } from "./encryption.js";
import { ProxyAgent, setGlobalDispatcher } from "undici";
const CONTEXT7_API_BASE_URL = "https://context7.com/api";
/**
* Parses error response from the Context7 API
* Extr... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/lib/encryption.ts | packages/mcp/src/lib/encryption.ts | import { createCipheriv, randomBytes } from "crypto";
import { SERVER_VERSION } from "./constants.js";
const DEFAULT_ENCRYPTION_KEY = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
const ENCRYPTION_KEY = process.env.CLIENT_IP_ENCRYPTION_KEY || DEFAULT_ENCRYPTION_KEY;
const ALGORITHM = "aes-256-cbc... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/lib/constants.ts | packages/mcp/src/lib/constants.ts | import pkg from "../../package.json" with { type: "json" };
export const SERVER_VERSION: string = pkg.version;
| typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
upstash/context7 | https://github.com/upstash/context7/blob/7a04a0484192d533534e59d193c8667b13c9339f/packages/mcp/src/lib/types.ts | packages/mcp/src/lib/types.ts | export interface SearchResult {
id: string;
title: string;
description: string;
branch: string;
lastUpdateDate: string;
state: DocumentState;
totalTokens: number;
totalSnippets: number;
stars?: number;
trustScore?: number;
benchmarkScore?: number;
versions?: string[];
}
export interface SearchR... | typescript | MIT | 7a04a0484192d533534e59d193c8667b13c9339f | 2026-01-04T15:51:54.569820Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/benchmarks/src/cases/SierpinskiTriangle.tsx | packages/benchmarks/src/cases/SierpinskiTriangle.tsx | import { interpolateBuPu, interpolatePurples, interpolateRdPu } from 'd3-scale-chromatic';
import React from 'react';
import { BenchmarkType } from '../app/Benchmark';
const targetSize = 10;
type ISierpinskiTriangle = {
components: {
Dot: React.FC<any>;
};
depth: number;
renderCount: number;
s: number;
... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/benchmarks/src/cases/Tree.tsx | packages/benchmarks/src/cases/Tree.tsx | import React from 'react';
import { BenchmarkType } from '../app/Benchmark';
interface IBox {
color?: number;
layout?: 'column' | 'row';
outer?: boolean;
fixed?: boolean;
}
interface ITree {
breadth: number;
components: {
Box: React.FC<IBox>;
};
depth: number;
id: number;
wrap: number;
}
expo... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/global.d.ts | packages/styled-components/src/global.d.ts | declare module '@babel/helper-module-imports' {
import { NodePath, types } from '@babel/core';
export function addDefault(
program: NodePath,
identifier: types.Identifier,
options: Object
): types.Identifier;
export function addNamed(
program: NodePath,
name: string,
identifier: types.... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/index-standalone.ts | packages/styled-components/src/index-standalone.ts | import * as secondary from './base';
/* Import singleton constructors */
import styled from './constructors/styled';
/**
* eliminates the need to do styled.default since the other APIs
* are directly assigned as properties to the main function
* */
for (const key in secondary) {
// @ts-expect-error shush
styled... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/base.ts | packages/styled-components/src/base.ts | /* Import singletons */
import { SC_ATTR, SC_VERSION } from './constants';
import createGlobalStyle from './constructors/createGlobalStyle';
import css from './constructors/css';
import keyframes from './constructors/keyframes';
/* Import Higher Order Components */
import withTheme from './hoc/withTheme';
/* Import hoo... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/constants.ts | packages/styled-components/src/constants.ts | declare let SC_DISABLE_SPEEDY: boolean | null | undefined;
declare let __VERSION__: string;
export const SC_ATTR: string =
(typeof process !== 'undefined' &&
typeof process.env !== 'undefined' &&
(process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
'data-styled';
export const SC_ATTR_ACTIVE = 'activ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/secretInternals.ts | packages/styled-components/src/secretInternals.ts | import { mainSheet } from './models/StyleSheetManager';
import StyleSheet from './sheet';
export const __PRIVATE__ = {
StyleSheet,
mainSheet,
};
| typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/types.ts | packages/styled-components/src/types.ts | import type * as CSS from 'csstype';
import React from 'react';
import ComponentStyle from './models/ComponentStyle';
import { DefaultTheme } from './models/ThemeProvider';
import createWarnTooManyClasses from './utils/createWarnTooManyClasses';
import type { SupportedHTMLElements } from './utils/domElements';
export ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/index.ts | packages/styled-components/src/index.ts | import styled, { LibraryStyled, Styled, StyledInstance } from './constructors/styled';
export * from './base';
export {
CSSKeyframes,
CSSObject,
CSSProp,
CSSProperties,
CSSPseudos,
DataAttributes,
DefaultTheme,
ExecutionContext,
ExecutionProps,
FastOmit,
IStyledComponent,
IStyledComponentFactor... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/native/index.ts | packages/styled-components/src/native/index.ts | import transformDeclPairs from 'css-to-react-native';
import { parse } from 'postcss';
import React from 'react';
import constructWithOptions, { Styled } from '../constructors/constructWithOptions';
import css from '../constructors/css';
import withTheme from '../hoc/withTheme';
import _InlineStyle from '../models/Inli... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/native/test/native.test.tsx | packages/styled-components/src/native/test/native.test.tsx | import React, { PropsWithChildren } from 'react';
import { Image, Text, View, ViewProps } from 'react-native';
import TestRenderer from 'react-test-renderer';
import styled, { ThemeProvider, css, toStyleSheet } from '../';
import { RN_UNSUPPORTED_VALUES } from '../../models/InlineStyle';
// NOTE: These tests are like ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/GroupIDAllocator.ts | packages/styled-components/src/sheet/GroupIDAllocator.ts | import styledError from '../utils/error';
const MAX_SMI = 1 << (31 - 1);
let groupIDRegister: Map<string, number> = new Map();
let reverseRegister: Map<number, string> = new Map();
let nextFreeGroup = 1;
export const resetGroupIds = () => {
groupIDRegister = new Map();
reverseRegister = new Map();
nextFreeGrou... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/Tag.ts | packages/styled-components/src/sheet/Tag.ts | import { InsertionTarget } from '../types';
import { getSheet, makeStyleTag } from './dom';
import { SheetOptions, Tag } from './types';
/** Create a CSSStyleSheet-like tag depending on the environment */
export const makeTag = ({ isServer, useCSSOMInjection, target }: SheetOptions) => {
if (isServer) {
return n... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/dom.ts | packages/styled-components/src/sheet/dom.ts | import { SC_ATTR, SC_ATTR_ACTIVE, SC_ATTR_VERSION, SC_VERSION } from '../constants';
import { InsertionTarget } from '../types';
import styledError from '../utils/error';
import getNonce from '../utils/nonce';
/** Find last style element if any inside target */
const findLastStyleTag = (target: InsertionTarget): void ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/GroupedTag.ts | packages/styled-components/src/sheet/GroupedTag.ts | import { SPLITTER } from '../constants';
import styledError from '../utils/error';
import { GroupedTag, Tag } from './types';
/** Create a GroupedTag with an underlying Tag implementation */
export const makeGroupedTag = (tag: Tag) => {
return new DefaultGroupedTag(tag);
};
const BASE_SIZE = 1 << 9;
const DefaultG... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/Sheet.ts | packages/styled-components/src/sheet/Sheet.ts | import { DISABLE_SPEEDY, IS_BROWSER } from '../constants';
import { InsertionTarget } from '../types';
import { EMPTY_OBJECT } from '../utils/empties';
import { setToString } from '../utils/setToString';
import { makeGroupedTag } from './GroupedTag';
import { getGroupForId } from './GroupIDAllocator';
import { outputSh... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/Rehydration.ts | packages/styled-components/src/sheet/Rehydration.ts | import { SC_ATTR, SC_ATTR_ACTIVE, SC_ATTR_VERSION, SC_VERSION, SPLITTER } from '../constants';
import { getIdForGroup, setGroupForId } from './GroupIDAllocator';
import { Sheet } from './types';
const SELECTOR = `style[${SC_ATTR}][${SC_ATTR_VERSION}="${SC_VERSION}"]`;
const MARKER_RE = new RegExp(`^${SC_ATTR}\\.g(\\d+... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/types.ts | packages/styled-components/src/sheet/types.ts | import { InsertionTarget } from '../types';
/** CSSStyleSheet-like Tag abstraction for CSS rules */
export interface Tag {
insertRule(index: number, rule: string): boolean;
deleteRule(index: number): void;
getRule(index: number): string;
length: number;
}
/** Group-aware Tag that sorts rules by indices */
exp... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/index.ts | packages/styled-components/src/sheet/index.ts | export { default } from './Sheet';
| typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/Sheet.test.ts | packages/styled-components/src/sheet/test/Sheet.test.ts | import StyleSheet from '../Sheet';
let sheet: InstanceType<typeof StyleSheet>;
let tag;
beforeEach(() => {
sheet = new StyleSheet({ isServer: true });
tag = sheet.getTag().tag;
});
it('inserts rules correctly', () => {
expect(tag.length).toBe(0);
sheet.insertRules('id', 'name', ['.test {}']);
expect(sheet.... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/Tag.test.ts | packages/styled-components/src/sheet/test/Tag.test.ts | import { C } from 'ts-toolbelt';
import { CSSOMTag, TextTag, VirtualTag } from '../Tag';
import { Tag } from '../types';
const describeTag = (TagClass: C.Class<[], Tag>) => {
it('inserts and retrieves rules at indices', () => {
const tag = new TagClass();
expect(tag.insertRule(0, '.b {}')).toBe(true);
ex... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/Rehydration.test.tsx | packages/styled-components/src/sheet/test/Rehydration.test.tsx | import React from 'react';
import { render } from '@testing-library/react';
import { ServerStyleSheet, StyleSheetManager } from '../../base';
import { SC_ATTR, SC_ATTR_ACTIVE, SC_ATTR_VERSION, SC_VERSION } from '../../constants';
import { resetStyled } from '../../test/utils';
import * as GroupIDAllocator from '../Gro... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/GroupedTag.test.ts | packages/styled-components/src/sheet/test/GroupedTag.test.ts | import { makeGroupedTag } from '../GroupedTag';
import { VirtualTag } from '../Tag';
let tag: InstanceType<typeof VirtualTag>;
let groupedTag: ReturnType<typeof makeGroupedTag>;
beforeEach(() => {
tag = new VirtualTag();
groupedTag = makeGroupedTag(tag);
});
it('inserts and retrieves rules by groups correctly', ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/dom.test.ts | packages/styled-components/src/sheet/test/dom.test.ts | import { SC_ATTR, SC_ATTR_ACTIVE, SC_ATTR_VERSION } from '../../constants';
import { makeStyleTag } from '../dom';
describe('makeStyleTag', () => {
it('creates a style element with the SC attributes', () => {
const element = makeStyleTag();
expect(element.tagName).toBe('STYLE');
expect(element.getAttrib... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/sheet/test/GroupIDAllocator.test.ts | packages/styled-components/src/sheet/test/GroupIDAllocator.test.ts | import * as GroupIDAllocator from '../GroupIDAllocator';
beforeEach(GroupIDAllocator.resetGroupIds);
afterEach(GroupIDAllocator.resetGroupIds);
it('creates continuous group IDs', () => {
const a = GroupIDAllocator.getGroupForId('a');
const b = GroupIDAllocator.getGroupForId('b');
expect(a).toBe(1);
expect(b)... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/styles.test.tsx | packages/styled-components/src/test/styles.test.tsx | import { render } from '@testing-library/react';
import React from 'react';
import { ThemeProvider } from '../base';
import css from '../constructors/css';
import { mainSheet } from '../models/StyleSheetManager';
import * as nonce from '../utils/nonce';
import { getRenderedCSS, resetStyled } from './utils';
jest.mock(... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/ssr.test.tsx | packages/styled-components/src/test/ssr.test.tsx | /**
* @jest-environment node
*/
import { resetStyled } from './utils';
import React from 'react';
import { renderToNodeStream, renderToPipeableStream, renderToString } from 'react-dom/server';
import stylisRTLPlugin from 'stylis-plugin-rtl';
import createGlobalStyle from '../constructors/createGlobalStyle';
import ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/test.d.ts | packages/styled-components/src/test/test.d.ts | import '../models/ThemeProvider';
declare module '../models/ThemeProvider' {
// random theme variables used throughout the tests, could consolidate this
interface DefaultTheme {
borderRadius?: string;
color?: string;
colors?: Record<string, any>;
fontSize?: number;
fontSizes?: { sm: string };
... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/theme.test.tsx | packages/styled-components/src/test/theme.test.tsx | import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React, { Component } from 'react';
import withTheme from '../hoc/withTheme';
import ThemeProvider, { DefaultTheme } from '../models/ThemeProvider';
import { getRenderedCSS, resetStyled } from './utils';
let styled: ReturnType<t... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/props.test.tsx | packages/styled-components/src/test/props.test.tsx | import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React, { Fragment } from 'react';
import { getRenderedCSS, resetStyled } from './utils';
let styled: ReturnType<typeof resetStyled>;
describe('props', () => {
beforeEach(() => {
styled = resetStyled();
});
it('shoul... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/basic.test.tsx | packages/styled-components/src/test/basic.test.tsx | import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React, { Component, CSSProperties, StrictMode } from 'react';
import { AnyComponent } from '../types';
import hoist from '../utils/hoist';
import { getRenderedCSS, resetStyled } from './utils';
let styled: ReturnType<typeof res... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/css.test.tsx | packages/styled-components/src/test/css.test.tsx | import { render } from '@testing-library/react';
import React from 'react';
import { getRenderedCSS, resetStyled } from './utils';
// Disable isStaticRules optimisation since we're not
// testing for ComponentStyle specifics here
jest.mock('../utils/isStaticRules', () => () => false);
let styled: ReturnType<typeof re... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/utils.ts | packages/styled-components/src/test/utils.ts | /**
* This sets up our end-to-end test suite, which essentially makes sure
* our public API works the way we promise/want
*/
import beautify from 'js-beautify';
import styled from '../constructors/styled';
import { mainSheet } from '../models/StyleSheetManager';
import { resetGroupIds } from '../sheet/GroupIDAllocat... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/warnOnDynamicCreation.test.tsx | packages/styled-components/src/test/warnOnDynamicCreation.test.tsx | import React from 'react';
import { render } from '@testing-library/react';
import { resetStyled } from './utils';
describe('warns on dynamic creation', () => {
let warn: ReturnType<typeof jest.spyOn>;
let styled: ReturnType<typeof resetStyled>;
beforeEach(() => {
warn = jest.spyOn(console, 'warn').mockImp... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/constants.test.tsx | packages/styled-components/src/test/constants.test.tsx | import { SC_ATTR as DEFAULT_SC_ATTR } from '../constants';
import { expectCSSMatches } from './utils';
declare global {
namespace NodeJS {
export interface ProcessEnv {
REACT_APP_SC_DISABLE_SPEEDY?: string;
SC_DISABLE_SPEEDY?: string;
}
}
interface Window {
REACT_APP_SC_DISABLE_SPEEDY?: ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/veryLargeUnionType.ts | packages/styled-components/src/test/veryLargeUnionType.ts | export type VeryLargeUnionType =
| 'add-clip'
| 'add-column-left'
| 'add-column-right'
| 'add-location'
| 'add-row-bottom'
| 'add-row-top'
| 'add-to-artifact'
| 'add-to-folder'
| 'add'
| 'aimpoints-target'
| 'airplane'
| 'align-center'
| 'align-justify'
| 'align-left'
| 'align-right'
| '... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/attrs.test.tsx | packages/styled-components/src/test/attrs.test.tsx | import { render } from '@testing-library/react';
import * as CSS from 'csstype';
import React from 'react';
import ThemeProvider from '../models/ThemeProvider';
import { AnyComponent, DataAttributes } from '../types';
import { getRenderedCSS, resetStyled } from './utils';
// Disable isStaticRules optimisation since we... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/expanded-api.test.tsx | packages/styled-components/src/test/expanded-api.test.tsx | import { render } from '@testing-library/react';
import React from 'react';
import { getRenderedCSS, resetStyled } from './utils';
// Disable isStaticRules optimisation since we're not
// testing for ComponentStyle specifics here
jest.mock('../utils/isStaticRules', () => () => false);
let styled: ReturnType<typeof re... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/types.tsx | packages/styled-components/src/test/types.tsx | /**
* This file is meant for typing-related tests that don't need to go through Jest.
*/
import React from 'react';
import { css, CSSProp, IStyledComponent, StyledObject } from '../index';
import styled from '../index-standalone';
import { DataAttributes } from '../types';
import { VeryLargeUnionType } from './veryLa... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/globals.ts | packages/styled-components/src/test/globals.ts | declare var __SERVER__: boolean;
declare var __VERSION__: string;
global.__SERVER__ = typeof document === 'undefined';
global.__VERSION__ = 'JEST_MOCK_VERSION';
| typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/staticCaching.test.ts | packages/styled-components/src/test/staticCaching.test.ts | import { resetStyled } from './utils';
let styled: ReturnType<typeof resetStyled>;
describe('static style caching', () => {
beforeEach(() => {
styled = resetStyled();
});
describe('non-production modes', () => {
it('should mark styles without any functions as not static', () => {
const TOP_AS_NUM... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/overriding.test.tsx | packages/styled-components/src/test/overriding.test.tsx | import { render } from '@testing-library/react';
import React from 'react';
import { AnyComponent } from '../types';
import { getRenderedCSS, resetStyled } from './utils';
// Disable isStaticRules optimisation since we're not
// testing for ComponentStyle specifics here
jest.mock('../utils/isStaticRules', () => () => ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/rehydration.test.tsx | packages/styled-components/src/test/rehydration.test.tsx | import { render } from '@testing-library/react';
import React from 'react';
import { SC_ATTR, SC_ATTR_VERSION } from '../constants';
import { getRenderedCSS, rehydrateTestStyles, resetStyled, seedNextClassnames } from './utils';
declare const __VERSION__: string;
/* NOTE:
Sometimes we add an empty function interpo... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/test/warnTooManyClasses.test.tsx | packages/styled-components/src/test/warnTooManyClasses.test.tsx | import React from 'react';
import { render } from '@testing-library/react';
import { LIMIT } from '../utils/createWarnTooManyClasses';
import { resetStyled } from './utils';
let styled: ReturnType<typeof resetStyled>;
describe('warn too many classes', () => {
/**
* Make sure the setup is the same for every test... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
styled-components/styled-components | https://github.com/styled-components/styled-components/blob/c3a599097a04ce681fd387e3d58c50e7c1fe3e76/packages/styled-components/src/models/ServerStyleSheet.tsx | packages/styled-components/src/models/ServerStyleSheet.tsx | import React from 'react';
import { type PipeableStream } from 'react-dom/server';
import type * as streamInternal from 'stream';
import { IS_BROWSER, SC_ATTR, SC_ATTR_VERSION, SC_VERSION } from '../constants';
import StyleSheet from '../sheet';
import styledError from '../utils/error';
import { joinStringArray } from ... | typescript | MIT | c3a599097a04ce681fd387e3d58c50e7c1fe3e76 | 2026-01-04T15:51:04.970441Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.