-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some schema for common nips, global tags, etc
- Loading branch information
Showing
35 changed files
with
316 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import esbuild from 'esbuild'; | ||
import { polyfillNode } from 'esbuild-plugin-polyfill-node'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { promises as fsp } from 'fs'; | ||
|
||
const isWatchMode = process.argv.includes('--watch'); | ||
|
||
const plugins = []; | ||
|
||
const browserConfig = { | ||
entryPoints: ['src/index.ts'], | ||
bundle: true, | ||
outdir: 'dist/web', | ||
platform: 'browser', | ||
format: 'esm', | ||
allowOverwrite: true, | ||
external: ['src/nips/*/index.js', 'ajv'], | ||
plugins: [ | ||
polyfillNode({ | ||
globals: { process: true, Buffer: true, global: true }, | ||
}), | ||
], | ||
}; | ||
|
||
const serverConfig = { | ||
entryPoints: ['src/index.ts'], | ||
bundle: true, | ||
outdir: 'dist/server', | ||
platform: 'node', | ||
format: 'esm', | ||
allowOverwrite: true, | ||
plugins: [ | ||
...plugins, | ||
], | ||
}; | ||
|
||
async function cleanDist() { | ||
const distWebPath = path.resolve('./dist/web'); | ||
const distServerPath = path.resolve('./dist/server'); | ||
try { | ||
if (fs.existsSync(distWebPath)) { | ||
console.log('Clearing dist/web directory...'); | ||
await fsp.rm(distWebPath, { recursive: true, force: true }); | ||
console.log('dist/web directory cleared.'); | ||
} | ||
if (fs.existsSync(distServerPath)) { | ||
console.log('Clearing dist/server directory...'); | ||
await fsp.rm(distServerPath, { recursive: true, force: true }); | ||
console.log('dist/server directory cleared.'); | ||
} | ||
} catch (error) { | ||
console.error('Error clearing dist directories:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
async function build() { | ||
try { | ||
await cleanDist(); | ||
|
||
if (isWatchMode) { | ||
const browserContext = await esbuild.context(browserConfig); | ||
const serverContext = await esbuild.context(serverConfig); | ||
|
||
await Promise.all([ | ||
browserContext.watch(), | ||
serverContext.watch(), | ||
]); | ||
|
||
console.log("Watching for changes in src..."); | ||
watchSrcDirectory(); | ||
} else { | ||
await esbuild.build(browserConfig); | ||
console.log("Browser build completed."); | ||
|
||
await esbuild.build(serverConfig); | ||
console.log("Server build completed."); | ||
|
||
console.log("Build complete for both web and server targets."); | ||
} | ||
} catch (error) { | ||
console.error("Build failed:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
|
||
function watchSrcDirectory() { | ||
fs.watch('./src', { recursive: true }, (eventType, filename) => { | ||
if (filename && (filename.endsWith('.ts') || filename.endsWith('.json'))) { | ||
build().then(() => dereferenceSchemas()); | ||
} | ||
}); | ||
} | ||
|
||
build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
declare module "ajv-errors" { | ||
const addErrors: (ajvInstance: any, options?: any) => void; | ||
export default addErrors; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
allOf: | ||
- $ref: "nips/nip-22/tag/_K/schema.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
allOf: | ||
- $ref: "nips/nip-18/tag/k/schema.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
allOf: | ||
- $ref: "nips/nip-65/tag/r/schema.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
$id: "https://schemata.nostr.watch/note/kind/0/content" | ||
$schema: "https://json-schema.org/draft/2020-12/schema" | ||
title: "Metadata Event Schema" | ||
type: "object" | ||
properties: | ||
name: | ||
type: "string" | ||
minLength: 1 | ||
about: | ||
type: "string" | ||
picture: | ||
type: "string" | ||
format: "uri" | ||
display_name: | ||
type: "string" | ||
description: "An alternative, richer name. 'name' must always be set." | ||
website: | ||
type: "string" | ||
format: "uri" | ||
description: "A web URL related to the event author." | ||
banner: | ||
type: "string" | ||
format: "uri" | ||
description: "A URL to a wide picture for background display." | ||
bot: | ||
type: "boolean" | ||
description: "Indicates if content is automated." | ||
lud16: | ||
type: "string" | ||
format: "email" | ||
lud06: | ||
type: "string" | ||
|
||
# deprecations | ||
displayName: | ||
deprecated: true | ||
description: "Use 'display_name' instead." | ||
errorMessage: { | ||
deprecated: "Use 'display_name' instead." | ||
} | ||
username: | ||
deprecated: true | ||
description: "Use 'name' instead." | ||
errorMessage: { | ||
deprecated: "Use 'display_name' instead." | ||
} | ||
|
||
required: | ||
- "name" | ||
additionalProperties: true |
4 changes: 2 additions & 2 deletions
4
...s/schemata/nips/nip-01/kind-3/schema.yaml → ...s/schemata/nips/nip-01/kind-0/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
$id: 'https://schemata.nostr.watch/note/kind/3' | ||
$id: "https://schemata.nostr.watch/note/kind/0" | ||
$schema: http://json-schema.org/draft-07/schema# | ||
title: kind3 | ||
title: kind0 | ||
allOf: | ||
- $ref: "@/note.yaml" |
6 changes: 4 additions & 2 deletions
6
libraries/schemata/nips/nip-01/messages/client-close/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
$id: 'https://schemata.nostr.watch/message/client-close' | ||
$id: 'https://schemata.nostr.watch/message/client/close' | ||
type: "array" | ||
items: | ||
- const: "CLOSE" | ||
- type: "string" | ||
description: "an id of the subscription to close" | ||
errorMessage: "subscription id must be a string and should be unique." | ||
errorMessage: { | ||
type: "subscription id must be a string and should be unique." | ||
} | ||
minItems: 2 | ||
maxItems: 2 |
4 changes: 2 additions & 2 deletions
4
libraries/schemata/nips/nip-01/messages/client-event/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libraries/schemata/nips/nip-01/messages/relay-closed/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libraries/schemata/nips/nip-01/messages/relay-event/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libraries/schemata/nips/nip-01/messages/relay-notice/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$id: "https://schemata.nostr.watch/note" | ||
$schema: http://json-schema.org/draft-07/schema | ||
type: object | ||
properties: | ||
content: | ||
type: string | ||
errorMessage: "content must be a string" | ||
description: "The content of the note" | ||
created_at: | ||
type: integer | ||
errorMessage: "created_at must be a timestamp expressed in seconds (not milliseconds)" | ||
description: "The timestamp of the note creation" | ||
kind: | ||
type: integer | ||
pubkey: | ||
allOf: | ||
- $ref: "@/secp256k1.yaml" | ||
errorMessage: "pubkey must be a secp256k1 public key" | ||
description: "The public key of the note's author" | ||
tags: | ||
type: array | ||
errorMessage: "tags must be an array of strings" | ||
description: "The tags of the note" | ||
items: | ||
- $ref: "@/tag.yaml" | ||
|
||
required: | ||
- content | ||
- created_at | ||
- kind | ||
- tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$id: 'https://schemata.nostr.watch/note/kind/3' | ||
$schema: http://json-schema.org/draft-07/schema# | ||
title: kind3 | ||
allOf: | ||
- $ref: "@/note.yaml" | ||
- type: object | ||
properties: | ||
tags: | ||
type: array | ||
items: | ||
$ref: "@/tag/p.yaml" | ||
additionalItems: false | ||
minItems: 1 | ||
errorMessage: | ||
type: "tags must be an array of p tags and only p tags" | ||
minItems: "tags array must have at least one p tag" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$id: 'https://schemata.nostr.watch/note/tag/k' | ||
$schema: "http://json-schema.org/draft-07/schema#" | ||
allOf: | ||
- $ref: "@/tag.yaml" | ||
- type: array | ||
minItems: 2 | ||
items: | ||
- const: "k" | ||
- type: string | ||
pattern: '^\d+$' | ||
additionalItems: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$id: "https://schemata.nostr.watch/note/kind/1111" | ||
$schema: http://json-schema.org/draft-07/schema# | ||
title: kind1111 | ||
allOf: | ||
- $ref: "@/note.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/note/tag/A' | ||
$schema: "http://json-schema.org/draft-07/schema#" | ||
allOf: | ||
- $ref: "@/tag/a.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/note/tag/E' | ||
$schema: "http://json-schema.org/draft-07/schema#" | ||
allOf: | ||
- $ref: "@/tag/e.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/note/tag/K' | ||
$schema: "http://json-schema.org/draft-07/schema#" | ||
allOf: | ||
- $ref: "@/tag/k.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/note/tag/P' | ||
$schema: "http://json-schema.org/draft-07/schema#" | ||
allOf: | ||
- $ref: "@/tag/p.yaml" |
1 change: 1 addition & 0 deletions
1
libraries/schemata/nips/nip-40/messages/client-auth/schema.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/message/client/auth' | ||
type: "array" | ||
items: | ||
- const: "AUTH" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
$id: 'https://schemata.nostr.watch/message/relay/auth' | ||
type: "array" | ||
items: | ||
- const: "AUTH" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$id: 'https://schemata.nostr.watch/note/kind/3' | ||
$schema: http://json-schema.org/draft-07/schema# | ||
title: kind10002 | ||
allOf: | ||
- $ref: "@/note.yaml" | ||
- type: object | ||
properties: | ||
tags: | ||
type: array | ||
items: | ||
$ref: "@/tag/r.yaml" | ||
additionalItems: false | ||
minItems: 1 | ||
errorMessage: | ||
type: "tags must be an array of r tags" | ||
minItems: "tags array must have at least one r tag" | ||
required: | ||
- tags |
Oops, something went wrong.