@uengage.io/platform-sdk 0.8.0 → 0.12.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 +94 -44
- package/dist/auth/index.d.ts +13 -3
- package/dist/auth/index.js +18 -5
- package/dist/auth/login.d.ts +30 -0
- package/dist/auth/login.js +36 -0
- package/dist/auth/otp.d.ts +43 -0
- package/dist/auth/otp.js +71 -0
- package/dist/business/client.js +3 -36
- package/dist/business/index.d.ts +1 -1
- package/dist/business/index.js +1 -1
- package/dist/business/schema.d.ts +161 -4
- package/dist/business/schema.js +17 -2
- package/dist/client.d.ts +77 -51
- package/dist/client.js +177 -142
- package/dist/http.d.ts +22 -0
- package/dist/http.js +39 -1
- package/dist/index.d.ts +2 -18
- package/dist/index.js +3 -23
- package/dist/token-source.d.ts +24 -0
- package/dist/token-source.js +65 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/zones/client.d.ts +51 -0
- package/dist/zones/client.js +156 -0
- package/dist/zones/index.d.ts +2 -0
- package/dist/zones/index.js +7 -0
- package/dist/zones/schema.d.ts +104 -0
- package/dist/zones/schema.js +16 -0
- package/package.json +2 -2
|
@@ -2,14 +2,154 @@
|
|
|
2
2
|
* Group names recognised by the business read API. Mirrors the GROUPS
|
|
3
3
|
* registry in services/business; if the server adds a group, add it here.
|
|
4
4
|
*/
|
|
5
|
-
export declare const BUSINESS_GROUPS: readonly ["profile", "
|
|
5
|
+
export declare const BUSINESS_GROUPS: readonly ["profile", "branding", "compliance", "address", "contact", "hours", "slots", "order_types", "delivery", "charges", "attributes", "app_config", "payment_gateway", "bank"];
|
|
6
6
|
export type BusinessGroupName = (typeof BUSINESS_GROUPS)[number];
|
|
7
7
|
export interface BusinessProfile {
|
|
8
8
|
name: string | null;
|
|
9
|
+
slug: string | null;
|
|
10
|
+
/** Numeric flag; 1 = active, 0 = inactive (legacy convention). */
|
|
11
|
+
status: number | null;
|
|
12
|
+
legal_entity_name: string | null;
|
|
9
13
|
}
|
|
10
|
-
export interface
|
|
14
|
+
export interface BusinessBranding {
|
|
15
|
+
/** Logo image URL or relative path served by the legacy CDN. */
|
|
16
|
+
logo: string | null;
|
|
17
|
+
/** Header/banner image URL. */
|
|
18
|
+
header_image: string | null;
|
|
19
|
+
/** Hex color string, e.g. "#01522B". */
|
|
20
|
+
brand_color: string | null;
|
|
21
|
+
social: {
|
|
22
|
+
facebook: string | null;
|
|
23
|
+
instagram: string | null;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface BusinessCompliance {
|
|
27
|
+
gstin: string | null;
|
|
28
|
+
fssai_no: string | null;
|
|
29
|
+
/** State of GST registration; same column as `address.state` in the DB. */
|
|
11
30
|
state: string | null;
|
|
12
|
-
|
|
31
|
+
legal_entity_name: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface BusinessAddress {
|
|
34
|
+
city: string | null;
|
|
35
|
+
state: string | null;
|
|
36
|
+
address: string | null;
|
|
37
|
+
locality: string | null;
|
|
38
|
+
postal_code: number | null;
|
|
39
|
+
latitude: string | null;
|
|
40
|
+
longitude: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface BusinessContact {
|
|
43
|
+
outlet_phone: string | null;
|
|
44
|
+
owner_phone: string | null;
|
|
45
|
+
alternative_phone: string | null;
|
|
46
|
+
/** Phone number that receives order-failure / SLA-breach SMS alerts. */
|
|
47
|
+
alert_phone: string | null;
|
|
48
|
+
/** Comma-separated email list for daily reports + alerts. */
|
|
49
|
+
alert_emails: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface TimeOfDay {
|
|
52
|
+
hour: number | null;
|
|
53
|
+
minute: number;
|
|
54
|
+
}
|
|
55
|
+
export interface BusinessHours {
|
|
56
|
+
/** Window during which the storefront accepts online orders. */
|
|
57
|
+
online_orders: {
|
|
58
|
+
start: TimeOfDay;
|
|
59
|
+
end: TimeOfDay;
|
|
60
|
+
};
|
|
61
|
+
/** Real-world open/close times (may differ from order-window for prep buffers). */
|
|
62
|
+
actual: {
|
|
63
|
+
open: TimeOfDay;
|
|
64
|
+
close: TimeOfDay;
|
|
65
|
+
};
|
|
66
|
+
/** Hours of the day (0-23) when ordering is blocked. */
|
|
67
|
+
blocked_hours: number[];
|
|
68
|
+
/** Legacy off-hours config; same shape as blocked_hours. */
|
|
69
|
+
off_hours: number[];
|
|
70
|
+
/** Minutes between order placement and outlet handoff. String for legacy compat. */
|
|
71
|
+
preparation_time_minutes: string | null;
|
|
72
|
+
}
|
|
73
|
+
export interface BusinessSlots {
|
|
74
|
+
/** 1 = slots enabled, 0 = disabled. */
|
|
75
|
+
enabled: number | null;
|
|
76
|
+
/** 1 = slot-based ordering, 0 = continuous. */
|
|
77
|
+
slot_based_ordering: number | null;
|
|
78
|
+
/** "1" = show today's slots, "0" = hide. */
|
|
79
|
+
show_current_day: string | null;
|
|
80
|
+
/** Number of days into the future the user can pick slots for. */
|
|
81
|
+
day_limit: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface BusinessOrderTypes {
|
|
84
|
+
self_pickup: number | null;
|
|
85
|
+
delivery: number | null;
|
|
86
|
+
in_car: number | null;
|
|
87
|
+
dine_in: number | null;
|
|
88
|
+
/** "1" / "0" — legacy storage uses string. */
|
|
89
|
+
uengage_pay: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Inverted from intuition: "1" = delivery is fully disabled, "0" = enabled.
|
|
92
|
+
* Same string-typed legacy column.
|
|
93
|
+
*/
|
|
94
|
+
delivery_disabled: string | null;
|
|
95
|
+
}
|
|
96
|
+
export interface BusinessDelivery {
|
|
97
|
+
/** Service radius in kilometers. String in legacy. */
|
|
98
|
+
radius_km: string | null;
|
|
99
|
+
/** Estimated delivery time, minutes. String in legacy. */
|
|
100
|
+
time_minutes: string | null;
|
|
101
|
+
tax_percent: number | null;
|
|
102
|
+
/** Min order value above which delivery is free. */
|
|
103
|
+
free_delivery_min_order_value: number | null;
|
|
104
|
+
/** Charge applied below the free-delivery threshold. */
|
|
105
|
+
delivery_charges: number | null;
|
|
106
|
+
/** Lower bound on order value the outlet accepts at all. */
|
|
107
|
+
eligible_order_value: number | null;
|
|
108
|
+
/** 0 → applied on Gross Value; 1 → applied on SubTotal. */
|
|
109
|
+
charges_applied_on: number;
|
|
110
|
+
}
|
|
111
|
+
export interface BusinessCharges {
|
|
112
|
+
packing: {
|
|
113
|
+
/** "1" = fixed, "2" = percentage. */
|
|
114
|
+
type: string | null;
|
|
115
|
+
/** Amount or percentage depending on `type`. */
|
|
116
|
+
amount: number | null;
|
|
117
|
+
tax_percent: number | null;
|
|
118
|
+
};
|
|
119
|
+
service: {
|
|
120
|
+
/** Percentage applied as service charge for dine-in orders. */
|
|
121
|
+
amount: number | null;
|
|
122
|
+
tax_percent: number | null;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export interface BusinessAttributes {
|
|
126
|
+
pure_veg: number | null;
|
|
127
|
+
serves_cuisine: string | null;
|
|
128
|
+
manages_riders: number | null;
|
|
129
|
+
/** "1" = grocery flow enabled in the consumer app. */
|
|
130
|
+
grocery_flow: string | null;
|
|
131
|
+
/** "1" = cloud kitchen (no in-person dining). */
|
|
132
|
+
cloud_kitchen: string | null;
|
|
133
|
+
/** Numeric campus identifier for B2B tenants; null for non-campus businesses. */
|
|
134
|
+
campus_id: string | null;
|
|
135
|
+
}
|
|
136
|
+
export interface BusinessAppConfig {
|
|
137
|
+
/** "1" = display menu prices inclusive of GST in the consumer app. */
|
|
138
|
+
menu_price_inclusive_of_gst: string | null;
|
|
139
|
+
new_launch: string | null;
|
|
140
|
+
share_link: string | null;
|
|
141
|
+
launch_date: string | null;
|
|
142
|
+
/** "0" = paid plan, "1" = free (legacy inverted). */
|
|
143
|
+
paid: string | null;
|
|
144
|
+
firebase_key: string | null;
|
|
145
|
+
/** Online listing visibility toggle; 1 = visible, 0 = hidden. */
|
|
146
|
+
online_visibility: number | null;
|
|
147
|
+
wallet: {
|
|
148
|
+
/** "1" = activated, "2" = inactive. */
|
|
149
|
+
activated: string | null;
|
|
150
|
+
/** "0" = show wallet tab, "1" = hide. */
|
|
151
|
+
hidden: string | null;
|
|
152
|
+
};
|
|
13
153
|
}
|
|
14
154
|
export interface BusinessPaymentGateway {
|
|
15
155
|
razorpay: {
|
|
@@ -17,6 +157,12 @@ export interface BusinessPaymentGateway {
|
|
|
17
157
|
secret: string | null;
|
|
18
158
|
};
|
|
19
159
|
}
|
|
160
|
+
export interface BusinessBank {
|
|
161
|
+
account_holder: string | null;
|
|
162
|
+
account_number: string | null;
|
|
163
|
+
bank_name: string | null;
|
|
164
|
+
ifsc: string | null;
|
|
165
|
+
}
|
|
20
166
|
/**
|
|
21
167
|
* Public summary of a parent business. Same shape as a top-level record
|
|
22
168
|
* with the `profile` group included, but the parent's own parent is NOT
|
|
@@ -37,6 +183,17 @@ export interface BusinessRecord {
|
|
|
37
183
|
/** Direct parent business (single level), or null if root. */
|
|
38
184
|
parent: BusinessParent | null;
|
|
39
185
|
profile?: BusinessProfile;
|
|
40
|
-
|
|
186
|
+
branding?: BusinessBranding;
|
|
187
|
+
compliance?: BusinessCompliance;
|
|
188
|
+
address?: BusinessAddress;
|
|
189
|
+
contact?: BusinessContact;
|
|
190
|
+
hours?: BusinessHours;
|
|
191
|
+
slots?: BusinessSlots;
|
|
192
|
+
order_types?: BusinessOrderTypes;
|
|
193
|
+
delivery?: BusinessDelivery;
|
|
194
|
+
charges?: BusinessCharges;
|
|
195
|
+
attributes?: BusinessAttributes;
|
|
196
|
+
app_config?: BusinessAppConfig;
|
|
41
197
|
payment_gateway?: BusinessPaymentGateway;
|
|
198
|
+
bank?: BusinessBank;
|
|
42
199
|
}
|
package/dist/business/schema.js
CHANGED
|
@@ -5,5 +5,20 @@ exports.BUSINESS_GROUPS = void 0;
|
|
|
5
5
|
* Group names recognised by the business read API. Mirrors the GROUPS
|
|
6
6
|
* registry in services/business; if the server adds a group, add it here.
|
|
7
7
|
*/
|
|
8
|
-
exports.BUSINESS_GROUPS = [
|
|
9
|
-
|
|
8
|
+
exports.BUSINESS_GROUPS = [
|
|
9
|
+
'profile',
|
|
10
|
+
'branding',
|
|
11
|
+
'compliance',
|
|
12
|
+
'address',
|
|
13
|
+
'contact',
|
|
14
|
+
'hours',
|
|
15
|
+
'slots',
|
|
16
|
+
'order_types',
|
|
17
|
+
'delivery',
|
|
18
|
+
'charges',
|
|
19
|
+
'attributes',
|
|
20
|
+
'app_config',
|
|
21
|
+
'payment_gateway',
|
|
22
|
+
'bank',
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2J1c2luZXNzL3NjaGVtYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7O0dBR0c7QUFDVSxRQUFBLGVBQWUsR0FBRztJQUM3QixTQUFTO0lBQ1QsVUFBVTtJQUNWLFlBQVk7SUFDWixTQUFTO0lBQ1QsU0FBUztJQUNULE9BQU87SUFDUCxPQUFPO0lBQ1AsYUFBYTtJQUNiLFVBQVU7SUFDVixTQUFTO0lBQ1QsWUFBWTtJQUNaLFlBQVk7SUFDWixpQkFBaUI7SUFDakIsTUFBTTtDQUNFLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdyb3VwIG5hbWVzIHJlY29nbmlzZWQgYnkgdGhlIGJ1c2luZXNzIHJlYWQgQVBJLiBNaXJyb3JzIHRoZSBHUk9VUFNcbiAqIHJlZ2lzdHJ5IGluIHNlcnZpY2VzL2J1c2luZXNzOyBpZiB0aGUgc2VydmVyIGFkZHMgYSBncm91cCwgYWRkIGl0IGhlcmUuXG4gKi9cbmV4cG9ydCBjb25zdCBCVVNJTkVTU19HUk9VUFMgPSBbXG4gICdwcm9maWxlJyxcbiAgJ2JyYW5kaW5nJyxcbiAgJ2NvbXBsaWFuY2UnLFxuIC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|
|
1
1
|
import { type AuditClient } from './audit/client';
|
|
2
2
|
import { type BusinessClient } from './business/client';
|
|
3
|
-
import {
|
|
3
|
+
import { type ZonesClient } from './zones/client';
|
|
4
|
+
import { auth as authNamespace } from './auth';
|
|
4
5
|
/**
|
|
5
|
-
* Caller-facing config for
|
|
6
|
-
* the `platform` singleton.
|
|
6
|
+
* Caller-facing config for `createClient(...)`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* `createClient()` (no args) reads everything from the standard
|
|
9
|
+
* `UENGAGE_*` environment variables — convenient for Lambdas that
|
|
10
|
+
* already have their config injected by the deploy stack. Any field
|
|
11
|
+
* passed explicitly overrides the matching env default for that one
|
|
12
|
+
* call only (no shared mutable state, no singleton).
|
|
11
13
|
*
|
|
12
|
-
*
|
|
14
|
+
* Auth-mode fields are mutually exclusive. Pick one:
|
|
15
|
+
* - `serviceId` + `serviceSecret` OAuth2 client_credentials.
|
|
16
|
+
* - `authToken` static Bearer token, or async
|
|
17
|
+
* callback that returns one.
|
|
18
|
+
* - `session: {id, token}` legacy uEngage (id, apiToken) /
|
|
19
|
+
* (id, addo_contacts_mapping.token)
|
|
20
|
+
* pair. The SDK probes the business
|
|
21
|
+
* surface (users) first, falls back
|
|
22
|
+
* to the customer surface
|
|
23
|
+
* (addo_contacts_mapping) if the
|
|
24
|
+
* business probe returns
|
|
25
|
+
* `invalid_grant`, and caches the
|
|
26
|
+
* resulting JWT.
|
|
27
|
+
*
|
|
28
|
+
* Passing more than one explicitly is a `ConfigError`. Passing any one
|
|
29
|
+
* of them suppresses every env-derived auth default, so a caller's
|
|
30
|
+
* explicit override is never silently merged with env credentials of
|
|
31
|
+
* a different mode.
|
|
13
32
|
*/
|
|
14
33
|
export interface ClientConfig {
|
|
15
34
|
baseUrl?: string;
|
|
16
35
|
/**
|
|
17
36
|
* Auth surface base used to bootstrap the first client_credentials
|
|
18
|
-
* mint. Defaults to `${baseUrl}/auth/business`.
|
|
19
|
-
* future auth calls follow the token's `iss` claim.
|
|
37
|
+
* mint. Defaults to `${baseUrl}/auth/business`.
|
|
20
38
|
*/
|
|
21
39
|
authBaseUrl?: string;
|
|
22
40
|
/**
|
|
23
|
-
* Customer auth surface base used by `
|
|
24
|
-
*
|
|
41
|
+
* Customer auth surface base used by `session` exchanges. Defaults to
|
|
42
|
+
* `${baseUrl}/auth/customer`.
|
|
25
43
|
*/
|
|
26
44
|
customerAuthBaseUrl?: string;
|
|
27
|
-
|
|
45
|
+
/** OAuth2 `client_credentials` clientId. Pair with `serviceSecret`. */
|
|
28
46
|
serviceId?: string;
|
|
47
|
+
/** OAuth2 `client_credentials` clientSecret. Pair with `serviceId`. */
|
|
29
48
|
serviceSecret?: string;
|
|
30
49
|
/** Space-separated scope list to request when minting via client_credentials. */
|
|
31
50
|
scope?: string;
|
|
51
|
+
/** Static Bearer JWT, or async callback that returns one. */
|
|
52
|
+
authToken?: string | (() => string | Promise<string>);
|
|
53
|
+
/**
|
|
54
|
+
* Legacy uEngage (id, token) pair. `id` is `users.userId` for staff
|
|
55
|
+
* users (matched via the business surface) or
|
|
56
|
+
* `addo_contacts_mapping.id`/`contactId` for customers (matched via
|
|
57
|
+
* the customer surface). The SDK probes the business surface first
|
|
58
|
+
* and falls back to customer on `invalid_grant`.
|
|
59
|
+
*/
|
|
60
|
+
session?: {
|
|
61
|
+
id: string | number;
|
|
62
|
+
token: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* `(accessToken, refreshToken)` pair from a finished login flow
|
|
66
|
+
* (`auth.loginWithPassword(...)`, `auth.verifyOtp(...)`, etc). The
|
|
67
|
+
* SDK uses the access token until it expires, then rotates via
|
|
68
|
+
* `auth.refresh(...)` transparently. `onRotate` fires after every
|
|
69
|
+
* rotation so callers can persist the new pair.
|
|
70
|
+
*/
|
|
71
|
+
tokens?: {
|
|
72
|
+
accessToken: string;
|
|
73
|
+
refreshToken: string;
|
|
74
|
+
/** Access token TTL (seconds), as returned by the auth surface. */
|
|
75
|
+
expiresIn: number;
|
|
76
|
+
/** OAuth client id used during the original login (required by the refresh handler). */
|
|
77
|
+
clientId: string;
|
|
78
|
+
onRotate?: (pair: {
|
|
79
|
+
accessToken: string;
|
|
80
|
+
refreshToken: string;
|
|
81
|
+
expiresAt: number;
|
|
82
|
+
}) => void | Promise<void>;
|
|
83
|
+
};
|
|
32
84
|
/**
|
|
33
85
|
* Service identifier the audit client should stamp into `actor.via`
|
|
34
86
|
* on emitted events. Defaults to `serviceId` when set; otherwise
|
|
@@ -41,48 +93,22 @@ export interface ClientConfig {
|
|
|
41
93
|
export interface PlatformClient {
|
|
42
94
|
business: BusinessClient;
|
|
43
95
|
audit: AuditClient;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* Return a derived client bound to the supplied access token.
|
|
47
|
-
* Inherits `baseUrl` and `fetchFn`; replaces the token source with
|
|
48
|
-
* the new one. Use case: BFF handlers that want to call the
|
|
49
|
-
* platform API as the end user instead of as the service.
|
|
50
|
-
*/
|
|
51
|
-
withToken(token: string | (() => string | Promise<string>)): PlatformClient;
|
|
96
|
+
zones: ZonesClient;
|
|
97
|
+
auth: typeof authNamespace;
|
|
52
98
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
99
|
+
* Resolve the current access token, minting via the configured auth
|
|
100
|
+
* mode if the cache is cold. Useful for `auth.verifyAccessToken(...)`
|
|
101
|
+
* round-trips and for callers that want to log / forward the bearer
|
|
102
|
+
* to a downstream service.
|
|
103
|
+
*
|
|
104
|
+
* Throws `ConfigError` when the client was built with no auth mode.
|
|
59
105
|
*/
|
|
60
|
-
|
|
106
|
+
getAccessToken(): Promise<string>;
|
|
61
107
|
}
|
|
62
108
|
/**
|
|
63
|
-
* Build a fresh, isolated client
|
|
64
|
-
*
|
|
65
|
-
*
|
|
109
|
+
* Build a fresh, isolated client. With no args, reads `UENGAGE_*`
|
|
110
|
+
* env vars; explicit fields override per call. Each call gets its own
|
|
111
|
+
* TokenSource state — concurrent `createClient(...)` use does not
|
|
112
|
+
* stampede the cache.
|
|
66
113
|
*/
|
|
67
114
|
export declare function createClient(input?: ClientConfig): PlatformClient;
|
|
68
|
-
/**
|
|
69
|
-
* Default client. Reads config from environment variables on first
|
|
70
|
-
* property access (so test setups that mutate `process.env` after
|
|
71
|
-
* import work). Use `createClient(...)` when you need an isolated
|
|
72
|
-
* instance with explicit config.
|
|
73
|
-
*
|
|
74
|
-
* UENGAGE_BASE_URL defaults to https://api.platform.uengage.io
|
|
75
|
-
* UENGAGE_AUTH_BASE_URL auth surface override (default ${baseUrl}/auth/business)
|
|
76
|
-
* UENGAGE_AUTH_TOKEN static Bearer token (overrides client_credentials)
|
|
77
|
-
* UENGAGE_SERVICE_ID OAuth2 client_credentials clientId
|
|
78
|
-
* UENGAGE_SERVICE_SECRET OAuth2 client_credentials clientSecret
|
|
79
|
-
* UENGAGE_SERVICE_SCOPE optional space-separated scope list
|
|
80
|
-
*/
|
|
81
|
-
export declare const platform: PlatformClient;
|
|
82
|
-
/** Test-only: drop the singleton cache between cases. */
|
|
83
|
-
export declare function _resetPlatformSingleton(): void;
|
|
84
|
-
/**
|
|
85
|
-
* Convenience: shorthand for `platform.withToken(token)`.
|
|
86
|
-
* BFF handlers commonly call this once per request.
|
|
87
|
-
*/
|
|
88
|
-
export declare function withToken(token: string | (() => string | Promise<string>)): PlatformClient;
|