@drttix/drt-sdk 0.7.0 → 0.7.5

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 (26) hide show
  1. package/demo/test.html +236 -33
  2. package/dist/bundle/drt-sdk.js +1 -1
  3. package/dist/cjs/src/generated/portal/core/OpenAPI.js +1 -1
  4. package/dist/cjs/src/generated/shopper/core/OpenAPI.js +1 -1
  5. package/dist/cjs/src/generated/shopper/index.d.ts +1 -0
  6. package/dist/cjs/src/generated/shopper/models/CreateSessionDto.d.ts +10 -0
  7. package/dist/cjs/src/generated/shopper/models/CreateSessionDto.js +2 -0
  8. package/dist/cjs/src/generated/shopper/services/SessionService.d.ts +9 -0
  9. package/dist/cjs/src/generated/shopper/services/SessionService.js +20 -0
  10. package/dist/cjs/src/generated/shopper/types.d.ts +1 -0
  11. package/dist/esm/src/generated/portal/core/OpenAPI.js +1 -1
  12. package/dist/esm/src/generated/shopper/core/OpenAPI.js +1 -1
  13. package/dist/esm/src/generated/shopper/index.d.ts +1 -0
  14. package/dist/esm/src/generated/shopper/models/CreateSessionDto.d.ts +10 -0
  15. package/dist/esm/src/generated/shopper/models/CreateSessionDto.js +1 -0
  16. package/dist/esm/src/generated/shopper/services/SessionService.d.ts +9 -0
  17. package/dist/esm/src/generated/shopper/services/SessionService.js +20 -0
  18. package/dist/esm/src/generated/shopper/types.d.ts +1 -0
  19. package/package.json +1 -1
  20. package/public/sdk/latest/drt-sdk.js +1 -0
  21. package/src/generated/portal/core/OpenAPI.ts +1 -1
  22. package/src/generated/shopper/core/OpenAPI.ts +1 -1
  23. package/src/generated/shopper/index.ts +1 -0
  24. package/src/generated/shopper/models/CreateSessionDto.ts +15 -0
  25. package/src/generated/shopper/services/SessionService.ts +23 -0
  26. package/src/generated/shopper/types.ts +1 -0
package/demo/test.html CHANGED
@@ -176,8 +176,39 @@
176
176
  <div class="left-panel">
177
177
  <h1>DRT SDK Test Page</h1>
178
178
 
179
- <h2>1. Initialize SDK</h2>
179
+ <h2>1. Create or Initialize SDK</h2>
180
180
  <div class="config-form">
181
+ <div
182
+ style="
183
+ background: #e8f5e9;
184
+ padding: 0.75rem;
185
+ border-radius: 4px;
186
+ margin-bottom: 1rem;
187
+ "
188
+ >
189
+ <strong>Quick Start:</strong> Create a new shopper
190
+ session
191
+ <div class="input-row" style="margin-top: 0.5rem">
192
+ <label>Studio ID:</label>
193
+ <input
194
+ type="number"
195
+ id="createStudioId"
196
+ placeholder="e.g., 508"
197
+ style="flex: 1"
198
+ />
199
+ <label>API Key:</label>
200
+ <input
201
+ type="text"
202
+ id="createApiKey"
203
+ placeholder="API key"
204
+ style="flex: 1"
205
+ />
206
+ <button id="btn-create-shopper">
207
+ Create Shopper
208
+ </button>
209
+ </div>
210
+ </div>
211
+
181
212
  <label for="shopperGuid">Shopper GUID:</label>
182
213
  <input
183
214
  type="text"
@@ -234,12 +265,15 @@
234
265
  <button id="btn-events">Get All Events</button>
235
266
  </div>
236
267
  <div class="input-row">
237
- <label>Event ID:</label>
238
- <input
239
- type="number"
240
- id="eventId"
241
- placeholder="e.g., 123"
242
- />
268
+ <label>Event:</label>
269
+ <select
270
+ id="eventSelect"
271
+ style="flex: 1; padding: 0.4rem"
272
+ >
273
+ <option value="">
274
+ -- Click "Get All Events" first --
275
+ </option>
276
+ </select>
243
277
  <button id="btn-event-details">
244
278
  Get Event Details
245
279
  </button>
@@ -317,13 +351,32 @@
317
351
  <code>DRT.scanner.database</code>
318
352
  </p>
319
353
  <div class="input-row">
320
- <label>Event ID:</label>
354
+ <label>Show Code:</label>
355
+ <input
356
+ type="text"
357
+ id="scannerShowCode"
358
+ placeholder="e.g., ABC123"
359
+ />
360
+ </div>
361
+ <div class="input-row">
362
+ <label>Device:</label>
321
363
  <input
