merchi_sdk_ts 1.9.10 → 1.9.12

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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_ts",
3
- "version": "1.9.10",
3
+ "version": "1.9.12",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:merchisdk/merchi_sdk_ts.git",
@@ -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
@@ -105,6 +105,7 @@ interface ListOptions {
105
105
  inDomain?: number;
106
106
  inDomainName?: string;
107
107
  inDomainRoles?: number[];
108
+ isJobManager?: boolean;
108
109
  isMaster?: boolean;
109
110
  isOrder?: boolean;
110
111
  isPrivate?: boolean;
@@ -159,11 +160,22 @@ interface ListOptions {
159
160
  teamOnly?: boolean;
160
161
  turnaroundTimeDays?: number;
161
162
  withRights?: boolean;
163
+ // Opt out of the unbounded ``SELECT count(*)`` the API runs to
164
+ // populate ``available``. When ``skipCount`` is true the response's
165
+ // ``available`` is ``null``. Use this whenever the caller only
166
+ // renders the visible page of rows (search modals, autocomplete,
167
+ // navbar dropdowns, infinite scroll, ...) and never reads
168
+ // ``metadata.available``. Paginated tables that show "Showing X
169
+ // of Y" or compute a page count must NOT set this.
170
+ skipCount?: boolean;
162
171
  }
163
172
 
164
173
  export interface ListMetadata {
165
174
  canCreate?: boolean;
166
- available: number;
175
+ // ``null`` when the caller passed ``skipCount: true``: the API
176
+ // intentionally skipped the ``COUNT(*)`` query. JSON consumers
177
+ // can detect the absence rather than mistaking it for zero.
178
+ available: number | null;
167
179
  count: number;
168
180
  limit: number;
169
181
  offset: number;
@@ -417,6 +429,16 @@ export class Entity {
417
429
  if (options.limit !== undefined) {
418
430
  fetchOptions.query.push(['limit', options.limit.toString()]);
419
431
  }
432
+ if (options.skipCount !== undefined) {
433
+ // Snake-case is the canonical form on the server; the API
434
+ // also accepts ``skipCount`` via its camelCase alias, but
435
+ // matching the wire shape of the other ``*_only`` /
436
+ // ``*_filter`` flags keeps logs and traffic captures
437
+ // consistent.
438
+ fetchOptions.query.push(
439
+ ['skip_count', options.skipCount.toString()]
440
+ );
441
+ }
420
442
  if (options.q !== undefined) {
421
443
  fetchOptions.query.push(['q', options.q]);
422
444
  }
@@ -463,6 +485,10 @@ export class Entity {
463
485
  if (options.asRole !== undefined) {
464
486
  fetchOptions.query.push(['as_role', options.asRole.toString()]);
465
487
  }
488
+ if (options.isJobManager !== undefined) {
489
+ fetchOptions.query.push(
490
+ ['is_job_manager', options.isJobManager.toString()]);
491
+ }
466
492
  if (options.groupBuyOnly !== undefined) {
467
493
  fetchOptions.query.push(
468
494
  ['group_buy_only', options.groupBuyOnly.toString()]);