toga-ai 1.0.157 → 1.0.159

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.
@@ -46,4 +46,5 @@ _Auto-generated by `knowledge.js index`. Do not hand-edit._
46
46
  - **Quad Graphics** (`quad`) → [clients/quad/INDEX.md](clients/quad/INDEX.md)
47
47
  - **Rate** (`rate`) → [clients/rate/INDEX.md](clients/rate/INDEX.md)
48
48
  - **Tow Foundation** (`tow-foundation`) → [clients/tow-foundation/INDEX.md](clients/tow-foundation/INDEX.md)
49
+ - **Walmart Client Profile** (`walmart`) → [clients/walmart/INDEX.md](clients/walmart/INDEX.md)
49
50
 
@@ -5,7 +5,7 @@ project: _Underscore
5
5
  client: compass-canada
6
6
  type: client-feature
7
7
  status: active
8
- updated: 2026-06-19
8
+ updated: 2026-06-22
9
9
  owners: ["bala"]
10
10
  files:
11
11
  - worker/crons/toga2/compasscanada/workflow/4_import_grand_and_toy_advance_shipping_notices.php
@@ -28,8 +28,9 @@ flow, adapted for Canadian carriers and bilingual email.
28
28
  ## Key files / entry points
29
29
  - `worker/crons/toga2/compasscanada/workflow/4_import_grand_and_toy_advance_shipping_notices.php`
30
30
  — the scheduled cron (1.0 worker tier). Reads mailbox `compasscanada.status@togatech.com`
31
- (OAuth2 creds in config `[compasscanada]`), parses the 24-column CSV, posts to api2
32
- `/advance-shipping-notices`. Scheduled in `worker/schedules/cron.worker.sync.json` (every 4h).
31
+ (OAuth2 creds — currently hardcoded with a TODO; must move to `App_Registry::get('config')['compasscanada']['gt_asn_oauth2']`
32
+ before production), parses the 24-column CSV, posts to api2 `/advance-shipping-notices`.
33
+ Scheduled in `worker/schedules/cron.worker.sync.json` (every 4h).
33
34
  - `_underscore/Model/Compass/AdvanceShippingNotice.php` — `postPost` interceptor that builds the
34
35
  ItemFulfillment chain on each ASN POST. Compass Canada inherits it via the empty
35
36
  `_underscore/Model/Compass/Canada/AdvanceShippingNotice.php`.
@@ -38,21 +39,27 @@ flow, adapted for Canadian carriers and bilingual email.
38
39
  user emails/notifications, and stamps `c_dtInTransitEmailSent = NOW()`.
39
40
 
40
41
  ## How it works
41
- 1. Cron gets an O365 OAuth2 token (creds from `App_Registry::get('config')['compasscanada']`),
42
+ 1. Cron gets an O365 OAuth2 token (creds currently hardcoded; see Gotchas for migration path),
42
43
  opens the INBOX.
43
44
  2. Per attachment: decode CSV, gate on exactly 24 columns (otherwise email the team the file +
44
- skip).
45
- 3. Per row: skip electronic-delivery carriers (`Digital` / `E-delivered` / `E-verified`);
46
- validate PO / part / tracking; look up SO + contact user + CC addresses; resolve carrier →
47
- Ground shipping method; upsert `TrackingNumbers`; resolve the item by
48
- `VendorItems.vendorPartNumber`; find-or-create a `Units` row per serial.
49
- 4. POST `/advance-shipping-notices` with the tracking number nested at header + item + unit
50
- level (so the interceptor sees it during the POST).
51
- 5. The Compass ASN `postPost` interceptor (when enabled) creates the `ItemFulfillment` (one per
45
+ skip). Uses `preg_split('/\r?\n/', ...)` on the first line so Windows CRLF attachments parse
46
+ correctly.
47
+ 3. **Before the row loop** — build three lookup maps once per file: `$purchaseOrderUuidByNumber`
48
+ (`SELECT number, uuid FROM PurchaseOrders`), `$shippingMethodByCarrierId`, `$carrierIdByName`.
49
+ 4. Per row: validate PO / part / tracking (early `continue` with error recording on missing
50
+ critical fields); look up SO + contact user + CC addresses; resolve carrier →
51
+ Ground shipping method (falls back to `DEFAULT_GROUND_SHIPPING_METHOD_ID = 3`); upsert
52
+ `TrackingNumbers`; resolve item by `Items.partNumber` joined through `VendorItems`; find-or-create
53
+ a `Units` row per serial.
54
+ 5. POST `/advance-shipping-notices` with ASNIU (unit) payload so the interceptor can act.
55
+ 6. After the POST: query each generated ASNIU UUID back from DB, insert
56
+ `AdvanceShippingNoticeItemUnits_TrackingNumbers`. This runs for EVERY newly created ASNIU,
57
+ regardless of whether the TrackingNumber record was new or pre-existing.
58
+ 7. The Compass ASN `postPost` interceptor (when enabled) creates the `ItemFulfillment` (one per
52
59
  SO number, reused if it exists), `ItemFulfillmentItems`, `ItemFulfillmentItemUnits`, and the
