social bookmarking for atproto

[lexicons] Add some more constraints to lexicons and refactor

hexmani.ac 4c57816d 436be09b

verified
+146 -127
+3
.idea/dictionaries/project.xml
··· 11 11 <w>dids</w> 12 12 <w>hono</w> 13 13 <w>jetstream</w> 14 + <w>lexdocs</w> 14 15 <w>llms</w> 15 16 <w>llmstxt</w> 16 17 <w>multiformats</w> 18 + <w>nsid</w> 19 + <w>outdir</w> 17 20 <w>rkey</w> 18 21 <w>tseslint</w> 19 22 <w>xrpc</w>
+2
lexdocs/clippr/social/clippr/actor/defs.json lexdocs/social/clippr/actor/defs.json
··· 19 19 }, 20 20 "displayName": { 21 21 "type": "string", 22 + "minGraphemes": 1, 23 + "minLength": 10, 22 24 "maxGraphemes": 64, 23 25 "maxLength": 640 24 26 },
lexdocs/clippr/social/clippr/actor/getProfile.json lexdocs/social/clippr/actor/getProfile.json
+2
lexdocs/clippr/social/clippr/actor/profile.json lexdocs/social/clippr/actor/profile.json
··· 16 16 "displayName": { 17 17 "type": "string", 18 18 "description": "A display name to be shown on a profile.", 19 + "minGraphemes": 1, 20 + "minLength": 10, 19 21 "maxGraphemes": 64, 20 22 "maxLength": 640 21 23 },
+9
lexdocs/clippr/social/clippr/feed/clip.json lexdocs/social/clippr/feed/clip.json
··· 18 18 "properties": { 19 19 "url": { 20 20 "type": "string", 21 + "format": "uri", 21 22 "description": "The URL of the bookmark. Cannot be left empty or be modified after creation.", 23 + "minGraphemes": 3, 24 + "minLength": 30, 22 25 "maxGraphemes": 2000, 23 26 "maxLength": 20000 24 27 }, 25 28 "title": { 26 29 "type": "string", 27 30 "description": "The title of the bookmark. If left empty, reuse the URL.", 31 + "minGraphemes": 1, 32 + "minLength": 10, 28 33 "maxGraphemes": 2048, 29 34 "maxLength": 20480 30 35 }, 31 36 "description": { 32 37 "type": "string", 33 38 "description": "A description of the bookmark's content. This should be ripped from the URL metadata and be static for all records using the URL.", 39 + "minGraphemes": 1, 40 + "minLength": 10, 34 41 "maxGraphemes": 4096, 35 42 "maxLength": 40960 36 43 }, 37 44 "notes": { 38 45 "type": "string", 39 46 "description": "User-written notes for the bookmark. Public and personal.", 47 + "minGraphemes": 1, 48 + "minLength": 10, 40 49 "maxGraphemes": 10000, 41 50 "maxLength": 100000 42 51 },
+4
lexdocs/clippr/social/clippr/feed/tag.json lexdocs/social/clippr/feed/tag.json
··· 16 16 "name": { 17 17 "type": "string", 18 18 "description": "A de-duplicated string containing the name of the tag.", 19 + "minGraphemes": 1, 20 + "minLength": 10, 19 21 "maxGraphemes": 64, 20 22 "maxLength": 640 21 23 }, 22 24 "color": { 23 25 "type": "string", 24 26 "description": "A hexadecimal color code.", 27 + "minGraphemes": 4, 28 + "minLength": 40, 25 29 "maxGraphemes": 7, 26 30 "maxLength": 70 27 31 },
+22 -23
lexicons/lib/lexicons/types/social/clippr/actor/defs.ts
··· 4 4 * SPDX-License-Identifier: AGPL-3.0-only 5 5 */ 6 6 7 + import type {} from "@atcute/lexicons"; 7 8 import * as v from "@atcute/lexicons/validations"; 8 9 9 10 const _profileViewSchema = /*#__PURE__*/ v.object({ 10 - $type: /*#__PURE__*/ v.optional( 11 - /*#__PURE__*/ v.literal("social.clippr.actor.defs#profileView"), 12 - ), 13 - avatar: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.genericUriString()), 14 - createdAt: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.datetimeString()), 15 - description: /*#__PURE__*/ v.optional( 16 - /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 17 - /*#__PURE__*/ v.stringLength(0, 5000), 18 - /*#__PURE__*/ v.stringGraphemes(0, 500), 19 - ]), 20 - ), 21 - did: /*#__PURE__*/ v.didString(), 22 - displayName: /*#__PURE__*/ v.optional( 23 - /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 24 - /*#__PURE__*/ v.stringLength(0, 640), 25 - /*#__PURE__*/ v.stringGraphemes(0, 64), 26 - ]), 27 - ), 28 - handle: /*#__PURE__*/ v.handleString(), 11 + $type: /*#__PURE__*/ v.optional( 12 + /*#__PURE__*/ v.literal("social.clippr.actor.defs#profileView"), 13 + ), 14 + avatar: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.genericUriString()), 15 + createdAt: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.datetimeString()), 16 + description: /*#__PURE__*/ v.optional( 17 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 18 + /*#__PURE__*/ v.stringLength(0, 5000), 19 + /*#__PURE__*/ v.stringGraphemes(0, 500), 20 + ]), 21 + ), 22 + did: /*#__PURE__*/ v.didString(), 23 + displayName: /*#__PURE__*/ v.optional( 24 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 25 + /*#__PURE__*/ v.stringLength(10, 640), 26 + /*#__PURE__*/ v.stringGraphemes(1, 64), 27 + ]), 28 + ), 29 + handle: /*#__PURE__*/ v.handleString(), 29 30 }); 30 31 31 32 type profileView$schematype = typeof _profileViewSchema; 32 33 33 - export interface profileViewSchema extends profileView$schematype { 34 - } 34 + export interface profileViewSchema extends profileView$schematype {} 35 35 36 36 export const profileViewSchema = _profileViewSchema as profileViewSchema; 37 37 38 - export interface ProfileView extends v.InferInput<typeof profileViewSchema> { 39 - } 38 + export interface ProfileView extends v.InferInput<typeof profileViewSchema> {}
+15 -15
lexicons/lib/lexicons/types/social/clippr/actor/getProfile.ts
··· 4 4 * SPDX-License-Identifier: AGPL-3.0-only 5 5 */ 6 6 7 + import type {} from "@atcute/lexicons"; 7 8 import * as v from "@atcute/lexicons/validations"; 9 + import type {} from "@atcute/lexicons/ambient"; 8 10 import * as SocialClipprActorDefs from "./defs.js"; 9 11 10 12 const _mainSchema = /*#__PURE__*/ v.query("social.clippr.actor.getProfile", { 11 - params: /*#__PURE__*/ v.object({ 12 - actor: /*#__PURE__*/ v.actorIdentifierString(), 13 - }), 14 - output: { 15 - type: "lex", 16 - get schema() { 17 - return SocialClipprActorDefs.profileViewSchema; 18 - }, 13 + params: /*#__PURE__*/ v.object({ 14 + actor: /*#__PURE__*/ v.actorIdentifierString(), 15 + }), 16 + output: { 17 + type: "lex", 18 + get schema() { 19 + return SocialClipprActorDefs.profileViewSchema; 19 20 }, 21 + }, 20 22 }); 21 23 22 24 type main$schematype = typeof _mainSchema; 23 25 24 - export interface mainSchema extends main$schematype { 25 - } 26 + export interface mainSchema extends main$schematype {} 26 27 27 28 export const mainSchema = _mainSchema as mainSchema; 28 29 29 - export interface $params extends v.InferInput<mainSchema["params"]> { 30 - } 30 + export interface $params extends v.InferInput<mainSchema["params"]> {} 31 31 export type $output = v.InferXRPCBodyInput<mainSchema["output"]>; 32 32 33 33 declare module "@atcute/lexicons/ambient" { 34 - interface XRPCQueries { 35 - "social.clippr.actor.getProfile": mainSchema; 36 - } 34 + interface XRPCQueries { 35 + "social.clippr.actor.getProfile": mainSchema; 36 + } 37 37 }
+23 -23
lexicons/lib/lexicons/types/social/clippr/actor/profile.ts
··· 4 4 * SPDX-License-Identifier: AGPL-3.0-only 5 5 */ 6 6 7 + import type {} from "@atcute/lexicons"; 7 8 import * as v from "@atcute/lexicons/validations"; 9 + import type {} from "@atcute/lexicons/ambient"; 8 10 9 11 const _mainSchema = /*#__PURE__*/ v.record( 10 - /*#__PURE__*/ v.literal("self"), 11 - /*#__PURE__*/ v.object({ 12 - $type: /*#__PURE__*/ v.literal("social.clippr.actor.profile"), 13 - avatar: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.blob()), 14 - createdAt: /*#__PURE__*/ v.datetimeString(), 15 - description: /*#__PURE__*/ v.optional( 16 - /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 17 - /*#__PURE__*/ v.stringLength(0, 5000), 18 - /*#__PURE__*/ v.stringGraphemes(0, 500), 19 - ]), 20 - ), 21 - displayName: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 22 - /*#__PURE__*/ v.stringLength(0, 640), 23 - /*#__PURE__*/ v.stringGraphemes(0, 64), 24 - ]), 25 - }), 12 + /*#__PURE__*/ v.literal("self"), 13 + /*#__PURE__*/ v.object({ 14 + $type: /*#__PURE__*/ v.literal("social.clippr.actor.profile"), 15 + avatar: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.blob()), 16 + createdAt: /*#__PURE__*/ v.datetimeString(), 17 + description: /*#__PURE__*/ v.optional( 18 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 19 + /*#__PURE__*/ v.stringLength(0, 5000), 20 + /*#__PURE__*/ v.stringGraphemes(0, 500), 21 + ]), 22 + ), 23 + displayName: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 24 + /*#__PURE__*/ v.stringLength(10, 640), 25 + /*#__PURE__*/ v.stringGraphemes(1, 64), 26 + ]), 27 + }), 26 28 ); 27 29 28 30 type main$schematype = typeof _mainSchema; 29 31 30 - export interface mainSchema extends main$schematype { 31 - } 32 + export interface mainSchema extends main$schematype {} 32 33 33 34 export const mainSchema = _mainSchema as mainSchema; 34 35 35 - export interface Main extends v.InferInput<typeof mainSchema> { 36 - } 36 + export interface Main extends v.InferInput<typeof mainSchema> {} 37 37 38 38 declare module "@atcute/lexicons/ambient" { 39 - interface Records { 40 - "social.clippr.actor.profile": mainSchema; 41 - } 39 + interface Records { 40 + "social.clippr.actor.profile": mainSchema; 41 + } 42 42 }
+43 -43
lexicons/lib/lexicons/types/social/clippr/feed/clip.ts
··· 4 4 * SPDX-License-Identifier: AGPL-3.0-only 5 5 */ 6 6 7 + import type {} from "@atcute/lexicons"; 7 8 import * as v from "@atcute/lexicons/validations"; 9 + import type {} from "@atcute/lexicons/ambient"; 8 10 import * as ComAtprotoRepoStrongRef from "@atcute/atproto/types/repo/strongRef"; 9 11 10 12 const _mainSchema = /*#__PURE__*/ v.record( 11 - /*#__PURE__*/ v.string(), 12 - /*#__PURE__*/ v.object({ 13 - $type: /*#__PURE__*/ v.literal("social.clippr.feed.clip"), 14 - createdAt: /*#__PURE__*/ v.datetimeString(), 15 - description: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 16 - /*#__PURE__*/ v.stringLength(0, 40960), 17 - /*#__PURE__*/ v.stringGraphemes(0, 4096), 18 - ]), 19 - languages: /*#__PURE__*/ v.optional( 20 - /*#__PURE__*/ v.constrain( 21 - /*#__PURE__*/ v.array(/*#__PURE__*/ v.languageCodeString()), 22 - [/*#__PURE__*/ v.arrayLength(0, 5)], 23 - ), 24 - ), 25 - notes: /*#__PURE__*/ v.optional( 26 - /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 27 - /*#__PURE__*/ v.stringLength(0, 100000), 28 - /*#__PURE__*/ v.stringGraphemes(0, 10000), 29 - ]), 30 - ), 31 - get tags() { 32 - return /*#__PURE__*/ v.optional( 33 - /*#__PURE__*/ v.array(ComAtprotoRepoStrongRef.mainSchema), 34 - ); 35 - }, 36 - title: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 37 - /*#__PURE__*/ v.stringLength(0, 20480), 38 - /*#__PURE__*/ v.stringGraphemes(0, 2048), 39 - ]), 40 - unlisted: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), false), 41 - unread: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), true), 42 - url: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 43 - /*#__PURE__*/ v.stringLength(0, 20000), 44 - /*#__PURE__*/ v.stringGraphemes(0, 2000), 45 - ]), 46 - }), 13 + /*#__PURE__*/ v.string(), 14 + /*#__PURE__*/ v.object({ 15 + $type: /*#__PURE__*/ v.literal("social.clippr.feed.clip"), 16 + createdAt: /*#__PURE__*/ v.datetimeString(), 17 + description: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 18 + /*#__PURE__*/ v.stringLength(10, 40960), 19 + /*#__PURE__*/ v.stringGraphemes(1, 4096), 20 + ]), 21 + languages: /*#__PURE__*/ v.optional( 22 + /*#__PURE__*/ v.constrain( 23 + /*#__PURE__*/ v.array(/*#__PURE__*/ v.languageCodeString()), 24 + [/*#__PURE__*/ v.arrayLength(0, 5)], 25 + ), 26 + ), 27 + notes: /*#__PURE__*/ v.optional( 28 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 29 + /*#__PURE__*/ v.stringLength(10, 100000), 30 + /*#__PURE__*/ v.stringGraphemes(1, 10000), 31 + ]), 32 + ), 33 + get tags() { 34 + return /*#__PURE__*/ v.optional( 35 + /*#__PURE__*/ v.array(ComAtprotoRepoStrongRef.mainSchema), 36 + ); 37 + }, 38 + title: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 39 + /*#__PURE__*/ v.stringLength(10, 20480), 40 + /*#__PURE__*/ v.stringGraphemes(1, 2048), 41 + ]), 42 + unlisted: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), false), 43 + unread: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), true), 44 + url: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.genericUriString(), [ 45 + /*#__PURE__*/ v.stringLength(30, 20000), 46 + /*#__PURE__*/ v.stringGraphemes(3, 2000), 47 + ]), 48 + }), 47 49 ); 48 50 49 51 type main$schematype = typeof _mainSchema; 50 52 51 - export interface mainSchema extends main$schematype { 52 - } 53 + export interface mainSchema extends main$schematype {} 53 54 54 55 export const mainSchema = _mainSchema as mainSchema; 55 56 56 - export interface Main extends v.InferInput<typeof mainSchema> { 57 - } 57 + export interface Main extends v.InferInput<typeof mainSchema> {} 58 58 59 59 declare module "@atcute/lexicons/ambient" { 60 - interface Records { 61 - "social.clippr.feed.clip": mainSchema; 62 - } 60 + interface Records { 61 + "social.clippr.feed.clip": mainSchema; 62 + } 63 63 }
+22 -22
lexicons/lib/lexicons/types/social/clippr/feed/tag.ts
··· 4 4 * SPDX-License-Identifier: AGPL-3.0-only 5 5 */ 6 6 7 + import type {} from "@atcute/lexicons"; 7 8 import * as v from "@atcute/lexicons/validations"; 9 + import type {} from "@atcute/lexicons/ambient"; 8 10 9 11 const _mainSchema = /*#__PURE__*/ v.record( 10 - /*#__PURE__*/ v.string(), 11 - /*#__PURE__*/ v.object({ 12 - $type: /*#__PURE__*/ v.literal("social.clippr.feed.tag"), 13 - color: /*#__PURE__*/ v.optional( 14 - /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 15 - /*#__PURE__*/ v.stringLength(0, 70), 16 - /*#__PURE__*/ v.stringGraphemes(0, 7), 17 - ]), 18 - ), 19 - createdAt: /*#__PURE__*/ v.datetimeString(), 20 - name: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 21 - /*#__PURE__*/ v.stringLength(0, 640), 22 - /*#__PURE__*/ v.stringGraphemes(0, 64), 23 - ]), 24 - }), 12 + /*#__PURE__*/ v.string(), 13 + /*#__PURE__*/ v.object({ 14 + $type: /*#__PURE__*/ v.literal("social.clippr.feed.tag"), 15 + color: /*#__PURE__*/ v.optional( 16 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 17 + /*#__PURE__*/ v.stringLength(40, 70), 18 + /*#__PURE__*/ v.stringGraphemes(4, 7), 19 + ]), 20 + ), 21 + createdAt: /*#__PURE__*/ v.datetimeString(), 22 + name: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 23 + /*#__PURE__*/ v.stringLength(10, 640), 24 + /*#__PURE__*/ v.stringGraphemes(1, 64), 25 + ]), 26 + }), 25 27 ); 26 28 27 29 type main$schematype = typeof _mainSchema; 28 30 29 - export interface mainSchema extends main$schematype { 30 - } 31 + export interface mainSchema extends main$schematype {} 31 32 32 33 export const mainSchema = _mainSchema as mainSchema; 33 34 34 - export interface Main extends v.InferInput<typeof mainSchema> { 35 - } 35 + export interface Main extends v.InferInput<typeof mainSchema> {} 36 36 37 37 declare module "@atcute/lexicons/ambient" { 38 - interface Records { 39 - "social.clippr.feed.tag": mainSchema; 40 - } 38 + interface Records { 39 + "social.clippr.feed.tag": mainSchema; 40 + } 41 41 }
+1 -1
lexicons/package.json
··· 1 1 { 2 2 "type": "module", 3 3 "name": "@clipprjs/lexicons", 4 - "version": "0.1.3", 4 + "version": "0.1.4", 5 5 "description": "Clippr schema definitions", 6 6 "license": "AGPL-3.0-only", 7 7 "private": false,