ignotum 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +85 -101
  2. package/dist/cli/bin.mjs +1487 -168
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/runtime/{api-DtX8qPrq.js → api-BTeMI5tx.js} +27 -3
  5. package/dist/runtime/api-BTeMI5tx.js.map +1 -0
  6. package/dist/runtime/{api-D2bsAz4T.d.ts → api-D9lV-5av.d.ts} +7 -10
  7. package/dist/runtime/client.d.ts +27 -3
  8. package/dist/runtime/client.js +468 -68
  9. package/dist/runtime/client.js.map +1 -1
  10. package/dist/runtime/{descriptor-t6BOEGw9-BTHR-ZMv.js → descriptor-C5VA9qRl-C338iC6l.js} +63 -5
  11. package/dist/runtime/descriptor-C5VA9qRl-C338iC6l.js.map +1 -0
  12. package/dist/runtime/file-BXf63ulU.js +166 -0
  13. package/dist/runtime/file-BXf63ulU.js.map +1 -0
  14. package/dist/runtime/{result-BgcHn25t.d.ts → id-Btwac71X-DGj0DQuu.d.ts} +56 -4
  15. package/dist/runtime/{index-Dl_VQGmA.d.ts → index-CF04_Dps.d.ts} +96 -86
  16. package/dist/runtime/internal/api.d.ts +2 -2
  17. package/dist/runtime/internal/api.js +1 -1
  18. package/dist/runtime/internal/host.d.ts +25 -8
  19. package/dist/runtime/internal/host.js +209 -15
  20. package/dist/runtime/internal/host.js.map +1 -1
  21. package/dist/runtime/internal/server.d.ts +1 -1
  22. package/dist/runtime/internal/server.js +1 -1
  23. package/dist/runtime/internal/types.d.ts +1 -1
  24. package/dist/runtime/internal/types.js +1 -1
  25. package/dist/runtime/pagination-BNFhAjns.d.ts +1 -0
  26. package/dist/runtime/pagination-DrOowBve-Bnipd34u.d.ts +84 -0
  27. package/dist/runtime/{schema-B-jMZEbs.js → schema-DJfwfq87.js} +108 -30
  28. package/dist/runtime/schema-DJfwfq87.js.map +1 -0
  29. package/dist/runtime/server.d.ts +3 -3
  30. package/dist/runtime/server.js +2 -2
  31. package/dist/runtime/server.js.map +1 -1
  32. package/dist/runtime/sync-mIXn9eKv.d.ts +8 -0
  33. package/package.json +2 -2
  34. package/src/cli/agent-files.ts +56 -13
  35. package/src/cli/app-configuration.ts +4 -1
  36. package/src/cli/build/server.ts +83 -6
  37. package/src/cli/new-app.ts +15 -0
  38. package/src/client/files.ts +168 -0
  39. package/src/client/hooks.ts +166 -17
  40. package/src/client/index.ts +9 -1
  41. package/src/client/sync.ts +137 -21
  42. package/src/dev-runtime/database.ts +621 -78
  43. package/src/dev-runtime/files.ts +338 -0
  44. package/src/dev-runtime/functions.ts +14 -6
  45. package/src/dev-runtime/migrations.ts +44 -0
  46. package/src/dev-runtime/sync.ts +123 -5
  47. package/src/internal/api.ts +16 -1
  48. package/src/server/index.ts +8 -1
  49. package/dist/runtime/api-DtX8qPrq.js.map +0 -1
  50. package/dist/runtime/descriptor-t6BOEGw9-BTHR-ZMv.js.map +0 -1
  51. package/dist/runtime/id-Btwac71X-B9OeBzvq.d.ts +0 -9
  52. package/dist/runtime/id-D570vudg.js +0 -26
  53. package/dist/runtime/id-D570vudg.js.map +0 -1
  54. package/dist/runtime/schema-B-jMZEbs.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { a as InvocationId, c as SubscriptionId, n as DeploymentId, t as AppId } from "./id-D570vudg.js";
1
+ import { _ as AppId, a as RuntimeFileMetadata, o as RuntimeFileOccurrence, v as DeploymentId, w as SubscriptionId, x as InvocationId } from "./file-BXf63ulU.js";
2
2
  import { Predicate, Schema } from "effect";
