ignotum 0.0.8 → 0.0.9
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 +6 -2
- package/dist/cli/bin.mjs +294 -64
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-BTeMI5tx.js → api-DzcR7spt.js} +22 -23
- package/dist/runtime/api-DzcR7spt.js.map +1 -0
- package/dist/runtime/{api-D9lV-5av.d.ts → api-jCl8Hzry.d.ts} +3 -3
- package/dist/runtime/client.d.ts +5 -5
- package/dist/runtime/client.js +57 -55
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-C5VA9qRl-C338iC6l.js → descriptor-C5VA9qRl-BKbdenuU.js} +2 -2
- package/dist/runtime/{descriptor-C5VA9qRl-C338iC6l.js.map → descriptor-C5VA9qRl-BKbdenuU.js.map} +1 -1
- package/dist/runtime/{file-BXf63ulU.js → file-C1abuMgd.js} +8 -1
- package/dist/runtime/file-C1abuMgd.js.map +1 -0
- package/dist/runtime/{id-Btwac71X-DGj0DQuu.d.ts → id-Cs82tq9Q-Caqfx54f.d.ts} +2 -2
- package/dist/runtime/{index-CF04_Dps.d.ts → index-D6VLTbDB.d.ts} +4 -4
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +4 -4
- package/dist/runtime/internal/host.js +3 -3
- 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/{pagination-DrOowBve-Bnipd34u.d.ts → pagination-Bt3l7QaC-D_zI5zsu.d.ts} +3 -3
- package/dist/runtime/pagination-DcIkTOFs.d.ts +1 -0
- package/dist/runtime/{schema-DJfwfq87.js → schema-B6PK_ZwV.js} +3 -3
- package/dist/runtime/{schema-DJfwfq87.js.map → schema-B6PK_ZwV.js.map} +1 -1
- package/dist/runtime/server.d.ts +2 -2
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/{sync-mIXn9eKv.d.ts → sync-bMQq9tXx.d.ts} +2 -2
- package/package.json +4 -2
- package/src/cli/auth-client.ts +286 -0
- package/src/cli/command.ts +65 -2
- package/src/cli/control-client.ts +19 -6
- package/src/cli/new-app.ts +2 -1
- package/src/client/errors.ts +7 -10
- package/src/client/files.ts +36 -51
- package/src/client/sync.ts +35 -23
- package/src/dev-runtime/files.ts +30 -31
- package/src/dev-runtime/sync.ts +19 -25
- package/dist/runtime/api-BTeMI5tx.js.map +0 -1
- package/dist/runtime/file-BXf63ulU.js.map +0 -1
- package/dist/runtime/pagination-BNFhAjns.d.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as AppId,
|
|
1
|
+
import { _ as AppId, r as FileId, v as DeploymentId, w as SubscriptionId, x as InvocationId } from "./file-C1abuMgd.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,18 +36,18 @@ const Invoke = Schema.Struct({
|
|
|
36
36
|
function: FunctionAddress,
|
|
37
37
|
args: Schema.Json
|
|
38
38
|
});
|
|
39
|
-
const
|
|
40
|
-
type: Schema.Literal("
|
|
39
|
+
const Prepare = Schema.Struct({
|
|
40
|
+
type: Schema.Literal("Prepare"),
|
|
41
41
|
id: InvocationId,
|
|
42
42
|
kind: Schema.Literal("Mutation"),
|
|
43
43
|
function: FunctionAddress,
|
|
44
44
|
args: Schema.Json,
|
|
45
|
-
files: Schema.Array(
|
|
45
|
+
files: Schema.Array(FileId)
|
|
46
46
|
});
|
|
47
47
|
const ClientMessage = Schema.Union([
|
|
48
48
|
Subscribe,
|
|
49
49
|
Unsubscribe,
|
|
50
|
-
|
|
50
|
+
Prepare,
|
|
51
51
|
Invoke
|
|
52
52
|
]);
|
|
53
53
|
const SubscriptionOperation = Schema.Struct({
|
|
@@ -84,17 +84,16 @@ const Snapshot = Schema.Struct({
|
|
|
84
84
|
result: WireResult,
|
|
85
85
|
revision: AppStateRevision,
|
|
86
86
|
files: Schema.optional(Schema.Array(Schema.Struct({
|
|
87
|
-
|
|
88
|
-
file: RuntimeFileMetadata,
|
|
87
|
+
id: FileId,
|
|
89
88
|
url: Schema.String
|
|
90
89
|
})))
|
|
91
90
|
});
|
|
92
|
-
const
|
|
93
|
-
type: Schema.Literal("
|
|
91
|
+
const Preparation = Schema.Struct({
|
|
92
|
+
type: Schema.Literal("Preparation"),
|
|
94
93
|
id: InvocationId,
|
|
94
|
+
kind: Schema.Literal("Mutation"),
|
|
95
95
|
uploads: Schema.Array(Schema.Struct({
|
|
96
|
-
|
|
97
|
-
file: RuntimeFileMetadata,
|
|
96
|
+
id: FileId,
|
|
98
97
|
url: Schema.optional(Schema.String)
|
|
99
98
|
}))
|
|
100
99
|
});
|
|
@@ -109,7 +108,7 @@ const SyncResultFailure = Schema.Struct({
|
|
|
109
108
|
id: InvocationId,
|
|
110
109
|
result: WireFailure
|
|
111
110
|
});
|
|
112
|
-
const
|
|
111
|
+
const ErrorCode = Schema.Literals([
|
|
113
112
|
"DuplicateOperationId",
|
|
114
113
|
"FunctionUnavailable",
|
|
115
114
|
"InvalidArguments",
|
|
@@ -119,26 +118,26 @@ const ProtocolErrorCode = Schema.Literals([
|
|
|
119
118
|
"UnknownFunction",
|
|
120
119
|
"WrongFunctionKind"
|
|
121
120
|
]);
|
|
122
|
-
const
|
|
123
|
-
type: Schema.Literal("
|
|
121
|
+
const SyncError = Schema.Struct({
|
|
122
|
+
type: Schema.Literal("Error"),
|
|
124
123
|
operation: Schema.optional(Operation),
|
|
125
|
-
code:
|
|
124
|
+
code: ErrorCode,
|
|
126
125
|
message: Schema.String
|
|
127
126
|
});
|
|
128
|
-
const
|
|
129
|
-
type: Schema.Literal("
|
|
127
|
+
const Deployment = Schema.Struct({
|
|
128
|
+
type: Schema.Literal("Deployment"),
|
|
130
129
|
deploymentId: DeploymentId,
|
|
131
130
|
generation: DeploymentGeneration
|
|
132
131
|
});
|
|
133
|
-
const
|
|
132
|
+
const DeploymentCloseCode = 4409;
|
|
134
133
|
const ServerMessage = Schema.Union([
|
|
135
134
|
SyncHandshake,
|
|
136
135
|
Snapshot,
|
|
137
|
-
|
|
136
|
+
Preparation,
|
|
138
137
|
SyncResultSuccess,
|
|
139
138
|
SyncResultFailure,
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
SyncError,
|
|
140
|
+
Deployment
|
|
142
141
|
]);
|
|
143
142
|
const ClientMessageJson = Schema.fromJsonString(ClientMessage);
|
|
144
143
|
const ServerMessageJson = Schema.fromJsonString(ServerMessage);
|
|
@@ -169,6 +168,6 @@ function createApi() {
|
|
|
169
168
|
} });
|
|
170
169
|
}
|
|
171
170
|
//#endregion
|
|
172
|
-
export {
|
|
171
|
+
export { ErrorCode as a, ServerMessageJson as c, WireSuccess as d, AppStateRevision as f, DeploymentCloseCode as i, WireFailure as l, InvocationKey as m, functionPathOf as n, FunctionAddress as o, DeploymentGeneration as p, ClientMessageJson as r, Operation as s, createApi as t, WireResult as u };
|
|
173
172
|
|
|
174
|
-
//# sourceMappingURL=api-
|
|
173
|
+
//# sourceMappingURL=api-DzcR7spt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-DzcR7spt.js","names":[],"sources":["../../../contracts/dist/runtime/identity.js","../../../contracts/dist/runtime/sync.js","../../src/internal/api.ts"],"sourcesContent":["import { AppId, AuthAccountId, AuthDeviceCodeId, AuthInternalId, AuthInvitationId, AuthMemberId, AuthSessionId, AuthVerificationId, 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, AuthAccountId, AuthDeviceCodeId, AuthInternalId, AuthInvitationId, AuthMemberId, AuthSessionId, AuthVerificationId, 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 { FileId } 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 Prepare = Schema.Struct({\n\ttype: Schema.Literal(\"Prepare\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tfunction: FunctionAddress,\n\targs: Schema.Json,\n\tfiles: Schema.Array(FileId)\n});\nconst ClientMessage = Schema.Union([\n\tSubscribe,\n\tUnsubscribe,\n\tPrepare,\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\tid: FileId,\n\t\turl: Schema.String\n\t})))\n});\nconst Preparation = Schema.Struct({\n\ttype: Schema.Literal(\"Preparation\"),\n\tid: InvocationId,\n\tkind: Schema.Literal(\"Mutation\"),\n\tuploads: Schema.Array(Schema.Struct({\n\t\tid: FileId,\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 ErrorCode = 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 SyncError = Schema.Struct({\n\ttype: Schema.Literal(\"Error\"),\n\toperation: Schema.optional(Operation),\n\tcode: ErrorCode,\n\tmessage: Schema.String\n});\nconst Deployment = Schema.Struct({\n\ttype: Schema.Literal(\"Deployment\"),\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration\n});\nconst DeploymentCloseCode = 4409;\nconst ServerMessage = Schema.Union([\n\tSyncHandshake,\n\tSnapshot,\n\tPreparation,\n\tSyncResultSuccess,\n\tSyncResultFailure,\n\tSyncError,\n\tDeployment\n]);\nconst ClientMessageJson = Schema.fromJsonString(ClientMessage);\nconst ServerMessageJson = Schema.fromJsonString(ServerMessage);\n//#endregion\nexport { ClientMessage, ClientMessageJson, DatePath, Deployment, DeploymentCloseCode, ErrorCode, FunctionAddress, FunctionNamePart, InvocationId, Operation, 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 },\n );\n}\n"],"mappings":";;;AAGA,MAAM,gBAAgB,OAAO,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACrF,MAAM,uBAAuB,OAAO,QAAQ,KAAK,OAAO,MAAM,qCAAqC,CAAC;AACpG,MAAM,mBAAmB,OAAO,QAAQ,KAAK,OAAO,MAAM,iCAAiC,CAAC;;;ACC5F,MAAM,mBAAmB,OAAO,OAAO,MAAM,OAAO,UAAU,4BAA4B,CAAC;AAC3D,OAAO,sBAAsB;CAC5D;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,kBAAkB,OA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MAAM,oBAAoB,OAAO,eAAe,aAAa;AAC7D,MAAM,oBAAoB,OAAO,eAAe,aAAa;;;AC5I7D,MAAM,0BAAyC,OAAO,IAAI,wCAAwC;AA0FlG,MAAa,kBAMX,cACG,UAAU;AAEf,MAAM,uBAAuB,eAAuB;CAClD,MAAM,6BAAa,IAAI,IAAoB;CAE3C,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,iBAAiB;EAC9B,IAAI,CAAC,UAAU,SAAS,YAAY,GAClC;EAGF,MAAM,WAAW,WAAW,IAAI,YAAY;EAC5C,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,YAAY,GACf,0BAA0B,gBAAgB,KAAK,OAAO,WAAW,GAAG,cAAc,EACrF;EACA,WAAW,IAAI,cAAc,SAAS;EACtC,OAAO;CACT,EACF,CACF;AACF;AAGA,SAAgB,YAAY;CAC1B,MAAM,0BAAU,IAAI,IAAoB;CAExC,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,eAAe;EAC5B,IAAI,CAAC,UAAU,SAAS,UAAU,GAChC;EAGF,MAAM,WAAW,QAAQ,IAAI,UAAU;EACvC,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,kBAAkB,oBAAoB,UAAU;EACtD,QAAQ,IAAI,YAAY,eAAe;EACvC,OAAO;CACT,EACF,CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as InternalServerError, g as FileValue, i as ErrorValue } from "./id-
|
|
2
|
-
import { t as FunctionAddress } from "./sync-
|
|
1
|
+
import { a as InternalServerError, g as FileValue, i as ErrorValue } from "./id-Cs82tq9Q-Caqfx54f.js";
|
|
2
|
+
import { t as FunctionAddress } from "./sync-bMQq9tXx.js";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
//#region src/internal/api.d.ts
|
|
5
5
|
declare const FunctionReferenceTypeId: unique symbol;
|
|
@@ -42,4 +42,4 @@ declare const functionPathOf: <Kind extends FunctionKind, Args, Success, Failure
|
|
|
42
42
|
declare function createApi<Modules>(): Api<Modules>;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { functionPathOf as a, createApi as i, FunctionReference as n, MutationInput as r, Api as t };
|
|
45
|
-
//# sourceMappingURL=api-
|
|
45
|
+
//# sourceMappingURL=api-jCl8Hzry.d.ts.map
|
package/dist/runtime/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
2
|
-
import "./sync-
|
|
3
|
-
import { n as FunctionReference } from "./api-
|
|
4
|
-
import { n as PaginationPage, t as PaginationOptions } from "./pagination-
|
|
5
|
-
import "./pagination-
|
|
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-Cs82tq9Q-Caqfx54f.js";
|
|
2
|
+
import "./sync-bMQq9tXx.js";
|
|
3
|
+
import { n as FunctionReference } from "./api-jCl8Hzry.js";
|
|
4
|
+
import { n as PaginationPage, t as PaginationOptions } from "./pagination-Bt3l7QaC-D_zI5zsu.js";
|
|
5
|
+
import "./pagination-DcIkTOFs.js";
|
|
6
6
|
import { Context as Context$1, Effect, Layer } from "effect";
|
|
7
7
|
import { Dispatch, Reducer, StateUpdater, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "preact/hooks";
|
|
8
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";
|
package/dist/runtime/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as RuntimeRequestNonce, T as TableId, _ as AppId, a as RuntimeFileMetadata, b as IdAlphabet, c as fileFormats, d as fileLimits, f as fileMimeTypes, h as makeFileValue, l as fileGrantUrlOf, m as isFileValue, o as RuntimeFileOccurrence, p as grantFileValue, r as FileId, u as fileIdOf, v as DeploymentId, w as SubscriptionId, x as InvocationId, y as GeneratedId } from "./file-
|
|
2
|
-
import { b as decodeTransportValue, c as upgrade, d as Result$1, h as pending, m as inspectResult, o as PaginationPageSize, p as failureFromWire, s as initial, t as ValueDescriptor, x as encodeTransportObject } from "./descriptor-C5VA9qRl-
|
|
3
|
-
import { a as
|
|
1
|
+
import { C as RuntimeRequestNonce, T as TableId, _ as AppId, a as RuntimeFileMetadata, b as IdAlphabet, c as fileFormats, d as fileLimits, f as fileMimeTypes, h as makeFileValue, l as fileGrantUrlOf, m as isFileValue, o as RuntimeFileOccurrence, p as grantFileValue, r as FileId, u as fileIdOf, v as DeploymentId, w as SubscriptionId, x as InvocationId, y as GeneratedId } from "./file-C1abuMgd.js";
|
|
2
|
+
import { b as decodeTransportValue, c as upgrade, d as Result$1, h as pending, m as inspectResult, o as PaginationPageSize, p as failureFromWire, s as initial, t as ValueDescriptor, x as encodeTransportObject } from "./descriptor-C5VA9qRl-BKbdenuU.js";
|
|
3
|
+
import { a as ErrorCode, c as ServerMessageJson, d as WireSuccess, f as AppStateRevision, i as DeploymentCloseCode, l as WireFailure, m as InvocationKey, n as functionPathOf, o as FunctionAddress, p as DeploymentGeneration, r as ClientMessageJson, s as Operation, u as WireResult } from "./api-DzcR7spt.js";
|
|
4
4
|
import { Array as Array$1, Cause, Context, Deferred, Duration, Effect, ErrorReporter, Fiber, HashMap, Layer, ManagedRuntime, Predicate, Schedule, Schema, String } from "effect";
|
|
5
5
|
import { customAlphabet } from "nanoid";
|
|
6
6
|
import { useCallback, useCallback as useCallback$1, useContext, useDebugValue, useDebugValue as useDebugValue$1, useEffect, useEffect as useEffect$1, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMemo as useMemo$1, useReducer, useRef, useState, useState as useState$1 } from "preact/hooks";
|
|
@@ -32,21 +32,18 @@ const Files = { url: (file) => {
|
|
|
32
32
|
} };
|
|
33
33
|
const formatByMime = {};
|
|
34
34
|
for (const format of fileFormats) formatByMime[fileMimeTypes[format]] = format;
|
|
35
|
-
const collectNativeFiles = (value,
|
|
35
|
+
const collectNativeFiles = (value, files) => {
|
|
36
36
|
if (value instanceof File) {
|
|
37
|
-
|
|
38
|
-
path,
|
|
39
|
-
value
|
|
40
|
-
});
|
|
37
|
+
files.push(value);
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
43
40
|
if (isFileValue(value) || Predicate.isDate(value)) return;
|
|
44
41
|
if (globalThis.Array.isArray(value)) {
|
|
45
|
-
for (const
|
|
42
|
+
for (const child of value) collectNativeFiles(child, files);
|
|
46
43
|
return;
|
|
47
44
|
}
|
|
48
45
|
if (!Predicate.isObject(value)) return;
|
|
49
|
-
for (const
|
|
46
|
+
for (const child of Object.values(value)) collectNativeFiles(child, files);
|
|
50
47
|
};
|
|
51
48
|
const replaceNativeFiles = (value, replacements) => {
|
|
52
49
|
if (value instanceof File) return replacements.get(value);
|
|
@@ -58,8 +55,8 @@ const replaceNativeFiles = (value, replacements) => {
|
|
|
58
55
|
const prepareMutationArguments = Effect.fn("SyncClient.prepareMutationArguments")(function* (input) {
|
|
59
56
|
const ids = yield* IdGenerator;
|
|
60
57
|
const native = [];
|
|
61
|
-
collectNativeFiles(input,
|
|
62
|
-
const unique = new Set(native
|
|
58
|
+
collectNativeFiles(input, native);
|
|
59
|
+
const unique = new Set(native);
|
|
63
60
|
if (unique.size > fileLimits.filesPerMutation) throw new Error(`A mutation may upload at most ${fileLimits.filesPerMutation} files.`);
|
|
64
61
|
if ([...unique].reduce((total, file) => total + file.size, 0) > fileLimits.mutationBytes) throw new Error(`Mutation uploads may total at most ${fileLimits.mutationBytes} bytes.`);
|
|
65
62
|
const replacements = /* @__PURE__ */ new Map();
|
|
@@ -80,35 +77,31 @@ const prepareMutationArguments = Effect.fn("SyncClient.prepareMutationArguments"
|
|
|
80
77
|
return {
|
|
81
78
|
value: replaceNativeFiles(input, replacements),
|
|
82
79
|
nativeFiles,
|
|
83
|
-
|
|
84
|
-
const replacement = replacements.get(file);
|
|
85
|
-
if (replacement === void 0) throw new Error("A native file replacement is missing.");
|
|
86
|
-
return {
|
|
87
|
-
path,
|
|
88
|
-
file: {
|
|
89
|
-
id: fileIdOf(replacement),
|
|
90
|
-
format: replacement.format,
|
|
91
|
-
name: replacement.name,
|
|
92
|
-
size: replacement.size
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
})
|
|
80
|
+
fileIds: Array.from(nativeFiles.keys())
|
|
96
81
|
};
|
|
97
82
|
});
|
|
98
|
-
const pathKey = (path) => JSON.stringify(path);
|
|
99
83
|
const applyFileGrants = (value, grants) => {
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
const byId = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const grant of grants) {
|
|
86
|
+
if (byId.has(grant.id)) throw new Error("A query file grant ID is duplicated.");
|
|
87
|
+
byId.set(grant.id, grant.url);
|
|
88
|
+
}
|
|
89
|
+
const matched = /* @__PURE__ */ new Set();
|
|
90
|
+
const visit = (current) => {
|
|
91
|
+
if (isFileValue(current)) {
|
|
92
|
+
const id = fileIdOf(current);
|
|
93
|
+
const url = byId.get(id);
|
|
94
|
+
if (url === void 0) return current;
|
|
95
|
+
matched.add(id);
|
|
96
|
+
return grantFileValue(current, url);
|
|
106
97
|
}
|
|
107
|
-
if (globalThis.Array.isArray(current)) return current.map(
|
|
108
|
-
if (!Predicate.isObject(current) || Predicate.isDate(current)
|
|
109
|
-
return Object.fromEntries(Object.entries(current).map(([key, child]) => [key, visit(child
|
|
98
|
+
if (globalThis.Array.isArray(current)) return current.map(visit);
|
|
99
|
+
if (!Predicate.isObject(current) || Predicate.isDate(current)) return current;
|
|
100
|
+
return Object.fromEntries(Object.entries(current).map(([key, child]) => [key, visit(child)]));
|
|
110
101
|
};
|
|
111
|
-
|
|
102
|
+
const granted = visit(value);
|
|
103
|
+
if (matched.size !== byId.size) throw new Error("A query file grant has no result value.");
|
|
104
|
+
return granted;
|
|
112
105
|
};
|
|
113
106
|
//#endregion
|
|
114
107
|
//#region ../contracts/dist/json.js
|
|
@@ -141,8 +134,8 @@ var InvalidServerMessage = class extends Schema.TaggedError()("InvalidServerMess
|
|
|
141
134
|
cause: Schema.Defect(),
|
|
142
135
|
message: Schema.String
|
|
143
136
|
}) {};
|
|
144
|
-
var
|
|
145
|
-
code:
|
|
137
|
+
var ServerError = class extends Schema.TaggedError()("ServerError", {
|
|
138
|
+
code: ErrorCode,
|
|
146
139
|
message: Schema.String,
|
|
147
140
|
operation: Schema.optional(Operation)
|
|
148
141
|
}) {};
|
|
@@ -151,7 +144,7 @@ const ClientInfrastructureError = Schema.Union([
|
|
|
151
144
|
InvalidClientMessage,
|
|
152
145
|
InvalidMutationArguments,
|
|
153
146
|
InvalidServerMessage,
|
|
154
|
-
|
|
147
|
+
ServerError
|
|
155
148
|
]);
|
|
156
149
|
const browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {
|
|
157
150
|
globalThis.console.error("Ignotum infrastructure error", error, attributes);
|
|
@@ -598,7 +591,7 @@ const makeQueryCache = (allocateId, sendLifecycleMessage) => {
|
|
|
598
591
|
};
|
|
599
592
|
};
|
|
600
593
|
const resultFromWire = Effect.fn("SyncClient.resultFromWire")((wire, files = []) => Effect.succeed(wire.type === "Success" ? Result$1.succeed(wire.value === void 0 ? void 0 : applyFileGrants(decodeTransportValue(wire.value, wire.dates ?? []), files)) : failureFromWire(wire.error, wire.dates)));
|
|
601
|
-
const shouldReloadForCloseCode = (code) => code ===
|
|
594
|
+
const shouldReloadForCloseCode = (code) => code === DeploymentCloseCode;
|
|
602
595
|
const handshakesMatch = (first, next) => first.appId === next.appId && first.deploymentId === next.deploymentId && first.generation === next.generation;
|
|
603
596
|
const handshakeDecision = (remembered, acceptedOnConnection, next) => {
|
|
604
597
|
if (remembered !== void 0 && !handshakesMatch(remembered, next)) return "Reload";
|
|
@@ -649,7 +642,7 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
649
642
|
if (queryCache.getById(message.id) === void 0) return;
|
|
650
643
|
yield* resultFromWire(message.result, message.files ?? []).pipe(Effect.tap((result) => Effect.sync(() => queryCache.setResult(message.id, result, message.revision))));
|
|
651
644
|
return;
|
|
652
|
-
case "
|
|
645
|
+
case "Preparation": {
|
|
653
646
|
const pendingInvocation = HashMap.getUnsafe(invocations, message.id);
|
|
654
647
|
if (pendingInvocation !== void 0) yield* Deferred.succeed(pendingInvocation.prepared, message.uploads);
|
|
655
648
|
return;
|
|
@@ -661,11 +654,11 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
661
654
|
yield* resultFromWire(message.result).pipe(Effect.flatMap((result) => Deferred.succeed(pendingInvocation.deferred, result)));
|
|
662
655
|
return;
|
|
663
656
|
}
|
|
664
|
-
case "
|
|
665
|
-
const error = message.operation === void 0 ?
|
|
657
|
+
case "Error": {
|
|
658
|
+
const error = message.operation === void 0 ? ServerError.make({
|
|
666
659
|
code: message.code,
|
|
667
660
|
message: message.message
|
|
668
|
-
}) :
|
|
661
|
+
}) : ServerError.make({
|
|
669
662
|
code: message.code,
|
|
670
663
|
message: message.message,
|
|
671
664
|
operation: message.operation
|
|
@@ -719,7 +712,7 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
719
712
|
message: "The server returned an invalid sync message."
|
|
720
713
|
})));
|
|
721
714
|
if (message.type === "Handshake") return yield* acceptHandshake(message);
|
|
722
|
-
if (message.type === "
|
|
715
|
+
if (message.type === "Deployment") {
|
|
723
716
|
requestReload();
|
|
724
717
|
return;
|
|
725
718
|
}
|
|
@@ -765,13 +758,13 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
765
758
|
function: functionAddress,
|
|
766
759
|
args: jsonArgs
|
|
767
760
|
};
|
|
768
|
-
const message = preparedArguments.
|
|
769
|
-
type: "
|
|
761
|
+
const message = preparedArguments.fileIds.length === 0 ? invokeMessage : {
|
|
762
|
+
type: "Prepare",
|
|
770
763
|
id: invocationId,
|
|
771
764
|
kind: "Mutation",
|
|
772
765
|
function: functionAddress,
|
|
773
766
|
args: jsonArgs,
|
|
774
|
-
files: preparedArguments.
|
|
767
|
+
files: preparedArguments.fileIds
|
|
775
768
|
};
|
|
776
769
|
invocations = HashMap.set(invocations, invocationId, {
|
|
777
770
|
deferred,
|
|
@@ -784,18 +777,23 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
784
777
|
ConnectionUnavailable: reportClientError,
|
|
785
778
|
InvalidClientMessage: (error) => rejectInvocation(invocationId, error)
|
|
786
779
|
}));
|
|
787
|
-
if (message.type === "
|
|
780
|
+
if (message.type === "Prepare") {
|
|
788
781
|
const uploads = yield* Deferred.await(prepared);
|
|
789
|
-
const
|
|
782
|
+
const expected = new Set(message.files);
|
|
783
|
+
const received = /* @__PURE__ */ new Set();
|
|
790
784
|
for (const upload of uploads) {
|
|
791
|
-
if (upload.
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
785
|
+
if (!expected.has(upload.id) || received.has(upload.id)) return yield* InvalidServerMessage.make({
|
|
786
|
+
cause: /* @__PURE__ */ new Error(`Unexpected prepared file '${upload.id}'.`),
|
|
787
|
+
message: "The server returned invalid application file preparation data."
|
|
788
|
+
});
|
|
789
|
+
received.add(upload.id);
|
|
790
|
+
const file = preparedArguments.nativeFiles.get(upload.id);
|
|
795
791
|
if (file === void 0) return yield* InvalidServerMessage.make({
|
|
796
|
-
cause: /* @__PURE__ */ new Error(`Missing native file '${upload.
|
|
792
|
+
cause: /* @__PURE__ */ new Error(`Missing native file '${upload.id}'.`),
|
|
797
793
|
message: "The server prepared an unknown application file."
|
|
798
794
|
});
|
|
795
|
+
if (upload.url === void 0) continue;
|
|
796
|
+
const uploadUrl = upload.url;
|
|
799
797
|
const response = yield* Effect.tryPromise({
|
|
800
798
|
try: () => fetch(uploadUrl, {
|
|
801
799
|
method: "PUT",
|
|
@@ -816,6 +814,10 @@ var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync
|
|
|
816
814
|
});
|
|
817
815
|
}
|
|
818
816
|
}
|
|
817
|
+
if (received.size !== expected.size) return yield* InvalidServerMessage.make({
|
|
818
|
+
cause: /* @__PURE__ */ new Error("The server omitted a prepared file."),
|
|
819
|
+
message: "The server returned incomplete application file preparation data."
|
|
820
|
+
});
|
|
819
821
|
const pendingInvocation = HashMap.getUnsafe(invocations, invocationId);
|
|
820
822
|
if (pendingInvocation === void 0) return yield* Deferred.await(deferred);
|
|
821
823
|
invocations = HashMap.set(invocations, invocationId, {
|