import { BuildDataFormats, BuildResourceProtocolCategories, BuildResourceProtocols } from '../config'; export type JsonPrimitive = string | number | boolean | null; export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue; }; /** Final parsed/built GCScript representation. */ export type GCScript = JsonValue; export type JsonObject = { [key: string]: JsonValue; }; export type SchemaDefinitionLookupResult = { /** Lookup key requested by the caller, for example "buildTx" or "buildTx.json". */ key: string; /** Schema file that contains the fragment, for example "buildTx.json". */ schemaFile: string; /** JSON pointer to the returned fragment inside the schema bundle. */ schemaPath: string; /** Full deserialized schema bundle originally passed by the caller. */ schema: JsonValue; /** Matching schema fragment, or definition fragment, from the bundle. */ fragment: JsonValue; }; /** * Looks up a schema file or local JSON Schema definition by name. * * Full schema flavors usually expose one file per GCScript function * (`buildTx.json`, `data.json`, etc.). Minified schema flavors may omit rich * documentation or local definitions, so the helper returns undefined when a * fragment is unavailable instead of throwing. */ export declare const getSchemaDefOf: (useSchema: JsonValue | undefined, definitionKey: string) => SchemaDefinitionLookupResult | undefined; export type BuildDataFormat = (typeof BuildDataFormats)[number]; export type BuildResourceProtocol = (typeof BuildResourceProtocols)[number]; export type BuildResourceProtocolCategory = keyof typeof BuildResourceProtocolCategories; export type VirtualFile = { /** Runtime value is a Buffer; Uint8Array keeps declarations portable. */ data: Uint8Array; mimeType?: string; }; export type VirtualFileSystem = { [relativeFilePath: string]: VirtualFile; }; export type BuildEvent = { type: string; message?: string; stage?: string; fileUri?: string; protocol?: string; path?: string; directive?: string; data?: Record; }; export type GCScriptProcessContext = { fileUri: string; options: { onEvent?: BuildEventHandler; }; importTrace?: string[]; state?: Record; }; export type BuildEventHandler = (event: BuildEvent, context: Readonly) => void | Promise; export type BuildProtocolHandler = (resourceUri: string, args: BuildResourceArgs) => Promise; export type BuildProtocolHandlers = { [protocol: string]: BuildProtocolHandler | undefined; }; export type BuildSecurityContext = { /** Mutable remote ancestor that taints this dependency branch, if any. */ mutableAncestorUri?: string; }; export type BuildOptions = { /** Raw GCScript JSON/JSONC text. build() never loads this from fileUri. */ input: string; /** * URI used only as the parent identity for resolving relative imports. * * When omitted, DefaultMainFileAppURI is used as a synthetic parent URI for * app:// virtual-file projects. The build handler must not read or write this * default URI because callers may not have such a file in their VFS or local * filesystem. */ fileUri?: string; /** Absolute filesystem/virtual root used as the app:// root for build-time resolution. */ appWorkingDir?: string; files?: VirtualFileSystem; allowedProtocols?: string[]; /** Optional exact/wildcard hostname whitelist for http(s) resources. */ allowedRemoteDomains?: string[]; protocolHandlers?: BuildProtocolHandlers; directiveHandlers?: BuildDirectiveHandlers; stages?: BuildStage[]; importTrace?: string[]; security?: BuildSecurityContext; /** JSON schema object returned by the GCScript schema endpoint. Required when validation runs. */ useSchema?: JsonValue; /** Schema URL used by helper downloaders. Callers can override the production default. */ schemaUrl?: string; /** Root schema filename inside useSchema. Defaults to the production API schema root. */ schemaRootFile?: string; /** Validate final built strict JSON output. Enabled by default. */ doValidate?: boolean; /** Emit strict/minified JSON when serializing buildToDataURI output. */ compactOutput?: boolean; /** Internal/CLI flag: collect resource stats only when a caller will display them. */ collectSummary?: boolean; onEvent?: BuildEventHandler; }; export type BuildContext = { input: string; fileUri: string; explicitFileUri: boolean; appWorkingDir: string; files: VirtualFileSystem; allowedProtocols: string[]; allowedRemoteDomains?: string[]; protocolHandlers: BuildProtocolHandlers; directiveHandlers: BuildDirectiveHandlers; importTrace: string[]; security: BuildSecurityContext; options: BuildOptions; state: Record; }; export type BuildStageArgs = BuildOptions & { context: BuildContext; previousResult: GCScript; }; export type BuildStage = (args: BuildStageArgs) => Promise; export type BuildDirectiveArgs = { node: GCScript; key: string; index: number; path: string[]; context: BuildContext; }; export type BuildDirectiveHandler = (args: BuildDirectiveArgs) => Promise; export type BuildDirectiveHandlers = { [type: string]: BuildDirectiveHandler | undefined; }; export type BuildResourceArgs = Partial> & { context?: BuildContext; baseUri?: string; explicitBaseUri?: boolean; }; export declare const emitBuildEvent: (context: GCScriptProcessContext, event: Omit & { fileUri?: string; }) => Promise; export declare const isArray: (maybeArray: unknown) => maybeArray is unknown[]; export declare const toKVList: (maybeArray: any, options?: { sort?: boolean; }) => [string, any][]; export declare const kvList2Array: (kvMap: [string, any][]) => any[]; export declare const kvList2Object: (kvMap: [string, any][]) => { [k: string]: any; }; export declare const gcScriptWalker: ({ code, onNode, context }: { code: GCScript; onNode: (args: BuildDirectiveArgs) => Promise; context: BuildContext; }) => Promise; export declare const getResourceProtocol: (resourceUri: string) => string; export declare const getBuildResourceProtocolCategory: (protocol: string) => BuildResourceProtocolCategory; export declare const assertResourceHasProtocol: (resourceUri: string, context?: BuildContext, path?: string[]) => void; export declare const assertBuildFileUri: (fileUri: string) => string; export declare const parseBuildResourceUri: (resourceUri: string) => { protocol: string; path: string; isAbsolute: boolean; }; export declare const appUriToProjectPath: (resourceUri: string) => string; export declare const fileUriToFilesystemPath: (resourceUri: string) => string; export declare const resolveBuildResourceUri: (resourceUri: string, context: BuildContext, path?: string[]) => string; export declare const resourceUriToRelativePath: (resourceUri: string) => string; export declare const resolveResourceUri: (resourceUri: string, baseUri?: string) => string; declare const createBuildError: ({ type, importTrace, path, message, data }: { type: string; importTrace?: string[]; path?: string[]; message: string; data?: Record; }) => Error & { type?: string; importTrace?: string[]; path?: string; data?: Record; }; export declare const defaultBuildProtocolHandlers: BuildProtocolHandlers; export declare const getResource: (fileUri: string, options: BuildResourceArgs) => Promise>; /** * Parses build-only JSONC into strict GCScript JSON. * * Supported compatibility extensions are intentionally narrow: comments and * trailing commas only. The returned value is a normal JS JSON value and all * comments/trailing commas disappear from the final wallet-facing output. */ export declare function parseGCScriptJSONC(input: string): GCScript; export type { JsonLocation, ValidationErrorReport, ValidationProfiling, ValidationReport, ValidateOptions, ValidateContext, SchemaValueIndex, SchemaPropertyIndex, SchemaISLFunctionIndex } from './validate/helpers'; export { createSchemaISLFunctionIndex, createSchemaPropertyIndex, createSchemaValueIndex, docs as validationDocs, downloadGCScriptSchema, getJsonPathLocation, getAtJsonPath, jsonPointerToPathParts, normalizeAdditionalPropertyError, normalizeConstEnumError, normalizeFallbackAjvError, normalizeOneOfAnyOfError, normalizeRequiredPropertyError, normalizeRootKnownFunctionError, normalizeStrictJsonSyntaxError, normalizeTypeMismatchError, normalizers, parseGCScriptJSON, pathPartsToJsonPointer, validate, validateGCScriptObject, validateToDataURI } from './validate/helpers'; export declare const getBufferAs: (fileBuff: Uint8Array | ArrayBuffer, as: BuildDataFormat) => Promise; export declare const path2Str: (path: string[]) => string; export { createBuildError }; export declare const defaultBuildDirectiveHandlers: BuildDirectiveHandlers; export declare const resolveBuildDirectivesStage: BuildStage; /** Validates the resolved build output, after build directives have been expanded. */ export declare const validateBuildOutputStage: BuildStage; export declare const defaultBuildStages: BuildStage[]; export declare const build: (options: BuildOptions) => Promise; export declare const buildToDataURI: (input: string, options?: Omit) => Promise;