3
3
  //#region ../contracts/dist/runtime/identity.js
4
4
  const InvocationKey = Schema.String.pipe(Schema.brand("ignotum/hosted/InvocationKey"));
@@ -36,9 +36,18 @@ const Invoke = Schema.Struct({
36
36
  function: FunctionAddress,
37
37
  args: Schema.Json
38
38
  });
39
+ const PrepareMutation = Schema.Struct({
40
+ type: Schema.Literal("PrepareMutation"),
41
+ id: InvocationId,
42
+ kind: Schema.Literal("Mutation"),
43
+ function: FunctionAddress,
44
+ args: Schema.Json,
45
+ files: Schema.Array(RuntimeFileOccurrence)
46
+ });
39
47
  const ClientMessage = Schema.Union([
40
48
  Subscribe,
41
49
  Unsubscribe,
50
+ PrepareMutation,
42
51
  Invoke
43
52
  ]);
44
53
  const SubscriptionOperation = Schema.Struct({
@@ -73,7 +82,21 @@ const Snapshot = Schema.Struct({
73
82
  type: Schema.Literal("Snapshot"),
74
83
  id: SubscriptionId,
75
84
  result: WireResult,
76
- revision: AppStateRevision
85
+ revision: AppStateRevision,
86
+ files: Schema.optional(Schema.Array(Schema.Struct({
87
+ path: RuntimeFileOccurrence.fields.path,
88
+ file: RuntimeFileMetadata,
89
+ url: Schema.String
90
+ })))
91
+ });
92
+ const MutationPrepared = Schema.Struct({
93
+ type: Schema.Literal("MutationPrepared"),
94
+ id: InvocationId,
95
+ uploads: Schema.Array(Schema.Struct({
96
+ path: RuntimeFileOccurrence.fields.path,
97
+ file: RuntimeFileMetadata,
98
+ url: Schema.optional(Schema.String)
99
+ }))
77
100
  });
78
101
  const SyncResultSuccess = Schema.Struct({
79
102
  type: Schema.Literal("Result"),
@@ -111,6 +134,7 @@ const DeploymentChangedCloseCode = 4409;
111
134
  const ServerMessage = Schema.Union([
112
135
  SyncHandshake,
113
136
  Snapshot,
137
+ MutationPrepared,
114
138
  SyncResultSuccess,
115
139
  SyncResultFailure,
116
140
  ProtocolError,
@@ -147,4 +171,4 @@ function createApi() {
147
171
  //#endregion
148
172
  export { FunctionAddress as a, ServerMessageJson as c, WireSuccess as d, AppStateRevision as f, DeploymentChangedCloseCode as i, WireFailure as l, InvocationKey as m, functionPathOf as n, Operation as o, DeploymentGeneration as p, ClientMessageJson as r, ProtocolErrorCode as s, createApi as t, WireResult as u };
149
173
 
150
- //# sourceMappingURL=api-DtX8qPrq.js.map
174
+ //# sourceMappingURL=api-BTeMI5tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-BTeMI5tx.js","names":[],"sources":["../../../contracts/dist/runtime/identity.js","../../../contracts/dist/runtime/sync.js","../../src/internal/api.ts"],"sourcesContent":["import { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId } from \"./id.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/identity.ts\nconst InvocationKey = Schema.String.pipe(Schema.brand(\"ignotum/hosted/InvocationKey\"));\nconst DeploymentGeneration = Schema.Natural.pipe(Schema.brand(\"ignotum/hosted/DeploymentGeneration\"));\nconst AppStateRevision = Schema.Natural.pipe(Schema.brand(\"ignotum/hosted/AppStateRevision\"));\n//#endregion\nexport { AppId, AppStateRevision, ConnectionId, DeploymentGeneration, DeploymentId, DevDatabaseLockId, InvocationId, InvocationKey, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId };\n\n//# sourceMappingURL=identity.js.map","import { AppId, DeploymentId, InvocationId, SubscriptionId } from \"./id.js\";\nimport { AppStateRevision, DeploymentGeneration } from \"./identity.js\";\nimport { RuntimeFileMetadata, RuntimeFileOccurrence } from \"../schema/file.js\";\nimport { TransportValueSchema, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue } from \"./value.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/sync.ts\nconst FunctionNamePart = Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/));\nconst ApiFunctionAddressParts = Schema.TemplateLiteralParser([\n\t\"api.\",\n\tFunctionNamePart,\n\t\".\",\n\tFunctionNamePart\n]);\nconst FunctionAddress = Schema.TemplateLiteral([\n\t\"api.\",\n\tFunctionNamePart,\n\t\".\",\n\tFunctionNamePart\n]);\nconst apiFunctionParts = (address) => {\n\tconst [, moduleName, , functionName] = Schema.decodeSync(ApiFunctionAddressParts)(address);\n\treturn {\n\t\tfunctionName,\n\t\tmoduleName\n\t};\n};\nconst Subscribe = Schema.Struct({\n\ttype: Schema.Literal(\"Subscribe\"),\n\tid: SubscriptionId,\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n});\nconst Unsubscribe = Schema.Struct({\n\ttype: Schema.Literal(\"Unsubscribe\"),\n\tid: SubscriptionId\n});\nconst Invoke = Schema.Struct({\n\ttype: Schema.Literal(\"Invoke\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n});\nconst PrepareMutation = Schema.Struct({\n\ttype: Schema.Literal(\"PrepareMutation\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tfunction: FunctionAddress,\n\targs: Schema.Json,\n\tfiles: Schema.Array(RuntimeFileOccurrence)\n});\nconst ClientMessage = Schema.Union([\n\tSubscribe,\n\tUnsubscribe,\n\tPrepareMutation,\n\tInvoke\n]);\nconst SubscriptionOperation = Schema.Struct({\n\ttype: Schema.Literal(\"Subscription\"),\n\tid: SubscriptionId\n});\nconst InvocationOperation = Schema.Struct({\n\ttype: Schema.Literal(\"Invocation\"),\n\tid: InvocationId\n});\nconst Operation = Schema.Union([SubscriptionOperation, InvocationOperation]);\nconst DatePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));\nconst DatePaths = Schema.Array(DatePath);\nconst WireSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Success\"),\n\tvalue: Schema.optional(Schema.Json),\n\tdates: Schema.optional(DatePaths)\n});\nconst WireFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Failure\"),\n\terror: Schema.Json,\n\tdates: Schema.optional(DatePaths)\n});\nconst WireResult = Schema.Union([WireSuccess, WireFailure]);\nconst SyncHandshake = Schema.Struct({\n\ttype: Schema.Literal(\"Handshake\"),\n\tappId: AppId,\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration\n});\nconst Snapshot = Schema.Struct({\n\ttype: Schema.Literal(\"Snapshot\"),\n\tid: SubscriptionId,\n\tresult: WireResult,\n\trevision: AppStateRevision,\n\tfiles: Schema.optional(Schema.Array(Schema.Struct({\n\t\tpath: RuntimeFileOccurrence.fields.path,\n\t\tfile: RuntimeFileMetadata,\n\t\turl: Schema.String\n\t})))\n});\nconst MutationPrepared = Schema.Struct({\n\ttype: Schema.Literal(\"MutationPrepared\"),\n\tid: InvocationId,\n\tuploads: Schema.Array(Schema.Struct({\n\t\tpath: RuntimeFileOccurrence.fields.path,\n\t\tfile: RuntimeFileMetadata,\n\t\turl: Schema.optional(Schema.String)\n\t}))\n});\nconst SyncResultSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Result\"),\n\tid: InvocationId,\n\tresult: WireSuccess,\n\tcommittedRevision: AppStateRevision\n});\nconst SyncResultFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Result\"),\n\tid: InvocationId,\n\tresult: WireFailure\n});\nconst ProtocolErrorCode = Schema.Literals([\n\t\"DuplicateOperationId\",\n\t\"FunctionUnavailable\",\n\t\"InvalidArguments\",\n\t\"InvalidMessage\",\n\t\"InvocationIdConflict\",\n\t\"ResourceLimitExceeded\",\n\t\"UnknownFunction\",\n\t\"WrongFunctionKind\"\n]);\nconst ProtocolError = Schema.Struct({\n\ttype: Schema.Literal(\"ProtocolError\"),\n\toperation: Schema.optional(Operation),\n\tcode: ProtocolErrorCode,\n\tmessage: Schema.String\n});\nconst DeploymentChanged = Schema.Struct({\n\ttype: Schema.Literal(\"DeploymentChanged\"),\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration\n});\nconst DeploymentChangedCloseCode = 4409;\nconst ServerMessage = Schema.Union([\n\tSyncHandshake,\n\tSnapshot,\n\tMutationPrepared,\n\tSyncResultSuccess,\n\tSyncResultFailure,\n\tProtocolError,\n\tDeploymentChanged\n]);\nconst ClientMessageJson = Schema.fromJsonString(ClientMessage);\nconst ServerMessageJson = Schema.fromJsonString(ServerMessage);\n//#endregion\nexport { ClientMessage, ClientMessageJson, DatePath, DeploymentChanged, DeploymentChangedCloseCode, FunctionAddress, FunctionNamePart, InvocationId, Operation, ProtocolErrorCode, ServerMessage, ServerMessageJson, SubscriptionId, SyncHandshake, TransportValueSchema, WireFailure, WireResult, WireSuccess, apiFunctionParts, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue };\n\n//# sourceMappingURL=sync.js.map","import { Predicate } from \"effect\";\nimport type { Effect } from \"effect\";\n\nimport type { ErrorValue, InternalServerError } from \"@ignotum/contracts/runtime/result\";\nimport { FunctionAddress } from \"@ignotum/contracts/runtime/sync\";\nimport type { FileValue } from \"@ignotum/contracts/schema/file\";\n\nconst FunctionReferenceTypeId: unique symbol = Symbol.for(\"ignotum/internal/api/FunctionReference\");\ndeclare const FunctionReferenceTypesTypeId: unique symbol;\n\ntype FunctionKind = \"Mutation\" | \"Query\";\n\nexport type MutationInput<Value> = Value extends FileValue\n ? Value | File\n : Value extends Date\n ? Value\n : Value extends ReadonlyArray<infer Item>\n ? ReadonlyArray<MutationInput<Item>>\n : Value extends object\n ? { readonly [Key in keyof Value]: MutationInput<Value[Key]> }\n : Value;\n\nexport interface FunctionReference<\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n> {\n readonly [FunctionReferenceTypeId]: FunctionAddress;\n readonly [FunctionReferenceTypesTypeId]?: {\n readonly kind: Kind;\n readonly args: Args;\n readonly value: Success;\n readonly error: Failure;\n };\n}\n\ntype ReferenceTypes<Reference> = Reference extends {\n readonly [FunctionReferenceTypesTypeId]?: infer Types;\n}\n ? Exclude<Types, undefined>\n : never;\n\nexport declare namespace FunctionReference {\n type Args<Reference> =\n ReferenceTypes<Reference> extends { readonly args: infer Args } ? Args : never;\n type Failure<Reference> =\n ReferenceTypes<Reference> extends {\n readonly error: infer Failure;\n }\n ? Failure\n : never;\n type Kind<Reference> =\n ReferenceTypes<Reference> extends { readonly kind: infer Kind } ? Kind : never;\n type Success<Reference> =\n ReferenceTypes<Reference> extends {\n readonly value: infer Success;\n }\n ? Success\n : never;\n}\n\ntype ReferenceOf<Definition> = Definition extends {\n readonly _tag: infer Kind extends FunctionKind;\n readonly handler: (\n ...arguments_: infer HandlerArguments\n ) => Generator<infer Yielded, infer Success, never>;\n}\n ? HandlerArguments extends readonly [infer _Context, ...infer Rest]\n ? FunctionReference<\n Kind,\n Rest extends readonly [infer Args, ...ReadonlyArray<unknown>]\n ? Kind extends \"Mutation\"\n ? MutationInput<Args>\n : Args\n : void,\n Success,\n | (Yielded extends Effect.Effect<unknown, infer Failure extends ErrorValue, never>\n ? Failure\n : never)\n | InternalServerError\n >\n : never\n : never;\n\ntype ApiModule<Module> = {\n readonly [FunctionName in keyof Module as FunctionName extends string\n ? ReferenceOf<Module[FunctionName]> extends never\n ? never\n : FunctionName\n : never]: ReferenceOf<Module[FunctionName]>;\n};\n\nexport type Api<Modules> = {\n readonly [ModuleName in keyof Modules]: ApiModule<Modules[ModuleName]>;\n};\n\nexport const functionPathOf = <\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n>(\n reference: FunctionReference<Kind, Args, Success, Failure>,\n) => reference[FunctionReferenceTypeId];\n\nconst makeModuleReference = (moduleName: string) => {\n const references = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, functionName) => {\n if (!Predicate.isString(functionName)) {\n return undefined;\n }\n\n const existing = references.get(functionName);\n if (existing !== undefined) {\n return existing;\n }\n\n const reference = {\n [FunctionReferenceTypeId]: FunctionAddress.make(`api.${moduleName}.${functionName}`),\n };\n references.set(functionName, reference);\n return reference;\n },\n },\n );\n};\n\nexport function createApi<Modules>(): Api<Modules>;\nexport function createApi() {\n const modules = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, moduleName) => {\n if (!Predicate.isString(moduleName)) {\n return undefined;\n }\n\n const existing = modules.get(moduleName);\n if (existing !== undefined) {\n return existing;\n }\n\n const moduleReference = makeModuleReference(moduleName);\n modules.set(moduleName, moduleReference);\n return moduleReference;\n },\n },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CACF;AACF"}
@@ -1,14 +1,11 @@
1
- import { i as InternalServerError, r as ErrorValue } from "./result-BgcHn25t.js";
2
- import "./id-Btwac71X-B9OeBzvq.js";
3
- import { Effect, Schema } from "effect";
4
- //#region ../contracts/dist/runtime/sync.d.ts
5
- declare const FunctionAddress: Schema.TemplateLiteral<readonly ["api.", Schema.String, ".", Schema.String]>;
6
- type FunctionAddress = typeof FunctionAddress.Type;
7
- //#endregion
1
+ import { a as InternalServerError, g as FileValue, i as ErrorValue } from "./id-Btwac71X-DGj0DQuu.js";
2
+ import { t as FunctionAddress } from "./sync-mIXn9eKv.js";
3
+ import { Effect } from "effect";
8
4
  //#region src/internal/api.d.ts
9
5
  declare const FunctionReferenceTypeId: unique symbol;
10
6
  declare const FunctionReferenceTypesTypeId: unique symbol;
11
7
  type FunctionKind = "Mutation" | "Query";
8
+ type MutationInput<Value> = Value extends FileValue ? Value | File : Value extends Date ? Value : Value extends ReadonlyArray<infer Item> ? ReadonlyArray<MutationInput<Item>> : Value extends object ? { readonly [Key in keyof Value]: MutationInput<Value[Key]>; } : Value;
12
9
  interface FunctionReference<Kind extends FunctionKind, Args, Success, Failure extends ErrorValue> {
13
10
  readonly [FunctionReferenceTypeId]: FunctionAddress;
14
11
  readonly [FunctionReferenceTypesTypeId]?: {
@@ -38,11 +35,11 @@ declare namespace FunctionReference {
38
35
  type ReferenceOf<Definition> = Definition extends {
39
36
  readonly _tag: infer Kind extends FunctionKind;
40
37
  readonly handler: (...arguments_: infer HandlerArguments) => Generator<infer Yielded, infer Success, never>;
41
- } ? HandlerArguments extends readonly [infer _Context, ...infer Rest] ? FunctionReference<Kind, Rest extends readonly [infer Args, ...ReadonlyArray<unknown>] ? Args : void, Success, (Yielded extends Effect.Effect<unknown, infer Failure extends ErrorValue, never> ? Failure : never) | InternalServerError> : never : never;
38
+ } ? HandlerArguments extends readonly [infer _Context, ...infer Rest] ? FunctionReference<Kind, Rest extends readonly [infer Args, ...ReadonlyArray<unknown>] ? Kind extends "Mutation" ? MutationInput<Args> : Args : void, Success, (Yielded extends Effect.Effect<unknown, infer Failure extends ErrorValue, never> ? Failure : never) | InternalServerError> : never : never;
42
39
  type ApiModule<Module> = { readonly [FunctionName in keyof Module as FunctionName extends string ? ReferenceOf<Module[FunctionName]> extends never ? never : FunctionName : never]: ReferenceOf<Module[FunctionName]>; };
43
40
  type Api<Modules> = { readonly [ModuleName in keyof Modules]: ApiModule<Modules[ModuleName]>; };
44
41
  declare const functionPathOf: <Kind extends FunctionKind, Args, Success, Failure extends ErrorValue>(reference: FunctionReference<Kind, Args, Success, Failure>) => `api.${string}.${string}`;
45
42
  declare function createApi<Modules>(): Api<Modules>;
46
43
  //#endregion
47
- export { functionPathOf as i, FunctionReference as n, createApi as r, Api as t };
48
- //# sourceMappingURL=api-D2bsAz4T.d.ts.map
44
+ export { functionPathOf as a, createApi as i, FunctionReference as n, MutationInput as r, Api as t };
45
+ //# sourceMappingURL=api-D9lV-5av.d.ts.map
@@ -1,7 +1,16 @@
1
- import { a as Match, c as SettledResult, i as InternalServerError, o as QueryResult$1, r as ErrorValue } from "./result-BgcHn25t.js";
2
- import { n as FunctionReference } from "./api-D2bsAz4T.js";
1
+ import { a as InternalServerError, g as FileValue, h as FileMimeType, i as ErrorValue, l as SettledResult, m as FileMetadata, o as Match, p as FileFormat, s as QueryResult$1 } from "./id-Btwac71X-DGj0DQuu.js";
2
+ import "./sync-mIXn9eKv.js";
3
+ import { n as FunctionReference } from "./api-D9lV-5av.js";
4
+ import { n as PaginationPage, t as PaginationOptions } from "./pagination-DrOowBve-Bnipd34u.js";
5
+ import "./pagination-BNFhAjns.js";
6
+ import { Context as Context$1, Effect, Layer } from "effect";
3
7
  import { Dispatch, Reducer, StateUpdater, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "preact/hooks";
4
8
  import { AnyComponent, Attributes, ClassAttributes, Component, ComponentChild, ComponentChildren, ComponentClass, ComponentConstructor, ComponentFactory, ComponentProps, ComponentType, ComponentType as ComponentType$1, Consumer, Context, ContextType, ErrorInfo, Fragment, FunctionComponent, FunctionalComponent, JSX, Key, PreactConsumer, PreactContext, PreactDOMAttributes, PreactProvider, Provider, Ref, RefCallback, RefObject, RenderableProps, TargetedAnimationEvent, TargetedClipboardEvent, TargetedCommandEvent, TargetedCompositionEvent, TargetedDragEvent, TargetedEvent, TargetedFocusEvent, TargetedInputEvent, TargetedKeyboardEvent, TargetedMouseEvent, TargetedPictureInPictureEvent, TargetedPointerEvent, TargetedSnapEvent, TargetedSubmitEvent, TargetedToggleEvent, TargetedTouchEvent, TargetedTransitionEvent, TargetedUIEvent, TargetedWheelEvent, VNode, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray } from "preact";
9
+ //#region src/client/files.d.ts
10
+ declare const Files: {
11
+ readonly url: (file: FileValue) => string;
12
+ };
13
+ //#endregion
5
14
  //#region src/client/query.d.ts
6
15
  declare const QuerySkipTypeId: unique symbol;
7
16
  interface QuerySkip {
@@ -15,6 +24,21 @@ declare const Query: {
15
24
  declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>): QueryResult$1<Success, Failure>;
16
25
  declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>, args: QuerySkip): QueryResult$1<Success, Failure>;
17
26
  declare function useQuery<Args extends object, Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", Args, Success, Failure>, args: NoInfer<Args> | QuerySkip): QueryResult$1<Success, Failure>;
27
+ type PaginationStatus = "CanLoadMore" | "Exhausted" | "LoadingMore";
28
+ interface PaginatedQueryValue<Item> {
29
+ readonly items: ReadonlyArray<Item>;
30
+ readonly loadMore: () => void;
31
+ readonly status: PaginationStatus;
32
+ }
33
+ interface PaginatedQueryOptions {
34
+ readonly pageSize?: number;
35
+ }
36
+ type PaginationArguments = {
37
+ readonly pagination: PaginationOptions;
38
+ };
39
+ type ApplicationPaginationArguments<Args extends PaginationArguments> = Omit<Args, "pagination">;
40
+ declare function usePaginatedQuery<Args extends PaginationArguments, Item, Failure extends ErrorValue>(reference: keyof ApplicationPaginationArguments<Args> extends never ? FunctionReference<"Query", Args, PaginationPage<Item>, Failure> : never): QueryResult$1<PaginatedQueryValue<Item>, Failure>;
41
+ declare function usePaginatedQuery<Args extends PaginationArguments, Item, Failure extends ErrorValue>(reference: FunctionReference<"Query", Args, PaginationPage<Item>, Failure>, args: NoInfer<ApplicationPaginationArguments<Args>> | QuerySkip, options?: PaginatedQueryOptions): QueryResult$1<PaginatedQueryValue<Item>, Failure>;
18
42
  type Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void] ? () => Promise<SettledResult<Success, Failure>> : (args: Args) => Promise<SettledResult<Success, Failure>>;
19
43
  declare const useMutation: <Args extends object | void, Success, Failure extends ErrorValue>(reference: FunctionReference<"Mutation", Args, Success, Failure>) => Mutation<Args, Success, Failure>;
20
44
  //#endregion
@@ -32,5 +56,5 @@ declare const Result: {
32
56
  type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;
33
57
  type QueryResult<Value, Error extends ErrorValue> = QueryResult$1<Value, Error>;
34
58
  //#endregion
35
- export { type AnyComponent, type AppDefinition, type Attributes, type ClassAttributes, Component, type ComponentChild, type ComponentChildren, type ComponentClass, type ComponentConstructor, type ComponentFactory, type ComponentProps, type ComponentType, type Consumer, type Context, type ContextType, type Dispatch, type ErrorInfo, Fragment, type FunctionComponent, type FunctionalComponent, type InternalServerError, type JSX, type Key, type PreactConsumer, type PreactContext, type PreactDOMAttributes, type PreactProvider, type Provider, Query, QueryResult, type QuerySkip, type Reducer, type Ref, type RefCallback, type RefObject, type RenderableProps, Result, type StateUpdater, type TargetedAnimationEvent, type TargetedClipboardEvent, type TargetedCommandEvent, type TargetedCompositionEvent, type TargetedDragEvent, type TargetedEvent, type TargetedFocusEvent, type TargetedInputEvent, type TargetedKeyboardEvent, type TargetedMouseEvent, type TargetedPictureInPictureEvent, type TargetedPointerEvent, type TargetedSnapEvent, type TargetedSubmitEvent, type TargetedToggleEvent, type TargetedTouchEvent, type TargetedTransitionEvent, type TargetedUIEvent, type TargetedWheelEvent, type VNode, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, useQuery, useReducer, useRef, useState };
59
+ export { type AnyComponent, type AppDefinition, type Attributes, type ClassAttributes, Component, type ComponentChild, type ComponentChildren, type ComponentClass, type ComponentConstructor, type ComponentFactory, type ComponentProps, type ComponentType, type Consumer, type Context, type ContextType, type Dispatch, type ErrorInfo, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Files, Fragment, type FunctionComponent, type FunctionalComponent, type InternalServerError, type JSX, type Key, type PaginatedQueryOptions, type PaginatedQueryValue, type PaginationStatus, type PreactConsumer, type PreactContext, type PreactDOMAttributes, type PreactProvider, type Provider, Query, QueryResult, type QuerySkip, type Reducer, type Ref, type RefCallback, type RefObject, type RenderableProps, Result, type StateUpdater, type TargetedAnimationEvent, type TargetedClipboardEvent, type TargetedCommandEvent, type TargetedCompositionEvent, type TargetedDragEvent, type TargetedEvent, type TargetedFocusEvent, type TargetedInputEvent, type TargetedKeyboardEvent, type TargetedMouseEvent, type TargetedPictureInPictureEvent, type TargetedPointerEvent, type TargetedSnapEvent, type TargetedSubmitEvent, type TargetedToggleEvent, type TargetedTouchEvent, type TargetedTransitionEvent, type TargetedUIEvent, type TargetedWheelEvent, type VNode, app, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, usePaginatedQuery, useQuery, useReducer, useRef, useState };
36
60
  //# sourceMappingURL=client.d.ts.map