sailfork / t3code-github / .repos/ alchemy-effect/ packages/ prisma/ src/ ComputeArchive.ts

import { dotAlchemyDirectory } from "alchemy/AlchemyContext";
import { isPathWithin } from "alchemy/Util/isPathWithin";
import * as Data from "effect/Data";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import type { PlatformError } from "effect/PlatformError";
import {
  isArchivedRegularFile,
  readDirectoryEntriesSecure,
  writeCompressedArchiveSecure,
  type ArchiveTarEntry,
} from "./internal/ArchivePlatform.ts";
import {
  inspectArtifactFile,
  inspectVerifiedFile,
  readArtifactFile,
  type ArtifactFile,
} from "./internal/ArtifactFile.ts";

export class ComputeArchiveInvalidProps extends Data.TaggedError("ComputeArchiveInvalidProps")<{
  readonly message: string;
  readonly cause?: unknown;
}> {}

export class ComputeArchiveOperationFailed extends Data.TaggedError(
  "ComputeArchiveOperationFailed",
)<{
  readonly message: string;
  readonly cause?: unknown;
}> {}

export const COMPUTE_MANIFEST_VERSION = "1";

const MAX_UNCOMPRESSED_BYTES = 768 * 1024 * 1024;
const MAX_FILE_BYTES = 128 * 1024 * 1024;
const MAX_ENTRIES = 50_000;
const MAX_COMPRESSED_BYTES = 768 * 1024 * 1024;

export interface ComputeArchiveOptions {
  /**
   * Directory whose files should be uploaded as the compute bundle.
   */
  directory: string;
  /**
   * Entrypoint relative to `directory`.
   */
  entrypoint: string;
  /**
   * Additional artifact-relative paths to exclude. Patterns support `*` and
   * `**`; directory matches exclude their complete subtree. Absolute paths,
   * parent (`..`) segments, and negated patterns are rejected. Sensitive
   * Alchemy, Git, and dotenv files are always excluded.
   */
  ignore?: readonly string[];
  /**
   * Artifact-relative prefix applied to custom ignore patterns after they are
   * validated.
   */
  ignorePrefix?: string;
  /**
   * Artifact-relative files that must remain present after exclusions.
   */
  requiredFiles?: readonly string[];
  /**
   * Maximum uncompressed bytes accepted across all archived files. Values
   * above the provider's 768 MiB hard ceiling are rejected.
   *
   * @default 805306368 (768 MiB)
   */
  maxUncompressedBytes?: number;
  /**
   * Maximum bytes accepted for one archived file. Values above the provider's
   * 128 MiB hard ceiling are rejected.
   *
   * @default 134217728 (128 MiB)
   */
  maxFileBytes?: number;
  /**
   * Maximum number of filesystem entries accepted in an artifact. Values
   * above the provider's 50,000-entry hard ceiling are rejected.
   *
   * @default 50000
   */
  maxEntries?: number;
  /**
   * Return a verified, file-backed archive instead of materializing the final
   * compressed bytes. The caller must run the returned `cleanup` Effect.
   *
   * @default "bytes"
   */
  output?: "bytes" | "file";
}

const ALWAYS_IGNORED_PATTERNS = [
  ".git",
  "**/.git",
  ".alchemy",
  "**/.alchemy",
  ".env",
  "**/.env",
  ".env.*",
  "**/.env.*",
  ".envrc",
  "**/.envrc",
  ".npmrc",
  "**/.npmrc",
  ".yarnrc*",
  "**/.yarnrc*",
  ".netrc",
  "**/.netrc",
  ".pypirc",
  "**/.pypirc",
  ".aws",
  "**/.aws",
  ".ssh",
  "**/.ssh",
] as const;

interface ArchiveBudget {
  readonly ignore: readonly RegExp[];
  readonly maxUncompressedBytes: number;
  readonly maxFileBytes: number;
  readonly maxEntries: number;
  bytes: number;
  entries: number;
}

export class ComputeArchiveOptionsError extends Data.TaggedError("ComputeArchiveOptionsError")<{
  readonly message: string;
  readonly cause?: unknown;
}> {}

type ArchiveError = PlatformError | Error;
type ArchiveRequirements = FileSystem.FileSystem | Path.Path;

