merchi_sdk_ts 1.9.0 → 1.9.1

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.
@@ -49,6 +49,57 @@ var Domain = /** @class */ (function (_super) {
49
49
  }
50
50
  return _this.activeTheme;
51
51
  };
52
+ _this.getDomainId = function () {
53
+ if (_this.id === undefined || _this.id === null) {
54
+ throw new Error('id is undefined, did you forget to set it?');
55
+ }
56
+ return _this.id;
57
+ };
58
+ _this.storefrontV2DomainResource = function (suffix) {
59
+ if (suffix === void 0) { suffix = ''; }
60
+ return "/domains/".concat(_this.getDomainId(), "/storefront_v2/").concat(suffix);
61
+ };
62
+ _this.storefrontV2Request = function (resource, method, payload) {
63
+ var fetchOptions = {
64
+ method: method,
65
+ query: [['skip_rights', 'y']]
66
+ };
67
+ if (payload !== undefined) {
68
+ fetchOptions.body = JSON.stringify(payload);
69
+ fetchOptions.headers = { 'Content-Type': 'application/json' };
70
+ }
71
+ return _this.merchi.authenticatedFetch(resource, fetchOptions);
72
+ };
73
+ _this.getStorefrontV2 = function () {
74
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource(), 'GET');
75
+ };
76
+ _this.provisionStorefrontV2 = function (payload) {
77
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource('provision/'), 'POST', payload);
78
+ };
79
+ _this.createStorefrontChangeRequest = function (payload) {
80
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource('requests/'), 'POST', payload);
81
+ };
82
+ _this.getStorefrontChangeRequest = function (requestId) {
83
+ return _this.storefrontV2Request("/storefront_change_requests/".concat(String(requestId), "/"), 'GET');
84
+ };
85
+ _this.runStorefrontChangeRequest = function (requestId, payload) {
86
+ return _this.storefrontV2Request("/storefront_change_requests/".concat(String(requestId), "/run/"), 'POST', payload);
87
+ };
88
+ _this.approveStorefrontChangeRequest = function (requestId, payload) {
89
+ return _this.storefrontV2Request("/storefront_change_requests/".concat(String(requestId), "/approve/"), 'POST', payload);
90
+ };
91
+ _this.rejectStorefrontChangeRequest = function (requestId, payload) {
92
+ return _this.storefrontV2Request("/storefront_change_requests/".concat(String(requestId), "/reject/"), 'POST', payload);
93
+ };
94
+ _this.getStorefrontV2Deployments = function () {
95
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource('deployments/'), 'GET');
96
+ };
97
+ _this.getStorefrontV2DeploymentLogs = function (deploymentId) {
98
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource("deployments/".concat(String(deploymentId), "/logs/")), 'GET');
99
+ };
100
+ _this.rollbackStorefrontV2 = function (payload) {
101
+ return _this.storefrontV2Request(_this.storefrontV2DomainResource('rollback/'), 'POST', payload);
102
+ };
52
103
  return _this;
53
104
  }
54
105
  Domain.resourceName = 'domains';
@@ -66,3 +66,129 @@ test('fail to delete non-existant domain', function () {
66
66
  expect(fetch.mock.calls[0][1].method).toBe('DELETE');
67
67
  return invocation.catch(function (e) { return expect(e.statusCode).toEqual(404); });
68
68
  });
