@umbraco-cms/backoffice 1.0.0-next.d924405b → 1.0.0-next.f8d940fc

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,6 +1,6 @@
1
1
  import * as rxjs from 'rxjs';
2
2
  import { Observable, BehaviorSubject } from 'rxjs';
3
- import { UmbControllerInterface, UmbControllerHostInterface } from './controller';
3
+ import { UmbControllerInterface, UmbControllerHostElement } from './controller';
4
4
 
5
5
  declare class UmbObserver<T> {
6
6
  #private;
@@ -13,7 +13,7 @@ declare class UmbObserver<T> {
13
13
  declare class UmbObserverController<T = unknown> extends UmbObserver<T> implements UmbControllerInterface {
14
14
  _alias?: string;
15
15
  get unique(): string | undefined;
16
- constructor(host: UmbControllerHostInterface, source: Observable<T>, callback: (_value: T) => void, alias?: string);
16
+ constructor(host: UmbControllerHostElement, source: Observable<T>, callback: (_value: T) => void, alias?: string);
17
17
  }
18
18
 
19
19
  /**
@@ -99,7 +99,7 @@ declare class DeepState<T> extends BehaviorSubject<T> {
99
99
  */
100
100
  declare class ArrayState<T> extends DeepState<T[]> {
101
101
  private _getUnique?;
102
- constructor(initialData: T[], _getUnique?: ((entry: T) => unknown) | undefined);
102
+ constructor(initialData: T[], getUniqueMethod?: (entry: T) => unknown);
103
103
  /**
104
104
  * @method remove
105
105
  * @param {unknown[]} uniques - The unique values to remove.
@@ -181,6 +181,21 @@ declare class ArrayState<T> extends DeepState<T[]> {
181
181
  * ]);
182
182
  */
183
183
  append(entries: T[]): this;
184
+ /**
185
+ * @method updateOne
186
+ * @param {unknown} unique - Unique value to find entry to update.
187
+ * @param {Partial<T>} entry - new data to be added in this Subject.
188
+ * @return {ArrayState<T>} Reference to it self.
189
+ * @description - Update a item with some new data, requires the ArrayState to be constructed with a getUnique method.
190
+ * @example <caption>Example append some data.</caption>
191
+ * const data = [
192
+ * { key: 1, value: 'foo'},
193
+ * { key: 2, value: 'bar'}
194
+ * ];
195
+ * const myState = new ArrayState(data, (x) => x.key);
196
+ * myState.updateOne(2, {value: 'updated-bar'});
197
+ */
198
+ updateOne(unique: unknown, entry: Partial<T>): this;
184
199
  }
185
200
 
186
201
  /**
@@ -246,4 +261,4 @@ declare function appendToFrozenArray<T>(data: T[], entry: T, getUniqueMethod?: (
246
261
  */
247
262
  declare function partialUpdateFrozenArray<T>(data: T[], partialEntry: Partial<T>, findMethod: (entry: T) => boolean): T[];
248
263
 
249
- export { ArrayState, BooleanState, ClassState, DeepState, NumberState, ObjectState, StringState, UmbObserver, UmbObserverController, appendToFrozenArray, createObservablePart, partialUpdateFrozenArray };
264
+ export { ArrayState, BasicState, BooleanState, ClassState, DeepState, MappingFunction, NumberState, ObjectState, StringState, UmbObserver, UmbObserverController, appendToFrozenArray, createObservablePart, partialUpdateFrozenArray };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-cms/backoffice",
3
- "version": "1.0.0-next.d924405b",
3
+ "version": "1.0.0-next.f8d940fc",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "umbraco",
package/repository.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ProblemDetailsModel } from './backend-api';
1
+ import { ProblemDetailsModel, FolderReponseModel, CreateFolderRequestModel, UpdateFolderReponseModel, FolderModelBaseModel } from './backend-api';
2
2
  import { DataSourceResponse as DataSourceResponse$1 } from './repository';
3
3
  import { Observable } from 'rxjs';
4
4
 
@@ -7,12 +7,20 @@ interface DataSourceResponse<T = undefined> {
7
7
  error?: ProblemDetailsModel;
8
8
  }
9
9
 
10
- interface UmbDataSource<T> {
11
- createScaffold(parentKey: string | null): Promise<DataSourceResponse$1<T>>;
12
- get(key: string): Promise<DataSourceResponse$1<T>>;
13
- insert(data: T): Promise<DataSourceResponse$1<T>>;
14
- update(data: T): Promise<DataSourceResponse$1<T>>;
15
- delete(key: string): Promise<DataSourceResponse$1<T>>;
10
+ interface UmbDataSource<CreateRequestType, UpdateRequestType, ResponseType> {
11
+ createScaffold(parentKey: string | null): Promise<DataSourceResponse$1<ResponseType>>;
12
+ get(unique: string): Promise<DataSourceResponse$1<ResponseType>>;
13
+ insert(data: CreateRequestType): Promise<any>;
14
+ update(unique: string, data: UpdateRequestType): Promise<DataSourceResponse$1<ResponseType>>;
15
+ delete(unique: string): Promise<DataSourceResponse$1>;
16
+ }
17
+
18
+ interface UmbFolderDataSource {
19
+ createScaffold(parentKey: string | null): Promise<DataSourceResponse<FolderReponseModel>>;
20
+ get(unique: string): Promise<DataSourceResponse<FolderReponseModel>>;
21
+ insert(data: CreateFolderRequestModel): Promise<DataSourceResponse<string>>;
22
+ update(unique: string, data: CreateFolderRequestModel): Promise<DataSourceResponse<UpdateFolderReponseModel>>;
23
+ delete(unique: string): Promise<DataSourceResponse>;
16
24
  }
17
25
 
18
26
  interface UmbTreeDataSource<PagedItemsType = any, ItemsType = any> {
@@ -66,4 +74,26 @@ interface UmbTreeRepository<ItemType = any, PagedItemType = UmbPagedData<ItemTyp
66
74
  treeItems: (uniques: string[]) => Promise<Observable<ItemType[]>>;
67
75
  }
68
76
 
69
- export { DataSourceResponse, UmbDataSource, UmbDetailRepository, UmbPagedData, UmbTreeDataSource, UmbTreeRepository };
77
+ interface UmbFolderRepository {
78
+ createFolderScaffold(parentKey: string | null): Promise<{
79
+ data?: FolderReponseModel;
80
+ error?: ProblemDetailsModel;
81
+ }>;
82
+ createFolder(folderRequest: CreateFolderRequestModel): Promise<{
83
+ data?: string;
84
+ error?: ProblemDetailsModel;
85
+ }>;
86
+ requestFolder(unique: string): Promise<{
87
+ data?: FolderReponseModel;
88
+ error?: ProblemDetailsModel;
89
+ }>;
90
+ updateFolder(unique: string, folder: FolderModelBaseModel): Promise<{
91
+ data?: UpdateFolderReponseModel;
92
+ error?: ProblemDetailsModel;
93
+ }>;
94
+ deleteFolder(key: string): Promise<{
95
+ error?: ProblemDetailsModel;
96
+ }>;
97
+ }
98
+
99
+ export { DataSourceResponse, UmbDataSource, UmbDetailRepository, UmbFolderDataSource, UmbFolderRepository, UmbPagedData, UmbTreeDataSource, UmbTreeRepository };
package/resources.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { UmbNotificationOptions } from './notification';
2
2
  import { ProblemDetailsModel } from './backend-api';
3
- import { UmbController, UmbControllerHostInterface } from './controller';
3
+ import { UmbController, UmbControllerHostElement } from './controller';
4
4
  import { DataSourceResponse as DataSourceResponse$1 } from './repository';
5
5
 
6
6
  declare class UmbResourceController extends UmbController {
7
7
  #private;
8
- constructor(host: UmbControllerHostInterface, promise: Promise<any>, alias?: string);
8
+ constructor(host: UmbControllerHostElement, promise: Promise<any>, alias?: string);
9
9
  hostConnected(): void;
10
10
  hostDisconnected(): void;
11
11
  /**
@@ -45,6 +45,6 @@ interface DataSourceResponse<T = undefined> {
45
45
 
46
46
  declare function tryExecute<T>(promise: Promise<T>): Promise<DataSourceResponse<T>>;
47
47
 
48
- declare function tryExecuteAndNotify<T>(host: UmbControllerHostInterface, resource: Promise<T>, options?: UmbNotificationOptions<any>): Promise<DataSourceResponse<T>>;
48
+ declare function tryExecuteAndNotify<T>(host: UmbControllerHostElement, resource: Promise<T>, options?: UmbNotificationOptions<any>): Promise<DataSourceResponse<T>>;
49
49
 
50
50
  export { UmbResourceController, tryExecute, tryExecuteAndNotify };
package/router.d.ts ADDED
@@ -0,0 +1,130 @@
1
+ import { UmbContextToken } from './context-api';
2
+ import { UmbControllerHostElement } from './controller';
3
+ import { UmbModalRouteRegistration } from './modal';
4
+
5
+ interface UmbRouteLocation {
6
+ name?: string;
7
+ params: {
8
+ [key: string]: string;
9
+ };
10
+ }
11
+
12
+ declare class UmbRouteContext {
13
+ #private;
14
+ private _onGotModals;
15
+ constructor(host: UmbControllerHostElement, _onGotModals: (contextRoutes: any) => void);
16
+ registerModal(registration: UmbModalRouteRegistration): UmbModalRouteRegistration<object, any>;
17
+ unregisterModal(registrationToken: ReturnType<typeof this$1.registerModal>): void;
18
+ _internal_routerGotBasePath(routerBasePath: string): void;
19
+ _internal_modalRouterChanged(activeModalPath: string | undefined): void;
20
+ }
21
+ declare const UMB_ROUTE_CONTEXT_TOKEN: UmbContextToken<UmbRouteContext>;
22
+
23
+ interface IRouterSlot<D = any, P = any> extends HTMLElement {
24
+ readonly route: IRoute<D> | null;
25
+ readonly isRoot: boolean;
26
+ readonly fragments: IPathFragments | null;
27
+ readonly params: Params | null;
28
+ readonly match: IRouteMatch<D> | null;
29
+ routes: IRoute<D>[];
30
+ add: ((routes: IRoute<D>[], navigate?: boolean) => void);
31
+ clear: (() => void);
32
+ render: (() => Promise<void>);
33
+ constructAbsolutePath: ((path: PathFragment) => string);
34
+ parent: IRouterSlot<P> | null | undefined;
35
+ queryParentRouterSlot: (() => IRouterSlot<P> | null);
36
+ }
37
+ type IRoutingInfo<D = any, P = any> = {
38
+ slot: IRouterSlot<D, P>;
39
+ match: IRouteMatch<D>;
40
+ };
41
+ type CustomResolver<D = any, P = any> = ((info: IRoutingInfo<D>) => boolean | void | Promise<boolean> | Promise<void>);
42
+ type Guard<D = any, P = any> = ((info: IRoutingInfo<D, P>) => boolean | Promise<boolean>);
43
+ type PageComponent = HTMLElement;
44
+ type ModuleResolver = Promise<{
45
+ default: any;
46
+ }>;
47
+ type Class<T extends PageComponent = PageComponent> = {
48
+ new (...args: any[]): T;
49
+ };
50
+ type Setup<D = any> = ((component: PageComponent, info: IRoutingInfo<D>) => void);
51
+ type PathMatch = "prefix" | "suffix" | "full" | "fuzzy";
52
+ /**
53
+ * The base route interface.
54
+ * D = the data type of the data
55
+ */
56
+ interface IRouteBase<D = any> {
57
+ path: PathFragment;
58
+ data?: D;
59
+ guards?: Guard[];
60
+ pathMatch?: PathMatch;
61
+ }
62
+ /**
63
+ * Route type used for redirection.
64
+ */
65
+ interface IRedirectRoute<D = any> extends IRouteBase<D> {
66
+ redirectTo: string;
67
+ preserveQuery?: boolean;
68
+ }
69
+ /**
70
+ * Route type used to resolve and stamp components.
71
+ */
72
+ interface IComponentRoute<D = any> extends IRouteBase<D> {
73
+ component: Class | ModuleResolver | PageComponent | (() => Class) | (() => PageComponent) | (() => ModuleResolver);
74
+ setup?: Setup;
75
+ }
76
+ /**
77
+ * Route type used to take control of how the route should resolve.
78
+ */
79
+ interface IResolverRoute<D = any> extends IRouteBase<D> {
80
+ resolve: CustomResolver;
81
+ }
82
+ type IRoute<D = any> = IRedirectRoute<D> | IComponentRoute<D> | IResolverRoute<D>;
83
+ type PathFragment = string;
84
+ type IPathFragments = {
85
+ consumed: PathFragment;
86
+ rest: PathFragment;
87
+ };
88
+ interface IRouteMatch<D = any> {
89
+ route: IRoute<D>;
90
+ params: Params;
91
+ fragments: IPathFragments;
92
+ match: RegExpMatchArray;
93
+ }
94
+ type PushStateEvent = CustomEvent<null>;
95
+ type ReplaceStateEvent = CustomEvent<null>;
96
+ type ChangeStateEvent = CustomEvent<null>;
97
+ type WillChangeStateEvent = CustomEvent<{
98
+ url?: string | null;
99
+ eventName: GlobalRouterEvent;
100
+ }>;
101
+ type NavigationStartEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
102
+ type NavigationSuccessEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
103
+ type NavigationCancelEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
104
+ type NavigationErrorEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
105
+ type NavigationEndEvent<D = any> = CustomEvent<IRoutingInfo<D>>;
106
+ type Params = {
107
+ [key: string]: string;
108
+ };
109
+ /**
110
+ * History related events.
111
+ */
112
+ type GlobalRouterEvent = "pushstate" | "replacestate" | "popstate" | "changestate" | "willchangestate" | "navigationstart" | "navigationcancel" | "navigationerror" | "navigationsuccess" | "navigationend";
113
+ declare global {
114
+ interface GlobalEventHandlersEventMap {
115
+ "pushstate": PushStateEvent;
116
+ "replacestate": ReplaceStateEvent;
117
+ "popstate": PopStateEvent;
118
+ "changestate": ChangeStateEvent;
119
+ "navigationstart": NavigationStartEvent;
120
+ "navigationend": NavigationEndEvent;
121
+ "navigationsuccess": NavigationSuccessEvent;
122
+ "navigationcancel": NavigationCancelEvent;
123
+ "navigationerror": NavigationErrorEvent;
124
+ "willchangestate": WillChangeStateEvent;
125
+ }
126
+ }
127
+
128
+ type UmbRoute = IRoute;
129
+
130
+ export { UMB_ROUTE_CONTEXT_TOKEN, UmbRoute, UmbRouteContext, UmbRouteLocation };
package/store.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rxjs from 'rxjs';
2
2
  import { Observable } from 'rxjs';
3
- import { UmbControllerHostInterface } from './controller';
3
+ import { UmbControllerHostElement } from './controller';
4
4
  import { EntityTreeItemResponseModel, FileSystemTreeItemPresentationModel } from './backend-api';
5
5
  import { UmbStoreBase as UmbStoreBase$1, UmbTreeStore as UmbTreeStore$1 } from './store';
6
6
 
@@ -39,9 +39,9 @@ interface UmbContentStore<T> extends UmbEntityDetailStore<T> {
39
39
  }
40
40
 
41
41
  declare class UmbStoreBase {
42
- protected _host: UmbControllerHostInterface;
42
+ protected _host: UmbControllerHostElement;
43
43
  readonly storeAlias: string;
44
- constructor(_host: UmbControllerHostInterface, storeAlias: string);
44
+ constructor(_host: UmbControllerHostElement, storeAlias: string);
45
45
  }
46
46
 
47
47
  /**