@use-stall/types 0.3.5 → 0.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@use-stall/types",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Type declarations for Stall SDKs",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
@@ -1,6 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { UnifiedOrderType } from "./orders";
3
- import { LookupGroupRouteType } from "./utils/lookup";
3
+ import {
4
+ LookupActionHelpersType,
5
+ LookupGroupRouteType,
6
+ LookupListFilterType,
7
+ } from "./lookup";
4
8
  import type { CoreConfig } from "./core-sdk";
5
9
 
6
10
  interface StallExtension {
@@ -26,22 +30,23 @@ interface ExtensionActionShortcut {
26
30
  }
27
31
 
28
32
  interface ExtensionLookupAction {
29
- native: boolean;
30
- name: string;
33
+ id: string;
31
34
  label: string;
32
- static_args: Record<string, any>;
33
- close_on_complete: boolean; // Close lookup
35
+ close_on_complete?: boolean; // Close lookup
34
36
  reopen_on_return?: boolean; // Reopen lookup on return from an external page
35
37
  always_show?: boolean; // Always show the action in the lookup even if no item is selected or highlighted
36
38
  shortcut?: ExtensionActionShortcut;
37
39
  paths?: string[]; // You can specify a list of paths where this action should be available, when left empty it will be available everywhere
40
+ static_args?: Record<string, any>;
41
+ run: (arg: ExtensionLookupActionArgs) => Promise<void> | void;
38
42
  }
39
43
 
40
- interface ExtensionActionFunctionProps {
41
- static_args: Record<string, any>;
42
- item: any;
43
- router: Router;
44
+ interface ExtensionLookupActionArgs {
45
+ item: any | null;
44
46
  active_group: LookupGroupRouteType;
47
+ search_query: string;
48
+ helpers: LookupActionHelpersType;
49
+ static_args: Record<string, any>;
45
50
  action: ExtensionLookupAction;
46
51
  }
47
52
 
@@ -86,12 +91,20 @@ type ListFilters = {
86
91
  dynamic: boolean;
87
92
  };
88
93
 
94
+ interface ExtensionLookupFetchArgs {
95
+ filters: LookupListFilterType[];
96
+ active_group: LookupGroupRouteType;
97
+ parent_item: Record<string, any>;
98
+ search_query: string;
99
+ helpers: LookupActionHelpersType;
100
+ }
101
+
89
102
  interface LocalListUIComponent {
90
103
  id: string;
91
104
  title: string;
92
105
  description: string;
93
106
  data_origin: "local";
94
- filters: ListFilters[];
107
+ filters: LookupListFilterType[];
95
108
  sorting: {
96
109
  key: string;
97
110
  order: "asc" | "desc";
@@ -106,12 +119,13 @@ interface RemoteListUIComponent {
106
119
  title: string;
107
120
  description: string;
108
121
  data_origin: "remote";
109
- filters: ListFilters[];
122
+ filters: LookupListFilterType[];
110
123
  sorting: {
111
124
  key: string;
112
125
  order: "asc" | "desc";
113
126
  };
114
127
  source: string;
128
+ fetch: (arg: ExtensionLookupFetchArgs) => Promise<any[]> | any[];
115
129
  keys: ListKeys;
116
130
  actions: ExtensionLookupAction[];
117
131
  }
@@ -153,7 +167,8 @@ export type {
153
167
  ExtensionPage,
154
168
  ExtensionActionShortcut,
155
169
  ExtensionLookupAction,
156
- ExtensionActionFunctionProps,
170
+ ExtensionLookupActionArgs,
171
+ ExtensionLookupFetchArgs,
157
172
  ListFilters,
158
173
  ListFormatKey,
159
174
  ListKeys,
package/src/lookup.d.ts CHANGED
@@ -1,45 +1,58 @@
1
- import { ExtensionModule } from "@/extensions/types";
2
- import React from "react";
3
-
4
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
- export interface LookUpStateType {
6
- active_group: LookupGroupRouteType | undefined;
7
- routes: LookupGroupRouteType[];
8
- search_query: string;
9
- is_shortcut?: boolean;
2
+ export type LookupValueType = "string" | "number" | "array";
3
+
4
+ export interface LookupListFilterType {
5
+ key: string;
6
+ type: LookupValueType;
7
+ query_value: string;
8
+ dynamic: boolean;
9
+ }
10
+
11
+ export interface LookupRouteExtensionType {
12
+ id: string;
13
+ title: string;
10
14
  }
11
15
 
12
16
  export interface LookupGroupRouteType {
13
17
  id: string;
14
18
  title: string;
15
- extension: {
16
- id: string;
17
- title: string;
18
- };
19
+ extension: LookupRouteExtensionType;
19
20
  previous_route_item: Record<string, any>;
20
- filters?: LookupListFilters[];
21
+ filters?: LookupListFilterType[];
21
22
  }
22
23
 
23
- export type LookupListFilters = {
24
- key: string;
25
- type: "string" | "number" | "array";
26
- query_value: string;
27
- dynamic: boolean;
28
- };
24
+ export interface LookupStateType {
25
+ active_group: LookupGroupRouteType | undefined;
26
+ routes: LookupGroupRouteType[];
27
+ search_query: string;
28
+ is_shortcut?: boolean;
29
+ }
29
30
 
30
- export type ActionTriggerType = null | {
31
- global: boolean;
32
- };
31
+ export interface LookupLastInstanceType extends LookupStateType {
32
+ path: string;
33
+ }
34
+
35
+ export interface LookupOpenGroupArgsType {
36
+ group: Omit<LookupGroupRouteType, "previous_route_item">;
37
+ item?: Record<string, any>;
38
+ }
33
39
 
34
- export interface LookUpContextType {
35
- actionsTriggered: ActionTriggerType;
36
- triggerActions: (state: ActionTriggerType) => void;
37
- lookUpSearchInputRef: React.RefObject<HTMLInputElement>;
38
- closeLookUp: (force?: boolean) => void;
39
- module: ExtensionModule | null;
40
- loading: boolean;
41
- error: Error | null;
42
- look_up: LookUpStateType;
40
+ export interface LookupActionHelpersType {
41
+ navigate: (path: string | number, options?: { replace?: boolean }) => void;
42
+ open_group: (arg: LookupOpenGroupArgsType) => void;
43
+ go_back: (force?: boolean) => void;
44
+ close_lookup: (force?: boolean) => void;
45
+ set_search_query: (value: string) => void;
46
+ get_lookup_state: () => LookupStateType | null;
47
+ }
48
+
49
+ export interface LookUpStateType {
43
50
  active_group: LookupGroupRouteType | undefined;
44
- handleInputsKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
51
+ routes: LookupGroupRouteType[];
52
+ search_query: string;
53
+ is_shortcut?: boolean;
45
54
  }
55
+
56
+ export type LookupActionTriggerType = null | {
57
+ global: boolean;
58
+ };
@@ -1,17 +0,0 @@
1
- export interface LookupGroupRouteType {
2
- id: string;
3
- title: string;
4
- extension: {
5
- id: string;
6
- title: string;
7
- };
8
- previous_route_item: Record<string, any>;
9
- filters?: LookupListFilters[];
10
- }
11
-
12
- export type LookupListFilters = {
13
- key: string;
14
- type: "string" | "number" | "array";
15
- query_value: string;
16
- dynamic: boolean;
17
- };