ignotum 0.0.2 → 0.0.4
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.
- package/README.md +23 -7
- package/dist/cli/bin.mjs +32313 -751
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-Cpx57mk3.d.ts → api-D2bsAz4T.d.ts} +3 -2
- package/dist/runtime/{api-BXXIZc_Q.js → api-DtX8qPrq.js} +58 -27
- package/dist/runtime/api-DtX8qPrq.js.map +1 -0
- package/dist/runtime/client.d.ts +11 -4
- package/dist/runtime/client.js +343 -79
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{result-B2W-z2wG.js → descriptor-t6BOEGw9-BTHR-ZMv.js} +119 -4
- package/dist/runtime/descriptor-t6BOEGw9-BTHR-ZMv.js.map +1 -0
- package/dist/runtime/id-Btwac71X-B9OeBzvq.d.ts +9 -0
- package/dist/runtime/id-D570vudg.js +26 -0
- package/dist/runtime/id-D570vudg.js.map +1 -0
- package/dist/runtime/{index-BgWROoyk.d.ts → index-Dl_VQGmA.d.ts} +114 -31
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +44 -0
- package/dist/runtime/internal/host.js +213 -0
- package/dist/runtime/internal/host.js.map +1 -0
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +1 -1
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/{result-C1ZdsM6Y.d.ts → result-BgcHn25t.d.ts} +21 -6
- package/dist/runtime/schema-B-jMZEbs.js +227 -0
- package/dist/runtime/schema-B-jMZEbs.js.map +1 -0
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/server.js +2 -2
- package/package.json +15 -5
- package/src/cli/agent-files.ts +6 -2
- package/src/cli/app-configuration.ts +135 -0
- package/src/cli/bin.ts +24 -1
- package/src/cli/build/artifact.ts +95 -0
- package/src/cli/build/client.ts +103 -0
- package/src/cli/build/server.ts +526 -0
- package/src/cli/client-config.ts +141 -0
- package/src/cli/client-entry.ts +152 -0
- package/src/cli/client-plugin.ts +86 -16
- package/src/cli/codegen.ts +5 -5
- package/src/cli/command.ts +41 -9
- package/src/cli/control-client.ts +343 -0
- package/src/cli/deploy.ts +217 -0
- package/src/cli/dev.ts +43 -108
- package/src/cli/module-boundaries.ts +183 -0
- package/src/cli/{new-project.ts → new-app.ts} +86 -86
- package/src/cli/package-manager.ts +9 -9
- package/src/client/app.ts +15 -0
- package/src/client/errors.ts +1 -17
- package/src/client/index.ts +2 -0
- package/src/client/sync.ts +172 -120
- package/src/dev-runtime/database.ts +253 -96
- package/src/dev-runtime/dev-database.ts +14 -14
- package/src/dev-runtime/functions.ts +57 -88
- package/src/dev-runtime/id.ts +2 -10
- package/src/dev-runtime/migrations.ts +68 -0
- package/src/dev-runtime/sync.ts +266 -83
- package/src/internal/function-definition.ts +77 -0
- package/src/internal/host.ts +1 -0
- package/src/internal/http-paths.ts +3 -1
- package/dist/runtime/api-BXXIZc_Q.js.map +0 -1
- package/dist/runtime/result-B2W-z2wG.js.map +0 -1
- package/dist/runtime/schema-CNEVLF7D.js +0 -116
- package/dist/runtime/schema-CNEVLF7D.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["Result","useState","useMemo","contractResult"],"sources":["../../src/client/errors.ts","../../src/client/query.ts","../../src/internal/http-paths.ts","../../src/client/sync.ts","../../src/client/hooks.ts","../../src/client/index.ts"],"sourcesContent":["/** @effect-diagnostics globalConsole:skip-file */\nimport { Cause, Effect, ErrorReporter, Schema } from \"effect\";\n\nimport {\n FunctionAddress,\n Operation,\n ProtocolErrorCode,\n RequestId,\n} from \"@ignotum/contracts/runtime/sync\";\n\nexport class ConnectionUnavailable extends Schema.TaggedError<ConnectionUnavailable>()(\n \"ConnectionUnavailable\",\n {\n cause: Schema.optional(Schema.Defect()),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidClientMessage extends Schema.TaggedError<InvalidClientMessage>()(\n \"InvalidClientMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidMutationArguments extends Schema.TaggedError<InvalidMutationArguments>()(\n \"InvalidMutationArguments\",\n {\n cause: Schema.Defect(),\n function: FunctionAddress,\n message: Schema.String,\n },\n) {}\n\nexport class InvalidServerMessage extends Schema.TaggedError<InvalidServerMessage>()(\n \"InvalidServerMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class ServerProtocolError extends Schema.TaggedError<ServerProtocolError>()(\n \"ServerProtocolError\",\n {\n code: ProtocolErrorCode,\n message: Schema.String,\n operation: Schema.optional(Operation),\n },\n) {}\n\nexport class MutationOutcomeUnknown extends Schema.TaggedError<MutationOutcomeUnknown>()(\n \"MutationOutcomeUnknown\",\n {\n cause: Schema.optional(Schema.Defect()),\n function: FunctionAddress,\n id: RequestId,\n message: Schema.String,\n },\n) {}\n\nexport const ClientInfrastructureError = Schema.Union([\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidMutationArguments,\n InvalidServerMessage,\n ServerProtocolError,\n MutationOutcomeUnknown,\n]);\nexport type ClientInfrastructureError = typeof ClientInfrastructureError.Type;\n\nconst browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {\n globalThis.console.error(\"Ignotum infrastructure error\", error, attributes);\n});\n\nexport const clientErrorReporterLayer = ErrorReporter.layer([browserErrorReporter]);\n\nexport const reportClientError = Effect.fn(\"ClientErrorReporter.report\")(function* (\n error: ClientInfrastructureError,\n) {\n yield* ErrorReporter.report(Cause.fail(error));\n});\n","const QuerySkipTypeId: unique symbol = Symbol.for(\"ignotum/client/QuerySkip\");\n\nexport interface QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId;\n}\n\nclass QuerySkipToken implements QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId = QuerySkipTypeId;\n}\n\nconst skip: QuerySkip = Object.freeze(new QuerySkipToken());\n\nexport const Query = { skip };\n\nexport const isQuerySkip = <Value extends object | undefined>(\n value: Value,\n): value is Value & QuerySkip => value === skip;\n","export const ignotumPathPrefix = \"/_ignotum\";\nexport const syncPath = `${ignotumPathPrefix}/sync`;\n\nexport const isIgnotumPath = (pathname: string): boolean =>\n pathname === ignotumPathPrefix || pathname.startsWith(`${ignotumPathPrefix}/`);\n","import {\n Context,\n Deferred,\n Duration,\n Effect,\n HashMap,\n Layer,\n ManagedRuntime,\n Predicate,\n Schedule,\n Schema,\n} from \"effect\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\n\nimport type {\n ErrorValue,\n QueryResult,\n Result as IgnotumResult,\n} from \"@ignotum/contracts/runtime/result\";\nimport { failureFromWire, pending, Result } from \"@ignotum/contracts/runtime/result\";\nimport {\n ClientMessageJson,\n RequestId,\n ServerMessageJson,\n SubscriptionId,\n decodeTransportValue,\n type ClientMessage,\n type FunctionAddress,\n type WireResult,\n} from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidServerMessage,\n MutationOutcomeUnknown,\n ServerProtocolError,\n clientErrorReporterLayer,\n reportClientError,\n} from \"./errors.js\";\nimport { syncPath } from \"../internal/http-paths.js\";\n\ntype Listener = () => void;\ntype SocketWriter = (chunk: string) => Effect.Effect<void, Socket.SocketError>;\n\ninterface QueryEntry {\n readonly args: Schema.Json;\n readonly function: FunctionAddress;\n readonly listeners: Set<Listener>;\n readonly subscriptionId: SubscriptionId;\n generation: number;\n references: number;\n result: QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n}\n\ninterface QueryObserver {\n readonly getSnapshot: () => QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n readonly release: Effect.Effect<void>;\n readonly subscribe: (listener: Listener) => () => void;\n}\n\ntype QueryLifecycleMessage = Extract<ClientMessage, { readonly type: \"Subscribe\" | \"Unsubscribe\" }>;\n\ninterface QueryCache {\n readonly entries: () => Iterable<QueryEntry>;\n readonly getById: (id: SubscriptionId) => QueryEntry | undefined;\n readonly setError: (id: SubscriptionId, error: ClientInfrastructureError) => void;\n readonly setResult: (id: SubscriptionId, result: QueryResult<unknown, ErrorValue>) => void;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver>;\n}\n\nconst canonicalJson = (value: Schema.Json): string => {\n if (\n Predicate.isNull(value) ||\n Predicate.isString(value) ||\n Predicate.isNumber(value) ||\n Predicate.isBoolean(value)\n ) {\n return JSON.stringify(value);\n }\n if (globalThis.Array.isArray(value)) {\n return `[${value.map(canonicalJson).join(\",\")}]`;\n }\n\n return `{${Object.entries(value)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`)\n .join(\",\")}}`;\n};\n\nconst queryKey = (functionAddress: FunctionAddress, args: Schema.Json): string =>\n `${functionAddress}:${canonicalJson(args)}`;\n\nconst subscribeMessage = (entry: QueryEntry): QueryLifecycleMessage => ({\n type: \"Subscribe\",\n id: entry.subscriptionId,\n function: entry.function,\n args: entry.args,\n});\n\nconst makeQueryCache = (\n allocateId: () => SubscriptionId,\n sendLifecycleMessage: (message: QueryLifecycleMessage) => Effect.Effect<void>,\n) => {\n const queries = new Map<string, QueryEntry>();\n const queryKeysById = new Map<SubscriptionId, string>();\n\n const observe = Effect.fn(\"SyncClient.QueryCache.observe\")(function* (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) {\n const key = queryKey(functionAddress, args);\n let entry = queries.get(key);\n\n if (entry === undefined) {\n const created: QueryEntry = {\n args,\n function: functionAddress,\n generation: 0,\n listeners: new Set(),\n references: 0,\n result: pending(),\n subscriptionId: allocateId(),\n };\n queries.set(key, created);\n queryKeysById.set(created.subscriptionId, key);\n yield* sendLifecycleMessage(subscribeMessage(created));\n entry = created;\n }\n\n const observed = entry;\n observed.references += 1;\n observed.generation += 1;\n let released = false;\n return {\n getSnapshot: () => observed.result,\n subscribe: (listener: Listener) => {\n observed.listeners.add(listener);\n return () => observed.listeners.delete(listener);\n },\n release: Effect.gen(function* () {\n if (released) return;\n released = true;\n observed.references -= 1;\n if (observed.references !== 0) return;\n const generation = ++observed.generation;\n\n // Preact and HMR may release and reacquire an observer during one render handoff.\n // Keep the server subscription alive long enough for that handoff to reuse it.\n yield* Effect.sleep(\"25 millis\");\n if (\n observed.references !== 0 ||\n observed.generation !== generation ||\n queries.get(key) !== observed\n ) {\n return;\n }\n\n queries.delete(key);\n queryKeysById.delete(observed.subscriptionId);\n yield* sendLifecycleMessage({\n type: \"Unsubscribe\",\n id: observed.subscriptionId,\n });\n }),\n } satisfies QueryObserver;\n });\n\n return {\n entries: () => queries.values(),\n getById: (id: SubscriptionId) => {\n const key = queryKeysById.get(id);\n return key === undefined ? undefined : queries.get(key);\n },\n observe,\n setError: (id, error) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n entry.result = error;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n setResult: (id, result) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n entry.result = result;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n } satisfies QueryCache;\n};\n\nconst resultFromWire = Effect.fn(\"SyncClient.resultFromWire\")((wire: WireResult) =>\n Effect.succeed(\n wire.type === \"Success\"\n ? Result.succeed(\n wire.value === undefined ? undefined : decodeTransportValue(wire.value, wire.dates ?? []),\n )\n : failureFromWire(wire.error, wire.dates),\n ),\n);\n\nexport const syncClientInternals = { makeQueryCache, queryIdentity: queryKey, resultFromWire };\n\nconst socketUrl = (): string => {\n const url = new URL(syncPath, globalThis.location.href);\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n return url.href;\n};\n\ninterface SyncClientService {\n readonly mutate: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<IgnotumResult<unknown, ErrorValue>, ClientInfrastructureError>;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver, ClientInfrastructureError>;\n}\n\ninterface PendingMutation {\n readonly deferred: Deferred.Deferred<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >;\n readonly function: FunctionAddress;\n}\n\nexport class SyncClient extends Context.Service<SyncClient, SyncClientService>()(\n \"ignotum/client/sync/SyncClient\",\n) {\n static readonly layer = Layer.effect(\n SyncClient,\n Effect.gen(function* () {\n let nextOperationId = 0;\n let mutations = HashMap.empty<RequestId, PendingMutation>();\n let writer: SocketWriter | undefined;\n\n const encode = (message: ClientMessage) =>\n Schema.encodeEffect(ClientMessageJson)(message).pipe(\n Effect.mapError((cause) =>\n InvalidClientMessage.make({\n cause,\n message: \"Could not encode an Ignotum sync message.\",\n }),\n ),\n );\n\n const sendWith = (write: SocketWriter, message: ClientMessage) =>\n encode(message).pipe(\n Effect.flatMap(write),\n Effect.mapError((cause) =>\n Schema.is(InvalidClientMessage)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n );\n\n const send = (message: ClientMessage) =>\n writer === undefined\n ? Effect.fail(\n ConnectionUnavailable.make({ message: \"The sync connection is not ready.\" }),\n )\n : sendWith(writer, message);\n\n const queryCache = makeQueryCache(\n () => SubscriptionId.make(nextOperationId++),\n (message) =>\n writer === undefined\n ? Effect.void\n : send(message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: reportClientError,\n }),\n ),\n );\n\n const rejectMutation = (requestId: RequestId, error: ClientInfrastructureError) => {\n const pendingMutation = HashMap.getUnsafe(mutations, requestId);\n if (pendingMutation === undefined) {\n return Effect.void;\n }\n mutations = HashMap.remove(mutations, requestId);\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingMutation.deferred, error)),\n Effect.asVoid,\n );\n };\n\n const handleMessage = Effect.fn(\"SyncClient.handleMessage\")(function* (text: string) {\n const message = yield* Schema.decodeEffect(ServerMessageJson)(text).pipe(\n Effect.mapError((cause) =>\n InvalidServerMessage.make({\n cause,\n message: \"The server returned an invalid sync message.\",\n }),\n ),\n );\n\n switch (message.type) {\n case \"QuerySnapshot\": {\n const entry = queryCache.getById(message.id);\n if (entry === undefined) return;\n yield* resultFromWire(message.result).pipe(\n Effect.tap((result) => Effect.sync(() => queryCache.setResult(message.id, result))),\n );\n return;\n }\n case \"MutationResult\": {\n const pendingMutation = HashMap.getUnsafe(mutations, message.id);\n if (pendingMutation === undefined) return;\n mutations = HashMap.remove(mutations, message.id);\n yield* resultFromWire(message.result).pipe(\n Effect.flatMap((result) => Deferred.succeed(pendingMutation.deferred, result)),\n );\n return;\n }\n case \"ProtocolError\": {\n const error =\n message.operation === undefined\n ? ServerProtocolError.make({\n code: message.code,\n message: message.message,\n })\n : ServerProtocolError.make({\n code: message.code,\n message: message.message,\n operation: message.operation,\n });\n if (message.operation?.type === \"Mutate\") {\n yield* rejectMutation(message.operation.id, error);\n } else if (message.operation?.type === \"Query\") {\n queryCache.setError(message.operation.id, error);\n yield* reportClientError(error);\n } else {\n yield* reportClientError(error);\n }\n return;\n }\n }\n });\n\n const disconnect = Effect.gen(function* () {\n writer = undefined;\n const current = mutations;\n mutations = HashMap.empty();\n yield* Effect.forEach(HashMap.entries(current), ([id, pendingMutation]) => {\n const error = MutationOutcomeUnknown.make({\n function: pendingMutation.function,\n id,\n message: \"The connection closed before the mutation outcome was known.\",\n });\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingMutation.deferred, error)),\n );\n });\n });\n\n const connect = Effect.scoped(\n Effect.gen(function* () {\n const socket = yield* Socket.makeWebSocket(socketUrl(), {\n closeCodeIsError: () => false,\n });\n const write = yield* socket.writer;\n const onOpen = Effect.gen(function* () {\n writer = write;\n yield* Effect.forEach(queryCache.entries(), (entry) =>\n sendWith(write, subscribeMessage(entry)),\n );\n }).pipe(Effect.tapError(reportClientError), Effect.ignore);\n\n yield* socket.runString(handleMessage, { onOpen });\n }),\n ).pipe(\n Effect.mapError((cause) =>\n Schema.is(ClientInfrastructureError)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n Effect.ensuring(disconnect),\n );\n\n const reconnectSchedule = Schedule.exponential(\"250 millis\").pipe(\n Schedule.modifyDelay(({ duration }) =>\n Effect.succeed(Duration.min(duration, Duration.seconds(5))),\n ),\n Schedule.jittered,\n );\n yield* connect.pipe(\n Effect.andThen(\n Effect.fail(\n ConnectionUnavailable.make({\n message: \"The sync connection closed; reconnecting.\",\n }),\n ),\n ),\n Effect.tapError(reportClientError),\n Effect.retry(reconnectSchedule),\n Effect.forkScoped,\n );\n\n const observe: SyncClientService[\"observe\"] = Effect.fn(\"SyncClient.observe\")(\n function* (functionAddress, args) {\n return yield* queryCache.observe(functionAddress, args);\n },\n );\n\n const mutate: SyncClientService[\"mutate\"] = Effect.fn(\"SyncClient.mutate\")(\n function* (functionAddress, args) {\n const requestId = RequestId.make(nextOperationId++);\n const deferred = yield* Deferred.make<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >();\n mutations = HashMap.set(mutations, requestId, {\n deferred,\n function: functionAddress,\n });\n const message: ClientMessage = {\n type: \"Mutate\",\n id: requestId,\n function: functionAddress,\n args,\n };\n const sendMutation = Effect.gen(function* () {\n const mutationWriter = writer;\n if (mutationWriter === undefined) {\n return yield* ConnectionUnavailable.make({\n message: \"The sync connection is not ready.\",\n });\n }\n return yield* sendWith(mutationWriter, message).pipe(\n Effect.mapError((error) =>\n Schema.is(InvalidClientMessage)(error)\n ? error\n : MutationOutcomeUnknown.make({\n cause: error,\n function: functionAddress,\n id: requestId,\n message: \"The connection failed while sending the mutation.\",\n }),\n ),\n );\n });\n yield* sendMutation.pipe(\n Effect.tapError(reportClientError),\n Effect.tapError(() =>\n Effect.sync(() => (mutations = HashMap.remove(mutations, requestId))),\n ),\n );\n return yield* Deferred.await(deferred);\n },\n );\n\n return SyncClient.of({ mutate, observe });\n }),\n ).pipe(Layer.provide(Socket.layerWebSocketConstructorGlobal));\n}\n\nexport const syncRuntime = ManagedRuntime.make(\n SyncClient.layer.pipe(Layer.provideMerge(clientErrorReporterLayer)),\n);\n\n// SAFETY: Vite adds this optional property to browser development modules.\nconst hot = (\n import.meta as ImportMeta & {\n readonly hot?: { readonly dispose: (cleanup: () => void) => void };\n }\n).hot;\nif (hot !== undefined) {\n hot.dispose(() => void syncRuntime.dispose());\n}\n","import { Effect, Schema } from \"effect\";\nimport { useDebugValue, useEffect, useMemo, useState } from \"preact/hooks\";\n\nimport { functionPathOf, type FunctionReference } from \"../internal/api.js\";\nimport { pending } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, QueryResult, SettledResult } from \"@ignotum/contracts/runtime/result\";\nimport { encodeTransportObject } from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n InvalidMutationArguments,\n reportClientError,\n} from \"./errors.js\";\nimport { isQuerySkip, type QuerySkip } from \"./query.js\";\nimport { SyncClient, syncClientInternals, syncRuntime } from \"./sync.js\";\n\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks are not pipeable functions.\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n): QueryResult<Success, Failure>;\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n args: QuerySkip,\n): QueryResult<Success, Failure>;\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args, Success, Failure>,\n args: NoInfer<Args> | QuerySkip,\n): QueryResult<Success, Failure>;\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks must remain direct calls so hook order is statically visible.\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args | void, Success, Failure>,\n args?: Args | QuerySkip,\n): QueryResult<Success, Failure> {\n const functionPath = functionPathOf(reference);\n const skipped = isQuerySkip(args);\n const input = args === undefined || skipped ? {} : args;\n const jsonArgs = encodeTransportObject(input);\n const identity = skipped\n ? `skip:${functionPath}`\n : syncClientInternals.queryIdentity(functionPath, jsonArgs);\n const [state, setState] = useState<{\n readonly identity: string;\n readonly result: QueryResult<Success, Failure> | ClientInfrastructureError;\n }>(() => ({ identity, result: pending() }));\n\n useDebugValue({ args: input, function: functionPath, result: state.result });\n useEffect(() => {\n if (skipped) return;\n\n let active = true;\n let release: (() => void) | undefined;\n\n void syncRuntime\n .runPromise(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n return yield* client.observe(functionPath, jsonArgs);\n }),\n )\n .then(\n (observer) => {\n if (!active) {\n syncRuntime.runFork(observer.release);\n return;\n }\n const update = () => {\n // SAFETY: the function reference couples this subscription's runtime\n // path to its generated success and failure types.\n const result = observer.getSnapshot() as\n | QueryResult<Success, Failure>\n | ClientInfrastructureError;\n setState({ identity, result });\n };\n release = observer.subscribe(update);\n update();\n const releaseObserver = release;\n release = () => {\n releaseObserver();\n syncRuntime.runFork(observer.release);\n };\n },\n (error) => {\n if (active && Schema.is(ClientInfrastructureError)(error)) {\n setState({ identity, result: error });\n }\n },\n );\n\n return () => {\n active = false;\n release?.();\n };\n }, [identity]);\n\n if (skipped) return pending();\n\n if (state.identity !== identity) {\n return pending();\n }\n\n const result = state.result;\n if (Schema.is(ClientInfrastructureError)(result)) throw result;\n return result;\n}\n\ntype Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void]\n ? () => Promise<SettledResult<Success, Failure>>\n : (args: Args) => Promise<SettledResult<Success, Failure>>;\n\nexport const useMutation = <Args extends object | void, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Mutation\", Args, Success, Failure>,\n): Mutation<Args, Success, Failure> =>\n useMemo(() => {\n const mutate = (args: Args | undefined) => {\n const functionPath = functionPathOf(reference);\n const input = args === undefined ? {} : args;\n return syncRuntime.runPromise<SettledResult<Success, Failure>, ClientInfrastructureError>(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n const jsonArgs = yield* Effect.try({\n try: () => encodeTransportObject(input),\n catch: (cause) =>\n InvalidMutationArguments.make({\n cause,\n function: functionPath,\n message: `Mutation arguments for ${functionPath} contain an unsupported value.`,\n }),\n }).pipe(Effect.tapError(reportClientError));\n // SAFETY: generated function references bind the runtime path to the\n // declared public result types validated by the server executor.\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- The untyped sync transport deliberately erases the generated reference's result parameters.\n return (yield* client.mutate(functionPath, jsonArgs)) as unknown as SettledResult<\n Success,\n Failure\n >;\n }),\n );\n };\n // SAFETY: the builder gives argument-free functions Args = void. At runtime\n // both call shapes normalize omitted arguments to the empty JSON object.\n return mutate as Mutation<Args, Success, Failure>;\n }, [reference]);\n","import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type {\n ErrorValue,\n QueryResult as ContractQueryResult,\n SettledResult,\n} from \"@ignotum/contracts/runtime/result\";\n\nexport const Result = { match: contractResult.match };\nexport type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;\nexport type QueryResult<Value, Error extends ErrorValue> = ContractQueryResult<Value, Error>;\nexport type { InternalServerError } from \"@ignotum/contracts/runtime/result\";\nexport { useMutation, useQuery } from \"./hooks.js\";\nexport { Query } from \"./query.js\";\nexport type { QuerySkip } from \"./query.js\";\n\nexport {\n Component,\n Fragment,\n cloneElement,\n createContext,\n createElement,\n createRef,\n h,\n isValidElement,\n toChildArray,\n} from \"preact\";\nexport type {\n AnyComponent,\n Attributes,\n ClassAttributes,\n ComponentChild,\n ComponentChildren,\n ComponentClass,\n ComponentConstructor,\n ComponentFactory,\n ComponentProps,\n ComponentType,\n Consumer,\n Context,\n ContextType,\n ErrorInfo,\n FunctionComponent,\n FunctionalComponent,\n JSX,\n Key,\n PreactContext,\n PreactConsumer,\n PreactDOMAttributes,\n PreactProvider,\n Provider,\n Ref,\n RefCallback,\n RefObject,\n RenderableProps,\n TargetedAnimationEvent,\n TargetedClipboardEvent,\n TargetedCommandEvent,\n TargetedCompositionEvent,\n TargetedDragEvent,\n TargetedEvent,\n TargetedFocusEvent,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedMouseEvent,\n TargetedPictureInPictureEvent,\n TargetedPointerEvent,\n TargetedSnapEvent,\n TargetedSubmitEvent,\n TargetedToggleEvent,\n TargetedTouchEvent,\n TargetedTransitionEvent,\n TargetedUIEvent,\n TargetedWheelEvent,\n VNode,\n} from \"preact\";\nexport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useErrorBoundary,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"preact/hooks\";\nexport type { Dispatch, Reducer, StateUpdater } from \"preact/hooks\";\n"],"mappings":";;;;;;;;AAUA,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;CACtC,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,OAAO,OAAO,OAAO;CACrB,UAAU;CACV,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,MAAM;CACN,SAAS,OAAO;CAChB,WAAW,OAAO,SAAS,SAAS;AACtC,CACF,CAAC,CAAC,C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,aAAa;GACtB,MAAM,SAAS,OAAO;GACtB,MAAM,WAAW,OAAO,OAAO,IAAI;IACjC,WAAW,sBAAsB,KAAK;IACtC,QAAQ,UACN,yBAAyB,KAAK;KAC5B;KACA,UAAU;KACV,SAAS,0BAA0B,aAAa;IAClD,CAAC;GACL,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,iBAAiB,CAAC;GAI1C,OAAQ,OAAO,OAAO,OAAO,cAAc,QAAQ;EAIrD,CAAC,CACH;CACF;CAGA,OAAO;AACT,GAAG,CAAC,SAAS,CAAC;;;ACrIhB,MAAa,SAAS,EAAE,OAAOC,SAAe,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["Result","useState","useMemo","contractResult"],"sources":["../../src/client/errors.ts","../../src/client/query.ts","../../../contracts/dist/json.js","../../../contracts/dist/runtime/hosted.js","../../../shared/dist/id.js","../../../contracts/dist/runtime/functions.js","../../../contracts/dist/deployment.js","../../../contracts/dist/runtime/transport.js","../../src/internal/http-paths.ts","../../src/client/sync.ts","../../src/client/hooks.ts","../../src/client/app.ts","../../src/client/index.ts"],"sourcesContent":["/** @effect-diagnostics globalConsole:skip-file */\nimport { Cause, Effect, ErrorReporter, Schema } from \"effect\";\n\nimport { FunctionAddress, Operation, ProtocolErrorCode } from \"@ignotum/contracts/runtime/sync\";\n\nexport class ConnectionUnavailable extends Schema.TaggedError<ConnectionUnavailable>()(\n \"ConnectionUnavailable\",\n {\n cause: Schema.optional(Schema.Defect()),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidClientMessage extends Schema.TaggedError<InvalidClientMessage>()(\n \"InvalidClientMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidMutationArguments extends Schema.TaggedError<InvalidMutationArguments>()(\n \"InvalidMutationArguments\",\n {\n cause: Schema.Defect(),\n function: FunctionAddress,\n message: Schema.String,\n },\n) {}\n\nexport class InvalidServerMessage extends Schema.TaggedError<InvalidServerMessage>()(\n \"InvalidServerMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class ServerProtocolError extends Schema.TaggedError<ServerProtocolError>()(\n \"ServerProtocolError\",\n {\n code: ProtocolErrorCode,\n message: Schema.String,\n operation: Schema.optional(Operation),\n },\n) {}\n\nexport const ClientInfrastructureError = Schema.Union([\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidMutationArguments,\n InvalidServerMessage,\n ServerProtocolError,\n]);\nexport type ClientInfrastructureError = typeof ClientInfrastructureError.Type;\n\nconst browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {\n globalThis.console.error(\"Ignotum infrastructure error\", error, attributes);\n});\n\nexport const clientErrorReporterLayer = ErrorReporter.layer([browserErrorReporter]);\n\nexport const reportClientError = Effect.fn(\"ClientErrorReporter.report\")(function* (\n error: ClientInfrastructureError,\n) {\n yield* ErrorReporter.report(Cause.fail(error));\n});\n","const QuerySkipTypeId: unique symbol = Symbol.for(\"ignotum/client/QuerySkip\");\n\nexport interface QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId;\n}\n\nclass QuerySkipToken implements QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId = QuerySkipTypeId;\n}\n\nconst skip: QuerySkip = Object.freeze(new QuerySkipToken());\n\nexport const Query = { skip };\n\nexport const isQuerySkip = <Value extends object | undefined>(\n value: Value,\n): value is Value & QuerySkip => value === skip;\n","import { Array, Predicate, Schema, String } from \"effect\";\n//#region src/json.ts\nconst encodeScalar = (value) => Schema.decodeSync(Schema.String)(JSON.stringify(value));\nconst encodeCanonicalJson = (value) => {\n\tif (value === null || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return encodeScalar(value);\n\tif (Predicate.isObject(value)) return `{${Array.map(Array.sort(String.Order)(Object.keys(value)), (key) => {\n\t\tconst field = Schema.decodeUnknownSync(Schema.Json)(value[key]);\n\t\treturn `${encodeScalar(key)}:${encodeCanonicalJson(field)}`;\n\t}).join(\",\")}}`;\n\treturn `[${Schema.decodeUnknownSync(Schema.Array(Schema.Json))(value).map(encodeCanonicalJson).join(\",\")}]`;\n};\n//#endregion\nexport { encodeCanonicalJson };\n\n//# sourceMappingURL=json.js.map","import { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, GeneratedId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId } from \"./id.js\";\nimport { AppStateRevision, DeploymentGeneration, InvocationKey } from \"./identity.js\";\nimport { FunctionAddress, WireFailure, WireResult, WireSuccess } from \"./sync.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/hosted.ts\nconst QueryKey = Schema.String.pipe(Schema.brand(\"ignotum/hosted/QueryKey\"));\nconst TableDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Table\"),\n\ttableId: TableId\n});\nconst DocumentDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Document\"),\n\ttableId: TableId,\n\tid: GeneratedId\n});\nconst DependencyKey = Schema.Union([TableDependency, DocumentDependency]);\nconst DependencySet = Schema.Array(DependencyKey);\nconst InvalidationSet = Schema.Array(DependencyKey);\nconst RuntimeQueryResult = Schema.Struct({\n\ttype: Schema.Literal(\"Query\"),\n\tresult: WireResult,\n\tdependencies: DependencySet,\n\tobservedRevision: AppStateRevision\n});\nconst RuntimeMutationSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireSuccess,\n\tinvalidations: InvalidationSet,\n\tcommittedRevision: AppStateRevision\n});\nconst RuntimeMutationFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireFailure\n});\nconst RuntimeMutationResult = Schema.Union([RuntimeMutationSuccess, RuntimeMutationFailure]);\nconst RuntimeInvocationResult = Schema.Union([RuntimeQueryResult, RuntimeMutationResult]);\nconst InvocationBase = {\n\tappId: AppId,\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration,\n\tinvocationKey: InvocationKey,\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n};\nconst QueryInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Query\")\n});\nconst MutationInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Mutation\"),\n\tinvocationId: InvocationId\n});\nconst RuntimeInvocation = Schema.Union([QueryInvocation, MutationInvocation]);\nconst RevisionCheck = Schema.Struct({\n\tappId: AppId,\n\texpectedRevision: AppStateRevision\n});\nconst RevisionCheckResult = Schema.Struct({ currentRevision: AppStateRevision });\nvar RuntimeDeploymentUnavailable = class extends Schema.TaggedError()(\"RuntimeDeploymentUnavailable\", {\n\tdeploymentId: DeploymentId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeInvocationRejectionCode = Schema.Literals([\n\t\"FunctionUnavailable\",\n\t\"InvalidArguments\",\n\t\"InvocationIdConflict\",\n\t\"ResourceLimitExceeded\",\n\t\"UnknownFunction\",\n\t\"WrongFunctionKind\"\n]);\nvar RuntimeInvocationRejected = class extends Schema.TaggedError()(\"RuntimeInvocationRejected\", {\n\tcode: RuntimeInvocationRejectionCode,\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeInvocationUnavailable = class extends Schema.TaggedError()(\"RuntimeInvocationUnavailable\", {\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeRevisionRejected = class extends Schema.TaggedError()(\"RuntimeRevisionRejected\", {\n\tappId: AppId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeTransportError = Schema.Union([\n\tRuntimeDeploymentUnavailable,\n\tRuntimeInvocationRejected,\n\tRuntimeInvocationUnavailable\n]);\nconst dependencyKey = (dependency) => dependency.type === \"Table\" ? encodeCanonicalJson([dependency.type, dependency.tableId]) : encodeCanonicalJson([\n\tdependency.type,\n\tdependency.tableId,\n\tdependency.id\n]);\nconst canonicalQueryKey = (deploymentId, functionAddress, args) => QueryKey.make(encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionAddress,\n\targs\n]));\nconst canonicalInvocationInput = (deploymentId, functionKind, functionAddress, args) => encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionKind,\n\tfunctionAddress,\n\targs\n]);\nconst mutationInvocationKey = (appId, invocationId) => InvocationKey.make(encodeCanonicalJson([appId, invocationId]));\nconst tableDependency = (tableId) => ({\n\ttype: \"Table\",\n\ttableId\n});\nconst documentDependency = (tableId, id) => ({\n\ttype: \"Document\",\n\ttableId,\n\tid\n});\n//#endregion\nexport { AppId, AppStateRevision, ConnectionId, DependencyKey, DependencySet, DeploymentGeneration, DeploymentId, DevDatabaseLockId, DocumentDependency, InvalidationSet, InvocationId, InvocationKey, MutationInvocation, PlatformPrincipalId, QueryInvocation, QueryKey, RequestId, RevisionCheck, RevisionCheckResult, RuntimeDeploymentUnavailable, RuntimeInvocation, RuntimeInvocationRejected, RuntimeInvocationRejectionCode, RuntimeInvocationResult, RuntimeInvocationUnavailable, RuntimeMutationFailure, RuntimeMutationResult, RuntimeMutationSuccess, RuntimeQueryResult, RuntimeRequestNonce, RuntimeRevisionRejected, RuntimeTransportError, SubscriptionId, TableDependency, TableId, TeamId, canonicalInvocationInput, canonicalQueryKey, dependencyKey, documentDependency, mutationInvocationKey, tableDependency };\n\n//# sourceMappingURL=hosted.js.map","import { Context, Effect, Layer, Schema } from \"effect\";\nimport { IdAlphabet, IdLength } from \"@ignotum/contracts/runtime/id\";\nimport { customAlphabet } from \"nanoid\";\n//#region src/id.ts\nconst decodeGenerated = (definition, payload) => Schema.decodeSync(definition)(definition.idPrefix === void 0 ? payload : `${definition.idPrefix}_${payload}`);\nvar IdGenerator = class IdGenerator extends Context.Service()(\"@ignotum/shared/id/IdGenerator\") {\n\tstatic layer = Layer.sync(IdGenerator, () => {\n\t\tconst generatePayload = customAlphabet(IdAlphabet, IdLength);\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => decodeGenerated(definition, generatePayload())) });\n\t});\n\tstatic deterministic = (startAt = 1) => Layer.sync(IdGenerator, () => {\n\t\tconst counters = /* @__PURE__ */ new Map();\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => {\n\t\t\tconst counter = (counters.get(definition.idPrefix) ?? startAt - 1) + 1;\n\t\t\tcounters.set(definition.idPrefix, counter);\n\t\t\treturn decodeGenerated(definition, counter.toString(36).padStart(IdLength, \"0\"));\n\t\t}) });\n\t});\n};\n//#endregion\nexport { IdGenerator };\n\n//# sourceMappingURL=id.js.map","import { FunctionAddress } from \"./sync.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/functions.ts\nconst FunctionKind = Schema.Literals([\"Mutation\", \"Query\"]);\nvar UnknownFunction = class extends Schema.TaggedError()(\"UnknownFunction\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar WrongFunctionKind = class extends Schema.TaggedError()(\"WrongFunctionKind\", {\n\tactual: FunctionKind,\n\texpected: FunctionKind,\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar InvalidArguments = class extends Schema.TaggedError()(\"InvalidArguments\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar FunctionUnavailable = class extends Schema.TaggedError()(\"FunctionUnavailable\", {\n\tcause: Schema.Defect(),\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\n//#endregion\nexport { FunctionKind, FunctionUnavailable, InvalidArguments, UnknownFunction, WrongFunctionKind };\n\n//# sourceMappingURL=functions.js.map","import { FunctionAddress } from \"./runtime/sync.js\";\nimport { FunctionKind } from \"./runtime/functions.js\";\nimport { t as ValueDescriptor } from \"./descriptor-t6BOEGw9.js\";\nimport { Schema } from \"effect\";\n//#region src/deployment.ts\nconst ArtifactPath = Schema.String.check(Schema.isPattern(/^(?!\\/)(?![A-Za-z]:\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))(?!.*(?:^|\\/)\\.(?:\\/|$))(?!.*\\/\\/)[^\\\\\\0]+$/)).pipe(Schema.brand(\"ignotum/deployment/ArtifactPath\"));\nconst Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)).pipe(Schema.brand(\"ignotum/deployment/Sha256\"));\nconst ArtifactKind = Schema.Literals([\n\t\"ClientAsset\",\n\t\"ClientShell\",\n\t\"FunctionBundle\",\n\t\"ServerManifest\",\n\t\"SourceMap\",\n\t\"SchemaSnapshot\"\n]);\nconst ArtifactReference = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256\n});\nconst ArtifactFile = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256,\n\tkind: ArtifactKind,\n\tcontentType: Schema.String,\n\tcontentEncoding: Schema.optional(Schema.String)\n});\nconst DeploymentInventory = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tfiles: Schema.Array(ArtifactFile)\n});\nconst SchemaSnapshotField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: ValueDescriptor\n});\nconst SchemaSnapshotTable = Schema.Struct({\n\tname: Schema.String,\n\tfields: Schema.Array(SchemaSnapshotField)\n});\nconst SchemaSnapshot = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\ttables: Schema.Array(SchemaSnapshotTable)\n});\nconst ServerFunctionArtifact = Schema.Struct({\n\taddress: FunctionAddress,\n\tkind: FunctionKind,\n\tbundle: ArtifactReference,\n\tsourceMap: ArtifactReference\n});\nconst ServerBuildManifest = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tschema: ArtifactReference,\n\tfunctions: Schema.Array(ServerFunctionArtifact)\n});\nconst deploymentInventoryPath = ArtifactPath.make(\"inventory.json\");\nconst clientShellPath = ArtifactPath.make(\"client/_shell.html\");\nconst serverManifestPath = ArtifactPath.make(\"server/manifest.json\");\nconst schemaSnapshotPath = ArtifactPath.make(\"server/schema.json\");\nconst deploymentArtifactLimits = {\n\tfileBytes: 16777216,\n\tfileCount: 512,\n\tinventoryBytes: 1048576,\n\tserverBytes: 67108864,\n\ttotalBytes: 134217728\n};\n//#endregion\nexport { ArtifactFile, ArtifactKind, ArtifactPath, ArtifactReference, DeploymentInventory, SchemaSnapshot, SchemaSnapshotField, SchemaSnapshotTable, ServerBuildManifest, ServerFunctionArtifact, Sha256, clientShellPath, deploymentArtifactLimits, deploymentInventoryPath, schemaSnapshotPath, serverManifestPath };\n\n//# sourceMappingURL=deployment.js.map","import { AppId, DeploymentId, RuntimeRequestNonce } from \"./id.js\";\nimport { Sha256 } from \"../deployment.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { RuntimeInvocationRejectionCode } from \"./hosted.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/transport.ts\nconst runtimeInvocationPath = \"/v1/invoke\";\nconst runtimeRevisionPath = \"/v1/revision\";\nconst gatewayHealthPath = \"/_ignotum/health\";\nconst appSyncPath = \"/_ignotum/v1/sync\";\nconst RuntimeRequestPath = Schema.Literals([runtimeInvocationPath, runtimeRevisionPath]);\nconst RuntimeRequestTimestamp = Schema.FiniteFromString.pipe(Schema.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), Schema.brand(\"ignotum/runtime/RequestTimestamp\"));\nconst RuntimeRequestSignature = Sha256.pipe(Schema.brand(\"ignotum/runtime/RequestSignature\"));\nconst RuntimeRequestHeaders = Schema.Struct({\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tnonce: RuntimeRequestNonce,\n\ttimestamp: RuntimeRequestTimestamp,\n\tsignature: RuntimeRequestSignature\n});\nconst RuntimeSigningInput = Schema.Struct({\n\tmethod: Schema.Literal(\"POST\"),\n\tpath: RuntimeRequestPath,\n\ttimestamp: RuntimeRequestTimestamp,\n\tnonce: RuntimeRequestNonce,\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tbodySha256: Sha256\n});\nconst runtimeRequestHeaderNames = {\n\tappId: \"x-ignotum-app-id\",\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tnonce: \"x-ignotum-nonce\",\n\tsignature: \"x-ignotum-signature\",\n\ttimestamp: \"x-ignotum-timestamp\"\n};\nconst appSyncRequestHeaderNames = {\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tgeneration: \"x-ignotum-deployment-generation\"\n};\nconst runtimeRequestMaxSkewMillis = 3e4;\nconst encodeRuntimeSigningInput = (input) => encodeCanonicalJson(input.deploymentId === void 0 ? {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n} : {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tdeploymentId: input.deploymentId,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n});\nconst RuntimeErrorCode = Schema.Literals([\n\t\"InvalidRequest\",\n\t\"InvalidSignature\",\n\t\"RequestExpired\",\n\t\"RequestReplay\",\n\t\"InvocationRejected\",\n\t\"RuntimeUnavailable\"\n]);\nconst RuntimeErrorResponse = Schema.Struct({\n\tcode: RuntimeErrorCode,\n\tmessage: Schema.String,\n\trejectionCode: Schema.optional(RuntimeInvocationRejectionCode)\n});\n//#endregion\nexport { RuntimeErrorCode, RuntimeErrorResponse, RuntimeRequestHeaders, RuntimeRequestNonce, RuntimeRequestPath, RuntimeRequestSignature, RuntimeRequestTimestamp, RuntimeSigningInput, appSyncPath, appSyncRequestHeaderNames, encodeRuntimeSigningInput, gatewayHealthPath, runtimeInvocationPath, runtimeRequestHeaderNames, runtimeRequestMaxSkewMillis, runtimeRevisionPath };\n\n//# sourceMappingURL=transport.js.map","import { appSyncPath } from \"@ignotum/contracts/runtime/transport\";\n\nexport const ignotumPathPrefix = \"/_ignotum\";\nexport const syncPath = appSyncPath;\n\nexport const isIgnotumPath = (pathname: string): boolean =>\n pathname === ignotumPathPrefix || pathname.startsWith(`${ignotumPathPrefix}/`);\n","import {\n Context,\n Deferred,\n Duration,\n Effect,\n Fiber,\n HashMap,\n Layer,\n ManagedRuntime,\n Schedule,\n Schema,\n} from \"effect\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\nimport * as BrowserCrypto from \"@effect/platform-browser/BrowserCrypto\";\n\nimport { encodeCanonicalJson } from \"@ignotum/contracts/json\";\nimport { type AppStateRevision } from \"@ignotum/contracts/runtime/hosted\";\nimport { IdGenerator } from \"@ignotum/shared/id\";\n\nimport type {\n ErrorValue,\n QueryResult,\n Result as IgnotumResult,\n} from \"@ignotum/contracts/runtime/result\";\nimport { failureFromWire, pending, Result } from \"@ignotum/contracts/runtime/result\";\nimport {\n ClientMessageJson,\n DeploymentChangedCloseCode,\n InvocationId,\n ServerMessageJson,\n SubscriptionId,\n decodeTransportValue,\n type ClientMessage,\n type FunctionAddress,\n type ServerMessage,\n type SyncHandshake,\n type WireResult,\n} from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidServerMessage,\n ServerProtocolError,\n clientErrorReporterLayer,\n reportClientError,\n} from \"./errors.js\";\nimport { syncPath } from \"../internal/http-paths.js\";\n\ntype Listener = () => void;\ntype SocketWriter = (chunk: string) => Effect.Effect<void, Socket.SocketError>;\n\ninterface QueryEntry {\n readonly args: Schema.Json;\n readonly function: FunctionAddress;\n readonly listeners: Set<Listener>;\n readonly subscriptionId: SubscriptionId;\n generation: number;\n revision: AppStateRevision | undefined;\n references: number;\n result: QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n}\n\ninterface QueryObserver {\n readonly getSnapshot: () => QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n readonly release: Effect.Effect<void>;\n readonly subscribe: (listener: Listener) => () => void;\n}\n\ntype QueryLifecycleMessage = Extract<ClientMessage, { readonly type: \"Subscribe\" | \"Unsubscribe\" }>;\n\ninterface QueryCache {\n readonly entries: () => Iterable<QueryEntry>;\n readonly getById: (id: SubscriptionId) => QueryEntry | undefined;\n readonly setError: (id: SubscriptionId, error: ClientInfrastructureError) => void;\n readonly setResult: (\n id: SubscriptionId,\n result: QueryResult<unknown, ErrorValue>,\n revision: AppStateRevision,\n ) => void;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver>;\n}\n\nconst queryKey = (functionAddress: FunctionAddress, args: Schema.Json): string =>\n encodeCanonicalJson([functionAddress, args]);\n\nconst subscribeMessage = (entry: QueryEntry): QueryLifecycleMessage => ({\n type: \"Subscribe\",\n id: entry.subscriptionId,\n function: entry.function,\n args: entry.args,\n});\n\nconst makeQueryCache = (\n allocateId: Effect.Effect<SubscriptionId>,\n sendLifecycleMessage: (message: QueryLifecycleMessage) => Effect.Effect<void>,\n) => {\n const queries = new Map<string, QueryEntry>();\n const queryKeysById = new Map<SubscriptionId, string>();\n\n const observe = Effect.fn(\"SyncClient.QueryCache.observe\")(function* (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) {\n const key = queryKey(functionAddress, args);\n let entry = queries.get(key);\n\n if (entry === undefined) {\n const created: QueryEntry = {\n args,\n function: functionAddress,\n generation: 0,\n listeners: new Set(),\n revision: undefined,\n references: 0,\n result: pending(),\n subscriptionId: yield* allocateId,\n };\n queries.set(key, created);\n queryKeysById.set(created.subscriptionId, key);\n yield* sendLifecycleMessage(subscribeMessage(created));\n entry = created;\n }\n\n const observed = entry;\n observed.references += 1;\n observed.generation += 1;\n let released = false;\n return {\n getSnapshot: () => observed.result,\n subscribe: (listener: Listener) => {\n observed.listeners.add(listener);\n return () => observed.listeners.delete(listener);\n },\n release: Effect.gen(function* () {\n if (released) return;\n released = true;\n observed.references -= 1;\n if (observed.references !== 0) return;\n const generation = ++observed.generation;\n\n // Preact and HMR may release and reacquire an observer during one render handoff.\n // Keep the server subscription alive long enough for that handoff to reuse it.\n yield* Effect.sleep(\"25 millis\");\n if (\n observed.references !== 0 ||\n observed.generation !== generation ||\n queries.get(key) !== observed\n ) {\n return;\n }\n\n queries.delete(key);\n queryKeysById.delete(observed.subscriptionId);\n yield* sendLifecycleMessage({\n type: \"Unsubscribe\",\n id: observed.subscriptionId,\n });\n }),\n } satisfies QueryObserver;\n });\n\n return {\n entries: () => queries.values(),\n getById: (id: SubscriptionId) => {\n const key = queryKeysById.get(id);\n return key === undefined ? undefined : queries.get(key);\n },\n observe,\n setError: (id, error) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n entry.result = error;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n setResult: (id, result, revision) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n if (entry.revision !== undefined && revision < entry.revision) {\n return;\n }\n entry.revision = revision;\n entry.result = result;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n } satisfies QueryCache;\n};\n\nconst resultFromWire = Effect.fn(\"SyncClient.resultFromWire\")((wire: WireResult) =>\n Effect.succeed(\n wire.type === \"Success\"\n ? Result.succeed(\n wire.value === undefined ? undefined : decodeTransportValue(wire.value, wire.dates ?? []),\n )\n : failureFromWire(wire.error, wire.dates),\n ),\n);\n\nexport const shouldReloadForCloseCode = (code: number): boolean =>\n code === DeploymentChangedCloseCode;\n\nconst handshakesMatch = (first: SyncHandshake, next: SyncHandshake): boolean =>\n first.appId === next.appId &&\n first.deploymentId === next.deploymentId &&\n first.generation === next.generation;\n\ntype HandshakeDecision = \"Accept\" | \"Ignore\" | \"Reload\";\n\nconst handshakeDecision = (\n remembered: SyncHandshake | undefined,\n acceptedOnConnection: boolean,\n next: SyncHandshake,\n): HandshakeDecision => {\n if (remembered !== undefined && !handshakesMatch(remembered, next)) return \"Reload\";\n return acceptedOnConnection ? \"Ignore\" : \"Accept\";\n};\n\nexport const syncClientInternals = {\n makeQueryCache,\n handshakeDecision,\n queryIdentity: queryKey,\n resultFromWire,\n handshakesMatch,\n shouldReloadForCloseCode,\n};\n\nconst socketUrl = (): string => {\n const url = new URL(syncPath, globalThis.location.href);\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n return url.href;\n};\n\ninterface SyncClientService {\n readonly mutate: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<IgnotumResult<unknown, ErrorValue>, ClientInfrastructureError>;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver, ClientInfrastructureError>;\n}\n\ninterface PendingInvocation {\n readonly deferred: Deferred.Deferred<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >;\n readonly function: FunctionAddress;\n readonly message: Extract<ClientMessage, { readonly type: \"Invoke\" }>;\n}\n\nexport class SyncClient extends Context.Service<SyncClient, SyncClientService>()(\n \"ignotum/client/sync/SyncClient\",\n) {\n static readonly layer = Layer.effect(\n SyncClient,\n Effect.gen(function* () {\n const ids = yield* IdGenerator;\n let invocations = HashMap.empty<InvocationId, PendingInvocation>();\n let rememberedHandshake: SyncHandshake | undefined;\n let reloadRequested = false;\n let writer: SocketWriter | undefined;\n\n const encode = (message: ClientMessage) =>\n Schema.encodeEffect(ClientMessageJson)(message).pipe(\n Effect.mapError((cause) =>\n InvalidClientMessage.make({\n cause,\n message: \"Could not encode an Ignotum sync message.\",\n }),\n ),\n );\n\n const sendWith = (write: SocketWriter, message: ClientMessage) =>\n encode(message).pipe(\n Effect.flatMap(write),\n Effect.mapError((cause) =>\n Schema.is(InvalidClientMessage)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n );\n\n const send = (message: ClientMessage) =>\n writer === undefined\n ? Effect.fail(\n ConnectionUnavailable.make({ message: \"The sync connection is not ready.\" }),\n )\n : sendWith(writer, message);\n\n const queryCache = makeQueryCache(ids.generate(SubscriptionId), (message) =>\n writer === undefined\n ? Effect.void\n : send(message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: reportClientError,\n }),\n ),\n );\n\n const rejectInvocation = (id: InvocationId, error: ClientInfrastructureError) => {\n const pendingInvocation = HashMap.getUnsafe(invocations, id);\n if (pendingInvocation === undefined) {\n return Effect.void;\n }\n invocations = HashMap.remove(invocations, id);\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingInvocation.deferred, error)),\n Effect.asVoid,\n );\n };\n\n const handleMessage = Effect.fn(\"SyncClient.handleMessage\")(function* (\n message: Exclude<ServerMessage, SyncHandshake | { readonly type: \"DeploymentChanged\" }>,\n ) {\n switch (message.type) {\n case \"Snapshot\": {\n const entry = queryCache.getById(message.id);\n if (entry === undefined) return;\n yield* resultFromWire(message.result).pipe(\n Effect.tap((result) =>\n Effect.sync(() => queryCache.setResult(message.id, result, message.revision)),\n ),\n );\n return;\n }\n case \"Result\": {\n const pendingInvocation = HashMap.getUnsafe(invocations, message.id);\n if (pendingInvocation === undefined) return;\n invocations = HashMap.remove(invocations, message.id);\n yield* resultFromWire(message.result).pipe(\n Effect.flatMap((result) => Deferred.succeed(pendingInvocation.deferred, result)),\n );\n return;\n }\n case \"ProtocolError\": {\n const error =\n message.operation === undefined\n ? ServerProtocolError.make({\n code: message.code,\n message: message.message,\n })\n : ServerProtocolError.make({\n code: message.code,\n message: message.message,\n operation: message.operation,\n });\n if (message.operation?.type === \"Invocation\") {\n yield* rejectInvocation(message.operation.id, error);\n } else if (message.operation?.type === \"Subscription\") {\n queryCache.setError(message.operation.id, error);\n yield* reportClientError(error);\n } else {\n yield* reportClientError(error);\n }\n return;\n }\n }\n });\n\n const requestReload = () => {\n if (reloadRequested) return;\n reloadRequested = true;\n writer = undefined;\n globalThis.location.reload();\n };\n\n const disconnect = Effect.sync(() => {\n writer = undefined;\n });\n\n const connect = Effect.scoped(\n Effect.gen(function* () {\n if (reloadRequested) return yield* Effect.never;\n const socket = yield* Socket.makeWebSocket(socketUrl(), {\n closeCodeIsError: (code) => {\n if (shouldReloadForCloseCode(code)) requestReload();\n return false;\n },\n });\n const write = yield* socket.writer;\n const handshakeReceived = yield* Deferred.make<void>();\n let handshakeAccepted = false;\n const acceptHandshake = Effect.fn(\"SyncClient.acceptHandshake\")(function* (\n handshake: SyncHandshake,\n ) {\n const decision = handshakeDecision(rememberedHandshake, handshakeAccepted, handshake);\n if (decision === \"Reload\") {\n requestReload();\n return;\n }\n if (decision === \"Ignore\") return;\n rememberedHandshake = handshake;\n handshakeAccepted = true;\n writer = write;\n yield* Deferred.succeed(handshakeReceived, undefined);\n yield* Effect.gen(function* () {\n yield* Effect.forEach(queryCache.entries(), (entry) =>\n sendWith(write, subscribeMessage(entry)),\n );\n yield* Effect.forEach(HashMap.values(invocations), (pendingInvocation) =>\n sendWith(write, pendingInvocation.message),\n );\n }).pipe(Effect.tapError(reportClientError), Effect.ignore);\n });\n\n const handleText = Effect.fn(\"SyncClient.handleText\")(function* (text: string) {\n const message = yield* Schema.decodeEffect(ServerMessageJson)(text).pipe(\n Effect.mapError((cause) =>\n InvalidServerMessage.make({\n cause,\n message: \"The server returned an invalid sync message.\",\n }),\n ),\n );\n if (message.type === \"Handshake\") return yield* acceptHandshake(message);\n if (message.type === \"DeploymentChanged\") {\n requestReload();\n return;\n }\n if (!handshakeAccepted) {\n return yield* InvalidServerMessage.make({\n cause: new Error(\"The server sent a sync message before the handshake.\"),\n message: \"The server returned a sync message before the handshake.\",\n });\n }\n return yield* handleMessage(message);\n });\n\n const run = yield* socket.runString(handleText).pipe(Effect.forkChild);\n yield* Effect.raceFirst(\n Deferred.await(handshakeReceived).pipe(Effect.timeout(\"10 seconds\")),\n Fiber.join(run),\n );\n yield* Fiber.join(run);\n }),\n ).pipe(\n Effect.mapError((cause) =>\n Schema.is(ClientInfrastructureError)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n Effect.ensuring(disconnect),\n );\n\n const reconnectSchedule = Schedule.exponential(\"250 millis\").pipe(\n Schedule.modifyDelay(({ duration }) =>\n Effect.succeed(Duration.min(duration, Duration.seconds(5))),\n ),\n Schedule.jittered,\n );\n yield* connect.pipe(\n Effect.andThen(\n Effect.fail(\n ConnectionUnavailable.make({\n message: \"The sync connection closed; reconnecting.\",\n }),\n ),\n ),\n Effect.tapError(reportClientError),\n Effect.retry(reconnectSchedule),\n Effect.forkScoped,\n );\n\n const observe: SyncClientService[\"observe\"] = Effect.fn(\"SyncClient.observe\")(\n function* (functionAddress, args) {\n return yield* queryCache.observe(functionAddress, args);\n },\n );\n\n const mutate: SyncClientService[\"mutate\"] = Effect.fn(\"SyncClient.mutate\")(\n function* (functionAddress, args) {\n const invocationId = yield* ids.generate(InvocationId);\n const deferred = yield* Deferred.make<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >();\n const message: ClientMessage = {\n type: \"Invoke\",\n id: invocationId,\n kind: \"Mutation\",\n function: functionAddress,\n args,\n };\n invocations = HashMap.set(invocations, invocationId, {\n deferred,\n function: functionAddress,\n message,\n });\n if (writer !== undefined) {\n yield* sendWith(writer, message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: (error) => rejectInvocation(invocationId, error),\n }),\n );\n }\n return yield* Deferred.await(deferred);\n },\n );\n\n return SyncClient.of({ mutate, observe });\n }),\n ).pipe(Layer.provide(Layer.merge(Socket.layerWebSocketConstructorGlobal, BrowserCrypto.layer)));\n}\n\nexport const syncRuntime = ManagedRuntime.make(\n SyncClient.layer.pipe(\n Layer.provideMerge(clientErrorReporterLayer),\n Layer.provideMerge(IdGenerator.layer),\n ),\n);\n\n// SAFETY: Vite adds this optional property to browser development modules.\nconst hot = (\n import.meta as ImportMeta & {\n readonly hot?: { readonly dispose: (cleanup: () => void) => void };\n }\n).hot;\nif (hot !== undefined) {\n hot.dispose(() => void syncRuntime.dispose());\n}\n","import { Effect, Schema } from \"effect\";\nimport { useDebugValue, useEffect, useMemo, useState } from \"preact/hooks\";\n\nimport { functionPathOf, type FunctionReference } from \"../internal/api.js\";\nimport { pending } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, QueryResult, SettledResult } from \"@ignotum/contracts/runtime/result\";\nimport { encodeTransportObject } from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n InvalidMutationArguments,\n reportClientError,\n} from \"./errors.js\";\nimport { isQuerySkip, type QuerySkip } from \"./query.js\";\nimport { SyncClient, syncClientInternals, syncRuntime } from \"./sync.js\";\n\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks are not pipeable functions.\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n): QueryResult<Success, Failure>;\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n args: QuerySkip,\n): QueryResult<Success, Failure>;\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args, Success, Failure>,\n args: NoInfer<Args> | QuerySkip,\n): QueryResult<Success, Failure>;\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks must remain direct calls so hook order is statically visible.\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args | void, Success, Failure>,\n args?: Args | QuerySkip,\n): QueryResult<Success, Failure> {\n const functionPath = functionPathOf(reference);\n const skipped = isQuerySkip(args);\n const input = args === undefined || skipped ? {} : args;\n const jsonArgs = encodeTransportObject(input);\n const identity = skipped\n ? `skip:${functionPath}`\n : syncClientInternals.queryIdentity(functionPath, jsonArgs);\n const [state, setState] = useState<{\n readonly identity: string;\n readonly result: QueryResult<Success, Failure> | ClientInfrastructureError;\n }>(() => ({ identity, result: pending() }));\n\n useDebugValue({ args: input, function: functionPath, result: state.result });\n useEffect(() => {\n if (skipped) return;\n\n let active = true;\n let release: (() => void) | undefined;\n\n void syncRuntime\n .runPromise(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n return yield* client.observe(functionPath, jsonArgs);\n }),\n )\n .then(\n (observer) => {\n if (!active) {\n syncRuntime.runFork(observer.release);\n return;\n }\n const update = () => {\n // SAFETY: the function reference couples this subscription's runtime\n // path to its generated success and failure types.\n const result = observer.getSnapshot() as\n | QueryResult<Success, Failure>\n | ClientInfrastructureError;\n setState({ identity, result });\n };\n release = observer.subscribe(update);\n update();\n const releaseObserver = release;\n release = () => {\n releaseObserver();\n syncRuntime.runFork(observer.release);\n };\n },\n (error) => {\n if (active && Schema.is(ClientInfrastructureError)(error)) {\n setState({ identity, result: error });\n }\n },\n );\n\n return () => {\n active = false;\n release?.();\n };\n }, [identity]);\n\n if (skipped) return pending();\n\n if (state.identity !== identity) {\n return pending();\n }\n\n const result = state.result;\n if (Schema.is(ClientInfrastructureError)(result)) throw result;\n return result;\n}\n\ntype Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void]\n ? () => Promise<SettledResult<Success, Failure>>\n : (args: Args) => Promise<SettledResult<Success, Failure>>;\n\nexport const useMutation = <Args extends object | void, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Mutation\", Args, Success, Failure>,\n): Mutation<Args, Success, Failure> =>\n useMemo(() => {\n const mutate = (args: Args | undefined) => {\n const functionPath = functionPathOf(reference);\n const input = args === undefined ? {} : args;\n return syncRuntime.runPromise<SettledResult<Success, Failure>, ClientInfrastructureError>(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n const jsonArgs = yield* Effect.try({\n try: () => encodeTransportObject(input),\n catch: (cause) =>\n InvalidMutationArguments.make({\n cause,\n function: functionPath,\n message: `Mutation arguments for ${functionPath} contain an unsupported value.`,\n }),\n }).pipe(Effect.tapError(reportClientError));\n // SAFETY: generated function references bind the runtime path to the\n // declared public result types validated by the server executor.\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- The untyped sync transport deliberately erases the generated reference's result parameters.\n return (yield* client.mutate(functionPath, jsonArgs)) as unknown as SettledResult<\n Success,\n Failure\n >;\n }),\n );\n };\n // SAFETY: the builder gives argument-free functions Args = void. At runtime\n // both call shapes normalize omitted arguments to the empty JSON object.\n return mutate as Mutation<Args, Success, Failure>;\n }, [reference]);\n","import type { ComponentType } from \"preact\";\n\nexport interface AppDefinition<Component extends ComponentType<{}> = ComponentType<{}>> {\n readonly component: Component;\n readonly title: string;\n}\n\nexport const app = <Component extends ComponentType<{}>>(\n definition: AppDefinition<Component>,\n): AppDefinition<Component> => {\n if (definition.title.trim().length === 0) {\n throw new Error(\"The app title must contain a non-whitespace character.\");\n }\n return definition;\n};\n","import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type {\n ErrorValue,\n QueryResult as ContractQueryResult,\n SettledResult,\n} from \"@ignotum/contracts/runtime/result\";\n\nexport const Result = { match: contractResult.match };\nexport type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;\nexport type QueryResult<Value, Error extends ErrorValue> = ContractQueryResult<Value, Error>;\nexport type { InternalServerError } from \"@ignotum/contracts/runtime/result\";\nexport { useMutation, useQuery } from \"./hooks.js\";\nexport { Query } from \"./query.js\";\nexport type { QuerySkip } from \"./query.js\";\nexport { app } from \"./app.js\";\nexport type { AppDefinition } from \"./app.js\";\n\nexport {\n Component,\n Fragment,\n cloneElement,\n createContext,\n createElement,\n createRef,\n h,\n isValidElement,\n toChildArray,\n} from \"preact\";\nexport type {\n AnyComponent,\n Attributes,\n ClassAttributes,\n ComponentChild,\n ComponentChildren,\n ComponentClass,\n ComponentConstructor,\n ComponentFactory,\n ComponentProps,\n ComponentType,\n Consumer,\n Context,\n ContextType,\n ErrorInfo,\n FunctionComponent,\n FunctionalComponent,\n JSX,\n Key,\n PreactContext,\n PreactConsumer,\n PreactDOMAttributes,\n PreactProvider,\n Provider,\n Ref,\n RefCallback,\n RefObject,\n RenderableProps,\n TargetedAnimationEvent,\n TargetedClipboardEvent,\n TargetedCommandEvent,\n TargetedCompositionEvent,\n TargetedDragEvent,\n TargetedEvent,\n TargetedFocusEvent,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedMouseEvent,\n TargetedPictureInPictureEvent,\n TargetedPointerEvent,\n TargetedSnapEvent,\n TargetedSubmitEvent,\n TargetedToggleEvent,\n TargetedTouchEvent,\n TargetedTransitionEvent,\n TargetedUIEvent,\n TargetedWheelEvent,\n VNode,\n} from \"preact\";\nexport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useErrorBoundary,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"preact/hooks\";\nexport type { Dispatch, Reducer, StateUpdater } from \"preact/hooks\";\n"],"mappings":";;;;;;;;;;;AAKA,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;CACtC,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,OAAO,OAAO,OAAO;CACrB,UAAU;CACV,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,MAAM;CACN,SAAS,OAAO;CAChB,WAAW,OAAO,SAAS,SAAS;AACtC,CACF,CAAC,CAAC,CAAC;AAEH,MAAa,4BAA4B,OAAO,MAAM;CACpD;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAM,uBAAuB,cAAc,MAAM,EAAE,YAAY,YAAY;CACzE,WAAW,QAAQ,MAAM,gCAAgC,OAAO,UAAU;AAC5E,CAAC;AAED,MAAa,2BAA2B,cAAc,MAAM,CAAC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AO;AACT;;;ACPA,MAAa,SAAS,EAAE,OAAOC,SAAe,MAAM"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { o as RequestId } from "./id-D570vudg.js";
|
|
1
2
|
import { Brand, Effect, Effectable, Function, Option, Predicate, Schema } from "effect";
|
|
2
|
-
//#region ../contracts/dist/value
|
|
3
|
+
//#region ../contracts/dist/runtime/value.js
|
|
3
4
|
const TransportValueSchema = Schema.suspend(() => Schema.Union([
|
|
4
5
|
Schema.Null,
|
|
5
6
|
Schema.Boolean,
|
|
@@ -17,6 +18,25 @@ const encodeTransportValue = (value) => {
|
|
|
17
18
|
return Object.fromEntries(Object.entries(value).flatMap(([key, child]) => child === void 0 ? [] : [[key, encodeTransportValue(child)]]));
|
|
18
19
|
};
|
|
19
20
|
const encodeTransportObject = (value) => Schema.decodeUnknownSync(Schema.JsonObject)(encodeTransportValue(Schema.decodeUnknownSync(TransportValueSchema)(value)));
|
|
21
|
+
const collectDatePaths = (value, path, paths) => {
|
|
22
|
+
if (Predicate.isDate(value)) {
|
|
23
|
+
Schema.decodeSync(Schema.Date)(value);
|
|
24
|
+
paths.push(path);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (globalThis.Array.isArray(value)) {
|
|
28
|
+
for (const [index, child] of value.entries()) collectDatePaths(child, [...path, index], paths);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (value === void 0 || Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return;
|
|
32
|
+
for (const [key, child] of Object.entries(value)) collectDatePaths(child, [...path, key], paths);
|
|
33
|
+
};
|
|
34
|
+
const datePathsOf = (value) => {
|
|
35
|
+
const paths = [];
|
|
36
|
+
collectDatePaths(value, [], paths);
|
|
37
|
+
return paths;
|
|
38
|
+
};
|
|
39
|
+
const datePathsOfObject = (value) => datePathsOf(Schema.decodeUnknownSync(TransportValueSchema)(value));
|
|
20
40
|
const pathKey = (path) => JSON.stringify(path);
|
|
21
41
|
const decodeTransportValueAt = (value, path, encodedDatePaths) => {
|
|
22
42
|
if (encodedDatePaths.has(pathKey(path))) return Schema.decodeUnknownSync(Schema.DateFromMillis)(value);
|
|
@@ -37,7 +57,7 @@ const PendingResultTypeId = Symbol.for("ignotum/runtime/result/Pending");
|
|
|
37
57
|
const ErrorBrand = "ignotum/error";
|
|
38
58
|
const makeErrorValue = Brand.nominal();
|
|
39
59
|
const ErrorValueSchema = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Json)]).pipe(Schema.brand(ErrorBrand));
|
|
40
|
-
var InternalServerErrorCause = class extends Schema.TaggedError()("InternalServerError", { requestId:
|
|
60
|
+
var InternalServerErrorCause = class extends Schema.TaggedError()("InternalServerError", { requestId: RequestId }) {};
|
|
41
61
|
const InternalServerErrorSchema = InternalServerErrorCause.pipe(Schema.brand(ErrorBrand));
|
|
42
62
|
const effectOf = (value) => Predicate.hasProperty(value, ResultTypeId) ? value[ResultTypeId] : Effect.succeed(value);
|
|
43
63
|
function makeResultEffectBase() {
|
|
@@ -73,6 +93,7 @@ const inspectResult = (value) => {
|
|
|
73
93
|
if (!Predicate.hasProperty(value, CompletedResultTypeId)) return void 0;
|
|
74
94
|
return value[CompletedResultTypeId];
|
|
75
95
|
};
|
|
96
|
+
const resultFromEffect = (effect) => new ResultOperation(effect);
|
|
76
97
|
const isFailureResult = (result) => Predicate.hasProperty(result, CompletedResultTypeId) && Predicate.isObject(result[CompletedResultTypeId]) && Predicate.hasProperty(result[CompletedResultTypeId], "type") && result[CompletedResultTypeId].type === "Failure";
|
|
77
98
|
const succeed = (value) => new ResultOperation(Effect.succeed(value), {
|
|
78
99
|
type: "Success",
|
|
@@ -124,6 +145,11 @@ const failureFromWire = (error, datePaths = []) => {
|
|
|
124
145
|
_tag: decoded.value._tag
|
|
125
146
|
}));
|
|
126
147
|
};
|
|
148
|
+
const documentNotFound = (table, id) => Brand.nominal()({
|
|
149
|
+
_tag: "DocumentNotFound",
|
|
150
|
+
table,
|
|
151
|
+
id
|
|
152
|
+
});
|
|
127
153
|
const Result = {
|
|
128
154
|
fail,
|
|
129
155
|
match,
|
|
@@ -131,6 +157,95 @@ const Result = {
|
|
|
131
157
|
try: tryResult
|
|
132
158
|
};
|
|
133
159
|
//#endregion
|
|
134
|
-
|
|
160
|
+
//#region ../contracts/dist/descriptor-t6BOEGw9.js
|
|
161
|
+
const LiteralValue = Schema.Union([
|
|
162
|
+
Schema.String,
|
|
163
|
+
Schema.Finite,
|
|
164
|
+
Schema.Boolean
|
|
165
|
+
]);
|
|
166
|
+
const DescriptorField = Schema.Struct({
|
|
167
|
+
name: Schema.String,
|
|
168
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
169
|
+
});
|
|
170
|
+
const ValueDescriptor = Schema.Union([
|
|
171
|
+
Schema.Struct({
|
|
172
|
+
type: Schema.Literal("array"),
|
|
173
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
174
|
+
}),
|
|
175
|
+
Schema.Struct({ type: Schema.Literal("boolean") }),
|
|
176
|
+
Schema.Struct({ type: Schema.Literal("date") }),
|
|
177
|
+
Schema.Struct({
|
|
178
|
+
type: Schema.Literal("error"),
|
|
179
|
+
tag: Schema.String,
|
|
180
|
+
fields: Schema.Array(DescriptorField)
|
|
181
|
+
}),
|
|
182
|
+
Schema.Struct({
|
|
183
|
+
type: Schema.Literal("id"),
|
|
184
|
+
table: Schema.String
|
|
185
|
+
}),
|
|
186
|
+
Schema.Struct({ type: Schema.Literal("integer") }),
|
|
187
|
+
Schema.Struct({
|
|
188
|
+
type: Schema.Literal("literal"),
|
|
189
|
+
value: LiteralValue
|
|
190
|
+
}),
|
|
191
|
+
Schema.Struct({
|
|
192
|
+
type: Schema.Literal("literals"),
|
|
193
|
+
values: Schema.Array(LiteralValue)
|
|
194
|
+
}),
|
|
195
|
+
Schema.Struct({ type: Schema.Literal("never") }),
|
|
196
|
+
Schema.Struct({ type: Schema.Literal("null") }),
|
|
197
|
+
Schema.Struct({
|
|
198
|
+
type: Schema.Literal("nullable"),
|
|
199
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
200
|
+
}),
|
|
201
|
+
Schema.Struct({ type: Schema.Literal("number") }),
|
|
202
|
+
Schema.Struct({
|
|
203
|
+
type: Schema.Literal("object"),
|
|
204
|
+
fields: Schema.Array(DescriptorField)
|
|
205
|
+
}),
|
|
206
|
+
Schema.Struct({
|
|
207
|
+
type: Schema.Literal("optional"),
|
|
208
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
209
|
+
}),
|
|
210
|
+
Schema.Struct({
|
|
211
|
+
type: Schema.Literal("record"),
|
|
212
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
213
|
+
}),
|
|
214
|
+
Schema.Struct({ type: Schema.Literal("string") }),
|
|
215
|
+
Schema.Struct({
|
|
216
|
+
type: Schema.Literal("union"),
|
|
217
|
+
members: Schema.Array(Schema.suspend(() => ValueDescriptor))
|
|
218
|
+
})
|
|
219
|
+
]);
|
|
220
|
+
const ValueDescriptorTypeId = Symbol.for("ignotum/schema/ValueDescriptor");
|
|
221
|
+
const attachValueDescriptor = Function.dual(2, (value, descriptor) => {
|
|
222
|
+
Object.defineProperty(value, ValueDescriptorTypeId, {
|
|
223
|
+
configurable: false,
|
|
224
|
+
enumerable: false,
|
|
225
|
+
value: descriptor,
|
|
226
|
+
writable: false
|
|
227
|
+
});
|
|
228
|
+
return value;
|
|
229
|
+
});
|
|
230
|
+
const getValueDescriptor = (value) => {
|
|
231
|
+
if (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;
|
|
232
|
+
return Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;
|
|
233
|
+
};
|
|
234
|
+
const descriptorFields = (fields) => {
|
|
235
|
+
const entries = [];
|
|
236
|
+
for (const name of Reflect.ownKeys(fields)) {
|
|
237
|
+
if (!Predicate.isString(name)) throw new Error("Ignotum value objects only support string field names.");
|
|
238
|
+
const field = fields[name];
|
|
239
|
+
const value = field === void 0 ? void 0 : getValueDescriptor(field);
|
|
240
|
+
if (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);
|
|
241
|
+
entries.push({
|
|
242
|
+
name,
|
|
243
|
+
value
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
249
|
+
export { ErrorBrand as a, documentNotFound as c, resultFromEffect as d, TransportValueSchema as f, encodeTransportObject as g, decodeTransportValue as h, getValueDescriptor as i, failureFromWire as l, datePathsOfObject as m, attachValueDescriptor as n, ErrorValueSchema as o, datePathsOf as p, descriptorFields as r, Result as s, ValueDescriptor as t, pending as u };
|
|
135
250
|
|
|
136
|
-
//# sourceMappingURL=
|
|
251
|
+
//# sourceMappingURL=descriptor-t6BOEGw9-BTHR-ZMv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-t6BOEGw9-BTHR-ZMv.js","names":[],"sources":["../../../contracts/dist/runtime/value.js","../../../contracts/dist/runtime/result.js","../../../contracts/dist/descriptor-t6BOEGw9.js"],"sourcesContent":["import { Predicate, Schema } from \"effect\";\n//#region src/runtime/value.ts\nconst TransportValueSchema = Schema.suspend(() => Schema.Union([\n\tSchema.Null,\n\tSchema.Boolean,\n\tSchema.Finite,\n\tSchema.String,\n\tSchema.Date,\n\tSchema.Array(TransportValueSchema),\n\tSchema.Record(Schema.String, Schema.UndefinedOr(TransportValueSchema))\n]));\nconst encodeTransportValue = (value) => {\n\tif (Predicate.isDate(value)) return Schema.encodeSync(Schema.DateFromMillis)(value);\n\tif (globalThis.Array.isArray(value)) return value.map(encodeTransportValue);\n\tif (Predicate.isNumber(value)) return Schema.decodeSync(Schema.Finite)(value);\n\tif (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isBoolean(value)) return value;\n\treturn Object.fromEntries(Object.entries(value).flatMap(([key, child]) => child === void 0 ? [] : [[key, encodeTransportValue(child)]]));\n};\nconst encodeTransportObject = (value) => Schema.decodeUnknownSync(Schema.JsonObject)(encodeTransportValue(Schema.decodeUnknownSync(TransportValueSchema)(value)));\nconst collectDatePaths = (value, path, paths) => {\n\tif (Predicate.isDate(value)) {\n\t\tSchema.decodeSync(Schema.Date)(value);\n\t\tpaths.push(path);\n\t\treturn;\n\t}\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectDatePaths(child, [...path, index], paths);\n\t\treturn;\n\t}\n\tif (value === void 0 || Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectDatePaths(child, [...path, key], paths);\n};\nconst datePathsOf = (value) => {\n\tconst paths = [];\n\tcollectDatePaths(value, [], paths);\n\treturn paths;\n};\nconst datePathsOfObject = (value) => datePathsOf(Schema.decodeUnknownSync(TransportValueSchema)(value));\nconst pathKey = (path) => JSON.stringify(path);\nconst decodeTransportValueAt = (value, path, encodedDatePaths) => {\n\tif (encodedDatePaths.has(pathKey(path))) return Schema.decodeUnknownSync(Schema.DateFromMillis)(value);\n\tif (globalThis.Array.isArray(value)) return value.map((item, index) => decodeTransportValueAt(item, [...path, index], encodedDatePaths));\n\tif (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return value;\n\treturn Object.fromEntries(Object.entries(value).map(([key, item]) => [key, decodeTransportValueAt(item, [...path, key], encodedDatePaths)]));\n};\nconst decodeTransportValue = (value, datePaths) => decodeTransportValueAt(value, [], new Set(datePaths.map(pathKey)));\nconst decodeTransportObject = (value, datePaths) => {\n\tconst encodedDatePaths = new Set(datePaths.map(pathKey));\n\treturn Object.fromEntries(Object.entries(value).map(([key, child]) => [key, decodeTransportValueAt(child, [key], encodedDatePaths)]));\n};\n//#endregion\nexport { TransportValueSchema, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue };\n\n//# sourceMappingURL=value.js.map","import { RequestId } from \"./id.js\";\nimport { decodeTransportObject } from \"./value.js\";\nimport { Brand, Effect, Effectable, Function, Option, Predicate, Schema } from \"effect\";\n//#region src/runtime/result.ts\nconst ResultTypeId = Symbol.for(\"ignotum/runtime/result/Result\");\nconst CompletedResultTypeId = Symbol.for(\"ignotum/runtime/result/Completed\");\nconst PendingResultTypeId = Symbol.for(\"ignotum/runtime/result/Pending\");\nconst ErrorBrand = \"ignotum/error\";\nconst makeErrorValue = Brand.nominal();\nconst ErrorValueSchema = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Json)]).pipe(Schema.brand(ErrorBrand));\nvar InternalServerErrorCause = class extends Schema.TaggedError()(\"InternalServerError\", { requestId: RequestId }) {};\nconst InternalServerError = InternalServerErrorCause;\nconst InternalServerErrorSchema = InternalServerErrorCause.pipe(Schema.brand(ErrorBrand));\nconst effectOf = (value) => Predicate.hasProperty(value, ResultTypeId) ? value[ResultTypeId] : Effect.succeed(value);\nfunction makeResultEffectBase() {\n\tconst Base = function() {};\n\tBase.prototype = Effectable.Prototype({\n\t\tlabel: \"IgnotumResult\",\n\t\tevaluate() {\n\t\t\treturn this[ResultTypeId];\n\t\t}\n\t});\n\treturn Base;\n}\nconst ResultEffectBase = makeResultEffectBase();\nvar ResultOperation = class ResultOperation extends ResultEffectBase {\n\t[ResultTypeId];\n\tconstructor(effect, completed) {\n\t\tsuper();\n\t\tthis[ResultTypeId] = effect;\n\t\tif (completed !== void 0) Object.defineProperty(this, CompletedResultTypeId, { value: completed });\n\t}\n\tcatch(cases) {\n\t\tconst effectCases = {};\n\t\tfor (const [tag, handler] of Object.entries(cases)) if (Predicate.isFunction(handler)) effectCases[tag] = (failure) => effectOf(handler(failure));\n\t\tconst runtimeEffect = this[ResultTypeId];\n\t\tconst caught = Effect.catchTags(runtimeEffect, effectCases);\n\t\treturn new ResultOperation(caught);\n\t}\n};\nvar PendingQueryResult = class {\n\t[PendingResultTypeId] = PendingResultTypeId;\n};\nconst inspectResult = (value) => {\n\tif (!Predicate.hasProperty(value, CompletedResultTypeId)) return void 0;\n\treturn value[CompletedResultTypeId];\n};\nconst effectFromResult = (result) => result[ResultTypeId];\nconst resultFromEffect = (effect) => new ResultOperation(effect);\nconst isFailureResult = (result) => Predicate.hasProperty(result, CompletedResultTypeId) && Predicate.isObject(result[CompletedResultTypeId]) && Predicate.hasProperty(result[CompletedResultTypeId], \"type\") && result[CompletedResultTypeId].type === \"Failure\";\nconst succeed = (value) => new ResultOperation(Effect.succeed(value), {\n\ttype: \"Success\",\n\tvalue\n});\nconst fail = (error) => new ResultOperation(Effect.fail(error), {\n\ttype: \"Failure\",\n\terror\n});\nconst tryResult = (body) => {\n\treturn new ResultOperation(Effect.gen(body));\n};\nconst match = Function.dual(2, (result, matchers) => {\n\tif (result instanceof PendingQueryResult) {\n\t\tif (matchers.pending === void 0) throw new Error(\"A pending Result requires a pending matcher.\");\n\t\treturn matchers.pending();\n\t}\n\tif (!Predicate.hasProperty(result, ResultTypeId)) throw new Error(\"Unknown Result implementation.\");\n\tconst inspected = inspectResult(result);\n\tif (inspected?.type === \"Success\") {\n\t\tconst value = inspected.value;\n\t\treturn matchers.value(value);\n\t}\n\tif (!isFailureResult(result)) throw new Error(\"Unknown or incomplete Result operation.\");\n\tconst error = result[CompletedResultTypeId].error;\n\tif (error._tag === \"InternalServerError\") {\n\t\tconst internalError = Schema.decodeUnknownSync(InternalServerErrorSchema)(error);\n\t\tconst handler = matchers.internalError;\n\t\tif (handler === void 0) throw internalError;\n\t\treturn handler(internalError);\n\t}\n\tconst errorMatcher = matchers.error;\n\tif (errorMatcher === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);\n\tif (Predicate.isFunction(errorMatcher)) return errorMatcher(error);\n\tconst handlers = errorMatcher;\n\tconst handler = Object.hasOwn(handlers, error._tag) ? handlers[error._tag] : void 0;\n\tif (handler === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);\n\treturn handler(error);\n});\nconst pending = () => new PendingQueryResult();\nconst failureFromWire = (error, datePaths = []) => {\n\tconst internalError = Schema.decodeUnknownOption(InternalServerErrorSchema)(error);\n\tif (Option.isSome(internalError)) return fail(internalError.value);\n\tconst decoded = Schema.decodeUnknownOption(ErrorValueSchema)(error);\n\tif (Option.isNone(decoded)) throw new Error(\"The server returned an invalid application error.\");\n\tconst restored = decodeTransportObject(decoded.value, datePaths);\n\treturn fail(makeErrorValue({\n\t\t...restored,\n\t\t_tag: decoded.value._tag\n\t}));\n};\nconst documentNotFound = (table, id) => Brand.nominal()({\n\t_tag: \"DocumentNotFound\",\n\ttable,\n\tid\n});\nconst Result = {\n\tfail,\n\tmatch,\n\tsucceed,\n\ttry: tryResult\n};\n//#endregion\nexport { ErrorBrand, ErrorValueSchema, InternalServerError, InternalServerErrorSchema, Result, documentNotFound, effectFromResult, failureFromWire, inspectResult, match, pending, resultFromEffect };\n\n//# sourceMappingURL=result.js.map","import { Function, Predicate, Schema } from \"effect\";\n//#region src/schema/descriptor.ts\nconst LiteralValue = Schema.Union([\n\tSchema.String,\n\tSchema.Finite,\n\tSchema.Boolean\n]);\nconst DescriptorField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: Schema.suspend(() => ValueDescriptor)\n});\nconst ValueDescriptor = Schema.Union([\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"array\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"boolean\") }),\n\tSchema.Struct({ type: Schema.Literal(\"date\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"error\"),\n\t\ttag: Schema.String,\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"id\"),\n\t\ttable: Schema.String\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"integer\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literal\"),\n\t\tvalue: LiteralValue\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literals\"),\n\t\tvalues: Schema.Array(LiteralValue)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"never\") }),\n\tSchema.Struct({ type: Schema.Literal(\"null\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"nullable\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"number\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"object\"),\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"optional\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"record\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"string\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"union\"),\n\t\tmembers: Schema.Array(Schema.suspend(() => ValueDescriptor))\n\t})\n]);\nconst ValueDescriptorTypeId = Symbol.for(\"ignotum/schema/ValueDescriptor\");\nconst attachValueDescriptor = Function.dual(2, (value, descriptor) => {\n\tObject.defineProperty(value, ValueDescriptorTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: descriptor,\n\t\twritable: false\n\t});\n\treturn value;\n});\nconst getValueDescriptor = (value) => {\n\tif (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;\n\treturn Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;\n};\nconst descriptorFields = (fields) => {\n\tconst entries = [];\n\tfor (const name of Reflect.ownKeys(fields)) {\n\t\tif (!Predicate.isString(name)) throw new Error(\"Ignotum value objects only support string field names.\");\n\t\tconst field = fields[name];\n\t\tconst value = field === void 0 ? void 0 : getValueDescriptor(field);\n\t\tif (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);\n\t\tentries.push({\n\t\t\tname,\n\t\t\tvalue\n\t\t});\n\t}\n\treturn entries.sort((left, right) => left.name.localeCompare(right.name));\n};\n//#endregion\nexport { getValueDescriptor as a, descriptorFields as i, ValueDescriptorTypeId as n, attachValueDescriptor as r, ValueDescriptor as t };\n\n//# sourceMappingURL=descriptor-t6BOEGw9.js.map"],"mappings":";;;AAEA,MAAM,uBAAuB,OAAO,cAAc,OAAO,MAAM;CAC9D,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO;CACP,OAAO,MAAM,oBAAoB;CACjC,OAAO,OAAO,OAAO,QAAQ,OAAO,YAAY,oBAAoB,CAAC;AACtE,CAAC,CAAC;AACF,MAAM,wBAAwB,UAAU;CACvC,IAAI,UAAU,OAAO,KAAK,GAAG,OAAO,OAAO,WAAW,OAAO,cAAc,CAAC,CAAC,KAAK;CAClF,IAAI,WAAW,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,oBAAoB;CAC1E,IAAI,UAAU,SAAS,KAAK,GAAG,OAAO,OAAO,WAAW,OAAO,MAAM,CAAC,CAAC,KAAK;CAC5E,IAAI,UAAU,OAAO,KAAK,KAAK,UAAU,SAAS,KAAK,KAAK,UAAU,UAAU,KAAK,GAAG,OAAO;CAC/F,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,qBAAqB,KAAK,CAAC,CAAC,CAAC,CAAC;AACxI;AACA,MAAM,yBAAyB,UAAU,OAAO,kBAAkB,OAAO,UAAU,CAAC,CAAC,qBAAqB,OAAO,kBAAkB,oBAAoB,CAAC,CAAC,KAAK,CAAC,CAAC;AAChK,MAAM,oBAAoB,OAAO,MAAM,UAAU;CAChD,IAAI,UAAU,OAAO,KAAK,GAAG;EAC5B,OAAO,WAAW,OAA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AwC;EACjG,QAAQ,KAAK;GACZ;GACA;EACD,CAAC;CACF;CACA,OAAO,QAAQ,MAAM,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;AACzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region ../contracts/dist/id-Btwac71X.d.ts
|
|
3
|
+
declare const GeneratedId: Schema.brand<Schema.String, "ignotum/id"> & {
|
|
4
|
+
readonly idPrefix: undefined;
|
|
5
|
+
};
|
|
6
|
+
type GeneratedId = typeof GeneratedId.Type;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { GeneratedId as t };
|
|
9
|
+
//# sourceMappingURL=id-Btwac71X-B9OeBzvq.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region ../contracts/dist/runtime/id.js
|
|
3
|
+
const IdAlphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
4
|
+
const IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));
|
|
5
|
+
const IdPayloadPattern = /^[0-9a-z]{24}$/;
|
|
6
|
+
const withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });
|
|
7
|
+
const defineId = (prefix, brand) => {
|
|
8
|
+
const idPrefix = Schema.decodeSync(IdPrefix)(prefix);
|
|
9
|
+
return withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);
|
|
10
|
+
};
|
|
11
|
+
const GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand("ignotum/id")), void 0);
|
|
12
|
+
const AppId = defineId("app", "ignotum/hosted/AppId");
|
|
13
|
+
const DeploymentId = defineId("dep", "ignotum/hosted/DeploymentId");
|
|
14
|
+
defineId("team", "ignotum/hosted/TeamId");
|
|
15
|
+
const TableId = defineId("table", "ignotum/runtime/TableId");
|
|
16
|
+
defineId("prn", "ignotum/control/PlatformPrincipalId");
|
|
17
|
+
const InvocationId = defineId("inv", "ignotum/sync/InvocationId");
|
|
18
|
+
const SubscriptionId = defineId("sub", "ignotum/sync/SubscriptionId");
|
|
19
|
+
defineId("conn", "ignotum/gateway/ConnectionId");
|
|
20
|
+
const RuntimeRequestNonce = defineId("nonce", "ignotum/runtime/RequestNonce");
|
|
21
|
+
const RequestId = defineId("req", "ignotum/runtime/RequestId");
|
|
22
|
+
defineId("lock", "ignotum/dev/DatabaseLockId");
|
|
23
|
+
//#endregion
|
|
24
|
+
export { InvocationId as a, SubscriptionId as c, IdAlphabet as i, TableId as l, DeploymentId as n, RequestId as o, GeneratedId as r, RuntimeRequestNonce as s, AppId as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=id-D570vudg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-D570vudg.js","names":[],"sources":["../../../contracts/dist/runtime/id.js"],"sourcesContent":["import { Schema } from \"effect\";\n//#region src/runtime/id.ts\nconst IdAlphabet = \"0123456789abcdefghijklmnopqrstuvwxyz\";\nconst IdLength = 24;\nconst IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));\nconst IdPayloadPattern = /^[0-9a-z]{24}$/;\nconst withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });\nconst defineId = (prefix, brand) => {\n\tconst idPrefix = Schema.decodeSync(IdPrefix)(prefix);\n\treturn withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);\n};\nconst GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand(\"ignotum/id\")), void 0);\nconst AppId = defineId(\"app\", \"ignotum/hosted/AppId\");\nconst DeploymentId = defineId(\"dep\", \"ignotum/hosted/DeploymentId\");\nconst TeamId = defineId(\"team\", \"ignotum/hosted/TeamId\");\nconst TableId = defineId(\"table\", \"ignotum/runtime/TableId\");\nconst PlatformPrincipalId = defineId(\"prn\", \"ignotum/control/PlatformPrincipalId\");\nconst InvocationId = defineId(\"inv\", \"ignotum/sync/InvocationId\");\nconst SubscriptionId = defineId(\"sub\", \"ignotum/sync/SubscriptionId\");\nconst ConnectionId = defineId(\"conn\", \"ignotum/gateway/ConnectionId\");\nconst RuntimeRequestNonce = defineId(\"nonce\", \"ignotum/runtime/RequestNonce\");\nconst RequestId = defineId(\"req\", \"ignotum/runtime/RequestId\");\nconst DevDatabaseLockId = defineId(\"lock\", \"ignotum/dev/DatabaseLockId\");\n//#endregion\nexport { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, GeneratedId, IdAlphabet, IdLength, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId, defineId };\n\n//# sourceMappingURL=id.js.map"],"mappings":";;AAEA,MAAM,aAAa;AAEnB,MAAM,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,UAAU,CAAC;AACjE,MAAM,mBAAmB;AACzB,MAAM,cAAc,YAAY,aAAa,OAAO,OAAO,YAAY,EAAE,SAAS,CAAC;AACnF,MAAM,YAAY,QAAQ,UAAU;CACnC,MAAM,WAAW,OAAO,WAAW,QAAQ,CAAC,CAAC,MAAM;CACnD,OAAO,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,IAAI,OAAO,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,CAAC,GAAG,QAAQ;AACtI;AACA,MAAM,cAAc,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,gBAAgB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,GAAG,KAAK,CAAC;AAC/H,MAAM,QAAQ,SAAS,OAAO,sBAAsB;AACpD,MAAM,eAAe,SAAS,OAAO,6BAA6B;AACnD,SAAS,QAAQ,uBAAuB;AACvD,MAAM,UAAU,SAAS,SAAS,yBAAyB;AAC/B,SAAS,OAAO,qCAAqC;AACjF,MAAM,eAAe,SAAS,OAAO,2BAA2B;AAChE,MAAM,iBAAiB,SAAS,OAAO,6BAA6B;AAC/C,SAAS,QAAQ,8BAA8B;AACpE,MAAM,sBAAsB,SAAS,SAAS,8BAA8B;AAC5E,MAAM,YAAY,SAAS,OAAO,2BAA2B;AACnC,SAAS,QAAQ,4BAA4B"}
|