69
+ test('can get storefront v2 config', function () {
70
+ var merchi = new Merchi();
71
+ var domain = new merchi.Domain();
72
+ domain.id = 42;
73
+ var fetch = mockFetch(true, {}, 200);
74
+ domain.getStorefrontV2();
75
+ var fetchUrl = fetch.mock.calls[0][0];
76
+ var query = fetch.mock.calls[0][1].query;
77
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
78
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/');
79
+ expect(query).toContainEqual(['skip_rights', 'y']);
80
+ });
81
+ test('can provision storefront v2', function () {
82
+ var merchi = new Merchi();
83
+ var domain = new merchi.Domain();
84
+ domain.id = 42;
85
+ var fetch = mockFetch(true, {}, 200);
86
+ domain.provisionStorefrontV2({ force: true });
87
+ var fetchUrl = fetch.mock.calls[0][0];
88
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
89
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
90
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/provision/');
91
+ expect(body).toEqual({ force: true });
92
+ });
93
+ test('can create storefront v2 change request', function () {
94
+ var merchi = new Merchi();
95
+ var domain = new merchi.Domain();
96
+ domain.id = 42;
97
+ var fetch = mockFetch(true, {}, 200);
98
+ domain.createStorefrontChangeRequest({ prompt: 'update hero' });
99
+ var fetchUrl = fetch.mock.calls[0][0];
100
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
101
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
102
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/requests/');
103
+ expect(body).toEqual({ prompt: 'update hero' });
104
+ });
105
+ test('can get storefront v2 change request by id', function () {
106
+ var merchi = new Merchi();
107
+ var domain = new merchi.Domain();
108
+ var fetch = mockFetch(true, {}, 200);
109
+ domain.getStorefrontChangeRequest(9);
110
+ var fetchUrl = fetch.mock.calls[0][0];
111
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
112
+ expect(fetchUrl).toContain('/storefront_change_requests/9/');
113
+ });
114
+ test('can run storefront v2 change request', function () {
115
+ var merchi = new Merchi();
116
+ var domain = new merchi.Domain();
117
+ var fetch = mockFetch(true, {}, 200);
118
+ domain.runStorefrontChangeRequest(9, {
119
+ status: 'running',
120
+ pullRequestNumber: 42,
121
+ checksSummary: {
122
+ overall: 'passing',
123
+ counts: { total: 4, passed: 4, failed: 0, pending: 0, neutral: 0 },
124
+ },
125
+ checksUpdatedAt: '2026-05-15T00:00:00Z',
126
+ });
127
+ var fetchUrl = fetch.mock.calls[0][0];
128
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
129
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
130
+ expect(fetchUrl).toContain('/storefront_change_requests/9/run/');
131
+ expect(body).toEqual({
132
+ status: 'running',
133
+ pullRequestNumber: 42,
134
+ checksSummary: {
135
+ overall: 'passing',
136
+ counts: { total: 4, passed: 4, failed: 0, pending: 0, neutral: 0 },
137
+ },
138
+ checksUpdatedAt: '2026-05-15T00:00:00Z',
139
+ });
140
+ });
141
+ test('can approve storefront v2 change request', function () {
142
+ var merchi = new Merchi();
143
+ var domain = new merchi.Domain();
144
+ var fetch = mockFetch(true, {}, 200);
145
+ domain.approveStorefrontChangeRequest(9, { comment: 'looks good' });
146
+ var fetchUrl = fetch.mock.calls[0][0];
147
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
148
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
149
+ expect(fetchUrl).toContain('/storefront_change_requests/9/approve/');
150
+ expect(body).toEqual({ comment: 'looks good' });
151
+ });
152
+ test('can reject storefront v2 change request', function () {
153
+ var merchi = new Merchi();
154
+ var domain = new merchi.Domain();
155
+ var fetch = mockFetch(true, {}, 200);
156
+ domain.rejectStorefrontChangeRequest(9, { reason: 'needs edits' });
157
+ var fetchUrl = fetch.mock.calls[0][0];
158
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
159
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
160
+ expect(fetchUrl).toContain('/storefront_change_requests/9/reject/');
161
+ expect(body).toEqual({ reason: 'needs edits' });
162
+ });
163
+ test('can get storefront v2 deployments', function () {
164
+ var merchi = new Merchi();
165
+ var domain = new merchi.Domain();
166
+ domain.id = 42;
167
+ var fetch = mockFetch(true, {}, 200);
168
+ domain.getStorefrontV2Deployments();
169
+ var fetchUrl = fetch.mock.calls[0][0];
170
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
171
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/deployments/');
172
+ });
173
+ test('can get storefront v2 deployment logs', function () {
174
+ var merchi = new Merchi();
175
+ var domain = new merchi.Domain();
176
+ domain.id = 42;
177
+ var fetch = mockFetch(true, {}, 200);
178
+ domain.getStorefrontV2DeploymentLogs('dep_123');
179
+ var fetchUrl = fetch.mock.calls[0][0];
180
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
181
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/deployments/dep_123/logs/');
182
+ });
183
+ test('can rollback storefront v2 deployment', function () {
184
+ var merchi = new Merchi();
185
+ var domain = new merchi.Domain();
186
+ domain.id = 42;
187
+ var fetch = mockFetch(true, {}, 200);
188
+ domain.rollbackStorefrontV2({ deploymentId: 'dep_123' });
189
+ var fetchUrl = fetch.mock.calls[0][0];
190
+ var body = JSON.parse(fetch.mock.calls[0][1].body);
191
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
192
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/rollback/');
193
+ expect(body).toEqual({ deploymentId: 'dep_123' });
194
+ });
@@ -19,33 +19,3 @@ 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,14 +614,6 @@ 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
- }
625
617
  if (options.q !== undefined) {
626
618
  fetchOptions.query.push(['q', options.q]);
627
619
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_ts",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:merchisdk/merchi_sdk_ts.git",
@@ -77,3 +77,139 @@ test('fail to delete non-existant domain', () => {
77
77
  expect(fetch.mock.calls[0][1].method).toBe('DELETE');
78
78
  return invocation.catch(e => expect(e.statusCode).toEqual(404));
79
79
  });
80
+
81
+ test('can get storefront v2 config', () => {
82
+ const merchi = new Merchi();
83
+ const domain = new merchi.Domain();
84
+ domain.id = 42;
85
+ const fetch = mockFetch(true, {}, 200);
86
+ domain.getStorefrontV2();
87
+ const fetchUrl = fetch.mock.calls[0][0];
88
+ const query = fetch.mock.calls[0][1].query;
89
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
90
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/');
91
+ expect(query).toContainEqual(['skip_rights', 'y']);
92
+ });
93
+
94
+ test('can provision storefront v2', () => {
95
+ const merchi = new Merchi();
96
+ const domain = new merchi.Domain();
97
+ domain.id = 42;
98
+ const fetch = mockFetch(true, {}, 200);
99
+ domain.provisionStorefrontV2({force: true});
100
+ const fetchUrl = fetch.mock.calls[0][0];
101
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
102
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
103
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/provision/');
104
+ expect(body).toEqual({force: true});
105
+ });
106
+
107
+ test('can create storefront v2 change request', () => {
108
+ const merchi = new Merchi();
109
+ const domain = new merchi.Domain();
110
+ domain.id = 42;
111
+ const fetch = mockFetch(true, {}, 200);
112
+ domain.createStorefrontChangeRequest({prompt: 'update hero'});
113
+ const fetchUrl = fetch.mock.calls[0][0];
114
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
115
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
116
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/requests/');
117
+ expect(body).toEqual({prompt: 'update hero'});
118
+ });
119
+
120
+ test('can get storefront v2 change request by id', () => {
121
+ const merchi = new Merchi();
122
+ const domain = new merchi.Domain();
123
+ const fetch = mockFetch(true, {}, 200);
124
+ domain.getStorefrontChangeRequest(9);
125
+ const fetchUrl = fetch.mock.calls[0][0];
126
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
127
+ expect(fetchUrl).toContain('/storefront_change_requests/9/');
128
+ });
129
+
130
+ test('can run storefront v2 change request', () => {
131
+ const merchi = new Merchi();
132
+ const domain = new merchi.Domain();
133
+ const fetch = mockFetch(true, {}, 200);
134
+ domain.runStorefrontChangeRequest(9, {
135
+ status: 'running',
136
+ pullRequestNumber: 42,
137
+ checksSummary: {
138
+ overall: 'passing',
139
+ counts: {total: 4, passed: 4, failed: 0, pending: 0, neutral: 0},
140
+ },
141
+ checksUpdatedAt: '2026-05-15T00:00:00Z',
142
+ });
143
+ const fetchUrl = fetch.mock.calls[0][0];
144
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
145
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
146
+ expect(fetchUrl).toContain('/storefront_change_requests/9/run/');
147
+ expect(body).toEqual({
148
+ status: 'running',
149
+ pullRequestNumber: 42,
150
+ checksSummary: {
151
+ overall: 'passing',
152
+ counts: {total: 4, passed: 4, failed: 0, pending: 0, neutral: 0},
153
+ },
154
+ checksUpdatedAt: '2026-05-15T00:00:00Z',
155
+ });
156
+ });
157
+
158
+ test('can approve storefront v2 change request', () => {
159
+ const merchi = new Merchi();
160
+ const domain = new merchi.Domain();
161
+ const fetch = mockFetch(true, {}, 200);
162
+ domain.approveStorefrontChangeRequest(9, {comment: 'looks good'});
163
+ const fetchUrl = fetch.mock.calls[0][0];
164
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
165
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
166
+ expect(fetchUrl).toContain('/storefront_change_requests/9/approve/');
167
+ expect(body).toEqual({comment: 'looks good'});
168
+ });
169
+
170
+ test('can reject storefront v2 change request', () => {
171
+ const merchi = new Merchi();
172
+ const domain = new merchi.Domain();
173
+ const fetch = mockFetch(true, {}, 200);
174
+ domain.rejectStorefrontChangeRequest(9, {reason: 'needs edits'});
175
+ const fetchUrl = fetch.mock.calls[0][0];
176
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
177
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
178
+ expect(fetchUrl).toContain('/storefront_change_requests/9/reject/');
179
+ expect(body).toEqual({reason: 'needs edits'});
180
+ });
181
+
182
+ test('can get storefront v2 deployments', () => {
183
+ const merchi = new Merchi();
184
+ const domain = new merchi.Domain();
185
+ domain.id = 42;
186
+ const fetch = mockFetch(true, {}, 200);
187
+ domain.getStorefrontV2Deployments();
188
+ const fetchUrl = fetch.mock.calls[0][0];
189
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
190
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/deployments/');
191
+ });
192
+
193
+ test('can get storefront v2 deployment logs', () => {
194
+ const merchi = new Merchi();
195
+ const domain = new merchi.Domain();
196
+ domain.id = 42;
197
+ const fetch = mockFetch(true, {}, 200);
198
+ domain.getStorefrontV2DeploymentLogs('dep_123');
199
+ const fetchUrl = fetch.mock.calls[0][0];
200
+ expect(fetch.mock.calls[0][1].method).toBe('GET');
201
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/deployments/dep_123/logs/');
202
+ });
203
+
204
+ test('can rollback storefront v2 deployment', () => {
205
+ const merchi = new Merchi();
206
+ const domain = new merchi.Domain();
207
+ domain.id = 42;
208
+ const fetch = mockFetch(true, {}, 200);
209
+ domain.rollbackStorefrontV2({deploymentId: 'dep_123'});
210
+ const fetchUrl = fetch.mock.calls[0][0];
211
+ const body = JSON.parse(fetch.mock.calls[0][1].body as string);
212
+ expect(fetch.mock.calls[0][1].method).toBe('POST');
213
+ expect(fetchUrl).toContain('/domains/42/storefront_v2/rollback/');
214
+ expect(body).toEqual({deploymentId: 'dep_123'});
215
+ });
@@ -21,6 +21,43 @@ import { DomainChatSettings } from './domain_chat_settings.js';
21
21
  import { Theme } from './theme.js';
22
22
  import { DomainType } from '../constants/domain_types.js';
23
23
  import { ShipmentMethod } from './shipment_method.js';
24
+ import { RequestOptions } from '../request.js';
25
+
26
+ export type StorefrontChangeRequestStatus =
27
+ | 'created'
28
+ | 'running'
29
+ | 'preview_ready'
30
+ | 'approved'
31
+ | 'rejected';
32
+
33
+ export interface StorefrontChecksSummary {
34
+ overall?: 'passing' | 'failing' | 'pending' | 'unknown';
35
+ statusState?: string;
36
+ counts?: {
37
+ total?: number;
38
+ passed?: number;
39
+ failed?: number;
40
+ pending?: number;
41
+ neutral?: number;
42
+ };
43
+ updatedAt?: string;
44
+ }
45
+
46
+ export interface StorefrontV2ChangeRequest {
47
+ id: number;
48
+ domainId: number;
49
+ storefrontV2Id: number;
50
+ status: StorefrontChangeRequestStatus;
51
+ prompt: string;
52
+ branchName?: string | null;
53
+ commitSha?: string | null;
54
+ pullRequestNumber?: number | null;
55
+ previewUrl?: string | null;
56
+ summary?: string | null;
57
+ checksSummary?: StorefrontChecksSummary | null;
58
+ checksUpdatedAt?: string | null;
59
+ errorDetails?: string | null;
60
+ }
24
61
 
25
62
  export class Domain extends Entity {
26
63
  protected static resourceName = 'domains';
@@ -291,4 +328,117 @@ export class Domain extends Entity {
291
328
  }
292
329
  return this.activeTheme!;
293
330
  };
331
+
332
+ private getDomainId = () => {
333
+ if (this.id === undefined || this.id === null) {
334
+ throw new Error('id is undefined, did you forget to set it?');
335
+ }
336
+ return this.id;
337
+ };
338
+
339
+ private storefrontV2DomainResource = (suffix = '') => {
340
+ return `/domains/${this.getDomainId()}/storefront_v2/${suffix}`;
341
+ };
342
+
343
+ private storefrontV2Request = (
344
+ resource: string,
345
+ method: 'GET' | 'POST',
346
+ payload?: Record<string, any>
347
+ ) => {
348
+ const fetchOptions: RequestOptions = {
349
+ method: method,
350
+ query: [['skip_rights', 'y']]
351
+ };
352
+ if (payload !== undefined) {
353
+ fetchOptions.body = JSON.stringify(payload);
354
+ fetchOptions.headers = {'Content-Type': 'application/json'};
355
+ }
356
+ return this.merchi.authenticatedFetch(resource, fetchOptions);
357
+ };
358
+
359
+ public getStorefrontV2 = () => {
360
+ return this.storefrontV2Request(this.storefrontV2DomainResource(), 'GET');
361
+ };
362
+
363
+ public provisionStorefrontV2 = (payload?: Record<string, any>) => {
364
+ return this.storefrontV2Request(
365
+ this.storefrontV2DomainResource('provision/'),
366
+ 'POST',
367
+ payload
368
+ );
369
+ };
370
+
371
+ public createStorefrontChangeRequest = (
372
+ payload?: Record<string, any>
373
+ ): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
374
+ return this.storefrontV2Request(
375
+ this.storefrontV2DomainResource('requests/'),
376
+ 'POST',
377
+ payload
378
+ ) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
379
+ };
380
+
381
+ public getStorefrontChangeRequest = (
382
+ requestId: number | string
383
+ ): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
384
+ return this.storefrontV2Request(
385
+ `/storefront_change_requests/${String(requestId)}/`,
386
+ 'GET'
387
+ ) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
388
+ };
389
+
390
+ public runStorefrontChangeRequest = (
391
+ requestId: number | string,
392
+ payload?: Record<string, any>
393
+ ): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
394
+ return this.storefrontV2Request(
395
+ `/storefront_change_requests/${String(requestId)}/run/`,
396
+ 'POST',
397
+ payload
398
+ ) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
399
+ };
400
+
401
+ public approveStorefrontChangeRequest = (
402
+ requestId: number | string,
403
+ payload?: Record<string, any>
404
+ ): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
405
+ return this.storefrontV2Request(
406
+ `/storefront_change_requests/${String(requestId)}/approve/`,
407
+ 'POST',
408
+ payload
409
+ ) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
410
+ };
411
+
412
+ public rejectStorefrontChangeRequest = (
413
+ requestId: number | string,
414
+ payload?: Record<string, any>
415
+ ): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
416
+ return this.storefrontV2Request(
417
+ `/storefront_change_requests/${String(requestId)}/reject/`,
418
+ 'POST',
419
+ payload
420
+ ) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
421
+ };
422
+
423
+ public getStorefrontV2Deployments = () => {
424
+ return this.storefrontV2Request(
425
+ this.storefrontV2DomainResource('deployments/'),
426
+ 'GET'
427
+ );
428
+ };
429
+
430
+ public getStorefrontV2DeploymentLogs = (deploymentId: number | string) => {
431
+ return this.storefrontV2Request(
432
+ this.storefrontV2DomainResource(`deployments/${String(deploymentId)}/logs/`),
433
+ 'GET'
434
+ );
435
+ };
436
+
437
+ public rollbackStorefrontV2 = (payload?: Record<string, any>) => {
438
+ return this.storefrontV2Request(
439
+ this.storefrontV2DomainResource('rollback/'),
440
+ 'POST',
441
+ payload
442
+ );
443
+ };
294
444
  }
@@ -22,37 +22,3 @@ 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,22 +159,11 @@ 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;
170
162
  }
171
163
 
172
164
  export interface ListMetadata {
173
165
  canCreate?: boolean;
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;
166
+ available: number;
178
167
  count: number;
179
168
  limit: number;
180
169
  offset: number;
@@ -428,16 +417,6 @@ export class Entity {
428
417
  if (options.limit !== undefined) {
429
418
  fetchOptions.query.push(['limit', options.limit.toString()]);
430
419
  }
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
- }
441
420
  if (options.q !== undefined) {
442
421
  fetchOptions.query.push(['q', options.q]);
443
422
  }