refactor: zones => topics
This commit is contained in:
parent
20a5d1bc88
commit
fac8f409f4
26 changed files with 470 additions and 469 deletions
|
|
@ -1,87 +0,0 @@
|
|||
import { by_character, by_lurid } from '@andyburke/fsdb/organizers';
|
||||
import { FSDB_COLLECTION } from '@andyburke/fsdb';
|
||||
import { FSDB_INDEXER_SYMLINKS } from '@andyburke/fsdb/indexers';
|
||||
|
||||
/**
|
||||
* @typedef {object} ZONE_PERMISSIONS
|
||||
* @property {string[]} read a list of user_ids with read permission for the zone
|
||||
* @property {string[]} write a list of user_ids with write permission for the zone
|
||||
* @property {string[]} read_events a list of user_ids with read_events permission for this zone
|
||||
* @property {string[]} write_events a list of user_ids with write_events permission for this zone
|
||||
*/
|
||||
|
||||
/**
|
||||
* ZONE
|
||||
*
|
||||
* @property {string} id - lurid (stable)
|
||||
* @property {string} name - channel name (max 64 characters, unique, unstable)
|
||||
* @property {string} creator_id - user id of the zone creator
|
||||
* @property {ZONE_PERMISSIONS} permissions - permissions setup for the zone
|
||||
* @property {string} [icon_url] - optional url for zone icon
|
||||
* @property {string} [topic] - optional topic for the zone
|
||||
* @property {string} [rules] - optional zone rules (Markdown/text)
|
||||
* @property {string[]} [tags] - optional tags for the zone
|
||||
* @property {Record<string,any>} [meta] - optional metadata about the zone
|
||||
* @property {Record<string,string>} [emojis] - optional emojis table, eg: { 'rofl': 🤣, 'blap': 'https://somewhere.someplace/image.jpg' }
|
||||
*/
|
||||
|
||||
export type ZONE = {
|
||||
id: string;
|
||||
name: string;
|
||||
creator_id: string;
|
||||
permissions: {
|
||||
read: string[];
|
||||
write: string[];
|
||||
read_events: string[];
|
||||
write_events: string[];
|
||||
};
|
||||
icon_url?: string;
|
||||
topic?: string;
|
||||
rules?: string;
|
||||
tags?: string[];
|
||||
meta?: Record<string, any>;
|
||||
emojis?: Record<string, string>; // either: string: emoji eg: { 'rofl: 🤣, ... } or { 'rofl': 🤣, 'blap': 'https://somewhere.someplace/image.jpg' }
|
||||
timestamps: {
|
||||
created: string;
|
||||
updated: string;
|
||||
archived: string | undefined;
|
||||
};
|
||||
};
|
||||
|
||||
export const ZONES = new FSDB_COLLECTION<ZONE>({
|
||||
name: 'zones',
|
||||
id_field: 'id',
|
||||
organize: by_lurid,
|
||||
indexers: {
|
||||
creator_id: new FSDB_INDEXER_SYMLINKS<ZONE>({
|
||||
name: 'creator_id',
|
||||
field: 'creator_id',
|
||||
to_many: true,
|
||||
organize: by_lurid
|
||||
}),
|
||||
|
||||
name: new FSDB_INDEXER_SYMLINKS<ZONE>({
|
||||
name: 'name',
|
||||
get_values_to_index: (zone) => [zone.name.toLowerCase()],
|
||||
organize: by_character
|
||||
}),
|
||||
|
||||
tags: new FSDB_INDEXER_SYMLINKS<ZONE>({
|
||||
name: 'tags',
|
||||
get_values_to_index: (zone): string[] => {
|
||||
return (zone.tags ?? []).map((tag) => tag.toLowerCase());
|
||||
},
|
||||
to_many: true,
|
||||
organize: by_character
|
||||
}),
|
||||
|
||||
topic: new FSDB_INDEXER_SYMLINKS<ZONE>({
|
||||
name: 'topic',
|
||||
get_values_to_index: (zone): string[] => {
|
||||
return (zone.topic ?? '').split(/\W/);
|
||||
},
|
||||
to_many: true,
|
||||
organize: by_character
|
||||
})
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue