@lavalogic/scoria 0.0.13 → 0.0.15

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.
Files changed (187) hide show
  1. package/dist/Components/Button.svelte +0 -3
  2. package/dist/Components/Contexts/ContextMenuOption.svelte +0 -3
  3. package/dist/Components/DatePicker.svelte +1 -6
  4. package/dist/Components/DimensionInput.svelte +5 -6
  5. package/dist/Components/DimensionInput.svelte.d.ts +4 -4
  6. package/dist/Components/FileUpload.svelte +4 -2
  7. package/dist/Components/GridInput.svelte +3 -3
  8. package/dist/Components/MultiSelect.svelte +0 -4
  9. package/dist/Components/ProgressBubble.svelte +1 -2
  10. package/dist/Components/Table/Body/QuickSearchCell.svelte +0 -9
  11. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +1 -5
  12. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +2 -2
  13. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +1 -2
  14. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +6 -7
  15. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +2 -5
  16. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +0 -3
  17. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +8 -6
  18. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +12 -19
  19. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +2 -5
  20. package/dist/Components/Table/Body/Rows/TableRow.svelte +3 -17
  21. package/dist/Components/Table/Headers/TableHead.svelte +1 -5
  22. package/dist/Components/Table/Misc/FilterInput.svelte +10 -27
  23. package/dist/Components/Table/Table.svelte +1 -2
  24. package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js +6 -5
  25. package/dist/Components/Table/Types/Context/TableContext.svelte.js +11 -30
  26. package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.d.ts +0 -1
  27. package/dist/Components/Table/Types/DataRepository/LocalTableDataRepository.svelte.js +3 -16
  28. package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +2 -5
  29. package/dist/Components/Table/Types/Filtering/CustomRemoteFilters.d.ts +1 -2
  30. package/dist/Components/Table/Types/Focus/TableFocusDetails.svelte.js +1 -5
  31. package/dist/Components/Touch/DateModal.svelte +0 -5
  32. package/dist/Components/Touch/UtilityButton.svelte +12 -7
  33. package/dist/Components/Touch/UtilityButton.svelte.d.ts +1 -1
  34. package/dist/Contexts/UntypedInputContext.svelte.d.ts +2 -1
  35. package/dist/Contexts/UntypedInputContext.svelte.js +1 -17
  36. package/dist/Helpers/Helpers.svelte.d.ts +21 -95
  37. package/dist/Helpers/Helpers.svelte.js +54 -395
  38. package/dist/Types/Examples/ExampleItem.d.ts +3 -3
  39. package/dist/Types/Internal/Misc.d.ts +12 -267
  40. package/dist/Types/Internal/Misc.js +1 -129
  41. package/dist/index.d.ts +4 -76
  42. package/dist/index.js +4 -76
  43. package/package.json +16 -16
  44. package/dist/Components/Table/Types/DataRepository/RemoteTableDataRepository.svelte.d.ts +0 -74
  45. package/dist/Components/Table/Types/DataRepository/RemoteTableDataRepository.svelte.js +0 -521
  46. package/dist/Components/Table/Types/Filtering/CustomProxyFilter.d.ts +0 -10
  47. package/dist/Components/Table/Types/Filtering/CustomProxyFilter.js +0 -1
  48. package/dist/Types/Internal/ApplicationIdentifier.d.ts +0 -39
  49. package/dist/Types/Internal/ApplicationIdentifier.js +0 -2080
  50. package/dist/Types/Internal/FloService.d.ts +0 -7
  51. package/dist/Types/Internal/FloService.js +0 -30
  52. package/dist/Types/Requests/IFillablePodLineDateRequestBody.d.ts +0 -13
  53. package/dist/Types/Requests/IFillablePodLineDateRequestBody.js +0 -10
  54. package/dist/Types/Requests/IRequiredPodLineDateRequestBody.d.ts +0 -14
  55. package/dist/Types/Requests/IRequiredPodLineDateRequestBody.js +0 -8
  56. package/dist/Types/Requests/IValidatedPodLineDateRequestBody.d.ts +0 -16
  57. package/dist/Types/Requests/IValidatedPodLineDateRequestBody.js +0 -10
  58. package/dist/Types/Responses/AddressType.d.ts +0 -3
  59. package/dist/Types/Responses/AddressType.js +0 -2
  60. package/dist/Types/Responses/IAddress.d.ts +0 -39
  61. package/dist/Types/Responses/IAddress.js +0 -30
  62. package/dist/Types/Responses/IBaseAddress.d.ts +0 -17
  63. package/dist/Types/Responses/IBaseAddress.js +0 -15
  64. package/dist/Types/Responses/ICountry.d.ts +0 -16
  65. package/dist/Types/Responses/ICountry.js +0 -1
  66. package/dist/Types/Responses/IDBEntry.d.ts +0 -13
  67. package/dist/Types/Responses/IDBEntry.js +0 -12
  68. package/dist/Types/Responses/IErrorResponse.d.ts +0 -10
  69. package/dist/Types/Responses/IErrorResponse.js +0 -1
  70. package/dist/Types/Responses/ILabelPrinter.d.ts +0 -4
  71. package/dist/Types/Responses/ILabelPrinter.js +0 -1
  72. package/dist/Types/Responses/ILaserPrinter.d.ts +0 -4
  73. package/dist/Types/Responses/ILaserPrinter.js +0 -1
  74. package/dist/Types/Responses/ILoginResponse.d.ts +0 -8
  75. package/dist/Types/Responses/ILoginResponse.js +0 -1
  76. package/dist/Types/Responses/IPaginatedPayload.d.ts +0 -5
  77. package/dist/Types/Responses/IPaginatedPayload.js +0 -1
  78. package/dist/Types/Responses/IPaginatedResponse.d.ts +0 -5
  79. package/dist/Types/Responses/IPaginatedResponse.js +0 -1
  80. package/dist/Types/Responses/IPagination.d.ts +0 -9
  81. package/dist/Types/Responses/IPagination.js +0 -1
  82. package/dist/Types/Responses/IPayload.d.ts +0 -3
  83. package/dist/Types/Responses/IPayload.js +0 -1
  84. package/dist/Types/Responses/IPrinter.d.ts +0 -11
  85. package/dist/Types/Responses/IPrinter.js +0 -1
  86. package/dist/Types/Responses/IProcessTypeSelectionMethodOutboundType.d.ts +0 -18
  87. package/dist/Types/Responses/IProcessTypeSelectionMethodOutboundType.js +0 -12
  88. package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomer.d.ts +0 -20
  89. package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomer.js +0 -14
  90. package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomerType.d.ts +0 -20
  91. package/dist/Types/Responses/IProcessTypeSelectionMethodWarehouseCustomerType.js +0 -14
  92. package/dist/Types/Responses/IProductCategory.d.ts +0 -19
  93. package/dist/Types/Responses/IProductCategory.js +0 -13
  94. package/dist/Types/Responses/IProductCategoryDetails.d.ts +0 -33
  95. package/dist/Types/Responses/IProductCategoryDetails.js +0 -13
  96. package/dist/Types/Responses/IProductIgnoreOnAllocationOutboundType.d.ts +0 -17
  97. package/dist/Types/Responses/IProductIgnoreOnAllocationOutboundType.js +0 -11
  98. package/dist/Types/Responses/IProductLocation.d.ts +0 -23
  99. package/dist/Types/Responses/IProductLocation.js +0 -17
  100. package/dist/Types/Responses/IResponse.d.ts +0 -8
  101. package/dist/Types/Responses/IResponse.js +0 -1
  102. package/dist/Types/Responses/IStockSortationMethodCustomer.d.ts +0 -18
  103. package/dist/Types/Responses/IStockSortationMethodCustomer.js +0 -12
  104. package/dist/Types/Responses/Pods/IAttributeTypeWithAI.d.ts +0 -8
  105. package/dist/Types/Responses/Pods/IAttributeTypeWithAI.js +0 -1
  106. package/dist/Types/Responses/Pods/IBatchType.d.ts +0 -5
  107. package/dist/Types/Responses/Pods/IBatchType.js +0 -1
  108. package/dist/Types/Responses/Pods/IDateType.d.ts +0 -6
  109. package/dist/Types/Responses/Pods/IDateType.js +0 -1
  110. package/dist/Types/Responses/Pods/IFillablePodLineAttribute.d.ts +0 -10
  111. package/dist/Types/Responses/Pods/IFillablePodLineAttribute.js +0 -9
  112. package/dist/Types/Responses/Pods/IFillablePodLineBatch.d.ts +0 -18
  113. package/dist/Types/Responses/Pods/IFillablePodLineBatch.js +0 -12
  114. package/dist/Types/Responses/Pods/IFillablePodLineDate.d.ts +0 -19
  115. package/dist/Types/Responses/Pods/IFillablePodLineDate.js +0 -13
  116. package/dist/Types/Responses/Pods/IFillablePodLinePurchaseOrder.d.ts +0 -18
  117. package/dist/Types/Responses/Pods/IFillablePodLinePurchaseOrder.js +0 -12
  118. package/dist/Types/Responses/Pods/IFillablePodLineSerial.d.ts +0 -18
  119. package/dist/Types/Responses/Pods/IFillablePodLineSerial.js +0 -12
  120. package/dist/Types/Responses/Pods/IFillablePodLineTag.d.ts +0 -18
  121. package/dist/Types/Responses/Pods/IFillablePodLineTag.js +0 -12
  122. package/dist/Types/Responses/Pods/IPurchaseOrderType.d.ts +0 -5
  123. package/dist/Types/Responses/Pods/IPurchaseOrderType.js +0 -1
  124. package/dist/Types/Responses/Pods/IRequiredOrValidatedAttribute.d.ts +0 -7
  125. package/dist/Types/Responses/Pods/IRequiredOrValidatedAttribute.js +0 -7
  126. package/dist/Types/Responses/Pods/IRequiredPodLineBatch.d.ts +0 -18
  127. package/dist/Types/Responses/Pods/IRequiredPodLineBatch.js +0 -8
  128. package/dist/Types/Responses/Pods/IRequiredPodLineDate.d.ts +0 -19
  129. package/dist/Types/Responses/Pods/IRequiredPodLineDate.js +0 -8
  130. package/dist/Types/Responses/Pods/IRequiredPodLinePurchaseOrder.d.ts +0 -19
  131. package/dist/Types/Responses/Pods/IRequiredPodLinePurchaseOrder.js +0 -8
  132. package/dist/Types/Responses/Pods/IRequiredPodLineSerial.d.ts +0 -19
  133. package/dist/Types/Responses/Pods/IRequiredPodLineSerial.js +0 -8
  134. package/dist/Types/Responses/Pods/IRequiredPodLineTag.d.ts +0 -19
  135. package/dist/Types/Responses/Pods/IRequiredPodLineTag.js +0 -8
  136. package/dist/Types/Responses/Pods/ISerialType.d.ts +0 -6
  137. package/dist/Types/Responses/Pods/ISerialType.js +0 -1
  138. package/dist/Types/Responses/Pods/ITagType.d.ts +0 -6
  139. package/dist/Types/Responses/Pods/ITagType.js +0 -1
  140. package/dist/Types/Responses/Pods/IValidatedPodLineAttribute.d.ts +0 -13
  141. package/dist/Types/Responses/Pods/IValidatedPodLineAttribute.js +0 -10
  142. package/dist/Types/Responses/Pods/IValidatedPodLineBatch.d.ts +0 -19
  143. package/dist/Types/Responses/Pods/IValidatedPodLineBatch.js +0 -10
  144. package/dist/Types/Responses/Pods/IValidatedPodLineDate.d.ts +0 -21
  145. package/dist/Types/Responses/Pods/IValidatedPodLineDate.js +0 -10
  146. package/dist/Types/Responses/Pods/IValidatedPodLinePurchaseOrder.d.ts +0 -20
  147. package/dist/Types/Responses/Pods/IValidatedPodLinePurchaseOrder.js +0 -10
  148. package/dist/Types/Responses/Pods/IValidatedPodLineSerial.d.ts +0 -20
  149. package/dist/Types/Responses/Pods/IValidatedPodLineSerial.js +0 -10
  150. package/dist/Types/Responses/Pods/IValidatedPodLineTag.d.ts +0 -20
  151. package/dist/Types/Responses/Pods/IValidatedPodLineTag.js +0 -10
  152. package/dist/Types/Responses/Products/IAttributeRule.d.ts +0 -34
  153. package/dist/Types/Responses/Products/IAttributeRule.js +0 -28
  154. package/dist/Types/Responses/Products/IBarcode.d.ts +0 -18
  155. package/dist/Types/Responses/Products/IBarcode.js +0 -12
  156. package/dist/Types/Responses/Products/IBatchRule.d.ts +0 -36
  157. package/dist/Types/Responses/Products/IBatchRule.js +0 -9
  158. package/dist/Types/Responses/Products/ICustomerRule.d.ts +0 -23
  159. package/dist/Types/Responses/Products/ICustomerRule.js +0 -17
  160. package/dist/Types/Responses/Products/IDateRule.d.ts +0 -36
  161. package/dist/Types/Responses/Products/IDateRule.js +0 -9
  162. package/dist/Types/Responses/Products/IPrice.d.ts +0 -19
  163. package/dist/Types/Responses/Products/IPrice.js +0 -12
  164. package/dist/Types/Responses/Products/IProduct.d.ts +0 -436
  165. package/dist/Types/Responses/Products/IProduct.js +0 -77
  166. package/dist/Types/Responses/Products/IProductKit.d.ts +0 -24
  167. package/dist/Types/Responses/Products/IProductKit.js +0 -18
  168. package/dist/Types/Responses/Products/IProductKitMatrix.d.ts +0 -13
  169. package/dist/Types/Responses/Products/IProductKitMatrix.js +0 -1
  170. package/dist/Types/Responses/Products/IProductSupplier.d.ts +0 -18
  171. package/dist/Types/Responses/Products/IProductSupplier.js +0 -12
  172. package/dist/Types/Responses/Products/IProductTag.d.ts +0 -33
  173. package/dist/Types/Responses/Products/IProductTag.js +0 -14
  174. package/dist/Types/Responses/Products/IProductTagType.d.ts +0 -18
  175. package/dist/Types/Responses/Products/IProductTagType.js +0 -12
  176. package/dist/Types/Responses/Products/IProductUnitOfMeasure.d.ts +0 -97
  177. package/dist/Types/Responses/Products/IProductUnitOfMeasure.js +0 -35
  178. package/dist/Types/Responses/Products/IProductUnitOfMeasurePrice.d.ts +0 -36
  179. package/dist/Types/Responses/Products/IProductUnitOfMeasurePrice.js +0 -17
  180. package/dist/Types/Responses/Products/IPurchaseOrderRule.d.ts +0 -36
  181. package/dist/Types/Responses/Products/IPurchaseOrderRule.js +0 -9
  182. package/dist/Types/Responses/Products/ISerialRule.d.ts +0 -36
  183. package/dist/Types/Responses/Products/ISerialRule.js +0 -9
  184. package/dist/Types/Responses/Products/ITagRule.d.ts +0 -36
  185. package/dist/Types/Responses/Products/ITagRule.js +0 -9
  186. package/dist/Types/Responses/Products/IUnitOfMeasure.d.ts +0 -18
  187. package/dist/Types/Responses/Products/IUnitOfMeasure.js +0 -12
