@chainfuse/types 0.0.1-beta.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 +11 -0
- package/dist/d1/dataspaces/index.d.ts +15 -0
- package/dist/d1/index.d.ts +10 -0
- package/dist/d1/users/index.d.ts +1 -0
- package/dist/discourse/index.d.ts +2 -0
- package/dist/discourse/post/index.d.ts +66 -0
- package/dist/discourse/topic/index.d.ts +120 -0
- package/dist/index.d.ts +38 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* It is used to carry over the types when using the `Object.values()` method.
|
|
3
|
+
*/
|
|
4
|
+
export type ObjectValues<T> = {
|
|
5
|
+
[K in keyof T]: T[K];
|
|
6
|
+
} extends Record<string, infer U> ? U[] : never;
|
|
7
|
+
export type ExtractKeysWithPrefix<T, Prefix extends string> = {
|
|
8
|
+
[K in keyof T]: K extends `${Prefix}${string}` ? K : never;
|
|
9
|
+
}[keyof T];
|
|
10
|
+
export type FilterKeysWithPrefix<T, Prefix extends string> = {
|
|
11
|
+
[K in keyof T as K extends `${Prefix}${string}` ? K : never]: T[K];
|
|
12
|
+
};
|
|
13
|
+
export type FilterKeysWithPrefixAndPrepend<T, Prefix extends string, Prepend extends string> = {
|
|
14
|
+
[K in keyof T as K extends `${Prefix}${string}` ? `${Prepend}${K}` : never]: T[K];
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Buffer } from 'node:buffer';
|
|
2
|
+
export * from './dataspaces/index.js';
|
|
3
|
+
export * from './users/index.js';
|
|
4
|
+
export type PrefixedUuid = `${'t_' | 'd_' | 'u_'}${UuidExport['utf8']}${'' | '_p'}`;
|
|
5
|
+
export interface UuidExport {
|
|
6
|
+
utf8: ReturnType<typeof crypto.randomUUID>;
|
|
7
|
+
hex: string;
|
|
8
|
+
blob: (typeof Uint8Array)['prototype']['buffer'] | Buffer['buffer'];
|
|
9
|
+
}
|
|
10
|
+
export type ISODateString = `${number}-${number}-${number}T${number}:${number}:${number}.${number}Z`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EmailAddress = `${string}@${string}.${string}`;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare enum PostEvents {
|
|
2
|
+
created = "post_created",
|
|
3
|
+
edited = "post_edited",
|
|
4
|
+
destroyed = "post_destroyed",
|
|
5
|
+
recovered = "post_recovered"
|
|
6
|
+
}
|
|
7
|
+
export interface TopicPost extends Record<string, any> {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
username: string;
|
|
11
|
+
avatar_template: string;
|
|
12
|
+
created_at: ReturnType<Date['toISOString']>;
|
|
13
|
+
cooked: string;
|
|
14
|
+
post_number: number;
|
|
15
|
+
post_type: number;
|
|
16
|
+
updated_at: ReturnType<Date['toISOString']>;
|
|
17
|
+
reply_count: number;
|
|
18
|
+
reply_to_post_number: string | null;
|
|
19
|
+
quote_count: number;
|
|
20
|
+
incoming_link_count: number;
|
|
21
|
+
reads: number;
|
|
22
|
+
readers_count: number;
|
|
23
|
+
score: number;
|
|
24
|
+
yours: boolean;
|
|
25
|
+
topic_id: number;
|
|
26
|
+
topic_slug: string;
|
|
27
|
+
display_username: string;
|
|
28
|
+
flair_name: string | null;
|
|
29
|
+
flair_url: string | null;
|
|
30
|
+
flair_bg_color: string | null;
|
|
31
|
+
flair_color: string | null;
|
|
32
|
+
version: number;
|
|
33
|
+
can_edit: boolean;
|
|
34
|
+
can_delete: boolean;
|
|
35
|
+
can_recover: boolean;
|
|
36
|
+
can_see_hidden_post?: boolean;
|
|
37
|
+
can_wiki: boolean;
|
|
38
|
+
link_counts: {
|
|
39
|
+
url: string;
|
|
40
|
+
internal: boolean;
|
|
41
|
+
reflection: boolean;
|
|
42
|
+
title: string;
|
|
43
|
+
clicks: number;
|
|
44
|
+
}[];
|
|
45
|
+
read: boolean;
|
|
46
|
+
user_title: string | null;
|
|
47
|
+
bookmarked: boolean;
|
|
48
|
+
actions_summary: {
|
|
49
|
+
id: number;
|
|
50
|
+
can_act: boolean;
|
|
51
|
+
}[];
|
|
52
|
+
moderator: boolean;
|
|
53
|
+
admin: boolean;
|
|
54
|
+
staff: boolean;
|
|
55
|
+
user_id: number;
|
|
56
|
+
hidden: boolean;
|
|
57
|
+
trust_level: number;
|
|
58
|
+
deleted_at: ReturnType<Date['toISOString']>;
|
|
59
|
+
user_deleted: boolean;
|
|
60
|
+
edit_reason: string | null;
|
|
61
|
+
can_view_edit_history: number;
|
|
62
|
+
wiki: boolean;
|
|
63
|
+
reviewable_id: number;
|
|
64
|
+
reviewable_score_count: number;
|
|
65
|
+
reviewable_score_pending_count: number;
|
|
66
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { TopicPost } from '../post/index.js';
|
|
2
|
+
export declare enum TopicEvents {
|
|
3
|
+
created = "topic_created",
|
|
4
|
+
revised = "topic_revised",
|
|
5
|
+
edited = "topic_edited",
|
|
6
|
+
destroyed = "topic_destroyed",
|
|
7
|
+
recovered = "topic_recovered"
|
|
8
|
+
}
|
|
9
|
+
export interface TopicCollections extends Record<string, any> {
|
|
10
|
+
topic_list: TopicList;
|
|
11
|
+
}
|
|
12
|
+
interface TopicList extends Record<string, any> {
|
|
13
|
+
topics: Topic[];
|
|
14
|
+
}
|
|
15
|
+
export interface TopicUser {
|
|
16
|
+
id: number;
|
|
17
|
+
username: string;
|
|
18
|
+
name: string;
|
|
19
|
+
avatar_template: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Topic extends Record<string, any> {
|
|
22
|
+
post_stream: {
|
|
23
|
+
posts: TopicPost[];
|
|
24
|
+
stream: any[];
|
|
25
|
+
};
|
|
26
|
+
suggested_topics: Record<string, any>[];
|
|
27
|
+
timeline_lookup: any[];
|
|
28
|
+
tags_descriptions: Record<string, any>;
|
|
29
|
+
id: number;
|
|
30
|
+
title: string;
|
|
31
|
+
fancy_title: string;
|
|
32
|
+
posts_count: number;
|
|
33
|
+
created_at: ReturnType<Date['toISOString']>;
|
|
34
|
+
views: number;
|
|
35
|
+
reply_count: number;
|
|
36
|
+
like_count: number;
|
|
37
|
+
last_posted_at: ReturnType<Date['toISOString']>;
|
|
38
|
+
visible: boolean;
|
|
39
|
+
closed: boolean;
|
|
40
|
+
archived: boolean;
|
|
41
|
+
has_summary: boolean;
|
|
42
|
+
archetype: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
category_id: number;
|
|
45
|
+
word_count: number | null;
|
|
46
|
+
deleted_at: ReturnType<Date['toISOString']> | null;
|
|
47
|
+
user_id: number;
|
|
48
|
+
featured_link: string | null;
|
|
49
|
+
pinned_globally: boolean;
|
|
50
|
+
pinned_at: ReturnType<Date['toISOString']> | null;
|
|
51
|
+
pinned_until: ReturnType<Date['toISOString']> | null;
|
|
52
|
+
image_url: string | null;
|
|
53
|
+
slow_mode_seconds: number;
|
|
54
|
+
draft: string | null;
|
|
55
|
+
draft_key: string;
|
|
56
|
+
draft_sequence: number;
|
|
57
|
+
unpinned: string | null;
|
|
58
|
+
pinned: boolean;
|
|
59
|
+
current_post_number: number;
|
|
60
|
+
highest_post_number: number | null;
|
|
61
|
+
deleted_by: ReturnType<Date['toISOString']> | null;
|
|
62
|
+
has_deleted: number;
|
|
63
|
+
actions_summary: {
|
|
64
|
+
id: number;
|
|
65
|
+
count: number;
|
|
66
|
+
hidden: boolean;
|
|
67
|
+
can_act: boolean;
|
|
68
|
+
}[];
|
|
69
|
+
chunk_size: number;
|
|
70
|
+
bookmarked: boolean;
|
|
71
|
+
bookmarks: any[];
|
|
72
|
+
topic_timer: string | null;
|
|
73
|
+
message_bus_last_id: number;
|
|
74
|
+
participant_count: number;
|
|
75
|
+
show_read_indicator: boolean;
|
|
76
|
+
thumbnails: string | null;
|
|
77
|
+
slow_mode_enabled_until: string | null;
|
|
78
|
+
summarizable: boolean;
|
|
79
|
+
details: {
|
|
80
|
+
can_edit: boolean;
|
|
81
|
+
notification_level: number;
|
|
82
|
+
can_move_posts: boolean;
|
|
83
|
+
can_delete: boolean;
|
|
84
|
+
can_remove_allowed_users: boolean;
|
|
85
|
+
can_create_post: boolean;
|
|
86
|
+
can_reply_as_new_topic: boolean;
|
|
87
|
+
can_invite_to?: boolean;
|
|
88
|
+
can_invite_via_email?: boolean;
|
|
89
|
+
can_flag_topic?: boolean;
|
|
90
|
+
can_convert_topic: boolean;
|
|
91
|
+
can_review_topic: boolean;
|
|
92
|
+
can_close_topic: boolean;
|
|
93
|
+
can_archive_topic: boolean;
|
|
94
|
+
can_split_merge_topic: boolean;
|
|
95
|
+
can_edit_staff_notes: boolean;
|
|
96
|
+
can_toggle_topic_visibility: boolean;
|
|
97
|
+
can_pin_unpin_topic: boolean;
|
|
98
|
+
can_moderate_category: boolean;
|
|
99
|
+
can_remove_self_id: boolean;
|
|
100
|
+
participants?: {
|
|
101
|
+
id: number;
|
|
102
|
+
username: string;
|
|
103
|
+
name: string;
|
|
104
|
+
avatar_template: string;
|
|
105
|
+
post_count: number;
|
|
106
|
+
primary_group_name: string | null;
|
|
107
|
+
flair_name: string | null;
|
|
108
|
+
flair_url: string | null;
|
|
109
|
+
flair_color: string | null;
|
|
110
|
+
flair_bg_color: string | null;
|
|
111
|
+
flair_group_id: string | null;
|
|
112
|
+
admin: boolean;
|
|
113
|
+
moderator: boolean;
|
|
114
|
+
trust_level: number;
|
|
115
|
+
}[];
|
|
116
|
+
created_by: TopicUser;
|
|
117
|
+
last_poster: TopicUser;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from './d1/index.js';
|
|
2
|
+
export * from './discourse/index.js';
|
|
3
|
+
type MethodKeys<T> = {
|
|
4
|
+
[P in keyof T]: T[P] extends (...args: any[]) => any ? P : never;
|
|
5
|
+
}[keyof T];
|
|
6
|
+
export type JsonParsed<T> = Omit<T, MethodKeys<T>>;
|
|
7
|
+
/**
|
|
8
|
+
* This type is similar to the built-in `Partial<>` type, but it applies recursively to nested objects and arrays.
|
|
9
|
+
* If a property is an array, the elements of the array will also be recursively made optional.
|
|
10
|
+
* If a property is an object, the properties of the object will also be recursively made optional.
|
|
11
|
+
*/
|
|
12
|
+
export type RecursivePartial<T> = {
|
|
13
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Returns the union of keys from a given type.
|
|
17
|
+
*/
|
|
18
|
+
export type UnionKeys<T> = T extends any ? keyof T : never;
|
|
19
|
+
/**
|
|
20
|
+
* Defines a type that excludes specific keys from an object type.
|
|
21
|
+
*/
|
|
22
|
+
export type BlockKeys<T, K extends readonly string[]> = {
|
|
23
|
+
[P in keyof T as P extends K[number] ? never : P]: T[P];
|
|
24
|
+
};
|
|
25
|
+
export type PromiseFactory<T> = () => Promise<T>;
|
|
26
|
+
export interface ExternallyResolvablePromise<T> {
|
|
27
|
+
promise: Promise<T>;
|
|
28
|
+
resolve: (value: T) => void;
|
|
29
|
+
reject: (reason?: any) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Mark every property of an object as undefined.
|
|
33
|
+
*/
|
|
34
|
+
export type UndefinedProperties<T extends object> = {
|
|
35
|
+
[P in keyof T]: undefined;
|
|
36
|
+
};
|
|
37
|
+
export type CustomLogCallback = (message: string) => void;
|
|
38
|
+
export type CustomLoging = boolean | CustomLogCallback;
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainfuse/types",
|
|
3
|
+
"version": "0.0.1-beta.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "ChainFuse",
|
|
6
|
+
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/types#readme",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "dist"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/ChainFuse/packages.git"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"fmt": "prettier --check .",
|
|
24
|
+
"fmt:fix": "prettier --write .",
|
|
25
|
+
"lint": "eslint .",
|
|
26
|
+
"lint:fix": "npm run lint -- --fix",
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"build:clean": "npm run build -- --build --clean && npm run build"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/ChainFuse/packages/issues"
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20.16.0"
|
|
37
|
+
},
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"import": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./d1": {
|
|
44
|
+
"import": "./dist/d1/index.js",
|
|
45
|
+
"types": "./dist/d1/index.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./d1/dataspaces": {
|
|
48
|
+
"import": "./dist/d1/dataspaces/index.js",
|
|
49
|
+
"types": "./dist/d1/dataspaces/index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./d1/users": {
|
|
52
|
+
"import": "./dist/d1/users/index.js",
|
|
53
|
+
"types": "./dist/d1/users/index.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./discourse": {
|
|
56
|
+
"import": "./dist/discourse/index.js",
|
|
57
|
+
"types": "./dist/discourse/index.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./discourse/post": {
|
|
60
|
+
"import": "./dist/discourse/post/index.js",
|
|
61
|
+
"types": "./dist/discourse/post/index.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./discourse/topic": {
|
|
64
|
+
"import": "./dist/discourse/topic/index.js",
|
|
65
|
+
"types": "./dist/discourse/topic/index.d.ts"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"prettier": "@demosjarco/prettier-config",
|
|
69
|
+
"dependencies": {},
|
|
70
|
+
"devDependencies": {},
|
|
71
|
+
"optionalDependencies": {}
|
|
72
|
+
}
|