ignotum 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -101
- package/dist/cli/bin.mjs +1487 -168
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/{api-DtX8qPrq.js → api-BTeMI5tx.js} +27 -3
- package/dist/runtime/api-BTeMI5tx.js.map +1 -0
- package/dist/runtime/{api-D2bsAz4T.d.ts → api-D9lV-5av.d.ts} +7 -10
- package/dist/runtime/client.d.ts +27 -3
- package/dist/runtime/client.js +468 -68
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/{descriptor-t6BOEGw9-BTHR-ZMv.js → descriptor-C5VA9qRl-C338iC6l.js} +63 -5
- package/dist/runtime/descriptor-C5VA9qRl-C338iC6l.js.map +1 -0
- package/dist/runtime/file-BXf63ulU.js +166 -0
- package/dist/runtime/file-BXf63ulU.js.map +1 -0
- package/dist/runtime/{result-BgcHn25t.d.ts → id-Btwac71X-DGj0DQuu.d.ts} +56 -4
- package/dist/runtime/{index-Dl_VQGmA.d.ts → index-CF04_Dps.d.ts} +96 -86
- package/dist/runtime/internal/api.d.ts +2 -2
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/host.d.ts +25 -8
- package/dist/runtime/internal/host.js +209 -15
- 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-BNFhAjns.d.ts +1 -0
- package/dist/runtime/pagination-DrOowBve-Bnipd34u.d.ts +84 -0
- package/dist/runtime/{schema-B-jMZEbs.js → schema-DJfwfq87.js} +108 -30
- package/dist/runtime/schema-DJfwfq87.js.map +1 -0
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/sync-mIXn9eKv.d.ts +8 -0
- package/package.json +2 -2
- package/src/cli/agent-files.ts +56 -13
- package/src/cli/app-configuration.ts +4 -1
- package/src/cli/build/server.ts +83 -6
- package/src/cli/new-app.ts +15 -0
- package/src/client/files.ts +168 -0
- package/src/client/hooks.ts +166 -17
- package/src/client/index.ts +9 -1
- package/src/client/sync.ts +137 -21
- package/src/dev-runtime/database.ts +621 -78
- package/src/dev-runtime/files.ts +338 -0
- package/src/dev-runtime/functions.ts +14 -6
- package/src/dev-runtime/migrations.ts +44 -0
- package/src/dev-runtime/sync.ts +123 -5
- package/src/internal/api.ts +16 -1
- package/src/server/index.ts +8 -1
- package/dist/runtime/api-DtX8qPrq.js.map +0 -1
- package/dist/runtime/descriptor-t6BOEGw9-BTHR-ZMv.js.map +0 -1
- package/dist/runtime/id-Btwac71X-B9OeBzvq.d.ts +0 -9
- package/dist/runtime/id-D570vudg.js +0 -26
- package/dist/runtime/id-D570vudg.js.map +0 -1
- package/dist/runtime/schema-B-jMZEbs.js.map +0 -1
|
@@ -1,36 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { c as fileFormats, d as fileLimits, n as FileFormat, s as constrainedFileValue, y as GeneratedId } from "./file-BXf63ulU.js";
|
|
2
|
+
import { a as PaginationCursor, i as getValueDescriptor, l as ErrorBrand, n as attachValueDescriptor, o as PaginationPageSize, r as descriptorFields } from "./descriptor-C5VA9qRl-C338iC6l.js";
|
|
3
3
|
import { Schema, Struct } from "effect";
|
|
4
|
-
//#region ../contracts/dist/runtime/schema.js
|
|
5
|
-
const FunctionSchemaTypeId = Symbol.for("ignotum/runtime/schema/FunctionSchema");
|
|
6
|
-
const attachFunctionSchema = (schema) => (definition) => {
|
|
7
|
-
Object.defineProperty(definition, FunctionSchemaTypeId, {
|
|
8
|
-
configurable: false,
|
|
9
|
-
enumerable: false,
|
|
10
|
-
value: schema,
|
|
11
|
-
writable: false
|
|
12
|
-
});
|
|
13
|
-
return definition;
|
|
14
|
-
};
|
|
15
|
-
const getFunctionSchema = (value) => value[FunctionSchemaTypeId];
|
|
16
|
-
//#endregion
|
|
17
4
|
//#region ../contracts/dist/schema/values.js
|
|
18
5
|
const LiteralValueSchema = Schema.Union([
|
|
19
6
|
Schema.String,
|
|
20
7
|
Schema.Finite,
|
|
21
8
|
Schema.Boolean
|
|
22
9
|
]);
|
|
10
|
+
const schemaIndexLimits = {
|
|
11
|
+
fieldsPerIndex: 8,
|
|
12
|
+
indexesPerSchema: 128,
|
|
13
|
+
indexesPerTable: 16,
|
|
14
|
+
keyBytes: 4096,
|
|
15
|
+
nameBytes: 64
|
|
16
|
+
};
|
|
17
|
+
const utf8ByteLength = (value) => {
|
|
18
|
+
let bytes = 0;
|
|
19
|
+
for (const character of value) {
|
|
20
|
+
const point = character.codePointAt(0) ?? 0;
|
|
21
|
+
bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
22
|
+
}
|
|
23
|
+
return bytes;
|
|
24
|
+
};
|
|
23
25
|
const table = (fields) => {
|
|
24
26
|
const tableFields = fields;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const make = (indexes) => {
|
|
28
|
+
const index = (name, fieldNames) => {
|
|
29
|
+
if (utf8ByteLength(name) > schemaIndexLimits.nameBytes) throw new Error(`Index names cannot exceed ${schemaIndexLimits.nameBytes} UTF-8 bytes.`);
|
|
30
|
+
if (name.length === 0) throw new Error("Index names cannot be empty.");
|
|
31
|
+
if (name.startsWith("$")) throw new Error("Index names beginning with '$' are reserved.");
|
|
32
|
+
if (Object.hasOwn(indexes, name)) throw new Error(`Duplicate index name '${name}'.`);
|
|
33
|
+
if (fieldNames.length > schemaIndexLimits.fieldsPerIndex) throw new Error(`Indexes cannot contain more than ${schemaIndexLimits.fieldsPerIndex} fields.`);
|
|
34
|
+
if (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Index '${name}' contains duplicate fields.`);
|
|
35
|
+
for (const fieldName of fieldNames) {
|
|
36
|
+
if (!Object.hasOwn(tableFields, fieldName)) throw new Error(`Index '${name}' references unknown field '${fieldName}'.`);
|
|
37
|
+
const descriptor = getValueDescriptor(tableFields[fieldName]);
|
|
38
|
+
if (!(descriptor?.type === "boolean" || descriptor?.type === "date" || descriptor?.type === "id" || descriptor?.type === "integer" || descriptor?.type === "number" || descriptor?.type === "string" || descriptor?.type === "literal" || descriptor?.type === "literals")) throw new Error(`Index '${name}' field '${fieldName}' is not indexable.`);
|
|
39
|
+
if (descriptor.type === "literals" && !(descriptor.values.every(Schema.is(Schema.Boolean)) || descriptor.values.every(Schema.is(Schema.Finite)) || descriptor.values.every(Schema.is(Schema.String)))) throw new Error(`Index '${name}' field '${fieldName}' mixes value types.`);
|
|
40
|
+
}
|
|
41
|
+
const duplicate = Object.values(indexes).find((candidate) => candidate.fields.length === fieldNames.length && candidate.fields.every((fieldName, position) => fieldName === fieldNames[position]));
|
|
42
|
+
if (duplicate !== void 0) throw new Error(`Index '${name}' duplicates index '${duplicate.name}'.`);
|
|
43
|
+
if (Object.keys(indexes).length >= schemaIndexLimits.indexesPerTable) throw new Error(`Tables cannot declare more than ${schemaIndexLimits.indexesPerTable} indexes.`);
|
|
44
|
+
return make({
|
|
45
|
+
...indexes,
|
|
46
|
+
[name]: {
|
|
47
|
+
name,
|
|
48
|
+
fields: fieldNames
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
_tag: "Table",
|
|
54
|
+
descriptor: {
|
|
55
|
+
type: "object",
|
|
56
|
+
fields: descriptorFields(tableFields)
|
|
57
|
+
},
|
|
58
|
+
fields: tableFields,
|
|
59
|
+
index,
|
|
60
|
+
indexes,
|
|
61
|
+
schema: Schema.Struct(tableFields)
|
|
62
|
+
};
|
|
33
63
|
};
|
|
64
|
+
return make({});
|
|
34
65
|
};
|
|
35
66
|
const fresh = (value) => value.pipe(Schema.annotate({}));
|
|
36
67
|
const string = () => attachValueDescriptor(fresh(Schema.String), { type: "string" });
|
|
@@ -38,6 +69,19 @@ const number = () => attachValueDescriptor(fresh(Schema.Finite), { type: "number
|
|
|
38
69
|
const integer = () => attachValueDescriptor(fresh(Schema.Int), { type: "integer" });
|
|
39
70
|
const boolean = () => attachValueDescriptor(fresh(Schema.Boolean), { type: "boolean" });
|
|
40
71
|
const date = () => attachValueDescriptor(fresh(Schema.DateFromMillis), { type: "date" });
|
|
72
|
+
const file = (options = {}) => {
|
|
73
|
+
const formats = options.formats ?? fileFormats;
|
|
74
|
+
if (formats.length === 0) throw new Error("File format lists cannot be empty.");
|
|
75
|
+
Schema.decodeUnknownSync(Schema.Array(FileFormat))(formats);
|
|
76
|
+
if (new Set(formats).size !== formats.length) throw new Error("File format lists cannot contain duplicates.");
|
|
77
|
+
const maxBytes = options.maxBytes ?? fileLimits.fileBytes;
|
|
78
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || maxBytes > fileLimits.fileBytes) throw new Error(`File sizes must be between 1 and ${fileLimits.fileBytes} bytes.`);
|
|
79
|
+
return attachValueDescriptor(constrainedFileValue(formats, maxBytes), {
|
|
80
|
+
type: "file",
|
|
81
|
+
formats: [...formats],
|
|
82
|
+
maxBytes
|
|
83
|
+
});
|
|
84
|
+
};
|
|
41
85
|
const never = () => attachValueDescriptor(fresh(Schema.Never), { type: "never" });
|
|
42
86
|
const nullValue = () => attachValueDescriptor(fresh(Schema.Null), { type: "null" });
|
|
43
87
|
const literal = (value) => {
|
|
@@ -143,6 +187,17 @@ const union = (...members) => {
|
|
|
143
187
|
members: members.map(requireDescriptor)
|
|
144
188
|
});
|
|
145
189
|
};
|
|
190
|
+
const paginationCursor = () => attachValueDescriptor(fresh(PaginationCursor), { type: "string" });
|
|
191
|
+
const pagination = () => fixedObject({
|
|
192
|
+
cursor: nullable(paginationCursor()),
|
|
193
|
+
pageSize: attachValueDescriptor(fresh(PaginationPageSize), { type: "integer" })
|
|
194
|
+
});
|
|
195
|
+
const page = (value) => {
|
|
196
|
+
return fixedObject({
|
|
197
|
+
items: array(value),
|
|
198
|
+
nextCursor: nullable(paginationCursor())
|
|
199
|
+
});
|
|
200
|
+
};
|
|
146
201
|
const error = (tag, fields) => {
|
|
147
202
|
if (tag === "InternalServerError") throw new Error("The error tag 'InternalServerError' is reserved by Ignotum.");
|
|
148
203
|
const errorFields = { ...fields };
|
|
@@ -162,6 +217,7 @@ const values = {
|
|
|
162
217
|
array,
|
|
163
218
|
boolean,
|
|
164
219
|
date,
|
|
220
|
+
file,
|
|
165
221
|
error,
|
|
166
222
|
id,
|
|
167
223
|
integer,
|
|
@@ -190,22 +246,44 @@ const bindValues = (definition) => {
|
|
|
190
246
|
};
|
|
191
247
|
return fixedObject(Struct.assign(tableFields, systemFields));
|
|
192
248
|
};
|
|
249
|
+
const boundPagination = () => {
|
|
250
|
+
return pagination();
|
|
251
|
+
};
|
|
193
252
|
return {
|
|
194
253
|
...values,
|
|
195
254
|
doc,
|
|
196
|
-
id: boundId
|
|
255
|
+
id: boundId,
|
|
256
|
+
page,
|
|
257
|
+
pagination: boundPagination
|
|
197
258
|
};
|
|
198
259
|
};
|
|
199
260
|
//#endregion
|
|
261
|
+
//#region ../contracts/dist/runtime/schema.js
|
|
262
|
+
const FunctionSchemaTypeId = Symbol.for("ignotum/runtime/schema/FunctionSchema");
|
|
263
|
+
const attachFunctionSchema = (schema) => (definition) => {
|
|
264
|
+
Object.defineProperty(definition, FunctionSchemaTypeId, {
|
|
265
|
+
configurable: false,
|
|
266
|
+
enumerable: false,
|
|
267
|
+
value: schema,
|
|
268
|
+
writable: false
|
|
269
|
+
});
|
|
270
|
+
return definition;
|
|
271
|
+
};
|
|
272
|
+
const getFunctionSchema = (value) => value[FunctionSchemaTypeId];
|
|
273
|
+
//#endregion
|
|
200
274
|
//#region ../contracts/dist/schema/index.js
|
|
201
275
|
const SchemaDefinitionTypeId = Symbol.for("ignotum/schema/SchemaDefinition");
|
|
202
|
-
const defineSchema = (define) =>
|
|
203
|
-
|
|
204
|
-
[SchemaDefinitionTypeId]: define({
|
|
276
|
+
const defineSchema = (define) => {
|
|
277
|
+
const definitions = define({
|
|
205
278
|
table,
|
|
206
279
|
values
|
|
207
|
-
})
|
|
208
|
-
});
|
|
280
|
+
});
|
|
281
|
+
if (Object.values(definitions).reduce((count, definition) => count + Object.keys(definition.indexes).length, 0) > schemaIndexLimits.indexesPerSchema) throw new Error(`Schemas cannot declare more than ${schemaIndexLimits.indexesPerSchema} indexes.`);
|
|
282
|
+
return {
|
|
283
|
+
_tag: "Schema",
|
|
284
|
+
[SchemaDefinitionTypeId]: definitions
|
|
285
|
+
};
|
|
286
|
+
};
|
|
209
287
|
const makeFunctionBuilder = (schema, kind) => {
|
|
210
288
|
const define = (definition) => attachFunctionSchema(schema)({
|
|
211
289
|
_tag: kind,
|
|
@@ -224,4 +302,4 @@ const bindSchema = (schema) => ({
|
|
|
224
302
|
//#endregion
|
|
225
303
|
export { getFunctionSchema as i, bindSchema as n, defineSchema as r, SchemaDefinitionTypeId as t };
|
|
226
304
|
|
|
227
|
-
//# sourceMappingURL=schema-
|
|
305
|
+
//# sourceMappingURL=schema-DJfwfq87.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-DJfwfq87.js","names":[],"sources":["../../../contracts/dist/schema/values.js","../../../contracts/dist/runtime/schema.js","../../../contracts/dist/schema/index.js"],"sourcesContent":["import { GeneratedId } from \"../runtime/id.js\";\nimport { FileFormat, constrainedFileValue, fileFormats, fileLimits } from \"./file.js\";\nimport { a as descriptorFields, o as getValueDescriptor, r as attachValueDescriptor } from \"../descriptor-C5VA9qRl.js\";\nimport { PaginationCursor, PaginationPageSize } from \"../runtime/pagination.js\";\nimport { ErrorBrand } from \"../runtime/result.js\";\nimport { Schema, Struct } from \"effect\";\n//#region src/schema/values.ts\nconst LiteralValueSchema = Schema.Union([\n\tSchema.String,\n\tSchema.Finite,\n\tSchema.Boolean\n]);\nconst schemaIndexLimits = {\n\tfieldsPerIndex: 8,\n\tindexesPerSchema: 128,\n\tindexesPerTable: 16,\n\tkeyBytes: 4096,\n\tnameBytes: 64\n};\nconst utf8ByteLength = (value) => {\n\tlet bytes = 0;\n\tfor (const character of value) {\n\t\tconst point = character.codePointAt(0) ?? 0;\n\t\tbytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;\n\t}\n\treturn bytes;\n};\nconst table = (fields) => {\n\tconst tableFields = fields;\n\tconst make = (indexes) => {\n\t\tconst index = (name, fieldNames) => {\n\t\t\tif (utf8ByteLength(name) > schemaIndexLimits.nameBytes) throw new Error(`Index names cannot exceed ${schemaIndexLimits.nameBytes} UTF-8 bytes.`);\n\t\t\tif (name.length === 0) throw new Error(\"Index names cannot be empty.\");\n\t\t\tif (name.startsWith(\"$\")) throw new Error(\"Index names beginning with '$' are reserved.\");\n\t\t\tif (Object.hasOwn(indexes, name)) throw new Error(`Duplicate index name '${name}'.`);\n\t\t\tif (fieldNames.length > schemaIndexLimits.fieldsPerIndex) throw new Error(`Indexes cannot contain more than ${schemaIndexLimits.fieldsPerIndex} fields.`);\n\t\t\tif (new Set(fieldNames).size !== fieldNames.length) throw new Error(`Index '${name}' contains duplicate fields.`);\n\t\t\tfor (const fieldName of fieldNames) {\n\t\t\t\tif (!Object.hasOwn(tableFields, fieldName)) throw new Error(`Index '${name}' references unknown field '${fieldName}'.`);\n\t\t\t\tconst descriptor = getValueDescriptor(tableFields[fieldName]);\n\t\t\t\tif (!(descriptor?.type === \"boolean\" || descriptor?.type === \"date\" || descriptor?.type === \"id\" || descriptor?.type === \"integer\" || descriptor?.type === \"number\" || descriptor?.type === \"string\" || descriptor?.type === \"literal\" || descriptor?.type === \"literals\")) throw new Error(`Index '${name}' field '${fieldName}' is not indexable.`);\n\t\t\t\tif (descriptor.type === \"literals\" && !(descriptor.values.every(Schema.is(Schema.Boolean)) || descriptor.values.every(Schema.is(Schema.Finite)) || descriptor.values.every(Schema.is(Schema.String)))) throw new Error(`Index '${name}' field '${fieldName}' mixes value types.`);\n\t\t\t}\n\t\t\tconst duplicate = Object.values(indexes).find((candidate) => candidate.fields.length === fieldNames.length && candidate.fields.every((fieldName, position) => fieldName === fieldNames[position]));\n\t\t\tif (duplicate !== void 0) throw new Error(`Index '${name}' duplicates index '${duplicate.name}'.`);\n\t\t\tif (Object.keys(indexes).length >= schemaIndexLimits.indexesPerTable) throw new Error(`Tables cannot declare more than ${schemaIndexLimits.indexesPerTable} indexes.`);\n\t\t\treturn make({\n\t\t\t\t...indexes,\n\t\t\t\t[name]: {\n\t\t\t\t\tname,\n\t\t\t\t\tfields: fieldNames\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\treturn {\n\t\t\t_tag: \"Table\",\n\t\t\tdescriptor: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tfields: descriptorFields(tableFields)\n\t\t\t},\n\t\t\tfields: tableFields,\n\t\t\tindex,\n\t\t\tindexes,\n\t\t\tschema: Schema.Struct(tableFields)\n\t\t};\n\t};\n\treturn make({});\n};\nconst fresh = (value) => value.pipe(Schema.annotate({}));\nconst string = () => attachValueDescriptor(fresh(Schema.String), { type: \"string\" });\nconst number = () => attachValueDescriptor(fresh(Schema.Finite), { type: \"number\" });\nconst integer = () => attachValueDescriptor(fresh(Schema.Int), { type: \"integer\" });\nconst boolean = () => attachValueDescriptor(fresh(Schema.Boolean), { type: \"boolean\" });\nconst date = () => attachValueDescriptor(fresh(Schema.DateFromMillis), { type: \"date\" });\nconst file = (options = {}) => {\n\tconst formats = options.formats ?? fileFormats;\n\tif (formats.length === 0) throw new Error(\"File format lists cannot be empty.\");\n\tSchema.decodeUnknownSync(Schema.Array(FileFormat))(formats);\n\tif (new Set(formats).size !== formats.length) throw new Error(\"File format lists cannot contain duplicates.\");\n\tconst maxBytes = options.maxBytes ?? fileLimits.fileBytes;\n\tif (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || maxBytes > fileLimits.fileBytes) throw new Error(`File sizes must be between 1 and ${fileLimits.fileBytes} bytes.`);\n\treturn attachValueDescriptor(constrainedFileValue(formats, maxBytes), {\n\t\ttype: \"file\",\n\t\tformats: [...formats],\n\t\tmaxBytes\n\t});\n};\nconst never = () => attachValueDescriptor(fresh(Schema.Never), { type: \"never\" });\nconst nullValue = () => attachValueDescriptor(fresh(Schema.Null), { type: \"null\" });\nconst literal = (value) => {\n\tSchema.decodeSync(LiteralValueSchema)(value);\n\treturn attachValueDescriptor(Schema.Literal(value), {\n\t\ttype: \"literal\",\n\t\tvalue\n\t});\n};\nconst literals = (...members) => {\n\tSchema.decodeSync(Schema.Array(LiteralValueSchema))(members);\n\treturn attachValueDescriptor(Schema.Literals(members), {\n\t\ttype: \"literals\",\n\t\tvalues: members\n\t});\n};\nconst makeIdSchema = (tableName) => {\n\tconst identifier = `ignotum/id/${tableName}`;\n\treturn attachValueDescriptor(GeneratedId.pipe(Schema.brand(identifier), Schema.annotate({ \"ignotum/table\": tableName })), {\n\t\ttype: \"id\",\n\t\ttable: tableName\n\t});\n};\nconst id = (tableName) => makeIdSchema(tableName);\nconst requireDescriptor = (value) => {\n\tconst descriptor = getValueDescriptor(value);\n\tif (descriptor === void 0) throw new Error(\"Ignotum value combinators require a values validator.\");\n\treturn descriptor;\n};\nconst array = (value) => {\n\treturn attachValueDescriptor(Schema.Array(value), {\n\t\ttype: \"array\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst assertFieldsExist = (fields, keys, operation) => {\n\tfor (const key of keys) if (!Object.hasOwn(fields, key)) throw new Error(`Cannot ${operation} unknown field '${String(key)}'.`);\n};\nconst fixedObject = (fields) => {\n\tconst pick = (...keys) => {\n\t\tassertFieldsExist(fields, keys, \"pick\");\n\t\treturn fixedObject(Struct.pick(fields, keys));\n\t};\n\tconst omit = (...keys) => {\n\t\tassertFieldsExist(fields, keys, \"omit\");\n\t\treturn fixedObject(Struct.omit(fields, keys));\n\t};\n\tconst extend = (addedFields, ..._validation) => {\n\t\tfor (const key of Reflect.ownKeys(addedFields)) if (Object.hasOwn(fields, key)) throw new Error(`Cannot extend existing field '${String(key)}'.`);\n\t\treturn fixedObject(Struct.assign(fields, addedFields));\n\t};\n\tconst override = (overriddenFields, ..._validation) => {\n\t\tassertFieldsExist(fields, Reflect.ownKeys(overriddenFields), \"override\");\n\t\treturn fixedObject(Struct.assign(fields, overriddenFields));\n\t};\n\tconst partial = () => {\n\t\tconst partialFields = Struct.map(fields, Schema.optional);\n\t\tfor (const name of Reflect.ownKeys(fields)) {\n\t\t\tconst field = fields[name];\n\t\t\tconst partialField = partialFields[name];\n\t\t\tif (field === void 0 || partialField === void 0) continue;\n\t\t\tattachValueDescriptor(partialField, {\n\t\t\t\ttype: \"optional\",\n\t\t\t\tvalue: requireDescriptor(field)\n\t\t\t});\n\t\t}\n\t\treturn fixedObject(partialFields);\n\t};\n\tconst schema = attachValueDescriptor(Schema.Struct(fields), {\n\t\ttype: \"object\",\n\t\tfields: descriptorFields(fields)\n\t});\n\treturn Object.assign(schema, {\n\t\textend,\n\t\tomit,\n\t\toverride,\n\t\tpartial,\n\t\tpick\n\t});\n};\nconst object = (fields) => fixedObject(fields);\nconst optional = (value) => {\n\treturn attachValueDescriptor(Schema.optional(value), {\n\t\ttype: \"optional\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst nullable = (value) => {\n\treturn attachValueDescriptor(Schema.NullOr(value), {\n\t\ttype: \"nullable\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst record = (value) => {\n\treturn attachValueDescriptor(Schema.Record(Schema.String, value), {\n\t\ttype: \"record\",\n\t\tvalue: requireDescriptor(value)\n\t});\n};\nconst union = (...members) => {\n\treturn attachValueDescriptor(Schema.Union(members), {\n\t\ttype: \"union\",\n\t\tmembers: members.map(requireDescriptor)\n\t});\n};\nconst paginationCursor = () => attachValueDescriptor(fresh(PaginationCursor), { type: \"string\" });\nconst pagination = () => fixedObject({\n\tcursor: nullable(paginationCursor()),\n\tpageSize: attachValueDescriptor(fresh(PaginationPageSize), { type: \"integer\" })\n});\nconst page = (value) => {\n\treturn fixedObject({\n\t\titems: array(value),\n\t\tnextCursor: nullable(paginationCursor())\n\t});\n};\nconst error = (tag, fields) => {\n\tif (tag === \"InternalServerError\") throw new Error(\"The error tag 'InternalServerError' is reserved by Ignotum.\");\n\tconst errorFields = { ...fields };\n\tReflect.deleteProperty(errorFields, \"_tag\");\n\tconst schema = Schema.TaggedStruct(tag, errorFields).pipe(Schema.brand(ErrorBrand));\n\tconst make = (input) => schema.make(input);\n\tconst definition = Object.assign(make, schema);\n\tObject.setPrototypeOf(definition, Object.getPrototypeOf(schema));\n\tattachValueDescriptor(definition, {\n\t\ttype: \"error\",\n\t\ttag,\n\t\tfields: descriptorFields(errorFields)\n\t});\n\treturn definition;\n};\nconst values = {\n\tarray,\n\tboolean,\n\tdate,\n\tfile,\n\terror,\n\tid,\n\tinteger,\n\tliteral,\n\tliterals,\n\tnever,\n\tnull: nullValue,\n\tnullable,\n\tnumber,\n\tobject,\n\toptional,\n\trecord,\n\tstring,\n\tunion\n};\nconst bindValues = (definition) => {\n\tconst boundId = (tableName) => makeIdSchema(tableName);\n\tconst doc = (tableName) => {\n\t\tconst tableDefinition = definition[tableName];\n\t\tif (tableDefinition === void 0) throw new Error(`Unknown table '${tableName}'.`);\n\t\tconst tableFields = tableDefinition.fields;\n\t\tconst systemFields = {\n\t\t\tid: boundId(tableName),\n\t\t\tcreatedAt: date(),\n\t\t\tupdatedAt: date()\n\t\t};\n\t\treturn fixedObject(Struct.assign(tableFields, systemFields));\n\t};\n\tconst boundPagination = () => {\n\t\treturn pagination();\n\t};\n\treturn {\n\t\t...values,\n\t\tdoc,\n\t\tid: boundId,\n\t\tpage,\n\t\tpagination: boundPagination\n\t};\n};\n//#endregion\nexport { bindValues, schemaIndexLimits, table, values };\n\n//# sourceMappingURL=values.js.map","//#region src/runtime/schema.ts\nconst FunctionSchemaTypeId = Symbol.for(\"ignotum/runtime/schema/FunctionSchema\");\nconst attachFunctionSchema = (schema) => (definition) => {\n\tObject.defineProperty(definition, FunctionSchemaTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: schema,\n\t\twritable: false\n\t});\n\treturn definition;\n};\nconst getFunctionSchema = (value) => value[FunctionSchemaTypeId];\n//#endregion\nexport { FunctionSchemaTypeId, attachFunctionSchema, getFunctionSchema };\n\n//# sourceMappingURL=schema.js.map","import { FileFormat, FileId, FileValue, FileValueTypeId, fileFormats, fileLimits, fileMimeTypes, isFileValue } from \"./file.js\";\nimport { a as descriptorFields, i as descriptorContainsFile, n as ValueDescriptorTypeId, o as getValueDescriptor, t as ValueDescriptor } from \"../descriptor-C5VA9qRl.js\";\nimport { Result } from \"../runtime/result.js\";\nimport { bindValues, schemaIndexLimits, table, values } from \"./values.js\";\nimport { attachFunctionSchema } from \"../runtime/schema.js\";\nimport { Predicate } from \"effect\";\n//#region src/schema/types.ts\nconst SchemaDefinitionTypeId = Symbol.for(\"ignotum/schema/SchemaDefinition\");\n//#endregion\n//#region src/schema/definition.ts\nconst defineSchema = (define) => {\n\tconst definitions = define({\n\t\ttable,\n\t\tvalues\n\t});\n\tif (Object.values(definitions).reduce((count, definition) => count + Object.keys(definition.indexes).length, 0) > schemaIndexLimits.indexesPerSchema) throw new Error(`Schemas cannot declare more than ${schemaIndexLimits.indexesPerSchema} indexes.`);\n\treturn {\n\t\t_tag: \"Schema\",\n\t\t[SchemaDefinitionTypeId]: definitions\n\t};\n};\nconst isDefinedSchema = (value) => value._tag === \"Schema\" && Predicate.isObject(value[SchemaDefinitionTypeId]);\n//#endregion\n//#region src/schema/server.ts\nconst makeFunctionBuilder = (schema, kind) => {\n\tconst define = (definition) => attachFunctionSchema(schema)({\n\t\t_tag: kind,\n\t\t...definition\n\t});\n\treturn define;\n};\nconst makeFunctionBuilders = (schema) => ({\n\tmutation: makeFunctionBuilder(schema, \"Mutation\"),\n\tquery: makeFunctionBuilder(schema, \"Query\")\n});\nconst bindSchema = (schema) => ({\n\tvalues: bindValues(schema[SchemaDefinitionTypeId]),\n\t...makeFunctionBuilders(schema)\n});\n//#endregion\nexport { FileFormat, FileId, FileValue, FileValueTypeId, Result, SchemaDefinitionTypeId, ValueDescriptor, ValueDescriptorTypeId, bindSchema, bindValues, defineSchema, descriptorContainsFile, descriptorFields, fileFormats, fileLimits, fileMimeTypes, getValueDescriptor, isDefinedSchema, isFileValue, schemaIndexLimits, table, values };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;;;AAOA,MAAM,qBAAqB,OAAO,MAAM;CACvC,OAAO;CACP,OAAO;CACP,OAAO;AACR,CAAC;AACD,MAAM,oBAAoB;CACzB,gBAAgB;CAChB,kBAAkB;CAClB,iBAAiB;CACjB,UAAU;CACV,WAAW;AACZ;AACA,MAAM,kBAAkB,UAAU;CACjC,IAAI,QAAQ;CACZ,KAAK,MAAM,aAAa,OAAO;EAC9B,MAAM,QAAQ,UAAU,YAAY,CAAC,KAAK;EAC1C,SAAS,SAAS,MAAM,IAAI,SAAS,OAAO,IAAI,SAAS,QAAQ,IAAI;CACtE;CACA,OAAO;AACR;AACA,MAAM,SAAS,WAAW;CACzB,MAAM,cAAc;CACpB,MAAM,QAAQ,YAAY;EACzB,MAAM,SAAS,MAAM,eAAe;GACnC,IAAI,eAAe,IAAI,IAAI,kBAAkB,WAAW,MAAM,IAAI,MAAM,6BAA6B,kBAAkB,UAAU,cAAc;GAC/I,IAAI,KAAK,WAAW,GAAG,MAAM,IAAI,MAAM,8BAA8B;GACrE,IAAI,KAAK,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,8CAA8C;GACxF,IAAI,OAAO,OAAO,SAAS,IAAI,GAAG,MAAM,IAAI,MAAM,yBAAyB,KAAK,GAAG;GACnF,IAAI,WAAW,SAAS,kBAAkB,gBAAgB,MAAM,IAAI,MAAM,oCAAoC,kBAAkB,eAAe,SAAS;GACxJ,IAAI,IAAI,IAA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ACjD,GAAG,qBAAqB,MAAM;AAC/B"}
|
package/dist/runtime/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as defineSchema$1, n as SchemaAuthoring, t as DefinedSchema } from "./index-
|
|
1
|
+
import { c as Result$1, g as FileValue, h as FileMimeType, i as ErrorValue, m as FileMetadata, p as FileFormat } from "./id-Btwac71X-DGj0DQuu.js";
|
|
2
|
+
import { i as defineSchema$1, n as SchemaAuthoring, t as DefinedSchema } from "./index-CF04_Dps.js";
|
|
3
3
|
//#region src/server/index.d.ts
|
|
4
4
|
declare const Result: typeof Result$1;
|
|
5
5
|
type Result<Success, Failure extends ErrorValue> = Result$1<Success, Failure>;
|
|
6
6
|
declare const defineSchema: typeof defineSchema$1;
|
|
7
7
|
//#endregion
|
|
8
|
-
export { type DefinedSchema, Result, type SchemaAuthoring, defineSchema };
|
|
8
|
+
export { type DefinedSchema, type FileFormat, type FileMetadata, type FileMimeType, type FileValue, Result, type SchemaAuthoring, defineSchema };
|
|
9
9
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/runtime/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as defineSchema$1 } from "./schema-
|
|
1
|
+
import { d as Result$1 } from "./descriptor-C5VA9qRl-C338iC6l.js";
|
|
2
|
+
import { r as defineSchema$1 } from "./schema-DJfwfq87.js";
|
|
3
3
|
//#region src/server/index.ts
|
|
4
4
|
const Result = Result$1;
|
|
5
5
|
const defineSchema = defineSchema$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["contractResult","defineContractSchema"],"sources":["../../src/server/index.ts"],"sourcesContent":["import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, Result as ContractResult } from \"@ignotum/contracts/runtime/result\";\nimport { defineSchema as defineContractSchema } from \"@ignotum/contracts/schema\";\n\nexport const Result: typeof contractResult = contractResult;\nexport type Result<Success, Failure extends ErrorValue> = ContractResult<Success, Failure>;\nexport const defineSchema: typeof defineContractSchema = defineContractSchema;\nexport type {
|
|
1
|
+
{"version":3,"file":"server.js","names":["contractResult","defineContractSchema"],"sources":["../../src/server/index.ts"],"sourcesContent":["import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, Result as ContractResult } from \"@ignotum/contracts/runtime/result\";\nimport { defineSchema as defineContractSchema } from \"@ignotum/contracts/schema\";\n\nexport const Result: typeof contractResult = contractResult;\nexport type Result<Success, Failure extends ErrorValue> = ContractResult<Success, Failure>;\nexport const defineSchema: typeof defineContractSchema = defineContractSchema;\nexport type {\n DefinedSchema,\n FileFormat,\n FileMetadata,\n FileMimeType,\n FileValue,\n SchemaAuthoring,\n} from \"@ignotum/contracts/schema\";\n"],"mappings":";;;AAIA,MAAa,SAAgCA;AAE7C,MAAa,eAA4CC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./id-Btwac71X-DGj0DQuu.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
//#region ../contracts/dist/runtime/sync.d.ts
|
|
4
|
+
declare const FunctionAddress: Schema.TemplateLiteral<readonly ["api.", Schema.String, ".", Schema.String]>;
|
|
5
|
+
type FunctionAddress = typeof FunctionAddress.Type;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { FunctionAddress as t };
|
|
8
|
+
//# sourceMappingURL=sync-mIXn9eKv.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ignotum",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Ignotum is an opinionated TypeScript application cloud.",
|
|
5
5
|
"author": "Johannes Schießl",
|
|
6
6
|
"repository": {
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"@effect/sql-sqlite-node": "4.0.0-rc.111",
|
|
80
80
|
"redis": "6.2.1",
|
|
81
81
|
"@ignotum/contracts": "1.0.0",
|
|
82
|
-
"@ignotum/runtime": "1.0.0",
|
|
83
82
|
"@ignotum/deployment": "1.0.0",
|
|
83
|
+
"@ignotum/runtime": "1.0.0",
|
|
84
84
|
"@ignotum/shared": "1.0.0"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
package/src/cli/agent-files.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import agents from "../../../../docs/agent/AGENTS.md?raw";
|
|
2
2
|
import skill from "../../../../docs/agent/skills/ignotum/SKILL.md?raw";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import api from "../../../../docs/user/api.md?raw";
|
|
4
|
+
import appEntry from "../../../../docs/user/app-entry.md?raw";
|
|
5
|
+
import cli from "../../../../docs/user/cli.md?raw";
|
|
6
|
+
import database from "../../../../docs/user/database.md?raw";
|
|
7
|
+
import deployApp from "../../../../docs/user/deploy-app.md?raw";
|
|
8
|
+
import deploymentModel from "../../../../docs/user/deployment-model.md?raw";
|
|
9
|
+
import deployments from "../../../../docs/user/deployments.md?raw";
|
|
10
|
+
import errors from "../../../../docs/user/errors.md?raw";
|
|
11
|
+
import files from "../../../../docs/user/files.md?raw";
|
|
12
|
+
import functions from "../../../../docs/user/functions.md?raw";
|
|
13
|
+
import generatedCode from "../../../../docs/user/generated-code.md?raw";
|
|
14
|
+
import guarantees from "../../../../docs/user/guarantees.md?raw";
|
|
15
|
+
import howIgnotumWorks from "../../../../docs/user/how-ignotum-works.md?raw";
|
|
7
16
|
import index from "../../../../docs/user/index.md?raw";
|
|
17
|
+
import indexes from "../../../../docs/user/indexes.md?raw";
|
|
8
18
|
import limits from "../../../../docs/user/limits.md?raw";
|
|
9
|
-
import
|
|
19
|
+
import localDevelopment from "../../../../docs/user/local-development.md?raw";
|
|
20
|
+
import mutations from "../../../../docs/user/mutations.md?raw";
|
|
21
|
+
import pagination from "../../../../docs/user/pagination.md?raw";
|
|
22
|
+
import preact from "../../../../docs/user/preact.md?raw";
|
|
23
|
+
import projectStructure from "../../../../docs/user/project-structure.md?raw";
|
|
24
|
+
import publicAssets from "../../../../docs/user/public-assets.md?raw";
|
|
25
|
+
import queries from "../../../../docs/user/queries.md?raw";
|
|
26
|
+
import quickstart from "../../../../docs/user/quickstart.md?raw";
|
|
27
|
+
import readingData from "../../../../docs/user/reading-data.md?raw";
|
|
10
28
|
import schema from "../../../../docs/user/schema.md?raw";
|
|
11
|
-
import
|
|
29
|
+
import styling from "../../../../docs/user/styling.md?raw";
|
|
12
30
|
import values from "../../../../docs/user/values.md?raw";
|
|
31
|
+
import web from "../../../../docs/user/web.md?raw";
|
|
32
|
+
import writingData from "../../../../docs/user/writing-data.md?raw";
|
|
13
33
|
|
|
14
34
|
export interface AppFile {
|
|
15
35
|
readonly content: string;
|
|
@@ -17,23 +37,46 @@ export interface AppFile {
|
|
|
17
37
|
}
|
|
18
38
|
|
|
19
39
|
const references = [
|
|
20
|
-
["
|
|
21
|
-
["
|
|
22
|
-
["
|
|
23
|
-
["
|
|
40
|
+
["api.md", api],
|
|
41
|
+
["app-entry.md", appEntry],
|
|
42
|
+
["cli.md", cli],
|
|
43
|
+
["database.md", database],
|
|
44
|
+
["deploy-app.md", deployApp],
|
|
45
|
+
["deployment-model.md", deploymentModel],
|
|
46
|
+
["deployments.md", deployments],
|
|
47
|
+
["errors.md", errors],
|
|
48
|
+
["files.md", files],
|
|
49
|
+
["functions.md", functions],
|
|
50
|
+
["generated-code.md", generatedCode],
|
|
51
|
+
["guarantees.md", guarantees],
|
|
52
|
+
["how-ignotum-works.md", howIgnotumWorks],
|
|
24
53
|
["index.md", index],
|
|
54
|
+
["indexes.md", indexes],
|
|
25
55
|
["limits.md", limits],
|
|
26
|
-
["
|
|
56
|
+
["local-development.md", localDevelopment],
|
|
57
|
+
["mutations.md", mutations],
|
|
58
|
+
["pagination.md", pagination],
|
|
59
|
+
["preact.md", preact],
|
|
60
|
+
["project-structure.md", projectStructure],
|
|
61
|
+
["public-assets.md", publicAssets],
|
|
62
|
+
["queries.md", queries],
|
|
63
|
+
["quickstart.md", quickstart],
|
|
64
|
+
["reading-data.md", readingData],
|
|
27
65
|
["schema.md", schema],
|
|
28
|
-
["
|
|
66
|
+
["styling.md", styling],
|
|
29
67
|
["values.md", values],
|
|
68
|
+
["web.md", web],
|
|
69
|
+
["writing-data.md", writingData],
|
|
30
70
|
] as const;
|
|
31
71
|
|
|
72
|
+
const withoutFrontmatter = (content: string) =>
|
|
73
|
+
content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, "");
|
|
74
|
+
|
|
32
75
|
export const agentAppFiles: ReadonlyArray<AppFile> = [
|
|
33
76
|
{ content: agents, path: "AGENTS.md" },
|
|
34
77
|
{ content: skill, path: ".agents/skills/ignotum/SKILL.md" },
|
|
35
78
|
...references.map(([name, content]) => ({
|
|
36
|
-
content,
|
|
79
|
+
content: withoutFrontmatter(content),
|
|
37
80
|
path: `.agents/skills/ignotum/references/${name}`,
|
|
38
81
|
})),
|
|
39
82
|
];
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { AppSlug, type ControlApp } from "@ignotum/contracts/control";
|
|
2
2
|
import { AppId } from "@ignotum/contracts/runtime/identity";
|
|
3
|
+
import * as Versioned from "@ignotum/contracts/versioned";
|
|
3
4
|
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
4
5
|
import { Prompt } from "effect/unstable/cli";
|
|
5
6
|
|
|
6
7
|
import { ControlApiError, ControlClient, HostedControlConfiguration } from "./control-client.js";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const AppConfigurationV1 = Schema.Struct({
|
|
9
10
|
formatVersion: Schema.Literal(1),
|
|
10
11
|
appId: AppId,
|
|
11
12
|
slug: AppSlug,
|
|
12
13
|
apiUrl: Schema.URLFromString,
|
|
13
14
|
});
|
|
15
|
+
const AppConfigurationThroughV1 = Versioned.initial(AppConfigurationV1);
|
|
16
|
+
export const AppConfiguration = AppConfigurationThroughV1;
|
|
14
17
|
export type AppConfiguration = typeof AppConfiguration.Type;
|
|
15
18
|
|
|
16
19
|
export class AppConfigurationInvalid extends Schema.TaggedError<AppConfigurationInvalid>()(
|
package/src/cli/build/server.ts
CHANGED
|
@@ -16,7 +16,15 @@ import {
|
|
|
16
16
|
} from "@ignotum/contracts/deployment";
|
|
17
17
|
import { FunctionAddress } from "@ignotum/contracts/runtime/sync";
|
|
18
18
|
import type { FunctionKind } from "@ignotum/contracts/runtime/functions";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
descriptorContainsFile,
|
|
21
|
+
descriptorFields,
|
|
22
|
+
getValueDescriptor,
|
|
23
|
+
isDefinedSchema,
|
|
24
|
+
ValueDescriptor,
|
|
25
|
+
type DefinedSchema,
|
|
26
|
+
type Tables,
|
|
27
|
+
} from "@ignotum/contracts/schema";
|
|
20
28
|
import {
|
|
21
29
|
artifactReference,
|
|
22
30
|
encodeCanonical,
|
|
@@ -41,17 +49,23 @@ const encodeJavaScriptString = Schema.encodeSync(Schema.fromJsonString(Schema.St
|
|
|
41
49
|
|
|
42
50
|
const DiscoveredServerFunction = Schema.Struct({
|
|
43
51
|
address: FunctionAddress,
|
|
52
|
+
args: Schema.optional(ValueDescriptor),
|
|
53
|
+
errors: Schema.optional(ValueDescriptor),
|
|
44
54
|
exportName: Schema.String,
|
|
45
55
|
kind: Schema.Literals(["Mutation", "Query"]),
|
|
46
56
|
moduleName: Schema.String,
|
|
47
57
|
modulePath: Schema.String,
|
|
58
|
+
returns: Schema.optional(ValueDescriptor),
|
|
48
59
|
});
|
|
49
60
|
interface DiscoveredServerFunction {
|
|
50
61
|
readonly address: FunctionAddress;
|
|
62
|
+
readonly args?: ValueDescriptor;
|
|
63
|
+
readonly errors?: ValueDescriptor;
|
|
51
64
|
readonly exportName: string;
|
|
52
65
|
readonly kind: FunctionKind;
|
|
53
66
|
readonly moduleName: string;
|
|
54
67
|
readonly modulePath: string;
|
|
68
|
+
readonly returns?: ValueDescriptor;
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
const ServerDiscoveryManifest = Schema.Struct({
|
|
@@ -179,13 +193,68 @@ const discoverModuleFunctions = Effect.fn("Deploy.discoverServerModule")(functio
|
|
|
179
193
|
continue;
|
|
180
194
|
}
|
|
181
195
|
|
|
182
|
-
|
|
196
|
+
const args =
|
|
197
|
+
inspected.definition.args === undefined
|
|
198
|
+
? undefined
|
|
199
|
+
: ({ type: "object", fields: descriptorFields(inspected.definition.args) } as const);
|
|
200
|
+
const returns =
|
|
201
|
+
inspected.definition.returns === undefined
|
|
202
|
+
? undefined
|
|
203
|
+
: getValueDescriptor(inspected.definition.returns);
|
|
204
|
+
const errors =
|
|
205
|
+
inspected.definition.errors === undefined
|
|
206
|
+
? undefined
|
|
207
|
+
: getValueDescriptor(inspected.definition.errors);
|
|
208
|
+
if (
|
|
209
|
+
(inspected.definition.returns !== undefined && returns === undefined) ||
|
|
210
|
+
(inspected.definition.errors !== undefined && errors === undefined)
|
|
211
|
+
) {
|
|
212
|
+
return yield* InvalidServerFunctionExport.make({
|
|
213
|
+
exportName,
|
|
214
|
+
message: `${moduleName}.${exportName} uses a validator that was not created by Ignotum values.`,
|
|
215
|
+
path: modulePath,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (
|
|
219
|
+
inspected.definition._tag === "Query" &&
|
|
220
|
+
args !== undefined &&
|
|
221
|
+
descriptorContainsFile(args)
|
|
222
|
+
) {
|
|
223
|
+
return yield* InvalidServerFunctionExport.make({
|
|
224
|
+
exportName,
|
|
225
|
+
message: `${moduleName}.${exportName} cannot accept files in query arguments.`,
|
|
226
|
+
path: modulePath,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (
|
|
230
|
+
inspected.definition._tag === "Mutation" &&
|
|
231
|
+
returns !== undefined &&
|
|
232
|
+
descriptorContainsFile(returns)
|
|
233
|
+
) {
|
|
234
|
+
return yield* InvalidServerFunctionExport.make({
|
|
235
|
+
exportName,
|
|
236
|
+
message: `${moduleName}.${exportName} cannot return files from a mutation.`,
|
|
237
|
+
path: modulePath,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (errors !== undefined && descriptorContainsFile(errors)) {
|
|
241
|
+
return yield* InvalidServerFunctionExport.make({
|
|
242
|
+
exportName,
|
|
243
|
+
message: `${moduleName}.${exportName} cannot include files in application errors.`,
|
|
244
|
+
path: modulePath,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const discovered = {
|
|
183
249
|
address: FunctionAddress.make(`api.${moduleName}.${exportName}`),
|
|
184
250
|
exportName,
|
|
185
251
|
kind: inspected.definition._tag,
|
|
186
252
|
moduleName,
|
|
187
253
|
modulePath,
|
|
188
|
-
}
|
|
254
|
+
};
|
|
255
|
+
const withArgs = args === undefined ? discovered : { ...discovered, args };
|
|
256
|
+
const withErrors = errors === undefined ? withArgs : { ...withArgs, errors };
|
|
257
|
+
functions.push(returns === undefined ? withErrors : { ...withErrors, returns });
|
|
189
258
|
}
|
|
190
259
|
|
|
191
260
|
return Array.sortWith(functions, (definition) => definition.address, String.Order);
|
|
@@ -319,6 +388,7 @@ const discoverServerFunctions = Effect.fn("Deploy.discoverServerFunctionsIsolate
|
|
|
319
388
|
appDirectory,
|
|
320
389
|
nodeModulesDirectory(),
|
|
321
390
|
packageRoot,
|
|
391
|
+
path.join(packageRoot, "node_modules"),
|
|
322
392
|
...workspaceProbes,
|
|
323
393
|
].map((allowedPath) => `--allow-fs-read=${allowedPath}`);
|
|
324
394
|
const exitCode = yield* spawner.exitCode(
|
|
@@ -476,7 +546,7 @@ const buildServerFunction = Effect.fn("Deploy.buildServerFunction")(function* (
|
|
|
476
546
|
const bundlePath = normalizePath(path.join("server", relativeFile));
|
|
477
547
|
const sourceMapPath = normalizePath(path.join("server", relativeSourceMap));
|
|
478
548
|
|
|
479
|
-
|
|
549
|
+
const artifact = {
|
|
480
550
|
address: definition.address,
|
|
481
551
|
kind: definition.kind,
|
|
482
552
|
bundle: yield* artifactReference(bundlePath, yield* fileSystem.readFile(absoluteFile)),
|
|
@@ -484,7 +554,14 @@ const buildServerFunction = Effect.fn("Deploy.buildServerFunction")(function* (
|
|
|
484
554
|
sourceMapPath,
|
|
485
555
|
yield* fileSystem.readFile(absoluteSourceMap),
|
|
486
556
|
),
|
|
487
|
-
}
|
|
557
|
+
};
|
|
558
|
+
const withArgs =
|
|
559
|
+
definition.args === undefined ? artifact : { ...artifact, args: definition.args };
|
|
560
|
+
const withErrors =
|
|
561
|
+
definition.errors === undefined ? withArgs : { ...withArgs, errors: definition.errors };
|
|
562
|
+
return definition.returns === undefined
|
|
563
|
+
? (withErrors satisfies ServerFunctionArtifact)
|
|
564
|
+
: ({ ...withErrors, returns: definition.returns } satisfies ServerFunctionArtifact);
|
|
488
565
|
});
|
|
489
566
|
|
|
490
567
|
export const buildServer = Effect.fn("Deploy.buildServer")(function* (
|
|
@@ -507,7 +584,7 @@ export const buildServer = Effect.fn("Deploy.buildServer")(function* (
|
|
|
507
584
|
{ concurrency: 4 },
|
|
508
585
|
);
|
|
509
586
|
const manifest = {
|
|
510
|
-
formatVersion:
|
|
587
|
+
formatVersion: 2,
|
|
511
588
|
schema: yield* artifactReference(schemaSnapshotPath, snapshotBytes),
|
|
512
589
|
functions,
|
|
513
590
|
} satisfies ServerBuildManifest;
|
package/src/cli/new-app.ts
CHANGED
|
@@ -207,6 +207,17 @@ Open <http://127.0.0.1:3210>.
|
|
|
207
207
|
The app generator creates \`_generated\`. The dev server checks those files before it starts
|
|
208
208
|
and updates them when the schema or server functions change.
|
|
209
209
|
|
|
210
|
+
## Deploy
|
|
211
|
+
|
|
212
|
+
Set \`IGNOTUM_API_TOKEN\`, then choose a unique slug on the first deployment:
|
|
213
|
+
|
|
214
|
+
\`\`\`sh
|
|
215
|
+
npx ignotum deploy --app my-app
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
218
|
+
The command prints the hosted URL and records the app link in \`.ignotum/app.json\`. Later
|
|
219
|
+
deployments use \`npx ignotum deploy\` without the \`--app\` flag.
|
|
220
|
+
|
|
210
221
|
## App files
|
|
211
222
|
|
|
212
223
|
- \`server/schema.ts\` defines the database tables.
|
|
@@ -216,6 +227,7 @@ and updates them when the schema or server functions change.
|
|
|
216
227
|
- Ignotum loads Tailwind CSS automatically. Custom CSS files are ordinary client modules.
|
|
217
228
|
- \`shared/utils.ts\` contains code shared across the app.
|
|
218
229
|
- \`_generated\` contains Ignotum's generated types and bindings. Do not edit it by hand.
|
|
230
|
+
- \`.agents/skills/ignotum\` contains the app skill and references used by coding agents.
|
|
219
231
|
|
|
220
232
|
Run the typechecker after a change:
|
|
221
233
|
|
|
@@ -224,6 +236,9 @@ npx ignotum codegen
|
|
|
224
236
|
npx tsc --noEmit
|
|
225
237
|
\`\`\`
|
|
226
238
|
|
|
239
|
+
The [Ignotum documentation](https://docs.ignotum.cloud) covers schema values, indexes, queries,
|
|
240
|
+
mutations, client hooks, deployment, guarantees, and hosted limits.
|
|
241
|
+
|
|
227
242
|
## Claude Code
|
|
228
243
|
|
|
229
244
|
If you use Claude Code, rename \`AGENTS.md\` to \`CLAUDE.md\` and \`.agents\` to \`.claude\` so it
|