53
60
  IF/IFI/IFIU `_TrackingNumbers` bridges.
54
- 6. Only when a tracking number is newly inserted: write Notifications (1.0 `db_store` + 2.0),
55
- resolve the user's language, send the EN/FR in-transit email via POST
61
+ 8. Only when a tracking number is newly inserted: write Notifications (1.0 `db_store` + 2.0),
62
+ resolve the user's language, send the EN/FR in-transit email via
56
63
  `/email-templates/sendEmail`, then stamp `c_dtInTransitEmailSent = NOW()`.
57
64
 
58
65
  ## Data model
@@ -73,30 +80,47 @@ a bilingual EN/FR in-transit email (USA is English only) and uses Canadian carri
73
80
 
74
81
  ## Gotchas / known issues
75
82
  - **CSV "Part Number" is the VENDOR part number (`VendorItems.vendorPartNumber`), NOT
76
- `Items.partNumber`.** Resolve the item through `VendorItems`. (e.g. vendor `IMFP3260` →
77
- `Items.partNumber` `C2CY5UC#ABA`.)
83
+ `Items.partNumber` directly.** Resolve the item through the `VendorItems` join. (e.g. vendor
84
+ `IMFP3260` → `Items.partNumber` `C2CY5UC#ABA`.)
78
85
  - **G&T's ASN file inconsistently drops the `IM` prefix** (`FP3260` vs `IMFP3260`) on some lines
79
86
  → item-not-found → those lines are skipped and reported in the import-report email. This is a
80
87
  G&T-side export issue; toga transmits the correct `IMFP…` to G&T as the cXML `SupplierPartID`
81
88
  (see `2_transmit_mits_purchase_orders_to_vendors.php`), so it is NOT a MITS bug.
89
+ - **Build lookup maps OUTSIDE the while loop.** `$purchaseOrderUuidByNumber`, `$shippingMethodByCarrierId`,
90
+ and `$carrierIdByName` must be built once before the row loop — they were originally inside,
91
+ causing a full-table scan of `PurchaseOrders`, `ShippingMethods`, and `ShippingCarriers` on
92
+ every CSV row.
93
+ - **ASNIU→TrackingNumber link is NOT gated on `$isNewTrackingNumber`.** The ASNIU is always
94
+ freshly created on each import row; the `AdvanceShippingNoticeItemUnits_TrackingNumbers` insert
95
+ must run regardless of whether the TrackingNumber record itself was new or pre-existing.
96
+ Gating it on "new TN only" means re-sent / re-processed CSV rows create orphaned ASNIUs with
97
+ no tracking link.
98
+ - **`$shippingMethodByCarrierId[$selectedCarrierId]` needs a null-coalesce fallback.** On PHP 8,
99
+ accessing a missing key without `?? DEFAULT_GROUND_SHIPPING_METHOD_ID` produces a deprecation
100
+ warning that becomes an error. Always write `$shippingMethodByCarrierId[$selectedCarrierId] ?? DEFAULT_GROUND_SHIPPING_METHOD_ID`.
101
+ - **CSV CRLF attachments:** use `preg_split('/\r?\n/', $decodedAttachment)[0]` (not
102
+ `explode("\n", ...)`) for the header-line column-count check. `explode("\n")` leaves a trailing
103
+ `\r` on the first line when the file uses Windows line endings, making `str_getcsv` miscount
104
+ columns and silently skip the file.
82
105
  - **The ASN→IF interceptor must be ENABLED per client.** `Core.ApiPayloadInterceptors` for
