@midsummer-ai/sdk 0.1.0-staging.4333 → 0.1.0-staging.4339
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/auth/mail.mjs +9 -9
- package/client.mjs +1 -1
- package/contract.mjs +1 -1
- package/database/stand-in.mjs +1 -1
- package/here-C2jhTheQ.mjs +1 -1
- package/index.mjs +1 -1
- package/package.json +9 -7
- package/s3.mjs +1 -1
- package/socket.mjs +1 -1
- package/{src-C1ZmZ4oB.mjs → src-GjQuOm-D.mjs} +6 -7
- package/stand-in.mjs +1 -1
package/auth/mail.mjs
CHANGED
|
@@ -24,21 +24,21 @@ const NAME = /^[^\r\n<>]{1,80}$/;
|
|
|
24
24
|
function checkSignInMail(value) {
|
|
25
25
|
const given = typeof value === "object" && value !== null ? value : {};
|
|
26
26
|
const invalid = (why) => new EmailError("invalid", why);
|
|
27
|
-
if (typeof given.to !== "string" || !ADDRESS.test(given.to) || given.to.length > 254) throw invalid("
|
|
28
|
-
if (!KINDS.includes(given.kind)) throw invalid(`
|
|
29
|
-
if (typeof given.app !== "string" || !NAME.test(given.app.trim())) throw invalid("
|
|
27
|
+
if (typeof given.to !== "string" || !ADDRESS.test(given.to) || given.to.length > 254) throw invalid("A sign-in mail's to is the one email address it goes to, such as ada@example.com.");
|
|
28
|
+
if (!KINDS.includes(given.kind)) throw invalid(`A sign-in mail's kind is one of ${KINDS.join(", ")}.`);
|
|
29
|
+
if (typeof given.app !== "string" || !NAME.test(given.app.trim())) throw invalid("A sign-in mail's app is the app's name, 1 to 80 characters on one line, such as Shop.");
|
|
30
30
|
const kind = given.kind;
|
|
31
31
|
if (kind === "code") {
|
|
32
|
-
if (typeof given.code !== "string" || !/^[A-Za-z0-9-]{4,16}$/.test(given.code)) throw invalid("
|
|
32
|
+
if (typeof given.code !== "string" || !/^[A-Za-z0-9-]{4,16}$/.test(given.code)) throw invalid("A code mail's code is 4 to 16 letters or digits, such as 123456.");
|
|
33
33
|
} else if (kind !== "device" || given.url !== void 0) {
|
|
34
34
|
const url = typeof given.url === "string" ? URL.parse(given.url) : null;
|
|
35
|
-
if (!url || !(url.protocol === "https:" || url.protocol === "http:" && LOCAL.test(url.hostname)) || given.url.length > 2048) throw invalid("
|
|
35
|
+
if (!url || !(url.protocol === "https:" || url.protocol === "http:" && LOCAL.test(url.hostname)) || given.url.length > 2048) throw invalid("A sign-in mail's url is the address its link opens: an https address of at most 2048 characters. Every kind but code and device has one.");
|
|
36
36
|
}
|
|
37
|
-
for (const field of ["organization", "inviter"]) if (given[field] !== void 0 && (typeof given[field] !== "string" || !NAME.test(given[field]))) throw invalid(`
|
|
38
|
-
if (given.device !== void 0 && (typeof given.device !== "string" || !/^[^\r\n<>]{1,120}$/.test(given.device))) throw invalid("
|
|
37
|
+
for (const field of ["organization", "inviter"]) if (given[field] !== void 0 && (typeof given[field] !== "string" || !NAME.test(given[field]))) throw invalid(`A sign-in mail's ${field} is 1 to 80 characters on one line.`);
|
|
38
|
+
if (given.device !== void 0 && (typeof given.device !== "string" || !/^[^\r\n<>]{1,120}$/.test(given.device))) throw invalid("A sign-in mail's device is 1 to 120 characters on one line, such as Firefox on Linux.");
|
|
39
39
|
const brand = typeof given.brand === "object" && given.brand !== null ? given.brand : {};
|
|
40
|
-
if (brand.logo !== void 0 && (typeof brand.logo !== "string" || URL.parse(brand.logo)?.protocol !== "https:" || brand.logo.length > 2048)) throw invalid("
|
|
41
|
-
if (brand.color !== void 0 && (typeof brand.color !== "string" || !/^#[0-9a-f]{6}$/i.test(brand.color))) throw invalid("
|
|
40
|
+
if (brand.logo !== void 0 && (typeof brand.logo !== "string" || URL.parse(brand.logo)?.protocol !== "https:" || brand.logo.length > 2048)) throw invalid("A sign-in mail's brand.logo is an https address.");
|
|
41
|
+
if (brand.color !== void 0 && (typeof brand.color !== "string" || !/^#[0-9a-f]{6}$/i.test(brand.color))) throw invalid("A sign-in mail's brand.color is #rrggbb, such as #2f6feb.");
|
|
42
42
|
return {
|
|
43
43
|
to: given.to.toLowerCase(),
|
|
44
44
|
kind,
|
package/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as FRAMES_PATH, c as serveSigned, l as signedHttp, o as SOCKET_PATH, s as client } from "./src-
|
|
1
|
+
import { a as FRAMES_PATH, c as serveSigned, l as signedHttp, o as SOCKET_PATH, s as client } from "./src-GjQuOm-D.mjs";
|
|
2
2
|
export { FRAMES_PATH, SOCKET_PATH, client, serveSigned, signedHttp };
|
package/contract.mjs
CHANGED
package/database/stand-in.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as storage } from "../src-
|
|
1
|
+
import { r as storage } from "../src-GjQuOm-D.mjs";
|
|
2
2
|
import { standIn } from "../stand-in.mjs";
|
|
3
3
|
import { _ as shapeError, a as tagBytes, b as valueAt, f as indexFields, g as shapeAt, i as keyBytes, o as untagBytes, v as tableCode } from "../bytes-C2pcyl9u.mjs";
|
|
4
4
|
import { A as comparePrefix, M as indexTuple, O as valueKey, S as nextCron, T as readLimited, _ as isFunction, a as Refusal, b as limits, i as NotFoundError, j as documentBytes, k as compareKey, l as fetchOver, o as TooLarge, r as InsufficientError, y as isRouter } from "../server-Drjni3-F.mjs";
|
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.4339";
|
|
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/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as StorageError } from "./errors-B1tO_wdm.mjs";
|
|
2
|
-
import { i as streamsOf, n as bucket, r as storage, t as WORKLOAD_PATH } from "./src-
|
|
2
|
+
import { i as streamsOf, n as bucket, r as storage, t as WORKLOAD_PATH } from "./src-GjQuOm-D.mjs";
|
|
3
3
|
export { StorageError, WORKLOAD_PATH, bucket, storage, streamsOf };
|
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.4339",
|
|
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.",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://docs.staging.midsummer.new",
|
|
13
13
|
"exports": {
|
|
14
|
-
"
|
|
14
|
+
"./storage": {
|
|
15
15
|
"types": "./index.d.mts",
|
|
16
16
|
"import": "./index.mjs"
|
|
17
17
|
},
|
|
18
|
-
"./stand-in": {
|
|
18
|
+
"./storage/stand-in": {
|
|
19
19
|
"types": "./stand-in.d.mts",
|
|
20
20
|
"import": "./stand-in.mjs"
|
|
21
21
|
},
|
|
22
|
-
"./contract": {
|
|
22
|
+
"./storage/contract": {
|
|
23
23
|
"types": "./contract.d.mts",
|
|
24
24
|
"import": "./contract.mjs"
|
|
25
25
|
},
|
|
@@ -236,13 +236,15 @@
|
|
|
236
236
|
"import": "./auth/import.mjs"
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
|
-
"types": "./index.d.mts",
|
|
240
239
|
"typesVersions": {
|
|
241
240
|
"*": {
|
|
242
|
-
"
|
|
241
|
+
"storage": [
|
|
242
|
+
"./index.d.mts"
|
|
243
|
+
],
|
|
244
|
+
"storage/stand-in": [
|
|
243
245
|
"./stand-in.d.mts"
|
|
244
246
|
],
|
|
245
|
-
"contract": [
|
|
247
|
+
"storage/contract": [
|
|
246
248
|
"./contract.d.mts"
|
|
247
249
|
],
|
|
248
250
|
"wire": [
|
package/s3.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as StorageError } from "./errors-B1tO_wdm.mjs";
|
|
2
2
|
import { a as checkMetadata, l as checkUploadId, m as sha256, n as checkBucketName, o as checkPartNumber, r as checkKey, s as checkParts } from "./names-Do0ot5Ha.mjs";
|
|
3
|
-
import { i as streamsOf } from "./src-
|
|
3
|
+
import { i as streamsOf } from "./src-GjQuOm-D.mjs";
|
|
4
4
|
import { inertHeaders } from "./inert.mjs";
|
|
5
5
|
//#region src/s3.ts
|
|
6
6
|
/**
|
package/socket.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as sameHex, f as sign, m as socketSession, p as socket, u as keyed } from "./src-
|
|
1
|
+
import { d as sameHex, f as sign, m as socketSession, p as socket, u as keyed } from "./src-GjQuOm-D.mjs";
|
|
2
2
|
export { keyed, sameHex, sign, socket, socketSession };
|
|
@@ -366,15 +366,14 @@ function serveSigned(options) {
|
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/index.ts
|
|
368
368
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
* Imported as `@midsummer-ai/sdk`, it gives you storage: your team's files, kept in buckets.
|
|
369
|
+
* Storage: your team's files, kept in buckets. Each of Midsummer's products is its own entry of the SDK, imported by
|
|
370
|
+
* its name, as `@midsummer-ai/sdk/storage` is Storage's and `@midsummer-ai/sdk/queues` is Queues'.
|
|
372
371
|
*
|
|
373
372
|
* In your deployment, in any framework, `bucket` reaches a bucket by the name the environment binds
|
|
374
373
|
* it under (`midsummer env binding set`), so `avatars` can be one bucket in production and another
|
|
375
374
|
* in preview. Under `midsummer dev`, each name is a bucket of its own:
|
|
376
375
|
*
|
|
377
|
-
* import { bucket } from "@midsummer-ai/sdk"
|
|
376
|
+
* import { bucket } from "@midsummer-ai/sdk/storage"
|
|
378
377
|
*
|
|
379
378
|
* const avatars = bucket("avatars")
|
|
380
379
|
* await avatars.put("ada.png", new Uint8Array(await request.arrayBuffer()), { contentType: "image/png" })
|
|
@@ -382,13 +381,13 @@ function serveSigned(options) {
|
|
|
382
381
|
*
|
|
383
382
|
* Code that runs outside Midsummer connects with a storage key (`midsummer storage key create`):
|
|
384
383
|
*
|
|
385
|
-
* import { storage } from "@midsummer-ai/sdk"
|
|
384
|
+
* import { storage } from "@midsummer-ai/sdk/storage"
|
|
386
385
|
* import { client } from "@midsummer-ai/sdk/client"
|
|
387
386
|
*
|
|
388
387
|
* const files = storage(client("https://api.<site>", { key, secret }))
|
|
389
388
|
*
|
|
390
|
-
* In tests, `standIn` from `@midsummer-ai/sdk/stand-in` keeps files in memory. All three pass the same
|
|
391
|
-
* tests, in `@midsummer-ai/sdk/contract`, and only what those tests check is guaranteed.
|
|
389
|
+
* In tests, `standIn` from `@midsummer-ai/sdk/storage/stand-in` keeps files in memory. All three pass the same
|
|
390
|
+
* tests, in `@midsummer-ai/sdk/storage/contract`, and only what those tests check is guaranteed.
|
|
392
391
|
*
|
|
393
392
|
* Bucket names and keys are checked before a request is sent. Every failure is a `StorageError`,
|
|
394
393
|
* and its `code` shows which kind. Reading a key with nothing stored returns `null`, not an error.
|
package/stand-in.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { f as resolveRange, m as sha256, p as sameSizes, u as compareKeys } from
|
|
|
3
3
|
//#region src/stand-in.ts
|
|
4
4
|
/**
|
|
5
5
|
* Storage's Stand-in: the Capability's behaviour in memory, for `midsummer dev` and tests. It holds
|
|
6
|
-
* no engine code and passes the contract (`@midsummer-ai/sdk/contract`) except durability and scale.
|
|
6
|
+
* no engine code and passes the contract (`@midsummer-ai/sdk/storage/contract`) except durability and scale.
|
|
7
7
|
*
|
|
8
8
|
* const files = storage(standIn({ clock: Date.now }))
|
|
9
9
|
*
|