apps 0.0.1-beta.3 → 0.0.1-beta.30
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 +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-G7ZIRKMK.js → chunk-2D2PKLGQ.js} +118 -197
- package/js/chunk-3SPRHIEE.js +42 -0
- package/js/{chunk-FDNTX5QJ.js → chunk-4N26L465.js} +2 -2
- package/js/chunk-5ZHHO4OM.js +92 -0
- package/js/{chunk-EVJUVWN2.js → chunk-65SZ23BK.js} +2 -2
- package/js/{chunk-M6ZRRIBI.js → chunk-6JBTHTI5.js} +1 -1
- package/js/{chunk-J7O55ZV7.js → chunk-6NK26ONC.js} +332 -187
- package/js/chunk-6VWYEQ4X.js +254 -0
- package/js/{chunk-RN2MXB4R.js → chunk-AE4FWJQU.js} +128 -24
- package/js/{chunk-HDJH3RPR.js → chunk-BBTELEAN.js} +2 -2
- package/js/{chunk-LGIYBDWA.js → chunk-BRGF7VFN.js} +65 -1
- package/js/{chunk-MYYEW3RA.js → chunk-BSRU52RU.js} +984 -61
- package/js/{chunk-FZJOYIZO.js → chunk-BTJMXW4I.js} +1 -1
- package/js/{chunk-HDTGZWP2.js → chunk-IMCEF6KE.js} +139 -32
- package/js/chunk-KQCMHI3K.js +118 -0
- package/js/{chunk-BMOIAIVR.js → chunk-M2KEEOIQ.js} +49 -1
- package/js/{chunk-YEJOQEII.js → chunk-MYCVMDWI.js} +45 -7
- package/js/{chunk-FW5HBOIK.js → chunk-NXTXZ635.js} +1841 -1701
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-JN55AYQH.js → chunk-OI5CKSBU.js} +61 -32
- package/js/{chunk-NQ3OMCA5.js → chunk-P46HIAX6.js} +2 -2
- package/js/chunk-PUC24GZP.js +801 -0
- package/js/{chunk-SATWJKN6.js → chunk-PWF2DRJ3.js} +1 -1
- package/js/{chunk-D47C7KG5.js → chunk-VUVBMNKC.js} +2 -2
- package/js/{chunk-ZCAMUXSG.js → chunk-WGBI5MVX.js} +3 -4
- package/js/{chunk-T2LAZCAD.js → chunk-WQ5MVBTP.js} +1 -1
- package/js/{chunk-PLCMJREA.js → chunk-XBQTJP76.js} +60 -20
- package/js/{chunk-QKHR7BMF.js → chunk-XGN5IFOZ.js} +3 -3
- package/js/{chunk-WFSQXYUT.js → chunk-YML53Z7H.js} +42 -5
- package/js/{chunk-5MQZEB6Y.js → chunk-ZZOCEUTB.js} +37 -12
- package/js/client.js +120 -84
- package/js/contracts.js +110 -16
- package/js/effect.js +20 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +58 -54
- package/js/host.js +20 -20
- package/js/index.js +247 -204
- package/js/mcp/effect.js +24 -22
- package/js/mcp/stdio.js +35 -30
- package/js/mcp.js +105 -68
- package/js/openapi.js +4087 -1503
- package/js/react.js +3 -3
- package/js/skills/effect.js +5 -3
- package/js/skills.js +15 -15
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8516 -214
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/failure.d.ts +54 -0
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +34 -11
- package/types/apps/src/contracts/mcp.d.ts +91 -10
- package/types/apps/src/contracts/network.d.ts +84 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +31 -3
- package/types/apps/src/contracts/openapi.d.ts +45 -9
- package/types/apps/src/contracts/operations.d.ts +5 -6
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +251 -69
- package/types/apps/src/contracts/protocols/2.d.ts +710 -0
- package/types/apps/src/contracts/protocols/3.d.ts +716 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1298 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1119 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +115 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/skills.d.ts +18 -5
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
- package/types/apps/src/implementation/elicitation.d.ts +9 -9
- package/types/apps/src/implementation/failure-detail.d.ts +46 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +49 -25
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +52 -25
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +27 -6
- package/types/apps/src/implementation/openapi-document.d.ts +35 -8
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +8 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/router-catalog.d.ts +224 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +52 -1
- package/types/apps/src/implementation/skills.d.ts +2 -2
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +10 -4
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +29 -11
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +25 -5
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/skills.d.ts +4 -4
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/utils/src/api-error.d.ts +48 -0
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-W7D7WVSY.js +0 -18
- package/js/chunk-Z5NMEGJN.js +0 -29
- package/js/chunk-ZJWDMTE3.js +0 -63
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
CacheEntry,
|
|
4
4
|
CacheError,
|
|
5
5
|
cacheLimits
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BRGF7VFN.js";
|
|
7
7
|
import {
|
|
8
8
|
Clock_exports,
|
|
9
9
|
Duration_exports,
|
|
10
10
|
Effect_exports,
|
|
11
11
|
Exit_exports,
|
|
12
12
|
Schema_exports
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NXTXZ635.js";
|
|
14
14
|
|
|
15
15
|
// ../app-cache/src/index.ts
|
|
16
16
|
var canonical = (value) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchHttpClient_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BBTELEAN.js";
|
|
4
4
|
import {
|
|
5
5
|
HttpBody_exports,
|
|
6
6
|
HttpClient,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setBody,
|
|
19
19
|
transformResponse,
|
|
20
20
|
uint8Array
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XGN5IFOZ.js";
|
|
22
22
|
import {
|
|
23
23
|
Array as Array2,
|
|
24
24
|
Boolean2 as Boolean,
|
|
@@ -125,7 +125,7 @@ import {
|
|
|
125
125
|
withDefault2 as withDefault,
|
|
126
126
|
withTracerEnabled,
|
|
127
127
|
zero
|
|
128
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-NXTXZ635.js";
|
|
129
129
|
import {
|
|
130
130
|
__export
|
|
131
131
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -2508,7 +2508,6 @@ export {
|
|
|
2508
2508
|
withRemoteSpan,
|
|
2509
2509
|
invocationFetch,
|
|
2510
2510
|
collectTelemetry,
|
|
2511
|
-
TraceContext,
|
|
2512
2511
|
externalTrace,
|
|
2513
2512
|
traceLinks,
|
|
2514
2513
|
pendingSpan
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppDatabaseError,
|
|
3
|
+
DatabaseFieldReserved,
|
|
4
|
+
DatabaseLimitExceeded,
|
|
3
5
|
DatabaseLimits,
|
|
4
6
|
DatabaseOperation,
|
|
5
7
|
DatabaseSchema,
|
|
@@ -8,18 +10,21 @@ import {
|
|
|
8
10
|
Row,
|
|
9
11
|
RowMetadata,
|
|
10
12
|
defaultDatabaseLimits,
|
|
11
|
-
defaultDatabaseRuntimeLimits
|
|
12
|
-
|
|
13
|
+
defaultDatabaseRuntimeLimits,
|
|
14
|
+
reservedFieldNames
|
|
15
|
+
} from "./chunk-M2KEEOIQ.js";
|
|
13
16
|
import {
|
|
17
|
+
Cause_exports,
|
|
14
18
|
Clock_exports,
|
|
15
19
|
Effect_exports,
|
|
16
20
|
Encoding_exports,
|
|
17
21
|
Schema_exports,
|
|
18
22
|
Semaphore_exports
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-NXTXZ635.js";
|
|
20
24
|
|
|
21
25
|
// ../app-data/src/implementation/schema.ts
|
|
22
|
-
var metadata =
|
|
26
|
+
var metadata = new Set(reservedFieldNames);
|
|
27
|
+
var reserved = (name) => metadata.has(name);
|
|
23
28
|
var indexesFor = (table) => [{ name: "by_creation", fields: [] }, ...table.indexes].map((index) => ({
|
|
24
29
|
name: index.name,
|
|
25
30
|
fields: [
|
|
@@ -33,23 +38,25 @@ var validScalar = (field, value) => field.kind === "number" ? typeof value === "
|
|
|
33
38
|
return point !== void 0 && point >= 55296 && point <= 57343;
|
|
34
39
|
});
|
|
35
40
|
var parseDatabaseSchema = (input) => Schema_exports.decodeUnknownEffect(DatabaseSchema)(input).pipe(
|
|
41
|
+
Effect_exports.mapError(() => new AppDatabaseError({ reason: "schema" })),
|
|
36
42
|
Effect_exports.flatMap(
|
|
37
43
|
(schema) => Effect_exports.gen(function* () {
|
|
38
|
-
for (const table of Object.
|
|
39
|
-
|
|
44
|
+
for (const [name, table] of Object.entries(schema)) {
|
|
45
|
+
const field = Object.keys(table.fields).find(reserved);
|
|
46
|
+
if (field !== void 0) return yield* new DatabaseFieldReserved({ table: name, field });
|
|
47
|
+
if (new Set(table.indexes.map((index) => index.name)).size !== table.indexes.length)
|
|
40
48
|
return yield* new AppDatabaseError({ reason: "schema" });
|
|
41
|
-
for (const
|
|
42
|
-
if ((
|
|
49
|
+
for (const field2 of Object.values(table.fields)) {
|
|
50
|
+
if ((field2.kind === "id" ? field2.references === void 0 : field2.references !== void 0) || field2.default !== void 0 && !validScalar(field2, field2.default) || field2.references !== void 0 && !Object.hasOwn(schema, field2.references))
|
|
43
51
|
return yield* new AppDatabaseError({ reason: "schema" });
|
|
44
52
|
}
|
|
45
53
|
for (const index of table.indexes)
|
|
46
|
-
if (index.name === "by_creation" || new Set(index.fields).size !== index.fields.length || index.fields.some((
|
|
54
|
+
if (index.name === "by_creation" || new Set(index.fields).size !== index.fields.length || index.fields.some((name2) => fieldFor(table, name2) === void 0))
|
|
47
55
|
return yield* new AppDatabaseError({ reason: "schema" });
|
|
48
56
|
}
|
|
49
57
|
return schema;
|
|
50
58
|
})
|
|
51
|
-
)
|
|
52
|
-
Effect_exports.mapError(() => new AppDatabaseError({ reason: "schema" }))
|
|
59
|
+
)
|
|
53
60
|
);
|
|
54
61
|
var canonicalSchema = (schema) => JSON.stringify(
|
|
55
62
|
Object.fromEntries(
|
|
@@ -248,7 +255,12 @@ var decodeBody = Schema_exports.decodeUnknownEffect(Schema_exports.fromJsonStrin
|
|
|
248
255
|
var storageError = () => new AppDatabaseError({ reason: "storage" });
|
|
249
256
|
var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
250
257
|
const { sql, crypto } = options;
|
|
251
|
-
const schema = yield* parseDatabaseSchema(options.schema)
|
|
258
|
+
const schema = yield* parseDatabaseSchema(options.schema).pipe(
|
|
259
|
+
Effect_exports.catchTag(
|
|
260
|
+
"DatabaseFieldReserved",
|
|
261
|
+
() => Effect_exports.fail(new AppDatabaseError({ reason: "schema" }))
|
|
262
|
+
)
|
|
263
|
+
);
|
|
252
264
|
const limits = yield* Schema_exports.decodeUnknownEffect(DatabaseLimits)(
|
|
253
265
|
options.limits ?? defaultDatabaseLimits
|
|
254
266
|
).pipe(Effect_exports.mapError(() => new AppDatabaseError({ reason: "limit" })));
|
|
@@ -295,7 +307,13 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
295
307
|
};
|
|
296
308
|
const charge = (name, amount) => Effect_exports.suspend(() => {
|
|
297
309
|
used[name] += amount;
|
|
298
|
-
return used[name] > limits[name] ? Effect_exports.fail(
|
|
310
|
+
return used[name] > limits[name] ? Effect_exports.fail(
|
|
311
|
+
new DatabaseLimitExceeded({
|
|
312
|
+
limit: name,
|
|
313
|
+
maximum: limits[name],
|
|
314
|
+
requested: used[name]
|
|
315
|
+
})
|
|
316
|
+
) : Effect_exports.void;
|
|
299
317
|
});
|
|
300
318
|
const get = (table, id) => Effect_exports.gen(function* () {
|
|
301
319
|
yield* charge("directGets", 1);
|
|
@@ -312,8 +330,13 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
312
330
|
const store = (tableName, table, row) => Effect_exports.gen(function* () {
|
|
313
331
|
const meta = yield* Schema_exports.decodeUnknownEffect(RowMetadata)(row);
|
|
314
332
|
const body = JSON.stringify(row);
|
|
315
|
-
|
|
316
|
-
|
|
333
|
+
const bytes = new TextEncoder().encode(body).length;
|
|
334
|
+
if (bytes > limits.valueBytes)
|
|
335
|
+
return yield* new DatabaseLimitExceeded({
|
|
336
|
+
limit: "valueBytes",
|
|
337
|
+
maximum: limits.valueBytes,
|
|
338
|
+
requested: bytes
|
|
339
|
+
});
|
|
317
340
|
const keys = yield* Effect_exports.forEach(
|
|
318
341
|
indexesFor(table),
|
|
319
342
|
(index) => encodeIndexKey(
|
|
@@ -384,9 +407,14 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
384
407
|
const bounds = yield* queryBounds(table, plan, limits.indexBytes);
|
|
385
408
|
reads.add(tableName);
|
|
386
409
|
yield* charge("scanCalls", 1);
|
|
387
|
-
const
|
|
388
|
-
const count = terminal.kind === "first" ? 1 : terminal.kind === "take" ? terminal.count : terminal.kind === "paginate" ? terminal.numItems :
|
|
389
|
-
if (
|
|
410
|
+
const remaining = terminal.kind === "count" ? limits.rowsRead - used.rowsRead : limits.rowsReturned - used.rowsReturned;
|
|
411
|
+
const count = terminal.kind === "first" ? 1 : terminal.kind === "take" ? terminal.count : terminal.kind === "paginate" ? terminal.numItems : remaining;
|
|
412
|
+
if ((terminal.kind === "take" || terminal.kind === "paginate") && count > limits.rowsReturned)
|
|
413
|
+
return yield* new DatabaseLimitExceeded({
|
|
414
|
+
limit: "pageSize",
|
|
415
|
+
maximum: limits.rowsReturned,
|
|
416
|
+
requested: count
|
|
417
|
+
});
|
|
390
418
|
if (count === 0 && terminal.kind === "take") return [];
|
|
391
419
|
const query = yield* fingerprint(
|
|
392
420
|
crypto,
|
|
@@ -412,7 +440,10 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
412
440
|
plan.order === "asc" ? sql`i.sort_key > ${position}` : sql`i.sort_key < ${position}`
|
|
413
441
|
);
|
|
414
442
|
const direction = plan.order === "asc" ? sql.literal("ASC") : sql.literal("DESC");
|
|
415
|
-
const limit =
|
|
443
|
+
const limit = Math.min(
|
|
444
|
+
terminal.kind === "first" || terminal.kind === "take" ? count : count + 1,
|
|
445
|
+
remaining + 1
|
|
446
|
+
);
|
|
416
447
|
if (terminal.kind === "count") {
|
|
417
448
|
const rows2 = yield* sql`SELECT i.sort_key FROM app_indexes i WHERE ${sql.and(predicates)} ORDER BY i.sort_key ${direction} LIMIT ${limit}`.pipe(
|
|
418
449
|
Effect_exports.flatMap(Schema_exports.decodeUnknownEffect(Schema_exports.Array(CountRow)))
|
|
@@ -436,7 +467,11 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
436
467
|
)
|
|
437
468
|
);
|
|
438
469
|
if (terminal.kind === "collect" && rows.length > count)
|
|
439
|
-
return yield* new
|
|
470
|
+
return yield* new DatabaseLimitExceeded({
|
|
471
|
+
limit: "rowsReturned",
|
|
472
|
+
maximum: limits.rowsReturned,
|
|
473
|
+
requested: used.rowsReturned + rows.length
|
|
474
|
+
});
|
|
440
475
|
const page = rows.slice(0, count);
|
|
441
476
|
yield* charge("rowsReturned", page.length);
|
|
442
477
|
const values = yield* Effect_exports.forEach(page, (row) => decodeBody(row.body));
|
|
@@ -502,6 +537,11 @@ var makeSqliteDatabase = (options) => Effect_exports.gen(function* () {
|
|
|
502
537
|
})
|
|
503
538
|
};
|
|
504
539
|
return yield* Effect_exports.suspend(() => work(session)).pipe(
|
|
540
|
+
// A failed database call poisons the session. Report that failure even when
|
|
541
|
+
// authored code caught it or threw something else in its place.
|
|
542
|
+
Effect_exports.catchCause(
|
|
543
|
+
(cause) => failed === void 0 || Cause_exports.hasInterrupts(cause) ? Effect_exports.failCause(cause) : Effect_exports.fail(failed)
|
|
544
|
+
),
|
|
505
545
|
Effect_exports.tap(
|
|
506
546
|
() => gate.withPermits(1)(
|
|
507
547
|
Effect_exports.suspend(() => failed === void 0 ? Effect_exports.void : Effect_exports.fail(failed))
|
|
@@ -211,7 +211,7 @@ import {
|
|
|
211
211
|
withFiber,
|
|
212
212
|
withParentSpan,
|
|
213
213
|
zero2 as zero
|
|
214
|
-
} from "./chunk-
|
|
214
|
+
} from "./chunk-NXTXZ635.js";
|
|
215
215
|
import {
|
|
216
216
|
__export
|
|
217
217
|
} from "./chunk-CZ7CSFO4.js";
|
|
@@ -4358,6 +4358,8 @@ export {
|
|
|
4358
4358
|
bodyFormData,
|
|
4359
4359
|
HttpClientRequest_exports,
|
|
4360
4360
|
fromWeb2 as fromWeb,
|
|
4361
|
+
HttpServerResponse_exports,
|
|
4362
|
+
HttpServerRequest_exports,
|
|
4361
4363
|
HttpTraceContext_exports,
|
|
4362
4364
|
HttpClient,
|
|
4363
4365
|
transformResponse,
|
|
@@ -4368,8 +4370,6 @@ export {
|
|
|
4368
4370
|
TracerPropagationEnabled,
|
|
4369
4371
|
layerMergedContext,
|
|
4370
4372
|
HttpClient_exports,
|
|
4371
|
-
HttpServerResponse_exports,
|
|
4372
|
-
HttpServerRequest_exports,
|
|
4373
4373
|
prefixPath,
|
|
4374
4374
|
fromLiteral
|
|
4375
4375
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
JsonObject,
|
|
2
3
|
ValidationError
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PWF2DRJ3.js";
|
|
4
5
|
import {
|
|
5
6
|
Cause_exports,
|
|
6
7
|
Effect_exports,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
SchemaIssue_exports,
|
|
10
11
|
SchemaParser_exports,
|
|
11
12
|
Schema_exports
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NXTXZ635.js";
|
|
13
14
|
|
|
14
15
|
// ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
15
16
|
function deepCompareStrict(a, b) {
|
|
@@ -1144,6 +1145,25 @@ function object(fields) {
|
|
|
1144
1145
|
) : Schema_exports.Struct(Object.fromEntries(entries));
|
|
1145
1146
|
return { ...wrap(decoder, false), fields: Object.freeze({ ...fields }) };
|
|
1146
1147
|
}
|
|
1148
|
+
var Exposure = /* @__PURE__ */ Symbol("apps.FieldExposure");
|
|
1149
|
+
var exposureOf = (schema) => Exposure in schema && (schema[Exposure] === "plain" || schema[Exposure] === "raw") ? schema[Exposure] : void 0;
|
|
1150
|
+
var expose = (schema, exposure) => (
|
|
1151
|
+
// SAFETY: the copy keeps every member of S, and `optional` and `default` keep the marking.
|
|
1152
|
+
{
|
|
1153
|
+
...schema,
|
|
1154
|
+
[Exposure]: exposure,
|
|
1155
|
+
optional: () => expose(schema.optional(), exposure),
|
|
1156
|
+
default: (value) => expose(schema.default(value), exposure)
|
|
1157
|
+
}
|
|
1158
|
+
);
|
|
1159
|
+
var plain = (schema) => expose(schema, "plain");
|
|
1160
|
+
var raw = (schema) => expose(schema, "raw");
|
|
1161
|
+
var fieldExposure = (fields) => Object.fromEntries(
|
|
1162
|
+
Object.entries(fields).flatMap(([name, field]) => {
|
|
1163
|
+
const exposure = exposureOf(field);
|
|
1164
|
+
return exposure === void 0 ? [] : [[name, exposure]];
|
|
1165
|
+
})
|
|
1166
|
+
);
|
|
1147
1167
|
var ImportedJsonSchema = /* @__PURE__ */ Symbol("apps.JsonSchemaDocument");
|
|
1148
1168
|
var importedJsonSchema = (decoder) => ImportedJsonSchema in decoder ? decoder[ImportedJsonSchema] : void 0;
|
|
1149
1169
|
var withJsonSchemaDocument = (decoder, document) => Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
@@ -1332,7 +1352,7 @@ var compileJsonSchemaDecoder = (document) => Effect_exports.gen(function* () {
|
|
|
1332
1352
|
);
|
|
1333
1353
|
return Object.assign(decoder, { [ImportedJsonSchema]: document });
|
|
1334
1354
|
});
|
|
1335
|
-
var
|
|
1355
|
+
var lazyCompiledDecoder = (document) => {
|
|
1336
1356
|
const read = once(document);
|
|
1337
1357
|
let compiled;
|
|
1338
1358
|
const compile = Effect_exports.suspend(
|
|
@@ -1352,9 +1372,11 @@ var lazyDecoder = (document) => {
|
|
|
1352
1372
|
Effect_exports.flatMap((schema) => SchemaParser_exports.decodeUnknownEffect(schema)(input, options))
|
|
1353
1373
|
)
|
|
1354
1374
|
);
|
|
1355
|
-
return withLazyJsonSchemaDocument(decoder, read);
|
|
1375
|
+
return { decoder: withLazyJsonSchemaDocument(decoder, read), compile };
|
|
1356
1376
|
};
|
|
1377
|
+
var lazyDecoder = (document) => lazyCompiledDecoder(document).decoder;
|
|
1357
1378
|
var lazyJsonSchemaDecoder = (document) => Effect_exports.sync(() => lazyDecoder(document));
|
|
1379
|
+
var preparedJsonSchemaDecoder = (document) => lazyCompiledDecoder(() => document);
|
|
1358
1380
|
var isJsonValue = Schema_exports.is(Schema_exports.Json);
|
|
1359
1381
|
var jsonDocument = (input) => {
|
|
1360
1382
|
if (typeof input !== "object" || input === null || Array.isArray(input)) return void 0;
|
|
@@ -1387,6 +1409,16 @@ var jsonSchema = (input) => {
|
|
|
1387
1409
|
var storageFieldOf = (schema) => schema[StorageField];
|
|
1388
1410
|
var id = (table) => wrap(Schema_exports.NonEmptyString, false, { kind: "id", references: table });
|
|
1389
1411
|
var userId = () => wrap(Schema_exports.NonEmptyString, false, { kind: "userId" });
|
|
1412
|
+
var jsonSchemaDocument = (decoder) => {
|
|
1413
|
+
const imported = importedJsonSchema(decoder);
|
|
1414
|
+
if (imported !== void 0) return Schema_exports.decodeUnknownEffect(JsonObject)(imported);
|
|
1415
|
+
const document = Schema_exports.toJsonSchemaDocument(decoder);
|
|
1416
|
+
return Schema_exports.decodeUnknownEffect(JsonObject)({
|
|
1417
|
+
...document.schema,
|
|
1418
|
+
$defs: document.definitions,
|
|
1419
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
1420
|
+
});
|
|
1421
|
+
};
|
|
1390
1422
|
|
|
1391
1423
|
export {
|
|
1392
1424
|
decoderOf,
|
|
@@ -1401,15 +1433,20 @@ export {
|
|
|
1401
1433
|
literal,
|
|
1402
1434
|
array,
|
|
1403
1435
|
object,
|
|
1436
|
+
plain,
|
|
1437
|
+
raw,
|
|
1438
|
+
fieldExposure,
|
|
1404
1439
|
importedJsonSchema,
|
|
1405
1440
|
once,
|
|
1406
1441
|
withLazyJsonSchemaDocument,
|
|
1407
1442
|
nestJsonSchema,
|
|
1408
1443
|
compileJsonSchemaDecoder,
|
|
1409
1444
|
lazyJsonSchemaDecoder,
|
|
1445
|
+
preparedJsonSchemaDecoder,
|
|
1410
1446
|
jsonSchemaDecoder,
|
|
1411
1447
|
jsonSchema,
|
|
1412
1448
|
storageFieldOf,
|
|
1413
1449
|
id,
|
|
1414
|
-
userId
|
|
1450
|
+
userId,
|
|
1451
|
+
jsonSchemaDocument
|
|
1415
1452
|
};
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CacheError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-BRGF7VFN.js";
|
|
4
4
|
import {
|
|
5
5
|
wrap
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YML53Z7H.js";
|
|
7
7
|
import {
|
|
8
8
|
JsonObject
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PWF2DRJ3.js";
|
|
10
10
|
import {
|
|
11
11
|
Duration_exports,
|
|
12
12
|
Effect_exports,
|
|
13
13
|
Schema_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NXTXZ635.js";
|
|
15
15
|
|
|
16
16
|
// src/implementation/catalog-cache.ts
|
|
17
|
+
var catalogScope = (options, invalid) => {
|
|
18
|
+
const { account, cache, headers } = options;
|
|
19
|
+
if (account === void 0)
|
|
20
|
+
return headers === void 0 ? Effect_exports.succeed(cache) : Effect_exports.fail(invalid());
|
|
21
|
+
if (cache === void 0) return Effect_exports.succeed(void 0);
|
|
22
|
+
return Effect_exports.try({ try: () => cache.forAccount(account), catch: invalid });
|
|
23
|
+
};
|
|
17
24
|
var schema = (decoder) => wrap(decoder, false);
|
|
18
25
|
var Manifest = Schema_exports.Struct({
|
|
19
26
|
revision: Schema_exports.String,
|
|
20
27
|
pages: Schema_exports.Int,
|
|
21
|
-
summaries: Schema_exports.Int
|
|
28
|
+
summaries: Schema_exports.Int,
|
|
29
|
+
header: Schema_exports.optionalKey(JsonObject)
|
|
22
30
|
});
|
|
23
31
|
var invoke = (work) => Effect_exports.tryPromise({ try: work, catch: (error) => error });
|
|
24
32
|
var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
@@ -35,9 +43,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
35
43
|
const retention = Duration_exports.toMillis(Duration_exports.fromInputUnsafe(freshFor)) + Duration_exports.toMillis(Duration_exports.fromInputUnsafe(staleFor)) + 3e5;
|
|
36
44
|
const local = yield* Effect_exports.cached(options.load());
|
|
37
45
|
const refresh = (context) => Effect_exports.gen(function* () {
|
|
38
|
-
const tools = yield* options.load(context);
|
|
46
|
+
const { tools, header } = yield* options.load(context);
|
|
39
47
|
const digest = yield* invoke(
|
|
40
|
-
() => crypto.subtle.digest(
|
|
48
|
+
() => crypto.subtle.digest(
|
|
49
|
+
"SHA-256",
|
|
50
|
+
new TextEncoder().encode(JSON.stringify({ tools, header: header ?? null }))
|
|
51
|
+
)
|
|
41
52
|
);
|
|
42
53
|
const revision = Array.from(
|
|
43
54
|
new Uint8Array(digest),
|
|
@@ -104,7 +115,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
104
115
|
yield* pageOut();
|
|
105
116
|
yield* summaryOut();
|
|
106
117
|
yield* flush();
|
|
107
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
revision,
|
|
120
|
+
pages: pages2,
|
|
121
|
+
summaries,
|
|
122
|
+
...header === void 0 ? {} : { header: yield* json(header) }
|
|
123
|
+
};
|
|
108
124
|
});
|
|
109
125
|
const getOptions = {
|
|
110
126
|
key,
|
|
@@ -113,7 +129,12 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
113
129
|
staleFor,
|
|
114
130
|
load: (context) => Effect_exports.runPromise(refresh(context), { signal: context.signal })
|
|
115
131
|
};
|
|
116
|
-
|
|
132
|
+
let reading;
|
|
133
|
+
const current = () => cache === void 0 ? Effect_exports.fail(new CacheError({ reason: "unavailable" })) : invoke(
|
|
134
|
+
() => reading ??= cache.get(getOptions).finally(() => {
|
|
135
|
+
reading = void 0;
|
|
136
|
+
})
|
|
137
|
+
);
|
|
117
138
|
if (options.revalidate) {
|
|
118
139
|
if (cache === void 0) yield* local;
|
|
119
140
|
else yield* invoke(() => cache.revalidate(getOptions));
|
|
@@ -140,14 +161,17 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
140
161
|
return values;
|
|
141
162
|
});
|
|
142
163
|
const metadata = () => Effect_exports.gen(function* () {
|
|
143
|
-
if (cache === void 0) return yield* local;
|
|
164
|
+
if (cache === void 0) return (yield* local).tools;
|
|
144
165
|
const manifest = yield* current();
|
|
145
166
|
return yield* pages(cache, manifest.revision, "page", manifest.pages, options.schema);
|
|
146
167
|
});
|
|
147
168
|
return {
|
|
148
169
|
list: metadata,
|
|
170
|
+
/** The record stored with the current revision, if the source supplied one. */
|
|
171
|
+
header: () => cache === void 0 ? local.pipe(Effect_exports.map(({ header }) => header)) : current().pipe(Effect_exports.map((manifest) => manifest.header)),
|
|
149
172
|
summaries: () => Effect_exports.gen(function* () {
|
|
150
|
-
if (cache === void 0)
|
|
173
|
+
if (cache === void 0)
|
|
174
|
+
return (yield* local).tools.map((tool) => options.summary.of(tool));
|
|
151
175
|
const manifest = yield* current();
|
|
152
176
|
return yield* pages(
|
|
153
177
|
cache,
|
|
@@ -157,7 +181,7 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
157
181
|
options.summary.schema
|
|
158
182
|
);
|
|
159
183
|
}),
|
|
160
|
-
resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map((tools) => tools.find((tool) => tool.name === name))) : current().pipe(
|
|
184
|
+
resolve: (name) => cache === void 0 ? local.pipe(Effect_exports.map(({ tools }) => tools.find((tool) => tool.name === name))) : current().pipe(
|
|
161
185
|
Effect_exports.flatMap(
|
|
162
186
|
(manifest) => invoke(
|
|
163
187
|
() => cache.read(part(manifest.revision, "tool", name), schema(options.schema))
|
|
@@ -168,5 +192,6 @@ var catalogCache = (options) => Effect_exports.gen(function* () {
|
|
|
168
192
|
});
|
|
169
193
|
|
|
170
194
|
export {
|
|
195
|
+
catalogScope,
|
|
171
196
|
catalogCache
|
|
172
197
|
};
|