@superforge/infra 0.1.1 → 0.2.0
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 +37 -26
- package/output/agents.d.ts +50 -69
- package/output/agents.js +118 -85
- package/output/choose.d.ts +3 -1
- package/output/choose.js +20 -13
- package/output/client.d.ts +11 -12
- package/output/client.js +86 -114
- package/output/contract/agents.d.ts +203 -0
- package/output/contract/agents.js +94 -0
- package/output/contract/comments.d.ts +101 -0
- package/output/contract/comments.js +66 -0
- package/output/contract/errors.d.ts +123 -0
- package/output/contract/errors.js +61 -0
- package/output/contract/index.d.ts +6 -0
- package/output/contract/index.js +11 -0
- package/output/contract/login.d.ts +152 -0
- package/output/contract/login.js +93 -0
- package/output/contract/people.d.ts +9 -0
- package/output/contract/people.js +16 -0
- package/output/contract/project.d.ts +38 -0
- package/output/contract/project.js +36 -0
- package/output/index.d.ts +4 -5
- package/output/index.js +10 -8
- package/output/infra.d.ts +44 -58
- package/output/primitives.d.ts +0 -8
- package/output/primitives.js +0 -7
- package/output/stand-in.d.ts +18 -16
- package/output/stand-in.js +74 -39
- package/output/version.d.ts +3 -5
- package/output/version.js +2 -4
- package/package.json +5 -1
- package/output/answers.d.ts +0 -154
- package/output/answers.js +0 -153
- package/output/comments.d.ts +0 -37
- package/output/comments.js +0 -58
package/output/answers.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Which project the key is for, its mode, and its domains, the only hosts
|
|
4
|
-
* besides localhost its login emails link to. An Infra from before it
|
|
5
|
-
* answered the domains answers none here, `null`, which an app shows as
|
|
6
|
-
* not known.
|
|
7
|
-
*/
|
|
8
|
-
export declare const infra_project: z.ZodObject<{
|
|
9
|
-
project: z.ZodObject<{
|
|
10
|
-
id: z.ZodString;
|
|
11
|
-
name: z.ZodString;
|
|
12
|
-
domains: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
mode: z.ZodEnum<{
|
|
15
|
-
live: "live";
|
|
16
|
-
test: "test";
|
|
17
|
-
}>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
/** A login email that went out. */
|
|
20
|
-
export declare const started_login: z.ZodObject<{
|
|
21
|
-
email: z.ZodString;
|
|
22
|
-
with_link: z.ZodBoolean;
|
|
23
|
-
expires_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
24
|
-
test: z.ZodNullable<z.ZodObject<{
|
|
25
|
-
code: z.ZodString;
|
|
26
|
-
link: z.ZodNullable<z.ZodString>;
|
|
27
|
-
}, z.core.$strip>>;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
|
-
/** Why Infra didn't send a login email. */
|
|
30
|
-
export declare const start_refused: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
31
|
-
error: z.ZodLiteral<"too-soon">;
|
|
32
|
-
retry_after: z.ZodNumber;
|
|
33
|
-
message: z.ZodCatch<z.ZodString>;
|
|
34
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
35
|
-
reason: "too-soon";
|
|
36
|
-
retry_after: number;
|
|
37
|
-
message: string;
|
|
38
|
-
}, {
|
|
39
|
-
error: "too-soon";
|
|
40
|
-
retry_after: number;
|
|
41
|
-
message: string;
|
|
42
|
-
}>>, z.ZodPipe<z.ZodObject<{
|
|
43
|
-
error: z.ZodLiteral<"too-many">;
|
|
44
|
-
limit: z.ZodString;
|
|
45
|
-
retry_after: z.ZodNumber;
|
|
46
|
-
message: z.ZodCatch<z.ZodString>;
|
|
47
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
48
|
-
reason: "too-many";
|
|
49
|
-
limit: string;
|
|
50
|
-
retry_after: number;
|
|
51
|
-
message: string;
|
|
52
|
-
}, {
|
|
53
|
-
error: "too-many";
|
|
54
|
-
limit: string;
|
|
55
|
-
retry_after: number;
|
|
56
|
-
message: string;
|
|
57
|
-
}>>, z.ZodPipe<z.ZodObject<{
|
|
58
|
-
error: z.ZodLiteral<"not-sent">;
|
|
59
|
-
message: z.ZodCatch<z.ZodString>;
|
|
60
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
61
|
-
reason: "not-sent";
|
|
62
|
-
message: string;
|
|
63
|
-
}, {
|
|
64
|
-
error: "not-sent";
|
|
65
|
-
message: string;
|
|
66
|
-
}>>]>;
|
|
67
|
-
/** Whose email the code or the link was. */
|
|
68
|
-
export declare const verified_login: z.ZodObject<{
|
|
69
|
-
email: z.ZodString;
|
|
70
|
-
}, z.core.$strip>;
|
|
71
|
-
/** Why what the visitor brought back didn't log them in. */
|
|
72
|
-
export declare const verify_refused: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
73
|
-
error: z.ZodLiteral<"wrong-code">;
|
|
74
|
-
attempts_left: z.ZodNumber;
|
|
75
|
-
message: z.ZodCatch<z.ZodString>;
|
|
76
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
77
|
-
reason: "wrong-code";
|
|
78
|
-
attempts_left: number;
|
|
79
|
-
message: string;
|
|
80
|
-
}, {
|
|
81
|
-
error: "wrong-code";
|
|
82
|
-
attempts_left: number;
|
|
83
|
-
message: string;
|
|
84
|
-
}>>, z.ZodPipe<z.ZodObject<{
|
|
85
|
-
error: z.ZodLiteral<"no-code">;
|
|
86
|
-
message: z.ZodCatch<z.ZodString>;
|
|
87
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
88
|
-
reason: "no-code";
|
|
89
|
-
message: string;
|
|
90
|
-
}, {
|
|
91
|
-
error: "no-code";
|
|
92
|
-
message: string;
|
|
93
|
-
}>>, z.ZodPipe<z.ZodObject<{
|
|
94
|
-
error: z.ZodLiteral<"no-link">;
|
|
95
|
-
message: z.ZodCatch<z.ZodString>;
|
|
96
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
97
|
-
reason: "no-link";
|
|
98
|
-
message: string;
|
|
99
|
-
}, {
|
|
100
|
-
error: "no-link";
|
|
101
|
-
message: string;
|
|
102
|
-
}>>]>;
|
|
103
|
-
/** A comment Infra kept: its ID, and when. */
|
|
104
|
-
export declare const kept_comment: z.ZodPipe<z.ZodObject<{
|
|
105
|
-
comment: z.ZodObject<{
|
|
106
|
-
id: z.ZodString;
|
|
107
|
-
created_at: z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>;
|
|
108
|
-
}, z.core.$strip>;
|
|
109
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
110
|
-
id: string;
|
|
111
|
-
created_at: Date;
|
|
112
|
-
}, {
|
|
113
|
-
comment: {
|
|
114
|
-
id: string;
|
|
115
|
-
created_at: Date;
|
|
116
|
-
};
|
|
117
|
-
}>>;
|
|
118
|
-
/**
|
|
119
|
-
* Why Infra didn't keep a comment. Either is a bug in what the app sent,
|
|
120
|
-
* so sending it again won't help.
|
|
121
|
-
*/
|
|
122
|
-
export declare const comment_refused: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
|
|
123
|
-
error: z.ZodLiteral<"invalid">;
|
|
124
|
-
fields: z.ZodArray<z.ZodString>;
|
|
125
|
-
message: z.ZodCatch<z.ZodString>;
|
|
126
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
127
|
-
reason: "invalid";
|
|
128
|
-
fields: string[];
|
|
129
|
-
message: string;
|
|
130
|
-
}, {
|
|
131
|
-
error: "invalid";
|
|
132
|
-
fields: string[];
|
|
133
|
-
message: string;
|
|
134
|
-
}>>, z.ZodPipe<z.ZodObject<{
|
|
135
|
-
error: z.ZodLiteral<"too-large">;
|
|
136
|
-
limit: z.ZodNumber;
|
|
137
|
-
message: z.ZodCatch<z.ZodString>;
|
|
138
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
139
|
-
reason: "too-large";
|
|
140
|
-
limit: number;
|
|
141
|
-
message: string;
|
|
142
|
-
}, {
|
|
143
|
-
error: "too-large";
|
|
144
|
-
limit: number;
|
|
145
|
-
message: string;
|
|
146
|
-
}>>]>;
|
|
147
|
-
/**
|
|
148
|
-
* Any refusal of Infra's, read only for its words: what the client logs,
|
|
149
|
-
* and what it tells an app about an error it doesn't know
|
|
150
|
-
*/
|
|
151
|
-
export declare const any_refusal: z.ZodObject<{
|
|
152
|
-
error: z.ZodString;
|
|
153
|
-
message: z.ZodOptional<z.ZodString>;
|
|
154
|
-
}, z.core.$strip>;
|
package/output/answers.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// What Infra answers, parsed by the client (client.ts) so an app gets typed
|
|
3
|
-
// values, each refusal read into an app's own shape: its `error` as
|
|
4
|
-
// `reason`. Every refusal carries Infra's `message`, what went wrong and
|
|
5
|
-
// what fixes it in plain words, for whoever runs the app and their agent
|
|
6
|
-
// (Infra's README, "Errors"), or the client's own words when an Infra from
|
|
7
|
-
// before it said one answers. The types in infra.ts come from these, and
|
|
8
|
-
// the stand-in answers the same.
|
|
9
|
-
// Infra's words for a refusal, or these when it gave none
|
|
10
|
-
const said = (fallback) => z.string().catch(fallback);
|
|
11
|
-
/**
|
|
12
|
-
* Which project the key is for, its mode, and its domains, the only hosts
|
|
13
|
-
* besides localhost its login emails link to. An Infra from before it
|
|
14
|
-
* answered the domains answers none here, `null`, which an app shows as
|
|
15
|
-
* not known.
|
|
16
|
-
*/
|
|
17
|
-
export const infra_project = z.object({
|
|
18
|
-
project: z.object({
|
|
19
|
-
id: z.string(),
|
|
20
|
-
name: z.string(),
|
|
21
|
-
domains: z.array(z.string()).nullable().default(null)
|
|
22
|
-
}),
|
|
23
|
-
mode: z.enum(["live", "test"])
|
|
24
|
-
});
|
|
25
|
-
/** A login email that went out. */
|
|
26
|
-
export const started_login = z.object({
|
|
27
|
-
// The address as Infra keeps it, which verifying the code takes
|
|
28
|
-
email: z.string(),
|
|
29
|
-
// Whether the email holds a link as well as the code
|
|
30
|
-
with_link: z.boolean(),
|
|
31
|
-
// When the code and the link stop working
|
|
32
|
-
expires_at: z.iso.datetime().transform((value) => new Date(value)),
|
|
33
|
-
// With a test key, which sends nothing: what the email would have held,
|
|
34
|
-
// for a dev server to show on the page. Null with a secret key.
|
|
35
|
-
test: z.object({ code: z.string(), link: z.string().nullable() }).nullable()
|
|
36
|
-
});
|
|
37
|
-
/** Why Infra didn't send a login email. */
|
|
38
|
-
export const start_refused = z.union([
|
|
39
|
-
// This address was sent one less than a minute ago
|
|
40
|
-
z
|
|
41
|
-
.object({
|
|
42
|
-
error: z.literal("too-soon"),
|
|
43
|
-
retry_after: z.number(),
|
|
44
|
-
message: said("A login email went to this address less than a minute ago.")
|
|
45
|
-
})
|
|
46
|
-
.transform(({ retry_after, message }) => ({
|
|
47
|
-
reason: "too-soon",
|
|
48
|
-
retry_after,
|
|
49
|
-
message
|
|
50
|
-
})),
|
|
51
|
-
// Over one of Infra's limits, an hour each: `email`, `ip` or `project`.
|
|
52
|
-
// Kept as a string, so a limit Infra adds later still reads.
|
|
53
|
-
z
|
|
54
|
-
.object({
|
|
55
|
-
error: z.literal("too-many"),
|
|
56
|
-
limit: z.string(),
|
|
57
|
-
retry_after: z.number(),
|
|
58
|
-
message: said("Infra has sent as many login emails as it sends in an hour.")
|
|
59
|
-
})
|
|
60
|
-
.transform(({ limit, retry_after, message }) => ({
|
|
61
|
-
reason: "too-many",
|
|
62
|
-
limit,
|
|
63
|
-
retry_after,
|
|
64
|
-
message
|
|
65
|
-
})),
|
|
66
|
-
// The email didn't go out, and nothing was counted, so asking again can
|
|
67
|
-
// work at once
|
|
68
|
-
z
|
|
69
|
-
.object({
|
|
70
|
-
error: z.literal("not-sent"),
|
|
71
|
-
message: said("The login email didn't go out.")
|
|
72
|
-
})
|
|
73
|
-
.transform(({ message }) => ({ reason: "not-sent", message }))
|
|
74
|
-
]);
|
|
75
|
-
/** Whose email the code or the link was. */
|
|
76
|
-
export const verified_login = z.object({ email: z.string() });
|
|
77
|
-
/** Why what the visitor brought back didn't log them in. */
|
|
78
|
-
export const verify_refused = z.union([
|
|
79
|
-
// Not the code, which still works for this many more tries
|
|
80
|
-
z
|
|
81
|
-
.object({
|
|
82
|
-
error: z.literal("wrong-code"),
|
|
83
|
-
attempts_left: z.number(),
|
|
84
|
-
message: said("That isn't the code Infra emailed this address.")
|
|
85
|
-
})
|
|
86
|
-
.transform(({ attempts_left, message }) => ({
|
|
87
|
-
reason: "wrong-code",
|
|
88
|
-
attempts_left,
|
|
89
|
-
message
|
|
90
|
-
})),
|
|
91
|
-
// Nothing left to try: never sent, expired, already used, or out of
|
|
92
|
-
// tries
|
|
93
|
-
z
|
|
94
|
-
.object({
|
|
95
|
-
error: z.literal("no-code"),
|
|
96
|
-
message: said("No code is waiting for this address.")
|
|
97
|
-
})
|
|
98
|
-
.transform(({ message }) => ({ reason: "no-code", message })),
|
|
99
|
-
// The link is spent, expired, or never was this project's
|
|
100
|
-
z
|
|
101
|
-
.object({
|
|
102
|
-
error: z.literal("no-link"),
|
|
103
|
-
message: said("That link has been used or has run out.")
|
|
104
|
-
})
|
|
105
|
-
.transform(({ message }) => ({ reason: "no-link", message }))
|
|
106
|
-
]);
|
|
107
|
-
/** A comment Infra kept: its ID, and when. */
|
|
108
|
-
export const kept_comment = z
|
|
109
|
-
.object({
|
|
110
|
-
comment: z.object({
|
|
111
|
-
id: z.string(),
|
|
112
|
-
created_at: z.iso.datetime().transform((value) => new Date(value))
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
.transform(({ comment }) => comment);
|
|
116
|
-
/**
|
|
117
|
-
* Why Infra didn't keep a comment. Either is a bug in what the app sent,
|
|
118
|
-
* so sending it again won't help.
|
|
119
|
-
*/
|
|
120
|
-
export const comment_refused = z.union([
|
|
121
|
-
// Not the call's shape: `fields` names what failed, like `element.tag`
|
|
122
|
-
z
|
|
123
|
-
.object({
|
|
124
|
-
error: z.literal("invalid"),
|
|
125
|
-
fields: z.array(z.string()),
|
|
126
|
-
message: said("The comment didn't fit what Infra takes.")
|
|
127
|
-
})
|
|
128
|
-
.transform(({ fields, message }) => ({
|
|
129
|
-
reason: "invalid",
|
|
130
|
-
fields,
|
|
131
|
-
message
|
|
132
|
-
})),
|
|
133
|
-
// Over the most a call's body can be, in bytes
|
|
134
|
-
z
|
|
135
|
-
.object({
|
|
136
|
-
error: z.literal("too-large"),
|
|
137
|
-
limit: z.number(),
|
|
138
|
-
message: said("The comment is bigger than Infra takes.")
|
|
139
|
-
})
|
|
140
|
-
.transform(({ limit, message }) => ({
|
|
141
|
-
reason: "too-large",
|
|
142
|
-
limit,
|
|
143
|
-
message
|
|
144
|
-
}))
|
|
145
|
-
]);
|
|
146
|
-
/**
|
|
147
|
-
* Any refusal of Infra's, read only for its words: what the client logs,
|
|
148
|
-
* and what it tells an app about an error it doesn't know
|
|
149
|
-
*/
|
|
150
|
-
export const any_refusal = z.object({
|
|
151
|
-
error: z.string(),
|
|
152
|
-
message: z.string().optional()
|
|
153
|
-
});
|
package/output/comments.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** The most a comment says, in characters, as Infra takes it */
|
|
3
|
-
export declare const LONGEST_COMMENT = 5000;
|
|
4
|
-
/** How big one comment's body can be, in bytes, as Infra takes it */
|
|
5
|
-
export declare const COMMENT_BODY_LIMIT: number;
|
|
6
|
-
/**
|
|
7
|
-
* One call's body: what was written, the page's path and title, the
|
|
8
|
-
* element it's about (a CSS selector from the page's body, its tag, the
|
|
9
|
-
* text it shows or null, its `class`, and its box on the page), or null for
|
|
10
|
-
* the page as a whole, the window's size, the app's own ID for whoever
|
|
11
|
-
* filed it, never their email, and their browser's User-Agent, for what
|
|
12
|
-
* they were on, which Infra doesn't keep
|
|
13
|
-
*/
|
|
14
|
-
export declare const filed_comment: z.ZodObject<{
|
|
15
|
-
body: z.ZodString;
|
|
16
|
-
path: z.ZodString;
|
|
17
|
-
title: z.ZodNullable<z.ZodString>;
|
|
18
|
-
element: z.ZodNullable<z.ZodObject<{
|
|
19
|
-
selector: z.ZodString;
|
|
20
|
-
tag: z.ZodString;
|
|
21
|
-
text: z.ZodNullable<z.ZodString>;
|
|
22
|
-
classes: z.ZodNullable<z.ZodString>;
|
|
23
|
-
box: z.ZodObject<{
|
|
24
|
-
x: z.ZodNumber;
|
|
25
|
-
y: z.ZodNumber;
|
|
26
|
-
width: z.ZodNumber;
|
|
27
|
-
height: z.ZodNumber;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
|
-
}, z.core.$strip>>;
|
|
30
|
-
viewport: z.ZodNullable<z.ZodObject<{
|
|
31
|
-
width: z.ZodNumber;
|
|
32
|
-
height: z.ZodNumber;
|
|
33
|
-
}, z.core.$strip>>;
|
|
34
|
-
user: z.ZodNullable<z.ZodString>;
|
|
35
|
-
user_agent: z.ZodNullable<z.ZodString>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
export type FiledComment = z.infer<typeof filed_comment>;
|
package/output/comments.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// What an app's server sends Infra for its toolbar, through `fileComment`
|
|
3
|
-
// (infra.ts): a comment someone logged in wrote about an element of a page,
|
|
4
|
-
// which the toolbar posted to the app's own /api/comments, with who they
|
|
5
|
-
// are. It's what Infra checks (Infra's README, "Comments"), and the
|
|
6
|
-
// stand-in checks it the same (stand-in.ts). An app's toolbar checks the
|
|
7
|
-
// comment itself with its own schema first, for its form to say what's
|
|
8
|
-
// wrong at once.
|
|
9
|
-
/** The most a comment says, in characters, as Infra takes it */
|
|
10
|
-
export const LONGEST_COMMENT = 5000;
|
|
11
|
-
/** How big one comment's body can be, in bytes, as Infra takes it */
|
|
12
|
-
export const COMMENT_BODY_LIMIT = 32 * 1024;
|
|
13
|
-
// A place or a length on the page, in whole CSS pixels: a page can be
|
|
14
|
-
// scrolled far, and an element can sit above its top
|
|
15
|
-
const coordinate = z.number().int().min(-1_000_000).max(10_000_000);
|
|
16
|
-
const length = z.number().int().min(0).max(10_000_000);
|
|
17
|
-
/**
|
|
18
|
-
* One call's body: what was written, the page's path and title, the
|
|
19
|
-
* element it's about (a CSS selector from the page's body, its tag, the
|
|
20
|
-
* text it shows or null, its `class`, and its box on the page), or null for
|
|
21
|
-
* the page as a whole, the window's size, the app's own ID for whoever
|
|
22
|
-
* filed it, never their email, and their browser's User-Agent, for what
|
|
23
|
-
* they were on, which Infra doesn't keep
|
|
24
|
-
*/
|
|
25
|
-
export const filed_comment = z.object({
|
|
26
|
-
body: z.string().trim().min(1).max(LONGEST_COMMENT),
|
|
27
|
-
path: z
|
|
28
|
-
.string()
|
|
29
|
-
.max(2048)
|
|
30
|
-
.regex(/^\/[^?#]*$/),
|
|
31
|
-
title: z.string().trim().max(200).nullable(),
|
|
32
|
-
element: z
|
|
33
|
-
.object({
|
|
34
|
-
selector: z.string().trim().min(1).max(1000),
|
|
35
|
-
tag: z
|
|
36
|
-
.string()
|
|
37
|
-
.max(64)
|
|
38
|
-
.regex(/^[a-z][a-z0-9-]*$/),
|
|
39
|
-
text: z.string().max(1000).nullable(),
|
|
40
|
-
classes: z.string().max(1000).nullable(),
|
|
41
|
-
box: z.object({
|
|
42
|
-
x: coordinate,
|
|
43
|
-
y: coordinate,
|
|
44
|
-
width: length,
|
|
45
|
-
height: length
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
.nullable(),
|
|
49
|
-
viewport: z.object({ width: length, height: length }).nullable(),
|
|
50
|
-
user: z
|
|
51
|
-
.string()
|
|
52
|
-
.trim()
|
|
53
|
-
.min(1)
|
|
54
|
-
.max(128)
|
|
55
|
-
.refine((id) => !id.includes("@"), { message: "An email, not an ID" })
|
|
56
|
-
.nullable(),
|
|
57
|
-
user_agent: z.string().max(1024).nullable()
|
|
58
|
-
});
|