oneentry 1.0.155 → 1.0.157
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/README.md +19 -0
- package/changelog.md +154 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +1 -1
- package/dist/auth-provider/authProviderSchemas.d.ts +2 -0
- package/dist/auth-provider/authProviderSchemas.js +2 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +4 -0
- package/dist/base/asyncModules.d.ts +18 -2
- package/dist/base/asyncModules.js +32 -8
- package/dist/base/syncModules.d.ts +41 -144
- package/dist/base/syncModules.js +67 -359
- package/dist/base/timeIntervals.d.ts +95 -0
- package/dist/base/timeIntervals.js +321 -0
- package/dist/base/utils.d.ts +65 -7
- package/dist/base/validation.js +0 -1
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +3 -3
- package/dist/forms-data/formsDataApi.js +2 -2
- package/dist/forms-data/formsDataInterfaces.d.ts +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -0
- package/dist/integration-collections/integrationCollectionsApi.js +6 -6
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +4 -0
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +4 -0
- package/dist/integration-collections/integrationCollectionsSchemas.js +2 -0
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersInterfaces.d.ts +10 -0
- package/dist/orders/ordersSchemas.d.ts +10 -0
- package/dist/orders/ordersSchemas.js +12 -0
- package/dist/pages/pagesApi.d.ts +4 -4
- package/dist/pages/pagesApi.js +10 -9
- package/dist/pages/pagesInterfaces.d.ts +14 -4
- package/dist/pages/pagesSchemas.d.ts +15 -0
- package/dist/pages/pagesSchemas.js +13 -1
- package/dist/products/productsApi.d.ts +4 -4
- package/dist/products/productsApi.js +12 -10
- package/dist/products/productsInterfaces.d.ts +16 -4
- package/dist/products/productsSchemas.d.ts +17 -0
- package/dist/products/productsSchemas.js +14 -1
- package/dist/subscriptions/subscriptionsApi.d.ts +4 -4
- package/dist/subscriptions/subscriptionsApi.js +3 -3
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +26 -5
- package/dist/subscriptions/subscriptionsSchemas.d.ts +27 -1
- package/dist/subscriptions/subscriptionsSchemas.js +20 -2
- package/package.json +1 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expandTimeIntervals = expandTimeIntervals;
|
|
4
|
+
exports.isTimeIntervalAttribute = isTimeIntervalAttribute;
|
|
5
|
+
exports.expandAttributeTimeIntervals = expandAttributeTimeIntervals;
|
|
6
|
+
const _MS_PER_MINUTE = 60000;
|
|
7
|
+
const _MS_PER_DAY = 86400000;
|
|
8
|
+
const _MS_PER_WEEK = 7 * _MS_PER_DAY;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a date-ish value to the UTC midnight of its day, as epoch milliseconds.
|
|
11
|
+
*
|
|
12
|
+
* Everything downstream works on whole UTC days, so this is the single place
|
|
13
|
+
* where an incoming `Date` / ISO string / timestamp is reduced to a day key.
|
|
14
|
+
*
|
|
15
|
+
* `null` is rejected explicitly: `new Date(null)` is the epoch, not an invalid
|
|
16
|
+
* date, so a NaN check alone would silently accept it as 1970-01-01.
|
|
17
|
+
* @param {Date | string | number} value - The value to interpret as a date.
|
|
18
|
+
* @returns {number | null} Epoch ms of the UTC day start, or null when the value is not a valid date.
|
|
19
|
+
*/
|
|
20
|
+
function _toUtcDayStart(value) {
|
|
21
|
+
if (value === null || value === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
24
|
+
if (Number.isNaN(date.getTime()))
|
|
25
|
+
return null;
|
|
26
|
+
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a time-of-day point to minutes since midnight.
|
|
30
|
+
*
|
|
31
|
+
* Guards the numeric contract: a missing component, or one arriving as a string
|
|
32
|
+
* (`{ hours: '9' }`), would otherwise poison the arithmetic downstream — either
|
|
33
|
+
* throwing `RangeError` on `toISOString` or, for strings, concatenating instead
|
|
34
|
+
* of adding.
|
|
35
|
+
* @param {ITimeIntervalPoint | undefined} point - The point to convert.
|
|
36
|
+
* @returns {number | null} Minutes since midnight, or null when the point is malformed.
|
|
37
|
+
*/
|
|
38
|
+
function _toMinutes(point) {
|
|
39
|
+
if (!point)
|
|
40
|
+
return null;
|
|
41
|
+
if (!Number.isFinite(point.hours) || !Number.isFinite(point.minutes)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return point.hours * 60 + point.minutes;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the days a schedule is active on, clipped to the requested window.
|
|
48
|
+
*
|
|
49
|
+
* `anchor` is both the recurrence phase (which weekday / which day-of-month)
|
|
50
|
+
* and the first day the schedule is valid — nothing before it is ever emitted.
|
|
51
|
+
* The recurrence rule is open-ended, so `rangeEnd` (the window, intersected
|
|
52
|
+
* with the schedule's own validity end) is what stops the enumeration.
|
|
53
|
+
* @param {number} anchor - UTC day start the schedule is anchored to.
|
|
54
|
+
* @param {number} rangeStart - UTC day start of the first day to consider (inclusive).
|
|
55
|
+
* @param {number} rangeEnd - UTC day start of the last day to consider (inclusive).
|
|
56
|
+
* @param {boolean} inEveryWeek - Whether the schedule repeats weekly.
|
|
57
|
+
* @param {boolean} inEveryMonth - Whether the schedule repeats monthly.
|
|
58
|
+
* @returns {number[]} Ascending UTC day starts the schedule is active on.
|
|
59
|
+
*/
|
|
60
|
+
function _resolveActiveDays(anchor, rangeStart, rangeEnd, inEveryWeek, inEveryMonth) {
|
|
61
|
+
const days = [];
|
|
62
|
+
// Weekly wins over monthly: repeating "every week" already visits every
|
|
63
|
+
// occurrence of the anchor's weekday in every month, which is exactly what
|
|
64
|
+
// the two flags combined have always meant.
|
|
65
|
+
if (inEveryWeek) {
|
|
66
|
+
const offset = Math.ceil((rangeStart - anchor) / _MS_PER_WEEK);
|
|
67
|
+
for (let day = anchor + Math.max(0, offset) * _MS_PER_WEEK; day <= rangeEnd; day += _MS_PER_WEEK) {
|
|
68
|
+
days.push(day);
|
|
69
|
+
}
|
|
70
|
+
return days;
|
|
71
|
+
}
|
|
72
|
+
// Monthly: the same day-of-month, every month. Months too short for that day
|
|
73
|
+
// (e.g. the 31st in February) are skipped rather than rolled over.
|
|
74
|
+
if (inEveryMonth) {
|
|
75
|
+
const dayOfMonth = new Date(anchor).getUTCDate();
|
|
76
|
+
const start = new Date(rangeStart);
|
|
77
|
+
let year = start.getUTCFullYear();
|
|
78
|
+
let month = start.getUTCMonth();
|
|
79
|
+
// Walk the calendar month by month. The cursor is the first of the month,
|
|
80
|
+
// not the emitted day: a month too short for `dayOfMonth` emits nothing and
|
|
81
|
+
// would otherwise leave the cursor standing still.
|
|
82
|
+
while (Date.UTC(year, month, 1) <= rangeEnd) {
|
|
83
|
+
const daysInMonth = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
84
|
+
if (dayOfMonth <= daysInMonth) {
|
|
85
|
+
const day = Date.UTC(year, month, dayOfMonth);
|
|
86
|
+
if (day >= rangeStart && day <= rangeEnd)
|
|
87
|
+
days.push(day);
|
|
88
|
+
}
|
|
89
|
+
month += 1;
|
|
90
|
+
if (month > 11) {
|
|
91
|
+
month = 0;
|
|
92
|
+
year += 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return days;
|
|
96
|
+
}
|
|
97
|
+
// No recurrence: a plain date range — every day of it.
|
|
98
|
+
for (let day = rangeStart; day <= rangeEnd; day += _MS_PER_DAY) {
|
|
99
|
+
days.push(day);
|
|
100
|
+
}
|
|
101
|
+
return days;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Builds slots for one day from explicit `[start, end]` time pairs.
|
|
105
|
+
*
|
|
106
|
+
* Used by entity schedules, where each pair is emitted verbatim as one slot.
|
|
107
|
+
* @param {number} day - UTC day start, in epoch ms.
|
|
108
|
+
* @param {ITimeIntervalPoint[][]} times - Daily time ranges as `[start, end]` pairs.
|
|
109
|
+
* @param {TimeIntervalPair[]} out - Accumulator the produced slots are pushed to.
|
|
110
|
+
*/
|
|
111
|
+
function _addSlotsFromTimes(day, times, out) {
|
|
112
|
+
times.forEach((range) => {
|
|
113
|
+
const [start, end] = range !== null && range !== void 0 ? range : [];
|
|
114
|
+
const startMinutes = _toMinutes(start);
|
|
115
|
+
const endMinutes = _toMinutes(end);
|
|
116
|
+
if (startMinutes === null || endMinutes === null)
|
|
117
|
+
return;
|
|
118
|
+
const from = day + startMinutes * _MS_PER_MINUTE;
|
|
119
|
+
const to = day + endMinutes * _MS_PER_MINUTE;
|
|
120
|
+
out.push([new Date(from).toISOString(), new Date(to).toISOString()]);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Builds slots for one day by slicing each range into fixed-length periods.
|
|
125
|
+
*
|
|
126
|
+
* Used by form schedules: `start=09:00, end=12:00, period=30` yields
|
|
127
|
+
* `[09:00–09:30], [09:30–10:00], …, [11:30–12:00]`. A trailing partial slot
|
|
128
|
+
* that would overrun `end` is not emitted.
|
|
129
|
+
* @param {number} day - UTC day start, in epoch ms.
|
|
130
|
+
* @param {ITimeIntervalRange[]} ranges - Daily ranges carrying a slot `period` in minutes.
|
|
131
|
+
* @param {TimeIntervalPair[]} out - Accumulator the produced slots are pushed to.
|
|
132
|
+
*/
|
|
133
|
+
function _addSlotsFromRanges(day, ranges, out) {
|
|
134
|
+
ranges.forEach((range) => {
|
|
135
|
+
const startMinutes = _toMinutes(range === null || range === void 0 ? void 0 : range.start);
|
|
136
|
+
const endMinutes = _toMinutes(range === null || range === void 0 ? void 0 : range.end);
|
|
137
|
+
if (startMinutes === null || endMinutes === null)
|
|
138
|
+
return;
|
|
139
|
+
// A non-positive period would never advance the cursor; a non-numeric one
|
|
140
|
+
// would concatenate into it.
|
|
141
|
+
if (!Number.isFinite(range.period) || range.period <= 0)
|
|
142
|
+
return;
|
|
143
|
+
for (let minutes = startMinutes; minutes + range.period <= endMinutes; minutes += range.period) {
|
|
144
|
+
const from = day + minutes * _MS_PER_MINUTE;
|
|
145
|
+
const to = day + (minutes + range.period) * _MS_PER_MINUTE;
|
|
146
|
+
out.push([new Date(from).toISOString(), new Date(to).toISOString()]);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Deduplicates slots by value and sorts them by start, then end.
|
|
152
|
+
*
|
|
153
|
+
* A plain `Set` would not do: slots are arrays, so it would compare by
|
|
154
|
+
* reference and keep every duplicate.
|
|
155
|
+
* @param {TimeIntervalPair[]} slots - The slots to normalize.
|
|
156
|
+
* @returns {TimeIntervalPair[]} Sorted, deduplicated slots.
|
|
157
|
+
*/
|
|
158
|
+
function _dedupeAndSort(slots) {
|
|
159
|
+
const unique = new Map();
|
|
160
|
+
slots.forEach((slot) => {
|
|
161
|
+
const key = `${slot[0]}|${slot[1]}`;
|
|
162
|
+
if (!unique.has(key))
|
|
163
|
+
unique.set(key, slot);
|
|
164
|
+
});
|
|
165
|
+
return [...unique.values()].sort((a, b) => a[0].localeCompare(b[0]) || a[1].localeCompare(b[1]));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Narrows a schedule to the entity shape (pages, products, blocks, attribute sets).
|
|
169
|
+
*
|
|
170
|
+
* Entity schedules carry `times`; form schedules never do.
|
|
171
|
+
* @param {ITimeIntervalEntitySchedule | ITimeIntervalSchedule} schedule - The schedule to test.
|
|
172
|
+
* @returns {boolean} True when the schedule is an entity schedule.
|
|
173
|
+
*/
|
|
174
|
+
function _isEntitySchedule(schedule) {
|
|
175
|
+
return Array.isArray(schedule.times);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Expands a `timeInterval` schedule into concrete UTC slots for a given window.
|
|
179
|
+
*
|
|
180
|
+
* A schedule as returned by the API is a compact **recurrence rule** — an
|
|
181
|
+
* anchor date plus daily time ranges plus repeat flags — not a list of slots.
|
|
182
|
+
* Materializing it wholesale is what makes `timeInterval` attributes expensive
|
|
183
|
+
* (a year of half-hour slots runs to megabytes), so expansion is on demand and
|
|
184
|
+
* the window is required: only the caller knows how far it needs to resolve.
|
|
185
|
+
*
|
|
186
|
+
* Both schedule shapes the API returns are accepted:
|
|
187
|
+
* - **entity** — `attributeValues[marker].value[].values[]` on pages, products,
|
|
188
|
+
* blocks and attribute sets: a `dates` range with `times` pairs;
|
|
189
|
+
* - **form** — `attributes[marker].localizeInfos.intervals[]`: a `range` with
|
|
190
|
+
* `intervals` that carry a slot `period` in minutes.
|
|
191
|
+
*
|
|
192
|
+
* Semantics:
|
|
193
|
+
* - `dates[0]` / `range[0]` is both the recurrence phase and the first valid
|
|
194
|
+
* day — nothing earlier is emitted, however wide the window;
|
|
195
|
+
* - `dates[1]` / `range[1]` ends validity; when it does not extend past the
|
|
196
|
+
* start, the schedule is anchored to that day — with a recurrence flag set,
|
|
197
|
+
* recurrence is then open-ended and the window alone bounds the result;
|
|
198
|
+
* - `inEveryWeek` repeats every 7 days from the anchor; `inEveryMonth` repeats
|
|
199
|
+
* on the same day-of-month, skipping months that are too short; with both set
|
|
200
|
+
* the weekly rule applies, which is what it has always meant in practice;
|
|
201
|
+
* - with neither flag the schedule is a plain date range — every day of it;
|
|
202
|
+
* - the result is deduplicated and sorted by start, then end.
|
|
203
|
+
* @param {ITimeIntervalEntitySchedule | ITimeIntervalSchedule} schedule - A single schedule entry from a `timeInterval` attribute.
|
|
204
|
+
* @param {ITimeIntervalWindow} window - Inclusive `{ from, to }` range to resolve, compared at UTC day granularity.
|
|
205
|
+
* @returns {TimeIntervalPair[]} Sorted, deduplicated `[start, end]` ISO pairs; empty when the schedule is malformed or does not overlap the window.
|
|
206
|
+
* To expand a whole attribute at once, prefer {@link expandAttributeTimeIntervals}
|
|
207
|
+
* — it walks the groups and merges the results for you. Reach for this function
|
|
208
|
+
* directly when you already hold a single schedule, e.g. a form's
|
|
209
|
+
* `localizeInfos.intervals[]`.
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { expandTimeIntervals } from 'oneentry';
|
|
213
|
+
*
|
|
214
|
+
* // Form attributes are an array keyed by `marker`, and carry their schedules
|
|
215
|
+
* // already typed on `localizeInfos.intervals`.
|
|
216
|
+
* const field = form.attributes.find((a) => a.marker === 'booking');
|
|
217
|
+
*
|
|
218
|
+
* const slots = (field?.localizeInfos.intervals ?? []).flatMap((schedule) =>
|
|
219
|
+
* expandTimeIntervals(schedule, { from: '2025-05-01', to: '2025-05-31' }),
|
|
220
|
+
* );
|
|
221
|
+
* // [['2025-05-07T09:00:00.000Z', '2025-05-07T10:00:00.000Z'], …]
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
function expandTimeIntervals(schedule, window) {
|
|
225
|
+
var _a, _b;
|
|
226
|
+
if (!schedule || !window)
|
|
227
|
+
return [];
|
|
228
|
+
const isEntity = _isEntitySchedule(schedule);
|
|
229
|
+
const bounds = isEntity ? schedule.dates : schedule.range;
|
|
230
|
+
if (!Array.isArray(bounds))
|
|
231
|
+
return [];
|
|
232
|
+
const anchor = _toUtcDayStart(bounds[0]);
|
|
233
|
+
if (anchor === null)
|
|
234
|
+
return [];
|
|
235
|
+
const windowFrom = _toUtcDayStart(window.from);
|
|
236
|
+
const windowTo = _toUtcDayStart(window.to);
|
|
237
|
+
if (windowFrom === null || windowTo === null || windowTo < windowFrom) {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
const inEveryWeek = (_a = schedule.inEveryWeek) !== null && _a !== void 0 ? _a : false;
|
|
241
|
+
const inEveryMonth = (_b = schedule.inEveryMonth) !== null && _b !== void 0 ? _b : false;
|
|
242
|
+
// An anchor-only range (start === end) means the schedule is pinned to that
|
|
243
|
+
// day; with a recurrence rule it then runs open-ended and the window is the
|
|
244
|
+
// only horizon. Otherwise the second bound ends validity.
|
|
245
|
+
const declaredEnd = _toUtcDayStart(bounds[1]);
|
|
246
|
+
const isOpenEnded = (declaredEnd === null || declaredEnd <= anchor) &&
|
|
247
|
+
(inEveryWeek || inEveryMonth);
|
|
248
|
+
const validTo = isOpenEnded
|
|
249
|
+
? Number.POSITIVE_INFINITY
|
|
250
|
+
: Math.max(anchor, declaredEnd !== null && declaredEnd !== void 0 ? declaredEnd : anchor);
|
|
251
|
+
const rangeStart = Math.max(anchor, windowFrom);
|
|
252
|
+
const rangeEnd = Math.min(validTo, windowTo);
|
|
253
|
+
if (rangeEnd < rangeStart)
|
|
254
|
+
return [];
|
|
255
|
+
const days = _resolveActiveDays(anchor, rangeStart, rangeEnd, inEveryWeek, inEveryMonth);
|
|
256
|
+
const slots = [];
|
|
257
|
+
days.forEach((day) => {
|
|
258
|
+
if (isEntity) {
|
|
259
|
+
_addSlotsFromTimes(day, schedule.times, slots);
|
|
260
|
+
}
|
|
261
|
+
else if (Array.isArray(schedule.intervals)) {
|
|
262
|
+
_addSlotsFromRanges(day, schedule.intervals, slots);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return _dedupeAndSort(slots);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Narrows an attribute value to a `timeInterval` attribute.
|
|
269
|
+
*
|
|
270
|
+
* `IAttributeValue.value` is `unknown` — its shape depends on `type` — so this
|
|
271
|
+
* guard is what lets you reach the schedules without a cast.
|
|
272
|
+
* @param {IAttributeValue | undefined} attr - The attribute value to test.
|
|
273
|
+
* @returns {boolean} True when the attribute is a `timeInterval` carrying an array of groups.
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* const attr = page.attributeValues.interval;
|
|
277
|
+
* if (isTimeIntervalAttribute(attr)) {
|
|
278
|
+
* attr.value[0].values[0].dates; // fully typed, no cast
|
|
279
|
+
* }
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
function isTimeIntervalAttribute(attr) {
|
|
283
|
+
return !!attr && attr.type === 'timeInterval' && Array.isArray(attr.value);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Expands a whole `timeInterval` attribute into concrete UTC slots for a window.
|
|
287
|
+
*
|
|
288
|
+
* The one-call path for the common case: it walks the attribute's groups and
|
|
289
|
+
* their schedules, expands each with {@link expandTimeIntervals}, and merges the
|
|
290
|
+
* results. Merging matters — deduplication and ordering only hold within a
|
|
291
|
+
* single schedule, so combining groups by hand can yield duplicate or unsorted
|
|
292
|
+
* slots.
|
|
293
|
+
*
|
|
294
|
+
* Anything that is not a `timeInterval` attribute yields an empty array, so this
|
|
295
|
+
* is safe to call on an arbitrary attribute without checking `type` first.
|
|
296
|
+
*
|
|
297
|
+
* For **form** attributes the schedules are already typed at
|
|
298
|
+
* `localizeInfos.intervals`, so no equivalent helper is needed — map over them
|
|
299
|
+
* and call {@link expandTimeIntervals} directly.
|
|
300
|
+
* @param {IAttributeValue | undefined} attr - A `timeInterval` attribute value, e.g. `page.attributeValues.interval`.
|
|
301
|
+
* @param {ITimeIntervalWindow} window - Inclusive `{ from, to }` range to resolve, compared at UTC day granularity.
|
|
302
|
+
* @returns {TimeIntervalPair[]} Sorted, deduplicated `[start, end]` ISO pairs across every group; empty when the attribute is not a `timeInterval`.
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* import { expandAttributeTimeIntervals } from 'oneentry';
|
|
306
|
+
*
|
|
307
|
+
* const slots = expandAttributeTimeIntervals(page.attributeValues.interval, {
|
|
308
|
+
* from: '2025-04-01',
|
|
309
|
+
* to: '2025-04-30',
|
|
310
|
+
* });
|
|
311
|
+
* // [['2025-04-14T09:00:00.000Z', '2025-04-14T10:00:00.000Z'], …]
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
function expandAttributeTimeIntervals(attr, window) {
|
|
315
|
+
if (!isTimeIntervalAttribute(attr))
|
|
316
|
+
return [];
|
|
317
|
+
const slots = attr.value.flatMap((group) => Array.isArray(group === null || group === void 0 ? void 0 : group.values)
|
|
318
|
+
? group.values.flatMap((schedule) => expandTimeIntervals(schedule, window))
|
|
319
|
+
: []);
|
|
320
|
+
return _dedupeAndSort(slots);
|
|
321
|
+
}
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ interface ILocalizeInfo {
|
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* @interface IAttributeLocalizeInfo
|
|
151
|
-
* @property {ITimeIntervalSchedule[]} [intervals] - For attributes of type `timeInterval`, the
|
|
151
|
+
* @property {ITimeIntervalSchedule[]} [intervals] - For attributes of type `timeInterval`, the schedule data attached to the localization payload. Each entry is a compact recurrence rule — pass it to `expandTimeIntervals` to resolve concrete slots.
|
|
152
152
|
* @description Extension of {@link ILocalizeInfo} used by attribute entities — adds attribute-type-specific fields the API exposes via `localizeInfos`.
|
|
153
153
|
*/
|
|
154
154
|
interface IAttributeLocalizeInfo extends ILocalizeInfo {
|
|
@@ -163,8 +163,9 @@ interface IAttributeLocalizeInfo extends ILocalizeInfo {
|
|
|
163
163
|
* @property {number} selectedYear - Year the schedule applies to. Example: 2025.
|
|
164
164
|
* @property {ITimeIntervalRange[]} intervals - Daily time ranges configured for the schedule.
|
|
165
165
|
* @property {unknown[]} external - External overrides; empty array when none.
|
|
166
|
-
* @property {
|
|
167
|
-
* @
|
|
166
|
+
* @property {string[]} range - Validity range as a pair of ISO dates `[from, to]`; empty array when none. When both entries are equal the schedule is anchored to that single day and its recurrence is open-ended. Example: ["2025-05-07T21:00:00.000Z", "2025-05-07T21:00:00.000Z"].
|
|
167
|
+
* @property {boolean} [inEveryWeek] - Whether the schedule repeats every week. Optional.
|
|
168
|
+
* @description One entry of a `timeInterval` **form** attribute's schedule, carried on `localizeInfos.intervals`. Holds a compact recurrence rule — pass it to `expandTimeIntervals` to resolve concrete slots for a given window.
|
|
168
169
|
*/
|
|
169
170
|
interface ITimeIntervalSchedule {
|
|
170
171
|
id: string;
|
|
@@ -173,8 +174,65 @@ interface ITimeIntervalSchedule {
|
|
|
173
174
|
selectedYear: number;
|
|
174
175
|
intervals: ITimeIntervalRange[];
|
|
175
176
|
external: unknown[];
|
|
176
|
-
range:
|
|
177
|
+
range: string[];
|
|
178
|
+
inEveryWeek?: boolean;
|
|
177
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* @interface ITimeIntervalEntitySchedule
|
|
182
|
+
* @property {string} id - Schedule entry identifier (UUID). Example: "bbc82c9f-1bc4-4c86-b83c-c062016eb7cb".
|
|
183
|
+
* @property {string} intervalId - Identifier of the parent interval group (UUID). Example: "c6466cd8-c55d-4583-97c5-42b684210f12".
|
|
184
|
+
* @property {string[]} dates - Validity range as a pair of ISO dates `[from, to]`. When both entries are equal the schedule is anchored to that single day and its recurrence is open-ended. Example: ["2025-04-14T00:00:00.000Z", "2025-04-14T00:00:00.000Z"].
|
|
185
|
+
* @property {ITimeIntervalPoint[][]} times - Daily time ranges, each a `[start, end]` pair. Example: [[{ "hours": 9, "minutes": 0 }, { "hours": 10, "minutes": 0 }]].
|
|
186
|
+
* @property {boolean} inEveryWeek - Whether the schedule repeats every week. Example: true.
|
|
187
|
+
* @property {boolean} inEveryMonth - Whether the schedule repeats every month. Example: true.
|
|
188
|
+
* @property {unknown[]} [exceptions] - Excluded dates; empty array when none. Optional.
|
|
189
|
+
* @property {ITimeIntervalRange[]} [intervals] - Slot-based ranges; empty array on entity schedules, which use `times` instead. Optional.
|
|
190
|
+
* @description One entry of a `timeInterval` attribute's schedule on pages, products, blocks and attribute sets — found at `attributeValues[marker].value[].values[]`. Holds a compact recurrence rule — pass it to `expandTimeIntervals` to resolve concrete slots for a given window.
|
|
191
|
+
*/
|
|
192
|
+
interface ITimeIntervalEntitySchedule {
|
|
193
|
+
id: string;
|
|
194
|
+
intervalId: string;
|
|
195
|
+
dates: string[];
|
|
196
|
+
times: ITimeIntervalPoint[][];
|
|
197
|
+
inEveryWeek: boolean;
|
|
198
|
+
inEveryMonth: boolean;
|
|
199
|
+
exceptions?: unknown[];
|
|
200
|
+
intervals?: ITimeIntervalRange[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @interface ITimeIntervalGroup
|
|
204
|
+
* @property {string} intervalId - Identifier of the interval group (UUID). Example: "c6466cd8-c55d-4583-97c5-42b684210f12".
|
|
205
|
+
* @property {ITimeIntervalEntitySchedule[]} values - The schedules configured under this group.
|
|
206
|
+
* @description One entry of a `timeInterval` attribute's `value` array — a group of schedules sharing an `intervalId`.
|
|
207
|
+
*/
|
|
208
|
+
interface ITimeIntervalGroup {
|
|
209
|
+
intervalId: string;
|
|
210
|
+
values: ITimeIntervalEntitySchedule[];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @interface ITimeIntervalAttributeValue
|
|
214
|
+
* @property {'timeInterval'} type - Discriminant identifying the attribute as a `timeInterval`.
|
|
215
|
+
* @property {ITimeIntervalGroup[]} value - Groups of schedules attached to the attribute.
|
|
216
|
+
* @description {@link IAttributeValue} narrowed to `timeInterval` attributes, whose generic `value: unknown` resolves to an array of {@link ITimeIntervalGroup}. Narrow to it with `isTimeIntervalAttribute`, or skip straight to the slots with `expandAttributeTimeIntervals`.
|
|
217
|
+
*/
|
|
218
|
+
interface ITimeIntervalAttributeValue extends IAttributeValue {
|
|
219
|
+
type: 'timeInterval';
|
|
220
|
+
value: ITimeIntervalGroup[];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @interface ITimeIntervalWindow
|
|
224
|
+
* @property {Date | string | number} from - Inclusive start of the window.
|
|
225
|
+
* @property {Date | string | number} to - Inclusive end of the window.
|
|
226
|
+
* @description The bounded range to expand a schedule into. Both bounds are inclusive and compared at UTC day granularity, so the time-of-day component of `from`/`to` is ignored. The window is required: a schedule is an open-ended recurrence rule, and only the caller knows how far it needs to be resolved.
|
|
227
|
+
*/
|
|
228
|
+
interface ITimeIntervalWindow {
|
|
229
|
+
from: Date | string | number;
|
|
230
|
+
to: Date | string | number;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* TimeIntervalPair — one resolved slot as a `[start, end]` pair of ISO 8601 UTC timestamps.
|
|
234
|
+
*/
|
|
235
|
+
type TimeIntervalPair = [string, string];
|
|
178
236
|
/**
|
|
179
237
|
* @interface ITimeIntervalPoint
|
|
180
238
|
* @property {number} hours - Hour component (0-23).
|
|
@@ -202,8 +260,8 @@ interface ITimeIntervalRange {
|
|
|
202
260
|
/**
|
|
203
261
|
* @interface IAttributeValue
|
|
204
262
|
* @property {string} type - Attribute data type (e.g. "string", "integer", "list", "file", "image").
|
|
205
|
-
* @property {unknown} value - Attribute value — actual TS type depends on `type`
|
|
206
|
-
* @property {number} [position] - Sort position of the value inside its set. Example: 0.
|
|
263
|
+
* @property {unknown} value - Attribute value — actual TS type depends on `type`, and the SDK normalizes it to the same shape in every module: `string` for "string"/"text"; `number | null` for "integer"/"float"/"real"; the file object itself for a single-file "image"/"file" and an array of them for several; an array for "list" and "groupOfImages". An attribute with no value is always `null`. Example: "Admins text".
|
|
264
|
+
* @property {number} [position] - Sort position of the value inside its set; the containing collection is returned sorted by it. Example: 0.
|
|
207
265
|
* @property {Record<string, IAttributeValue> | unknown[]} [additionalFields] - Nested attribute values keyed by marker; the API may also return an empty array when none are configured. Optional.
|
|
208
266
|
* @property {boolean} [isIcon] - Block/preview attribute flag — whether the field is treated as an icon. Optional.
|
|
209
267
|
* @property {boolean} [isProductPreview] - Block/preview attribute flag — whether the field is shown in product preview. Optional.
|
|
@@ -289,4 +347,4 @@ type LangType = string | Array<string>;
|
|
|
289
347
|
* LocalizeType
|
|
290
348
|
*/
|
|
291
349
|
type LocalizeType = ILocalizeInfo;
|
|
292
|
-
export type { IAttributeLocalizeInfo, IAttributes, IAttributeValue, IAttributeValues, IConfig, IError, IHttpHeaders, IHttpOptions, ILocalizeInfo, IRating, ITimeIntervalPoint, ITimeIntervalRange, ITimeIntervalSchedule, LangType, LocalizeType, };
|
|
350
|
+
export type { IAttributeLocalizeInfo, IAttributes, IAttributeValue, IAttributeValues, IConfig, IError, IHttpHeaders, IHttpOptions, ILocalizeInfo, IRating, ITimeIntervalAttributeValue, ITimeIntervalEntitySchedule, ITimeIntervalGroup, ITimeIntervalPoint, ITimeIntervalRange, ITimeIntervalSchedule, ITimeIntervalWindow, LangType, LocalizeType, TimeIntervalPair, };
|
package/dist/base/validation.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.createPaginatedSchema = createPaginatedSchema;
|
|
|
5
5
|
exports.validateResponse = validateResponse;
|
|
6
6
|
exports.validateResponseSafe = validateResponseSafe;
|
|
7
7
|
/* eslint-disable jsdoc/reject-any-type */
|
|
8
|
-
/* eslint-disable jsdoc/no-undefined-types */
|
|
9
8
|
const zod_1 = require("zod");
|
|
10
9
|
/**
|
|
11
10
|
* Common validation schemas for API responses
|
package/dist/forms/formsApi.js
CHANGED
|
@@ -38,7 +38,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
38
38
|
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
39
39
|
// Validate response if validation is enabled
|
|
40
40
|
const validated = this._validateResponse(result, formsSchemas_1.FormsResponseSchema);
|
|
41
|
-
return this.
|
|
41
|
+
return this._normalizeData(validated, langCode);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Get one form by form marker.
|
|
@@ -53,7 +53,7 @@ class FormsApi extends asyncModules_1.default {
|
|
|
53
53
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
54
54
|
// Validate response if validation is enabled
|
|
55
55
|
const validated = this._validateResponse(result, formsSchemas_1.FormEntitySchema);
|
|
56
|
-
return this.
|
|
56
|
+
return this._normalizeData(validated, langCode);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.default = FormsApi;
|
|
@@ -71,7 +71,7 @@ interface IFromPages {
|
|
|
71
71
|
* @property {string} identifier - The textual identifier for the record field. Example: "form_contact_us".
|
|
72
72
|
* @property {string} processingType - Type of form processing. Example: "async".
|
|
73
73
|
* @property {number | null} templateId - The identifier of the template used by the form, or null if no template is used. Example: 6789.
|
|
74
|
-
* @property {IFormAttribute[]} attributes - Form fields with their localization, validators and form-specific flags
|
|
74
|
+
* @property {IFormAttribute[]} attributes - Form fields with their localization, validators and form-specific flags, sorted by `position`.
|
|
75
75
|
* @property {number | string} [total] - Total count of related entries. Example: "1".
|
|
76
76
|
* @property {IFormConfig[]} [moduleFormConfigs] - Array of module form configurations associated with the form.
|
|
77
77
|
* @description This interface defines the structure of a form entity, including its identifiers, attributes, and processing data.
|
|
@@ -79,7 +79,7 @@ interface IFromPages {
|
|
|
79
79
|
interface IFormsEntity {
|
|
80
80
|
id: number;
|
|
81
81
|
attributeSetId: number | null;
|
|
82
|
-
type: 'order' | '
|
|
82
|
+
type: 'order' | 'sign_in_up' | 'collection' | 'data' | 'rating' | null;
|
|
83
83
|
localizeInfos: IFormLocalizeInfo;
|
|
84
84
|
version: number;
|
|
85
85
|
position: number;
|
|
@@ -153,7 +153,7 @@ interface IFormAttribute {
|
|
|
153
153
|
* @interface IFormAttributeAdditionalField
|
|
154
154
|
* @property {string} marker - Marker of the additional field. Example: "additional_field".
|
|
155
155
|
* @property {string} type - Type of the additional field. Example: "string".
|
|
156
|
-
* @property {unknown} value - Value of the additional field. Example: "Additional field data".
|
|
156
|
+
* @property {unknown} value - Value of the additional field, normalized like any other attribute value: `number | null` for numeric types, the file object itself for a single-file `image`/`file`, `null` when empty. Example: "Additional field data".
|
|
157
157
|
* @description A single nested entry inside {@link IFormAttribute}'s `additionalFields` map.
|
|
158
158
|
*/
|
|
159
159
|
interface IFormAttributeAdditionalField {
|
|
@@ -123,7 +123,7 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
123
123
|
const result = await this._fetchPost(``, body);
|
|
124
124
|
// Validate response if validation is enabled
|
|
125
125
|
const validated = this._validateResponse(result, formsDataSchemas_1.PostFormResponseSchema);
|
|
126
|
-
return this.
|
|
126
|
+
return this._normalizeData(validated);
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Get one object of form data by marker.
|
|
@@ -152,7 +152,7 @@ class FormsDataApi extends asyncModules_1.default {
|
|
|
152
152
|
const result = await this._fetchPost(`/marker/${marker}?formModuleConfigId=${formModuleConfigId}&isExtended=${isExtended}&langCode=${langCode}&offset=${offset}&limit=${limit}`, body);
|
|
153
153
|
// Validate response if validation is enabled
|
|
154
154
|
const validated = this._validateResponse(result, formsDataSchemas_1.FormsByMarkerDataResponseSchema);
|
|
155
|
-
return this.
|
|
155
|
+
return this._normalizeData(validated, langCode);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Update one object of form data by id. Requires user authentication.
|
|
@@ -346,13 +346,13 @@ interface IBodyPostFormData {
|
|
|
346
346
|
* @interface IBodyTypeStringNumberFloat
|
|
347
347
|
* @property {string} marker - marker name. Example: "some_marker".
|
|
348
348
|
* @property {string} type - Type value. "string" | "number" | "float". Example: "string".
|
|
349
|
-
* @property {string} value - Value of the form data entity
|
|
349
|
+
* @property {string | number | null} value - Value of the form data entity. Send it as a string; in responses numeric fields come back normalized to `number`, or `null` when the field is empty. Example: "string".
|
|
350
350
|
* @description Represents a form data entity with a marker, type, and value.
|
|
351
351
|
*/
|
|
352
352
|
interface IBodyTypeStringNumberFloat {
|
|
353
353
|
marker: string;
|
|
354
354
|
type: 'string' | 'number' | 'float';
|
|
355
|
-
value: string;
|
|
355
|
+
value: string | number | null;
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
358
|
* Represents a date/time form data entity.
|
|
@@ -520,7 +520,7 @@ interface IImageValue {
|
|
|
520
520
|
* @interface IBodyTypeFile
|
|
521
521
|
* @property {string} marker - marker name. Example: "picture".
|
|
522
522
|
* @property {'file'} type - Type value. Example: "file".
|
|
523
|
-
* @property {object} value - File Object. Contains file information.
|
|
523
|
+
* @property {object} value - File Object. Contains file information. A single attached file is returned as the object itself, several files as an array.
|
|
524
524
|
* @example
|
|
525
525
|
[
|
|
526
526
|
{
|
|
@@ -534,7 +534,7 @@ interface IImageValue {
|
|
|
534
534
|
interface IBodyTypeFile {
|
|
535
535
|
marker: string;
|
|
536
536
|
type: 'file';
|
|
537
|
-
value: IFileValue;
|
|
537
|
+
value: IFileValue | IFileValue[];
|
|
538
538
|
}
|
|
539
539
|
/**
|
|
540
540
|
* @interface IFileValue
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import AdminsApi from './admins/adminsApi';
|
|
5
5
|
import AttributesSetsApi from './attribute-sets/attributeSetsApi';
|
|
6
6
|
import AuthProviderApi from './auth-provider/authProviderApi';
|
|
7
|
-
import type { IConfig } from './base/utils';
|
|
7
|
+
import type { IAttributeValue, IConfig, ITimeIntervalAttributeValue, ITimeIntervalEntitySchedule, ITimeIntervalGroup, ITimeIntervalSchedule, ITimeIntervalWindow, TimeIntervalPair } from './base/utils';
|
|
8
8
|
import BlocksApi from './blocks/blocksApi';
|
|
9
9
|
import DiscountsApi from './discounts/discountsApi';
|
|
10
10
|
import EventsApi from './events/eventsApi';
|
|
@@ -29,6 +29,8 @@ import TemplatePreviewsApi from './templates-preview/templatesPreviewApi';
|
|
|
29
29
|
import UserActivityApi from './user-activity/userActivityApi';
|
|
30
30
|
import UsersApi from './users/usersApi';
|
|
31
31
|
import WsApi from './web-socket/wsApi';
|
|
32
|
+
export { expandAttributeTimeIntervals, expandTimeIntervals, isTimeIntervalAttribute, } from './base/timeIntervals';
|
|
33
|
+
export type { IAttributeValue, ITimeIntervalAttributeValue, ITimeIntervalEntitySchedule, ITimeIntervalGroup, ITimeIntervalSchedule, ITimeIntervalWindow, TimeIntervalPair, };
|
|
32
34
|
/**
|
|
33
35
|
* IDefineApi interface
|
|
34
36
|
* @interface IDefineApi
|
|
@@ -135,4 +137,3 @@ interface IDefineApi {
|
|
|
135
137
|
* @description Define API.
|
|
136
138
|
*/
|
|
137
139
|
export declare function defineOneEntry(url: string, config: IConfig): IDefineApi;
|
|
138
|
-
export {};
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isTimeIntervalAttribute = exports.expandTimeIntervals = exports.expandAttributeTimeIntervals = void 0;
|
|
6
7
|
exports.defineOneEntry = defineOneEntry;
|
|
7
8
|
/**
|
|
8
9
|
* OneEntry SDK
|
|
@@ -35,6 +36,10 @@ const templatesPreviewApi_1 = __importDefault(require("./templates-preview/templ
|
|
|
35
36
|
const userActivityApi_1 = __importDefault(require("./user-activity/userActivityApi"));
|
|
36
37
|
const usersApi_1 = __importDefault(require("./users/usersApi"));
|
|
37
38
|
const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
|
|
39
|
+
var timeIntervals_1 = require("./base/timeIntervals");
|
|
40
|
+
Object.defineProperty(exports, "expandAttributeTimeIntervals", { enumerable: true, get: function () { return timeIntervals_1.expandAttributeTimeIntervals; } });
|
|
41
|
+
Object.defineProperty(exports, "expandTimeIntervals", { enumerable: true, get: function () { return timeIntervals_1.expandTimeIntervals; } });
|
|
42
|
+
Object.defineProperty(exports, "isTimeIntervalAttribute", { enumerable: true, get: function () { return timeIntervals_1.isTimeIntervalAttribute; } });
|
|
38
43
|
/**
|
|
39
44
|
* Define API.
|
|
40
45
|
* @function defineOneEntry
|
|
@@ -52,7 +52,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
52
52
|
const result = await this._fetchGet(`?` + this._queryParamsToString(query));
|
|
53
53
|
// Validate response if validation is enabled
|
|
54
54
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionsResponseSchema);
|
|
55
|
-
return this.
|
|
55
|
+
return this._normalizeData(validated, langCode);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Get a single collection object by id.
|
|
@@ -67,7 +67,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
67
67
|
const result = await this._fetchGet(`/${id}?` + this._queryParamsToString({ langCode }));
|
|
68
68
|
// Validate response if validation is enabled
|
|
69
69
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionEntitySchema);
|
|
70
|
-
return this.
|
|
70
|
+
return this._normalizeData(validated, langCode);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Get all records belonging to the collection by collection id.
|
|
@@ -100,7 +100,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
100
100
|
}));
|
|
101
101
|
// Validate response if validation is enabled
|
|
102
102
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowsResponseSchema);
|
|
103
|
-
return this.
|
|
103
|
+
return this._normalizeData(validated, langCode);
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Check for the existence of a text identifier (marker).
|
|
@@ -119,7 +119,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
119
119
|
const result = await this._fetchGet(`/marker-validation/${marker}`);
|
|
120
120
|
// Validate response if validation is enabled
|
|
121
121
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionIsValidSchema);
|
|
122
|
-
return this.
|
|
122
|
+
return this._normalizeData(validated);
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Getting all records from the collection.
|
|
@@ -134,7 +134,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
134
134
|
const result = await this._fetchGet(`/marker/${marker}/rows?langCode=${langCode}`);
|
|
135
135
|
// Validate response if validation is enabled
|
|
136
136
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowsResponseSchema);
|
|
137
|
-
return this.
|
|
137
|
+
return this._normalizeData(validated, langCode);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Getting one record from the collection.
|
|
@@ -150,7 +150,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
|
|
|
150
150
|
const result = await this._fetchGet(`/marker/${marker}/rows/${id}?langCode=${langCode}`);
|
|
151
151
|
// Validate response if validation is enabled
|
|
152
152
|
const validated = this._validateResponse(result, integrationCollectionsSchemas_1.CollectionRowSchema);
|
|
153
|
-
return this.
|
|
153
|
+
return this._normalizeData(validated, langCode);
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Create a record in the collection.
|
|
@@ -244,6 +244,8 @@ interface ICollectionFormObject {
|
|
|
244
244
|
* @property {string | null} entityType - Type of the entity associated with the collection row. Example: "product", "order", "etc".
|
|
245
245
|
* @property {number | null} entityId - Identifier of the entity associated with the collection row. Example: 12345.
|
|
246
246
|
* @property {string | null} [attributeSetIdentifier] - Identifier of the attribute set used by the form attached to the collection row, or null if not applicable. Example: "attributeSet1" or null.
|
|
247
|
+
* @property {string | null} [langCode] - Language code the row was stored under. Example: "en_US".
|
|
248
|
+
* @property {string | null} [formIdentifier] - Text identifier of the form the row was created from; returned by the create/update row endpoints. Example: "collection_form".
|
|
247
249
|
* @property {string} total - Total count. Example: "1".
|
|
248
250
|
* @description Represents a row in a collection, containing various properties such as identifiers, dates, form data, and an optional total value.
|
|
249
251
|
*/
|
|
@@ -256,6 +258,8 @@ interface ICollectionRow {
|
|
|
256
258
|
entityType: string | null;
|
|
257
259
|
entityId: number | null;
|
|
258
260
|
attributeSetIdentifier?: string | null;
|
|
261
|
+
langCode?: string | null;
|
|
262
|
+
formIdentifier?: string | null;
|
|
259
263
|
total?: string;
|
|
260
264
|
}
|
|
261
265
|
/**
|