@umbraco-cms/backoffice 1.0.0-next.b7d4efa4 → 1.0.0-next.ba26bec7

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, UmbControllerHostElement } from './controller';
3
+ import { UmbControllerInterface, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
4
4
 
5
5
  declare class UmbObserver<T> {
6
6
  #private;
@@ -18,55 +18,55 @@ declare class UmbObserverController<T = unknown> extends UmbObserver<T> implemen
18
18
 
19
19
  /**
20
20
  * @export
21
- * @class BasicState
21
+ * @class UmbBasicState
22
22
  * @extends {BehaviorSubject<T>}
23
23
  * @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
24
24
  */
25
- declare class BasicState<T> extends BehaviorSubject<T> {
25
+ declare class UmbBasicState<T> extends BehaviorSubject<T> {
26
26
  constructor(initialData: T);
27
27
  next(newData: T): void;
28
28
  }
29
29
 
30
30
  /**
31
31
  * @export
32
- * @class BooleanState
32
+ * @class UmbBooleanState
33
33
  * @extends {BehaviorSubject<T>}
34
34
  * @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
35
35
  */
36
- declare class BooleanState<T> extends BasicState<T | boolean> {
36
+ declare class UmbBooleanState<T> extends UmbBasicState<T | boolean> {
37
37
  constructor(initialData: T | boolean);
38
38
  }
39
39
 
40
40
  /**
41
41
  * @export
42
- * @class NumberState
42
+ * @class UmbNumberState
43
43
  * @extends {BehaviorSubject<T>}
44
44
  * @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
45
45
  */
46
- declare class NumberState<T> extends BasicState<T | number> {
46
+ declare class UmbNumberState<T> extends UmbBasicState<T | number> {
47
47
  constructor(initialData: T | number);
48
48
  }
49
49
 
50
50
  /**
51
51
  * @export
52
- * @class StringState
53
- * @extends {BasicState<T>}
52
+ * @class UmbStringState
53
+ * @extends {UmbBasicState<T>}
54
54
  * @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
55
55
  */
56
- declare class StringState<T> extends BasicState<T | string> {
56
+ declare class UmbStringState<T> extends UmbBasicState<T | string> {
57
57
  constructor(initialData: T | string);
58
58
  }
59
59
 
60
- interface ClassStateData {
61
- equal(otherClass: ClassStateData): boolean;
60
+ interface UmbClassStateData {
61
+ equal(otherClass: UmbClassStateData): boolean;
62
62
  }
63
63
  /**
64
64
  * @export
65
- * @class ClassState
65
+ * @class UmbClassState
66
66
  * @extends {BehaviorSubject<T>}
67
67
  * @description - A RxJS BehaviorSubject which can hold class instance which has a equal method to compare in coming instances for changes.
68
68
  */
69
- declare class ClassState<T extends ClassStateData | undefined | null> extends BehaviorSubject<T> {
69
+ declare class UmbClassState<T extends UmbClassStateData | undefined | null> extends BehaviorSubject<T> {
70
70
  constructor(initialData: T);
71
71
  next(newData: T): void;
72
72
  }
@@ -77,12 +77,12 @@ type MemoizationFunction<R> = (previousResult: R, currentResult: R) => boolean;
77
77
 
78
78
  /**
79
79
  * @export
80
- * @class DeepState
80
+ * @class UmbDeepState
81
81
  * @extends {BehaviorSubject<T>}
82
82
  * @description - A RxJS BehaviorSubject which deepFreezes the data to ensure its not manipulated from any implementations.
83
83
  * Additionally the Subject ensures the data is unique, not updating any Observes unless there is an actual change of the content.
84
84
  */
85
- declare class DeepState<T> extends BehaviorSubject<T> {
85
+ declare class UmbDeepState<T> extends BehaviorSubject<T> {
86
86
  constructor(initialData: T);
87
87
  getObservablePart<ReturnType>(mappingFunction: MappingFunction<T, ReturnType>, memoizationFunction?: MemoizationFunction<ReturnType>): rxjs.Observable<ReturnType>;
88
88
  next(newData: T): void;
@@ -90,14 +90,14 @@ declare class DeepState<T> extends BehaviorSubject<T> {
90
90
 
91
91
  /**
92
92
  * @export
93
- * @class ArrayState
94
- * @extends {DeepState<T>}
93
+ * @class UmbArrayState
94
+ * @extends {UmbDeepState<T>}
95
95
  * @description - A RxJS BehaviorSubject which deepFreezes the object-data to ensure its not manipulated from any implementations.
96
96
  * Additionally the Subject ensures the data is unique, not updating any Observes unless there is an actual change of the content.
97
97
  *
98
98
  * The ArrayState provides methods to append data when the data is an Object.
99
99
  */
100
- declare class ArrayState<T> extends DeepState<T[]> {
100
+ declare class UmbArrayState<T> extends UmbDeepState<T[]> {
101
101
  #private;
102
102
  constructor(initialData: T[], getUniqueMethod?: (entry: T) => unknown);
103
103
  /**
@@ -109,7 +109,7 @@ declare class ArrayState<T> extends DeepState<T[]> {
109
109
  * { key: 1, value: 'foo'},
110
110
  * { key: 2, value: 'bar'}
111
111
  * ];
112
- * const myState = new ArrayState(data, (x) => x.key);
112
+ * const myState = new UmbArrayState(data, (x) => x.key);
113
113
  * myState.sortBy((a, b) => (a.sortOrder || 0) - (b.sortOrder || 0));
114
114
  */
115
115
  sortBy(sortMethod?: (a: T, b: T) => number): this;
@@ -117,35 +117,35 @@ declare class ArrayState<T> extends DeepState<T[]> {
117
117
  /**
118
118
  * @method remove
119
119
  * @param {unknown[]} uniques - The unique values to remove.
120
- * @return {ArrayState<T>} Reference to it self.
120
+ * @return {UmbArrayState<T>} Reference to it self.
121
121
  * @description - Remove some new data of this Subject.
122
- * @example <caption>Example remove entry with key '1' and '2'</caption>
122
+ * @example <caption>Example remove entry with id '1' and '2'</caption>
123
123
  * const data = [
124
- * { key: 1, value: 'foo'},
125
- * { key: 2, value: 'bar'}
124
+ * { id: 1, value: 'foo'},
125
+ * { id: 2, value: 'bar'}
126
126
  * ];
127
- * const myState = new ArrayState(data, (x) => x.key);
127
+ * const myState = new UmbArrayState(data, (x) => x.id);
128
128
  * myState.remove([1, 2]);
129
129
  */
130
130
  remove(uniques: unknown[]): this;
131
131
  /**
132
132
  * @method removeOne
133
133
  * @param {unknown} unique - The unique value to remove.
134
- * @return {ArrayState<T>} Reference to it self.
134
+ * @return {UmbArrayState<T>} Reference to it self.
135
135
  * @description - Remove some new data of this Subject.
136
- * @example <caption>Example remove entry with key '1'</caption>
136
+ * @example <caption>Example remove entry with id '1'</caption>
137
137
  * const data = [
138
- * { key: 1, value: 'foo'},
139
- * { key: 2, value: 'bar'}
138
+ * { id: 1, value: 'foo'},
139
+ * { id: 2, value: 'bar'}
140
140
  * ];
141
- * const myState = new ArrayState(data, (x) => x.key);
141
+ * const myState = new UmbArrayState(data, (x) => x.id);
142
142
  * myState.removeOne(1);
143
143
  */
144
144
  removeOne(unique: unknown): this;
145
145
  /**
146
146
  * @method filter
147
147
  * @param {unknown} filterMethod - The unique value to remove.
148
- * @return {ArrayState<T>} Reference to it self.
148
+ * @return {UmbArrayState<T>} Reference to it self.
149
149
  * @description - Remove some new data of this Subject.
150
150
  * @example <caption>Example remove entry with key '1'</caption>
151
151
  * const data = [
@@ -153,7 +153,7 @@ declare class ArrayState<T> extends DeepState<T[]> {
153
153
  * { key: 2, value: 'bar'},
154
154
  * { key: 3, value: 'poo'}
155
155
  * ];
156
- * const myState = new ArrayState(data, (x) => x.key);
156
+ * const myState = new UmbArrayState(data, (x) => x.key);
157
157
  * myState.filter((entry) => entry.key !== 1);
158
158
  *
159
159
  * Result:
@@ -167,28 +167,28 @@ declare class ArrayState<T> extends DeepState<T[]> {
167
167
  /**
168
168
  * @method appendOne
169
169
  * @param {T} entry - new data to be added in this Subject.
170
- * @return {ArrayState<T>} Reference to it self.
170
+ * @return {UmbArrayState<T>} Reference to it self.
171
171
  * @description - Append some new data to this Subject.
172
172
  * @example <caption>Example append some data.</caption>
173
173
  * const data = [
174
174
  * { key: 1, value: 'foo'},
175
175
  * { key: 2, value: 'bar'}
176
176
  * ];
177
- * const myState = new ArrayState(data);
177
+ * const myState = new UmbArrayState(data);
178
178
  * myState.append({ key: 1, value: 'replaced-foo'});
179
179
  */
180
180
  appendOne(entry: T): this;
181
181
  /**
182
182
  * @method append
183
183
  * @param {T[]} entries - A array of new data to be added in this Subject.
184
- * @return {ArrayState<T>} Reference to it self.
184
+ * @return {UmbArrayState<T>} Reference to it self.
185
185
  * @description - Append some new data to this Subject, if it compares to existing data it will replace it.
186
186
  * @example <caption>Example append some data.</caption>
187
187
  * const data = [
188
188
  * { key: 1, value: 'foo'},
189
189
  * { key: 2, value: 'bar'}
190
190
  * ];
191
- * const myState = new ArrayState(data);
191
+ * const myState = new UmbArrayState(data);
192
192
  * myState.append([
193
193
  * { key: 1, value: 'replaced-foo'},
194
194
  * { key: 3, value: 'another-bla'}
@@ -199,14 +199,14 @@ declare class ArrayState<T> extends DeepState<T[]> {
199
199
  * @method updateOne
200
200
  * @param {unknown} unique - Unique value to find entry to update.
201
201
  * @param {Partial<T>} entry - new data to be added in this Subject.
202
- * @return {ArrayState<T>} Reference to it self.
202
+ * @return {UmbArrayState<T>} Reference to it self.
203
203
  * @description - Update a item with some new data, requires the ArrayState to be constructed with a getUnique method.
204
204
  * @example <caption>Example append some data.</caption>
205
205
  * const data = [
206
206
  * { key: 1, value: 'foo'},
207
207
  * { key: 2, value: 'bar'}
208
208
  * ];
209
- * const myState = new ArrayState(data, (x) => x.key);
209
+ * const myState = new UmbArrayState(data, (x) => x.key);
210
210
  * myState.updateOne(2, {value: 'updated-bar'});
211
211
  */
212
212
  updateOne(unique: unknown, entry: Partial<T>): this;
@@ -214,22 +214,22 @@ declare class ArrayState<T> extends DeepState<T[]> {
214
214
 
215
215
  /**
216
216
  * @export
217
- * @class ObjectState
218
- * @extends {DeepState<T>}
217
+ * @class UmbObjectState
218
+ * @extends {UmbDeepState<T>}
219
219
  * @description - A RxJS BehaviorSubject which deepFreezes the object-data to ensure its not manipulated from any implementations.
220
220
  * Additionally the Subject ensures the data is unique, not updating any Observes unless there is an actual change of the content.
221
221
  *
222
- * The ObjectState provides methods to append data when the data is an Object.
222
+ * The UmbObjectState provides methods to append data when the data is an Object.
223
223
  */
224
- declare class ObjectState<T> extends DeepState<T> {
224
+ declare class UmbObjectState<T> extends UmbDeepState<T> {
225
225
  /**
226
226
  * @method update
227
227
  * @param {Partial<T>} partialData - A object containing some of the data to update in this Subject.
228
228
  * @description - Append some new data to this Object.
229
- * @return {ObjectState<T>} Reference to it self.
229
+ * @return {UmbObjectState<T>} Reference to it self.
230
230
  * @example <caption>Example append some data.</caption>
231
231
  * const data = {key: 'myKey', value: 'myInitialValue'};
232
- * const myState = new ObjectState(data);
232
+ * const myState = new UmbObjectState(data);
233
233
  * myState.update({value: 'myNewValue'});
234
234
  */
235
235
  update(partialData: Partial<T>): this;
@@ -254,13 +254,25 @@ declare function createObservablePart<R, T>(source$: Observable<T>, mappingFunct
254
254
  * @param {(mappable: T) => R} mappingFunction - Method to return the part for this Observable to return.
255
255
  * @param {(previousResult: R, currentResult: R) => boolean} [memoizationFunction] - Method to Compare if the data has changed. Should return true when data is different.
256
256
  * @description - Creates a RxJS Observable from RxJS Subject.
257
- * @example <caption>Example append new entry for a ArrayState or a part of DeepState/ObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
258
- * const entry = {key: 'myKey', value: 'myValue'};
259
- * const newDataSet = appendToFrozenArray(mySubject.getValue(), entry, x => x.key === key);
257
+ * @example <caption>Example append new entry for a ArrayState or a part of UmbDeepState/UmbObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
258
+ * const entry = {id: 'myKey', value: 'myValue'};
259
+ * const newDataSet = appendToFrozenArray(mySubject.getValue(), entry, x => x.id === id);
260
260
  * mySubject.next(newDataSet);
261
261
  */
262
262
  declare function appendToFrozenArray<T>(data: T[], entry: T, getUniqueMethod?: (entry: T) => unknown): T[];
263
263
 
264
+ /**
265
+ * @export
266
+ * @method filterFrozenArray
267
+ * @param {Array<T>} data - RxJS Subject to use for this Observable.
268
+ * @param {(entry: T) => boolean} filterMethod - Method to filter the array.
269
+ * @description - Creates a RxJS Observable from RxJS Subject.
270
+ * @example <caption>Example remove an entry of a ArrayState or a part of DeepState/ObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
271
+ * const newDataSet = filterFrozenArray(mySubject.getValue(), x => x.id !== "myKey");
272
+ * mySubject.next(newDataSet);
273
+ */
274
+ declare function filterFrozenArray<T>(data: T[], filterMethod: (entry: T) => boolean): T[];
275
+
264
276
  /**
265
277
  * @export
266
278
  * @method partialUpdateFrozenArray
@@ -268,11 +280,11 @@ declare function appendToFrozenArray<T>(data: T[], entry: T, getUniqueMethod?: (
268
280
  * @param {(mappable: T) => R} mappingFunction - Method to return the part for this Observable to return.
269
281
  * @param {(previousResult: R, currentResult: R) => boolean} [memoizationFunction] - Method to Compare if the data has changed. Should return true when data is different.
270
282
  * @description - Creates a RxJS Observable from RxJS Subject.
271
- * @example <caption>Example append new entry for a ArrayState or a part of DeepState/ObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
283
+ * @example <caption>Example append new entry for a ArrayState or a part of UmbDeepState/UmbObjectState it which is an array. Where the key is unique and the item will be updated if matched with existing.</caption>
272
284
  * const partialEntry = {value: 'myValue'};
273
285
  * const newDataSet = partialUpdateFrozenArray(mySubject.getValue(), partialEntry, x => x.key === 'myKey');
274
286
  * mySubject.next(newDataSet);
275
287
  */
276
288
  declare function partialUpdateFrozenArray<T>(data: T[], partialEntry: Partial<T>, findMethod: (entry: T) => boolean): T[];
277
289
 
278
- export { ArrayState, BasicState, BooleanState, ClassState, DeepState, MappingFunction, NumberState, ObjectState, StringState, UmbObserver, UmbObserverController, appendToFrozenArray, createObservablePart, partialUpdateFrozenArray };
290
+ export { MappingFunction, UmbArrayState, UmbBasicState, UmbBooleanState, UmbClassState, UmbDeepState, UmbNumberState, UmbObjectState, UmbObserver, UmbObserverController, UmbStringState, appendToFrozenArray, createObservablePart, filterFrozenArray, partialUpdateFrozenArray };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-cms/backoffice",
3
- "version": "1.0.0-next.b7d4efa4",
3
+ "version": "1.0.0-next.ba26bec7",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "umbraco",
@@ -0,0 +1,24 @@
1
+ import * as rxjs from 'rxjs';
2
+ import { UmbItemRepository } from '@umbraco-cms/backoffice/repository';
3
+ import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
4
+ import { UmbModalToken, UmbModalContext } from '@umbraco-cms/backoffice/modal';
5
+ import { ItemResponseModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
6
+
7
+ declare class UmbPickerInputContext<ItemType extends ItemResponseModelBaseModel> {
8
+ #private;
9
+ host: UmbControllerHostElement;
10
+ modalAlias: string | UmbModalToken;
11
+ repository?: UmbItemRepository<ItemType>;
12
+ modalContext?: UmbModalContext;
13
+ selection: rxjs.Observable<string[]>;
14
+ selectedItems: rxjs.Observable<ItemType[]>;
15
+ max: number;
16
+ min: number;
17
+ constructor(host: UmbControllerHostElement, repositoryAlias: string, modalAlias: string | UmbModalToken, getUniqueMethod?: (entry: ItemType) => string | undefined);
18
+ getSelection(): string[];
19
+ setSelection(selection: string[]): void;
20
+ openPicker(pickerData?: any): void;
21
+ requestRemoveItem(unique: string): Promise<void>;
22
+ }
23
+
24
+ export { UmbPickerInputContext };
package/repository.d.ts CHANGED
@@ -1,22 +1,24 @@
1
- import { ProblemDetailsModel, FolderReponseModel, CreateFolderRequestModel, UpdateFolderReponseModel, FolderModelBaseModel } from './backend-api';
2
- import { DataSourceResponse as DataSourceResponse$1 } from './repository';
1
+ import { ApiError, CancelError, FolderReponseModel, CreateFolderRequestModel, UpdateFolderReponseModel, ProblemDetailsModel, FolderModelBaseModel, ItemResponseModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
2
+ import { DataSourceResponse as DataSourceResponse$1, UmbDataSourceErrorResponse as UmbDataSourceErrorResponse$1 } from '@umbraco-cms/backoffice/repository';
3
3
  import { Observable } from 'rxjs';
4
4
 
5
- interface DataSourceResponse<T = undefined> {
5
+ interface DataSourceResponse<T = undefined> extends UmbDataSourceErrorResponse {
6
6
  data?: T;
7
- error?: ProblemDetailsModel;
7
+ }
8
+ interface UmbDataSourceErrorResponse {
9
+ error?: ApiError | CancelError;
8
10
  }
9
11
 
10
- interface UmbDataSource<CreateRequestType, UpdateRequestType, ResponseType> {
11
- createScaffold(parentKey: string | null): Promise<DataSourceResponse$1<ResponseType>>;
12
+ interface UmbDataSource<CreateRequestType, CreateResponseType, UpdateRequestType, ResponseType> {
13
+ createScaffold(parentId: string | null): Promise<DataSourceResponse$1<CreateRequestType>>;
12
14
  get(unique: string): Promise<DataSourceResponse$1<ResponseType>>;
13
- insert(data: CreateRequestType): Promise<any>;
15
+ insert(data: CreateRequestType): Promise<DataSourceResponse$1<CreateResponseType>>;
14
16
  update(unique: string, data: UpdateRequestType): Promise<DataSourceResponse$1<ResponseType>>;
15
17
  delete(unique: string): Promise<DataSourceResponse$1>;
16
18
  }
17
19
 
18
20
  interface UmbFolderDataSource {
19
- createScaffold(parentKey: string | null): Promise<DataSourceResponse<FolderReponseModel>>;
21
+ createScaffold(parentId: string | null): Promise<DataSourceResponse<FolderReponseModel>>;
20
22
  get(unique: string): Promise<DataSourceResponse<FolderReponseModel>>;
21
23
  insert(data: CreateFolderRequestModel): Promise<DataSourceResponse<string>>;
22
24
  update(unique: string, data: CreateFolderRequestModel): Promise<DataSourceResponse<UpdateFolderReponseModel>>;
@@ -29,24 +31,16 @@ interface UmbTreeDataSource<PagedItemsType = any, ItemsType = any> {
29
31
  getItems(unique: Array<string>): Promise<DataSourceResponse$1<Array<ItemsType>>>;
30
32
  }
31
33
 
32
- interface UmbDetailRepository<DetailType> {
33
- createScaffold(parentKey: string | null): Promise<{
34
- data?: DetailType;
35
- error?: ProblemDetailsModel;
36
- }>;
37
- requestByKey(key: string): Promise<{
38
- data?: DetailType;
39
- error?: ProblemDetailsModel;
40
- }>;
41
- create(data: DetailType): Promise<{
42
- error?: ProblemDetailsModel;
43
- }>;
44
- save(data: DetailType): Promise<{
45
- error?: ProblemDetailsModel;
46
- }>;
47
- delete(key: string): Promise<{
48
- error?: ProblemDetailsModel;
49
- }>;
34
+ interface UmbItemDataSource<ItemType> {
35
+ getItems(unique: Array<string>): Promise<DataSourceResponse$1<Array<ItemType>>>;
36
+ }
37
+
38
+ interface UmbMoveDataSource {
39
+ move(unique: string, targetUnique: string): Promise<UmbDataSourceErrorResponse$1>;
40
+ }
41
+
42
+ interface UmbCopyDataSource {
43
+ copy(unique: string, targetUnique: string): Promise<DataSourceResponse$1<string>>;
50
44
  }
51
45
 
52
46
  interface UmbPagedData<T> {
@@ -64,18 +58,38 @@ interface UmbTreeRepository<ItemType = any, PagedItemType = UmbPagedData<ItemTyp
64
58
  error: ProblemDetailsModel | undefined;
65
59
  asObservable?: () => Observable<ItemType[]>;
66
60
  }>;
67
- requestTreeItems: (uniques: string[]) => Promise<{
61
+ requestItemsLegacy?: (uniques: string[]) => Promise<{
68
62
  data: Array<ItemType> | undefined;
69
63
  error: ProblemDetailsModel | undefined;
70
64
  asObservable?: () => Observable<ItemType[]>;
71
65
  }>;
72
66
  rootTreeItems: () => Promise<Observable<ItemType[]>>;
73
67
  treeItemsOf: (parentUnique: string | null) => Promise<Observable<ItemType[]>>;
74
- treeItems: (uniques: string[]) => Promise<Observable<ItemType[]>>;
68
+ itemsLegacy?: (uniques: string[]) => Promise<Observable<ItemType[]>>;
69
+ }
70
+
71
+ interface UmbCollectionDataSource<ItemType = any, PagedItemType = UmbPagedData<ItemType>> {
72
+ getCollection(): Promise<DataSourceResponse<PagedItemType>>;
73
+ filterCollection(filter: any): Promise<DataSourceResponse<PagedItemType>>;
74
+ }
75
+
76
+ interface UmbRepositoryErrorResponse {
77
+ error?: ProblemDetailsModel;
78
+ }
79
+ interface UmbRepositoryResponse<T> extends UmbRepositoryErrorResponse {
80
+ data?: T;
81
+ }
82
+ interface UmbDetailRepository<CreateRequestType = any, CreateResponseType = any, UpdateRequestType = any, ResponseType = any> {
83
+ createScaffold(parentId: string | null): Promise<UmbRepositoryResponse<CreateRequestType>>;
84
+ requestById(id: string): Promise<UmbRepositoryResponse<ResponseType>>;
85
+ byId(id: string): Promise<Observable<ResponseType>>;
86
+ create(data: CreateRequestType): Promise<UmbRepositoryResponse<CreateResponseType>>;
87
+ save(id: string, data: UpdateRequestType): Promise<UmbRepositoryErrorResponse>;
88
+ delete(id: string): Promise<UmbRepositoryErrorResponse>;
75
89
  }
76
90
 
77
91
  interface UmbFolderRepository {
78
- createFolderScaffold(parentKey: string | null): Promise<{
92
+ createFolderScaffold(parentId: string | null): Promise<{
79
93
  data?: FolderReponseModel;
80
94
  error?: ProblemDetailsModel;
81
95
  }>;
@@ -91,9 +105,30 @@ interface UmbFolderRepository {
91
105
  data?: UpdateFolderReponseModel;
92
106
  error?: ProblemDetailsModel;
93
107
  }>;
94
- deleteFolder(key: string): Promise<{
108
+ deleteFolder(id: string): Promise<{
95
109
  error?: ProblemDetailsModel;
96
110
  }>;
97
111
  }
98
112
 
99
- export { DataSourceResponse, UmbDataSource, UmbDetailRepository, UmbFolderDataSource, UmbFolderRepository, UmbPagedData, UmbTreeDataSource, UmbTreeRepository };
113
+ interface UmbCollectionRepository {
114
+ requestCollection(filter?: any): Promise<any>;
115
+ }
116
+
117
+ interface UmbItemRepository<ItemType extends ItemResponseModelBaseModel> {
118
+ requestItems: (uniques: string[]) => Promise<{
119
+ data?: Array<ItemType> | undefined;
120
+ error?: ProblemDetailsModel | undefined;
121
+ asObservable?: () => Observable<Array<ItemType>>;
122
+ }>;
123
+ items: (uniques: string[]) => Promise<Observable<Array<ItemType>>>;
124
+ }
125
+
126
+ interface UmbMoveRepository {
127
+ move(unique: string, targetUnique: string): Promise<UmbRepositoryErrorResponse>;
128
+ }
129
+
130
+ interface UmbCopyRepository {
131
+ copy(unique: string, targetUnique: string): Promise<UmbRepositoryResponse<string>>;
132
+ }
133
+
134
+ export { DataSourceResponse, UmbCollectionDataSource, UmbCollectionRepository, UmbCopyDataSource, UmbCopyRepository, UmbDataSource, UmbDataSourceErrorResponse, UmbDetailRepository, UmbFolderDataSource, UmbFolderRepository, UmbItemDataSource, UmbItemRepository, UmbMoveDataSource, UmbMoveRepository, UmbPagedData, UmbRepositoryErrorResponse, UmbRepositoryResponse, UmbTreeDataSource, UmbTreeRepository };
package/resources.d.ts CHANGED
@@ -1,25 +1,20 @@
1
- import { UmbNotificationOptions } from './notification';
2
- import { ProblemDetailsModel } from './backend-api';
3
- import { UmbController, UmbControllerHostElement } from './controller';
4
- import { DataSourceResponse as DataSourceResponse$1 } from './repository';
1
+ import { UmbNotificationOptions } from '@umbraco-cms/backoffice/notification';
2
+ import { UmbController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller';
3
+ import { DataSourceResponse as DataSourceResponse$1 } from '@umbraco-cms/backoffice/repository';
4
+ import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
5
+ import { ApiError, CancelError } from '@umbraco-cms/backoffice/backend-api';
5
6
 
6
7
  declare class UmbResourceController extends UmbController {
7
8
  #private;
8
9
  constructor(host: UmbControllerHostElement, promise: Promise<any>, alias?: string);
9
10
  hostConnected(): void;
10
11
  hostDisconnected(): void;
11
- /**
12
- * Extract the ProblemDetailsModel object from an ApiError.
13
- *
14
- * This assumes that all ApiErrors contain a ProblemDetailsModel object in their body.
15
- */
16
- static toProblemDetailsModel(error: unknown): ProblemDetailsModel | undefined;
17
12
  /**
18
13
  * Base execute function with a try/catch block and return a tuple with the result and the error.
19
14
  */
20
15
  static tryExecute<T>(promise: Promise<T>): Promise<DataSourceResponse$1<T>>;
21
16
  /**
22
- * Wrap the {execute} function in a try/catch block and return the result.
17
+ * Wrap the {tryExecute} function in a try/catch block and return the result.
23
18
  * If the executor function throws an error, then show the details in a notification.
24
19
  */
25
20
  tryExecuteAndNotify<T>(options?: UmbNotificationOptions): Promise<DataSourceResponse$1<T>>;
@@ -38,13 +33,27 @@ declare class UmbResourceController extends UmbController {
38
33
  destroy(): void;
39
34
  }
40
35
 
41
- interface DataSourceResponse<T = undefined> {
36
+ /**
37
+ * The base URL of the configured Umbraco server.
38
+ * If the server is local, this will be an empty string.
39
+ *
40
+ * @remarks This is the base URL of the Umbraco server, not the base URL of the backoffice.
41
+ *
42
+ * @example https://localhost:44300
43
+ * @example https://my-umbraco-site.com
44
+ * @example ''
45
+ */
46
+ declare const UMB_SERVER_URL: UmbContextToken<string>;
47
+
48
+ interface DataSourceResponse<T = undefined> extends UmbDataSourceErrorResponse {
42
49
  data?: T;
43
- error?: ProblemDetailsModel;
50
+ }
51
+ interface UmbDataSourceErrorResponse {
52
+ error?: ApiError | CancelError;
44
53
  }
45
54
 
46
55
  declare function tryExecute<T>(promise: Promise<T>): Promise<DataSourceResponse<T>>;
47
56
 
48
- declare function tryExecuteAndNotify<T>(host: UmbControllerHostElement, resource: Promise<T>, options?: UmbNotificationOptions<any>): Promise<DataSourceResponse<T>>;
57
+ declare function tryExecuteAndNotify<T>(host: UmbControllerHostElement, resource: Promise<T>, options?: UmbNotificationOptions): Promise<DataSourceResponse<T>>;
49
58
 
50
- export { UmbResourceController, tryExecute, tryExecuteAndNotify };
59
+ export { UMB_SERVER_URL, UmbResourceController, tryExecute, tryExecuteAndNotify };