merchi_sdk_ts 1.9.10 → 1.9.11
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/dist/entities/job.js +4 -0
- package/dist/entities/notification.test.js +30 -0
- package/dist/entity.js +8 -0
- package/package.json +1 -1
- package/src/entities/job.ts +3 -0
- package/src/entities/notification.test.ts +34 -0
- package/src/entity.ts +22 -1
package/dist/entities/job.js
CHANGED
|
@@ -238,6 +238,10 @@ var Job = /** @class */ (function (_super) {
|
|
|
238
238
|
Job.property({ type: Date }),
|
|
239
239
|
__metadata("design:type", Object)
|
|
240
240
|
], Job.prototype, "dateLastActioned", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
Job.property({ type: Date }),
|
|
243
|
+
__metadata("design:type", Object)
|
|
244
|
+
], Job.prototype, "dateFirstActioned", void 0);
|
|
241
245
|
__decorate([
|
|
242
246
|
Job.property(),
|
|
243
247
|
__metadata("design:type", Date)
|
|
@@ -19,3 +19,33 @@ test('can list notifications with notificationSender filter', function () {
|
|
|
19
19
|
expect(query).toContainEqual(['notification_sender', '123']);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
+
test('list forwards skipCount=true as skip_count query param', function () {
|
|
23
|
+
var merchi = new Merchi();
|
|
24
|
+
var fetch = mockFetch(true, {
|
|
25
|
+
'notifications': [],
|
|
26
|
+
// backend returns ``available: null`` when skip_count was honoured
|
|
27
|
+
'available': null,
|
|
28
|
+
'count': 0
|
|
29
|
+
}, 200);
|
|
30
|
+
var options = { skipCount: true };
|
|
31
|
+
return merchi.Notification.list(options).then(function (response) {
|
|
32
|
+
var query = fetch.mock.calls[0][1]['query'];
|
|
33
|
+
expect(query).toContainEqual(['skip_count', 'true']);
|
|
34
|
+
// ``available`` must round-trip as ``null``; the typed metadata
|
|
35
|
+
// is now ``number | null``, so consumers can detect the absence.
|
|
36
|
+
expect(response.metadata.available).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test('list omits skip_count when skipCount is not set', function () {
|
|
40
|
+
var merchi = new Merchi();
|
|
41
|
+
var fetch = mockFetch(true, {
|
|
42
|
+
'notifications': [],
|
|
43
|
+
'available': 0,
|
|
44
|
+
'count': 0
|
|
45
|
+
}, 200);
|
|
46
|
+
return merchi.Notification.list({}).then(function () {
|
|
47
|
+
var query = fetch.mock.calls[0][1]['query'];
|
|
48
|
+
var skipCountEntries = query.filter(function (entry) { return entry[0] === 'skip_count'; });
|
|
49
|
+
expect(skipCountEntries).toEqual([]);
|
|
50
|
+
});
|
|
51
|
+
});
|
package/dist/entity.js
CHANGED
|
@@ -614,6 +614,14 @@ var Entity = /** @class */ (function () {
|
|
|
614
614
|
if (options.limit !== undefined) {
|
|
615
615
|
fetchOptions.query.push(['limit', options.limit.toString()]);
|
|
616
616
|
}
|
|
617
|
+
if (options.skipCount !== undefined) {
|
|
618
|
+
// Snake-case is the canonical form on the server; the API
|
|
619
|
+
// also accepts ``skipCount`` via its camelCase alias, but
|
|
620
|
+
// matching the wire shape of the other ``*_only`` /
|
|
621
|
+
// ``*_filter`` flags keeps logs and traffic captures
|
|
622
|
+
// consistent.
|
|
623
|
+
fetchOptions.query.push(['skip_count', options.skipCount.toString()]);
|
|
624
|
+
}
|
|
617
625
|
if (options.q !== undefined) {
|
|
618
626
|
fetchOptions.query.push(['q', options.q]);
|
|
619
627
|
}
|
package/package.json
CHANGED
package/src/entities/job.ts
CHANGED
|
@@ -145,6 +145,9 @@ export class Job extends Entity {
|
|
|
145
145
|
@Job.property({type: Date})
|
|
146
146
|
public dateLastActioned?: Date | null;
|
|
147
147
|
|
|
148
|
+
@Job.property({type: Date})
|
|
149
|
+
public dateFirstActioned?: Date | null;
|
|
150
|
+
|
|
148
151
|
@Job.property()
|
|
149
152
|
public groupBuyProductionStarted?: Date;
|
|
150
153
|
|
|
@@ -22,3 +22,37 @@ test('can list notifications with notificationSender filter', () => {
|
|
|
22
22
|
expect(query).toContainEqual(['notification_sender', '123']);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
test('list forwards skipCount=true as skip_count query param', () => {
|
|
27
|
+
const merchi = new Merchi();
|
|
28
|
+
const fetch = mockFetch(true, {
|
|
29
|
+
'notifications': [],
|
|
30
|
+
// backend returns ``available: null`` when skip_count was honoured
|
|
31
|
+
'available': null,
|
|
32
|
+
'count': 0
|
|
33
|
+
}, 200);
|
|
34
|
+
const options = { skipCount: true };
|
|
35
|
+
return merchi.Notification.list(options).then((response) => {
|
|
36
|
+
const query = fetch.mock.calls[0][1]['query'];
|
|
37
|
+
expect(query).toContainEqual(['skip_count', 'true']);
|
|
38
|
+
// ``available`` must round-trip as ``null``; the typed metadata
|
|
39
|
+
// is now ``number | null``, so consumers can detect the absence.
|
|
40
|
+
expect(response.metadata.available).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('list omits skip_count when skipCount is not set', () => {
|
|
45
|
+
const merchi = new Merchi();
|
|
46
|
+
const fetch = mockFetch(true, {
|
|
47
|
+
'notifications': [],
|
|
48
|
+
'available': 0,
|
|
49
|
+
'count': 0
|
|
50
|
+
}, 200);
|
|
51
|
+
return merchi.Notification.list({}).then(() => {
|
|
52
|
+
const query = fetch.mock.calls[0][1]['query'];
|
|
53
|
+
const skipCountEntries = query.filter(
|
|
54
|
+
(entry: [string, string]) => entry[0] === 'skip_count'
|
|
55
|
+
);
|
|
56
|
+
expect(skipCountEntries).toEqual([]);
|
|
57
|
+
});
|
|
58
|
+
});
|
package/src/entity.ts
CHANGED
|
@@ -159,11 +159,22 @@ interface ListOptions {
|
|
|
159
159
|
teamOnly?: boolean;
|
|
160
160
|
turnaroundTimeDays?: number;
|
|
161
161
|
withRights?: boolean;
|
|
162
|
+
// Opt out of the unbounded ``SELECT count(*)`` the API runs to
|
|
163
|
+
// populate ``available``. When ``skipCount`` is true the response's
|
|
164
|
+
// ``available`` is ``null``. Use this whenever the caller only
|
|
165
|
+
// renders the visible page of rows (search modals, autocomplete,
|
|
166
|
+
// navbar dropdowns, infinite scroll, ...) and never reads
|
|
167
|
+
// ``metadata.available``. Paginated tables that show "Showing X
|
|
168
|
+
// of Y" or compute a page count must NOT set this.
|
|
169
|
+
skipCount?: boolean;
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
export interface ListMetadata {
|
|
165
173
|
canCreate?: boolean;
|
|
166
|
-
|
|
174
|
+
// ``null`` when the caller passed ``skipCount: true``: the API
|
|
175
|
+
// intentionally skipped the ``COUNT(*)`` query. JSON consumers
|
|
176
|
+
// can detect the absence rather than mistaking it for zero.
|
|
177
|
+
available: number | null;
|
|
167
178
|
count: number;
|
|
168
179
|
limit: number;
|
|
169
180
|
offset: number;
|
|
@@ -417,6 +428,16 @@ export class Entity {
|
|
|
417
428
|
if (options.limit !== undefined) {
|
|
418
429
|
fetchOptions.query.push(['limit', options.limit.toString()]);
|
|
419
430
|
}
|
|
431
|
+
if (options.skipCount !== undefined) {
|
|
432
|
+
// Snake-case is the canonical form on the server; the API
|
|
433
|
+
// also accepts ``skipCount`` via its camelCase alias, but
|
|
434
|
+
// matching the wire shape of the other ``*_only`` /
|
|
435
|
+
// ``*_filter`` flags keeps logs and traffic captures
|
|
436
|
+
// consistent.
|
|
437
|
+
fetchOptions.query.push(
|
|
438
|
+
['skip_count', options.skipCount.toString()]
|
|
439
|
+
);
|
|
440
|
+
}
|
|
420
441
|
if (options.q !== undefined) {
|
|
421
442
|
fetchOptions.query.push(['q', options.q]);
|
|
422
443
|
}
|