-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
414 additions
and
51 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,24 @@ | ||
{ | ||
"name": "@hs/core", | ||
"version": "1.0.50", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "bun run --watch src/index.ts", | ||
"prepare": "ts-patch install && typia patch", | ||
"build": "tsc" | ||
}, | ||
"main": "./src/index.ts", | ||
"types": "./src/index.ts", | ||
"files": ["./src"], | ||
"dependencies": { | ||
"elysia": "latest", | ||
"typia": "^5.5.7" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "latest", | ||
"ts-node": "^10.9.2", | ||
"ts-patch": "^3.1.2", | ||
"typescript": "^5.4.2" | ||
}, | ||
"module": "src/index.js" | ||
} |
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,79 @@ | ||
export interface Endpoints {} | ||
|
||
export interface EndpointDefinition { | ||
auth: boolean; | ||
rateLimit: boolean; | ||
query: any; | ||
response: any; | ||
} | ||
|
||
export interface Endpoint { | ||
GET?: EndpointDefinition; | ||
POST?: EndpointDefinition; | ||
PUT?: EndpointDefinition; | ||
DELETE?: EndpointDefinition; | ||
} | ||
|
||
export type Method = | ||
| "GET" | ||
| "POST" | ||
| "DELETE" | ||
| "PUT" | ||
| "OPTIONS" | ||
| "HEAD" | ||
| "PATCH"; | ||
|
||
export type EndpointsPath = keyof Endpoints; | ||
|
||
// gets the endpoints for a given Method, if is never does not exist | ||
export type EndpointsByMethod = { | ||
[TMethod in Method]: { | ||
[TPathPattern in keyof Endpoints]: TMethod extends keyof Endpoints[TPathPattern] | ||
? Endpoints[TPathPattern][TMethod] extends infer TConfig | ||
? TConfig extends EndpointDefinition | ||
? TPathPattern | ||
: never | ||
: never | ||
: never; | ||
}[keyof Endpoints]; | ||
}; | ||
|
||
export type GetPropertyPath< | ||
TMethod extends Method, | ||
TPath extends EndpointsByMethod[TMethod], | ||
TProp extends keyof EndpointDefinition, | ||
> = TMethod extends keyof Endpoints[TPath] | ||
? TProp extends keyof Endpoints[TPath][TMethod] | ||
? Endpoints[TPath][TMethod][TProp] | ||
: never | ||
: never; | ||
|
||
export type ParametersByMethod< | ||
TMethod extends Method, | ||
TPath extends EndpointsByMethod[TMethod], | ||
> = GetPropertyPath<TMethod, TPath, "query">; | ||
|
||
export type ResponseByMethod< | ||
TMethod extends Method, | ||
TPath extends EndpointsByMethod[TMethod], | ||
> = GetPropertyPath<TMethod, TPath, "response">; | ||
|
||
export type FilterEndpointsByVersion<V extends "v1" | "v2" | "v3"> = | ||
EndpointsByMethod[keyof EndpointsByMethod] extends `/${infer U}/${string}` | ||
? U extends V | ||
? EndpointsByMethod[keyof EndpointsByMethod] | ||
: never | ||
: never; | ||
|
||
type UrlParams<T extends string> = string extends T | ||
? Record<string, string> | ||
: T extends `${string}:${infer Param}/${infer Rest}` | ||
? { [k in Param | keyof UrlParams<Rest>]: string } | ||
: T extends `${string}:${infer Param}` | ||
? { [k in Param]: string } | ||
: undefined | Record<string, never>; | ||
|
||
export type GetUrlParams< | ||
TMethod extends Method, | ||
TPath extends EndpointsByMethod[TMethod], | ||
> = UrlParams<TPath>; |
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...meserver/src/events/m.room.create.spec.ts → ...ges/core/src/events/m.room.create.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
...er/src/events/m.room.guest_access.spec.ts → ...re/src/events/m.room.guest_access.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
.../events/m.room.history_visibility.spec.ts → .../events/m.room.history_visibility.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
...rver/src/events/m.room.join_rules.spec.ts → ...core/src/events/m.room.join_rules.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
...r/src/events/m.room.member-invite.spec.ts → ...e/src/events/m.room.member-invite.spec.ts
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
6 changes: 3 additions & 3 deletions
6
...meserver/src/events/m.room.member.spec.ts → ...ges/core/src/events/m.room.member.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
...er/src/events/m.room.power_levels.spec.ts → ...re/src/events/m.room.power_levels.spec.ts
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.
6 changes: 3 additions & 3 deletions
6
...rc/events/utils/createSignedEvent.spec.ts → ...rc/events/utils/createSignedEvent.spec.ts
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
6 changes: 3 additions & 3 deletions
6
...ver/src/events/utils/createSignedEvent.ts → ...ore/src/events/utils/createSignedEvent.ts
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
Empty file.
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,57 @@ | ||
import typia, { tags } from "typia"; | ||
|
||
// https://spec.matrix.org/v1.10/server-server-api/#post_matrixkeyv2query | ||
|
||
interface Body { | ||
server_keys: Record< | ||
string, | ||
{ | ||
minimum_valid_until_ts: number; | ||
} | ||
>; | ||
} | ||
|
||
interface Response { | ||
server_keys: { | ||
old_verify_keys: Record< | ||
string, | ||
{ | ||
expired_ts: number; | ||
key: string; | ||
} | ||
>; | ||
server_name: string; | ||
signatures: Record<string, Record<string, string>>; | ||
valid_until_ts: number; | ||
verify_keys: Record< | ||
string, | ||
{ | ||
key: string; | ||
} | ||
>; | ||
}[]; | ||
} | ||
declare module "./endpoints" { | ||
interface Endpoints { | ||
"/v2/query": { | ||
POST: { | ||
description: "Query for keys from multiple servers in a batch format. The receiving (notary) server must sign the keys returned by the queried servers."; | ||
auth: false; | ||
rateLimit: false; | ||
body: Body; | ||
response: Response; | ||
}; | ||
}; | ||
"/v2/query/:serverName": { | ||
GET: { | ||
description: "Query for keys from a single server. The receiving (notary) server must sign the keys returned by the queried server."; | ||
auth: false; | ||
rateLimit: false; | ||
query: { | ||
minimum_valid_until_ts: number; | ||
}; | ||
response: Response; | ||
}; | ||
}; | ||
} | ||
} |
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,56 @@ | ||
import typia, { tags } from "typia"; | ||
|
||
// // https://spec.matrix.org/v1.9/server-server-api/#get_matrixkeyv2server | ||
|
||
interface Response { | ||
old_verify_keys: Record< | ||
string, | ||
{ | ||
expired_ts: number; | ||
key: string; | ||
} | ||
>; | ||
server_name: string; | ||
signatures: Record<string, Record<string, string>>; | ||
valid_until_ts: number; | ||
verify_keys: Record< | ||
string, | ||
{ | ||
key: string; | ||
} | ||
>; | ||
} | ||
|
||
type Query = object; | ||
|
||
declare module "./endpoints" { | ||
interface Endpoints { | ||
"/v2/server": { | ||
GET: { | ||
description: "Gets the homeserver’s published signing keys. The homeserver may have any number of active keys and may have a number of old keys."; | ||
auth: false; | ||
rateLimit: false; | ||
query: Query; | ||
response: Response; | ||
}; | ||
}; | ||
"/v2/server/": { | ||
GET: { | ||
description: "Gets the homeserver’s published signing keys. The homeserver may have any number of active keys and may have a number of old keys."; | ||
auth: false; | ||
rateLimit: false; | ||
query: Query; | ||
response: Response; | ||
}; | ||
}; | ||
"/v2/server/{keyID}": { | ||
GET: { | ||
description: "Gets the homeserver’s published signing keys. The homeserver may have any number of active keys and may have a number of old keys."; | ||
auth: false; | ||
rateLimit: false; | ||
query: Query; | ||
response: Response; | ||
}; | ||
}; | ||
} | ||
} |
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,29 @@ | ||
// https://spec.matrix.org/v1.10/server-server-api/#transactions | ||
|
||
interface PDU { | ||
pdu_type: string; | ||
content: unknown; | ||
} | ||
|
||
interface EDU { | ||
edu_type: string; | ||
content: unknown; | ||
} | ||
|
||
interface Body { | ||
edus?: EDU[]; | ||
pdus: PDU[]; | ||
|
||
room_id: string; | ||
origin: string; | ||
origin_server_ts: number; | ||
} | ||
|
||
interface Response { | ||
pdus: Record< | ||
`${string}:${string}`, | ||
{ | ||
error: string; | ||
} | ||
>; | ||
} |
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,23 @@ | ||
// https://spec.matrix.org/v1.9/server-server-api/#getwell-knownmatrixserver | ||
|
||
interface Response { | ||
server: { | ||
name: string; | ||
version: string; | ||
}; | ||
} | ||
|
||
type Query = object; | ||
|
||
declare module "./endpoints" { | ||
interface Endpoints { | ||
"/.well-known/matrix/server": { | ||
GET: { | ||
auth: false; | ||
rateLimit: false; | ||
query: Query; | ||
response: Response; | ||
}; | ||
}; | ||
} | ||
} |
Oops, something went wrong.