ignotum 0.0.12 → 0.0.13
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/dist/cli/bin.mjs +825 -403
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-DzcR7spt.js → api-CAgKDij7.js} +38 -2
- package/dist/runtime/api-CAgKDij7.js.map +1 -0
- package/dist/runtime/{api-5XSrIeqW.d.ts → api-Cv3hMbzo.d.ts} +4 -4
- package/dist/runtime/client.d.ts +39 -9
- package/dist/runtime/client.js +339 -60
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js +154 -0
- package/dist/runtime/descriptor-Cyo9FP9n-C0SRVXNW.js.map +1 -0
- package/dist/runtime/id-Bt9XWRGL.js +423 -0
- package/dist/runtime/id-Bt9XWRGL.js.map +1 -0
- package/dist/runtime/{id-Cs82tq9Q-CK-maMgN.d.ts → id-BzFHf3Wo-DGPCjgrf.d.ts} +2 -2
- package/dist/runtime/id-Dz0apuB3.d.ts +1 -0
- package/dist/runtime/{index-CrWg4Z0y.d.ts → index-D54flWtH.d.ts} +9 -5
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +9 -6
- package/dist/runtime/internal/host.js +15 -6
- package/dist/runtime/internal/host.js.map +1 -1
- 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-D-R9NR61-CpIoHFoI.d.ts → pagination-DnKg3dkI-r5ZUxBBx.d.ts} +31 -6
- package/dist/runtime/pagination-Dz0apuB3.d.ts +1 -0
- package/dist/runtime/result-DKAA4gpS.d.ts +1 -0
- package/dist/runtime/{schema-B9XxyRO8.js → schema-1Zs03-iS.js} +5 -3
- package/dist/runtime/schema-1Zs03-iS.js.map +1 -0
- package/dist/runtime/server.d.ts +6 -4
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/{sync-avN7NkcU.d.ts → sync-Bs8J3fIr.d.ts} +2 -2
- package/package.json +1 -1
- package/src/cli/agent-files.ts +6 -0
- package/src/client/hooks.ts +68 -0
- package/src/client/id.ts +259 -0
- package/src/client/index.ts +5 -2
- package/src/client/sync.ts +143 -10
- package/src/dev-runtime/functions.ts +111 -88
- package/src/dev-runtime/id.ts +175 -0
- package/src/dev-runtime/query-cache.ts +105 -0
- package/src/dev-runtime/sync.ts +149 -17
- package/src/server/index.ts +2 -0
- package/dist/runtime/api-DzcR7spt.js.map +0 -1
- package/dist/runtime/descriptor-XzDX2JDw-j3O6YHgW.js +0 -330
- package/dist/runtime/descriptor-XzDX2JDw-j3O6YHgW.js.map +0 -1
- package/dist/runtime/file-C1abuMgd.js +0 -173
- package/dist/runtime/file-C1abuMgd.js.map +0 -1
- package/dist/runtime/pagination-CX5IPbEi.d.ts +0 -1
- package/dist/runtime/result-DIjKM-p4.d.ts +0 -1
- package/dist/runtime/schema-B9XxyRO8.js.map +0 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { p as initial } from "./id-Bt9XWRGL.js";
|
|
2
|
+
import { Function, Predicate, Schema } from "effect";
|
|
3
|
+
//#region ../contracts/dist/runtime/pagination.js
|
|
4
|
+
const PaginationCursor = Schema.String.check(Schema.isBase64Url()).pipe(Schema.brand("ignotum/runtime/PaginationCursor"));
|
|
5
|
+
const PaginationPageSize = Schema.Int.check(Schema.isBetween({
|
|
6
|
+
minimum: 1,
|
|
7
|
+
maximum: 1e3
|
|
8
|
+
})).pipe(Schema.brand("ignotum/runtime/PaginationPageSize"));
|
|
9
|
+
Schema.Struct({
|
|
10
|
+
cursor: Schema.NullOr(PaginationCursor),
|
|
11
|
+
pageSize: PaginationPageSize
|
|
12
|
+
});
|
|
13
|
+
const TablePosition = Schema.Struct({
|
|
14
|
+
type: Schema.Literal("Table"),
|
|
15
|
+
createdAt: Schema.Int,
|
|
16
|
+
id: Schema.String
|
|
17
|
+
});
|
|
18
|
+
const IndexPosition = Schema.Struct({
|
|
19
|
+
type: Schema.Literal("Index"),
|
|
20
|
+
key: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2})*$/)).pipe(Schema.brand("ignotum/runtime/EncodedIndexKey"))
|
|
21
|
+
});
|
|
22
|
+
const PaginationPosition = Schema.Union([TablePosition, IndexPosition]);
|
|
23
|
+
const CursorPayloadV1 = Schema.Struct({
|
|
24
|
+
version: Schema.Literal(1),
|
|
25
|
+
query: Schema.String,
|
|
26
|
+
position: PaginationPosition
|
|
27
|
+
});
|
|
28
|
+
const CursorPayload = initial(CursorPayloadV1);
|
|
29
|
+
Schema.fromJsonString(CursorPayload);
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../contracts/dist/descriptor-Cyo9FP9n.js
|
|
32
|
+
const LiteralValue = Schema.Union([
|
|
33
|
+
Schema.String,
|
|
34
|
+
Schema.Finite,
|
|
35
|
+
Schema.Boolean
|
|
36
|
+
]);
|
|
37
|
+
const DescriptorField = Schema.Struct({
|
|
38
|
+
name: Schema.String,
|
|
39
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
40
|
+
});
|
|
41
|
+
const ValueDescriptor = Schema.Union([
|
|
42
|
+
Schema.Struct({
|
|
43
|
+
type: Schema.Literal("array"),
|
|
44
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
45
|
+
}),
|
|
46
|
+
Schema.Struct({ type: Schema.Literal("boolean") }),
|
|
47
|
+
Schema.Struct({ type: Schema.Literal("date") }),
|
|
48
|
+
Schema.Struct({
|
|
49
|
+
type: Schema.Literal("file"),
|
|
50
|
+
formats: Schema.Array(Schema.Literals([
|
|
51
|
+
"jpeg",
|
|
52
|
+
"png",
|
|
53
|
+
"webp",
|
|
54
|
+
"avif",
|
|
55
|
+
"gif"
|
|
56
|
+
])),
|
|
57
|
+
maxBytes: Schema.Int
|
|
58
|
+
}),
|
|
59
|
+
Schema.Struct({
|
|
60
|
+
type: Schema.Literal("error"),
|
|
61
|
+
tag: Schema.String,
|
|
62
|
+
fields: Schema.Array(DescriptorField)
|
|
63
|
+
}),
|
|
64
|
+
Schema.Struct({
|
|
65
|
+
type: Schema.Literal("id"),
|
|
66
|
+
table: Schema.String
|
|
67
|
+
}),
|
|
68
|
+
Schema.Struct({ type: Schema.Literal("userId") }),
|
|
69
|
+
Schema.Struct({ type: Schema.Literal("integer") }),
|
|
70
|
+
Schema.Struct({
|
|
71
|
+
type: Schema.Literal("literal"),
|
|
72
|
+
value: LiteralValue
|
|
73
|
+
}),
|
|
74
|
+
Schema.Struct({
|
|
75
|
+
type: Schema.Literal("literals"),
|
|
76
|
+
values: Schema.Array(LiteralValue)
|
|
77
|
+
}),
|
|
78
|
+
Schema.Struct({ type: Schema.Literal("never") }),
|
|
79
|
+
Schema.Struct({ type: Schema.Literal("null") }),
|
|
80
|
+
Schema.Struct({
|
|
81
|
+
type: Schema.Literal("nullable"),
|
|
82
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
83
|
+
}),
|
|
84
|
+
Schema.Struct({ type: Schema.Literal("number") }),
|
|
85
|
+
Schema.Struct({
|
|
86
|
+
type: Schema.Literal("object"),
|
|
87
|
+
fields: Schema.Array(DescriptorField)
|
|
88
|
+
}),
|
|
89
|
+
Schema.Struct({
|
|
90
|
+
type: Schema.Literal("optional"),
|
|
91
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
92
|
+
}),
|
|
93
|
+
Schema.Struct({
|
|
94
|
+
type: Schema.Literal("record"),
|
|
95
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
96
|
+
}),
|
|
97
|
+
Schema.Struct({
|
|
98
|
+
type: Schema.Literal("secret"),
|
|
99
|
+
value: Schema.suspend(() => ValueDescriptor)
|
|
100
|
+
}),
|
|
101
|
+
Schema.Struct({ type: Schema.Literal("string") }),
|
|
102
|
+
Schema.Struct({
|
|
103
|
+
type: Schema.Literal("union"),
|
|
104
|
+
members: Schema.Array(Schema.suspend(() => ValueDescriptor))
|
|
105
|
+
})
|
|
106
|
+
]);
|
|
107
|
+
const ValueDescriptorTypeId = Symbol.for("ignotum/schema/ValueDescriptor");
|
|
108
|
+
const attachValueDescriptor = Function.dual(2, (value, descriptor) => {
|
|
109
|
+
Object.defineProperty(value, ValueDescriptorTypeId, {
|
|
110
|
+
configurable: false,
|
|
111
|
+
enumerable: false,
|
|
112
|
+
value: descriptor,
|
|
113
|
+
writable: false
|
|
114
|
+
});
|
|
115
|
+
return value;
|
|
116
|
+
});
|
|
117
|
+
const getValueDescriptor = (value) => {
|
|
118
|
+
if (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;
|
|
119
|
+
return Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;
|
|
120
|
+
};
|
|
121
|
+
const descriptorAllowedInEnvironment = (descriptor) => {
|
|
122
|
+
switch (descriptor.type) {
|
|
123
|
+
case "error":
|
|
124
|
+
case "file":
|
|
125
|
+
case "userId":
|
|
126
|
+
case "id": return false;
|
|
127
|
+
case "array":
|
|
128
|
+
case "nullable":
|
|
129
|
+
case "optional":
|
|
130
|
+
case "record":
|
|
131
|
+
case "secret": return descriptorAllowedInEnvironment(descriptor.value);
|
|
132
|
+
case "object": return descriptor.fields.every((field) => descriptorAllowedInEnvironment(field.value));
|
|
133
|
+
case "union": return descriptor.members.every(descriptorAllowedInEnvironment);
|
|
134
|
+
default: return true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const descriptorFields = (fields) => {
|
|
138
|
+
const entries = [];
|
|
139
|
+
for (const name of Reflect.ownKeys(fields)) {
|
|
140
|
+
if (!Predicate.isString(name)) throw new Error("Ignotum value objects only support string field names.");
|
|
141
|
+
const field = fields[name];
|
|
142
|
+
const value = field === void 0 ? void 0 : getValueDescriptor(field);
|
|
143
|
+
if (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);
|
|
144
|
+
entries.push({
|
|
145
|
+
name,
|
|
146
|
+
value
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { getValueDescriptor as a, descriptorFields as i, attachValueDescriptor as n, PaginationCursor as o, descriptorAllowedInEnvironment as r, PaginationPageSize as s, ValueDescriptor as t };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=descriptor-Cyo9FP9n-C0SRVXNW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-Cyo9FP9n-C0SRVXNW.js","names":[],"sources":["../../../contracts/dist/runtime/pagination.js","../../../contracts/dist/descriptor-Cyo9FP9n.js"],"sourcesContent":["import { initial } from \"../versioned.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { Encoding, Result, Schema } from \"effect\";\n//#region src/runtime/pagination.ts\nconst PaginationCursor = Schema.String.check(Schema.isBase64Url()).pipe(Schema.brand(\"ignotum/runtime/PaginationCursor\"));\nconst PaginationPageSize = Schema.Int.check(Schema.isBetween({\n\tminimum: 1,\n\tmaximum: 1e3\n})).pipe(Schema.brand(\"ignotum/runtime/PaginationPageSize\"));\nconst PaginationOptions = Schema.Struct({\n\tcursor: Schema.NullOr(PaginationCursor),\n\tpageSize: PaginationPageSize\n});\nconst TablePosition = Schema.Struct({\n\ttype: Schema.Literal(\"Table\"),\n\tcreatedAt: Schema.Int,\n\tid: Schema.String\n});\nconst IndexPosition = Schema.Struct({\n\ttype: Schema.Literal(\"Index\"),\n\tkey: Schema.String.check(Schema.isPattern(/^(?:[0-9a-f]{2})*$/)).pipe(Schema.brand(\"ignotum/runtime/EncodedIndexKey\"))\n});\nconst PaginationPosition = Schema.Union([TablePosition, IndexPosition]);\nconst CursorPayloadV1 = Schema.Struct({\n\tversion: Schema.Literal(1),\n\tquery: Schema.String,\n\tposition: PaginationPosition\n});\nconst CursorPayload = initial(CursorPayloadV1);\nconst CursorPayloadJson = Schema.fromJsonString(CursorPayload);\nconst paginationQueryIdentity = (tableId, index, lower, upper, order) => encodeCanonicalJson([\n\ttableId,\n\tindex,\n\tlower ?? null,\n\tupper ?? null,\n\torder\n]);\nconst encodePaginationCursor = (query, position) => PaginationCursor.make(Encoding.encodeBase64Url(Schema.encodeSync(CursorPayloadJson)({\n\tversion: 1,\n\tquery,\n\tposition\n})));\nconst decodePaginationCursor = (cursor) => Schema.decodeSync(CursorPayloadJson)(Result.getOrThrow(Encoding.decodeBase64UrlString(cursor)));\n//#endregion\nexport { PaginationCursor, PaginationOptions, PaginationPageSize, PaginationPosition, decodePaginationCursor, encodePaginationCursor, paginationQueryIdentity };\n\n//# sourceMappingURL=pagination.js.map","import { Function, Predicate, Schema } from \"effect\";\n//#region src/schema/descriptor.ts\nconst LiteralValue = Schema.Union([\n\tSchema.String,\n\tSchema.Finite,\n\tSchema.Boolean\n]);\nconst DescriptorField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: Schema.suspend(() => ValueDescriptor)\n});\nconst ValueDescriptor = Schema.Union([\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"array\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"boolean\") }),\n\tSchema.Struct({ type: Schema.Literal(\"date\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"file\"),\n\t\tformats: Schema.Array(Schema.Literals([\n\t\t\t\"jpeg\",\n\t\t\t\"png\",\n\t\t\t\"webp\",\n\t\t\t\"avif\",\n\t\t\t\"gif\"\n\t\t])),\n\t\tmaxBytes: Schema.Int\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"error\"),\n\t\ttag: Schema.String,\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"id\"),\n\t\ttable: Schema.String\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"userId\") }),\n\tSchema.Struct({ type: Schema.Literal(\"integer\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literal\"),\n\t\tvalue: LiteralValue\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literals\"),\n\t\tvalues: Schema.Array(LiteralValue)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"never\") }),\n\tSchema.Struct({ type: Schema.Literal(\"null\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"nullable\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"number\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"object\"),\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"optional\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"record\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"secret\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"string\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"union\"),\n\t\tmembers: Schema.Array(Schema.suspend(() => ValueDescriptor))\n\t})\n]);\nconst ValueDescriptorTypeId = Symbol.for(\"ignotum/schema/ValueDescriptor\");\nconst attachValueDescriptor = Function.dual(2, (value, descriptor) => {\n\tObject.defineProperty(value, ValueDescriptorTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: descriptor,\n\t\twritable: false\n\t});\n\treturn value;\n});\nconst getValueDescriptor = (value) => {\n\tif (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;\n\treturn Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;\n};\nconst descriptorContainsFile = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"file\": return true;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\":\n\t\tcase \"secret\": return descriptorContainsFile(descriptor.value);\n\t\tcase \"error\":\n\t\tcase \"object\": return descriptor.fields.some((field) => descriptorContainsFile(field.value));\n\t\tcase \"union\": return descriptor.members.some(descriptorContainsFile);\n\t\tdefault: return false;\n\t}\n};\nconst descriptorContainsSecret = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"secret\": return true;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\": return descriptorContainsSecret(descriptor.value);\n\t\tcase \"error\":\n\t\tcase \"object\": return descriptor.fields.some((field) => descriptorContainsSecret(field.value));\n\t\tcase \"union\": return descriptor.members.some(descriptorContainsSecret);\n\t\tdefault: return false;\n\t}\n};\nconst descriptorAllowedInEnvironment = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"error\":\n\t\tcase \"file\":\n\t\tcase \"userId\":\n\t\tcase \"id\": return false;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\":\n\t\tcase \"secret\": return descriptorAllowedInEnvironment(descriptor.value);\n\t\tcase \"object\": return descriptor.fields.every((field) => descriptorAllowedInEnvironment(field.value));\n\t\tcase \"union\": return descriptor.members.every(descriptorAllowedInEnvironment);\n\t\tdefault: return true;\n\t}\n};\nconst descriptorFields = (fields) => {\n\tconst entries = [];\n\tfor (const name of Reflect.ownKeys(fields)) {\n\t\tif (!Predicate.isString(name)) throw new Error(\"Ignotum value objects only support string field names.\");\n\t\tconst field = fields[name];\n\t\tconst value = field === void 0 ? void 0 : getValueDescriptor(field);\n\t\tif (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);\n\t\tentries.push({\n\t\t\tname,\n\t\t\tvalue\n\t\t});\n\t}\n\treturn entries.sort((left, right) => left.name.localeCompare(right.name));\n};\n//#endregion\nexport { descriptorContainsFile as a, getValueDescriptor as c, descriptorAllowedInEnvironment as i, ValueDescriptorTypeId as n, descriptorContainsSecret as o, attachValueDescriptor as r, descriptorFields as s, ValueDescriptor as t };\n\n//# sourceMappingURL=descriptor-Cyo9FP9n.js.map"],"mappings":"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"}
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { Brand, Effect, Effectable, Function, Option, Predicate, Schema, SchemaGetter } from "effect";
|
|
2
|
+
//#region ../contracts/dist/runtime/id.js
|
|
3
|
+
const IdAlphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
4
|
+
const IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));
|
|
5
|
+
const IdPayloadPattern = /^[0-9a-z]{24}$/;
|
|
6
|
+
const withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });
|
|
7
|
+
const defineId = (prefix, brand) => {
|
|
8
|
+
const idPrefix = Schema.decodeSync(IdPrefix)(prefix);
|
|
9
|
+
return withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);
|
|
10
|
+
};
|
|
11
|
+
const GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand("ignotum/id")), void 0);
|
|
12
|
+
const AppId = defineId("app", "ignotum/hosted/AppId");
|
|
13
|
+
const DeploymentId = defineId("dep", "ignotum/hosted/DeploymentId");
|
|
14
|
+
defineId("team", "ignotum/hosted/TeamId");
|
|
15
|
+
const TableId = defineId("table", "ignotum/runtime/TableId");
|
|
16
|
+
defineId("prn", "ignotum/control/PlatformPrincipalId");
|
|
17
|
+
defineId("ses", "ignotum/auth/SessionId");
|
|
18
|
+
defineId("acct", "ignotum/auth/AccountId");
|
|
19
|
+
defineId("ver", "ignotum/auth/VerificationId");
|
|
20
|
+
defineId("mbr", "ignotum/auth/MemberId");
|
|
21
|
+
defineId("invt", "ignotum/auth/InvitationId");
|
|
22
|
+
defineId("dvc", "ignotum/auth/DeviceCodeId");
|
|
23
|
+
defineId("auth", "ignotum/auth/InternalId");
|
|
24
|
+
const InvocationId = defineId("inv", "ignotum/sync/InvocationId");
|
|
25
|
+
const SubscriptionId = defineId("sub", "ignotum/sync/SubscriptionId");
|
|
26
|
+
defineId("conn", "ignotum/gateway/ConnectionId");
|
|
27
|
+
const RuntimeRequestNonce = defineId("nonce", "ignotum/runtime/RequestNonce");
|
|
28
|
+
const RequestId = defineId("req", "ignotum/runtime/RequestId");
|
|
29
|
+
defineId("lock", "ignotum/dev/DatabaseLockId");
|
|
30
|
+
defineId("iid", "ignotum/id/AppUserId");
|
|
31
|
+
defineId("idu", "ignotum/id/GlobalUserId");
|
|
32
|
+
defineId("ids", "ignotum/id/SessionId");
|
|
33
|
+
defineId("idr", "ignotum/id/RequestId");
|
|
34
|
+
const SessionEpoch = defineId("epoch", "ignotum/id/SessionEpoch");
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../contracts/dist/schema/file.js
|
|
37
|
+
const fileFormats = [
|
|
38
|
+
"jpeg",
|
|
39
|
+
"png",
|
|
40
|
+
"webp",
|
|
41
|
+
"avif",
|
|
42
|
+
"gif"
|
|
43
|
+
];
|
|
44
|
+
const FileFormat = Schema.Literals(fileFormats);
|
|
45
|
+
const fileMimeTypes = {
|
|
46
|
+
avif: "image/avif",
|
|
47
|
+
gif: "image/gif",
|
|
48
|
+
jpeg: "image/jpeg",
|
|
49
|
+
png: "image/png",
|
|
50
|
+
webp: "image/webp"
|
|
51
|
+
};
|
|
52
|
+
const fileLimits = {
|
|
53
|
+
activeGrantsPerConnection: 1024,
|
|
54
|
+
distinctFilesPerQuerySnapshot: 256,
|
|
55
|
+
fileBytes: 10485760,
|
|
56
|
+
filesPerMutation: 8,
|
|
57
|
+
filenameBytes: 255,
|
|
58
|
+
mutationBytes: 26214400,
|
|
59
|
+
preparationLifetimeMillis: 9e5,
|
|
60
|
+
stagedBytesPerApp: 104857600
|
|
61
|
+
};
|
|
62
|
+
const FileId = Object.assign(Schema.String.pipe(Schema.check(Schema.isPattern(/^file_[0-9A-Za-z_-]{20,128}$/)), Schema.brand("ignotum/file/FileId")), { idPrefix: "file" });
|
|
63
|
+
defineId("upload", "ignotum/file/FileUploadToken");
|
|
64
|
+
defineId("grant", "ignotum/file/FileGrantToken");
|
|
65
|
+
const FileValueTypeId = Symbol.for("ignotum/file/FileValue");
|
|
66
|
+
const FileGrantTypeId = Symbol.for("ignotum/file/FileGrant");
|
|
67
|
+
const isFileValue = (value) => Predicate.isObject(value) && Predicate.hasProperty(value, FileValueTypeId) && Predicate.isObject(value[FileValueTypeId]) && Predicate.hasProperty(value[FileValueTypeId], "id") && Schema.is(FileId)(value[FileValueTypeId].id) && Predicate.hasProperty(value, "format") && Schema.is(FileFormat)(value.format) && Predicate.hasProperty(value, "name") && Predicate.isString(value.name) && Predicate.hasProperty(value, "size") && Predicate.isNumber(value.size) && Predicate.hasProperty(value, "mimeType") && value.mimeType === fileMimeTypes[value.format];
|
|
68
|
+
const buildFileValue = (id, metadata, grantUrl) => {
|
|
69
|
+
const value = {
|
|
70
|
+
format: metadata.format,
|
|
71
|
+
mimeType: fileMimeTypes[metadata.format],
|
|
72
|
+
name: metadata.name,
|
|
73
|
+
size: metadata.size
|
|
74
|
+
};
|
|
75
|
+
Object.defineProperty(value, FileValueTypeId, {
|
|
76
|
+
configurable: false,
|
|
77
|
+
enumerable: false,
|
|
78
|
+
value: Object.freeze({ id }),
|
|
79
|
+
writable: false
|
|
80
|
+
});
|
|
81
|
+
if (grantUrl !== void 0) Object.defineProperty(value, FileGrantTypeId, {
|
|
82
|
+
configurable: false,
|
|
83
|
+
enumerable: false,
|
|
84
|
+
value: grantUrl,
|
|
85
|
+
writable: false
|
|
86
|
+
});
|
|
87
|
+
return Object.freeze(value);
|
|
88
|
+
};
|
|
89
|
+
const makeFileValue = (id, metadata) => buildFileValue(id, metadata);
|
|
90
|
+
const fileIdOf = (value) => value[FileValueTypeId].id;
|
|
91
|
+
const grantFileValue = (value, url) => {
|
|
92
|
+
return buildFileValue(fileIdOf(value), value, url);
|
|
93
|
+
};
|
|
94
|
+
const fileGrantUrlOf = (value) => value[FileGrantTypeId];
|
|
95
|
+
const EncodedFileValue = Schema.Struct({
|
|
96
|
+
$ignotum: Schema.Literal("file"),
|
|
97
|
+
id: FileId,
|
|
98
|
+
format: FileFormat,
|
|
99
|
+
name: Schema.String,
|
|
100
|
+
size: Schema.Int.check(Schema.isBetween({
|
|
101
|
+
minimum: 0,
|
|
102
|
+
maximum: fileLimits.fileBytes
|
|
103
|
+
}))
|
|
104
|
+
});
|
|
105
|
+
const RuntimeFileMetadata = Schema.Struct({
|
|
106
|
+
id: FileId,
|
|
107
|
+
format: FileFormat,
|
|
108
|
+
name: Schema.String,
|
|
109
|
+
size: Schema.Int.check(Schema.isBetween({
|
|
110
|
+
minimum: 0,
|
|
111
|
+
maximum: fileLimits.fileBytes
|
|
112
|
+
}))
|
|
113
|
+
});
|
|
114
|
+
const FilePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));
|
|
115
|
+
const RuntimeFileOccurrence = Schema.Struct({
|
|
116
|
+
path: FilePath,
|
|
117
|
+
file: RuntimeFileMetadata
|
|
118
|
+
});
|
|
119
|
+
const DecodedFileValue = Schema.declare(isFileValue, { title: "FileValue" });
|
|
120
|
+
const FileValue = EncodedFileValue.pipe(Schema.decodeTo(DecodedFileValue, {
|
|
121
|
+
decode: SchemaGetter.transform((encoded) => makeFileValue(encoded.id, {
|
|
122
|
+
format: encoded.format,
|
|
123
|
+
name: encoded.name,
|
|
124
|
+
size: encoded.size
|
|
125
|
+
})),
|
|
126
|
+
encode: SchemaGetter.transform((value) => ({
|
|
127
|
+
$ignotum: "file",
|
|
128
|
+
format: value.format,
|
|
129
|
+
id: fileIdOf(value),
|
|
130
|
+
name: value.name,
|
|
131
|
+
size: value.size
|
|
132
|
+
}))
|
|
133
|
+
}));
|
|
134
|
+
const constrainedFileValue = (formats, maxBytes) => FileValue.pipe(Schema.check(Schema.makeFilter((value) => {
|
|
135
|
+
const issues = [];
|
|
136
|
+
if (!formats.includes(value.format)) issues.push({
|
|
137
|
+
path: ["format"],
|
|
138
|
+
issue: `File format '${value.format}' is not allowed by this field.`
|
|
139
|
+
});
|
|
140
|
+
if (value.size > maxBytes) issues.push({
|
|
141
|
+
path: ["size"],
|
|
142
|
+
issue: `File size ${value.size} exceeds this field's ${maxBytes} byte limit.`
|
|
143
|
+
});
|
|
144
|
+
return issues;
|
|
145
|
+
})));
|
|
146
|
+
const collectFileOccurrences = (value, path, occurrences) => {
|
|
147
|
+
if (isFileValue(value)) {
|
|
148
|
+
occurrences.push({
|
|
149
|
+
file: value,
|
|
150
|
+
path
|
|
151
|
+
});
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (globalThis.Array.isArray(value)) {
|
|
155
|
+
for (const [index, child] of value.entries()) collectFileOccurrences(child, [...path, index], occurrences);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!Predicate.isObject(value) || Predicate.isDate(value)) return;
|
|
159
|
+
for (const [key, child] of Object.entries(value)) collectFileOccurrences(child, [...path, key], occurrences);
|
|
160
|
+
};
|
|
161
|
+
const fileOccurrencesOf = (value) => {
|
|
162
|
+
const occurrences = [];
|
|
163
|
+
collectFileOccurrences(value, [], occurrences);
|
|
164
|
+
return occurrences;
|
|
165
|
+
};
|
|
166
|
+
const runtimeFileOccurrencesOf = (value) => fileOccurrencesOf(value).map(({ file, path }) => ({
|
|
167
|
+
path,
|
|
168
|
+
file: {
|
|
169
|
+
format: file.format,
|
|
170
|
+
id: fileIdOf(file),
|
|
171
|
+
name: file.name,
|
|
172
|
+
size: file.size
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region ../contracts/dist/runtime/value.js
|
|
177
|
+
const TransportValueSchema = Schema.suspend(() => Schema.Union([
|
|
178
|
+
Schema.Null,
|
|
179
|
+
Schema.Boolean,
|
|
180
|
+
Schema.Finite,
|
|
181
|
+
Schema.String,
|
|
182
|
+
Schema.Date,
|
|
183
|
+
FileValue,
|
|
184
|
+
Schema.Array(TransportValueSchema),
|
|
185
|
+
Schema.Record(Schema.String, Schema.UndefinedOr(TransportValueSchema))
|
|
186
|
+
]));
|
|
187
|
+
const TransportValueTypeSchema = Schema.toType(TransportValueSchema);
|
|
188
|
+
const TransportObjectTypeSchema = Schema.Record(Schema.String, Schema.UndefinedOr(TransportValueTypeSchema));
|
|
189
|
+
const encodeTransportValue = (value) => {
|
|
190
|
+
if (Predicate.isDate(value)) return Schema.encodeSync(Schema.DateFromMillis)(value);
|
|
191
|
+
if (isFileValue(value)) return Schema.encodeSync(FileValue)(value);
|
|
192
|
+
if (globalThis.Array.isArray(value)) return value.map(encodeTransportValue);
|
|
193
|
+
if (Predicate.isNumber(value)) return Schema.decodeSync(Schema.Finite)(value);
|
|
194
|
+
if (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isBoolean(value)) return value;
|
|
195
|
+
return Object.fromEntries(Object.entries(value).flatMap(([key, child]) => child === void 0 ? [] : [[key, encodeTransportValue(child)]]));
|
|
196
|
+
};
|
|
197
|
+
const encodeTransportObject = (value) => Schema.decodeUnknownSync(Schema.JsonObject)(encodeTransportValue(Schema.decodeUnknownSync(TransportObjectTypeSchema)(value)));
|
|
198
|
+
const collectDatePaths = (value, path, paths) => {
|
|
199
|
+
if (Predicate.isDate(value)) {
|
|
200
|
+
Schema.decodeSync(Schema.Date)(value);
|
|
201
|
+
paths.push(path);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (isFileValue(value)) return;
|
|
205
|
+
if (globalThis.Array.isArray(value)) {
|
|
206
|
+
for (const [index, child] of value.entries()) collectDatePaths(child, [...path, index], paths);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (value === void 0 || Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return;
|
|
210
|
+
for (const [key, child] of Object.entries(value)) collectDatePaths(child, [...path, key], paths);
|
|
211
|
+
};
|
|
212
|
+
const datePathsOf = (value) => {
|
|
213
|
+
const paths = [];
|
|
214
|
+
collectDatePaths(value, [], paths);
|
|
215
|
+
return paths;
|
|
216
|
+
};
|
|
217
|
+
const datePathsOfObject = (value) => datePathsOf(Schema.decodeUnknownSync(TransportObjectTypeSchema)(value));
|
|
218
|
+
const pathKey = (path) => JSON.stringify(path);
|
|
219
|
+
const decodeTransportValueAt = (value, path, encodedDatePaths) => {
|
|
220
|
+
if (encodedDatePaths.has(pathKey(path))) return Schema.decodeUnknownSync(Schema.DateFromMillis)(value);
|
|
221
|
+
if (Schema.is(EncodedFileValue)(value)) return Schema.decodeSync(FileValue)(value);
|
|
222
|
+
if (globalThis.Array.isArray(value)) return value.map((item, index) => decodeTransportValueAt(item, [...path, index], encodedDatePaths));
|
|
223
|
+
if (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return value;
|
|
224
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, decodeTransportValueAt(item, [...path, key], encodedDatePaths)]));
|
|
225
|
+
};
|
|
226
|
+
const decodeTransportValue = (value, datePaths) => decodeTransportValueAt(value, [], new Set(datePaths.map(pathKey)));
|
|
227
|
+
const decodeTransportObject = (value, datePaths) => {
|
|
228
|
+
const encodedDatePaths = new Set(datePaths.map(pathKey));
|
|
229
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, decodeTransportValueAt(child, [key], encodedDatePaths)]));
|
|
230
|
+
};
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region ../contracts/dist/runtime/result.js
|
|
233
|
+
const ResultTypeId = Symbol.for("ignotum/runtime/result/Result");
|
|
234
|
+
const CompletedResultTypeId = Symbol.for("ignotum/runtime/result/Completed");
|
|
235
|
+
const PendingResultTypeId = Symbol.for("ignotum/runtime/result/Pending");
|
|
236
|
+
const ErrorBrand = "ignotum/error";
|
|
237
|
+
const makeErrorValue = Brand.nominal();
|
|
238
|
+
const ErrorValueSchema = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Json)]).pipe(Schema.brand(ErrorBrand));
|
|
239
|
+
var InternalServerErrorCause = class extends Schema.TaggedError()("InternalServerError", { requestId: RequestId }) {};
|
|
240
|
+
const InternalServerErrorSchema = InternalServerErrorCause.pipe(Schema.brand(ErrorBrand));
|
|
241
|
+
const effectOf = (value) => Predicate.hasProperty(value, ResultTypeId) ? value[ResultTypeId] : Effect.succeed(value);
|
|
242
|
+
function makeResultEffectBase() {
|
|
243
|
+
const Base = function() {};
|
|
244
|
+
Base.prototype = Effectable.Prototype({
|
|
245
|
+
label: "IgnotumResult",
|
|
246
|
+
evaluate() {
|
|
247
|
+
return this[ResultTypeId];
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return Base;
|
|
251
|
+
}
|
|
252
|
+
const ResultEffectBase = makeResultEffectBase();
|
|
253
|
+
var ResultOperation = class ResultOperation extends ResultEffectBase {
|
|
254
|
+
[ResultTypeId];
|
|
255
|
+
constructor(effect, completed) {
|
|
256
|
+
super();
|
|
257
|
+
this[ResultTypeId] = effect;
|
|
258
|
+
if (completed !== void 0) Object.defineProperty(this, CompletedResultTypeId, { value: completed });
|
|
259
|
+
}
|
|
260
|
+
catch(cases) {
|
|
261
|
+
const effectCases = {};
|
|
262
|
+
for (const [tag, handler] of Object.entries(cases)) if (Predicate.isFunction(handler)) effectCases[tag] = (failure) => effectOf(handler(failure));
|
|
263
|
+
const runtimeEffect = this[ResultTypeId];
|
|
264
|
+
const caught = Effect.catchTags(runtimeEffect, effectCases);
|
|
265
|
+
return new ResultOperation(caught);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
var PendingQueryResult = class {
|
|
269
|
+
[PendingResultTypeId] = PendingResultTypeId;
|
|
270
|
+
};
|
|
271
|
+
const inspectResult = (value) => {
|
|
272
|
+
if (!Predicate.hasProperty(value, CompletedResultTypeId)) return void 0;
|
|
273
|
+
return value[CompletedResultTypeId];
|
|
274
|
+
};
|
|
275
|
+
const resultFromEffect = (effect) => new ResultOperation(effect);
|
|
276
|
+
const isFailureResult = (result) => Predicate.hasProperty(result, CompletedResultTypeId) && Predicate.isObject(result[CompletedResultTypeId]) && Predicate.hasProperty(result[CompletedResultTypeId], "type") && result[CompletedResultTypeId].type === "Failure";
|
|
277
|
+
const succeed = (value) => new ResultOperation(Effect.succeed(value), {
|
|
278
|
+
type: "Success",
|
|
279
|
+
value
|
|
280
|
+
});
|
|
281
|
+
const fail = (error) => new ResultOperation(Effect.fail(error), {
|
|
282
|
+
type: "Failure",
|
|
283
|
+
error
|
|
284
|
+
});
|
|
285
|
+
const tryResult = (body) => {
|
|
286
|
+
return new ResultOperation(Effect.gen(body));
|
|
287
|
+
};
|
|
288
|
+
const match = Function.dual(2, (result, matchers) => {
|
|
289
|
+
if (result instanceof PendingQueryResult) {
|
|
290
|
+
if (matchers.pending === void 0) throw new Error("A pending Result requires a pending matcher.");
|
|
291
|
+
return matchers.pending();
|
|
292
|
+
}
|
|
293
|
+
if (!Predicate.hasProperty(result, ResultTypeId)) throw new Error("Unknown Result implementation.");
|
|
294
|
+
const inspected = inspectResult(result);
|
|
295
|
+
if (inspected?.type === "Success") {
|
|
296
|
+
const value = inspected.value;
|
|
297
|
+
return matchers.value(value);
|
|
298
|
+
}
|
|
299
|
+
if (!isFailureResult(result)) throw new Error("Unknown or incomplete Result operation.");
|
|
300
|
+
const error = result[CompletedResultTypeId].error;
|
|
301
|
+
if (error._tag === "InternalServerError") {
|
|
302
|
+
const internalError = Schema.decodeUnknownSync(InternalServerErrorSchema)(error);
|
|
303
|
+
const handler = matchers.internalError;
|
|
304
|
+
if (handler === void 0) throw internalError;
|
|
305
|
+
return handler(internalError);
|
|
306
|
+
}
|
|
307
|
+
const errorMatcher = matchers.error;
|
|
308
|
+
if (errorMatcher === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);
|
|
309
|
+
if (Predicate.isFunction(errorMatcher)) return errorMatcher(error);
|
|
310
|
+
const handlers = errorMatcher;
|
|
311
|
+
const handler = Object.hasOwn(handlers, error._tag) ? handlers[error._tag] : void 0;
|
|
312
|
+
if (handler === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);
|
|
313
|
+
return handler(error);
|
|
314
|
+
});
|
|
315
|
+
const pending = () => new PendingQueryResult();
|
|
316
|
+
const failureFromWire = (error, datePaths = []) => {
|
|
317
|
+
const internalError = Schema.decodeUnknownOption(InternalServerErrorSchema)(error);
|
|
318
|
+
if (Option.isSome(internalError)) return fail(internalError.value);
|
|
319
|
+
const decoded = Schema.decodeUnknownOption(ErrorValueSchema)(error);
|
|
320
|
+
if (Option.isNone(decoded)) throw new Error("The server returned an invalid application error.");
|
|
321
|
+
const restored = decodeTransportObject(decoded.value, datePaths);
|
|
322
|
+
return fail(makeErrorValue({
|
|
323
|
+
...restored,
|
|
324
|
+
_tag: decoded.value._tag
|
|
325
|
+
}));
|
|
326
|
+
};
|
|
327
|
+
const documentNotFound = (table, id) => Brand.nominal()({
|
|
328
|
+
_tag: "DocumentNotFound",
|
|
329
|
+
table,
|
|
330
|
+
id
|
|
331
|
+
});
|
|
332
|
+
const Result$1 = {
|
|
333
|
+
fail,
|
|
334
|
+
match,
|
|
335
|
+
succeed,
|
|
336
|
+
try: tryResult
|
|
337
|
+
};
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region ../contracts/dist/versioned.js
|
|
340
|
+
/** Registers the first revision of a long-lived format. */
|
|
341
|
+
const initial = (schema) => schema;
|
|
342
|
+
/** Adds one adjacent migration and keeps encoding on the new current revision. */
|
|
343
|
+
const upgrade = (previous, current, migrate) => {
|
|
344
|
+
const accepted = Schema.Union([previous, current]);
|
|
345
|
+
const isCurrent = Schema.is(current);
|
|
346
|
+
return accepted.pipe(Schema.decodeTo(Schema.toType(current), {
|
|
347
|
+
decode: SchemaGetter.transform((value) => {
|
|
348
|
+
if (isCurrent(value)) return value;
|
|
349
|
+
return migrate(value);
|
|
350
|
+
}),
|
|
351
|
+
encode: SchemaGetter.transform((value) => value)
|
|
352
|
+
}));
|
|
353
|
+
};
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region ../contracts/dist/id.js
|
|
356
|
+
const DevelopmentUsername = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9_-]{0,63}$/));
|
|
357
|
+
const UserId = DevelopmentUsername.pipe(Schema.brand("ignotum/id/UserId"));
|
|
358
|
+
const User = Schema.Struct({
|
|
359
|
+
id: UserId,
|
|
360
|
+
name: Schema.optional(Schema.String),
|
|
361
|
+
email: Schema.optional(Schema.String),
|
|
362
|
+
image: Schema.optional(Schema.String)
|
|
363
|
+
});
|
|
364
|
+
const ProfileField = Schema.Literals([
|
|
365
|
+
"name",
|
|
366
|
+
"email",
|
|
367
|
+
"image"
|
|
368
|
+
]);
|
|
369
|
+
const ProfileFields = Schema.Array(ProfileField).check(Schema.isUnique());
|
|
370
|
+
const IdRequired = Schema.TaggedStruct("IdRequired", {}).pipe(Schema.brand(ErrorBrand));
|
|
371
|
+
const makeIdContext = (read) => ({
|
|
372
|
+
current: () => resultFromEffect(read),
|
|
373
|
+
require: () => resultFromEffect(read.pipe(Effect.flatMap((user) => user === null ? Effect.fail(IdRequired.make({})) : Effect.succeed(user))))
|
|
374
|
+
});
|
|
375
|
+
const SessionState = Schema.Struct({
|
|
376
|
+
sessionEpoch: Schema.String,
|
|
377
|
+
viewRevision: Schema.Natural,
|
|
378
|
+
user: Schema.NullOr(User),
|
|
379
|
+
validUntil: Schema.Finite
|
|
380
|
+
});
|
|
381
|
+
const SessionResponse = Schema.Struct({
|
|
382
|
+
development: Schema.optional(Schema.Literal(true)),
|
|
383
|
+
outcome: Schema.optional(Schema.Literals([
|
|
384
|
+
"SignedIn",
|
|
385
|
+
"ProfileUpdated",
|
|
386
|
+
"Cancelled"
|
|
387
|
+
])),
|
|
388
|
+
...SessionState.fields,
|
|
389
|
+
serverTime: Schema.Finite,
|
|
390
|
+
expiresAt: Schema.Finite
|
|
391
|
+
});
|
|
392
|
+
const ReturnPath = Schema.String.check(Schema.makeFilter((value) => {
|
|
393
|
+
if (!value.startsWith("/") || value.startsWith("//") || value.includes("\\")) return false;
|
|
394
|
+
const url = new URL(value, "https://app.ignotum.invalid");
|
|
395
|
+
return url.origin === "https://app.ignotum.invalid" && url.pathname !== "/_ignotum" && !url.pathname.startsWith("/_ignotum/");
|
|
396
|
+
}, { message: "Return to a path within this app." }));
|
|
397
|
+
const SessionRequest = Schema.Struct({
|
|
398
|
+
intent: Schema.Literals(["signIn", "requestProfile"]),
|
|
399
|
+
profile: ProfileFields,
|
|
400
|
+
returnTo: ReturnPath,
|
|
401
|
+
sessionEpoch: Schema.String
|
|
402
|
+
});
|
|
403
|
+
const SessionRedirect = Schema.Struct({
|
|
404
|
+
redirectUrl: Schema.String,
|
|
405
|
+
expiresAt: Schema.Finite
|
|
406
|
+
});
|
|
407
|
+
const SessionOutcome = Schema.Literals([
|
|
408
|
+
"SignedIn",
|
|
409
|
+
"ProfileUpdated",
|
|
410
|
+
"Cancelled"
|
|
411
|
+
]);
|
|
412
|
+
const sessionPath = "/_ignotum/v1/session";
|
|
413
|
+
const sessionRequestsPath = `${sessionPath}/requests`;
|
|
414
|
+
const DevelopmentSelection = initial(Schema.Struct({
|
|
415
|
+
formatVersion: Schema.Literal(1),
|
|
416
|
+
username: Schema.NullOr(DevelopmentUsername),
|
|
417
|
+
epoch: Schema.String
|
|
418
|
+
}));
|
|
419
|
+
const developmentSelectionKey = "ignotum.id.development";
|
|
420
|
+
//#endregion
|
|
421
|
+
export { RuntimeFileMetadata as A, makeFileValue as B, TransportObjectTypeSchema as C, encodeTransportObject as D, decodeTransportValue as E, fileIdOf as F, IdAlphabet as G, AppId as H, fileLimits as I, SessionEpoch as J, InvocationId as K, fileMimeTypes as L, constrainedFileValue as M, fileFormats as N, FileFormat as O, fileGrantUrlOf as P, grantFileValue as R, resultFromEffect as S, datePathsOfObject as T, DeploymentId as U, runtimeFileOccurrencesOf as V, GeneratedId as W, TableId as X, SubscriptionId as Y, Result$1 as _, SessionResponse as a, inspectResult as b, UserId as c, sessionPath as d, sessionRequestsPath as f, ErrorValueSchema as g, ErrorBrand as h, SessionRequest as i, RuntimeFileOccurrence as j, FileId as k, developmentSelectionKey as l, upgrade as m, SessionOutcome as n, SessionState as o, initial as p, RuntimeRequestNonce as q, SessionRedirect as r, User as s, DevelopmentSelection as t, makeIdContext as u, documentNotFound as v, datePathsOf as w, pending as x, failureFromWire as y, isFileValue as z };
|
|
422
|
+
|
|
423
|
+
//# sourceMappingURL=id-Bt9XWRGL.js.map
|