@midsummer-ai/sdk 0.1.0-staging.3880 → 0.1.0-staging.3886
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/{build-Y6rsumMB.d.mts → build-Cw1BOzoq.d.mts} +5 -1
- package/database/build.d.mts +1 -1
- package/database/build.mjs +12 -7
- package/database/contract.d.mts +1 -1
- package/database/contract.mjs +18 -8
- package/database/stand-in.d.mts +1 -1
- package/database/stand-in.mjs +1 -1
- package/here-C2jhTheQ.mjs +1 -1
- package/package.json +1 -1
|
@@ -52,7 +52,11 @@ interface Packages {
|
|
|
52
52
|
}
|
|
53
53
|
/** The most one built file may be, as a deploy admits it. */
|
|
54
54
|
declare const MODULE_BYTES: number;
|
|
55
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* The most a whole build may be, the folder's modules and every package file they reach, counted as a deploy sends
|
|
57
|
+
* it: the JSON of each file's path and text. The Database takes a deploy of at most 2 MiB, 1 KiB of it the rest of the
|
|
58
|
+
* request.
|
|
59
|
+
*/
|
|
56
60
|
declare const BUILD_BYTES: number;
|
|
57
61
|
/** The most files a build may have, as a deploy admits it. */
|
|
58
62
|
declare const BUILD_FILES = 4000;
|
package/database/build.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DEPLOYED_ENGINE, c as Packages, d as buildDatabase, f as enumAsObject, g as unboundCalls, h as typeOf, i as BuiltFunction, l as Refused, m as isSource, n as BUILD_FILES, o as EngineName, p as exported, r as Built, s as MODULE_BYTES, t as BUILD_BYTES, u as blockNames } from "../build-
|
|
1
|
+
import { a as DEPLOYED_ENGINE, c as Packages, d as buildDatabase, f as enumAsObject, g as unboundCalls, h as typeOf, i as BuiltFunction, l as Refused, m as isSource, n as BUILD_FILES, o as EngineName, p as exported, r as Built, s as MODULE_BYTES, t as BUILD_BYTES, u as blockNames } from "../build-Cw1BOzoq.mjs";
|
|
2
2
|
export { BUILD_BYTES, BUILD_FILES, Built, BuiltFunction, DEPLOYED_ENGINE, EngineName, MODULE_BYTES, Packages, Refused, blockNames, buildDatabase, enumAsObject, exported, isSource, typeOf, unboundCalls };
|
package/database/build.mjs
CHANGED
|
@@ -48,8 +48,12 @@ var Refused = class extends Error {
|
|
|
48
48
|
};
|
|
49
49
|
/** The most one built file may be, as a deploy admits it. */
|
|
50
50
|
const MODULE_BYTES = 1048576;
|
|
51
|
-
/**
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* The most a whole build may be, the folder's modules and every package file they reach, counted as a deploy sends
|
|
53
|
+
* it: the JSON of each file's path and text. The Database takes a deploy of at most 2 MiB, 1 KiB of it the rest of the
|
|
54
|
+
* request.
|
|
55
|
+
*/
|
|
56
|
+
const BUILD_BYTES = 2096128;
|
|
53
57
|
/** The most files a build may have, as a deploy admits it. */
|
|
54
58
|
const BUILD_FILES = 4e3;
|
|
55
59
|
const SOURCES = [
|
|
@@ -141,6 +145,8 @@ function relativeSpec(from, to) {
|
|
|
141
145
|
const GENERATED = /^_generated\/(server|api)(?:\.m?js)?$/u;
|
|
142
146
|
const bytesOf = (text) => new TextEncoder().encode(text).length;
|
|
143
147
|
const mib = (bytes) => `${(bytes / 1024 / 1024).toFixed(1)} MiB`;
|
|
148
|
+
/** A size in KiB, rounded up: `2,047 KiB`. */
|
|
149
|
+
const kib = (bytes) => `${Math.ceil(bytes / 1024).toLocaleString("en-US")} KiB`;
|
|
144
150
|
/** Strips each source: its built file by `<path>.mjs`. Throws `Refused` with the author's file. */
|
|
145
151
|
function stripSources(sources, strip) {
|
|
146
152
|
const entries = Object.keys(sources).filter(isSource);
|
|
@@ -1119,18 +1125,17 @@ function linkAll(sources, packages, strip) {
|
|
|
1119
1125
|
const sorted = Object.fromEntries(Object.entries(files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
1120
1126
|
const count = Object.keys(sorted).length;
|
|
1121
1127
|
if (count > 4e3) throw new Refused(`The build is ${count} files, over ${BUILD_FILES}. Import fewer packages, or smaller parts of them.`);
|
|
1122
|
-
let total = 0;
|
|
1123
1128
|
const byPackage = /* @__PURE__ */ new Map();
|
|
1124
1129
|
for (const [path, text] of Object.entries(sorted)) {
|
|
1125
1130
|
const bytes = bytesOf(text);
|
|
1126
1131
|
if (bytes > 1048576) throw new Refused(`${from[path]} is ${mib(bytes)}, over ${mib(MODULE_BYTES)} for one file. ${path.startsWith("node_modules/") ? "Import a smaller part of its package" : "Split it into smaller modules"}.`);
|
|
1127
|
-
total += bytes;
|
|
1128
1132
|
const pkg = /^node_modules\/((?:@[^/]+\/)?[^/]+)\//u.exec(path)?.[1];
|
|
1129
1133
|
if (pkg) byPackage.set(pkg, (byPackage.get(pkg) ?? 0) + bytes);
|
|
1130
1134
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1135
|
+
const total = bytesOf(JSON.stringify(sorted));
|
|
1136
|
+
if (total > 2096128) {
|
|
1137
|
+
const largest = [...byPackage].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1)).slice(0, 3).map(([name, bytes]) => `${name} (${kib(bytes)})`);
|
|
1138
|
+
throw new Refused(`The build is ${kib(total)} as a deploy sends it, over the ${kib(BUILD_BYTES)} a deploy can be.${largest.length ? ` Its largest packages: ${largest.join(", ")}.` : ""}`);
|
|
1134
1139
|
}
|
|
1135
1140
|
return {
|
|
1136
1141
|
files: sorted,
|
package/database/contract.d.mts
CHANGED
|
@@ -65,7 +65,7 @@ interface DeployCase {
|
|
|
65
65
|
readonly name: string;
|
|
66
66
|
run(deploy: (files: Readonly<Record<string, string>>) => Promise<string | null>): Promise<void>;
|
|
67
67
|
}
|
|
68
|
-
/** The limits a deploy keeps, each at its edge: 1 MiB a file,
|
|
68
|
+
/** The limits a deploy keeps, each at its edge: 1 MiB a file, 2,047 KiB in all as it is sent, and 4000 files. */
|
|
69
69
|
declare const databaseDeployContract: ReadonlyArray<DeployCase>;
|
|
70
70
|
/**
|
|
71
71
|
* An issuer of sign-in tokens made on this machine for the sign-in cases: an RSA key of its own, never one
|
package/database/contract.mjs
CHANGED
|
@@ -2085,7 +2085,11 @@ const admitted = async (deploy, files, what) => {
|
|
|
2085
2085
|
const refused = async (deploy, files, what) => {
|
|
2086
2086
|
if (await deploy(files) === null) throw new Error(`${what}: taken, want it refused`);
|
|
2087
2087
|
};
|
|
2088
|
-
/** The
|
|
2088
|
+
/** The bytes of a deploy's files as it sends them: the JSON of each file's path and text. */
|
|
2089
|
+
const sent = (files) => new TextEncoder().encode(JSON.stringify(files)).length;
|
|
2090
|
+
/** 2,047 KiB: the 2 MiB a deploy's request may be, less 1 KiB for the rest of the request. */
|
|
2091
|
+
const DEPLOY_SENT = 2096128;
|
|
2092
|
+
/** The limits a deploy keeps, each at its edge: 1 MiB a file, 2,047 KiB in all as it is sent, and 4000 files. */
|
|
2089
2093
|
const databaseDeployContract = [
|
|
2090
2094
|
{
|
|
2091
2095
|
name: "a deploy takes a file of exactly 1 MiB, and refuses one a byte larger",
|
|
@@ -2095,14 +2099,20 @@ const databaseDeployContract = [
|
|
|
2095
2099
|
}
|
|
2096
2100
|
},
|
|
2097
2101
|
{
|
|
2098
|
-
name: "a deploy takes
|
|
2102
|
+
name: "a deploy takes 2,047 KiB in all as it sends its files, and refuses a byte more",
|
|
2099
2103
|
async run(deploy) {
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2104
|
+
const two = {
|
|
2105
|
+
"part0.mjs": sized(1e6),
|
|
2106
|
+
"part1.mjs": sized(1e6),
|
|
2107
|
+
"part2.mjs": ""
|
|
2108
|
+
};
|
|
2109
|
+
const filled = (extra) => ({
|
|
2110
|
+
...two,
|
|
2111
|
+
"part2.mjs": sized(DEPLOY_SENT + extra - sent(two) - 3)
|
|
2112
|
+
});
|
|
2113
|
+
if (sent(filled(0)) !== DEPLOY_SENT) throw new Error(`the case's files are ${sent(filled(0))} bytes as sent, want ${DEPLOY_SENT}`);
|
|
2114
|
+
await admitted(deploy, filled(0), "2,047 KiB");
|
|
2115
|
+
await refused(deploy, filled(1), "2,047 KiB and a byte");
|
|
2106
2116
|
}
|
|
2107
2117
|
},
|
|
2108
2118
|
{
|
package/database/stand-in.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { t as DatabaseError } from "../errors-CnQduDOt.mjs";
|
|
|
2
2
|
import { p as Storage } from "../index-CXiY5knc.mjs";
|
|
3
3
|
import { t as AuthConfig } from "../auth-B7rCtXFQ.mjs";
|
|
4
4
|
import { a as FileMetadata, c as FunctionReference, d as HttpRouter, n as CronJob, s as FunctionKind, v as RegisteredFunction, y as Row } from "../server-B5HK2Ou9.mjs";
|
|
5
|
-
import { r as Built } from "../build-
|
|
5
|
+
import { r as Built } from "../build-Cw1BOzoq.mjs";
|
|
6
6
|
import { A as VectorControl, M as VectorEngine } from "../index-5INBK1BU.mjs";
|
|
7
7
|
//#region src/database/stand-in.d.ts
|
|
8
8
|
/** A Database as its client reaches it: by function name or reference. A refusal throws `DatabaseError`. */
|
package/database/stand-in.mjs
CHANGED
|
@@ -871,7 +871,7 @@ function databaseStandIn(options = {}) {
|
|
|
871
871
|
scheduled.set(id, entry);
|
|
872
872
|
entry.timer = setTimeout(() => {
|
|
873
873
|
if (entry.state !== "pending") return;
|
|
874
|
-
entry.state = "
|
|
874
|
+
entry.state = "inProgress";
|
|
875
875
|
invoke(name, entry.args, {
|
|
876
876
|
user: null,
|
|
877
877
|
server: true,
|
package/here-C2jhTheQ.mjs
CHANGED
|
@@ -12,7 +12,7 @@ function processEnv() {
|
|
|
12
12
|
* This package's version: `0.0.0-dev` here, and in a published package the version it was published at, which the
|
|
13
13
|
* release writes in its place as it stages the package (`stampSdk` in `scripts/release/packages.ts`).
|
|
14
14
|
*/
|
|
15
|
-
const SDK_VERSION = "0.1.0-staging.
|
|
15
|
+
const SDK_VERSION = "0.1.0-staging.3886";
|
|
16
16
|
/**
|
|
17
17
|
* The header that tells Midsummer which client made each of this package's calls: `Midsummer-Client: sdk/<version>
|
|
18
18
|
* <part>`, `part` the product whose client it is (`database`, `storage`, `queues`, ...), so the platform counts which
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midsummer-ai/sdk",
|
|
3
|
-
"version": "0.1.0-staging.
|
|
3
|
+
"version": "0.1.0-staging.3886",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Midsummer's handles for an app's code: its Database, Storage, Queues, Vector DB, AI, Email and Agents, with stand-ins for tests.",
|