@colixsystems/widget-sdk 0.318.0 → 0.319.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 +5 -1
- package/dist/contract.cjs +6 -4
- package/dist/contract.js +6 -4
- package/dist/hooks.js +2 -2
- package/dist/index.d.ts +6 -2
- package/dist/people-picker-view.js +1 -0
- package/package.json +1 -1
- package/src/contract.js +6 -4
package/README.md
CHANGED
|
@@ -92,6 +92,10 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
92
92
|
|
|
93
93
|
`v0.318.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**.
|
|
94
94
|
|
|
95
|
+
### What's new in 0.319.0 (contract 1.259.0)
|
|
96
|
+
|
|
97
|
+
**You can show other people's profile photos.** Every `useDirectory()` and `useUsers()` row now carries `photo_url`: the person's profile photo as an absolute URL, or `null` when they have none or their account is deactivated. Pass it straight to `<Avatar name={row.name} seed={row.id} url={row.photo_url} />`, which falls back to the initials when it is `null` or cannot load. `<PeoplePicker>` shows it on user rows by itself. Anyone who can see a person's name in the directory sees their photo. Additive: a widget that ignores the field is unchanged.
|
|
98
|
+
|
|
95
99
|
### What's new in 0.318.0 (contract 1.258.0)
|
|
96
100
|
|
|
97
101
|
**The linter refuses a charge that does not say what it sells.** The server has refused every `requestPayment` call without `kind` since 0.279.0, but nothing caught it before publishing, so a widget that left it out passed every check and then failed for every buyer. A `requestPayment` call whose options object omits `kind` is now the publish-blocking `payment-kind-required` finding, in `appstudio-widget lint` and in the platform's publish gate alike. Only the key is checked: `kind: props.kind` passes, and the server validates the value. An options object built in a local (`const body = { … }; requestPayment(body)`) is read where it is declared; an argument the source does not spell out, such as a spread or a function parameter, is left to the server. Fix: `requestPayment({ amount_cents, description, kind: "physical" })`, or `"service"` or `"digital"`.
|
|
@@ -1605,7 +1609,7 @@ function ProfileHeader() {
|
|
|
1605
1609
|
- **`useUserPhoto()`** returns `{ url, canEdit, upload, remove, uploading, error }`. `url` is the same value as `useUser().photoUrl`. `upload(file)` takes the file `<FilePicker>` gives you, or `asset.file` from `useCamera()` / `useImageEditor()` — never the asset itself (a browser `File` on web, expo-file-system's `File` in the exported app) and resolves `{ photoUrl }`; `remove()` resolves `{ photoUrl: null }`. Once either resolves, every widget on the page reads the new `useUser().photoUrl`.
|
|
1606
1610
|
- **The server crops the image to a square and resizes it.** PNG, JPEG or WebP, 10 MB at most. A refusal carries `err.status`: `413` too large, `415` unsupported type, `400` unreadable image.
|
|
1607
1611
|
- **Check `canEdit` before offering the control.** It is false when nobody is signed in and on a host that cannot change the photo, such as the Builder canvas preview. `upload()` and `remove()` then reject (`"Sign in to change your photo"` / `"Changing your photo is not available here"`) and set `error`; the hook itself never throws at render.
|
|
1608
|
-
- **
|
|
1612
|
+
- **Other people's photos come from the directory.** Each `useUsers()` / `useDirectory()` row carries `photo_url`, an absolute URL or `null`: `<Avatar name={row.name} seed={row.id} url={row.photo_url} />`. `useUserPhoto()` only ever changes the caller's own.
|
|
1609
1613
|
- **No new scope.** The hook only ever touches the caller's own account.
|
|
1610
1614
|
|
|
1611
1615
|
A host backs the hook with the new optional `WidgetContext.account` slice, `{ setPhoto(file), removePhoto() }`. A host without it needs no change: `photoUrl` reads `null` and `canEdit` is false.
|
package/dist/contract.cjs
CHANGED
|
@@ -1052,8 +1052,8 @@ const HOOKS = [
|
|
|
1052
1052
|
"url update in every widget on the page. canEdit is false when nobody is signed in and on a host that cannot change " +
|
|
1053
1053
|
"the photo (the Builder canvas preview): hide or disable the control then — upload() / remove() reject with an Error and " +
|
|
1054
1054
|
"set error rather than the hook throwing at render, as does upload() with no file. uploading is true while any call is in flight; error holds the last " +
|
|
1055
|
-
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account.
|
|
1056
|
-
"
|
|
1055
|
+
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account. Another " +
|
|
1056
|
+
"user's photo is photo_url on their useUsers() / useDirectory() row; this hook only changes your own. Identical on web (Player) and the Expo export.",
|
|
1057
1057
|
returnShape: {
|
|
1058
1058
|
url: "string | null // same value as useUser().photoUrl",
|
|
1059
1059
|
canEdit: "boolean // signed in AND the host can change the photo",
|
|
@@ -2410,7 +2410,7 @@ const HOOKS = [
|
|
|
2410
2410
|
description:
|
|
2411
2411
|
"Read-only roster of app users. query is { q?, role?, is_active?, group_id?, ids?, limit?, offset? }; ids (1 to 100) resolves the names behind ids a widget already holds.",
|
|
2412
2412
|
returnShape: {
|
|
2413
|
-
users: "Array<{ id, name, role }> // snake_case rows; unwrapped from { data, meta }",
|
|
2413
|
+
users: "Array<{ id, name, role, photo_url }> // snake_case rows; photo_url absolute or null; unwrapped from { data, meta }",
|
|
2414
2414
|
loading: "boolean",
|
|
2415
2415
|
error: "DatastoreError | null",
|
|
2416
2416
|
refetch: "() => Promise<void>",
|
|
@@ -6973,7 +6973,9 @@ const CONTRACT = deepFreeze({
|
|
|
6973
6973
|
// `crypto.hashSecret` / `crypto.verifySecret` hash a PIN or passcode.
|
|
6974
6974
|
// 1.258.0: stricter lint (sc-15497) — `requestPayment` without `kind` is
|
|
6975
6975
|
// the publish-blocking `payment-kind-required` finding.
|
|
6976
|
-
|
|
6976
|
+
// 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
|
|
6977
|
+
// person's profile photo as an absolute URL or null.
|
|
6978
|
+
version: "1.259.0",
|
|
6977
6979
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6978
6980
|
hooks: HOOKS,
|
|
6979
6981
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -1047,8 +1047,8 @@ const HOOKS = [
|
|
|
1047
1047
|
"url update in every widget on the page. canEdit is false when nobody is signed in and on a host that cannot change " +
|
|
1048
1048
|
"the photo (the Builder canvas preview): hide or disable the control then — upload() / remove() reject with an Error and " +
|
|
1049
1049
|
"set error rather than the hook throwing at render, as does upload() with no file. uploading is true while any call is in flight; error holds the last " +
|
|
1050
|
-
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account.
|
|
1051
|
-
"
|
|
1050
|
+
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account. Another " +
|
|
1051
|
+
"user's photo is photo_url on their useUsers() / useDirectory() row; this hook only changes your own. Identical on web (Player) and the Expo export.",
|
|
1052
1052
|
returnShape: {
|
|
1053
1053
|
url: "string | null // same value as useUser().photoUrl",
|
|
1054
1054
|
canEdit: "boolean // signed in AND the host can change the photo",
|
|
@@ -2405,7 +2405,7 @@ const HOOKS = [
|
|
|
2405
2405
|
description:
|
|
2406
2406
|
"Read-only roster of app users. query is { q?, role?, is_active?, group_id?, ids?, limit?, offset? }; ids (1 to 100) resolves the names behind ids a widget already holds.",
|
|
2407
2407
|
returnShape: {
|
|
2408
|
-
users: "Array<{ id, name, role }> // snake_case rows; unwrapped from { data, meta }",
|
|
2408
|
+
users: "Array<{ id, name, role, photo_url }> // snake_case rows; photo_url absolute or null; unwrapped from { data, meta }",
|
|
2409
2409
|
loading: "boolean",
|
|
2410
2410
|
error: "DatastoreError | null",
|
|
2411
2411
|
refetch: "() => Promise<void>",
|
|
@@ -6968,7 +6968,9 @@ const CONTRACT = deepFreeze({
|
|
|
6968
6968
|
// `crypto.hashSecret` / `crypto.verifySecret` hash a PIN or passcode.
|
|
6969
6969
|
// 1.258.0: stricter lint (sc-15497) — `requestPayment` without `kind` is
|
|
6970
6970
|
// the publish-blocking `payment-kind-required` finding.
|
|
6971
|
-
|
|
6971
|
+
// 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
|
|
6972
|
+
// person's profile photo as an absolute URL or null.
|
|
6973
|
+
version: "1.259.0",
|
|
6972
6974
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6973
6975
|
hooks: HOOKS,
|
|
6974
6976
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -353,8 +353,8 @@ const USER_PHOTO_NO_FILE = "useUserPhoto: file is required";
|
|
|
353
353
|
* signed in, `canEdit` is false and `upload` / `remove` reject instead of the
|
|
354
354
|
* hook throwing at render.
|
|
355
355
|
*
|
|
356
|
-
*
|
|
357
|
-
* `useDirectory()`
|
|
356
|
+
* Another user's photo is the `photo_url` on their `useUsers()` /
|
|
357
|
+
* `useDirectory()` row; this hook only changes the caller's own.
|
|
358
358
|
*/
|
|
359
359
|
export function useUserPhoto() {
|
|
360
360
|
const ctx = useWidgetContextOrThrow("useUserPhoto");
|
package/dist/index.d.ts
CHANGED
|
@@ -1491,6 +1491,8 @@ export interface DirectoryUser {
|
|
|
1491
1491
|
id: string;
|
|
1492
1492
|
name: string;
|
|
1493
1493
|
role: "USER" | "INTEGRATION";
|
|
1494
|
+
/** Their profile photo as an absolute URL, ready for `<Avatar url>`; null when none is set. */
|
|
1495
|
+
photo_url?: string | null;
|
|
1494
1496
|
}
|
|
1495
1497
|
|
|
1496
1498
|
export interface DirectoryQuery {
|
|
@@ -2541,8 +2543,8 @@ export interface UserPhotoApi {
|
|
|
2541
2543
|
* render: where nobody is signed in, or the host cannot change the photo,
|
|
2542
2544
|
* `canEdit` is false and `upload` / `remove` reject. Pass `upload` the
|
|
2543
2545
|
* file `<FilePicker>` gives you, or `asset.file` from `useCamera()` /
|
|
2544
|
-
* `useImageEditor()`.
|
|
2545
|
-
* `useUsers()`
|
|
2546
|
+
* `useImageEditor()`. Another user's photo is the `photo_url` on their
|
|
2547
|
+
* `useUsers()` / `useDirectory()` row; this hook only changes your own.
|
|
2546
2548
|
*/
|
|
2547
2549
|
export function useUserPhoto(): UserPhotoApi;
|
|
2548
2550
|
|
|
@@ -3725,6 +3727,8 @@ export interface AppUserRow {
|
|
|
3725
3727
|
email?: string;
|
|
3726
3728
|
role: "USER" | "INTEGRATION";
|
|
3727
3729
|
is_active: boolean;
|
|
3730
|
+
/** Their profile photo as an absolute URL, ready for `<Avatar url>`; null when none is set. */
|
|
3731
|
+
photo_url?: string | null;
|
|
3728
3732
|
}
|
|
3729
3733
|
|
|
3730
3734
|
export interface UsersQuery {
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -1047,8 +1047,8 @@ const HOOKS = [
|
|
|
1047
1047
|
"url update in every widget on the page. canEdit is false when nobody is signed in and on a host that cannot change " +
|
|
1048
1048
|
"the photo (the Builder canvas preview): hide or disable the control then — upload() / remove() reject with an Error and " +
|
|
1049
1049
|
"set error rather than the hook throwing at render, as does upload() with no file. uploading is true while any call is in flight; error holds the last " +
|
|
1050
|
-
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account.
|
|
1051
|
-
"
|
|
1050
|
+
"failure and clears on the next attempt. Needs no scope: it only ever touches the caller's own account. Another " +
|
|
1051
|
+
"user's photo is photo_url on their useUsers() / useDirectory() row; this hook only changes your own. Identical on web (Player) and the Expo export.",
|
|
1052
1052
|
returnShape: {
|
|
1053
1053
|
url: "string | null // same value as useUser().photoUrl",
|
|
1054
1054
|
canEdit: "boolean // signed in AND the host can change the photo",
|
|
@@ -2405,7 +2405,7 @@ const HOOKS = [
|
|
|
2405
2405
|
description:
|
|
2406
2406
|
"Read-only roster of app users. query is { q?, role?, is_active?, group_id?, ids?, limit?, offset? }; ids (1 to 100) resolves the names behind ids a widget already holds.",
|
|
2407
2407
|
returnShape: {
|
|
2408
|
-
users: "Array<{ id, name, role }> // snake_case rows; unwrapped from { data, meta }",
|
|
2408
|
+
users: "Array<{ id, name, role, photo_url }> // snake_case rows; photo_url absolute or null; unwrapped from { data, meta }",
|
|
2409
2409
|
loading: "boolean",
|
|
2410
2410
|
error: "DatastoreError | null",
|
|
2411
2411
|
refetch: "() => Promise<void>",
|
|
@@ -6968,7 +6968,9 @@ const CONTRACT = deepFreeze({
|
|
|
6968
6968
|
// `crypto.hashSecret` / `crypto.verifySecret` hash a PIN or passcode.
|
|
6969
6969
|
// 1.258.0: stricter lint (sc-15497) — `requestPayment` without `kind` is
|
|
6970
6970
|
// the publish-blocking `payment-kind-required` finding.
|
|
6971
|
-
|
|
6971
|
+
// 1.259.0: `useDirectory()` / `useUsers()` rows carry `photo_url`, the
|
|
6972
|
+
// person's profile photo as an absolute URL or null.
|
|
6973
|
+
version: "1.259.0",
|
|
6972
6974
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
6973
6975
|
hooks: HOOKS,
|
|
6974
6976
|
primitives: PRIMITIVES,
|