export function createComputeArchive(
  options: ComputeArchiveOptions & { readonly output: "file" },
): Effect.Effect<ArtifactFile, ArchiveError, ArchiveRequirements>;
export function createComputeArchive(
  options: ComputeArchiveOptions & { readonly output?: "bytes" },
): Effect.Effect<Uint8Array, ArchiveError, ArchiveRequirements>;
export function createComputeArchive(
  options: ComputeArchiveOptions,
): Effect.Effect<Uint8Array | ArtifactFile, ArchiveError, ArchiveRequirements>;
/**
 * Create the `tar.gz` artifact consumed by Prisma Compute.
 *
 * Files are added under the `bundle/` prefix, with a synthetic
 * `compute.manifest.json` at the archive root. Tar construction and gzip
 * compression stream through a private temporary file, so the uncompressed
 * artifact is never retained in memory.
 */
export function createComputeArchive(
  options: ComputeArchiveOptions,
): Effect.Effect<Uint8Array | ArtifactFile, ArchiveError, ArchiveRequirements> {
  const effect = createComputeArchiveFile(options);
  if (options.output === "file") return effect;
  return Effect.flatMap(effect, (artifact) =>
    readArtifactFile(artifact).pipe(Effect.ensuring(artifact.cleanup)),
  );
}

