@thomasfosterau/effect-sparql-node 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -1
  3. package/bin/effect-sparql-server.mjs +26 -0
  4. package/dist/Cli-DE0eXMJr.d.mts +143 -0
  5. package/dist/Cli-DFvng1N8.mjs +259 -0
  6. package/dist/Cli-DFvng1N8.mjs.map +1 -0
  7. package/dist/Cli.d.mts +2 -0
  8. package/dist/Cli.mjs +1 -0
  9. package/dist/NodeSparqlServer-1vSrPk3J.d.mts +41 -0
  10. package/dist/NodeSparqlServer-CYAd_6BG.mjs +50 -0
  11. package/dist/NodeSparqlServer-CYAd_6BG.mjs.map +1 -0
  12. package/dist/NodeSparqlServer.d.mts +2 -0
  13. package/dist/NodeSparqlServer.mjs +1 -0
  14. package/dist/SparqlApi-BKE9nIf4.d.mts +488 -0
  15. package/dist/SparqlApi-BuycDkWu.mjs +371 -0
  16. package/dist/SparqlApi-BuycDkWu.mjs.map +1 -0
  17. package/dist/SparqlApi.d.mts +2 -0
  18. package/dist/SparqlApi.mjs +1 -0
  19. package/dist/SparqlApiBuilder-BAMpMy-Z.d.mts +83 -0
  20. package/dist/SparqlApiBuilder-GT7EopBq.mjs +136 -0
  21. package/dist/SparqlApiBuilder-GT7EopBq.mjs.map +1 -0
  22. package/dist/SparqlApiBuilder.d.mts +2 -0
  23. package/dist/SparqlApiBuilder.mjs +1 -0
  24. package/dist/SparqlApiClient-C82RGMEF.d.mts +386 -0
  25. package/dist/SparqlApiClient-CJcoFy5b.mjs +203 -0
  26. package/dist/SparqlApiClient-CJcoFy5b.mjs.map +1 -0
  27. package/dist/SparqlApiClient.d.mts +2 -0
  28. package/dist/SparqlApiClient.mjs +1 -0
  29. package/dist/index.d.mts +6 -0
  30. package/dist/index.mjs +6 -0
  31. package/dist/rolldown-runtime-D8jQpDG7.mjs +12 -0
  32. package/package.json +59 -3
  33. package/src/Cli.ts +373 -0
  34. package/src/NodeSparqlServer.ts +71 -0
  35. package/src/SparqlApi.ts +506 -0
  36. package/src/SparqlApiBuilder.ts +196 -0
  37. package/src/SparqlApiClient.ts +383 -0
  38. package/src/index.ts +20 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cli-DFvng1N8.mjs","names":["NodeSparqlServer.layerMemory"],"sources":["../src/Cli.ts"],"sourcesContent":["/**\n * The command line entry point: serves RDF files loaded into an in-memory\n * store.\n *\n * ```sh\n * effect-sparql-server --port 3030 data.ttl more.trig\n * ```\n *\n * Files are parsed with the default formats, chosen by file extension.\n * Triples go to the default graph, or with `--graph-per-file` to a named\n * graph per file (named by the file URL); quads keep their graph.\n *\n * The command is built with `effect/cli` (generated `--help`, `--version`\n * and shell completions), and every flag also reads an environment variable\n * through `Config`: `SPARQL_SERVER_` followed by the flag name in upper\n * snake case (`--max-results` is `SPARQL_SERVER_MAX_RESULTS`). A flag on the\n * command line wins over the environment, which wins over the default.\n *\n * @since 0.1.0\n */\nimport * as NodeServices from '@effect/platform-node/NodeServices';\nimport * as NodeFileSystem from '@effect/platform-node/NodeFileSystem';\nimport * as NodePath from '@effect/platform-node/NodePath';\nimport * as Config from 'effect/Config';\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Layer from 'effect/Layer';\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Path from 'effect/Path';\nimport * as PlatformError from 'effect/PlatformError';\nimport * as Ref from 'effect/Ref';\nimport * as Schema from 'effect/Schema';\nimport { Argument, Command, Flag } from 'effect/cli';\nimport * as CliErrors from 'effect/cli/CliError';\nimport type * as HttpServerError from 'effect/http/HttpServerError';\nimport * as Iri from '@thomasfosterau/effect-rdf/Iri';\nimport * as Dataset from '@thomasfosterau/effect-rdf/Dataset';\nimport * as Serialization from '@thomasfosterau/effect-rdf/Serialization';\nimport * as Term from '@thomasfosterau/effect-rdf/Term';\nimport * as ServerFormats from '@thomasfosterau/effect-rdf/sparql/ServerFormats';\nimport type * as Options from '@thomasfosterau/effect-rdf/sparql/Options';\nimport * as NodeSparqlServer from './NodeSparqlServer.ts';\n\n/**\n * A command line usage error.\n *\n * @since 0.1.0\n * @category errors\n */\nexport class CliError extends Schema.TaggedError<CliError>()('CliError', {\n message: Schema.String,\n}) {}\n\n/**\n * The prefix of the environment variables that back the flags:\n * `SPARQL_SERVER_PORT`, `SPARQL_SERVER_READ_ONLY`, …\n *\n * @since 0.1.0\n * @category cli\n */\nexport const envPrefix = 'SPARQL_SERVER_';\n\nconst envName = (flag: string): string => `${envPrefix}${flag.toUpperCase().replaceAll('-', '_')}`;\n\n/**\n * A summary of the flags and their environment variables; `--help` prints\n * the full, generated help.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const usage = `Usage: effect-sparql-server [flags] [files...]\n\nServes the given RDF files from an in-memory store over the SPARQL 1.1\nProtocol and the Graph Store HTTP Protocol.\n\nFlags (environment variable in brackets; a flag wins over the environment):\n -p, --port <port> port to listen on (default 3030) [SPARQL_SERVER_PORT]\n --host <host> host to bind (default all interfaces) [SPARQL_SERVER_HOST]\n --path <path> SPARQL endpoint path (default /sparql) [SPARQL_SERVER_PATH]\n --update-path <path> separate update endpoint path [SPARQL_SERVER_UPDATE_PATH]\n --graph-store <path> Graph Store Protocol path (default /rdf-graph-store) [SPARQL_SERVER_GRAPH_STORE]\n --no-graph-store disable the Graph Store Protocol [SPARQL_SERVER_NO_GRAPH_STORE]\n --read-only reject updates and graph store writes [SPARQL_SERVER_READ_ONLY]\n --timeout <ms> query timeout in milliseconds [SPARQL_SERVER_TIMEOUT]\n --max-results <n> maximum number of results per query [SPARQL_SERVER_MAX_RESULTS]\n --cors enable permissive CORS [SPARQL_SERVER_CORS]\n --union-default-graph query the union of all graphs by default [SPARQL_SERVER_UNION_DEFAULT_GRAPH]\n --graph-per-file load each file into a named graph (its file URL) [SPARQL_SERVER_GRAPH_PER_FILE]\n --base-url <url> public origin of the server [SPARQL_SERVER_BASE_URL]\n -h, --help show the full help\n`;\n\n/**\n * Parsed command line arguments.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface Arguments {\n readonly help: boolean;\n readonly files: ReadonlyArray<string>;\n readonly graphPerFile: boolean;\n readonly unionDefaultGraph: boolean;\n readonly serve: NodeSparqlServer.ServeOptions;\n}\n\n// A string flag, falling back to its environment variable, absent when neither is set.\nconst stringFlag = (name: string, description: string) =>\n Flag.String(name).pipe(\n Flag.withDescription(`${description} [${envName(name)}]`),\n Flag.withFallbackConfig(Config.String(envName(name))),\n Flag.optional,\n );\n\n// An integer flag, falling back to its environment variable.\nconst intFlag = (name: string, description: string) =>\n Flag.Int(name).pipe(\n Flag.withDescription(`${description} [${envName(name)}]`),\n Flag.withFallbackConfig(Config.Int(envName(name))),\n Flag.optional,\n );\n\n// A boolean flag, falling back to its environment variable, then to false.\nconst booleanFlag = (name: string, description: string) =>\n Flag.Boolean(name).pipe(\n Flag.withDescription(`${description} [${envName(name)}]`),\n Flag.withFallbackConfig(Config.Boolean(envName(name))),\n Flag.withDefault(false),\n );\n\n/**\n * The command's flags and arguments.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const config = {\n port: intFlag('port', 'port to listen on (default 3030)').pipe(Flag.withAlias('p')),\n host: stringFlag('host', 'host to bind (default all interfaces)'),\n path: stringFlag('path', 'SPARQL endpoint path (default /sparql)'),\n updatePath: stringFlag('update-path', 'separate update endpoint path'),\n graphStore: stringFlag('graph-store', 'Graph Store Protocol path (default /rdf-graph-store)'),\n noGraphStore: booleanFlag('no-graph-store', 'disable the Graph Store Protocol'),\n readOnly: booleanFlag('read-only', 'reject updates and graph store writes'),\n timeout: intFlag('timeout', 'query timeout in milliseconds'),\n maxResults: intFlag('max-results', 'maximum number of results per query'),\n cors: booleanFlag('cors', 'enable permissive CORS'),\n unionDefaultGraph: booleanFlag('union-default-graph', 'query the union of all graphs by default'),\n graphPerFile: booleanFlag('graph-per-file', 'load each file into a named graph (its file URL)'),\n baseUrl: stringFlag('base-url', 'public origin of the server'),\n files: Argument.String('files').pipe(\n Argument.withDescription('RDF files to load, in any syntax the server reads'),\n Argument.variadic(),\n ),\n} as const;\n\n/**\n * The values of the flags and arguments, as `effect/cli` parses them.\n *\n * @since 0.1.0\n * @category models\n */\nexport type Flags = Command.Command.Config.Infer<typeof config>;\n\nconst nonNegative = (name: string, value: Option.Option<number>) =>\n Option.match(value, {\n onNone: () => Effect.succeed(undefined),\n onSome: (n) =>\n Number.isInteger(n) && n >= 0\n ? Effect.succeed(n)\n : Effect.fail(new CliError({ message: `--${name} expects a non-negative integer` })),\n });\n\nconst endpointPath = (name: string, value: Option.Option<string>) =>\n Option.match(value, {\n onNone: () => Effect.succeed(undefined),\n onSome: (path) =>\n Schema.is(EndpointPath)(path)\n ? Effect.succeed(path)\n : Effect.fail(new CliError({ message: `--${name} must start with '/'` })),\n });\n\nconst EndpointPath = Schema.TemplateLiteral(['/', Schema.String]);\n\n/**\n * Validates parsed flags into `Arguments`: integers must be non-negative,\n * paths must start with `/`, and `--base-url` must be an absolute IRI.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const toArguments = (flags: Flags): Effect.Effect<Arguments, CliError> =>\n Effect.gen(function* () {\n const baseUrl = Option.getOrUndefined(flags.baseUrl);\n if (baseUrl !== undefined && !Iri.isValid(baseUrl)) {\n return yield* new CliError({ message: `--base-url must be an absolute IRI: ${baseUrl}` });\n }\n const graphStore = yield* endpointPath('graph-store', flags.graphStore);\n const options: Options.Options = {\n path: yield* endpointPath('path', flags.path),\n updatePath: yield* endpointPath('update-path', flags.updatePath),\n graphStorePath: flags.noGraphStore ? false : graphStore,\n readOnly: flags.readOnly,\n queryTimeout: yield* nonNegative('timeout', flags.timeout),\n maxResults: yield* nonNegative('max-results', flags.maxResults),\n cors: flags.cors,\n logging: true,\n baseUrl,\n unionDefaultGraph: flags.unionDefaultGraph,\n };\n return {\n help: false,\n files: flags.files,\n graphPerFile: flags.graphPerFile,\n unionDefaultGraph: flags.unionDefaultGraph,\n serve: {\n ...options,\n port: (yield* nonNegative('port', flags.port)) ?? 3030,\n host: Option.getOrUndefined(flags.host),\n },\n };\n });\n\n// The `effect/cli` errors as this module's `CliError` (a help request has no message).\nconst fromCliError = (error: CliErrors.CliError): CliError =>\n new CliError({\n message: Match.value(error).pipe(\n Match.tag('ShowHelp', (help) => help.errors.map((e) => e.message).join('\\n')),\n Match.orElse((e) => e.message),\n ),\n });\n\nconst quiet = (): void => undefined;\nconst silentConsole: Console.Console = Object.assign(Object.create(globalThis.console), {\n log: quiet,\n error: quiet,\n info: quiet,\n warn: quiet,\n});\n\nconst isHelp = (argv: ReadonlyArray<string>): boolean =>\n argv.includes('--help') || argv.includes('-h');\n\n/**\n * Parses command line arguments, reading unset flags from the environment\n * (`SPARQL_SERVER_*`). `-h` / `--help` sets `help` instead.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const parse = (argv: ReadonlyArray<string>): Effect.Effect<Arguments, CliError> =>\n isHelp(argv)\n ? Effect.succeed({\n help: true,\n files: [],\n graphPerFile: false,\n unionDefaultGraph: false,\n serve: { port: 3030 },\n })\n : Effect.gen(function* () {\n const parsed = yield* Ref.make(Option.none<Arguments>());\n const capture = Command.make('effect-sparql-server', config, (flags) =>\n Effect.flatMap(toArguments(flags), (args) => Ref.set(parsed, Option.some(args))),\n );\n yield* Command.runWith(capture, { version: '', renderErrors: false })(argv).pipe(\n Effect.catchIf(CliErrors.isCliError, (e) => Effect.fail(fromCliError(e))),\n // Parsing is programmatic: the help `effect/cli` prints for a usage error stays quiet.\n Effect.provideService(Console.Console, silentConsole),\n Effect.provide(NodeServices.layer),\n );\n return yield* Effect.flatMap(Ref.get(parsed), Effect.fromOption).pipe(\n Effect.mapError(() => new CliError({ message: 'no arguments were parsed' })),\n );\n });\n\n/**\n * Loads RDF files into a dataset through Effect's `FileSystem`, choosing\n * parsers by file extension from the `Formats` service. Relative IRIs\n * resolve against each file's `file:` URL; with `graphPerFile`, a file's\n * default-graph triples go into a graph named by that URL.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const load = (\n files: ReadonlyArray<string>,\n graphPerFile: boolean,\n): Effect.Effect<\n Dataset.Dataset,\n CliError | Serialization.RdfParseError,\n Serialization.Formats | FileSystem.FileSystem | Path.Path\n> =>\n Effect.gen(function* () {\n const formats = yield* Serialization.Formats;\n const paths = yield* Path.Path;\n const perFile = yield* Effect.forEach(\n files,\n Effect.fnUntraced(function* (file) {\n const parser = Serialization.parserForExtension(formats, paths.extname(file));\n if (Option.isNone(parser)) {\n return yield* new CliError({ message: `Unknown RDF file extension: ${file}` });\n }\n const cannotRead = (e: PlatformError.PlatformError) =>\n new CliError({ message: `Cannot read ${file}: ${e.message}` });\n const url = (yield* paths\n .toFileUrl(paths.resolve(file))\n .pipe(Effect.mapError((e) => cannotRead(new PlatformError.PlatformError(e))))).href;\n const result = yield* Serialization.readFile(file, {\n parser: parser.value,\n baseIri: url,\n }).pipe(Effect.catchTag('PlatformError', (e) => Effect.fail(cannotRead(e))));\n const graph = graphPerFile ? Term.namedNode(url) : undefined;\n const quads = Array.from(result.dataset, (q) =>\n graph !== undefined && q.graph._tag === 'DefaultGraph'\n ? new Term.Quad(q.subject, q.predicate, q.object, graph)\n : q,\n );\n yield* Effect.logInfo(`Loaded ${result.dataset.size} quads from ${file}`);\n return quads;\n }),\n { concurrency: 1 },\n );\n return Dataset.fromIterable(perFile.flat());\n });\n\n/**\n * The `effect/cli` command: parses the flags (and their environment\n * variables), loads the files and serves them until interrupted.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const command = Command.make('effect-sparql-server', config, (flags) =>\n Effect.gen(function* () {\n const args = yield* toArguments(flags);\n const data = yield* Effect.provide(\n load(args.files, args.graphPerFile),\n Layer.mergeAll(ServerFormats.layer, NodeFileSystem.layer, NodePath.layer),\n );\n const server = NodeSparqlServer.layerMemory({\n ...args.serve,\n data,\n engine: { unionDefaultGraph: args.unionDefaultGraph },\n });\n return yield* Layer.launch(server);\n }),\n).pipe(\n Command.withDescription(\n 'Serves the given RDF files from an in-memory store over the SPARQL 1.1 Protocol and the Graph Store HTTP Protocol.',\n ),\n);\n\n/**\n * Runs the command line program: parses arguments (printing the generated\n * help for `--help` or a usage error), loads the files and serves them\n * until interrupted. `version` is what `--version` prints.\n *\n * @since 0.1.0\n * @category cli\n */\nexport const run = (\n argv: ReadonlyArray<string>,\n options?: { readonly version?: string | undefined },\n): Effect.Effect<void, CliError | Serialization.RdfParseError | HttpServerError.ServeError> =>\n Command.runWith(command, { version: options?.version ?? 'unknown', renderErrors: false })(\n argv,\n ).pipe(\n Effect.catchIf(CliErrors.isCliError, (e) => Effect.fail(fromCliError(e))),\n Effect.provide(NodeServices.layer),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,WAAb,cAA8B,OAAO,YAAsB,CAAC,CAAC,YAAY,EACvE,SAAS,OAAO,OAClB,CAAC,CAAC,CAAC,CAAC;;;;;;;;AASJ,MAAa,YAAY;AAEzB,MAAM,WAAW,SAAyB,GAAG,YAAY,KAAK,YAAY,CAAC,CAAC,WAAW,KAAK,GAAG;;;;;;;;AAS/F,MAAa,QAAQ;;;;;;;;;;;;;;;;;;;;;AAqCrB,MAAM,cAAc,MAAc,gBAChC,KAAK,OAAO,IAAI,CAAC,CAAC,KAChB,KAAK,gBAAgB,GAAG,YAAY,IAAI,QAAQ,IAAI,EAAE,EAAE,GACxD,KAAK,mBAAmB,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,GACpD,KAAK,QACP;AAGF,MAAM,WAAW,MAAc,gBAC7B,KAAK,IAAI,IAAI,CAAC,CAAC,KACb,KAAK,gBAAgB,GAAG,YAAY,IAAI,QAAQ,IAAI,EAAE,EAAE,GACxD,KAAK,mBAAmB,OAAO,IAAI,QAAQ,IAAI,CAAC,CAAC,GACjD,KAAK,QACP;AA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,CAAC,CACH,CAAC,CAAC,KACA,QAAQ,gBACN,oHACF,CACF;;;;;;;;;AAUA,MAAa,OACX,MACA,YAEA,QAAQ,QAAQ,SAAS;CAAE,SAAS,SAAS,WAAW;CAAW,cAAc;AAAM,CAAC,CAAC,CACvF,IACF,CAAC,CAAC,KACA,OAAO,QAAQ,UAAU,aAAa,MAAM,OAAO,KAAK,aAAa,CAAC,CAAC,CAAC,GACxE,OAAO,QAAQ,aAAa,KAAK,CACnC"}
package/dist/Cli.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { a as command, c as load, d as toArguments, f as usage, i as Flags, l as parse, n as CliError, o as config, s as envPrefix, t as Arguments, u as run } from "./Cli-DE0eXMJr.mjs";
2
+ export { Arguments, CliError, Flags, command, config, envPrefix, load, parse, run, toArguments, usage };
package/dist/Cli.mjs ADDED
@@ -0,0 +1 @@
1
+ export { t as CliError, r as command, i as config, a as envPrefix, o as load, s as parse, c as run, l as toArguments, u as usage } from "./Cli-DFvng1N8.mjs";
@@ -0,0 +1,41 @@
1
+ import * as Layer from "effect/Layer";
2
+ import * as Dataset from "@thomasfosterau/effect-rdf/Dataset";
3
+ import * as SparqlServer from "@thomasfosterau/effect-rdf/sparql/SparqlServer";
4
+ import * as HttpServer from "effect/http/HttpServer";
5
+ import * as HttpServerError from "effect/http/HttpServerError";
6
+ import * as Engine from "@thomasfosterau/effect-rdf/sparql/Engine";
7
+ import * as Options from "@thomasfosterau/effect-rdf/sparql/Options";
8
+ declare namespace NodeSparqlServer_d_exports {
9
+ export { ServeOptions, layer, layerMemory };
10
+ }
11
+ /**
12
+ * Options of the Node server.
13
+ *
14
+ * @since 0.1.0
15
+ * @category models
16
+ */
17
+ interface ServeOptions extends Options.Options {
18
+ /** The port to listen on (`0` for an ephemeral port). */
19
+ readonly port: number;
20
+ /** The host to bind (default: all interfaces). */
21
+ readonly host?: string | undefined;
22
+ }
23
+ /**
24
+ * A Node HTTP server serving the SPARQL endpoint and graph store.
25
+ *
26
+ * @since 0.1.0
27
+ * @category layers
28
+ */
29
+ declare const layer: (options: ServeOptions) => Layer.Layer<HttpServer.HttpServer, HttpServerError.ServeError, SparqlServer.Requirements>;
30
+ /**
31
+ * A Node server over an in-memory store.
32
+ *
33
+ * @since 0.1.0
34
+ * @category layers
35
+ */
36
+ declare const layerMemory: (options: ServeOptions & {
37
+ readonly data?: Dataset.Dataset | undefined;
38
+ readonly engine?: Engine.EngineOptions | undefined;
39
+ }) => Layer.Layer<HttpServer.HttpServer, HttpServerError.ServeError>;
40
+ export { layerMemory as i, ServeOptions as n, layer as r, NodeSparqlServer_d_exports as t };
41
+ //# sourceMappingURL=NodeSparqlServer-1vSrPk3J.d.mts.map
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.mjs";
2
+ import * as Layer from "effect/Layer";
3
+ import { createServer } from "node:http";
4
+ import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
5
+ import * as SparqlServer from "@thomasfosterau/effect-rdf/sparql/SparqlServer";
6
+ // src/NodeSparqlServer.ts
7
+ /**
8
+ * The SPARQL 1.1 Protocol and Graph Store HTTP Protocol server of
9
+ * `@thomasfosterau/effect-rdf/sparql` (`SparqlServer`) on a Node
10
+ * `node:http` server, through `@effect/platform-node`'s `NodeHttpServer`.
11
+ *
12
+ * `SparqlServer` itself is platform-neutral (`handler`, `layerRoutes`,
13
+ * `layerServe`); this module adds the listening socket.
14
+ *
15
+ * @since 0.1.0
16
+ */
17
+ var NodeSparqlServer_exports = /* @__PURE__ */ __exportAll({
18
+ layer: () => layer,
19
+ layerMemory: () => layerMemory
20
+ });
21
+ /**
22
+ * A Node HTTP server serving the SPARQL endpoint and graph store.
23
+ *
24
+ * @since 0.1.0
25
+ * @category layers
26
+ */
27
+ const layer = (options) => {
28
+ const { port, host, ...rest } = options;
29
+ return SparqlServer.layerServe(rest).pipe(Layer.provideMerge(NodeHttpServer.layer(createServer, host === void 0 ? { port } : {
30
+ port,
31
+ host
32
+ })));
33
+ };
34
+ /**
35
+ * A Node server over an in-memory store.
36
+ *
37
+ * @since 0.1.0
38
+ * @category layers
39
+ */
40
+ const layerMemory = (options) => {
41
+ const { data, engine, ...rest } = options;
42
+ return layer({
43
+ ...rest,
44
+ unionDefaultGraph: rest.unionDefaultGraph ?? engine?.unionDefaultGraph,
45
+ federation: rest.federation ?? engine?.service !== void 0
46
+ }).pipe(Layer.provide(SparqlServer.layerMemoryServices(data, engine)));
47
+ };
48
+ export { layer as n, layerMemory as r, NodeSparqlServer_exports as t };
49
+
50
+ //# sourceMappingURL=NodeSparqlServer-CYAd_6BG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeSparqlServer-CYAd_6BG.mjs","names":[],"sources":["../src/NodeSparqlServer.ts"],"sourcesContent":["/**\n * The SPARQL 1.1 Protocol and Graph Store HTTP Protocol server of\n * `@thomasfosterau/effect-rdf/sparql` (`SparqlServer`) on a Node\n * `node:http` server, through `@effect/platform-node`'s `NodeHttpServer`.\n *\n * `SparqlServer` itself is platform-neutral (`handler`, `layerRoutes`,\n * `layerServe`); this module adds the listening socket.\n *\n * @since 0.1.0\n */\nimport { createServer } from 'node:http';\nimport * as Layer from 'effect/Layer';\nimport type * as HttpServer from 'effect/http/HttpServer';\nimport type * as HttpServerError from 'effect/http/HttpServerError';\nimport * as NodeHttpServer from '@effect/platform-node/NodeHttpServer';\nimport type * as Dataset from '@thomasfosterau/effect-rdf/Dataset';\nimport type * as Engine from '@thomasfosterau/effect-rdf/sparql/Engine';\nimport type * as Options from '@thomasfosterau/effect-rdf/sparql/Options';\nimport * as SparqlServer from '@thomasfosterau/effect-rdf/sparql/SparqlServer';\n\n/**\n * Options of the Node server.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface ServeOptions extends Options.Options {\n /** The port to listen on (`0` for an ephemeral port). */\n readonly port: number;\n /** The host to bind (default: all interfaces). */\n readonly host?: string | undefined;\n}\n\n/**\n * A Node HTTP server serving the SPARQL endpoint and graph store.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layer = (\n options: ServeOptions,\n): Layer.Layer<HttpServer.HttpServer, HttpServerError.ServeError, SparqlServer.Requirements> => {\n const { port, host, ...rest } = options;\n // SAFETY: providing the Node HTTP server leaves `HttpServer` and `SparqlServer.Requirements`; the cast\n // restates the layer type.\n return SparqlServer.layerServe(rest).pipe(\n Layer.provideMerge(\n NodeHttpServer.layer(createServer, host === undefined ? { port } : { port, host }),\n ),\n );\n};\n\n/**\n * A Node server over an in-memory store.\n *\n * @since 0.1.0\n * @category layers\n */\nexport const layerMemory = (\n options: ServeOptions & {\n readonly data?: Dataset.Dataset | undefined;\n readonly engine?: Engine.EngineOptions | undefined;\n },\n): Layer.Layer<HttpServer.HttpServer, HttpServerError.ServeError> => {\n const { data, engine, ...rest } = options;\n return layer({\n ...rest,\n unionDefaultGraph: rest.unionDefaultGraph ?? engine?.unionDefaultGraph,\n federation: rest.federation ?? engine?.service !== undefined,\n }).pipe(Layer.provide(SparqlServer.layerMemoryServices(data, engine)));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,SACX,YAC8F;CAC9F,MAAM,EAAE,MAAM,MAAM,GAAG,SAAS;CAGhC,OAAO,aAAa,WAAW,IAAI,CAAC,CAAC,KACnC,MAAM,aACJ,eAAe,MAAM,cAAc,SAAS,KAAA,IAAY,EAAE,KAAK,IAAI;EAAE;EAAM;CAAK,CAAC,CACnF,CACF;AACF;;;;;;;AAQA,MAAa,eACX,YAImE;CACnE,MAAM,EAAE,MAAM,QAAQ,GAAG,SAAS;CAClC,OAAO,MAAM;EACX,GAAG;EACH,mBAAmB,KAAK,qBAAqB,QAAQ;EACrD,YAAY,KAAK,cAAc,QAAQ,YAAY,KAAA;CACrD,CAAC,CAAC,CAAC,KAAK,MAAM,QAAQ,aAAa,oBAAoB,MAAM,MAAM,CAAC,CAAC;AACvE"}
@@ -0,0 +1,2 @@
1
+ import { i as layerMemory, n as ServeOptions, r as layer } from "./NodeSparqlServer-1vSrPk3J.mjs";
2
+ export { ServeOptions, layer, layerMemory };
@@ -0,0 +1 @@
1
+ export { n as layer, r as layerMemory } from "./NodeSparqlServer-CYAd_6BG.mjs";
@@ -0,0 +1,488 @@
1
+ import * as Schema from "effect/Schema";
2
+ import * as Serialization from "@thomasfosterau/effect-rdf/Serialization";
3
+ import * as HttpApi from "effect/http-api/HttpApi";
4
+ import * as HttpApiEndpoint from "effect/http-api/HttpApiEndpoint";
5
+ import * as HttpApiGroup from "effect/http-api/HttpApiGroup";
6
+ import * as HttpApiMiddleware from "effect/http-api/HttpApiMiddleware";
7
+ import * as HttpApiSchema from "effect/http-api/HttpApiSchema";
8
+ import * as OpenApi from "effect/http-api/OpenApi";
9
+ import * as ProtocolErrors from "@thomasfosterau/effect-rdf/sparql/ProtocolErrors";
10
+ import * as Engine from "@thomasfosterau/effect-rdf/sparql/Engine";
11
+ import * as Store from "@thomasfosterau/effect-rdf/sparql/Store";
12
+ declare namespace SparqlApi_d_exports {
13
+ export { AcceptHeader, Api, DatasetParams, DirectQueryBody, DirectUpdateBody, FormBody, GraphParams, Paths, ProtocolErrorResponse, QueryParams, QueryResponse, RdfDocumentBody, RdfResponse, SchemaFallback, SparqlApi, make, openApi, queryMediaTypes, rdfMediaTypes, resultsMediaTypes };
14
+ }
15
+ /**
16
+ * The media types of the default RDF formats (`ServerFormats.codecs`), in order of
17
+ * preference: Graph Store bodies and `CONSTRUCT` / `DESCRIBE` / service
18
+ * description responses.
19
+ *
20
+ * @since 0.1.0
21
+ * @category media types
22
+ */
23
+ declare const rdfMediaTypes: ReadonlyArray<string>;
24
+ /**
25
+ * The media types of SPARQL results (`Results.codecs`): JSON, XML, CSV and
26
+ * TSV, in order of preference.
27
+ *
28
+ * @since 0.1.0
29
+ * @category media types
30
+ */
31
+ declare const resultsMediaTypes: ReadonlyArray<string>;
32
+ /**
33
+ * Every media type a query response can have: the results formats for
34
+ * `SELECT` / `ASK`, then the RDF formats for `CONSTRUCT` / `DESCRIBE` and the
35
+ * service description.
36
+ *
37
+ * @since 0.1.0
38
+ * @category media types
39
+ */
40
+ declare const queryMediaTypes: ReadonlyArray<string>;
41
+ /**
42
+ * A query response body: a byte stream under any of `queryMediaTypes`.
43
+ *
44
+ * @since 0.1.0
45
+ * @category schemas
46
+ */
47
+ declare const QueryResponse: HttpApiSchema.StreamUint8Array;
48
+ /**
49
+ * An RDF document response body: a byte stream under any of `rdfMediaTypes`.
50
+ *
51
+ * @since 0.1.0
52
+ * @category schemas
53
+ */
54
+ declare const RdfResponse: HttpApiSchema.StreamUint8Array;
55
+ /**
56
+ * The `Accept` request header, which selects the response format.
57
+ *
58
+ * @since 0.1.0
59
+ * @category schemas
60
+ */
61
+ declare const AcceptHeader: Schema.Struct<{
62
+ readonly accept: Schema.optionalKey<Schema.String>;
63
+ }>;
64
+ /**
65
+ * The decoded type of `AcceptHeader`.
66
+ *
67
+ * @since 0.1.0
68
+ * @category schemas
69
+ */
70
+ type AcceptHeader = typeof AcceptHeader.Type;
71
+ /**
72
+ * The query string of a query: the query and its protocol dataset.
73
+ *
74
+ * @since 0.1.0
75
+ * @category schemas
76
+ */
77
+ declare const QueryParams: Schema.Struct<{
78
+ readonly query: Schema.optionalKey<Schema.String>;
79
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
80
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
81
+ }>;
82
+ /**
83
+ * The decoded type of `QueryParams`.
84
+ *
85
+ * @since 0.1.0
86
+ * @category schemas
87
+ */
88
+ type QueryParams = typeof QueryParams.Type;
89
+ /**
90
+ * The query string of a `POST`: the protocol dataset of a query
91
+ * (`default-graph-uri` / `named-graph-uri`) or of an update
92
+ * (`using-graph-uri` / `using-named-graph-uri`).
93
+ *
94
+ * @since 0.1.0
95
+ * @category schemas
96
+ */
97
+ declare const DatasetParams: Schema.Struct<{
98
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
99
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
100
+ readonly 'using-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
101
+ readonly 'using-named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
102
+ }>;
103
+ /**
104
+ * The decoded type of `DatasetParams`.
105
+ *
106
+ * @since 0.1.0
107
+ * @category schemas
108
+ */
109
+ type DatasetParams = typeof DatasetParams.Type;
110
+ /**
111
+ * An `application/x-www-form-urlencoded` `POST` body holding a `query` or an
112
+ * `update` and its protocol dataset.
113
+ *
114
+ * @since 0.1.0
115
+ * @category schemas
116
+ */
117
+ declare const FormBody: Schema.Struct<{
118
+ readonly query: Schema.optionalKey<Schema.String>;
119
+ readonly update: Schema.optionalKey<Schema.String>;
120
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
121
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
122
+ readonly 'using-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
123
+ readonly 'using-named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
124
+ }>;
125
+ /**
126
+ * The decoded type of `FormBody`.
127
+ *
128
+ * @since 0.1.0
129
+ * @category schemas
130
+ */
131
+ type FormBody = typeof FormBody.Type;
132
+ /**
133
+ * An `application/sparql-query` `POST` body, decoded as
134
+ * `{ _tag: 'DirectQuery', query }`.
135
+ *
136
+ * @since 0.1.0
137
+ * @category schemas
138
+ */
139
+ declare const DirectQueryBody: Schema.decodeTo<Schema.TaggedStruct<"DirectQuery", {
140
+ readonly query: Schema.String;
141
+ }>, Schema.String, never, never>;
142
+ /**
143
+ * The decoded type of `DirectQueryBody`.
144
+ *
145
+ * @since 0.1.0
146
+ * @category schemas
147
+ */
148
+ type DirectQueryBody = typeof DirectQueryBody.Type;
149
+ /**
150
+ * An `application/sparql-update` `POST` body, decoded as
151
+ * `{ _tag: 'DirectUpdate', update }`.
152
+ *
153
+ * @since 0.1.0
154
+ * @category schemas
155
+ */
156
+ declare const DirectUpdateBody: Schema.decodeTo<Schema.TaggedStruct<"DirectUpdate", {
157
+ readonly update: Schema.String;
158
+ }>, Schema.String, never, never>;
159
+ /**
160
+ * The decoded type of `DirectUpdateBody`.
161
+ *
162
+ * @since 0.1.0
163
+ * @category schemas
164
+ */
165
+ type DirectUpdateBody = typeof DirectUpdateBody.Type;
166
+ /**
167
+ * Graph Store request bodies: an RDF document under one of `rdfMediaTypes`,
168
+ * decoded as `{ mediaType, document }` (the media type selects the request's
169
+ * `Content-Type`).
170
+ *
171
+ * @since 0.1.0
172
+ * @category schemas
173
+ */
174
+ declare const RdfDocumentBody: Schema.decodeTo<Schema.Struct<{
175
+ readonly mediaType: Schema.Literal<string>;
176
+ readonly document: Schema.String;
177
+ }>, Schema.String, never, never>[];
178
+ /**
179
+ * The query string of a Graph Store request: `graph=<iri>` (indirect
180
+ * identification) or `default` (the default graph).
181
+ *
182
+ * @since 0.1.0
183
+ * @category schemas
184
+ */
185
+ declare const GraphParams: Schema.Struct<{
186
+ readonly graph: Schema.optionalKey<Schema.String>;
187
+ readonly default: Schema.optionalKey<Schema.String>;
188
+ }>;
189
+ /**
190
+ * The decoded type of `GraphParams`.
191
+ *
192
+ * @since 0.1.0
193
+ * @category schemas
194
+ */
195
+ type GraphParams = typeof GraphParams.Type;
196
+ /**
197
+ * The error response of a status: a `text/plain` message, decoded as an
198
+ * `ProtocolErrors.ProtocolError` with that status.
199
+ *
200
+ * @since 0.1.0
201
+ * @category schemas
202
+ */
203
+ declare const ProtocolErrorResponse: (status: number) => Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
204
+ readonly status: number;
205
+ readonly message: string;
206
+ readonly _tag: "ProtocolError";
207
+ readonly headers?: {
208
+ readonly [x: string]: string;
209
+ } | undefined;
210
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
211
+ readonly status: Schema.Number;
212
+ readonly message: Schema.String;
213
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
214
+ }>], {
215
+ readonly status: number;
216
+ readonly message: string;
217
+ readonly _tag: "ProtocolError";
218
+ readonly headers?: {
219
+ readonly [x: string]: string;
220
+ } | undefined;
221
+ }>, Schema.TaggedStruct<"ProtocolError", {
222
+ readonly status: Schema.Number;
223
+ readonly message: Schema.String;
224
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
225
+ }>, never, never>, Schema.String, never, never>;
226
+ declare const SchemaFallback_base: HttpApiMiddleware.ServiceClass<SchemaFallback, "@thomasfosterau/effect-sparql-node/SparqlApi/SchemaFallback", {
227
+ requires: Engine.SparqlEngine | Store.QuadStore | Serialization.Formats;
228
+ provides: never;
229
+ error: never;
230
+ clientError: never;
231
+ requiredForClient: false;
232
+ security: never;
233
+ }, HttpApiMiddleware.HttpApiMiddleware<never, never, Engine.SparqlEngine | Store.QuadStore | Serialization.Formats>>;
234
+ /**
235
+ * Middleware on every endpoint that answers a request whose parameters or
236
+ * headers fail the API's schemas with the protocol handler instead of an
237
+ * empty `400` (see `SparqlApiBuilder.layerSchemaFallback`). It needs the
238
+ * server's services and nothing on the client side.
239
+ *
240
+ * @since 0.1.0
241
+ * @category middleware
242
+ */
243
+ declare class SchemaFallback extends SchemaFallback_base {}
244
+ /**
245
+ * The paths an API is served at.
246
+ *
247
+ * @since 0.1.0
248
+ * @category models
249
+ */
250
+ interface Paths {
251
+ /** The SPARQL endpoint, for queries and updates (default `/sparql`). */
252
+ readonly path?: `/${string}` | undefined;
253
+ /** The Graph Store endpoint (default `/rdf-graph-store`). */
254
+ readonly graphStorePath?: `/${string}` | undefined;
255
+ }
256
+ /**
257
+ * Builds the API at the given paths.
258
+ *
259
+ * @since 0.1.0
260
+ * @category constructors
261
+ */
262
+ declare const make: (paths?: Paths) => HttpApi.HttpApi<"effect-sparql-node", HttpApiGroup.HttpApiGroup<"sparql", HttpApiEndpoint.HttpApiEndpoint<"query", "GET", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
263
+ readonly query: Schema.optionalKey<Schema.String>;
264
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
265
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
266
+ }>>, never, Schema.toCodecStringTree<Schema.Struct<{
267
+ readonly accept: Schema.optionalKey<Schema.String>;
268
+ }>>, HttpApiSchema.StreamUint8Array, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
269
+ readonly status: number;
270
+ readonly message: string;
271
+ readonly _tag: "ProtocolError";
272
+ readonly headers?: {
273
+ readonly [x: string]: string;
274
+ } | undefined;
275
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
276
+ readonly status: Schema.Number;
277
+ readonly message: Schema.String;
278
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
279
+ }>], {
280
+ readonly status: number;
281
+ readonly message: string;
282
+ readonly _tag: "ProtocolError";
283
+ readonly headers?: {
284
+ readonly [x: string]: string;
285
+ } | undefined;
286
+ }>, Schema.TaggedStruct<"ProtocolError", {
287
+ readonly status: Schema.Number;
288
+ readonly message: Schema.String;
289
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
290
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>> | HttpApiEndpoint.HttpApiEndpoint<"post", "POST", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
291
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
292
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
293
+ readonly 'using-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
294
+ readonly 'using-named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
295
+ }>>, Schema.toCodecJson<Schema.decodeTo<Schema.TaggedStruct<"DirectQuery", {
296
+ readonly query: Schema.String;
297
+ }>, Schema.String, never, never> | Schema.decodeTo<Schema.TaggedStruct<"DirectUpdate", {
298
+ readonly update: Schema.String;
299
+ }>, Schema.String, never, never> | Schema.Struct<{
300
+ readonly query: Schema.optionalKey<Schema.String>;
301
+ readonly update: Schema.optionalKey<Schema.String>;
302
+ readonly 'default-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
303
+ readonly 'named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
304
+ readonly 'using-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
305
+ readonly 'using-named-graph-uri': Schema.optionalKey<Schema.$Array<Schema.String>>;
306
+ }>>, Schema.toCodecStringTree<Schema.Struct<{
307
+ readonly accept: Schema.optionalKey<Schema.String>;
308
+ }>>, HttpApiSchema.StreamUint8Array | Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
309
+ readonly status: number;
310
+ readonly message: string;
311
+ readonly _tag: "ProtocolError";
312
+ readonly headers?: {
313
+ readonly [x: string]: string;
314
+ } | undefined;
315
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
316
+ readonly status: Schema.Number;
317
+ readonly message: Schema.String;
318
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
319
+ }>], {
320
+ readonly status: number;
321
+ readonly message: string;
322
+ readonly _tag: "ProtocolError";
323
+ readonly headers?: {
324
+ readonly [x: string]: string;
325
+ } | undefined;
326
+ }>, Schema.TaggedStruct<"ProtocolError", {
327
+ readonly status: Schema.Number;
328
+ readonly message: Schema.String;
329
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
330
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>>, false> | HttpApiGroup.HttpApiGroup<"graphStore", HttpApiEndpoint.HttpApiEndpoint<"get", "GET", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
331
+ readonly graph: Schema.optionalKey<Schema.String>;
332
+ readonly default: Schema.optionalKey<Schema.String>;
333
+ }>>, never, Schema.toCodecStringTree<Schema.Struct<{
334
+ readonly accept: Schema.optionalKey<Schema.String>;
335
+ }>>, HttpApiSchema.StreamUint8Array, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
336
+ readonly status: number;
337
+ readonly message: string;
338
+ readonly _tag: "ProtocolError";
339
+ readonly headers?: {
340
+ readonly [x: string]: string;
341
+ } | undefined;
342
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
343
+ readonly status: Schema.Number;
344
+ readonly message: Schema.String;
345
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
346
+ }>], {
347
+ readonly status: number;
348
+ readonly message: string;
349
+ readonly _tag: "ProtocolError";
350
+ readonly headers?: {
351
+ readonly [x: string]: string;
352
+ } | undefined;
353
+ }>, Schema.TaggedStruct<"ProtocolError", {
354
+ readonly status: Schema.Number;
355
+ readonly message: Schema.String;
356
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
357
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>> | HttpApiEndpoint.HttpApiEndpoint<"head", "HEAD", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
358
+ readonly graph: Schema.optionalKey<Schema.String>;
359
+ readonly default: Schema.optionalKey<Schema.String>;
360
+ }>>, never, Schema.toCodecStringTree<Schema.Struct<{
361
+ readonly accept: Schema.optionalKey<Schema.String>;
362
+ }>>, Schema.toCodecJson<Schema.Void>, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
363
+ readonly status: number;
364
+ readonly message: string;
365
+ readonly _tag: "ProtocolError";
366
+ readonly headers?: {
367
+ readonly [x: string]: string;
368
+ } | undefined;
369
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
370
+ readonly status: Schema.Number;
371
+ readonly message: Schema.String;
372
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
373
+ }>], {
374
+ readonly status: number;
375
+ readonly message: string;
376
+ readonly _tag: "ProtocolError";
377
+ readonly headers?: {
378
+ readonly [x: string]: string;
379
+ } | undefined;
380
+ }>, Schema.TaggedStruct<"ProtocolError", {
381
+ readonly status: Schema.Number;
382
+ readonly message: Schema.String;
383
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
384
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>> | HttpApiEndpoint.HttpApiEndpoint<"put", "PUT", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
385
+ readonly graph: Schema.optionalKey<Schema.String>;
386
+ readonly default: Schema.optionalKey<Schema.String>;
387
+ }>>, Schema.toCodecJson<Schema.decodeTo<Schema.Struct<{
388
+ readonly mediaType: Schema.Literal<string>;
389
+ readonly document: Schema.String;
390
+ }>, Schema.String, never, never>>, never, Schema.toCodecJson<HttpApiSchema.NoContent | HttpApiSchema.Created>, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
391
+ readonly status: number;
392
+ readonly message: string;
393
+ readonly _tag: "ProtocolError";
394
+ readonly headers?: {
395
+ readonly [x: string]: string;
396
+ } | undefined;
397
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
398
+ readonly status: Schema.Number;
399
+ readonly message: Schema.String;
400
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
401
+ }>], {
402
+ readonly status: number;
403
+ readonly message: string;
404
+ readonly _tag: "ProtocolError";
405
+ readonly headers?: {
406
+ readonly [x: string]: string;
407
+ } | undefined;
408
+ }>, Schema.TaggedStruct<"ProtocolError", {
409
+ readonly status: Schema.Number;
410
+ readonly message: Schema.String;
411
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
412
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>> | HttpApiEndpoint.HttpApiEndpoint<"post", "POST", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
413
+ readonly graph: Schema.optionalKey<Schema.String>;
414
+ readonly default: Schema.optionalKey<Schema.String>;
415
+ }>>, Schema.toCodecJson<Schema.decodeTo<Schema.Struct<{
416
+ readonly mediaType: Schema.Literal<string>;
417
+ readonly document: Schema.String;
418
+ }>, Schema.String, never, never>>, never, Schema.toCodecJson<HttpApiSchema.NoContent | HttpApiSchema.Created>, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
419
+ readonly status: number;
420
+ readonly message: string;
421
+ readonly _tag: "ProtocolError";
422
+ readonly headers?: {
423
+ readonly [x: string]: string;
424
+ } | undefined;
425
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
426
+ readonly status: Schema.Number;
427
+ readonly message: Schema.String;
428
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
429
+ }>], {
430
+ readonly status: number;
431
+ readonly message: string;
432
+ readonly _tag: "ProtocolError";
433
+ readonly headers?: {
434
+ readonly [x: string]: string;
435
+ } | undefined;
436
+ }>, Schema.TaggedStruct<"ProtocolError", {
437
+ readonly status: Schema.Number;
438
+ readonly message: Schema.String;
439
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
440
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>> | HttpApiEndpoint.HttpApiEndpoint<"delete", "DELETE", `/${string}`, never, Schema.toCodecStringTree<Schema.Struct<{
441
+ readonly graph: Schema.optionalKey<Schema.String>;
442
+ readonly default: Schema.optionalKey<Schema.String>;
443
+ }>>, never, never, Schema.toCodecJson<HttpApiSchema.NoContent>, Schema.toCodecJson<Schema.decodeTo<Schema.decodeTo<Schema.declareConstructor<ProtocolErrors.ProtocolError, {
444
+ readonly status: number;
445
+ readonly message: string;
446
+ readonly _tag: "ProtocolError";
447
+ readonly headers?: {
448
+ readonly [x: string]: string;
449
+ } | undefined;
450
+ }, readonly [Schema.TaggedStruct<"ProtocolError", {
451
+ readonly status: Schema.Number;
452
+ readonly message: Schema.String;
453
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
454
+ }>], {
455
+ readonly status: number;
456
+ readonly message: string;
457
+ readonly _tag: "ProtocolError";
458
+ readonly headers?: {
459
+ readonly [x: string]: string;
460
+ } | undefined;
461
+ }>, Schema.TaggedStruct<"ProtocolError", {
462
+ readonly status: Schema.Number;
463
+ readonly message: Schema.String;
464
+ readonly headers: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
465
+ }>, never, never>, Schema.String, never, never>>, SchemaFallback, HttpApiMiddleware.ApplyServices<SchemaFallback, never>>, false>>;
466
+ /**
467
+ * The type of an API built by `make`.
468
+ *
469
+ * @since 0.1.0
470
+ * @category models
471
+ */
472
+ type Api = ReturnType<typeof make>;
473
+ /**
474
+ * The API at the default paths, `/sparql` and `/rdf-graph-store`.
475
+ *
476
+ * @since 0.1.0
477
+ * @category api
478
+ */
479
+ declare const SparqlApi: Api;
480
+ /**
481
+ * The OpenAPI document of an API (the default one when omitted).
482
+ *
483
+ * @since 0.1.0
484
+ * @category openapi
485
+ */
486
+ declare const openApi: (api?: Api) => OpenApi.OpenAPISpec;
487
+ export { make as _, DirectUpdateBody as a, rdfMediaTypes as b, Paths as c, QueryResponse as d, RdfDocumentBody as f, SparqlApi_d_exports as g, SparqlApi as h, DirectQueryBody as i, ProtocolErrorResponse as l, SchemaFallback as m, Api as n, FormBody as o, RdfResponse as p, DatasetParams as r, GraphParams as s, AcceptHeader as t, QueryParams as u, openApi as v, resultsMediaTypes as x, queryMediaTypes as y };
488
+ //# sourceMappingURL=SparqlApi-BKE9nIf4.d.mts.map