@colixsystems/widget-sdk 0.218.0 → 0.219.1

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/src/contract.js CHANGED
@@ -942,13 +942,14 @@ const HOOKS = [
942
942
  name: "useFill",
943
943
  signature: "useFill()",
944
944
  description:
945
- "Returns true when the host has sized this widget to fill its layout " +
946
- 'slot\'s available height — a page-grid tile whose author chose "Fill ' +
947
- 'tile height", or a widget type that fills by default (containers and ' +
948
- "media). When true, a widget that has a meaningful filled form (Image, " +
949
- "Chart, Map, Video) should switch from its intrinsic height to a stretch " +
950
- 'style (flex: 1 / height: "100%"); widgets with no useful filled form ' +
951
- "may ignore it. Defaults to false wherever the host has not opted the " +
945
+ "Returns true when the host has sized this widget to fill a box of " +
946
+ "definite height — a widget in the section a fit-to-screen page " +
947
+ "stretches to the bottom of the screen, or a widget given a fixed slot " +
948
+ "height. When true, a widget that has a meaningful filled form (Image, " +
949
+ "Chart, Map, Video, a chat or feed that scrolls its own content) should " +
950
+ "switch from its intrinsic height to a stretch style (flex: 1 / " +
951
+ 'height: "100%") and scroll inside it; widgets with no useful filled ' +
952
+ "form may ignore it. Defaults to false wherever the host has not opted the " +
952
953
  "widget into filling, so calling it is always safe. The SAME value is " +
953
954
  "injected by the web Player and the native export (widget-parity skill), so a " +
954
955
  "widget's fill behaviour is identical on both platforms.",
@@ -1511,7 +1512,15 @@ const HOOKS = [
1511
1512
  "polls (fresh QR while pending — render with the Image primitive), " +
1512
1513
  "cancel() aborts, verify() returns the offline verdict. Pass " +
1513
1514
  "existingSignatureId for an already-signed file to seed the complete " +
1514
- "state + verify() without re-signing. Reads " +
1515
+ "state + verify() without re-signing. autoStartToken is set only while " +
1516
+ "opening BankID can still help (null once the user has signed or the " +
1517
+ "order has ended). hintCode says where the order " +
1518
+ "stands; 'sealing' means the user has signed and the signature is being " +
1519
+ "added to the document, so there is nothing to scan and it can no longer " +
1520
+ "be cancelled. cancel() resolves to what became of the order, which is " +
1521
+ "then still pending or already complete: read status after it, never " +
1522
+ "assume 'cancelled'. nameRefusal is set when the order failed because " +
1523
+ "the signer's name cannot be shown on the document. Reads " +
1515
1524
  "ctx.filestore.signatures.{initiate,status,cancel,verify}.",
1516
1525
  returnShape: {
1517
1526
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
@@ -1520,12 +1529,15 @@ const HOOKS = [
1520
1529
  message: "string | null",
1521
1530
  signerName: "string | null",
1522
1531
  signedAt: "string | null",
1532
+ hintCode: "string | null // where the order stands, e.g. 'sealing'",
1533
+ nameRefusal:
1534
+ "{ reason: 'empty' | 'too_long' | 'unsupported_characters' | 'mixed_scripts', characters: string[] } | null",
1523
1535
  verdict: "{ valid, checks, content_status, signed_by_others_since, seal, ... } | null",
1524
1536
  loading: "boolean",
1525
1537
  error: "PermissionError | null // { code, message, retryable }",
1526
- initiate: "() => Promise<{ signature_id, qr, auto_start_token, status }>",
1538
+ initiate: "() => Promise<{ signature_id, qr, auto_start_token, status, hint_code?, message? }>",
1527
1539
  refresh: "() => Promise<void>",
1528
- cancel: "() => Promise<void>",
1540
+ cancel: "() => Promise<{ status, hint_code?, message?, signer_name?, signed_at? } | undefined>",
1529
1541
  verify: "() => Promise<verdict>",
1530
1542
  },
1531
1543
  requiredContextSlice: ["filestore.signatures"],
@@ -1572,6 +1584,91 @@ const HOOKS = [
1572
1584
  requiredContextSlice: ["filestore.signatures"],
1573
1585
  scopes: ["files.read:*"],
1574
1586
  },
1587
+ {
1588
+ name: "useSigningRounds",
1589
+ signature: "useSigningRounds(fileIds)",
1590
+ description:
1591
+ "What the signed-in user may know about the signing round of each file " +
1592
+ "in a list, in one batched request. A signing round fixes a PDF and a " +
1593
+ "list of signers: it is prepared and confirmed by someone who manages " +
1594
+ "the file's folder, then each signer signs once with useFileSignature(), " +
1595
+ "in any order (there are no turns; the list only orders the places on " +
1596
+ "the signature page). byFileId maps a file id to { file_id, can_manage, " +
1597
+ "can_prepare, round, locked }; a file the user cannot see is absent. " +
1598
+ "round is null when there is none, and for a user who is neither a " +
1599
+ "manager nor one of its signers; a signer sees it once it is confirmed, " +
1600
+ "with their own place (my_place) and can_sign (the round is open and " +
1601
+ "their place is unsigned), and signed_count is null " +
1602
+ "for them. locked is 'signing_round' while the file cannot be changed, " +
1603
+ "'signed' once its content cannot be replaced. roundsEnabled is false " +
1604
+ "when the workspace cannot start signing rounds (offer no way to start " +
1605
+ "one), and null until the first answer. can_prepare is about the file " +
1606
+ "and the user, roundsEnabled is about the workspace: offer 'prepare' " +
1607
+ "only when both are true. Ids are matched without regard to case. " +
1608
+ "Refetches only when the set of ids or the signed-in user changes; " +
1609
+ "until the new answer arrives loading is true and byFileId is empty. " +
1610
+ "Reads ctx.filestore.signingRounds.overview.",
1611
+ returnShape: {
1612
+ byFileId:
1613
+ "{ [fileId]: { file_id, can_manage: boolean, can_prepare: boolean, " +
1614
+ "round: { id, status: 'DRAFT' | 'OPEN' | 'COMPLETED', signer_count, signed_count: number | null, " +
1615
+ "my_place: { position, signed, signed_at } | null, can_sign: boolean } | null, " +
1616
+ "locked: 'signing_round' | 'signed' | null } }",
1617
+ roundsEnabled: "boolean | null",
1618
+ loading: "boolean",
1619
+ error: "PermissionError | null // { code, message, retryable, errors, retryAfter }",
1620
+ refresh: "() => Promise<void>",
1621
+ },
1622
+ requiredContextSlice: ["filestore.signingRounds"],
1623
+ scopes: ["files.read:*"],
1624
+ },
1625
+ {
1626
+ name: "useSigningRound",
1627
+ signature: "useSigningRound(fileId)",
1628
+ description:
1629
+ "One file's current signing round, and the actions of someone who " +
1630
+ "manages the file's folder. prepare(signerIds) drafts a round for those " +
1631
+ "users, their places on the signature page in the order given (take the " +
1632
+ "ids from useFileRoster()); it can take " +
1633
+ "up to a minute. preparedFile() returns a five-minute link to the " +
1634
+ "prepared document; show it to the user before confirming. confirm() " +
1635
+ "opens the round for exactly the document preparedFile() last returned, " +
1636
+ "and rejects with code PREVIEW_REQUIRED when it was not called first. " +
1637
+ "cancel() ends a draft or an open round and resolves to the cancelled " +
1638
+ "round (status 'CANCELLED'); round is then null. ONE ACTION RUNS AT A " +
1639
+ "TIME: while busy is true any other action is refused at once with code " +
1640
+ "ACTION_IN_PROGRESS (it is not queued), so disable your buttons on busy. " +
1641
+ "round is the full round as the " +
1642
+ "user may see it: a manager sees every signer's progress, a signer sees " +
1643
+ "every signer's name and position and their own progress only, anyone " +
1644
+ "else sees null. A refused action sets error and rejects with it: code " +
1645
+ "and message come from the server (show message as it is), errors has " +
1646
+ "one entry per refused signer ({ app_user_id, message, reason, " +
1647
+ "characters }), retryAfter is the seconds to wait. The hook's own " +
1648
+ "refusals (PREVIEW_REQUIRED, ACTION_IN_PROGRESS, NO_SIGNING_ROUND) carry " +
1649
+ "a message that can be shown the same way. When a refusal means the " +
1650
+ "round is no longer what was shown (it expired, was closed, or the " +
1651
+ "document changed) the hook reads the round again by itself. Code " +
1652
+ "SIGNING_ROUNDS_NOT_ENABLED means the workspace cannot start signing " +
1653
+ "rounds; check roundsEnabled from useSigningRounds() before offering to " +
1654
+ "start one. When fileId or the signed-in user changes, round is null " +
1655
+ "and loading true until the new answer. Reads ctx.filestore.signingRounds.",
1656
+ returnShape: {
1657
+ round:
1658
+ "{ id, file_id, status: 'DRAFT' | 'OPEN' | 'COMPLETED', created_at, confirmed_at, completed_at, expires_at, " +
1659
+ "signers: { name, position, app_user_id?, signed?, signed_at?, signed_as? }[] } | null",
1660
+ loading: "boolean",
1661
+ error: "PermissionError | null // { code, message, retryable, errors, retryAfter }",
1662
+ refresh: "() => Promise<void>",
1663
+ prepare: "(signerIds: string[]) => Promise<round> // status 'DRAFT'",
1664
+ preparedFile: "() => Promise<{ url, sha256, expires_at, size_bytes }>",
1665
+ confirm: "() => Promise<round> // status 'OPEN'",
1666
+ cancel: "() => Promise<round> // the round it ended, status 'CANCELLED'",
1667
+ busy: "boolean // an action is running; another one is refused with ACTION_IN_PROGRESS",
1668
+ },
1669
+ requiredContextSlice: ["filestore.signingRounds"],
1670
+ scopes: ["files.write:*"],
1671
+ },
1575
1672
  {
1576
1673
  name: "useFolderPermissions",
1577
1674
  signature: "useFolderPermissions(folderId, { enabled })",
@@ -3449,15 +3546,16 @@ const WIDGET_CONTEXT_SHAPE = {
3449
3546
  },
3450
3547
  },
3451
3548
  // REQ-LAY-08 — optional host layout hint backing useFill(). True when the
3452
- // host sized this widget to fill its layout slot's available height (a
3453
- // page-grid tile set to "Fill tile height", or a default-fill widget type).
3549
+ // host sized this widget to fill a box of definite height (a fit-to-screen
3550
+ // page's stretched section, or a fixed slot height).
3454
3551
  // Optional: a host that never fills a widget simply omits it and useFill()
3455
3552
  // returns false, so existing hosts need no change.
3456
3553
  fill: {
3457
3554
  description:
3458
3555
  "Optional host layout hint (boolean). True when the host sized this " +
3459
- "widget to fill its layout slot's available height (page-grid tile " +
3460
- "fill). Backs useFill(); defaults to false when absent.",
3556
+ "widget to fill a box of definite height (a fit-to-screen page's " +
3557
+ "stretched section, or a fixed slot height). Backs useFill(); defaults " +
3558
+ "to false when absent.",
3461
3559
  required: false,
3462
3560
  fields: {},
3463
3561
  },
@@ -3588,10 +3686,12 @@ const WIDGET_CONTEXT_SHAPE = {
3588
3686
  "Injected @colixsystems/filestore-client instance — the end-user file archive (project / personal / public spaces) + BankID file signing. " +
3589
3687
  "{ files: { list(query) -> Promise<{ data, meta }>, get(id), upload(formData), update(id, body), copy(id, body), remove(id), preview(id) }, " +
3590
3688
  "folders: { list, create, update, remove }, shares: { ... }, trash: { ... }, " +
3591
- "signatures: { initiate(fileId), status(id), cancel(id), verify(id) }, objectUrl(token), fetchObject(token) }. " +
3592
- "Backs useFilestoreFiles() + useFilestoreFolders() + useFilestoreCreateFolder() + useFilestoreCopy() + useFileSignature(). Optional — a host without an end-user filestore omits it and those hooks throw a clear error.",
3689
+ "signatures: { list(fileIds), roster(fileId, query), initiate(fileId), status(id), cancel(id), verify(id) }, " +
3690
+ "signingRounds: { overview(fileIds), list(fileId, query), get(roundId), prepare(fileId, signerIds), preparedFile(roundId), confirm(roundId, preparedSha256), cancel(roundId) }, " +
3691
+ "objectUrl(token), fetchObject(token) }. " +
3692
+ "Backs useFilestoreFiles() + useFilestoreFolders() + useFilestoreCreateFolder() + useFilestoreCopy() + useFileSignature() + useFileSignatures() + useFileRoster() + useSigningRounds() + useSigningRound(). Optional — a host without an end-user filestore omits it and those hooks throw a clear error.",
3593
3693
  required: false,
3594
- fields: { files: "object", folders: "object", shares: "object", signatures: "object" },
3694
+ fields: { files: "object", folders: "object", shares: "object", signatures: "object", signingRounds: "object" },
3595
3695
  },
3596
3696
  renderer: {
3597
3697
  description:
@@ -5703,7 +5803,12 @@ const CONTRACT = deepFreeze({
5703
5803
  // binds no widget style fields: the component reads it on both hosts,
5704
5804
  // which a scope now states as `sdkComponents`.
5705
5805
  // Additive: an unthemed chip is the muted pill widgets drew by hand.
5706
- version: "1.174.0",
5806
+ // 1.175.0: additive (sc-10410) — `useSigningRounds(fileIds)` and
5807
+ // `useSigningRound(fileId)` read and run PDF signing rounds through the
5808
+ // new `ctx.filestore.signingRounds`. `useFileSignature` also returns
5809
+ // `hintCode` and `nameRefusal`, and its `cancel()` resolves to what
5810
+ // became of the order instead of always reporting "cancelled".
5811
+ version: "1.175.0",
5707
5812
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
5708
5813
  hooks: HOOKS,
5709
5814
  primitives: PRIMITIVES,