@mana-app/types 0.0.18 → 0.0.19

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.
@@ -1,5 +1,5 @@
1
1
  import { Content, Chapter, ChapterData, SourceInfo, AdditionalInfoSectionItem } from "../../types";
2
- import { DirectoryHandler, ManaSource } from "../Source";
2
+ import { SearchProvider, ManaSource } from "../Source";
3
3
  export type SourceConfig = {
4
4
  /**
5
5
  * When `true`, Mana will disable being able to view more titles of a provided tags
@@ -30,7 +30,7 @@ interface SourceCore extends ManaSource {
30
30
  info: SourceInfo;
31
31
  config?: SourceConfig;
32
32
  }
33
- export interface ContentSource extends SourceCore, DirectoryHandler {
33
+ export interface ContentSource extends SourceCore, SearchProvider {
34
34
  /**
35
35
  * Gets the titles information from the source
36
36
  */
@@ -1,5 +1,5 @@
1
- import { DirectoryHandler } from "..";
2
- export interface AdvancedTracker extends DirectoryHandler {
1
+ import { SearchProvider } from "..";
2
+ export interface AdvancedTracker extends SearchProvider {
3
3
  /**
4
4
  * This is called to get the info required to prepare a "profile page" for the title
5
5
  */
@@ -0,0 +1,15 @@
1
+ import { SearchRequest, PagedSearchResult, SortOption, SearchFilter } from "../../../types";
2
+ export interface SearchProvider {
3
+ /**
4
+ * Fetches items/results for a directory request.
5
+ */
6
+ search(request: SearchRequest): Promise<PagedSearchResult>;
7
+ /**
8
+ * Fetches the available search filters for the source
9
+ */
10
+ getSearchFilters(): Promise<SearchFilter[]>;
11
+ /**
12
+ * Fetches the available sort options for the source
13
+ */
14
+ getSortOptions(): Promise<SortOption[]>;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,7 @@
1
1
  export * from "./Authentication";
2
2
  export * from "./Preferences";
3
3
  export * from "./ImageRequest";
4
- export * from "./DirectoryHandler";
4
+ export * from "./SearchProvider";
5
5
  export * from "./PageProvider";
6
6
  export * from "./Setup";
7
7
  export * from "./PageResolver";
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Authentication"), exports);
18
18
  __exportStar(require("./Preferences"), exports);
19
19
  __exportStar(require("./ImageRequest"), exports);
20
- __exportStar(require("./DirectoryHandler"), exports);
20
+ __exportStar(require("./SearchProvider"), exports);
21
21
  __exportStar(require("./PageProvider"), exports);
22
22
  __exportStar(require("./Setup"), exports);
23
23
  __exportStar(require("./PageResolver"), exports);
@@ -1,6 +1,6 @@
1
1
  export * from "./Authentication";
2
2
  export * from "./SourceInfo";
3
- export * from "./PagedResult";
3
+ export * from "../search/PagedSearchResult";
4
4
  export * from "./ContextProvider";
5
5
  export type Option = {
6
6
  id: string;
@@ -16,5 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Authentication"), exports);
18
18
  __exportStar(require("./SourceInfo"), exports);
19
- __exportStar(require("./PagedResult"), exports);
19
+ __exportStar(require("../search/PagedSearchResult"), exports);
20
20
  __exportStar(require("./ContextProvider"), exports);
@@ -3,7 +3,7 @@ export * from "./content";
3
3
  export * from "./networking";
4
4
  export * from "./UI";
5
5
  export * from "./tracker";
6
- export * from "./directory";
6
+ export * from "./search";
7
7
  export * from "./page";
8
8
  export type Only<T, U> = {
9
9
  [P in keyof T]: T[P];
@@ -20,7 +20,7 @@ __exportStar(require("./content"), exports);
20
20
  __exportStar(require("./networking"), exports);
21
21
  __exportStar(require("./UI"), exports);
22
22
  __exportStar(require("./tracker"), exports);
23
- __exportStar(require("./directory"), exports);
23
+ __exportStar(require("./search"), exports);
24
24
  __exportStar(require("./page"), exports);
25
25
  const Generate = (v) => v;
26
26
  exports.Generate = Generate;
@@ -1,5 +1,5 @@
1
1
  import { Badge, ContextProvider, Either, Highlight } from "..";
2
- import { DirectoryRequest } from "../directory";
2
+ import { SearchRequest } from "../search";
3
3
  /**
4
4
  * This object defines what page suwatte links to
5
5
  *
@@ -8,7 +8,7 @@ import { DirectoryRequest } from "../directory";
8
8
  export type Linkable = Either<{
9
9
  page: PageLink;
10
10
  }, {
11
- request: DirectoryRequest;
11
+ request: SearchRequest;
12
12
  }>;
13
13
  export type PageLink = ContextProvider & {
14
14
  id: "home" | string;
@@ -0,0 +1,17 @@
1
+ import { Highlight } from "../content";
2
+ export type PagedSearchResult = {
3
+ /**
4
+ * The results on this page
5
+ */
6
+ results: Highlight[];
7
+ /**
8
+ * Boolean Indicating whether this is the last available page.
9
+ *
10
+ * If this value is true or the results count is 0, Suwatte will stop making subsequent pagination requests
11
+ */
12
+ isLastPage: boolean;
13
+ /**
14
+ * The Total Results Count
15
+ */
16
+ totalResultCount?: number;
17
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,53 @@
1
+ import { Option } from "../core";
2
+ export declare enum FilterType {
3
+ /**
4
+ * This Represents the filter as a toggle switch, the value returned in the directory request will be a `boolean`
5
+ */
6
+ TOGGLE = 0,
7
+ /**
8
+ * This represents the filter as a picker, the value returned will be the `key` of the selected option as a `string`
9
+ */
10
+ SELECT = 1,
11
+ /**
12
+ * This Represents the filter as a multi-picker, the value returned will the the keys of the selected options as an array of strings
13
+ */
14
+ MULTISELECT = 2,
15
+ /**
16
+ * This Represents the filter as a multi-picker,the value returned will be of type {@link ExcludableMultiSelectProp}
17
+ */
18
+ EXCLUDABLE_MULTISELECT = 3,
19
+ /**
20
+ * This will represent the filter as a textfield, the value returned will be a string
21
+ */
22
+ TEXT = 4,
23
+ /**
24
+ * This is a basic filter that will only display the title or subtitle, it will not return any value in the populated `DirectoryRequest`
25
+ */
26
+ INFO = 5
27
+ }
28
+ export type SearchFilter = {
29
+ /**
30
+ * The ID of the filter
31
+ */
32
+ id: string;
33
+ /**
34
+ * The Title of the Filter
35
+ */
36
+ title: string;
37
+ /**
38
+ * The subtitle of the filter
39
+ */
40
+ subtitle?: string;
41
+ /**
42
+ * The Filter Type
43
+ */
44
+ type: FilterType;
45
+ /**
46
+ * The Filter's Options if the filter type is SELECT,MULTISELECT,EXCLUDABLE_SELECT
47
+ */
48
+ options?: Option[];
49
+ };
50
+ export type ExcludableMultiSelectProp = {
51
+ included: string[];
52
+ excluded: string[];
53
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterType = void 0;
4
+ var FilterType;
5
+ (function (FilterType) {
6
+ /**
7
+ * This Represents the filter as a toggle switch, the value returned in the directory request will be a `boolean`
8
+ */
9
+ FilterType[FilterType["TOGGLE"] = 0] = "TOGGLE";
10
+ /**
11
+ * This represents the filter as a picker, the value returned will be the `key` of the selected option as a `string`
12
+ */
13
+ FilterType[FilterType["SELECT"] = 1] = "SELECT";
14
+ /**
15
+ * This Represents the filter as a multi-picker, the value returned will the the keys of the selected options as an array of strings
16
+ */
17
+ FilterType[FilterType["MULTISELECT"] = 2] = "MULTISELECT";
18
+ /**
19
+ * This Represents the filter as a multi-picker,the value returned will be of type {@link ExcludableMultiSelectProp}
20
+ */
21
+ FilterType[FilterType["EXCLUDABLE_MULTISELECT"] = 3] = "EXCLUDABLE_MULTISELECT";
22
+ /**
23
+ * This will represent the filter as a textfield, the value returned will be a string
24
+ */
25
+ FilterType[FilterType["TEXT"] = 4] = "TEXT";
26
+ /**
27
+ * This is a basic filter that will only display the title or subtitle, it will not return any value in the populated `DirectoryRequest`
28
+ */
29
+ FilterType[FilterType["INFO"] = 5] = "INFO";
30
+ })(FilterType || (exports.FilterType = FilterType = {}));
@@ -0,0 +1,26 @@
1
+ import { ContextProvider } from "../core";
2
+ import { ExcludableMultiSelectProp } from "./SearchFilter";
3
+ export type FilterPrimitives = string | string[] | boolean | number | ExcludableMultiSelectProp;
4
+ export type SearchRequest<T extends Record<string, FilterPrimitives> = any> = ContextProvider & {
5
+ /**
6
+ * The Keywords the User would like to search
7
+ */
8
+ query?: string;
9
+ /**
10
+ * The Page Number of the current search
11
+ */
12
+ page: number;
13
+ listId?: string;
14
+ /**
15
+ * The User Selected Sort ID
16
+ */
17
+ sort?: SortSelection;
18
+ /**
19
+ * The populated filters with their mapped corresponding type
20
+ */
21
+ filters?: T;
22
+ };
23
+ export type SortSelection = {
24
+ id: string;
25
+ ascending?: boolean;
26
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { Option } from "../core";
2
+ export type SortOption = Option & {
3
+ /**
4
+ * If true, this option will be selected by default
5
+ */
6
+ isDefault?: boolean;
7
+ /**
8
+ * If true, the sort order can be toggled between ascending and descending
9
+ */
10
+ isOrderable?: boolean;
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from "./SearchRequest";
2
+ export * from "./SearchFilter";
3
+ export * from "./SortOption";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./SearchRequest"), exports);
18
+ __exportStar(require("./SearchFilter"), exports);
19
+ __exportStar(require("./SortOption"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mana-app/types",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {