@geophrase/core 1.6.0 β†’ 1.7.0

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/README.md CHANGED
@@ -4,6 +4,8 @@ The core vanilla JavaScript library for Geophrase Connect. Drop the Geophrase ad
4
4
 
5
5
  πŸ‘‰ **[Full documentation and integration guide](https://geophrase.com/docs/vanilla-js)**
6
6
 
7
+ πŸ—ΊοΈ **[How GPS address capture works with couriers or your own riders](https://geophrase.com/features/gps-address-capture)**
8
+
7
9
  *Building a React or Next.js app? Use [`@geophrase/react`](https://www.npmjs.com/package/@geophrase/react) instead. It wraps this core library in native hooks.*
8
10
 
9
11
  ---
@@ -83,6 +85,7 @@ const geo = new Geophrase({
83
85
  | `key` | `string` | **Conditional** | Your secret [Geophrase API key](https://geophrase.com/docs/api-keys). **Required if `mode` is `'client'`.** Omit if using server mode. |
84
86
  | `theme` | `string` | Optional | `'light'`, `'dark'`, or `'system'`. Defaults to `'system'`. |
85
87
  | `orderId` | `string` | Optional | Your internal reference ID for this checkout session. |
88
+ | `noteForAgent` | `string` | Optional | Note shown to your delivery agent, never to the customer. Client mode only; notes over 300 characters are cut. It is sent from the customer's device, so the customer can change it; send payment instructions, such as cash to collect, from your server or the dashboard. In server mode, send `note_for_agent` with your [resolve call](https://geophrase.com/docs/resolve-endpoint). |
86
89
  | `phone` | `string` | Optional | The customer's 10-digit phone number (pre-fills the widget). |
87
90
  | `onSuccess` | `function` | **Yes** | Called upon completion. Returns an `Address` object (`mode: 'client'`) or a `Token` object (`mode: 'server'`). |
88
91
  | `onError` | `function` | Optional | Called if the API fails or a network error occurs. Returns an `Error` object. |
package/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export interface GeophraseOptions {
38
38
  theme?: 'light' | 'dark' | 'system';
39
39
  key?: string;
40
40
  orderId?: string;
41
+ noteForAgent?: string;
41
42
  phone?: string;
42
43
  onSuccess: (result: GeophraseAddress | GeophraseRequestId) => void;
43
44
  onError?: (error: GeophraseError) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geophrase/core",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Drop-in address picker widget for Indian e-commerce checkouts. Captures structured addresses with coordinates to reduce RTO.",
5
5
  "license": "MIT",
6
6
  "author": "Geophrase",
package/src/index.js CHANGED
@@ -37,6 +37,7 @@ class Geophrase {
37
37
  this.keyId = options.keyId;
38
38
  this.apiKey = this.mode === 'client' ? options.key : null;
39
39
  this.orderId = options.orderId;
40
+ this.noteForAgent = options.noteForAgent;
40
41
  this.phone = options.phone;
41
42
 
42
43
  // 4. Theme validation
@@ -336,6 +337,8 @@ class Geophrase {
336
337
 
337
338
  const payload = { request_id: data.requestId };
338
339
  if (this.orderId) payload.order_id = this.orderId;
340
+ // Cut to the API's limit: a longer note would fail the whole address capture.
341
+ if (this.noteForAgent) payload.note_for_agent = String(this.noteForAgent).slice(0, 300);
339
342
 
340
343
  try {
341
344
  const response = await fetch(`${this.apiBase}/business/resolve/`, {