@@ -1,521 +0,0 @@
1
- import { Type } from '@sinclair/typebox';
2
- import { TableDataRepository } from './TableDataRepository.svelte.js';
3
- import { browser, dev } from '$app/environment';
4
- import { PaginationType } from '../Pagination/PaginationType.js';
5
- import { FilterType } from '../Filtering/FilterType.js';
6
- import { StringFilterMode } from '../Filtering/StringFilterMode.js';
7
- import { NumberDateFilterMode } from '../Filtering/NumberDateFilterMode.js';
8
- import { assert, asyncForEach, floFriendly, floFriendlyWithLocalTime, getErrorMessage, lastSec } from '../../../../Helpers/Helpers.svelte.js';
9
- function isProxyFilter(filter) {
10
- return 'responseValueTransform' in filter;
11
- }
12
- export class RemoteTableDataRepository extends TableDataRepository {
13
- options;
14
- static memoise = (getter, key) => {
15
- const cache = new Map();
16
- return async (item) => {
17
- const found = cache.get(item[key]);
18
- if (found) {
19
- return found;
20
- }
21
- const response = getter(item);
22
- cache.set(item[key], response);
23
- // invalidate cache shortly after
24
- setTimeout(() => {
25
- cache.delete(item[key]);
26
- }, 60000);
27
- return response;
28
- };
29
- };
30
- httpGetter;
31
- httpGetterPaginated;
32
- constructor(options) {
33
- super(options.tableName, options.getUserId);
34
- this.options = options;
35
- this.httpGetter = options.httpGetter;
36
- this.httpGetterPaginated = options.httpGetterPaginated;
37
- if (browser) {
38
- const userId = this.getUserId();
39
- const savedPageSize = localStorage.getItem(`${userId}-${options.tableName}-page-size`);
40
- if (savedPageSize) {
41
- const saved = JSON.parse(savedPageSize);
42
- if (saved) {
43
- this.setPageSize?.(saved);
44
- }
45
- }
46
- }
47
- else {
48
- this.paginationState = {
49
- pageIndex: 0,
50
- pageSize: options.pageSize ?? 20
51
- };
52
- }
53
- // this.paginationState = {
54
- // pageIndex: 0,
55
- // pageSize
56
- // };
57
- if (browser && options.fetchImmediately) {
58
- this.reload();
59
- }
60
- }
61
- _latestFetchId = 0;
62
- _data = $state([]);
63
- get data() {
64
- return this._data;
65
- }
66
- set data(v) {
67
- this._data = v;
68
- }
69
- paginationType = PaginationType.Remote;
70
- filterType = FilterType.Virtual;
71
- manualSorting = true;
72
- _sorting = $state([]);
73
- get sorting() {
74
- return this._sorting;
75
- }
76
- set sorting(v) {
77
- this._sorting = v;
78
- }
79
- _totalRows = $state(0);
80
- get totalRows() {
81
- return this._totalRows;
82
- }
83
- set totalRows(v) {
84
- this._totalRows = v;
85
- }
86
- _lastPageIndex = $state(0);
87
- _lastPage = $derived(this._lastPageIndex + 1);
88
- get lastPage() {
89
- return this._lastPage;
90
- }
91
- _isLoadingInternal = $state(false);
92
- _isLoadingExternal = $state(false);
93
- _isLoading = $derived(this._isLoadingInternal || this._isLoadingExternal);
94
- get isLoading() {
95
- return this._isLoading;
96
- }
97
- set isLoading(v) {
98
- this._isLoadingExternal = v;
99
- }
100
- _filtering = $state([]);
101
- get filtering() {
102
- return this._filtering;
103
- }
104
- set filtering(v) {
105
- this._filtering = v;
106
- this.reload(true);
107
- }
108
- get pageStartIndex() {
109
- return 0;
110
- }
111
- _pageEndIndexExclusive = $derived(this.paginationState.pageSize);
112
- get pageEndIndexExclusive() {
113
- return this._pageEndIndexExclusive;
114
- }
115
- resetFilters = () => {
116
- this.filtering = [];
117
- };
118
- updateSorting = (stateOrCallback) => {
119
- if (typeof stateOrCallback == 'function') {
120
- this._sorting = stateOrCallback(this._sorting);
121
- }
122
- else {
123
- this._sorting = stateOrCallback;
124
- }
125
- this._fetch(700);
126
- };
127
- setFilterMode = (id, mode) => {
128
- let wasUpdated = false;
129
- if (mode && this.filterModes.get(id) !== mode) {
130
- this.filterModes.set(id, mode);
131
- wasUpdated = true;
132
- }
133
- if (wasUpdated) {
134
- const filterValue = this._filtering.find((it) => it.id === id)?.value;
135
- if (filterValue != '' && filterValue != undefined) {
136
- this.reload();
137
- }
138
- }
139
- };
140
- filterBy = (id, value) => {
141
- // if (typeof value === 'string') {
142
- // value = value.trim();
143
- // }
144
- const newFiltering = this.filtering.concat();
145
- const oldIndex = newFiltering.findIndex((it) => it.id === id);
146
- if (oldIndex === -1 || newFiltering[oldIndex].value != value) {
147
- if (oldIndex > -1) {
148
- newFiltering.splice(oldIndex, 1);
149
- }
150
- const hasNoValue = value == null ||
151
- (typeof value === 'object' && Array.isArray(value) && value.length === 0) ||
152
- (typeof value === 'string' && value.length === 0);
153
- if (!hasNoValue) {
154
- newFiltering.push({ id, value });
155
- }
156
- this.filtering = newFiltering;
157
- }
158
- };
159
- setPageSize = (size) => {
160
- if (typeof size === 'string') {
161
- size = parseInt(size);
162
- }
163
- if (isNaN(size)) {
164
- return;
165
- }
166
- this.paginationState = { ...this.paginationState, pageSize: size };
167
- this.reload();
168
- };
169
- setPage = (page) => {
170
- const lastIndex = this._lastPageIndex;
171
- this.paginationState = {
172
- ...this.paginationState,
173
- pageIndex: Math.max(0, Math.min(lastIndex, page - 1))
174
- };
175
- this.reload();
176
- };
177
- nextPage = () => {
178
- const lastIndex = this._lastPageIndex;
179
- this.paginationState = {
180
- ...this.paginationState,
181
- pageIndex: Math.min(lastIndex, this.paginationState.pageIndex + 1)
182
- };
183
- this.reload();
184
- };
185
- prevPage = () => {
186
- this.paginationState = {
187
- ...this.paginationState,
188
- pageIndex: Math.max(0, this.paginationState.pageIndex - 1)
189
- };
190
- this.reload();
191
- };
192
- reload = (debounced = false) => {
193
- // force a re-fetch
194
- this._fetch(debounced ? undefined : 50, true);
195
- };
196
- previousUri = '';
197
- async _fetch(delay = 400, force = false) {
198
- const fetchId = (this._latestFetchId = this._latestFetchId + 1);
199
- if (delay) {
200
- await new Promise((r) => setTimeout(r, delay));
201
- }
202
- if (this._latestFetchId !== fetchId) {
203
- if (dev) {
204
- console.log('cancelling due to a newer fetch id');
205
- }
206
- return;
207
- }
208
- try {
209
- this._isLoadingInternal = true;
210
- const { pageIndex, pageSize } = this.paginationState;
211
- if (!this.options.uri) {
212
- this.data = [];
213
- if (dev) {
214
- console.log('cancelling due to no URI');
215
- }
216
- return;
217
- }
218
- const queryString = await this.queryString;
219
- const computedUri = `${this.options.uri}${this.options.uri.includes('?') ? '&' : '?'}page=${pageIndex + 1}&recordsPerPage=${pageSize}${queryString}`;
220
- if (!force && computedUri === this.previousUri) {
221
- if (dev) {
222
- console.log('cancelling due to final uri being identical to the previous one');
223
- }
224
- return;
225
- }
226
- const response = await this.httpGetterPaginated(this.options.service, computedUri);
227
- if (this._latestFetchId === fetchId) {
228
- this.previousUri = computedUri;
229
- //use response to set data AND pagination
230
- const { data, pagination } = response.payload;
231
- if (dev && this.options.schema) {
232
- assert(Type.Array(this.options.schema), data);
233
- }
234
- // HACK this type coercion needs proof. It is meant to happen when there is no response transformation, which means that R is identical to T
235
- this.data = this.options.responseTransformation?.(data) ?? data;
236
- this._lastPageIndex = pagination.lastPage - 1;
237
- this.totalRows = pagination.totalRecords;
238
- if (pagination.lastPage > 0 && pagination.lastPage < pageIndex + 1) {
239
- this._lastPageIndex = pagination.lastPage - 1;
240
- this.setPage(pagination.lastPage);
241
- }
242
- }
243
- else {
244
- if (dev) {
245
- console.log('cancelling callback as it was not the latest fetch');
246
- }
247
- }
248
- }
249
- catch (e) {
250
- if (this._latestFetchId === fetchId) {
251
- // TODO improve
252
- alert(getErrorMessage(e));
253
- }
254
- }
255
- finally {
256
- if (this._latestFetchId === fetchId) {
257
- this._isLoadingInternal = false;
258
- }
259
- }
260
- }
261
- _queryString = $derived.by(async () => {
262
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
263
- this.filtering;
264
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
265
- this.sorting;
266
- const uri = [];
267
- const buffer = new Map();
268
- const prerequisites = new Map();
269
- const remoteFilterResults = new Map();
270
- this.options.defaultFilters.forEach((value, key) => {
271
- buffer.set(key, value);
272
- });
273
- await asyncForEach(this.filtering, async (filtering) => {
274
- if (filtering.value != undefined && filtering.value !== '') {
275
- if (this.options.remoteFilters?.has(filtering.id)) {
276
- // debugger;
277
- const customFilter = this.options.remoteFilters.get(filtering.id);
278
- if (customFilter != null) {
279
- if (isProxyFilter(customFilter)) {
280
- if (!prerequisites.has(customFilter.service)) {
281
- prerequisites.set(customFilter.service, new Map());
282
- }
283
- const byService = prerequisites.get(customFilter.service);
284
- if (!byService.has(customFilter.group)) {
285
- byService.set(customFilter.group, new Map());
286
- }
287
- // return values for proxied requests, set directly for direct query strings
288
- const result = await (async () => {
289
- if (Array.isArray(filtering.value)) {
290
- const _result = getNumericFilterValue(this.filterModes.get(filtering.id) ?? NumberDateFilterMode.In, filtering);
291
- if (!_result) {
292
- return;
293
- }
294
- const [, mode, value] = _result;
295
- const finalValue = (await customFilter.searchValueTransform?.(mode, value)) ?? value;
296
- return [customFilter.queryKey, mode, finalValue];
297
- }
298
- else {
299
- const mode = this.filterModes.get(filtering.id) ?? StringFilterMode.Contains;
300
- const finalValue = (await customFilter.searchValueTransform?.(mode, filtering.value)) ??
301
- filtering.value;
302
- return [customFilter.queryKey, mode, finalValue];
303
- }
304
- })();
305
- if (!result) {
306
- return;
307
- }
308
- const [endpoint, mode, queryString] = result;
309
- const withMode = {
310
- endpoint,
311
- finalisedQuery: endpoint + mode + queryString,
312
- responseValueTransform: customFilter.responseValueTransform
313
- };
314
- const forThisService = byService.get(customFilter.group);
315
- if (forThisService.has(customFilter.endpoint)) {
316
- forThisService.get(customFilter.endpoint).push(withMode);
317
- }
318
- else {
319
- forThisService.set(customFilter.endpoint, [withMode]);
320
- }
321
- }
322
- else {
323
- if (Array.isArray(filtering.value)) {
324
- if (filtering.value[0] instanceof Date || filtering.value[1] instanceof Date) {
325
- const [from, to] = filtering.value;
326
- if (from && to) {
327
- buffer.set(filtering.id, `__between=${floFriendly(from)},${floFriendlyWithLocalTime(to, lastSec())}`);
328
- }
329
- else if (from) {
330
- buffer.set(filtering.id, `__gte=${floFriendly(from)}`);
331
- }
332
- else if (to) {
333
- buffer.set(filtering.id, `__lte=${floFriendlyWithLocalTime(to, lastSec())}`);
334
- }
335
- }
336
- else if (typeof filtering.value[0] === 'string') {
337
- const joinedValue = filtering.value.join(',');
338
- if (!joinedValue) {
339
- return;
340
- }
341
- const mode = this.filterModes.get(filtering.id) ?? StringFilterMode.In;
342
- buffer.set(customFilter.queryKey, mode + joinedValue);
343
- }
344
- else {
345
- const _result = getNumericFilterValue(this.filterModes.get(filtering.id) ?? NumberDateFilterMode.In, filtering);
346
- if (!_result) {
347
- return;
348
- }
349
- const [, mode, value] = _result;
350
- buffer.set(customFilter.queryKey, mode + value);
351
- }
352
- }
353
- else {
354
- if (typeof filtering.value === 'string' || typeof filtering.value == 'number') {
355
- const isNumeric = !isNaN(Number(filtering.value)) ||
356
- typeof filtering.value === 'number' ||
357
- (filtering.value.includes(',') &&
358
- filtering.value.split(',').every((slice) => !isNaN(Number(slice))));
359
- const mode = isNumeric
360
- ? (this.filterModes.get(filtering.id) ?? NumberDateFilterMode.In)
361
- : (this.filterModes.get(filtering.id) ?? StringFilterMode.Contains);
362
- buffer.set(customFilter.queryKey, (mode + filtering.value));
363
- }
364
- else if (dev) {
365
- console.warn(`unhandled filter value type ${typeof filtering.value} (value ${filtering.value})`);
366
- alert(`unhandled filter value type ${typeof filtering.value} (value ${filtering.value})`);
367
- }
368
- }
369
- }
370
- }
371
- return;
372
- }
373
- // if value is numeric
374
- if (Array.isArray(filtering.value)) {
375
- if (filtering.value[0] instanceof Date || filtering.value[1] instanceof Date) {
376
- const [from, to] = filtering.value;
377
- if (from && to) {
378
- buffer.set(filtering.id, `__between=${floFriendly(from)},${floFriendlyWithLocalTime(to, lastSec())}`);
379
- }
380
- else if (from) {
381
- buffer.set(filtering.id, `__gte=${floFriendly(from)}`);
382
- }
383
- else if (to) {
384
- buffer.set(filtering.id, `__lte=${floFriendlyWithLocalTime(to, lastSec())}`);
385
- }
386
- }
387
- else {
388
- const userMode = this.filterModes.get(filtering.id) ?? NumberDateFilterMode.In;
389
- const result = getNumericFilterValue(userMode, filtering);
390
- if (result) {
391
- const [key, mode, value] = result;
392
- buffer.set(key, mode + value);
393
- }
394
- }
395
- }
396
- else if (typeof filtering.value == 'string') {
397
- const mode = this.filterModes.get(filtering.id) ?? StringFilterMode.Contains;
398
- buffer.set(filtering.id, mode + filtering.value);
399
- }
400
- else if (dev) {
401
- console.log(filtering);
402
- // eslint-disable-next-line no-debugger
403
- debugger;
404
- }
405
- }
406
- });
407
- const finalisedRquests = [];
408
- for (const [service, groups] of prerequisites) {
409
- for (const [, filterMap] of groups) {
410
- for (const [endpoint, filters] of filterMap) {
411
- const q = `${endpoint}?${filters.map((it) => it.finalisedQuery).join('&')}`;
412
- finalisedRquests.push([service, q, filters]);
413
- }
414
- }
415
- }
416
- await asyncForEach(finalisedRquests, async ([service, uri, filters]) => {
417
- const response = await this.httpGetter(service, uri);
418
- await asyncForEach(filters, async (filter) => {
419
- const result = await filter.responseValueTransform(response.payload.data);
420
- if (result) {
421
- const [key, value] = result;
422
- if (remoteFilterResults.has(key)) {
423
- remoteFilterResults.set(key, remoteFilterResults.get(key).filter((it) => value.includes(it)));
424
- }
425
- else {
426
- remoteFilterResults.set(key, value);
427
- }
428
- }
429
- });
430
- });
431
- remoteFilterResults.forEach((values, key) => {
432
- const left = `${key}__in=`;
433
- if (values.length) {
434
- if (dev && buffer.has(left)) {
435
- console.log(buffer.get(left));
436
- console.log(values);
437
- // eslint-disable-next-line no-debugger
438
- debugger;
439
- }
440
- buffer.set(left, values.toString());
441
- }
442
- });
443
- buffer.forEach((value, key) => {
444
- if (value.length) {
445
- uri.push(key + value);
446
- }
447
- });
448
- if (this.sorting.length) {
449
- const sortingQueryString = this.sorting
450
- .map((it) => it.id + (it.desc ? '__desc' : '__asc'))
451
- .join(',');
452
- uri.push(`sortBy=${sortingQueryString}`);
453
- }
454
- return uri.length ? '&' + uri.join('&') : '';
455
- });
456
- get queryString() {
457
- return this._queryString;
458
- }
459
- }
460
- function getNumericFilterValue(mode, it) {
461
- if (Array.isArray(it.value)) {
462
- switch (mode) {
463
- case NumberDateFilterMode.Equals:
464
- case NumberDateFilterMode.Only:
465
- case NumberDateFilterMode.NotEquals:
466
- case NumberDateFilterMode.LessThan:
467
- case NumberDateFilterMode.LessThanOrEqual:
468
- case NumberDateFilterMode.GreaterThan:
469
- case NumberDateFilterMode.GreaterThanOrEqual: {
470
- const [min] = TableDataRepository.getMinMax(it.value);
471
- if (min != null) {
472
- return [it.id, mode, min.toString()];
473
- }
474
- break;
475
- }
476
- case NumberDateFilterMode.Between: {
477
- const [min, max] = TableDataRepository.getMinMax(it.value);
478
- if (min != null) {
479
- if (max != null) {
480
- return [it.id, mode, `${min},${max}`];
481
- }
482
- else {
483
- return [it.id, NumberDateFilterMode.GreaterThanOrEqual, min.toString()];
484
- }
485
- }
486
- else if (max != null) {
487
- return [it.id, NumberDateFilterMode.LessThanOrEqual, max.toString()];
488
- }
489
- break;
490
- }
491
- case NumberDateFilterMode.In:
492
- case NumberDateFilterMode.NotIn: {
493
- const values = TableDataRepository.getValues(it.value);
494
- if (values.length) {
495
- return [it.id, mode, values.toString()];
496
- }
497
- break;
498
- }
499
- case NumberDateFilterMode.null: {
500
- // TODO true or false
501
- return [it.id, mode, 'true'];
502
- }
503
- case StringFilterMode.ImplicitEquals:
504
- case StringFilterMode.Equals:
505
- case StringFilterMode.NotEquals:
506
- case StringFilterMode.Contains:
507
- case StringFilterMode.NotContains:
508
- case StringFilterMode.StartsWith:
509
- case StringFilterMode.NotStartsWith:
510
- case StringFilterMode.EndsWith:
511
- case StringFilterMode.NotEndsWith:
512
- case StringFilterMode.In:
513
- case StringFilterMode.NotIn:
514
- case StringFilterMode.Empty:
515
- case StringFilterMode.null: {
516
- throw new Error('Used stirng filtering mode were a numeric filter was expected');
517
- }
518
- }
519
- }
520
- return null;
521
- }
@@ -1,10 +0,0 @@
1
- import type { FloService } from '../../../../Types/Internal/FloService.js';
2
- import type { CustomFilter } from './CustomFilter.js';
3
- import type { FilterMode } from './FilterMode.js';
4
- export interface CustomProxyFilter extends CustomFilter {
5
- service: FloService;
6
- endpoint: string;
7
- group: unknown;
8
- searchValueTransform?: (mode: FilterMode, value: unknown) => Promise<string>;
9
- responseValueTransform: (item: unknown) => Promise<[string, unknown[]]>;
10
- }
@@ -1,39 +0,0 @@
1
- import type { AICode } from './Misc.js';
2
- export interface IApplicationIdentifier {
3
- readonly name: ApplicationIdentifierName;
4
- readonly GS1Code: AICode;
5
- readonly AILength: number;
6
- readonly valueLengths: IValueLength[];
7
- readonly parseFromParentheses: (value: string) => string;
8
- readonly parseFromFNC1: (buffer: string[], currentFnc1Substitute: string) => string;
9
- }
10
- export interface IValueLength {
11
- readonly type: GS1LengthType;
12
- readonly length: number;
13
- readonly encoding: GS1Encoding;
14
- readonly mandatory: boolean;
15
- }
16
- export declare const GS1LengthType: {
17
- readonly Fixed: "Fixed";
18
- readonly Variable: "Variable";
19
- };
20
- export type GS1LengthType = (typeof GS1LengthType)[keyof typeof GS1LengthType];
21
- export declare const GS1Encoding: {
22
- readonly Numeric: "Numeric";
23
- readonly Set82: "Set82";
24
- readonly Set39: "Set39";
25
- };
26
- export type GS1Encoding = (typeof GS1Encoding)[keyof typeof GS1Encoding];
27
- declare class ApplicationIdentifier implements IApplicationIdentifier {
28
- readonly name: ApplicationIdentifierName;
29
- readonly GS1Code: AICode;
30
- readonly AILength: number;
31
- readonly valueLengths: IValueLength[];
32
- constructor(name: ApplicationIdentifierName, GS1Code: AICode, AILength: number, valueLengths: IValueLength[]);
33
- readonly parseFromParentheses: (value: string) => string;
34
- protected readonly _defaultParseFromFNC1: (buffer: string[], currentFnc1Substitute: string) => string;
35
- readonly parseFromFNC1: (buffer: string[], currentFnc1Substitute: string) => string;
36
- }
37
- export declare const ApplicationIdentifiers: Record<ApplicationIdentifierName, ApplicationIdentifier>;
38
- export type ApplicationIdentifierName = 'SSCC' | 'GTIN' | 'CONTENT' | 'BATCH' | 'PROD_DATE' | 'PAYMENT_DUE_DATE' | 'PACK_DATE' | 'BEST_BEFORE' | 'SELL_BY' | 'USE_BY' | 'VARIANT' | 'SERIAL' | 'CPV' | 'TPX' | 'ADDITIONAL_ID' | 'CUSTOMER_PART_NUMBER' | 'MTO_VARIANT' | 'PCN' | 'SECONDARY_SERIAL' | 'REF_TO_SOURCE' | 'GDTI' | 'GLN_EXTENSION_COMPONENT' | 'GCN' | 'VAR_COUNT' | 'NET_WEIGHT_KG' | 'LENGTH_METRES' | 'WIDTH_METRES' | 'HEIGHT_METRES' | 'AREA' | 'NET_VOLUME_LITRES' | 'NET_VOLUME_CUBIC_METRES' | 'NET_WEIGHT_LB' | 'LENGTH_INCHES' | 'LENGTH_FEET' | 'LENGTH_YARDS' | 'WIDTH_INCHES' | 'WIDTH_FEET' | 'WIDTH_YARDS' | 'HEIGHT_INCHES' | 'HEIGHT_FEET' | 'HEIGHT_YARDS' | 'GROSS_WEIGHT_KG' | 'LENGTH_METRES_LOG' | 'WIDTH_METRES_LOG' | 'HEIGHT_METRES_LOG' | 'AREA_SQUARE_METRES_LOG' | 'VOLUME_LITRES_LOG' | 'VOLUME_CUBIC_METRES_LOG' | 'KG_PER_SQUARE_METRE' | 'GROSS_WEIGHT_LB' | 'LENGTH_INCHES_LOG' | 'LENGTH_FEET_LOG' | 'LENGTH_YARDS_LOG' | 'WIDTH_INCHES_LOG' | 'WIDTH_FEET_LOG' | 'WIDTH_YARDS_LOG' | 'HEIGHT_INCHES_LOG' | 'HEIGHT_FEET_LOG' | 'HEIGHT_YARDS_LOG' | 'AREA_SQUARE_INCHES' | 'AREA_SQUARE_FEET' | 'AREA_SQUARE_YARDS' | 'AREA_SQUARE_INCHES_LOG' | 'AREA_SQUARE_FEET_LOG' | 'AREA_SQUARE_YARDS_LOG' | 'NET_WEIGHT_TROY_OUNCES' | 'NET_VOLUME_OUNCES' | 'NET_VOLUME_QUARTS' | 'NET_VOLUME_GALLONS' | 'LOGISTIC_VOLUME_QUARTS' | 'LOGISTIC_VOLUME_GALLONS_US' | 'VOLUME_CUBIC_INCHES' | 'VOLUME_CUBIC_FEET' | 'VOLUME_CUBIC_YARDS' | 'LOGISTIC_VOLUME_CUBIC_INCHES' | 'LOGISTIC_VOLUME_CUBIC_FEET' | 'LOGISTIC_VOLUME_CUBIC_YARDS' | 'COUNT' | 'AMOUNT' | 'AMOUNT_ISO' | 'PRICE' | 'PRICE_ISO' | 'PERCENT_OFF' | 'PRICE_PER_UOM' | 'ORDER_NUMBER' | 'GINC' | 'GSIN' | 'ROUTE' | 'SHIP_TO_GLOBAL' | 'BILL_TO' | 'PURCHASE_FROM' | 'SHIP_FOR_LOC' | 'LOC_NUMBER' | 'PAY_TO' | 'PROD_LOC' | 'PARTY' | 'SHIP_TO_POST' | 'SHIP_TO_POST_ISO' | 'ORIGIN' | 'COUNTRY_INITIAL_PROCESS' | 'COUNTRY_PROCESS' | 'COUNTRY_DISASSEMBLY' | 'COUNTRY_FULL_PROCESS' | 'ORIGIN_SUBDIVISION' | 'SHIP_TO_COMP' | 'SHIP_TO_NAME' | 'SHIP_TO_ADD1' | 'SHIP_TO_ADD2' | 'SHIP_TO_SUB' | 'SHIP_TO_LOCAL' | 'SHIP_TO_REG' | 'SHIP_TO_COUNTRY' | 'SHIP_TO_PHONE' | 'SHIP_TO_GEO' | 'RTN_TO_COMP' | 'RTN_TO_NAME' | 'RTN_TO_ADD1' | 'RTN_TO_ADD2' | 'RTN_TO_SUB' | 'RTN_TO_LOC' | 'RTN_TO_REG' | 'RTN_TO_COUNTRY' | 'RTN_TO_POST' | 'RTN_TO_PHONE' | 'SRV_DESCRIPTION' | 'DANGEROUS_GOODS' | 'AUTH_LEAVE' | 'SIG_REQUIRED' | 'NOT_BEFORE_DELIVERY_DATE_TIME' | 'NOT_AFTER_DELIVERY_DATE_TIME' | 'RELEASE_DATE' | 'NSN' | 'MEAT_CUT' | 'EXPIRY_TIME' | 'ACTIVE_POTENCY' | 'CATCH_AREA' | 'FIRST_FREEZE_DATE' | 'HARVEST_DATE' | 'AQUATIC_SPECIES' | 'FISHING_GEAR_TYPE' | 'PROD_METHOD' | 'TEST_BY_DATE' | 'REFURB_LOT' | 'FUNC_STAT' | 'REV_STAT' | 'GIAI_ASSEMBLY' | 'PROCESSOR' | 'UIC_EXT' | 'NHRN_PZN' | 'NHRN_CIP' | 'NHRN_CN' | 'NHRN_DRN' | 'NHRN_AIM' | 'NHRN_NDC' | 'CERT_REF' | 'PROTOCOL' | 'DIMENSIONS' | 'CMT_NUMBER' | 'GRAI' | 'GIAI' | 'PRICE_PER_UNIT' | 'ITIP' | 'IBAN' | 'PROD_TIME' | 'OPTSEN' | 'CPID' | 'CPID_SERIAL' | 'VERSION' | 'GMN' | 'GSRN_PROVIDER' | 'GSRN_RECIPIENT' | 'SRIN' | 'REF_NUMBER' | 'ITIP_CONTENT' | 'COUPON_NA' | 'POINTS' | 'POSITIVE_OFFER_NA' | 'PRODUCT_URL' | 'INTERNAL' | 'INTERNAL_1' | 'INTERNAL_2' | 'INTERNAL_3' | 'INTERNAL_4' | 'INTERNAL_5' | 'INTERNAL_6' | 'INTERNAL_7' | 'INTERNAL_8' | 'INTERNAL_9';
39
- export {};