@omnichar/contracts 0.9.1 → 0.10.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/dist/v1/charInspection.d.ts +50 -0
- package/dist/v1/charInspection.d.ts.map +1 -0
- package/dist/v1/charInspection.js +35 -0
- package/dist/v1/charInspection.js.map +1 -0
- package/dist/v1/characterListings.d.ts +73 -0
- package/dist/v1/characterListings.d.ts.map +1 -0
- package/dist/v1/characterListings.js +61 -0
- package/dist/v1/characterListings.js.map +1 -0
- package/dist/v1/characters.d.ts +1 -0
- package/dist/v1/characters.d.ts.map +1 -1
- package/dist/v1/characters.js +2 -0
- package/dist/v1/characters.js.map +1 -1
- package/dist/v1/index.d.ts +4 -0
- package/dist/v1/index.d.ts.map +1 -1
- package/dist/v1/index.js +4 -0
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/me.d.ts +1 -0
- package/dist/v1/me.d.ts.map +1 -1
- package/dist/v1/me.js +3 -0
- package/dist/v1/me.js.map +1 -1
- package/dist/v1/runs.d.ts +126 -0
- package/dist/v1/runs.d.ts.map +1 -1
- package/dist/v1/runs.js +20 -0
- package/dist/v1/runs.js.map +1 -1
- package/dist/v1/sessions.d.ts +349 -0
- package/dist/v1/sessions.d.ts.map +1 -0
- package/dist/v1/sessions.js +73 -0
- package/dist/v1/sessions.js.map +1 -0
- package/dist/v1/studio.d.ts +119 -0
- package/dist/v1/studio.d.ts.map +1 -0
- package/dist/v1/studio.js +98 -0
- package/dist/v1/studio.js.map +1 -0
- package/dist/v1/usernames.d.ts +35 -0
- package/dist/v1/usernames.d.ts.map +1 -0
- package/dist/v1/usernames.js +67 -0
- package/dist/v1/usernames.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const USERNAME_MIN = 3;
|
|
3
|
+
export declare const USERNAME_MAX = 30;
|
|
4
|
+
export declare const USERNAME_PATTERN: RegExp;
|
|
5
|
+
export declare const RESERVED_USERNAMES: readonly ["about", "admin", "api", "auth", "characters", "help", "login", "logout", "omnichar", "pricing", "privacy", "projects", "root", "settings", "signup", "staff", "support", "team", "terms", "welcome", "workflows"];
|
|
6
|
+
/** Lowercasing is the client's job before it sends, so the API can refuse what it did not mean. */
|
|
7
|
+
export declare function normaliseUsername(raw: string): string;
|
|
8
|
+
export declare function isReservedUsername(name: string): boolean;
|
|
9
|
+
export declare const usernameShapeSchema: z.ZodString;
|
|
10
|
+
export declare const usernameSchema: z.ZodString;
|
|
11
|
+
export declare const usernameAvailableQuerySchema: z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const usernameAvailableSchema: z.ZodObject<{
|
|
15
|
+
available: z.ZodBoolean;
|
|
16
|
+
reason: z.ZodNullable<z.ZodEnum<{
|
|
17
|
+
shape: "shape";
|
|
18
|
+
reserved: "reserved";
|
|
19
|
+
taken: "taken";
|
|
20
|
+
}>>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export declare const claimUsernameBodySchema: z.ZodObject<{
|
|
23
|
+
username: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const claimUsernameResponseSchema: z.ZodObject<{
|
|
26
|
+
username: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type UsernameAvailable = z.infer<typeof usernameAvailableSchema>;
|
|
29
|
+
export type ClaimUsernameBody = z.infer<typeof claimUsernameBodySchema>;
|
|
30
|
+
export type ClaimUsernameResponse = z.infer<typeof claimUsernameResponseSchema>;
|
|
31
|
+
export declare const myUsernameSchema: z.ZodObject<{
|
|
32
|
+
username: z.ZodNullable<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type MyUsername = z.infer<typeof myUsernameSchema>;
|
|
35
|
+
//# sourceMappingURL=usernames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usernames.d.ts","sourceRoot":"","sources":["../../src/v1/usernames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,YAAY,IAAI,CAAA;AAC7B,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,gBAAgB,QAAiB,CAAA;AAK9C,eAAO,MAAM,kBAAkB,8NAsBrB,CAAA;AAEV,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAID,eAAO,MAAM,mBAAmB,aAIN,CAAA;AAE1B,eAAO,MAAM,cAAc,aAEzB,CAAA;AAIF,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;iBAIlC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;iBAAyC,CAAA;AAE7E,eAAO,MAAM,2BAA2B;;iBAAyC,CAAA;AAEjF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAI/E,eAAO,MAAM,gBAAgB;;iBAE3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// A handle is public, so the character set is deliberately narrow. Uppercase is refused rather than
|
|
3
|
+
// folded, which is what lets a plain unique index behave case-insensitively with no citext extension.
|
|
4
|
+
export const USERNAME_MIN = 3;
|
|
5
|
+
export const USERNAME_MAX = 30;
|
|
6
|
+
export const USERNAME_PATTERN = /^[a-z0-9_]+$/;
|
|
7
|
+
// Out of circulation so a handle can never read as though it belongs to us, or collide with a path
|
|
8
|
+
// if a profile route is ever added. Only words that could actually be claimed are listed: anything
|
|
9
|
+
// with a hyphen, or shorter than the minimum, is already unreachable.
|
|
10
|
+
export const RESERVED_USERNAMES = [
|
|
11
|
+
'about',
|
|
12
|
+
'admin',
|
|
13
|
+
'api',
|
|
14
|
+
'auth',
|
|
15
|
+
'characters',
|
|
16
|
+
'help',
|
|
17
|
+
'login',
|
|
18
|
+
'logout',
|
|
19
|
+
'omnichar',
|
|
20
|
+
'pricing',
|
|
21
|
+
'privacy',
|
|
22
|
+
'projects',
|
|
23
|
+
'root',
|
|
24
|
+
'settings',
|
|
25
|
+
'signup',
|
|
26
|
+
'staff',
|
|
27
|
+
'support',
|
|
28
|
+
'team',
|
|
29
|
+
'terms',
|
|
30
|
+
'welcome',
|
|
31
|
+
'workflows',
|
|
32
|
+
];
|
|
33
|
+
/** Lowercasing is the client's job before it sends, so the API can refuse what it did not mean. */
|
|
34
|
+
export function normaliseUsername(raw) {
|
|
35
|
+
return raw.trim().toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
export function isReservedUsername(name) {
|
|
38
|
+
return RESERVED_USERNAMES.includes(name);
|
|
39
|
+
}
|
|
40
|
+
// Shape alone, with no opinion on whether the word is spoken for. Separate so a caller can be told
|
|
41
|
+
// which of the two it failed: "too short" and "already ours" are different answers.
|
|
42
|
+
export const usernameShapeSchema = z
|
|
43
|
+
.string()
|
|
44
|
+
.min(USERNAME_MIN)
|
|
45
|
+
.max(USERNAME_MAX)
|
|
46
|
+
.regex(USERNAME_PATTERN);
|
|
47
|
+
export const usernameSchema = usernameShapeSchema.refine((name) => !isReservedUsername(name), {
|
|
48
|
+
message: 'That one is reserved.',
|
|
49
|
+
});
|
|
50
|
+
// Loosely typed on purpose: a live checker wants to be told why a candidate is wrong, so the route
|
|
51
|
+
// answers rather than rejecting the request. The shape is judged in the response, not the schema.
|
|
52
|
+
export const usernameAvailableQuerySchema = z.object({
|
|
53
|
+
name: z.string().min(1).max(64),
|
|
54
|
+
});
|
|
55
|
+
export const usernameAvailableSchema = z.object({
|
|
56
|
+
available: z.boolean(),
|
|
57
|
+
// Why not, when it is not, so the form states a reason instead of guessing at one.
|
|
58
|
+
reason: z.enum(['shape', 'reserved', 'taken']).nullable(),
|
|
59
|
+
});
|
|
60
|
+
export const claimUsernameBodySchema = z.object({ username: usernameSchema });
|
|
61
|
+
export const claimUsernameResponseSchema = z.object({ username: usernameSchema });
|
|
62
|
+
// The caller's own username, or null when they have not set one. Its own response rather than a
|
|
63
|
+
// field on /v1/me, because that route is behind the alpha gate and this is not.
|
|
64
|
+
export const myUsernameSchema = z.object({
|
|
65
|
+
username: z.string().nullable(),
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=usernames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usernames.js","sourceRoot":"","sources":["../../src/v1/usernames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,oGAAoG;AACpG,sGAAsG;AACtG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAA;AAC7B,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAC9B,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAE9C,mGAAmG;AACnG,mGAAmG;AACnG,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,YAAY;IACZ,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,SAAS;IACT,SAAS;IACT,UAAU;IACV,MAAM;IACN,UAAU;IACV,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,OAAO;IACP,SAAS;IACT,WAAW;CACH,C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