322
- type="number"
323
- id="scannerEventId"
324
- placeholder="e.g., 123"
364
+ type="text"
365
+ id="scannerDevice"
366
+ placeholder="device name"
367
+ value="test-device"
368
+ />
369
+ <label>User:</label>
370
+ <input
371
+ type="text"
372
+ id="scannerUser"
373
+ placeholder="username"
374
+ value="test-user"
325
375
  />
326
- <button id="btn-scanner-db">Get Database</button>
376
+ </div>
377
+ <div class="btn-group">
378
+ <button id="btn-scanner-db">Download Database</button>
379
+ <button id="btn-scanner-query">Query Sections</button>
327
380
  </div>
328
381
 
329
382
  <h3>Orders</h3>
@@ -332,13 +385,24 @@
332
385
  <code>DRT.scanner.orders</code>
333
386
  </p>
334
387
  <div class="input-row">
335
- <label>Order ID:</label>
388
+ <label>Phone:</label>
389
+ <input
390
+ type="text"
391
+ id="scannerPhone"
392
+ placeholder="Phone number"
393
+ />
394
+ <button id="btn-scanner-by-phone">
395
+ Search by Phone
396
+ </button>
397
+ </div>
398
+ <div class="input-row">
399
+ <label>Name:</label>
336
400
  <input
337
401
  type="text"
338
- id="scannerOrderId"
339
- placeholder="Order ID"
402
+ id="scannerName"
403
+ placeholder="Buyer name"
340
404
  />
341
- <button id="btn-scanner-order">Get Order</button>
405
+ <button id="btn-scanner-by-name">Search by Name</button>
342
406
  </div>
343
407
  </div>
344
408
  </div>
@@ -486,6 +550,60 @@ Initialize the SDK, then click a button to test...</pre
486
550
  });
487
551
  });
488
552
 
553
+ // Create Shopper
554
+ document
555
+ .getElementById('btn-create-shopper')
556
+ .addEventListener('click', async () => {
557
+ const studioId = parseInt(
558
+ document.getElementById('createStudioId').value,
559
+ );
560
+ const apiKey = document
561
+ .getElementById('createApiKey')
562
+ .value.trim();
563
+
564
+ if (!studioId) {
565
+ setStatus('Please enter a Studio ID', true);
566
+ return;
567
+ }
568
+ if (!apiKey) {
569
+ setStatus('Please enter an API Key', true);
570
+ return;
571
+ }
572
+
573
+ setStatus('Creating shopper session...', false);
574
+ try {
575
+ const result = await DRT.shopper.session.createSession({
576
+ studioId,
577
+ });
578
+ setStatus('Shopper created!', false);
579
+ setOutput(result);
580
+
581
+ // Populate the form fields
582
+ document.getElementById('shopperGuid').value =
583
+ result.shopperGuid;
584
+ document.getElementById('accountId').value =
585
+ result.studioId;
586
+ document.getElementById('apiKey').value = apiKey;
587
+
588
+ // Auto-initialize
589
+ DRT.init({
590
+ shopperGuid: result.shopperGuid,
591
+ accountId: String(result.studioId),
592
+ apiKey,
593
+ });
594
+ setStatus(
595
+ 'Shopper created and SDK initialized!',
596
+ false,
597
+ );
598
+ } catch (err) {
599
+ setStatus(`Error: ${err.message}`, true);
600
+ setOutput({
601
+ error: err.message,
602
+ details: err.body || err.toString(),
603
+ });
604
+ }
605
+ });
606
+
489
607
  // ==================== SHOPPER API ====================
490
608
 
491
609
  // Account
@@ -526,9 +644,33 @@ Initialize the SDK, then click a button to test...</pre
526
644
  // Events
527
645
  document
528
646
  .getElementById('btn-events')
