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,10 +1,69 @@
|
|
|
1
|
-
import { n as ErrorBrand, r as ErrorValue, s as Result, t as DocumentNotFoundValue } from "./result-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { n as ErrorBrand, r as ErrorValue, s as Result, t as DocumentNotFoundValue } from "./result-BgcHn25t.js";
|
|
2
|
+
import { t as GeneratedId } from "./id-Btwac71X-B9OeBzvq.js";
|
|
3
|
+
import { Brand, Effect, Schema, Struct } from "effect";
|
|
4
|
+
//#region ../contracts/dist/descriptor-CVZycwe2.d.ts
|
|
5
|
+
//#region src/schema/descriptor.d.ts
|
|
6
|
+
interface DescriptorField {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly value: ValueDescriptor;
|
|
9
|
+
}
|
|
10
|
+
type ValueDescriptor = {
|
|
11
|
+
readonly type: "array";
|
|
12
|
+
readonly value: ValueDescriptor;
|
|
13
|
+
} | {
|
|
14
|
+
readonly type: "boolean";
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: "date";
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: "error";
|
|
19
|
+
readonly tag: string;
|
|
20
|
+
readonly fields: ReadonlyArray<DescriptorField>;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "id";
|
|
23
|
+
readonly table: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: "integer";
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "literal";
|
|
28
|
+
readonly value: string | number | boolean;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "literals";
|
|
31
|
+
readonly values: ReadonlyArray<string | number | boolean>;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "never";
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "null";
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "nullable";
|
|
38
|
+
readonly value: ValueDescriptor;
|
|
39
|
+
} | {
|
|
40
|
+
readonly type: "number";
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: "object";
|
|
43
|
+
readonly fields: ReadonlyArray<DescriptorField>;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "optional";
|
|
46
|
+
readonly value: ValueDescriptor;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "record";
|
|
49
|
+
readonly value: ValueDescriptor;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "union";
|
|
54
|
+
readonly members: ReadonlyArray<ValueDescriptor>;
|
|
55
|
+
};
|
|
56
|
+
declare const ValueDescriptor: Schema.Codec<ValueDescriptor>;
|
|
57
|
+
declare const ValueDescriptorTypeId: unique symbol;
|
|
58
|
+
interface ValueDescriptorCarrier {
|
|
59
|
+
readonly [ValueDescriptorTypeId]: ValueDescriptor;
|
|
60
|
+
}
|
|
61
|
+
type DescribedValue<Value extends Schema.Constraint = Schema.Constraint> = Value & ValueDescriptorCarrier;
|
|
62
|
+
type ValueFields = {
|
|
63
|
+
readonly [fieldName: PropertyKey]: DescribedValue;
|
|
64
|
+
};
|
|
6
65
|
//#endregion
|
|
7
|
-
//#region ../contracts/dist/types-
|
|
66
|
+
//#region ../contracts/dist/types-DDg3XIFc.d.ts
|
|
8
67
|
//#region src/schema/types.d.ts
|
|
9
68
|
/** A document identifier branded with the table it belongs to. */
|
|
10
69
|
type Id<TableName extends string> = GeneratedId & Brand.Brand<`ignotum/id/${TableName}`>;
|
|
@@ -19,7 +78,7 @@ interface TableDefinitionLike {
|
|
|
19
78
|
interface TablesLike {
|
|
20
79
|
readonly [tableName: string]: TableDefinitionLike;
|
|
21
80
|
}
|
|
22
|
-
type TableNameOf$
|
|
81
|
+
type TableNameOf$2<Definition extends TablesLike> = keyof Definition & string;
|
|
23
82
|
interface SystemFields<TableName extends string> {
|
|
24
83
|
readonly id: Id<TableName>;
|
|
25
84
|
readonly createdAt: Date;
|
|
@@ -27,7 +86,7 @@ interface SystemFields<TableName extends string> {
|
|
|
27
86
|
}
|
|
28
87
|
type DocumentFields<TableName extends string, Table extends TableDefinitionLike> = SystemFields<TableName> & Schema.Struct.Type<Table["fields"]>;
|
|
29
88
|
/** The complete document returned for a table, including Ignotum system fields. */
|
|
30
|
-
type Document<Definition extends TablesLike, TableName extends TableNameOf$
|
|
89
|
+
type Document<Definition extends TablesLike, TableName extends TableNameOf$2<Definition>> = { readonly [FieldName in keyof DocumentFields<TableName, Definition[TableName]>]: DocumentFields<TableName, Definition[TableName]>[FieldName]; };
|
|
31
90
|
//#endregion
|
|
32
91
|
//#region ../contracts/dist/schema/values.d.ts
|
|
33
92
|
//#region src/schema/values.d.ts
|
|
@@ -44,14 +103,32 @@ type UnresolvedReferencesOf<Value> = Value extends UnresolvedReferences<infer Ta
|
|
|
44
103
|
type WithIdTargets<Value, TableName extends string> = [TableName] extends [never] ? Value : Value & IdTargets<TableName>;
|
|
45
104
|
type WithUnresolvedReferences<Value, TableName extends string> = [TableName] extends [never] ? Value : Value & UnresolvedReferences<TableName>;
|
|
46
105
|
type PreserveIdMetadata<Value, Source> = WithUnresolvedReferences<WithIdTargets<Value, IdTargetsOf<Source>>, UnresolvedReferencesOf<Source>>;
|
|
47
|
-
type
|
|
106
|
+
type PreserveValueMetadata<Value extends Schema.Constraint, Source> = Source extends ValueDescriptorCarrier ? DescribedValue<PreserveIdMetadata<Value, Source> & Schema.Constraint> : PreserveIdMetadata<Value, Source>;
|
|
107
|
+
type IdDefinition<TableName extends string> = DescribedValue<Schema.brand<typeof GeneratedId, `ignotum/id/${TableName}`> & IdTargets<TableName>>;
|
|
48
108
|
type ReferenceDefinition<TableName extends string> = IdDefinition<TableName> & UnresolvedReferences<TableName>;
|
|
109
|
+
type AddedFieldValidation<Fields, AddedFields> = Extract<keyof AddedFields, keyof Fields> extends never ? readonly [] : readonly [invalidFields: never];
|
|
110
|
+
type OverriddenFieldValidation<Fields, OverriddenFields> = Exclude<keyof OverriddenFields, keyof Fields> extends never ? readonly [] : readonly [invalidFields: never];
|
|
111
|
+
type PartialFields<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields]: Fields[FieldName] extends Schema.Constraint ? PreserveValueMetadata<Schema.optional<Fields[FieldName]>, Fields[FieldName]> : never; };
|
|
112
|
+
interface FixedObjectValidator<Fields extends Schema.Struct.Fields> extends Schema.Struct<Fields> {
|
|
113
|
+
readonly pick: <const Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys) => ObjectDefinition<Pick<Fields, Keys[number]>>;
|
|
114
|
+
readonly omit: <const Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys) => ObjectDefinition<Omit<Fields, Keys[number]>>;
|
|
115
|
+
readonly extend: <const AddedFields extends ValueFields>(fields: AddedFields, ...validation: AddedFieldValidation<Fields, AddedFields>) => ObjectDefinition<Struct.Assign<Fields, AddedFields>>;
|
|
116
|
+
readonly override: <const OverriddenFields extends Partial<Record<keyof Fields, DescribedValue>>>(fields: OverriddenFields, ...validation: OverriddenFieldValidation<Fields, OverriddenFields>) => ObjectDefinition<Struct.Assign<Fields, OverriddenFields>>;
|
|
117
|
+
readonly partial: () => ObjectDefinition<PartialFields<Fields>>;
|
|
118
|
+
}
|
|
119
|
+
type ObjectDefinition<Fields extends Schema.Struct.Fields> = DescribedValue<PreserveIdMetadata<FixedObjectValidator<Fields>, Fields[keyof Fields]>>;
|
|
120
|
+
type ResolvedFields<Fields extends Schema.Struct.Fields> = { readonly [FieldName in keyof Fields]: Omit<Fields[FieldName], typeof UnresolvedReferencesTypeId>; };
|
|
49
121
|
type LiteralValue = string | number | boolean;
|
|
50
122
|
interface TableDefinition<Fields extends Schema.Struct.Fields> {
|
|
51
123
|
readonly _tag: "Table";
|
|
124
|
+
readonly descriptor: ValueDescriptor;
|
|
52
125
|
readonly fields: Fields;
|
|
53
126
|
readonly schema: Schema.Struct<Fields>;
|
|
54
127
|
}
|
|
128
|
+
interface TableDefinitions {
|
|
129
|
+
readonly [tableName: string]: TableDefinition<Schema.Struct.Fields>;
|
|
130
|
+
}
|
|
131
|
+
type TableNameOf$1<Definition extends TableDefinitions> = keyof Definition & string;
|
|
55
132
|
type ReservedFieldName = "createdAt" | "id" | "updatedAt";
|
|
56
133
|
type ReservedErrorTagName = "InternalServerError";
|
|
57
134
|
declare const ReservedFieldTypeId: unique symbol;
|
|
@@ -65,25 +142,25 @@ interface ReservedErrorTag<Tag extends string> {
|
|
|
65
142
|
type ErrorTagValidation<Tag extends string> = Tag extends ReservedErrorTagName ? ReservedErrorTag<Tag> : unknown;
|
|
66
143
|
type ReservedFieldValidation<Fields extends Schema.Struct.Fields> = { readonly [FieldName in Extract<keyof Fields, ReservedFieldName>]: ReservedField<FieldName>; };
|
|
67
144
|
type ReservedErrorFieldValidation<Fields extends Schema.Struct.Fields> = { readonly [FieldName in Extract<keyof Fields, "_tag">]: ReservedField<FieldName>; };
|
|
68
|
-
type ErrorDefinition<Tag extends string, Fields extends Schema.Struct.Fields> = PreserveIdMetadata<Schema.brand<Schema.TaggedStruct<Tag, Fields>, typeof ErrorBrand> & ((fields: Schema.Struct.MakeIn<Fields>) => Schema.brand<Schema.TaggedStruct<Tag, Fields>, typeof ErrorBrand>["Type"]), Fields[keyof Fields]
|
|
69
|
-
declare const table: <const Fields extends
|
|
70
|
-
declare const string: () => Schema.String
|
|
71
|
-
declare const number: () => Schema.Finite
|
|
72
|
-
declare const integer: () => Schema.Int
|
|
73
|
-
declare const boolean: () => Schema.Boolean
|
|
74
|
-
declare const date: () => Schema.DateFromMillis
|
|
75
|
-
declare const never: () => Schema.Never
|
|
76
|
-
declare const nullValue: () => Schema.Null
|
|
77
|
-
declare const literal: <const Value extends LiteralValue>(value: Value) => Schema.Literal<Value
|
|
78
|
-
declare const literals: <const Members extends readonly [LiteralValue, LiteralValue, ...ReadonlyArray<LiteralValue>]>(...members: Members) => Schema.Literals<Members
|
|
145
|
+
type ErrorDefinition<Tag extends string, Fields extends Schema.Struct.Fields> = DescribedValue<PreserveIdMetadata<Schema.brand<Schema.TaggedStruct<Tag, Fields>, typeof ErrorBrand> & ((fields: Schema.Struct.MakeIn<Fields>) => Schema.brand<Schema.TaggedStruct<Tag, Fields>, typeof ErrorBrand>["Type"]), Fields[keyof Fields]>>;
|
|
146
|
+
declare const table: <const Fields extends ValueFields>(fields: Fields & ReservedFieldValidation<NoInfer<Fields>>) => TableDefinition<Fields>;
|
|
147
|
+
declare const string: () => DescribedValue<Schema.String>;
|
|
148
|
+
declare const number: () => DescribedValue<Schema.Finite>;
|
|
149
|
+
declare const integer: () => DescribedValue<Schema.Int>;
|
|
150
|
+
declare const boolean: () => DescribedValue<Schema.Boolean>;
|
|
151
|
+
declare const date: () => DescribedValue<Schema.DateFromMillis>;
|
|
152
|
+
declare const never: () => DescribedValue<Schema.Never>;
|
|
153
|
+
declare const nullValue: () => DescribedValue<Schema.Null>;
|
|
154
|
+
declare const literal: <const Value extends LiteralValue>(value: Value) => DescribedValue<Schema.Literal<Value>>;
|
|
155
|
+
declare const literals: <const Members extends readonly [LiteralValue, LiteralValue, ...ReadonlyArray<LiteralValue>]>(...members: Members) => DescribedValue<Schema.Literals<Members>>;
|
|
79
156
|
declare const id: <const TableName extends string>(tableName: TableName) => ReferenceDefinition<TableName>;
|
|
80
|
-
declare const array: <Value extends
|
|
81
|
-
declare const object: <const Fields extends
|
|
82
|
-
declare const optional: <Value extends
|
|
83
|
-
declare const nullable: <Value extends
|
|
84
|
-
declare const record: <Value extends
|
|
85
|
-
declare const union: <const Members extends ReadonlyArray<
|
|
86
|
-
declare const error: <const Tag extends string, const Fields extends
|
|
157
|
+
declare const array: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.$Array<Value>, Value>;
|
|
158
|
+
declare const object: <const Fields extends ValueFields>(fields: Fields) => ObjectDefinition<Fields>;
|
|
159
|
+
declare const optional: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.optional<Value>, Value>;
|
|
160
|
+
declare const nullable: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.NullOr<Value>, Value>;
|
|
161
|
+
declare const record: <Value extends DescribedValue>(value: Value) => PreserveValueMetadata<Schema.$Record<Schema.String, Value>, Value>;
|
|
162
|
+
declare const union: <const Members extends ReadonlyArray<DescribedValue>>(...members: Members) => PreserveValueMetadata<Schema.Union<Members>, Members[number]>;
|
|
163
|
+
declare const error: <const Tag extends string, const Fields extends ValueFields>(tag: Tag & ErrorTagValidation<Tag>, fields: Fields & ReservedErrorFieldValidation<NoInfer<Fields>>) => ErrorDefinition<Tag, Fields>;
|
|
87
164
|
declare const values: {
|
|
88
165
|
array: typeof array;
|
|
89
166
|
boolean: typeof boolean;
|
|
@@ -103,8 +180,14 @@ declare const values: {
|
|
|
103
180
|
string: typeof string;
|
|
104
181
|
union: typeof union;
|
|
105
182
|
};
|
|
106
|
-
type
|
|
107
|
-
readonly id: <
|
|
183
|
+
type DocumentDefinition<Definition extends TableDefinitions, TableName extends TableNameOf$1<Definition>> = ObjectDefinition<Struct.Assign<ResolvedFields<Definition[TableName]["fields"]>, {
|
|
184
|
+
readonly id: IdDefinition<TableName>;
|
|
185
|
+
readonly createdAt: typeof Schema.DateFromMillis;
|
|
186
|
+
readonly updatedAt: typeof Schema.DateFromMillis;
|
|
187
|
+
}>>;
|
|
188
|
+
type BoundValues<Definition extends TableDefinitions> = Omit<typeof values, "id"> & {
|
|
189
|
+
readonly doc: <const TableName extends TableNameOf$1<Definition>>(tableName: TableName) => DocumentDefinition<Definition, TableName>;
|
|
190
|
+
readonly id: <const TableName extends TableNameOf$1<Definition>>(tableName: TableName) => IdDefinition<TableName>;
|
|
108
191
|
};
|
|
109
192
|
//#endregion
|
|
110
193
|
//#region ../contracts/dist/schema/index.d.ts
|
|
@@ -241,9 +324,9 @@ interface FunctionBuilders<Definition extends Tables> {
|
|
|
241
324
|
readonly mutation: DefineFunction<"Mutation", Definition>;
|
|
242
325
|
}
|
|
243
326
|
interface SchemaBindings<Definition extends Tables> extends FunctionBuilders<Definition> {
|
|
244
|
-
readonly values: BoundValues<
|
|
327
|
+
readonly values: BoundValues<Definition>;
|
|
245
328
|
}
|
|
246
329
|
declare const bindSchema: <const Definition extends Tables>(schema: DefinedSchema<Definition>) => SchemaBindings<Definition>;
|
|
247
330
|
//#endregion
|
|
248
331
|
export { Document as a, SchemaDefinitionTypeId as c, defineSchema as i, SchemaAuthoring as n, Id as o, bindSchema as r, SchemaDefinitionOf as s, DefinedSchema as t };
|
|
249
|
-
//# sourceMappingURL=index-
|
|
332
|
+
//# sourceMappingURL=index-Dl_VQGmA.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as functionPathOf, n as FunctionReference, r as createApi, t as Api } from "../api-
|
|
1
|
+
import { i as functionPathOf, n as FunctionReference, r as createApi, t as Api } from "../api-D2bsAz4T.js";
|
|
2
2
|
export { Api, FunctionReference, createApi, functionPathOf };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as functionPathOf, t as createApi } from "../api-
|
|
1
|
+
import { n as functionPathOf, t as createApi } from "../api-DtX8qPrq.js";
|
|
2
2
|
export { createApi, functionPathOf };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { d as TransportValue, l as documentNotFound, r as ErrorValue, s as Result, u as TransportObject } from "../result-BgcHn25t.js";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
//#region ../contracts/dist/runtime/functions.d.ts
|
|
4
|
+
//#region src/runtime/functions.d.ts
|
|
5
|
+
declare const FunctionKind: Schema.Literals<readonly ["Mutation", "Query"]>;
|
|
6
|
+
type FunctionKind = typeof FunctionKind.Type;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../runtime/dist/guest.d.ts
|
|
9
|
+
//#region src/guest.d.ts
|
|
10
|
+
interface GuestFunctionDefinition {
|
|
11
|
+
readonly _tag: FunctionKind;
|
|
12
|
+
readonly args?: Schema.Struct.Fields;
|
|
13
|
+
readonly returns?: Schema.ConstraintCodec<unknown, unknown, never, never>;
|
|
14
|
+
readonly errors?: Schema.ConstraintCodec<unknown, unknown, never, never>;
|
|
15
|
+
readonly handler: (context: GuestQueryContext | GuestMutationContext, args: GuestFunctionArguments) => Generator<Effect.Effect<unknown, ErrorValue, never>, TransportValue | void, never>;
|
|
16
|
+
}
|
|
17
|
+
type GuestHostCall = (request: string) => Promise<string>;
|
|
18
|
+
declare const GuestFunctionArgumentsTypeId: unique symbol;
|
|
19
|
+
interface GuestFunctionArguments {
|
|
20
|
+
readonly [GuestFunctionArgumentsTypeId]?: never;
|
|
21
|
+
}
|
|
22
|
+
interface GuestDatabaseReader {
|
|
23
|
+
readonly find: (table: string, id: string) => Result<TransportObject | undefined, never>;
|
|
24
|
+
readonly get: (table: string, id: string) => Result<TransportObject, ReturnType<typeof documentNotFound>>;
|
|
25
|
+
readonly query: (table: string) => {
|
|
26
|
+
readonly collect: () => Result<ReadonlyArray<TransportObject>, never>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface GuestDatabaseWriter extends GuestDatabaseReader {
|
|
30
|
+
readonly delete: (table: string, id: string) => Result<void, never>;
|
|
31
|
+
readonly insert: (table: string, value: TransportObject) => Result<string, never>;
|
|
32
|
+
readonly patch: (table: string, id: string, value: TransportObject) => Result<void, never>;
|
|
33
|
+
readonly replace: (table: string, id: string, value: TransportObject) => Result<void, never>;
|
|
34
|
+
}
|
|
35
|
+
interface GuestQueryContext {
|
|
36
|
+
readonly db: GuestDatabaseReader;
|
|
37
|
+
}
|
|
38
|
+
interface GuestMutationContext {
|
|
39
|
+
readonly db: GuestDatabaseWriter;
|
|
40
|
+
}
|
|
41
|
+
declare const invoke: (definition: GuestFunctionDefinition, encodedArgs: Schema.Json, call: GuestHostCall) => Promise<string>;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { invoke };
|
|
44
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { r as GeneratedId } from "../id-D570vudg.js";
|
|
2
|
+
import { c as documentNotFound, d as resultFromEffect, f as TransportValueSchema, m as datePathsOfObject, o as ErrorValueSchema, p as datePathsOf } from "../descriptor-t6BOEGw9-BTHR-ZMv.js";
|
|
3
|
+
import { i as getFunctionSchema, t as SchemaDefinitionTypeId } from "../schema-B-jMZEbs.js";
|
|
4
|
+
import { Effect, Schema } from "effect";
|
|
5
|
+
//#region ../contracts/dist/runtime/host.js
|
|
6
|
+
const HostDocument = Schema.Struct({
|
|
7
|
+
id: GeneratedId,
|
|
8
|
+
createdAt: Schema.Int,
|
|
9
|
+
updatedAt: Schema.Int,
|
|
10
|
+
fields: Schema.JsonObject
|
|
11
|
+
});
|
|
12
|
+
const HostCollect = Schema.Struct({
|
|
13
|
+
type: Schema.Literal("Collect"),
|
|
14
|
+
table: Schema.String
|
|
15
|
+
});
|
|
16
|
+
const HostFind = Schema.Struct({
|
|
17
|
+
type: Schema.Literal("Find"),
|
|
18
|
+
table: Schema.String,
|
|
19
|
+
id: GeneratedId
|
|
20
|
+
});
|
|
21
|
+
const HostInsert = Schema.Struct({
|
|
22
|
+
type: Schema.Literal("Insert"),
|
|
23
|
+
table: Schema.String,
|
|
24
|
+
fields: Schema.JsonObject
|
|
25
|
+
});
|
|
26
|
+
const HostDelete = Schema.Struct({
|
|
27
|
+
type: Schema.Literal("Delete"),
|
|
28
|
+
table: Schema.String,
|
|
29
|
+
id: GeneratedId
|
|
30
|
+
});
|
|
31
|
+
const HostPatch = Schema.Struct({
|
|
32
|
+
type: Schema.Literal("Patch"),
|
|
33
|
+
table: Schema.String,
|
|
34
|
+
id: GeneratedId,
|
|
35
|
+
fields: Schema.JsonObject
|
|
36
|
+
});
|
|
37
|
+
const HostReplace = Schema.Struct({
|
|
38
|
+
type: Schema.Literal("Replace"),
|
|
39
|
+
table: Schema.String,
|
|
40
|
+
id: GeneratedId,
|
|
41
|
+
fields: Schema.JsonObject
|
|
42
|
+
});
|
|
43
|
+
const QuickJsHostRequest = Schema.Union([
|
|
44
|
+
HostCollect,
|
|
45
|
+
HostFind,
|
|
46
|
+
HostInsert,
|
|
47
|
+
HostDelete,
|
|
48
|
+
HostPatch,
|
|
49
|
+
HostReplace
|
|
50
|
+
]);
|
|
51
|
+
const HostDocuments = Schema.Struct({
|
|
52
|
+
type: Schema.Literal("Documents"),
|
|
53
|
+
documents: Schema.Array(HostDocument)
|
|
54
|
+
});
|
|
55
|
+
const HostFound = Schema.Struct({
|
|
56
|
+
type: Schema.Literal("Found"),
|
|
57
|
+
document: Schema.NullOr(HostDocument)
|
|
58
|
+
});
|
|
59
|
+
const HostInserted = Schema.Struct({
|
|
60
|
+
type: Schema.Literal("Inserted"),
|
|
61
|
+
id: GeneratedId
|
|
62
|
+
});
|
|
63
|
+
const HostCompleted = Schema.Struct({ type: Schema.Literal("Completed") });
|
|
64
|
+
Schema.Union([
|
|
65
|
+
HostDocuments,
|
|
66
|
+
HostFound,
|
|
67
|
+
HostInserted,
|
|
68
|
+
HostCompleted
|
|
69
|
+
]);
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region ../runtime/dist/guest.js
|
|
72
|
+
const decodeHostResponse = Schema.decodeEffect(Schema.fromJsonString(Schema.Union([
|
|
73
|
+
HostDocuments,
|
|
74
|
+
HostFound,
|
|
75
|
+
HostInserted,
|
|
76
|
+
HostCompleted
|
|
77
|
+
])));
|
|
78
|
+
const encodeHostRequest = Schema.encodeSync(Schema.fromJsonString(QuickJsHostRequest));
|
|
79
|
+
const callHost = Effect.fn("Guest.callHost")(function* (call, request) {
|
|
80
|
+
return yield* Effect.tryPromise(() => call(encodeHostRequest(request))).pipe(Effect.flatMap(decodeHostResponse), Effect.orDie);
|
|
81
|
+
});
|
|
82
|
+
const tableFor = (schema, table) => {
|
|
83
|
+
const definition = schema[SchemaDefinitionTypeId][table];
|
|
84
|
+
if (definition === void 0) throw new Error(`Unknown database table '${table}'.`);
|
|
85
|
+
return definition;
|
|
86
|
+
};
|
|
87
|
+
const guestCodec = (schema) => schema;
|
|
88
|
+
const encodeFields = (schema, table, fields) => {
|
|
89
|
+
const definition = tableFor(schema, table);
|
|
90
|
+
return Schema.decodeUnknownSync(Schema.JsonObject)(Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(definition.schema)), { onExcessProperty: "error" })(fields));
|
|
91
|
+
};
|
|
92
|
+
const encodePatchFields = (schema, table, fields) => {
|
|
93
|
+
const definition = tableFor(schema, table);
|
|
94
|
+
return Schema.decodeSync(Schema.JsonObject)(Object.fromEntries(Object.entries(fields).map(([name, value]) => {
|
|
95
|
+
const field = definition.fields[name];
|
|
96
|
+
if (field === void 0) throw new Error(`Unknown field '${name}' on table '${table}'.`);
|
|
97
|
+
return [name, Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(field)))(value)];
|
|
98
|
+
})));
|
|
99
|
+
};
|
|
100
|
+
const documentCodec = (schema, table) => guestCodec(Schema.Struct({
|
|
101
|
+
...tableFor(schema, table).fields,
|
|
102
|
+
id: Schema.String,
|
|
103
|
+
createdAt: Schema.DateFromMillis,
|
|
104
|
+
updatedAt: Schema.DateFromMillis
|
|
105
|
+
}));
|
|
106
|
+
const decodeDocument = (schema, table, document) => Schema.decodeUnknownSync(Schema.Record(Schema.String, Schema.UndefinedOr(TransportValueSchema)))(Schema.decodeSync(Schema.toCodecJson(documentCodec(schema, table)))({
|
|
107
|
+
...document.fields,
|
|
108
|
+
id: document.id,
|
|
109
|
+
createdAt: document.createdAt,
|
|
110
|
+
updatedAt: document.updatedAt
|
|
111
|
+
}));
|
|
112
|
+
const expectResponse = (response, tag) => {
|
|
113
|
+
if (response.type !== tag) throw new Error(`Unexpected host response '${response.type}'.`);
|
|
114
|
+
return response;
|
|
115
|
+
};
|
|
116
|
+
const makeReader = (schema, call) => {
|
|
117
|
+
const findEffect = (table, id) => callHost(call, {
|
|
118
|
+
type: "Find",
|
|
119
|
+
table,
|
|
120
|
+
id: GeneratedId.make(id)
|
|
121
|
+
}).pipe(Effect.map((response) => expectResponse(response, "Found")), Effect.map(({ document }) => document === null ? void 0 : decodeDocument(schema, table, document)));
|
|
122
|
+
return Object.freeze({
|
|
123
|
+
find: (table, id) => resultFromEffect(findEffect(table, id)),
|
|
124
|
+
get: (table, id) => resultFromEffect(findEffect(table, id).pipe(Effect.flatMap((document) => document === void 0 ? Effect.fail(documentNotFound(table, id)) : Effect.succeed(document)))),
|
|
125
|
+
query: (table) => ({ collect: () => resultFromEffect(callHost(call, {
|
|
126
|
+
type: "Collect",
|
|
127
|
+
table
|
|
128
|
+
}).pipe(Effect.map((response) => expectResponse(response, "Documents")), Effect.map(({ documents }) => documents.map((document) => decodeDocument(schema, table, document))))) })
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const makeWriter = (schema, call) => {
|
|
132
|
+
const reader = makeReader(schema, call);
|
|
133
|
+
const complete = (request) => callHost(call, request).pipe(Effect.map((response) => expectResponse(response, "Completed")), Effect.asVoid);
|
|
134
|
+
const writer = {
|
|
135
|
+
...reader,
|
|
136
|
+
delete: (table, id) => resultFromEffect(complete({
|
|
137
|
+
type: "Delete",
|
|
138
|
+
table,
|
|
139
|
+
id: GeneratedId.make(id)
|
|
140
|
+
})),
|
|
141
|
+
insert: (table, value) => resultFromEffect(callHost(call, {
|
|
142
|
+
type: "Insert",
|
|
143
|
+
table,
|
|
144
|
+
fields: encodeFields(schema, table, value)
|
|
145
|
+
}).pipe(Effect.map((response) => expectResponse(response, "Inserted").id))),
|
|
146
|
+
patch: (table, id, value) => resultFromEffect(complete({
|
|
147
|
+
type: "Patch",
|
|
148
|
+
table,
|
|
149
|
+
id: GeneratedId.make(id),
|
|
150
|
+
fields: encodePatchFields(schema, table, value)
|
|
151
|
+
})),
|
|
152
|
+
replace: (table, id, value) => resultFromEffect(complete({
|
|
153
|
+
type: "Replace",
|
|
154
|
+
table,
|
|
155
|
+
id: GeneratedId.make(id),
|
|
156
|
+
fields: encodeFields(schema, table, value)
|
|
157
|
+
}))
|
|
158
|
+
};
|
|
159
|
+
return Object.freeze(writer);
|
|
160
|
+
};
|
|
161
|
+
const encodeSuccess = Effect.fn("Guest.encodeSuccess")(function* (definition, value) {
|
|
162
|
+
if (definition.returns === void 0) {
|
|
163
|
+
yield* Schema.encodeUnknownEffect(Schema.Undefined)(value);
|
|
164
|
+
return { type: "Success" };
|
|
165
|
+
}
|
|
166
|
+
const result = {
|
|
167
|
+
type: "Success",
|
|
168
|
+
value: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value)
|
|
169
|
+
};
|
|
170
|
+
const dates = datePathsOf(value);
|
|
171
|
+
return dates.length === 0 ? result : {
|
|
172
|
+
...result,
|
|
173
|
+
dates
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
const encodeFailure = Effect.fn("Guest.encodeFailure")(function* (definition, error) {
|
|
177
|
+
const result = {
|
|
178
|
+
type: "Failure",
|
|
179
|
+
error: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.errors ?? ErrorValueSchema))(error)
|
|
180
|
+
};
|
|
181
|
+
const dates = datePathsOfObject(error);
|
|
182
|
+
return dates.length === 0 ? result : {
|
|
183
|
+
...result,
|
|
184
|
+
dates
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
const runGuest = Effect.fn("Guest.invoke")(function* (definition, encodedArgs, call) {
|
|
188
|
+
const schema = getFunctionSchema(definition);
|
|
189
|
+
if (schema === void 0) return yield* Effect.die("The function has no bound schema.");
|
|
190
|
+
const decodedArgs = yield* Schema.decodeEffect(Schema.toCodecJson(guestCodec(Schema.Struct(definition.args ?? {}))))(encodedArgs).pipe(Effect.match({
|
|
191
|
+
onFailure: () => ({ valid: false }),
|
|
192
|
+
onSuccess: (value) => ({
|
|
193
|
+
valid: true,
|
|
194
|
+
value
|
|
195
|
+
})
|
|
196
|
+
}));
|
|
197
|
+
if (!decodedArgs.valid) return {
|
|
198
|
+
type: "InvocationRejected",
|
|
199
|
+
code: "InvalidArguments",
|
|
200
|
+
message: "The invocation arguments do not match the function definition."
|
|
201
|
+
};
|
|
202
|
+
const args = yield* Schema.decodeUnknownEffect(Schema.ObjectKeyword)(decodedArgs.value);
|
|
203
|
+
const context = Object.freeze({ db: definition._tag === "Query" ? makeReader(schema, call) : makeWriter(schema, call) });
|
|
204
|
+
return yield* Effect.gen(() => definition.handler(context, args)).pipe(Effect.matchEffect({
|
|
205
|
+
onFailure: (error) => encodeFailure(definition, error),
|
|
206
|
+
onSuccess: (value) => encodeSuccess(definition, value)
|
|
207
|
+
}));
|
|
208
|
+
});
|
|
209
|
+
const invoke = (definition, encodedArgs, call) => Effect.runPromise(runGuest(definition, encodedArgs, call)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));
|
|
210
|
+
//#endregion
|
|
211
|
+
export { invoke };
|
|
212
|
+
|
|
213
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","names":[],"sources":["../../../../contracts/dist/runtime/host.js","../../../../runtime/dist/guest.js"],"sourcesContent":["import { GeneratedId } from \"./id.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/host.ts\nconst HostDocument = Schema.Struct({\n\tid: GeneratedId,\n\tcreatedAt: Schema.Int,\n\tupdatedAt: Schema.Int,\n\tfields: Schema.JsonObject\n});\nconst HostCollect = Schema.Struct({\n\ttype: Schema.Literal(\"Collect\"),\n\ttable: Schema.String\n});\nconst HostFind = Schema.Struct({\n\ttype: Schema.Literal(\"Find\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostInsert = Schema.Struct({\n\ttype: Schema.Literal(\"Insert\"),\n\ttable: Schema.String,\n\tfields: Schema.JsonObject\n});\nconst HostDelete = Schema.Struct({\n\ttype: Schema.Literal(\"Delete\"),\n\ttable: Schema.String,\n\tid: GeneratedId\n});\nconst HostPatch = Schema.Struct({\n\ttype: Schema.Literal(\"Patch\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst HostReplace = Schema.Struct({\n\ttype: Schema.Literal(\"Replace\"),\n\ttable: Schema.String,\n\tid: GeneratedId,\n\tfields: Schema.JsonObject\n});\nconst QuickJsHostRequest = Schema.Union([\n\tHostCollect,\n\tHostFind,\n\tHostInsert,\n\tHostDelete,\n\tHostPatch,\n\tHostReplace\n]);\nconst HostDocuments = Schema.Struct({\n\ttype: Schema.Literal(\"Documents\"),\n\tdocuments: Schema.Array(HostDocument)\n});\nconst HostFound = Schema.Struct({\n\ttype: Schema.Literal(\"Found\"),\n\tdocument: Schema.NullOr(HostDocument)\n});\nconst HostInserted = Schema.Struct({\n\ttype: Schema.Literal(\"Inserted\"),\n\tid: GeneratedId\n});\nconst HostCompleted = Schema.Struct({ type: Schema.Literal(\"Completed\") });\nconst QuickJsHostResponse = Schema.Union([\n\tHostDocuments,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted\n]);\n//#endregion\nexport { HostCollect, HostCompleted, HostDelete, HostDocument, HostDocuments, HostFind, HostFound, HostInsert, HostInserted, HostPatch, HostReplace, QuickJsHostRequest, QuickJsHostResponse };\n\n//# sourceMappingURL=host.js.map","import { HostCompleted, HostDocuments, HostFound, HostInserted, QuickJsHostRequest } from \"@ignotum/contracts/runtime/host\";\nimport { GeneratedId } from \"@ignotum/contracts/runtime/id\";\nimport { Effect, Schema } from \"effect\";\nimport { ErrorValueSchema, documentNotFound, resultFromEffect } from \"@ignotum/contracts/runtime/result\";\nimport { getFunctionSchema } from \"@ignotum/contracts/runtime/schema\";\nimport { TransportValueSchema, datePathsOf, datePathsOfObject } from \"@ignotum/contracts/runtime/value\";\nimport { SchemaDefinitionTypeId } from \"@ignotum/contracts/schema\";\n//#region src/guest.ts\nconst decodeHostResponse = Schema.decodeEffect(Schema.fromJsonString(Schema.Union([\n\tHostDocuments,\n\tHostFound,\n\tHostInserted,\n\tHostCompleted\n])));\nconst encodeHostRequest = Schema.encodeSync(Schema.fromJsonString(QuickJsHostRequest));\nconst callHost = Effect.fn(\"Guest.callHost\")(function* (call, request) {\n\treturn yield* Effect.tryPromise(() => call(encodeHostRequest(request))).pipe(Effect.flatMap(decodeHostResponse), Effect.orDie);\n});\nconst tableFor = (schema, table) => {\n\tconst definition = schema[SchemaDefinitionTypeId][table];\n\tif (definition === void 0) throw new Error(`Unknown database table '${table}'.`);\n\treturn definition;\n};\nconst guestCodec = (schema) => schema;\nconst encodeFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeUnknownSync(Schema.JsonObject)(Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(definition.schema)), { onExcessProperty: \"error\" })(fields));\n};\nconst encodePatchFields = (schema, table, fields) => {\n\tconst definition = tableFor(schema, table);\n\treturn Schema.decodeSync(Schema.JsonObject)(Object.fromEntries(Object.entries(fields).map(([name, value]) => {\n\t\tconst field = definition.fields[name];\n\t\tif (field === void 0) throw new Error(`Unknown field '${name}' on table '${table}'.`);\n\t\treturn [name, Schema.encodeUnknownSync(Schema.toCodecJson(guestCodec(field)))(value)];\n\t})));\n};\nconst documentCodec = (schema, table) => guestCodec(Schema.Struct({\n\t...tableFor(schema, table).fields,\n\tid: Schema.String,\n\tcreatedAt: Schema.DateFromMillis,\n\tupdatedAt: Schema.DateFromMillis\n}));\nconst decodeDocument = (schema, table, document) => Schema.decodeUnknownSync(Schema.Record(Schema.String, Schema.UndefinedOr(TransportValueSchema)))(Schema.decodeSync(Schema.toCodecJson(documentCodec(schema, table)))({\n\t...document.fields,\n\tid: document.id,\n\tcreatedAt: document.createdAt,\n\tupdatedAt: document.updatedAt\n}));\nconst expectResponse = (response, tag) => {\n\tif (response.type !== tag) throw new Error(`Unexpected host response '${response.type}'.`);\n\treturn response;\n};\nconst makeReader = (schema, call) => {\n\tconst findEffect = (table, id) => callHost(call, {\n\t\ttype: \"Find\",\n\t\ttable,\n\t\tid: GeneratedId.make(id)\n\t}).pipe(Effect.map((response) => expectResponse(response, \"Found\")), Effect.map(({ document }) => document === null ? void 0 : decodeDocument(schema, table, document)));\n\treturn Object.freeze({\n\t\tfind: (table, id) => resultFromEffect(findEffect(table, id)),\n\t\tget: (table, id) => resultFromEffect(findEffect(table, id).pipe(Effect.flatMap((document) => document === void 0 ? Effect.fail(documentNotFound(table, id)) : Effect.succeed(document)))),\n\t\tquery: (table) => ({ collect: () => resultFromEffect(callHost(call, {\n\t\t\ttype: \"Collect\",\n\t\t\ttable\n\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Documents\")), Effect.map(({ documents }) => documents.map((document) => decodeDocument(schema, table, document))))) })\n\t});\n};\nconst makeWriter = (schema, call) => {\n\tconst reader = makeReader(schema, call);\n\tconst complete = (request) => callHost(call, request).pipe(Effect.map((response) => expectResponse(response, \"Completed\")), Effect.asVoid);\n\tconst writer = {\n\t\t...reader,\n\t\tdelete: (table, id) => resultFromEffect(complete({\n\t\t\ttype: \"Delete\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id)\n\t\t})),\n\t\tinsert: (table, value) => resultFromEffect(callHost(call, {\n\t\t\ttype: \"Insert\",\n\t\t\ttable,\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}).pipe(Effect.map((response) => expectResponse(response, \"Inserted\").id))),\n\t\tpatch: (table, id, value) => resultFromEffect(complete({\n\t\t\ttype: \"Patch\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodePatchFields(schema, table, value)\n\t\t})),\n\t\treplace: (table, id, value) => resultFromEffect(complete({\n\t\t\ttype: \"Replace\",\n\t\t\ttable,\n\t\t\tid: GeneratedId.make(id),\n\t\t\tfields: encodeFields(schema, table, value)\n\t\t}))\n\t};\n\treturn Object.freeze(writer);\n};\nconst encodeSuccess = Effect.fn(\"Guest.encodeSuccess\")(function* (definition, value) {\n\tif (definition.returns === void 0) {\n\t\tyield* Schema.encodeUnknownEffect(Schema.Undefined)(value);\n\t\treturn { type: \"Success\" };\n\t}\n\tconst result = {\n\t\ttype: \"Success\",\n\t\tvalue: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.returns))(value)\n\t};\n\tconst dates = datePathsOf(value);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst encodeFailure = Effect.fn(\"Guest.encodeFailure\")(function* (definition, error) {\n\tconst result = {\n\t\ttype: \"Failure\",\n\t\terror: yield* Schema.encodeUnknownEffect(Schema.toCodecJson(definition.errors ?? ErrorValueSchema))(error)\n\t};\n\tconst dates = datePathsOfObject(error);\n\treturn dates.length === 0 ? result : {\n\t\t...result,\n\t\tdates\n\t};\n});\nconst runGuest = Effect.fn(\"Guest.invoke\")(function* (definition, encodedArgs, call) {\n\tconst schema = getFunctionSchema(definition);\n\tif (schema === void 0) return yield* Effect.die(\"The function has no bound schema.\");\n\tconst decodedArgs = yield* Schema.decodeEffect(Schema.toCodecJson(guestCodec(Schema.Struct(definition.args ?? {}))))(encodedArgs).pipe(Effect.match({\n\t\tonFailure: () => ({ valid: false }),\n\t\tonSuccess: (value) => ({\n\t\t\tvalid: true,\n\t\t\tvalue\n\t\t})\n\t}));\n\tif (!decodedArgs.valid) return {\n\t\ttype: \"InvocationRejected\",\n\t\tcode: \"InvalidArguments\",\n\t\tmessage: \"The invocation arguments do not match the function definition.\"\n\t};\n\tconst args = yield* Schema.decodeUnknownEffect(Schema.ObjectKeyword)(decodedArgs.value);\n\tconst context = Object.freeze({ db: definition._tag === \"Query\" ? makeReader(schema, call) : makeWriter(schema, call) });\n\treturn yield* Effect.gen(() => definition.handler(context, args)).pipe(Effect.matchEffect({\n\t\tonFailure: (error) => encodeFailure(definition, error),\n\t\tonSuccess: (value) => encodeSuccess(definition, value)\n\t}));\n});\nconst invoke = (definition, encodedArgs, call) => Effect.runPromise(runGuest(definition, encodedArgs, call)).then((result) => Schema.encodeSync(Schema.fromJsonString(Schema.Json))(result));\n//#endregion\nexport { invoke };\n\n//# sourceMappingURL=guest.js.map"],"mappings":";;;;;AAGA,MAAM,eAAe,OAAO,OAAO;CAClC,IAAI;CACJ,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,QAAQ,OAAO;AAChB,CAAC;AACD,MAAM,cAAc,OAAO,OAAO;CACjC,MAAM,OAAO,QAAQ,SAAS;CAC9B,OAAO,OAAO;AACf,CAAC;AACD,MAAM,WAAW,OAAO,OAAO;CAC9B,MAAM,OAAO,QAAQ,MAAM;CAC3B,OAAO,OAAO;CACd,IAAI;AACL,CAAC;AACD,MAAM,aAAa,OAAO,OAAO;CAChC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,OAAO,OAAO;CACd,QAAQ,OAAO;AAChB,CAAC;AACD,MAAM,aAAa,OAAO,OAAO;CAChC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,OAAO,OAAO;CACd,IAAI;AACL,CAAC;AACD,MAAM,YAAY,OAAO,OAAO;CAC/B,MAAM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AM;CACpF,MAAM,SAAS,kBAAkB,UAAU;CAC3C,IAAI,WAAW,KAAK,GAAG,OAAO,OAAO,OAAO,IAAI,mCAAmC;CACnF,MAAM,cAAc,OAAO,OAAO,aAAa,OAAO,YAAY,WAAW,OAAO,OAAO,WAAW,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,OAAO,MAAM;EACnJ,kBAAkB,EAAE,OAAO,MAAM;EACjC,YAAY,WAAW;GACtB,OAAO;GACP;EACD;CACD,CAAC,CAAC;CACF,IAAI,CAAC,YAAY,OAAO,OAAO;EAC9B,MAAM;EACN,MAAM;EACN,SAAS;CACV;CACA,MAAM,OAAO,OAAO,OAAO,oBAAoB,OAAO,aAAa,CAAC,CAAC,YAAY,KAAK;CACtF,MAAM,UAAU,OAAO,OAAO,EAAE,IAAI,WAAW,SAAS,UAAU,WAAW,QAAQ,IAAI,IAAI,WAAW,QAAQ,IAAI,EAAE,CAAC;CACvH,OAAO,OAAO,OAAO,UAAU,WAAW,QAAQ,SAAS,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,YAAY;EACzF,YAAY,UAAU,cAAc,YAAY,KAAK;EACrD,YAAY,UAAU,cAAc,YAAY,KAAK;CACtD,CAAC,CAAC;AACH,CAAC;AACD,MAAM,UAAU,YAAY,aAAa,SAAS,OAAO,WAAW,SAAS,YAAY,aAAa,IAAI,CAAC,CAAC,CAAC,MAAM,WAAW,OAAO,WAAW,OAAO,eAAe,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Document, c as SchemaDefinitionTypeId, o as Id, s as SchemaDefinitionOf } from "../index-
|
|
1
|
+
import { a as Document, c as SchemaDefinitionTypeId, o as Id, s as SchemaDefinitionOf } from "../index-Dl_VQGmA.js";
|
|
2
2
|
export { type Document, type Id, type SchemaDefinitionOf, SchemaDefinitionTypeId };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SchemaDefinitionTypeId } from "../schema-
|
|
1
|
+
import { t as SchemaDefinitionTypeId } from "../schema-B-jMZEbs.js";
|
|
2
2
|
export { SchemaDefinitionTypeId };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Brand, Effect, Schema } from "effect";
|
|
2
|
+
//#region ../contracts/dist/value-CiN-5gJo.d.ts
|
|
3
|
+
//#region src/runtime/value.d.ts
|
|
4
|
+
interface TransportArray extends ReadonlyArray<TransportValue> {}
|
|
5
|
+
interface TransportObject {
|
|
6
|
+
readonly [key: string]: TransportValue | undefined;
|
|
7
|
+
}
|
|
8
|
+
type TransportValue = null | boolean | number | string | Date | TransportArray | TransportObject;
|
|
9
|
+
//#endregion
|
|
2
10
|
//#region ../contracts/dist/runtime/result.d.ts
|
|
3
11
|
//#region src/runtime/result.d.ts
|
|
4
12
|
declare const ResultTypeId: unique symbol;
|
|
@@ -8,7 +16,9 @@ type ErrorValue = {
|
|
|
8
16
|
readonly _tag: string;
|
|
9
17
|
} & Brand.Brand<typeof ErrorBrand>;
|
|
10
18
|
declare const InternalServerErrorCause_base: Schema.Class<InternalServerErrorCause, Schema.TaggedStruct<"InternalServerError", {
|
|
11
|
-
readonly requestId: Schema.String
|
|
19
|
+
readonly requestId: Schema.brand<Schema.String, "ignotum/runtime/RequestId"> & {
|
|
20
|
+
readonly idPrefix: string;
|
|
21
|
+
};
|
|
12
22
|
}>, import("effect/Cause").YieldableError>;
|
|
13
23
|
declare class InternalServerErrorCause extends InternalServerErrorCause_base {}
|
|
14
24
|
declare const InternalServerError: typeof InternalServerErrorCause;
|
|
@@ -16,12 +26,16 @@ declare const InternalServerErrorSchema: Schema.brand<Schema.decodeTo<Schema.dec
|
|
|
16
26
|
readonly _tag: "InternalServerError";
|
|
17
27
|
readonly requestId: string;
|
|
18
28
|
}, readonly [Schema.TaggedStruct<"InternalServerError", {
|
|
19
|
-
readonly requestId: Schema.String
|
|
29
|
+
readonly requestId: Schema.brand<Schema.String, "ignotum/runtime/RequestId"> & {
|
|
30
|
+
readonly idPrefix: string;
|
|
31
|
+
};
|
|
20
32
|
}>], {
|
|
21
33
|
readonly _tag: "InternalServerError";
|
|
22
|
-
readonly requestId: string
|
|
34
|
+
readonly requestId: string & Brand.Brand<"ignotum/runtime/RequestId">;
|
|
23
35
|
}>, Schema.TaggedStruct<"InternalServerError", {
|
|
24
|
-
readonly requestId: Schema.String
|
|
36
|
+
readonly requestId: Schema.brand<Schema.String, "ignotum/runtime/RequestId"> & {
|
|
37
|
+
readonly idPrefix: string;
|
|
38
|
+
};
|
|
25
39
|
}>, never, never>, "ignotum/error">;
|
|
26
40
|
type InternalServerError = typeof InternalServerErrorSchema.Type;
|
|
27
41
|
type DocumentNotFoundValue<TableName extends string = string, Identifier extends string = string> = ErrorValue & {
|
|
@@ -95,6 +109,7 @@ interface Match {
|
|
|
95
109
|
<Success, Failure extends ErrorValue, Output>(matchers: CurriedQueryResultMatchers<Success, Failure, Output>): (result: QueryResult<Success, Failure>) => Output;
|
|
96
110
|
<Success, Failure extends ErrorValue, Output>(matchers: CurriedResultMatchers<Success, Failure, Output>): (result: SettledResult<Success, Failure>) => Output;
|
|
97
111
|
}
|
|
112
|
+
declare const documentNotFound: <TableName extends string, Identifier extends string>(table: TableName, id: Identifier) => DocumentNotFoundValue<TableName, Identifier>;
|
|
98
113
|
declare const Result: {
|
|
99
114
|
fail: typeof fail;
|
|
100
115
|
match: Match;
|
|
@@ -102,5 +117,5 @@ declare const Result: {
|
|
|
102
117
|
try: typeof tryResult;
|
|
103
118
|
};
|
|
104
119
|
//#endregion
|
|
105
|
-
export { Match as a, SettledResult as c, InternalServerError as i, ErrorBrand as n, QueryResult as o, ErrorValue as r, Result as s, DocumentNotFoundValue as t };
|
|
106
|
-
//# sourceMappingURL=result-
|
|
120
|
+
export { Match as a, SettledResult as c, TransportValue as d, InternalServerError as i, documentNotFound as l, ErrorBrand as n, QueryResult as o, ErrorValue as r, Result as s, DocumentNotFoundValue as t, TransportObject as u };
|
|
121
|
+
//# sourceMappingURL=result-BgcHn25t.d.ts.map
|