@colixsystems/widget-sdk 0.60.0 → 0.62.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 +14 -2
- package/dist/contract.cjs +13 -3
- package/dist/contract.js +13 -3
- package/dist/hooks.js +39 -12
- package/dist/index.d.ts +25 -17
- package/dist/index.js +1 -0
- package/dist/index.native.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
21
21
|
| **CORE** | `useWidgetStyle()` | `{ [styleField]: value }` | `ctx.props.style` — no scope. The author-set per-widget style values declared in `manifest.styleSchema`; apply each onto whatever element you choose. |
|
|
22
22
|
| **CORE** | `useUser()` | `{ id, email, displayName, roles, groupIds }` | `ctx.user` (host-built context, **camelCase** — not a wire payload; `id` null when anonymous) — no scope |
|
|
23
23
|
| **CORE** | `useNavigation()` | `{ goTo, goBack, push, replace, back, currentRoute }` | `ctx.navigation` — no scope (external URLs use the `Linking` primitive) |
|
|
24
|
+
| **CORE** | `useRouteParams()` | `{ [paramKey]: value }` | `ctx.navigation.currentRoute.params` — no scope. The nav params the previous page passed via `goTo(pageId, params)`; the flat accessor for master→detail (read `recordId` on a detail page). Empty object when none. |
|
|
24
25
|
| **CORE** | `useWidgetEvent(name)` | `(payload?) => void` | `ctx.events.emit` — no scope |
|
|
25
26
|
| **CORE** | `useChildRenderer()` | `{ renderNode(node) }` | `ctx.renderer` — no scope (prefer the `WidgetTree` component) |
|
|
26
27
|
| **CORE** | `useFill()` | `boolean` | `ctx.fill` — no scope. `true` when the host sized this widget to fill its page-grid tile's reserved height (containers + media fill by default; the author can override per tile). Media-style widgets switch to a `flex: 1` / `height: "100%"` layout; others ignore it. Defaults `false`. |
|
|
@@ -52,7 +53,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
52
53
|
|
|
53
54
|
## Status
|
|
54
55
|
|
|
55
|
-
`v0.
|
|
56
|
+
`v0.62.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
57
|
+
|
|
58
|
+
### What's new in 0.62.0
|
|
59
|
+
|
|
60
|
+
**`usePayments()` — the host owns the hosted-checkout redirect, and the documented contract is corrected to snake_case (sc-3290).** Two things that had drifted are now aligned with the runtime:
|
|
61
|
+
|
|
62
|
+
- **The host opens Checkout; the widget never does.** When a hosted-checkout provider (Mollie) is active, `requestPayment(...)` now makes the host open Checkout itself — a **same-tab** redirect on web, the **in-app browser** on native (the identical model the paid-signup flow uses). The result no longer carries a `checkout_url`, and widgets must **not** call `Linking.openURL(...)` for payments: `react-native-web`'s `Linking.openURL` opens a `_blank`, `noopener` tab, which left the app user stranded on an orphan tab after paying. `return_path` now defaults to the current page, so the web return lands the user back where they started. Confirm completion from server-authoritative state (the Mollie webhook flips your datastore record) or by polling `getPayment(id)`.
|
|
63
|
+
- **`PaymentRequest` / `PaymentResult` types are snake_case.** The TypeScript types and the `CONTRACT` return-shape strings described `amountCents` / `checkoutUrl` (plus a `metadata` field the client never forwarded), but the wire — and the runtime client — have always been snake_case. They now read `amount_cents`, `currency?`, `description`, `return_path?` in, `{ id, status, amount_cents, ... }` out. A TS widget that passed `amountCents` was silently sending `undefined`; update to `amount_cents`.
|
|
64
|
+
- No `CONTRACT.version` change — the `ctx.payments` context shape (`{ requestPayment, getPayment }`) is unchanged; only its documented request/return shape and the host-owned redirect behaviour changed.
|
|
56
65
|
|
|
57
66
|
### What's new in 0.60.0
|
|
58
67
|
|
|
@@ -384,6 +393,7 @@ The "split-implementation + vetted package list" pivot.
|
|
|
384
393
|
### What's new in 0.11.0
|
|
385
394
|
|
|
386
395
|
- **`useNavigation()` is wired.** Returns the host-provided navigation surface `{ goTo, goBack, push, replace, back, currentRoute }` for internal page-to-page navigation. Missing methods degrade to no-ops on the Studio canvas preview. Additive.
|
|
396
|
+
- **`useRouteParams()` reads the nav params.** Returns `currentRoute.params` — the bag a `goTo(pageId, params)` carried to this page. The flat accessor for master→detail: navigate with `goTo(detailPageId, { recordId: row.id })`, then read `const { recordId } = useRouteParams()`. It is an OBJECT — read a param off it, never call it. Empty object when the page was opened without params. Additive (v0.61.0).
|
|
387
397
|
- **`Linking` primitive re-exported.** `Linking.openURL(url)` opens an external URL with the OS handler — web (`react-native-web`) maps to `window.open` / `location.href`; native hands off to the system. Use this for external URLs; use `useNavigation().goTo(pageId)` for internal pages.
|
|
388
398
|
|
|
389
399
|
### What's new in 0.10.0
|
|
@@ -392,6 +402,8 @@ The "split-implementation + vetted package list" pivot.
|
|
|
392
402
|
|
|
393
403
|
### What's new in 0.9.0
|
|
394
404
|
|
|
405
|
+
> **Superseded in 0.62.0** — the wire was always snake_case (`amount_cents`, `return_path`), never the camelCase shown below, and the HOST now opens hosted Checkout itself (the widget does not). See the 0.62.0 entry for the current contract.
|
|
406
|
+
|
|
395
407
|
- **`usePayments()` — incoming app-user payments.** Returns `{ requestPayment, getPayment }`. `requestPayment({ amountCents, currency?, description, metadata?, returnPath? })` triggers a one-time charge from the signed-in app user and resolves to `{ id, status, checkoutUrl? }`: when `checkoutUrl` is present the widget opens it (web: navigate; native: `expo-web-browser`) — the user pays in the provider's **hosted checkout**; when absent (the platform's built-in **mock** provider, the default until a real provider is configured) the charge auto-confirms (`status: "PAID"`). `getPayment(id)` polls the terminal status. Backed by a new `WidgetContext.payments` slice and gated by the new `payments.charge:appUser` scope. **No card data ever touches the widget** — never collect card fields yourself. The charge settles to the workspace owner; the amount is bounded by a platform per-charge cap. Rejections are a structured `PaymentError` (also a new named export) with a stable `.code`.
|
|
396
408
|
- **`CONTRACT.version` → `1.2.0`** (additive: one new hook, one new context slice, one new scope, one new error class). No existing export changed signature.
|
|
397
409
|
|
|
@@ -454,7 +466,7 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
|
|
|
454
466
|
|
|
455
467
|
- `defineWidget({ manifest, component })` — validates the manifest and produces a widget module the host can register.
|
|
456
468
|
- `validateManifest(m)` / `validatePropertySchema(s)` / `validateProps(schema, props)` — shape validation; no third-party deps.
|
|
457
|
-
- `useDatastoreQuery`, `useDatastoreRecord`, `useDatastoreSchema`, `useDatastoreMutation`, `useDirectory`, `useUsers`, `useGroups`, `useRecordPermissions`, `useAsset`, `useWidgetEvent`, `usePayments`, `useSendNotification`, `useTheme`, `useI18n`, `useUser`, `useNavigation`, `useChildRenderer`, `useClipboard`, `useToast` — hooks that read from the host-provided `WidgetContext` (or, for `useClipboard`, the platform clipboard API directly). `useDirectory(query?)` returns `{ users, loading, error, refetch }` (each user `{ id, name, role }`) and requires the `directory.read:users` scope. `useUsers(query?)` returns `{ users, loading, error, refetch, invite, deactivate, reactivate, remove }` and requires `users.read:*` (mutations also need `users.write:*`); rejections are a `DirectoryError`. `useGroups(query?)` returns `{ groups, loading, error, refetch, create, remove, addMember, removeMember }` and requires `groups.read:*` (mutations also need `groups.write:*`). `usePayments()` returns `{ requestPayment, getPayment }` and requires the `payments.charge:appUser` scope; `requestPayment(...)` rejects with a `PaymentError`. `useSendNotification()` returns `{ send, sending, error }` and requires the `notifications.send:appUser` scope; `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace (cross-workspace `recipient_user_id` is rejected), must be called from an event handler rather than render, and rejects with a `NotificationError`. `useUser()` returns the active end-user identity `{ id, email, displayName, roles, groupIds }` (camelCase — the host-built context object, not a wire payload; `id` is `null` for anonymous / preview). `useNavigation()` returns `{ goTo, goBack, push, replace, back, currentRoute }` for internal page navigation — for external URLs use the `Linking` primitive (`Linking.openURL(url)`). `useDatastoreRecord(tableId, recordId)` returns `{ data, loading, error, refetch }` for a single record (data is one row or null). `useDatastoreSchema(tableId)` returns `{ schema, loading, error, refetch }` where `schema` is `{ id, name, columns: [{ id, name, data_type, required, relation_type, target_table_id, is_identification }] }` (structure only, no row data; snake_case verbatim) — use it to resolve a stored `columnId` to its column type at runtime; requires the `datastore.read:<table>` scope. `useAsset(fileId)` returns `{ url, file, loading, error, refetch }` — the `url` is an absolute URL composed against the host's API base. `useChildRenderer()` returns `{ renderNode(node) }` — container widgets call it to render arbitrary child page-tree nodes (prefer the `WidgetTree` component for the common case).
|
|
469
|
+
- `useDatastoreQuery`, `useDatastoreRecord`, `useDatastoreSchema`, `useDatastoreMutation`, `useDirectory`, `useUsers`, `useGroups`, `useRecordPermissions`, `useAsset`, `useWidgetEvent`, `usePayments`, `useSendNotification`, `useTheme`, `useI18n`, `useUser`, `useNavigation`, `useRouteParams`, `useChildRenderer`, `useClipboard`, `useToast` — hooks that read from the host-provided `WidgetContext` (or, for `useClipboard`, the platform clipboard API directly). `useDirectory(query?)` returns `{ users, loading, error, refetch }` (each user `{ id, name, role }`) and requires the `directory.read:users` scope. `useUsers(query?)` returns `{ users, loading, error, refetch, invite, deactivate, reactivate, remove }` and requires `users.read:*` (mutations also need `users.write:*`); rejections are a `DirectoryError`. `useGroups(query?)` returns `{ groups, loading, error, refetch, create, remove, addMember, removeMember }` and requires `groups.read:*` (mutations also need `groups.write:*`). `usePayments()` returns `{ requestPayment, getPayment }` and requires the `payments.charge:appUser` scope; `requestPayment(...)` rejects with a `PaymentError`. `useSendNotification()` returns `{ send, sending, error }` and requires the `notifications.send:appUser` scope; `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace (cross-workspace `recipient_user_id` is rejected), must be called from an event handler rather than render, and rejects with a `NotificationError`. `useUser()` returns the active end-user identity `{ id, email, displayName, roles, groupIds }` (camelCase — the host-built context object, not a wire payload; `id` is `null` for anonymous / preview). `useNavigation()` returns `{ goTo, goBack, push, replace, back, currentRoute }` for internal page navigation — for external URLs use the `Linking` primitive (`Linking.openURL(url)`). `useRouteParams()` returns the current route's params object (`currentRoute.params`) — the flat master→detail accessor; read a param off it (e.g. `recordId`), never call it. `useDatastoreRecord(tableId, recordId)` returns `{ data, loading, error, refetch }` for a single record (data is one row or null). `useDatastoreSchema(tableId)` returns `{ schema, loading, error, refetch }` where `schema` is `{ id, name, columns: [{ id, name, data_type, required, relation_type, target_table_id, is_identification }] }` (structure only, no row data; snake_case verbatim) — use it to resolve a stored `columnId` to its column type at runtime; requires the `datastore.read:<table>` scope. `useAsset(fileId)` returns `{ url, file, loading, error, refetch }` — the `url` is an absolute URL composed against the host's API base. `useChildRenderer()` returns `{ renderNode(node) }` — container widgets call it to render arbitrary child page-tree nodes (prefer the `WidgetTree` component for the common case).
|
|
458
470
|
- `WidgetTree({ node })` — component that renders an author-authored child node through the host's renderer; used by Tabs / Card / custom containers to host arbitrary child widgets.
|
|
459
471
|
- `Text`, `View`, `Pressable`, `Image`, `ScrollView`, `TextInput`, `FlatList`, `SectionList`, `ActivityIndicator`, `Switch`, `StyleSheet`, `Linking`, `Icon`, `DateTimePicker` — re-exported from `react-native` (the RN primitives) or implemented in the SDK (`Icon` wraps `lucide-react-native`; `DateTimePicker` wraps `@react-native-community/datetimepicker` on native and renders `<input type="date|time|datetime-local">` directly on web because the RN library has no react-native-web mapping). The web build aliases `react-native` to `react-native-web` so the RN-re-exported primitives render in the browser without any per-platform code; the exported Expo app's Metro bundler resolves the real `react-native` library. `Linking` is a static API (`Linking.openURL(url)`) — use it for external URLs, and use `useNavigation().goTo(pageId)` for internal page navigation. See https://reactnative.dev/docs/ for per-component props.
|
|
460
472
|
- `WidgetContextProvider` — React context provider that the host (Studio, Player, exported app) wraps widgets with.
|
package/dist/contract.cjs
CHANGED
|
@@ -150,6 +150,16 @@ const HOOKS = [
|
|
|
150
150
|
requiredContextSlice: ["navigation"],
|
|
151
151
|
scopes: null,
|
|
152
152
|
},
|
|
153
|
+
{
|
|
154
|
+
name: "useRouteParams",
|
|
155
|
+
signature: "useRouteParams()",
|
|
156
|
+
returnShape: {
|
|
157
|
+
"<paramKey>":
|
|
158
|
+
"a navigation param value the previous page passed via goTo(pageId, params) — usually a string id, e.g. recordId on a detail page",
|
|
159
|
+
},
|
|
160
|
+
requiredContextSlice: ["navigation"],
|
|
161
|
+
scopes: null,
|
|
162
|
+
},
|
|
153
163
|
{
|
|
154
164
|
name: "useDatastoreRecord",
|
|
155
165
|
signature: "useDatastoreRecord(tableId, recordId)",
|
|
@@ -459,9 +469,9 @@ const HOOKS = [
|
|
|
459
469
|
signature: "usePayments()",
|
|
460
470
|
returnShape: {
|
|
461
471
|
requestPayment:
|
|
462
|
-
"({
|
|
472
|
+
"({ amount_cents, currency?, description, return_path? }) => Promise<{ id, status }> // host opens hosted Checkout; rejects with PaymentError",
|
|
463
473
|
getPayment:
|
|
464
|
-
"(paymentId) => Promise<{ id, status,
|
|
474
|
+
"(paymentId) => Promise<{ id, status, amount_cents, currency, description }>",
|
|
465
475
|
},
|
|
466
476
|
requiredContextSlice: ["payments.requestPayment"],
|
|
467
477
|
scopes: ["payments.charge:appUser"],
|
|
@@ -1109,7 +1119,7 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
1109
1119
|
},
|
|
1110
1120
|
payments: {
|
|
1111
1121
|
description:
|
|
1112
|
-
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status
|
|
1122
|
+
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment> }; wire is snake_case (amount_cents, return_path). Backs usePayments(); requires the payments.charge:appUser scope. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
1113
1123
|
required: true,
|
|
1114
1124
|
fields: { requestPayment: "function", getPayment: "function" },
|
|
1115
1125
|
},
|
package/dist/contract.js
CHANGED
|
@@ -150,6 +150,16 @@ const HOOKS = [
|
|
|
150
150
|
requiredContextSlice: ["navigation"],
|
|
151
151
|
scopes: null,
|
|
152
152
|
},
|
|
153
|
+
{
|
|
154
|
+
name: "useRouteParams",
|
|
155
|
+
signature: "useRouteParams()",
|
|
156
|
+
returnShape: {
|
|
157
|
+
"<paramKey>":
|
|
158
|
+
"a navigation param value the previous page passed via goTo(pageId, params) — usually a string id, e.g. recordId on a detail page",
|
|
159
|
+
},
|
|
160
|
+
requiredContextSlice: ["navigation"],
|
|
161
|
+
scopes: null,
|
|
162
|
+
},
|
|
153
163
|
{
|
|
154
164
|
name: "useDatastoreRecord",
|
|
155
165
|
signature: "useDatastoreRecord(tableId, recordId)",
|
|
@@ -459,9 +469,9 @@ const HOOKS = [
|
|
|
459
469
|
signature: "usePayments()",
|
|
460
470
|
returnShape: {
|
|
461
471
|
requestPayment:
|
|
462
|
-
"({
|
|
472
|
+
"({ amount_cents, currency?, description, return_path? }) => Promise<{ id, status }> // host opens hosted Checkout; rejects with PaymentError",
|
|
463
473
|
getPayment:
|
|
464
|
-
"(paymentId) => Promise<{ id, status,
|
|
474
|
+
"(paymentId) => Promise<{ id, status, amount_cents, currency, description }>",
|
|
465
475
|
},
|
|
466
476
|
requiredContextSlice: ["payments.requestPayment"],
|
|
467
477
|
scopes: ["payments.charge:appUser"],
|
|
@@ -1109,7 +1119,7 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
1109
1119
|
},
|
|
1110
1120
|
payments: {
|
|
1111
1121
|
description:
|
|
1112
|
-
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status
|
|
1122
|
+
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment> }; wire is snake_case (amount_cents, return_path). Backs usePayments(); requires the payments.charge:appUser scope. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
1113
1123
|
required: true,
|
|
1114
1124
|
fields: { requestPayment: "function", getPayment: "function" },
|
|
1115
1125
|
},
|
package/dist/hooks.js
CHANGED
|
@@ -249,6 +249,27 @@ export function useNavigation() {
|
|
|
249
249
|
return ctx.navigation;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
const EMPTY_PARAMS = Object.freeze({});
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Returns the current route's navigation params — the bag a `goTo(pageId, params)`
|
|
256
|
+
* carried to this page (a query string on web, react-navigation route params on
|
|
257
|
+
* native). This is the flat accessor for the master→detail pattern: a list widget
|
|
258
|
+
* navigates with `goTo(detailPageId, { recordId: row.id })`, and the detail widget
|
|
259
|
+
* reads `const { recordId } = useRouteParams()`. Returns an empty object on a page
|
|
260
|
+
* opened without params (the Studio canvas, a direct deep link), so reads are
|
|
261
|
+
* always safe. Equivalent to `useNavigation().currentRoute.params`, but without the
|
|
262
|
+
* deep chain — read a param off it, never call it.
|
|
263
|
+
*/
|
|
264
|
+
export function useRouteParams() {
|
|
265
|
+
const ctx = useWidgetContextOrThrow("useRouteParams");
|
|
266
|
+
const nav = ctx.navigation || {};
|
|
267
|
+
const route = nav.currentRoute || {};
|
|
268
|
+
// Stable reference on the empty path so `useEffect([params])` doesn't re-fire
|
|
269
|
+
// every render on a paramless page.
|
|
270
|
+
return route.params || EMPTY_PARAMS;
|
|
271
|
+
}
|
|
272
|
+
|
|
252
273
|
/**
|
|
253
274
|
* Returns { t, locale }. `t(key, fallback)` resolves `{{t:key}}` against
|
|
254
275
|
* the host's translation table and falls back to `fallback ?? key` when
|
|
@@ -2792,20 +2813,26 @@ function toPaymentError(err) {
|
|
|
2792
2813
|
|
|
2793
2814
|
/**
|
|
2794
2815
|
* Incoming app-user payments (REQ-BILL-07-WIDGETPAY). Returns
|
|
2795
|
-
* `{ requestPayment, getPayment }`.
|
|
2796
|
-
*
|
|
2797
|
-
*
|
|
2798
|
-
*
|
|
2799
|
-
*
|
|
2800
|
-
*
|
|
2801
|
-
*
|
|
2802
|
-
* `
|
|
2816
|
+
* `{ requestPayment, getPayment }`. The wire is snake_case (REQ-GEN-09) —
|
|
2817
|
+
* pass and read snake_case keys VERBATIM.
|
|
2818
|
+
*
|
|
2819
|
+
* requestPayment({ amount_cents, currency?, description, return_path? })
|
|
2820
|
+
* → Promise<{ id, status, ... }>. When a hosted-checkout provider
|
|
2821
|
+
* (Mollie) is active the HOST opens Checkout for you — a same-tab
|
|
2822
|
+
* redirect on web, the in-app browser on native — so you do NOT open
|
|
2823
|
+
* anything yourself (no `Linking.openURL`, no `checkout_url` to
|
|
2824
|
+
* handle). The mock provider auto-confirms (`status: "PAID"`, no
|
|
2825
|
+
* redirect). Rejects with a `PaymentError`.
|
|
2803
2826
|
* getPayment(paymentId) → Promise<payment> — poll the terminal status.
|
|
2804
2827
|
*
|
|
2805
|
-
*
|
|
2806
|
-
*
|
|
2807
|
-
*
|
|
2808
|
-
*
|
|
2828
|
+
* Because the web redirect reloads the app on return, confirm completion
|
|
2829
|
+
* from server-authoritative state (the Mollie webhook flips the charge /
|
|
2830
|
+
* your datastore record) — re-read your bound record on mount, or poll
|
|
2831
|
+
* `getPayment(id)` after the mock/native flow resolves. Requires the
|
|
2832
|
+
* `payments.charge:appUser` scope in the manifest's `requestedScopes`. The
|
|
2833
|
+
* charge settles to the workspace owner; the app user confirms the amount
|
|
2834
|
+
* in hosted Checkout. No card data touches the widget — never collect card
|
|
2835
|
+
* fields yourself.
|
|
2809
2836
|
*/
|
|
2810
2837
|
export function usePayments() {
|
|
2811
2838
|
const ctx = useWidgetContextOrThrow("usePayments");
|
package/dist/index.d.ts
CHANGED
|
@@ -614,32 +614,27 @@ export function useDirectory(query?: DirectoryQuery): DirectoryResult;
|
|
|
614
614
|
export function useWidgetEvent(name: string): (payload?: unknown) => void;
|
|
615
615
|
|
|
616
616
|
/**
|
|
617
|
-
* Arguments for `usePayments().requestPayment(...)`.
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* widget's own reconciliation (never used to derive the amount).
|
|
617
|
+
* Arguments for `usePayments().requestPayment(...)`. snake_case VERBATIM —
|
|
618
|
+
* this is the wire contract (REQ-GEN-09). `amount_cents` is the charge in the
|
|
619
|
+
* currency's minor unit; the app user confirms it in hosted Checkout.
|
|
621
620
|
*/
|
|
622
621
|
export interface PaymentRequest {
|
|
623
|
-
|
|
622
|
+
amount_cents: number;
|
|
624
623
|
currency?: string;
|
|
625
624
|
description: string;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
625
|
+
/**
|
|
626
|
+
* Site-relative path to return to after Checkout (e.g. "/cart"). Defaults
|
|
627
|
+
* to the current page, so the user lands back where they started.
|
|
628
|
+
*/
|
|
629
|
+
return_path?: string;
|
|
629
630
|
}
|
|
630
631
|
|
|
631
632
|
export interface PaymentResult {
|
|
632
633
|
id: string;
|
|
633
634
|
status: "PENDING" | "PAID" | "FAILED" | "REFUNDED" | "CANCELLED";
|
|
634
|
-
|
|
635
|
+
amount_cents?: number;
|
|
635
636
|
currency?: string;
|
|
636
637
|
description?: string;
|
|
637
|
-
/**
|
|
638
|
-
* Present (Mollie provider) when the app user must complete a hosted
|
|
639
|
-
* checkout: the widget should open this URL. Absent under the mock
|
|
640
|
-
* provider, where the charge auto-confirms (`status: "PAID"`).
|
|
641
|
-
*/
|
|
642
|
-
checkoutUrl?: string | null;
|
|
643
638
|
}
|
|
644
639
|
|
|
645
640
|
export interface PaymentsApi {
|
|
@@ -649,8 +644,12 @@ export interface PaymentsApi {
|
|
|
649
644
|
|
|
650
645
|
/**
|
|
651
646
|
* Incoming app-user payments (REQ-BILL-07-WIDGETPAY). Requires the
|
|
652
|
-
* `payments.charge:appUser` scope in the widget manifest.
|
|
653
|
-
*
|
|
647
|
+
* `payments.charge:appUser` scope in the widget manifest. When a hosted-
|
|
648
|
+
* checkout provider is active the HOST opens Checkout for you (a same-tab
|
|
649
|
+
* redirect on web, the in-app browser on native) — you never open a URL and
|
|
650
|
+
* never collect card data. Confirm completion from server state (the webhook
|
|
651
|
+
* flips your record) or poll `getPayment(id)`. The charge settles to the
|
|
652
|
+
* workspace owner.
|
|
654
653
|
*/
|
|
655
654
|
export function usePayments(): PaymentsApi;
|
|
656
655
|
|
|
@@ -925,6 +924,15 @@ export function useNavigation(): {
|
|
|
925
924
|
currentRoute: { pageId: string; params: Record<string, unknown> };
|
|
926
925
|
};
|
|
927
926
|
|
|
927
|
+
/**
|
|
928
|
+
* Returns the current route's navigation params — the bag a `goTo(pageId, params)`
|
|
929
|
+
* carried to this page. The flat accessor for master→detail: navigate with
|
|
930
|
+
* `goTo(detailPageId, { recordId: row.id })`, then read
|
|
931
|
+
* `const { recordId } = useRouteParams()`. Empty object when the page was opened
|
|
932
|
+
* without params. Equivalent to `useNavigation().currentRoute.params`.
|
|
933
|
+
*/
|
|
934
|
+
export function useRouteParams(): Record<string, unknown>;
|
|
935
|
+
|
|
928
936
|
/**
|
|
929
937
|
* Static API for external URLs. `openURL(url)` opens a URL with the OS
|
|
930
938
|
* handler (web: react-native-web maps to `window.open` / `location.href`;
|
package/dist/index.js
CHANGED
package/dist/index.native.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|