const createComputeArchiveFile = Effect.fn(function* (
  options: ComputeArchiveOptions,
): Effect.fn.Return<ArtifactFile, ArchiveError, ArchiveRequirements> {
  const {
    directory,
    entrypoint,
    ignore = [],
    ignorePrefix,
    requiredFiles = [],
    maxUncompressedBytes = MAX_UNCOMPRESSED_BYTES,
    maxFileBytes = MAX_FILE_BYTES,
    maxEntries = MAX_ENTRIES,
  } = options;
  const fs = yield* FileSystem.FileSystem;
  const path = yield* Path.Path;
  const runtimeBase = process.cwd();
  const root = path.resolve(runtimeBase, directory);
  const realRoot = yield* fs.realPath(root);
  const dotAlchemy = yield* dotAlchemyDirectory;
  const runtimeRelative = path
    .relative(root, path.resolve(runtimeBase, dotAlchemy))
    .replaceAll("\\", "/");
  const normalizedEntrypoint = yield* normalizeEntrypoint(entrypoint);
  const validated = yield* Effect.try({
    try: () => ({
      ignore: [
        ...(isPathWithin(root, dotAlchemy, runtimeBase)
          ? [
              // Keep runtime state out of the archive. Escape regex characters
              // in the literal directory name (e.g. "cache[private]"); the
              // suffix matches that directory and its descendants, not siblings
              // whose names merely share its prefix (e.g. "cache-backup").
              new RegExp(`^${runtimeRelative.replace(/[.*+?^${}()|[\]\\]/g, "\\

Loading Sailfork

amp;")}(?:/.*)? .repos/alchemy-effect/packages/prisma/src/ComputeArchive.ts at main · sailfork/t3code-github · Sailfork
), ] : []), ...ALWAYS_IGNORED_PATTERNS.map((pattern) => compileIgnorePattern(pattern)), ...ignore.map((pattern) => compileIgnorePattern(pattern, ignorePrefix)), ], maxUncompressedBytes: boundedLimit( "maxUncompressedBytes", maxUncompressedBytes, MAX_UNCOMPRESSED_BYTES, ), maxFileBytes: boundedLimit("maxFileBytes", maxFileBytes, MAX_FILE_BYTES), maxEntries: boundedLimit("maxEntries", maxEntries, MAX_ENTRIES), }), catch: (error) => new ComputeArchiveOptionsError({ message: error instanceof Error ? error.message : String(error), cause: error, }), }); const budget: ArchiveBudget = { ...validated, bytes: 0, entries: 0, }; if (budget.maxFileBytes > budget.maxUncompressedBytes) { return yield* new ComputeArchiveInvalidProps({ message: "maxFileBytes must not exceed maxUncompressedBytes", }); } if (isIgnored(normalizedEntrypoint, budget.ignore)) { return yield* new ComputeArchiveInvalidProps({ message: `Entrypoint is excluded from the compute artifact: ${normalizedEntrypoint}`, }); } const resolvedEntrypoint = yield* resolvePathWithinRoot( realRoot, path.join(realRoot, normalizedEntrypoint), ); const entrypointStat = yield* fs.stat(resolvedEntrypoint); if (entrypointStat.type !== "File") { return yield* new ComputeArchiveInvalidProps({ message: `Entrypoint must be a file in compute artifact: ${normalizedEntrypoint}`, }); } const entries: ArchiveTarEntry[] = []; yield* addDirectoryEntries(entries, realRoot, realRoot, "bundle", "", budget); const entrypointArchiveName = `bundle/${normalizedEntrypoint}`; if (!isArchivedRegularFile(entries, entrypointArchiveName)) { return yield* new ComputeArchiveOperationFailed({ message: `Entrypoint not found in compute artifact: ${normalizedEntrypoint}`, }); } for (const file of requiredFiles) { const normalized = yield* normalizeEntrypoint(file); if (!isArchivedRegularFile(entries, `bundle/${normalized}`)) { return yield* new ComputeArchiveOperationFailed({ message: `Required file not found in compute artifact: ${normalized}`, }); } } const manifest = new TextEncoder().encode( JSON.stringify( { manifestVersion: COMPUTE_MANIFEST_VERSION, entrypoint: entrypointArchiveName, }, null, 2, ), ); const archivePath = yield* fs.makeTempFile({ prefix: "alchemy-prisma-compute-", suffix: ".tar.gz", }); const cleanup = fs.remove(archivePath, { force: true }).pipe(Effect.ignore); yield* writeCompressedArchiveSecure(archivePath, entries, manifest, MAX_COMPRESSED_BYTES).pipe( Effect.tapError(() => cleanup), ); return yield* inspectArtifactFile(archivePath, MAX_COMPRESSED_BYTES, { cleanup, description: "Prisma compute archive", }).pipe(Effect.tapError(() => cleanup)); }); const addDirectoryEntries: ( entries: ArchiveTarEntry[], realRoot: string, directory: string, tarPrefix: string, relativePrefix: string, budget: ArchiveBudget, ) => Effect.Effect<void, ArchiveError, ArchiveRequirements> = Effect.fn( function* (entries, realRoot, directory, tarPrefix, relativePrefix, budget) { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; const directoryResult = yield* readDirectoryEntriesSecure({ directory, relativePrefix, ignore: budget.ignore, entriesAlreadyObserved: budget.entries, maxEntries: budget.maxEntries, }); budget.entries += directoryResult.observedEntries; for (const entry of directoryResult.entries) { const name = entry.name; const relativeName = relativePrefix ? `${relativePrefix}/${name}` : name; const filePath = path.join(directory, name); const tarName = `${tarPrefix}/${name}`; if (entry.type === "SymbolicLink") { const symlinkTarget = yield* fs.readLink(filePath); const linkname = yield* resolveArchiveSymlinkTarget(realRoot, filePath, symlinkTarget); entries.push({ name: tarName, mode: 0o777, type: "symlink", linkname, }); continue; } if (entry.type === "Directory") { const realDirectory = yield* resolvePathWithinRoot(realRoot, filePath); yield* addDirectoryEntries(entries, realRoot, realDirectory, tarName, relativeName, budget); continue; } if (entry.type !== "File") { return yield* new ComputeArchiveOperationFailed({ message: `Unsupported filesystem entry in compute artifact: ${relativeName}`, }); } const verified = yield* inspectVerifiedFile(filePath, budget.maxFileBytes, { allowEmpty: true, description: `Compute artifact file '${relativeName}'`, }); yield* ensureResolvedPathWithinRoot(realRoot, verified.path); if (budget.bytes + verified.size > budget.maxUncompressedBytes) { return yield* new ComputeArchiveOperationFailed({ message: `Compute artifact exceeds the ${budget.maxUncompressedBytes} byte uncompressed safety limit. Narrow the artifact directory or add ignore patterns.`, }); } budget.bytes += verified.size; entries.push({ name: tarName, mode: verified.mode & 0o777, type: "file", file: verified, }); } }, ); export const normalizeEntrypoint = (entrypoint: string) => Effect.gen(function* () { const normalized = entrypoint.replaceAll("\\", "/"); if (normalized.trim().length === 0) { return yield* new ComputeArchiveInvalidProps({ message: "entrypoint must be non-empty" }); } if (normalized.startsWith("/") || /^[a-zA-Z]:\//.test(normalized)) { return yield* new ComputeArchiveInvalidProps({ message: "entrypoint must be relative" }); } const parts = normalized.split("/").filter((part) => part !== "."); if (parts.some((part) => part === ".." || part.length === 0)) { return yield* new ComputeArchiveInvalidProps({ message: "entrypoint must not contain empty or parent segments", }); } return parts.join("/"); }); const resolvePathWithinRoot = Effect.fn(function* (realRoot: string, candidate: string) { const fs = yield* FileSystem.FileSystem; const realCandidate = yield* fs.realPath(candidate); yield* ensureResolvedPathWithinRoot(realRoot, realCandidate); return realCandidate; }); const ensureResolvedPathWithinRoot = Effect.fn(function* ( realRoot: string, resolvedCandidate: string, ) { const path = yield* Path.Path; const relative = path.relative(realRoot, resolvedCandidate); if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) { return yield* new ComputeArchiveOperationFailed({ message: `Archive path escapes compute artifact root: ${resolvedCandidate}`, }); } }); const resolveArchiveSymlinkTarget = Effect.fn(function* ( realRoot: string, symlinkPath: string, target: string, ) { const path = yield* Path.Path; if (path.sep === "/" && target.includes("\\")) { return yield* new ComputeArchiveOperationFailed({ message: `Archive symlink target contains an unsupported backslash: ${target}`, }); } const symlinkDir = path.dirname(symlinkPath); const targetPath = path.isAbsolute(target) ? target : path.resolve(symlinkDir, target); const realTarget = yield* resolvePathWithinRoot(realRoot, targetPath); if (!path.isAbsolute(target)) return target.replaceAll("\\", "/"); const realSymlinkDir = yield* resolvePathWithinRoot(realRoot, symlinkDir); const relative = path.relative(realSymlinkDir, realTarget); return (relative.length === 0 ? "." : relative).replaceAll("\\", "/"); }); const boundedLimit = (name: string, value: number, hardLimit: number) => { if (!Number.isSafeInteger(value) || value <= 0) { throw new Error(`${name} must be a positive safe integer`); } if (value > hardLimit) { throw new Error(`${name} must not exceed the hard limit of ${hardLimit}`); } return value; }; const compileIgnorePattern = (input: string, prefix?: string) => { const normalized = input.replaceAll("\\", "/").replace(/^\.\//, ""); if ( normalized.length === 0 || normalized.startsWith("!") || normalized.startsWith("/") || /^[a-zA-Z]:\//.test(normalized) || normalized.split("/").some((segment) => segment === "..") ) { throw new Error(`Invalid compute archive ignore pattern: ${input}`); } const scoped = prefix === undefined ? normalized : `${prefix}/${normalized}`; const escaped = scoped .replace(/[.+^${}()|[\]\\]/g, "\\

Loading Sailfork

amp;") .replaceAll("**", "\0") .replaceAll("*", "[^/]*") .replaceAll("\0", ".*"); return new RegExp(`^${escaped}(?:/.*)? .repos/alchemy-effect/packages/prisma/src/ComputeArchive.ts at main · sailfork/t3code-github · Sailfork
); }; const isIgnored = (relativeName: string, patterns: readonly RegExp[]) => patterns.some((pattern) => pattern.test(relativeName));
.repos/alchemy-effect/packages/prisma/src/ComputeArchive.ts at main · sailfork/t3code-github · Sailfork
),\n ]\n : []),\n ...ALWAYS_IGNORED_PATTERNS.map((pattern) => compileIgnorePattern(pattern)),\n ...ignore.map((pattern) => compileIgnorePattern(pattern, ignorePrefix)),\n ],\n maxUncompressedBytes: boundedLimit(\n \"maxUncompressedBytes\",\n maxUncompressedBytes,\n MAX_UNCOMPRESSED_BYTES,\n ),\n maxFileBytes: boundedLimit(\"maxFileBytes\", maxFileBytes, MAX_FILE_BYTES),\n maxEntries: boundedLimit(\"maxEntries\", maxEntries, MAX_ENTRIES),\n }),\n catch: (error) =>\n new ComputeArchiveOptionsError({\n message: error instanceof Error ? error.message : String(error),\n cause: error,\n }),\n });\n const budget: ArchiveBudget = {\n ...validated,\n bytes: 0,\n entries: 0,\n };\n if (budget.maxFileBytes > budget.maxUncompressedBytes) {\n return yield* new ComputeArchiveInvalidProps({\n message: \"maxFileBytes must not exceed maxUncompressedBytes\",\n });\n }\n if (isIgnored(normalizedEntrypoint, budget.ignore)) {\n return yield* new ComputeArchiveInvalidProps({\n message: `Entrypoint is excluded from the compute artifact: ${normalizedEntrypoint}`,\n });\n }\n const resolvedEntrypoint = yield* resolvePathWithinRoot(\n realRoot,\n path.join(realRoot, normalizedEntrypoint),\n );\n const entrypointStat = yield* fs.stat(resolvedEntrypoint);\n if (entrypointStat.type !== \"File\") {\n return yield* new ComputeArchiveInvalidProps({\n message: `Entrypoint must be a file in compute artifact: ${normalizedEntrypoint}`,\n });\n }\n\n const entries: ArchiveTarEntry[] = [];\n yield* addDirectoryEntries(entries, realRoot, realRoot, \"bundle\", \"\", budget);\n const entrypointArchiveName = `bundle/${normalizedEntrypoint}`;\n if (!isArchivedRegularFile(entries, entrypointArchiveName)) {\n return yield* new ComputeArchiveOperationFailed({\n message: `Entrypoint not found in compute artifact: ${normalizedEntrypoint}`,\n });\n }\n\n for (const file of requiredFiles) {\n const normalized = yield* normalizeEntrypoint(file);\n if (!isArchivedRegularFile(entries, `bundle/${normalized}`)) {\n return yield* new ComputeArchiveOperationFailed({\n message: `Required file not found in compute artifact: ${normalized}`,\n });\n }\n }\n\n const manifest = new TextEncoder().encode(\n JSON.stringify(\n {\n manifestVersion: COMPUTE_MANIFEST_VERSION,\n entrypoint: entrypointArchiveName,\n },\n null,\n 2,\n ),\n );\n const archivePath = yield* fs.makeTempFile({\n prefix: \"alchemy-prisma-compute-\",\n suffix: \".tar.gz\",\n });\n const cleanup = fs.remove(archivePath, { force: true }).pipe(Effect.ignore);\n\n yield* writeCompressedArchiveSecure(archivePath, entries, manifest, MAX_COMPRESSED_BYTES).pipe(\n Effect.tapError(() => cleanup),\n );\n return yield* inspectArtifactFile(archivePath, MAX_COMPRESSED_BYTES, {\n cleanup,\n description: \"Prisma compute archive\",\n }).pipe(Effect.tapError(() => cleanup));\n});\n\nconst addDirectoryEntries: (\n entries: ArchiveTarEntry[],\n realRoot: string,\n directory: string,\n tarPrefix: string,\n relativePrefix: string,\n budget: ArchiveBudget,\n) => Effect.Effect\u003cvoid, ArchiveError, ArchiveRequirements> = Effect.fn(\n function* (entries, realRoot, directory, tarPrefix, relativePrefix, budget) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directoryResult = yield* readDirectoryEntriesSecure({\n directory,\n relativePrefix,\n ignore: budget.ignore,\n entriesAlreadyObserved: budget.entries,\n maxEntries: budget.maxEntries,\n });\n budget.entries += directoryResult.observedEntries;\n\n for (const entry of directoryResult.entries) {\n const name = entry.name;\n const relativeName = relativePrefix ? `${relativePrefix}/${name}` : name;\n\n const filePath = path.join(directory, name);\n const tarName = `${tarPrefix}/${name}`;\n if (entry.type === \"SymbolicLink\") {\n const symlinkTarget = yield* fs.readLink(filePath);\n const linkname = yield* resolveArchiveSymlinkTarget(realRoot, filePath, symlinkTarget);\n entries.push({\n name: tarName,\n mode: 0o777,\n type: \"symlink\",\n linkname,\n });\n continue;\n }\n\n if (entry.type === \"Directory\") {\n const realDirectory = yield* resolvePathWithinRoot(realRoot, filePath);\n yield* addDirectoryEntries(entries, realRoot, realDirectory, tarName, relativeName, budget);\n continue;\n }\n\n if (entry.type !== \"File\") {\n return yield* new ComputeArchiveOperationFailed({\n message: `Unsupported filesystem entry in compute artifact: ${relativeName}`,\n });\n }\n\n const verified = yield* inspectVerifiedFile(filePath, budget.maxFileBytes, {\n allowEmpty: true,\n description: `Compute artifact file '${relativeName}'`,\n });\n yield* ensureResolvedPathWithinRoot(realRoot, verified.path);\n if (budget.bytes + verified.size > budget.maxUncompressedBytes) {\n return yield* new ComputeArchiveOperationFailed({\n message: `Compute artifact exceeds the ${budget.maxUncompressedBytes} byte uncompressed safety limit. Narrow the artifact directory or add ignore patterns.`,\n });\n }\n budget.bytes += verified.size;\n entries.push({\n name: tarName,\n mode: verified.mode & 0o777,\n type: \"file\",\n file: verified,\n });\n }\n },\n);\n\nexport const normalizeEntrypoint = (entrypoint: string) =>\n Effect.gen(function* () {\n const normalized = entrypoint.replaceAll(\"\\\\\", \"/\");\n if (normalized.trim().length === 0) {\n return yield* new ComputeArchiveInvalidProps({ message: \"entrypoint must be non-empty\" });\n }\n if (normalized.startsWith(\"/\") || /^[a-zA-Z]:\\//.test(normalized)) {\n return yield* new ComputeArchiveInvalidProps({ message: \"entrypoint must be relative\" });\n }\n const parts = normalized.split(\"/\").filter((part) => part !== \".\");\n if (parts.some((part) => part === \"..\" || part.length === 0)) {\n return yield* new ComputeArchiveInvalidProps({\n message: \"entrypoint must not contain empty or parent segments\",\n });\n }\n return parts.join(\"/\");\n });\n\nconst resolvePathWithinRoot = Effect.fn(function* (realRoot: string, candidate: string) {\n const fs = yield* FileSystem.FileSystem;\n const realCandidate = yield* fs.realPath(candidate);\n yield* ensureResolvedPathWithinRoot(realRoot, realCandidate);\n return realCandidate;\n});\n\nconst ensureResolvedPathWithinRoot = Effect.fn(function* (\n realRoot: string,\n resolvedCandidate: string,\n) {\n const path = yield* Path.Path;\n const relative = path.relative(realRoot, resolvedCandidate);\n if (relative === \"..\" || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {\n return yield* new ComputeArchiveOperationFailed({\n message: `Archive path escapes compute artifact root: ${resolvedCandidate}`,\n });\n }\n});\n\nconst resolveArchiveSymlinkTarget = Effect.fn(function* (\n realRoot: string,\n symlinkPath: string,\n target: string,\n) {\n const path = yield* Path.Path;\n if (path.sep === \"/\" && target.includes(\"\\\\\")) {\n return yield* new ComputeArchiveOperationFailed({\n message: `Archive symlink target contains an unsupported backslash: ${target}`,\n });\n }\n const symlinkDir = path.dirname(symlinkPath);\n const targetPath = path.isAbsolute(target) ? target : path.resolve(symlinkDir, target);\n const realTarget = yield* resolvePathWithinRoot(realRoot, targetPath);\n\n if (!path.isAbsolute(target)) return target.replaceAll(\"\\\\\", \"/\");\n const realSymlinkDir = yield* resolvePathWithinRoot(realRoot, symlinkDir);\n const relative = path.relative(realSymlinkDir, realTarget);\n return (relative.length === 0 ? \".\" : relative).replaceAll(\"\\\\\", \"/\");\n});\n\nconst boundedLimit = (name: string, value: number, hardLimit: number) => {\n if (!Number.isSafeInteger(value) || value \u003c= 0) {\n throw new Error(`${name} must be a positive safe integer`);\n }\n if (value > hardLimit) {\n throw new Error(`${name} must not exceed the hard limit of ${hardLimit}`);\n }\n return value;\n};\n\nconst compileIgnorePattern = (input: string, prefix?: string) => {\n const normalized = input.replaceAll(\"\\\\\", \"/\").replace(/^\\.\\//, \"\");\n if (\n normalized.length === 0 ||\n normalized.startsWith(\"!\") ||\n normalized.startsWith(\"/\") ||\n /^[a-zA-Z]:\\//.test(normalized) ||\n normalized.split(\"/\").some((segment) => segment === \"..\")\n ) {\n throw new Error(`Invalid compute archive ignore pattern: ${input}`);\n }\n const scoped = prefix === undefined ? normalized : `${prefix}/${normalized}`;\n const escaped = scoped\n .replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\

Loading Sailfork

\")\n .replaceAll(\"**\", \"\\0\")\n .replaceAll(\"*\", \"[^/]*\")\n .replaceAll(\"\\0\", \".*\");\n return new RegExp(`^${escaped}(?:/.*)? .repos/alchemy-effect/packages/prisma/src/ComputeArchive.ts at main · sailfork/t3code-github · Sailfork
);\n};\n\nconst isIgnored = (relativeName: string, patterns: readonly RegExp[]) =>\n patterns.some((pattern) => pattern.test(relativeName));\n","preview":null,"history":null,"version":"55f75ef561e354c9a838a7a5560aab9467fe2472"},"/_session?shell=1":null}