83
- `recordId 55`, `prePostProcessing=POST`, `httpMethod=POST` must be `isActive=1` (and the client
84
- `AclRecordScripts` must grant the caller's roles). It was OFF for Compass Canada; enabling it is
85
- required or ASNs post but the IF/IFI/IFIU chain never builds.
86
- - **Tracking must be nested in the ASN POST payload** (header/item/unit), not linked via SQL
87
- after the POST — the interceptor runs during the POST, so post-POST links are invisible to it.
88
- - **`/email-templates/sendEmail` must be POST** (not GET) so a large `orderItems` HTML payload
89
- does not hit the URL-length limit (HTTP 414). POST requires the `sendEmail` record script
90
- registered for the POST method (`Core.RecordScripts`), else the engine returns `EV-8`.
106
+ `recordId 55`, `prePostProcessing=POST`, `httpMethod=POST` must be `isActive=1`. It was OFF for
107
+ Compass Canada; enabling it is required or ASNs post but the IF/IFI/IFIU chain never builds.
108
+ - **OAuth2 credentials are currently hardcoded** in the cron with a `// TODO` comment. Before
109
+ going to production, move them to `config.<env>.ini` under `[compasscanada]` and read via
110
+ `App_Registry::get('config')['compasscanada'][…]`. The `config.<env>.ini` must be deployed
111
+ with the code or the OAuth2 token request fails silently.
91
112
  - Each CSV line creates one ASN; the interceptor dedups to **one ItemFulfillment per SO**.
92
113
  - A new carrier needs its **own** Ground `ShippingMethod`, or the TrackingNumber ends up with the
93
114
  right carrier but another carrier's Ground method id.
94
115
  - `App_Database::fetchOne()` (1.0) throws on a 0-row result — guard item lookups with `numRows()`
95
116
  before `fetchOne()`.
96
- - The cron reads OAuth2 creds from config `[compasscanada]`; the updated `config.<env>.ini` must
97
- be deployed with the code or the token request fails.
98
117
 
99
118
  ## Change history
119
+ - 2026-06-22 — Full variable rename (no abbreviations); moved PO/carrier/shipping-method lookup maps
120
+ outside the CSV row loop (was causing N full-table queries per file); fixed ASNIU→TN link to run
121
+ unconditionally for new ASNIUs (not only when TN was new); added PHP 8 null-coalesce on carrier→
122
+ method lookup; fixed CSV CRLF detection with `preg_split`; added `DEFAULT_GROUND_SHIPPING_METHOD_ID`
123
+ named constant; function renamed `buildOrderItemsHtmlGrandAndToy` (camelCase). (bala)
100
124
  - 2026-06-19 — Built the G&T ASN import cron + one-time backfill script; matched items by
101
125
  `VendorItems.vendorPartNumber`; added Canadian carriers + per-carrier Ground methods; EN/FR
102
126
  in-transit email via POST; enabled the Compass ASN→IF interceptor for Compass Canada. (bala)
@@ -0,0 +1,7 @@
1
+ # Client: Walmart Client Profile `walmart`
2
+
3
+ | Doc | Framework | Summary | Files |
4
+ |-----|-----------|---------|-------|
5
+ | [Walmart Domain Migration — walmarttechservices.com to walmart.truesolutions.com](features/domain-migration.md) | 1.0 | `walmarttechservices.com` was decommissioned and all traffic/functionality migrated to `walmart.truesolutions.com` via the `walmart-activate` repo on AWS Elasti | walmart-activate/.htaccess, walmart-activate/mvc/home/get.php, walmart-activate/mvc/register/get.php, walmart-activate/mvc/register/post.php, walmart-activate/health/index.php, worker/crons/notifications/send_blast_email.php, library/app/model/servicerequest.php, library/app/client/walmart.php |
6
+ | [Walmart Service Registration Route](features/registration-route.md) | 1.0 | `/register` is the customer-facing service registration form at `walmart.truesolutions.com/register`. | walmart-activate/mvc/register/get.php, walmart-activate/mvc/register/post.php, library/app/client/walmart.php, library/app/string.php |
7
+ | [Walmart Client Profile](profile.md) | 1.0 | Walmart is client ID **7** in `TOGA.Clients`. | library/app/client/walmart.php, library/app/email/walmartb2c.php, walmart-activate/_/app/framework.php |
@@ -0,0 +1,91 @@
1
+ ---
2
+ title: Walmart Domain Migration — walmarttechservices.com to walmart.truesolutions.com
3
+ framework: "1.0"
4
+ project: TOGa
5
+ client: walmart
6
+ type: client-feature
7
+ status: active
8
+ updated: 2026-06-23
9
+ owners: []
10
+ files:
11
+ - walmart-activate/.htaccess
12
+ - walmart-activate/mvc/home/get.php
13
+ - walmart-activate/mvc/register/get.php
14
+ - walmart-activate/mvc/register/post.php
15
+ - walmart-activate/health/index.php
16
+ - worker/crons/notifications/send_blast_email.php
17
+ - library/app/model/servicerequest.php
18
+ - library/app/client/walmart.php
19
+ related:
20
+ - clients/walmart/profile.md
21
+ - clients/walmart/features/registration-route.md
22
+ ---
23
+
24
+ ## Summary
25
+
26
+ `walmarttechservices.com` was decommissioned and all traffic/functionality migrated to `walmart.truesolutions.com` via the `walmart-activate` repo on AWS Elastic Beanstalk. The old domain was flagged as a phishing site by browsers.
27
+
28
+ ## New routes on walmart.truesolutions.com
29
+
30
+ | URL | File | Purpose |
31
+ |-----|------|---------|
32
+ | `/` | `.htaccess` RewriteRule | 302 redirect → `/home` |
33
+ | `/home` | `mvc/home/get.php` | Marketing page |
34
+ | `/register` | `mvc/register/get.php` + `post.php` | Service registration form |
35
+ | `/health` | `health/index.php` | ELB health check (real directory, bypasses rewrite) |
36
+ | `/activate` | existing — untouched | PIN activation flow |
37
+
38
+ ## Root URL redirect
39
+
40
+ `.htaccess` has a dedicated rule BEFORE the catch-all:
41
+ ```apache
42
+ RewriteRule ^$ /home [R=302,L]
43
+ ```
44
+ Required because `/` is a real directory — Apache's `!-d` condition skips the catch-all and serves DirectoryIndex, which caused a 404 without this rule.
45
+
46
+ ## Code changes across repos
47
+
48
+ ### walmart-activate
49
+ - `.htaccess` — root redirect rule added
50
+ - `mvc/home/get.php` — marketing page (migrated from walmarttechservices.com)
51
+ - `mvc/register/get.php` — "Warranty Registration" → "Service Registration"; image paths made absolute
52
+ - `common/header.php` — logo image paths made absolute (relative paths broke on URLs with trailing slash)
53
+ - `health/index.php` — ELB health check: `http_response_code(200); echo 'ok';`
54
+
55
+ ### worker
56
+ - `crons/notifications/send_blast_email.php` line 74 — hardcoded URL updated:
57
+ - Old: `https://www.walmarttechservices.com/?{enc}`
58
+ - New: `https://walmart.truesolutions.com/register?{enc}=`
59
+
60
+ ### library
61
+ - `app/model/servicerequest.php` lines 5009 & 5021 — payment email image URLs updated from `walmarttechservices.com/assets/images/` to `walmart.truesolutions.com/assets/img/`
62
+
63
+ ## DB update (manual — done once on prod)
64
+
65
+ ```sql
66
+ UPDATE TOGA.Clients
67
+ SET requireRegistrationUrl = 'https://walmart.truesolutions.com/register'
68
+ WHERE id = 7
69
+ ```
70
+ Fixes `App_Client_Walmart::sendRegistrationEmail()` and `toga_walmart_order_reminder.php` in one shot — both read this value from the DB.
71
+
72
+ ## Emails that send registration links
73
+
74
+ | File | How URL is built | Status |
75
+ |------|-----------------|--------|
76
+ | `worker/crons/notifications/send_blast_email.php` | Hardcoded | Fixed in code |
77
+ | `worker/crons/toga/toga_walmart_order_reminder.php` | DB `requireRegistrationUrl` | Fixed by DB update |
78
+ | `library/app/client/walmart.php` `sendRegistrationEmail()` | DB `requireRegistrationUrl` | Fixed by DB update |
79
+
80
+ ## Gotchas
81
+
82
+ - Image paths in `walmart-activate` views must be **absolute** (`/assets/img/...`). Relative paths break when the URL has a trailing slash (e.g. `/register/`).
83
+ - `health/` is a real directory — Apache serves `health/index.php` directly, bypassing the MVC rewrite. Intentional.
84
+ - `toga/app/servicerequests/view.php` and togarefresh variants contain `str_replace('https://www.walmarttechservices.com', ...)` wrapped in `if (App_Registry::inDevMode())` — dev-only, no production impact.
85
+ - Old repos (`walmarttechservices`, `walmart-tech-services`) were archived on GitHub after prod was confirmed working.
86
+
87
+ ## Change history
88
+
89
+ | Date | Change |
90
+ |------|--------|
91
+ | 2026-06-23 | Migration completed; all three repos updated, DB updated, old repos archived |
@@ -0,0 +1,86 @@
1
+ ---
2
+ title: Walmart Service Registration Route
3
+ framework: "1.0"
4
+ project: TOGa
5
+ client: walmart
6
+ type: client-feature
7
+ status: active
8
+ updated: 2026-06-23
9
+ owners: []
10
+ files:
11
+ - walmart-activate/mvc/register/get.php
12
+ - walmart-activate/mvc/register/post.php
13
+ - library/app/client/walmart.php
14
+ - library/app/string.php
15
+ related:
16
+ - clients/walmart/profile.md
17
+ - clients/walmart/features/domain-migration.md
18
+ ---
19
+
20
+ ## Summary
21
+
22
+ `/register` is the customer-facing service registration form at `walmart.truesolutions.com/register`. Customers land here via an encrypted link sent in the blast email or order reminder. They confirm their contact info, which triggers a confirmation email.
23
+
24
+ ## URL format
25
+
26
+ The encrypted service request ID is the **query param KEY** (not the value):
27
+
28
+ ```
29
+ https://walmart.truesolutions.com/register?aB3xK9mPqR2vNwLz=
30
+ ```
31
+
32
+ The `=` at the end is intentional — the encrypted string is the key, the value is empty.
33
+
34
+ Built in code as:
35
+ ```php
36
+ $link = 'https://walmart.truesolutions.com/register?' . App_String::encryptString($serviceRequestId) . '=';
37
+ ```
38
+
39
+ ## How the key is parsed (GET handler)
40
+
41
+ `mvc/register/get.php` extracts the encrypted ID by iterating `$_GET` and taking the first key that is not `success` or `error`:
42
+
43
+ ```php
44
+ foreach ($_GET as $key => $val) {
45
+ if ($key !== 'success' && $key !== 'error') {
46
+ $encryptedServiceRequestId = $key;
47
+ break;
48
+ }
49
+ }
50
+ ```
51
+
52
+ Then decrypts: `$serviceRequestId = (int) App_String::decrypt($encryptedServiceRequestId);`
53
+
54
+ ## POST handler flow (mvc/register/post.php)
55
+
56
+ 1. Extract encrypted ID from `$_GET` (same loop as GET handler)
57
+ 2. Validate `firstName`, `lastName`, `phoneNumber`, `emailAddress` — redirect to `?{enc}=&error=1` if any missing
58
+ 3. Decrypt ID → `$serviceRequestId` — redirect to error if decrypt fails
59
+ 4. Update `Contacts` record via `App_Model_Toga_Contact`
60
+ 5. Mark `ServiceRequests.confirmed = true`
61
+ 6. Query `ServiceRequestItems` to check `requiresAgentDownload`
62
+ 7. Send confirmation email via `App_Email_WalmartB2C`:
63
+ - `requiresAgentDownload = 1` → "Download Tech Support App" email with agent download link
64
+ - Otherwise → "Call us to begin your service" email
65
+ 8. Redirect to `?{enc}=&success=1`
66
+
67
+ ## Success / error states
68
+
69
+ | Query string | Meaning |
70
+ |-------------|---------|
71
+ | `?{enc}=` | Fresh form load |
72
+ | `?{enc}=&success=1` | Registration submitted successfully |
73
+ | `?{enc}=&error=1` | Validation failed or decrypt failed |
74
+
75
+ ## Gotchas
76
+
77
+ - The encrypted ID is the **key**, not the value. `?enc=value` format would break parsing.
78
+ - `App_String::encryptString()` and `App_String::decrypt()` are the inverse pair — do not mix with other encryption helpers.
79
+ - Registration URL base comes from `TOGA.Clients.requireRegistrationUrl` for client id=7. If this DB field is wrong, all registration links break.
80
+ - Image paths in the view must use absolute paths (`/assets/img/...`) — relative paths break on URLs with a trailing slash.
81
+
82
+ ## Change history
83
+
84
+ | Date | Change |
85
+ |------|--------|
86
+ | 2026-06-23 | Route documented; migrated from walmarttechservices.com to walmart.truesolutions.com/register |
@@ -0,0 +1,51 @@
1
+ ---
2
+ title: Walmart Client Profile
3
+ framework: "1.0"
4
+ project: TOGa
5
+ client: walmart
6
+ type: client-feature
7
+ status: active
8
+ updated: 2026-06-23
9
+ owners: []
10
+ files:
11
+ - library/app/client/walmart.php
12
+ - library/app/email/walmartb2c.php
13
+ - walmart-activate/_/app/framework.php
14
+ related:
15
+ - clients/walmart/features/domain-migration.md
16
+ - clients/walmart/features/registration-route.md
17
+ ---
18
+
19
+ ## Summary
20
+
21
+ Walmart is client ID **7** in `TOGA.Clients`. All Walmart B2C tech services (service registration, PIN activation, blast emails, order reminders) run through the `walmart-activate` app at `walmart.truesolutions.com`.
22
+
23
+ ## Key identifiers
24
+
25
+ | Field | Value |
26
+ |-------|-------|
27
+ | `TOGA.Clients.id` | `7` |
28
+ | Primary domain | `walmart.truesolutions.com` |
29
+ | Former domain | `walmarttechservices.com` (decommissioned 2026) |
30
+ | Email from | `walmarttechservices@truenetworksolutions.com` |
31
+ | Support phone | (888) 725-4544 |
32
+
33
+ ## Key files
34
+
35
+ - `library/app/client/walmart.php` — `App_Client_Walmart` — sends registration confirmation emails; reads `requireRegistrationUrl` from `TOGA.Clients` to build the registration link
36
+ - `library/app/email/walmartb2c.php` — `App_Email_WalmartB2C` — base email class for all Walmart B2C transactional emails
37
+ - `walmart-activate/` — PHP MVC app serving all customer-facing Walmart routes
38
+
39
+ ## DB field: requireRegistrationUrl
40
+
41
+ `TOGA.Clients.requireRegistrationUrl` for id=7 must be:
42
+ ```
43
+ https://walmart.truesolutions.com/register
44
+ ```
45
+ Used by `App_Client_Walmart::sendRegistrationEmail()` and `worker/crons/toga/toga_walmart_order_reminder.php` to build registration links sent to customers.
46
+
47
+ ## Change history
48
+
49
+ | Date | Change |
50
+ |------|--------|
51
+ | 2026-06-23 | Profile created; domain migrated from walmarttechservices.com to walmart.truesolutions.com |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.157",
3
+ "version": "1.0.159",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",