@colixsystems/widget-sdk 0.215.0 → 0.219.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/src/contract.js CHANGED
@@ -1511,7 +1511,15 @@ const HOOKS = [
1511
1511
  "polls (fresh QR while pending — render with the Image primitive), " +
1512
1512
  "cancel() aborts, verify() returns the offline verdict. Pass " +
1513
1513
  "existingSignatureId for an already-signed file to seed the complete " +
1514
- "state + verify() without re-signing. Reads " +
1514
+ "state + verify() without re-signing. autoStartToken is set only while " +
1515
+ "opening BankID can still help (null once the user has signed or the " +
1516
+ "order has ended). hintCode says where the order " +
1517
+ "stands; 'sealing' means the user has signed and the signature is being " +
1518
+ "added to the document, so there is nothing to scan and it can no longer " +
1519
+ "be cancelled. cancel() resolves to what became of the order, which is " +
1520
+ "then still pending or already complete: read status after it, never " +
1521
+ "assume 'cancelled'. nameRefusal is set when the order failed because " +
1522
+ "the signer's name cannot be shown on the document. Reads " +
1515
1523
  "ctx.filestore.signatures.{initiate,status,cancel,verify}.",
1516
1524
  returnShape: {
1517
1525
  status: "'pending' | 'complete' | 'failed' | 'cancelled' | null",
@@ -1520,12 +1528,15 @@ const HOOKS = [
1520
1528
  message: "string | null",
1521
1529
  signerName: "string | null",
1522
1530
  signedAt: "string | null",
1531
+ hintCode: "string | null // where the order stands, e.g. 'sealing'",
1532
+ nameRefusal:
1533
+ "{ reason: 'empty' | 'too_long' | 'unsupported_characters' | 'mixed_scripts', characters: string[] } | null",
1523
1534
  verdict: "{ valid, checks, content_status, signed_by_others_since, seal, ... } | null",
1524
1535
  loading: "boolean",
1525
1536
  error: "PermissionError | null // { code, message, retryable }",
1526
- initiate: "() => Promise<{ signature_id, qr, auto_start_token, status }>",
1537
+ initiate: "() => Promise<{ signature_id, qr, auto_start_token, status, hint_code?, message? }>",
1527
1538
  refresh: "() => Promise<void>",
1528
- cancel: "() => Promise<void>",
1539
+ cancel: "() => Promise<{ status, hint_code?, message?, signer_name?, signed_at? } | undefined>",
1529
1540
  verify: "() => Promise<verdict>",
1530
1541
  },
1531
1542
  requiredContextSlice: ["filestore.signatures"],
@@ -1572,6 +1583,91 @@ const HOOKS = [
1572
1583
  requiredContextSlice: ["filestore.signatures"],
1573
1584
  scopes: ["files.read:*"],
1574
1585
  },
1586
+ {
1587
+ name: "useSigningRounds",
1588
+ signature: "useSigningRounds(fileIds)",
1589
+ description:
1590
+ "What the signed-in user may know about the signing round of each file " +
1591
+ "in a list, in one batched request. A signing round fixes a PDF and a " +
1592
+ "list of signers: it is prepared and confirmed by someone who manages " +
1593
+ "the file's folder, then each signer signs once with useFileSignature(), " +
1594
+ "in any order (there are no turns; the list only orders the places on " +
1595
+ "the signature page). byFileId maps a file id to { file_id, can_manage, " +
1596
+ "can_prepare, round, locked }; a file the user cannot see is absent. " +
1597
+ "round is null when there is none, and for a user who is neither a " +
1598
+ "manager nor one of its signers; a signer sees it once it is confirmed, " +
1599
+ "with their own place (my_place) and can_sign (the round is open and " +
1600
+ "their place is unsigned), and signed_count is null " +
1601
+ "for them. locked is 'signing_round' while the file cannot be changed, " +
1602
+ "'signed' once its content cannot be replaced. roundsEnabled is false " +
1603
+ "when the workspace cannot start signing rounds (offer no way to start " +
1604
+ "one), and null until the first answer. can_prepare is about the file " +
1605
+ "and the user, roundsEnabled is about the workspace: offer 'prepare' " +
1606
+ "only when both are true. Ids are matched without regard to case. " +
1607
+ "Refetches only when the set of ids or the signed-in user changes; " +
1608
+ "until the new answer arrives loading is true and byFileId is empty. " +
1609
+ "Reads ctx.filestore.signingRounds.overview.",
1610
+ returnShape: {
1611
+ byFileId:
1612
+ "{ [fileId]: { file_id, can_manage: boolean, can_prepare: boolean, " +
1613
+ "round: { id, status: 'DRAFT' | 'OPEN' | 'COMPLETED', signer_count, signed_count: number | null, " +
1614
+ "my_place: { position, signed, signed_at } | null, can_sign: boolean } | null, " +
1615
+ "locked: 'signing_round' | 'signed' | null } }",
1616
+ roundsEnabled: "boolean | null",
1617
+ loading: "boolean",
1618
+ error: "PermissionError | null // { code, message, retryable, errors, retryAfter }",
1619
+ refresh: "() => Promise<void>",
1620
+ },
1621
+ requiredContextSlice: ["filestore.signingRounds"],
1622
+ scopes: ["files.read:*"],
1623
+ },
1624
+ {
1625
+ name: "useSigningRound",
1626
+ signature: "useSigningRound(fileId)",
1627
+ description:
1628
+ "One file's current signing round, and the actions of someone who " +
1629
+ "manages the file's folder. prepare(signerIds) drafts a round for those " +
1630
+ "users, their places on the signature page in the order given (take the " +
1631
+ "ids from useFileRoster()); it can take " +
1632
+ "up to a minute. preparedFile() returns a five-minute link to the " +
1633
+ "prepared document; show it to the user before confirming. confirm() " +
1634
+ "opens the round for exactly the document preparedFile() last returned, " +
1635
+ "and rejects with code PREVIEW_REQUIRED when it was not called first. " +
1636
+ "cancel() ends a draft or an open round and resolves to the cancelled " +
1637
+ "round (status 'CANCELLED'); round is then null. ONE ACTION RUNS AT A " +
1638
+ "TIME: while busy is true any other action is refused at once with code " +
1639
+ "ACTION_IN_PROGRESS (it is not queued), so disable your buttons on busy. " +
1640
+ "round is the full round as the " +
1641
+ "user may see it: a manager sees every signer's progress, a signer sees " +
1642
+ "every signer's name and position and their own progress only, anyone " +
1643
+ "else sees null. A refused action sets error and rejects with it: code " +
1644
+ "and message come from the server (show message as it is), errors has " +
1645
+ "one entry per refused signer ({ app_user_id, message, reason, " +
1646
+ "characters }), retryAfter is the seconds to wait. The hook's own " +
1647
+ "refusals (PREVIEW_REQUIRED, ACTION_IN_PROGRESS, NO_SIGNING_ROUND) carry " +
1648
+ "a message that can be shown the same way. When a refusal means the " +
1649
+ "round is no longer what was shown (it expired, was closed, or the " +
1650
+ "document changed) the hook reads the round again by itself. Code " +
1651
+ "SIGNING_ROUNDS_NOT_ENABLED means the workspace cannot start signing " +
1652
+ "rounds; check roundsEnabled from useSigningRounds() before offering to " +
1653
+ "start one. When fileId or the signed-in user changes, round is null " +
1654
+ "and loading true until the new answer. Reads ctx.filestore.signingRounds.",
1655
+ returnShape: {
1656
+ round:
1657
+ "{ id, file_id, status: 'DRAFT' | 'OPEN' | 'COMPLETED', created_at, confirmed_at, completed_at, expires_at, " +
1658
+ "signers: { name, position, app_user_id?, signed?, signed_at?, signed_as? }[] } | null",
1659
+ loading: "boolean",
1660
+ error: "PermissionError | null // { code, message, retryable, errors, retryAfter }",
1661
+ refresh: "() => Promise<void>",
1662
+ prepare: "(signerIds: string[]) => Promise<round> // status 'DRAFT'",
1663
+ preparedFile: "() => Promise<{ url, sha256, expires_at, size_bytes }>",
1664
+ confirm: "() => Promise<round> // status 'OPEN'",
1665
+ cancel: "() => Promise<round> // the round it ended, status 'CANCELLED'",
1666
+ busy: "boolean // an action is running; another one is refused with ACTION_IN_PROGRESS",
1667
+ },
1668
+ requiredContextSlice: ["filestore.signingRounds"],
1669
+ scopes: ["files.write:*"],
1670
+ },
1575
1671
  {
1576
1672
  name: "useFolderPermissions",
1577
1673
  signature: "useFolderPermissions(folderId, { enabled })",
@@ -3588,10 +3684,12 @@ const WIDGET_CONTEXT_SHAPE = {
3588
3684
  "Injected @colixsystems/filestore-client instance — the end-user file archive (project / personal / public spaces) + BankID file signing. " +
3589
3685
  "{ files: { list(query) -> Promise<{ data, meta }>, get(id), upload(formData), update(id, body), copy(id, body), remove(id), preview(id) }, " +
3590
3686
  "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.",
3687
+ "signatures: { list(fileIds), roster(fileId, query), initiate(fileId), status(id), cancel(id), verify(id) }, " +
3688
+ "signingRounds: { overview(fileIds), list(fileId, query), get(roundId), prepare(fileId, signerIds), preparedFile(roundId), confirm(roundId, preparedSha256), cancel(roundId) }, " +
3689
+ "objectUrl(token), fetchObject(token) }. " +
3690
+ "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
3691
  required: false,
3594
- fields: { files: "object", folders: "object", shares: "object", signatures: "object" },
3692
+ fields: { files: "object", folders: "object", shares: "object", signatures: "object", signingRounds: "object" },
3595
3693
  },
3596
3694
  renderer: {
3597
3695
  description:
@@ -5703,7 +5801,12 @@ const CONTRACT = deepFreeze({
5703
5801
  // binds no widget style fields: the component reads it on both hosts,
5704
5802
  // which a scope now states as `sdkComponents`.
5705
5803
  // Additive: an unthemed chip is the muted pill widgets drew by hand.
5706
- version: "1.174.0",
5804
+ // 1.175.0: additive (sc-10410) — `useSigningRounds(fileIds)` and
5805
+ // `useSigningRound(fileId)` read and run PDF signing rounds through the
5806
+ // new `ctx.filestore.signingRounds`. `useFileSignature` also returns
5807
+ // `hintCode` and `nameRefusal`, and its `cancel()` resolves to what
5808
+ // became of the order instead of always reporting "cancelled".
5809
+ version: "1.175.0",
5707
5810
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
5708
5811
  hooks: HOOKS,
5709
5812
  primitives: PRIMITIVES,