529
- .addEventListener('click', () => {
647
+ .addEventListener('click', async () => {
530
648
  if (!requireInit()) return;
531
- callApi(() => DRT.shopper.event.getEvents(), 'events');
649
+ setStatus('Fetching events...', false);
650
+ try {
651
+ const result = await DRT.shopper.event.getEvents();
652
+ setStatus('Success!', false);
653
+ setOutput(result);
654
+
655
+ // Populate the dropdown
656
+ const select = document.getElementById('eventSelect');
657
+ select.innerHTML =
658
+ '<option value="">-- Select an event --</option>';
659
+ const events = result.events || result || [];
660
+ events.forEach((event) => {
661
+ const opt = document.createElement('option');
662
+ opt.value = event.eventId || event.id;
663
+ opt.textContent = `${event.eventId || event.id}: ${event.eventName || event.name || 'Unnamed'}`;
664
+ select.appendChild(opt);
665
+ });
666
+ setStatus(`Loaded ${events.length} events`, false);
667
+ } catch (err) {
668
+ setStatus(`Error: ${err.message}`, true);
669
+ setOutput({
670
+ error: err.message,
671
+ details: err.body || err.toString(),
672
+ });
673
+ }
532
674
  });
533
675
 
534
676
  document
@@ -536,10 +678,13 @@ Initialize the SDK, then click a button to test...</pre
536
678
  .addEventListener('click', () => {
537
679
  if (!requireInit()) return;
538
680
  const id = parseInt(
539
- document.getElementById('eventId').value,
681
+ document.getElementById('eventSelect').value,
540
682
  );
541
683
  if (!id) {
542
- setStatus('Please enter an Event ID', true);
684
+ setStatus(
685
+ 'Please select an event from the dropdown',
686
+ true,
687
+ );
543
688
  return;
544
689
  }
545
690
  callApi(
@@ -631,32 +776,90 @@ Initialize the SDK, then click a button to test...</pre
631
776
  document
632
777
  .getElementById('btn-scanner-db')
633
778
  .addEventListener('click', () => {
634
- const eventId = parseInt(
635
- document.getElementById('scannerEventId').value,
636
- );
637
- if (!eventId) {
638
- setStatus('Please enter an Event ID', true);
779
+ const showCode = document
780
+ .getElementById('scannerShowCode')
781
+ .value.trim();
782
+ const device = document
783
+ .getElementById('scannerDevice')
784
+ .value.trim();
785
+ const user = document
786
+ .getElementById('scannerUser')
787
+ .value.trim();
788
+ if (!showCode) {
789
+ setStatus('Please enter a Show Code', true);
639
790
  return;
640
791
  }
641
792
  callApi(
642
- () => DRT.scanner.database.getDatabase(eventId),
793
+ () =>
794
+ DRT.scanner.database.download(
795
+ showCode,
796
+ device,
797
+ user,
798
+ 'en',
799
+ ),
643
800
  `scanner database`,
644
801
  );
645
802
  });
646
803
 
647
804
  document
648
- .getElementById('btn-scanner-order')
805
+ .getElementById('btn-scanner-query')
806
+ .addEventListener('click', () => {
807
+ const showCode = document
808
+ .getElementById('scannerShowCode')
809
+ .value.trim();
810
+ if (!showCode) {
811
+ setStatus('Please enter a Show Code', true);
812
+ return;
813
+ }
814
+ callApi(
815
+ () => DRT.scanner.database.query(showCode, 'sections'),
816
+ `sections query`,
817
+ );
818
+ });
819
+
820
+ document
821
+ .getElementById('btn-scanner-by-phone')
822
+ .addEventListener('click', () => {
823
+ const showCode = document
824
+ .getElementById('scannerShowCode')
825
+ .value.trim();
826
+ const phone = document
827
+ .getElementById('scannerPhone')
828
+ .value.trim();
829
+ if (!showCode || !phone) {
830
+ setStatus('Please enter Show Code and Phone', true);
831
+ return;
832
+ }
833
+ callApi(
834
+ () =>
835
+ DRT.scanner.orders.ordersControllerGetOrdersByPhone(
836
+ showCode,
837
+ phone,
838
+ ),
839
+ `orders by phone`,
840
+ );
841
+ });
842
+
843
+ document
844
+ .getElementById('btn-scanner-by-name')
649
845
  .addEventListener('click', () => {
650
- const orderId = document
651
- .getElementById('scannerOrderId')
846
+ const showCode = document
847
+ .getElementById('scannerShowCode')
848
+ .value.trim();
849
+ const name = document
850
+ .getElementById('scannerName')
652
851
  .value.trim();
653
- if (!orderId) {
654
- setStatus('Please enter an Order ID', true);
852
+ if (!showCode || !name) {
853
+ setStatus('Please enter Show Code and Name', true);
655
854
  return;
656
855
  }
657
856
  callApi(
658
- () => DRT.scanner.orders.getOrder(orderId),
659
- `scanner order`,
857
+ () =>
858
+ DRT.scanner.orders.ordersControllerGetOrdersByName(
859
+ showCode,
860
+ name,
861
+ ),
862
+ `orders by name`,
660
863
  );
661
864
  });
662
865