@proveanything/smartlinks 3.0.0-alpha.2 → 3.0.0-alpha.3

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.
Files changed (151) hide show
  1. package/README.md +741 -741
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/api/bookings.d.ts +49 -2
  5. package/dist/api/bookings.js +59 -2
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +1 -0
  8. package/dist/api/payments.d.ts +60 -0
  9. package/dist/api/payments.js +94 -0
  10. package/dist/api/realtime.d.ts +3 -0
  11. package/dist/api/realtime.js +10 -2
  12. package/dist/baseline.css +194 -194
  13. package/dist/dataChanged.d.ts +74 -0
  14. package/dist/dataChanged.js +162 -0
  15. package/dist/docs/API_SUMMARY.md +1086 -858
  16. package/dist/docs/admin-cards.md +189 -189
  17. package/dist/docs/agent-tools.md +156 -156
  18. package/dist/docs/ai-tools-and-skills.md +180 -180
  19. package/dist/docs/ai.md +1721 -1721
  20. package/dist/docs/api-versions.md +85 -85
  21. package/dist/docs/app-data-storage.md +277 -277
  22. package/dist/docs/app-docs.md +73 -73
  23. package/dist/docs/app-manifest.md +852 -852
  24. package/dist/docs/app-records-pattern.md +388 -388
  25. package/dist/docs/appConfig.md +550 -550
  26. package/dist/docs/assistant-apps.md +172 -172
  27. package/dist/docs/assistant-context.md +119 -119
  28. package/dist/docs/bookings.md +105 -8
  29. package/dist/docs/caching.md +32 -3
  30. package/dist/docs/comms.md +689 -689
  31. package/dist/docs/connectors.md +340 -340
  32. package/dist/docs/css-baseline.md +133 -133
  33. package/dist/docs/customer-guide.md +70 -70
  34. package/dist/docs/data-changed.md +91 -0
  35. package/dist/docs/deploying-apps.md +340 -340
  36. package/dist/docs/dpp.md +115 -115
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +252 -252
  40. package/dist/docs/iframe-responder.md +11 -0
  41. package/dist/docs/integrations.md +322 -322
  42. package/dist/docs/interactions.md +544 -544
  43. package/dist/docs/item-context.md +181 -181
  44. package/dist/docs/knowledge.md +105 -105
  45. package/dist/docs/lists.md +157 -157
  46. package/dist/docs/lots.md +112 -112
  47. package/dist/docs/loyalty.md +348 -348
  48. package/dist/docs/members.md +183 -183
  49. package/dist/docs/memberships.md +150 -150
  50. package/dist/docs/mobile-admin-container.md +693 -693
  51. package/dist/docs/operations.md +281 -281
  52. package/dist/docs/overview.md +487 -485
  53. package/dist/docs/payments.md +94 -0
  54. package/dist/docs/proof-comms-triggers.md +142 -142
  55. package/dist/docs/proof-ownership-transfer.md +155 -155
  56. package/dist/docs/proof-product-data-scoping.md +462 -462
  57. package/dist/docs/proof-share-grants.md +305 -305
  58. package/dist/docs/realtime.md +149 -139
  59. package/dist/docs/records-admin-pattern.md +304 -304
  60. package/dist/docs/service-accounts.md +64 -64
  61. package/dist/docs/standard-query.md +196 -187
  62. package/dist/docs/tag-codes.md +97 -97
  63. package/dist/docs/tag-ranges.md +106 -106
  64. package/dist/docs/theme-tokens.md +252 -252
  65. package/dist/docs/upgrading-to-3.md +550 -532
  66. package/dist/docs/wallet-passes.md +107 -107
  67. package/dist/docs/websites.md +123 -123
  68. package/dist/http.d.ts +6 -3
  69. package/dist/http.js +48 -19
  70. package/dist/iframeResponder.d.ts +7 -0
  71. package/dist/iframeResponder.js +10 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.js +2 -0
  74. package/dist/openapi.yaml +426 -3
  75. package/dist/testing/bookingsMemory.d.ts +29 -1
  76. package/dist/testing/bookingsMemory.js +89 -1
  77. package/dist/testing/index.js +4 -1
  78. package/dist/theme-boot.js +82 -82
  79. package/dist/theme.css +75 -75
  80. package/dist/types/appManifest.d.ts +26 -4
  81. package/dist/types/bookings.d.ts +99 -1
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/index.js +1 -0
  84. package/dist/types/payments.d.ts +101 -0
  85. package/dist/types/payments.js +5 -0
  86. package/dist/types/realtime.d.ts +5 -1
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/API_SUMMARY.md +1086 -858
  90. package/docs/admin-cards.md +189 -189
  91. package/docs/agent-tools.md +156 -156
  92. package/docs/ai-tools-and-skills.md +180 -180
  93. package/docs/ai.md +1721 -1721
  94. package/docs/api-versions.md +85 -85
  95. package/docs/app-data-storage.md +277 -277
  96. package/docs/app-docs.md +73 -73
  97. package/docs/app-manifest.md +852 -852
  98. package/docs/app-records-pattern.md +388 -388
  99. package/docs/appConfig.md +550 -550
  100. package/docs/assistant-apps.md +172 -172
  101. package/docs/assistant-context.md +119 -119
  102. package/docs/bookings.md +105 -8
  103. package/docs/caching.md +32 -3
  104. package/docs/comms.md +689 -689
  105. package/docs/connectors.md +340 -340
  106. package/docs/css-baseline.md +133 -133
  107. package/docs/customer-guide.md +70 -70
  108. package/docs/data-changed.md +91 -0
  109. package/docs/deploying-apps.md +340 -340
  110. package/docs/dpp.md +115 -115
  111. package/docs/entitlements.md +90 -90
  112. package/docs/files.md +69 -69
  113. package/docs/host-dependency-contract.md +252 -252
  114. package/docs/iframe-responder.md +11 -0
  115. package/docs/integrations.md +322 -322
  116. package/docs/interactions.md +544 -544
  117. package/docs/item-context.md +181 -181
  118. package/docs/knowledge.md +105 -105
  119. package/docs/lists.md +157 -157
  120. package/docs/lots.md +112 -112
  121. package/docs/loyalty.md +348 -348
  122. package/docs/members.md +183 -183
  123. package/docs/memberships.md +150 -150
  124. package/docs/mobile-admin-container.md +693 -693
  125. package/docs/operations.md +281 -281
  126. package/docs/overview.md +487 -485
  127. package/docs/payments.md +94 -0
  128. package/docs/proof-comms-triggers.md +142 -142
  129. package/docs/proof-ownership-transfer.md +155 -155
  130. package/docs/proof-product-data-scoping.md +462 -462
  131. package/docs/proof-share-grants.md +305 -305
  132. package/docs/realtime.md +149 -139
  133. package/docs/service-accounts.md +64 -64
  134. package/docs/standard-query.md +196 -187
  135. package/docs/tag-codes.md +97 -97
  136. package/docs/tag-ranges.md +106 -106
  137. package/docs/theme-lookbook.v1.json +120 -120
  138. package/docs/theme-tokens.md +252 -252
  139. package/docs/upgrading-to-3.md +550 -532
  140. package/docs/wallet-passes.md +107 -107
  141. package/docs/websites.md +123 -123
  142. package/openapi.yaml +426 -3
  143. package/package.json +91 -91
  144. package/scripts/headless-check.mjs +87 -87
  145. package/scripts/lib/bare-imports.mjs +57 -57
  146. package/scripts/lib/keyed-app-data.mjs +21 -21
  147. package/scripts/lib/upgrade.mjs +708 -668
  148. package/scripts/publish.mjs +272 -272
  149. package/scripts/register-release.mjs +91 -91
  150. package/scripts/upgrade.mjs +79 -79
  151. package/upgrade/3.json +2 -2
@@ -28,61 +28,61 @@ export function adminCardAge(at, now = Date.now()) {
28
28
  return `${Math.round(s / 3600)} h ago`;
29
29
  return `${Math.round(s / 86400)} d ago`;
30
30
  }
31
- const CSS = `
32
- .slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
33
- .slc-grid>*{grid-column:span 12}
34
- @media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
35
- @media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
36
- .slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
37
- box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
38
- .slc-head{display:flex;align-items:center;gap:8px;min-width:0}
39
- .slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
40
- .slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
41
- .slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
42
- .slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
43
- .slc-refresh:focus-visible{outline:2px solid var(--_accent)}
44
- .slc-spin{animation:slc-spin 1s linear infinite}
45
- @keyframes slc-spin{to{transform:rotate(360deg)}}
46
- .slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
47
- .slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
48
- .slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
49
- .slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
50
- .slc-label{font-size:.875rem;color:var(--_muted)}
51
- .slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
52
- .slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
53
- .slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
54
- .slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
55
- .slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
56
- .slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
57
- .slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
58
- .slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
59
- .slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
60
- .slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
61
- .slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
62
- .slc-item:first-child{border-top:0}
63
- .slc-item-main{flex:1;min-width:0}
64
- .slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}
65
- .slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
66
- .slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}
67
- .slc-link{all:unset;cursor:pointer}
68
- .slc-link:hover .slc-item-title{text-decoration:underline}
69
- .slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}
70
- .slc-empty{font-size:.875rem;color:var(--_muted)}
71
- .slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}
72
- .slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}
73
- .slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}
74
- .slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}
75
- .slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
76
- .slc-note{font-size:.75rem;color:var(--_muted)}
77
- .slc-note.slc-err{color:var(--_err)}
78
- .slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}
79
- @keyframes slc-pulse{50%{opacity:.5}}
80
- .slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}
81
- .slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}
82
- .slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}
83
- .slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}
84
- .slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}
85
- .slc-todo-text{flex:1;min-width:0}
31
+ const CSS = `
32
+ .slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
33
+ .slc-grid>*{grid-column:span 12}
34
+ @media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
35
+ @media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
36
+ .slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
37
+ box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
38
+ .slc-head{display:flex;align-items:center;gap:8px;min-width:0}
39
+ .slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
40
+ .slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
41
+ .slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
42
+ .slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
43
+ .slc-refresh:focus-visible{outline:2px solid var(--_accent)}
44
+ .slc-spin{animation:slc-spin 1s linear infinite}
45
+ @keyframes slc-spin{to{transform:rotate(360deg)}}
46
+ .slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
47
+ .slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
48
+ .slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
49
+ .slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
50
+ .slc-label{font-size:.875rem;color:var(--_muted)}
51
+ .slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
52
+ .slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
53
+ .slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
54
+ .slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
55
+ .slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
56
+ .slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
57
+ .slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
58
+ .slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
59
+ .slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
60
+ .slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
61
+ .slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
62
+ .slc-item:first-child{border-top:0}
63
+ .slc-item-main{flex:1;min-width:0}
64
+ .slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}
65
+ .slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
66
+ .slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}
67
+ .slc-link{all:unset;cursor:pointer}
68
+ .slc-link:hover .slc-item-title{text-decoration:underline}
69
+ .slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}
70
+ .slc-empty{font-size:.875rem;color:var(--_muted)}
71
+ .slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}
72
+ .slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}
73
+ .slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}
74
+ .slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}
75
+ .slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
76
+ .slc-note{font-size:.75rem;color:var(--_muted)}
77
+ .slc-note.slc-err{color:var(--_err)}
78
+ .slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}
79
+ @keyframes slc-pulse{50%{opacity:.5}}
80
+ .slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}
81
+ .slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}
82
+ .slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}
83
+ .slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}
84
+ .slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}
85
+ .slc-todo-text{flex:1;min-width:0}
86
86
  `;
87
87
  let injected = false;
88
88
  /** Add the card styles to the page once (the views call it; hosts rendering on the server can too). */
@@ -1,4 +1,4 @@
1
- import type { Booking, BookingSlot, BookingAllocation, CreateBookingInput, UpdateBookingInput, MoveBookingInput, BookingListOptions, CreateSlotInput, UpdateSlotInput, SlotListOptions, CreateBlockInput, BlockListOptions, FreeBusyQuery, FreeBusyResponse, BookingAccessOptions, MessageBookersInput, MessageBookersResult } from '../types/bookings.js';
1
+ import type { Booking, BookingSlot, BookingAllocation, CreateBookingInput, UpdateBookingInput, MoveBookingInput, BookingListOptions, CreateSlotInput, UpdateSlotInput, SlotListOptions, CreateBlockInput, BlockListOptions, FreeBusyQuery, FreeBusyResponse, BookingAccessOptions, MessageBookersInput, MessageBookersResult, BookingCheckoutInput, BookingCheckoutResult, BookingPayLinkResult, BookingRefundResult } from '../types/bookings.js';
2
2
  import type { ListResult } from '../types/list.js';
3
3
  export declare namespace bookings {
4
4
  /**
@@ -49,17 +49,64 @@ export declare namespace bookings {
49
49
  /**
50
50
  * held / pending / waitlisted → confirmed (idempotent). A held booking whose hold has run out fails
51
51
  * with HOLD_EXPIRED. Public: only the booker's own hold, when `ownerActions.bookings.confirm` allows.
52
+ *
53
+ * Paid bookings: a booking waiting for its payment is confirmed by the payment (PAYMENT_REQUIRED
54
+ * otherwise). Admin confirming a REQUEST that has a price turns it into a hold with a pay link for the
55
+ * booker (`payment.link`, emailed through `booking.payment_requested`); `{ payment: 'waive' }` confirms
56
+ * without payment (paid in cash, a free place).
52
57
  * POST /bookings/:bookingId/confirm
53
58
  */
54
- function confirm(collectionId: string, appId: string, bookingId: string, admin?: boolean, opts?: BookingAccessOptions): Promise<Booking>;
59
+ function confirm(collectionId: string, appId: string, bookingId: string, admin?: boolean, opts?: BookingAccessOptions & {
60
+ payment?: 'waive';
61
+ }): Promise<Booking>;
55
62
  /**
56
63
  * Cancel and give the places back (idempotent). Public: per `ownerActions.bookings.cancel` and its
57
64
  * cutoff. `reason` is admin-only (public cancels record 'owner').
65
+ *
66
+ * Paid bookings are refunded: the booker's cancel follows the app's `bookingPayments.ownerCancelRefund`
67
+ * (full by default); staff choose with `refund`: 'full' (default) | 'none' | an amount in minor units.
58
68
  * POST /bookings/:bookingId/cancel
59
69
  */
60
70
  function cancel(collectionId: string, appId: string, bookingId: string, admin?: boolean, opts?: BookingAccessOptions & {
61
71
  reason?: string;
72
+ refund?: 'full' | 'none' | number;
62
73
  }): Promise<Booking>;
74
+ /**
75
+ * Book and pay. The same rules as `create` (public), then the app's `bookingPayments` decide:
76
+ * - pay now (the rules book as held / confirmed): the booking is held while the person pays on
77
+ * Stripe's page → go to `checkoutUrl`; Stripe's webhook confirms it.
78
+ * - a request (the rules book as pending): priced, nothing paid, `checkoutUrl: null`; staff approving it
79
+ * sends the booker a pay link.
80
+ * - free (no prices): booked the normal way, `checkoutUrl: null`.
81
+ * Name prices by id (`lines` for ticket types on a slot, `priceId` for an appointment's service); the
82
+ * server sets every amount.
83
+ * POST /bookings/checkout
84
+ */
85
+ function checkout(collectionId: string, appId: string, input: BookingCheckoutInput): Promise<BookingCheckoutResult>;
86
+ /**
87
+ * The thank-you page: the booking a Checkout Session paid for (`session_id` in the success address).
88
+ * `confirming: true` while Stripe's webhook is still on its way: show "confirming your payment…" and
89
+ * read again in a moment.
90
+ * GET /bookings/by-session/:sessionId
91
+ */
92
+ function bySession(collectionId: string, appId: string, sessionId: string): Promise<Booking & {
93
+ confirming: boolean;
94
+ }>;
95
+ /**
96
+ * An approved request's pay link, for an app with its own pay page (the link in the email goes straight
97
+ * to Stripe). `token` is the `t` of `payment.link`. → `{ checkoutUrl }`, or `{ done: 'paid' | 'closed', url }`.
98
+ * POST /bookings/:bookingId/pay
99
+ */
100
+ function pay(collectionId: string, appId: string, bookingId: string, token: string): Promise<BookingPayLinkResult>;
101
+ /**
102
+ * Refund a paid booking without cancelling it (admin): all that's left, or `amount` (minor units). A
103
+ * refund Stripe can't take now is retried by the platform (`refundPending: true`).
104
+ * POST /bookings/:bookingId/refund
105
+ */
106
+ function refund(collectionId: string, appId: string, bookingId: string, opts?: {
107
+ amount?: number;
108
+ reason?: string;
109
+ }): Promise<BookingRefundResult>;
63
110
  /**
64
111
  * Move to a new slot / time, all-or-nothing (a failed move leaves the booking as it was).
65
112
  * Public: per `ownerActions.bookings.move`; the create rules are re-checked for the new time.
@@ -97,21 +97,78 @@ export var bookings;
97
97
  /**
98
98
  * held / pending / waitlisted → confirmed (idempotent). A held booking whose hold has run out fails
99
99
  * with HOLD_EXPIRED. Public: only the booker's own hold, when `ownerActions.bookings.confirm` allows.
100
+ *
101
+ * Paid bookings: a booking waiting for its payment is confirmed by the payment (PAYMENT_REQUIRED
102
+ * otherwise). Admin confirming a REQUEST that has a price turns it into a hold with a pay link for the
103
+ * booker (`payment.link`, emailed through `booking.payment_requested`); `{ payment: 'waive' }` confirms
104
+ * without payment (paid in cash, a free place).
100
105
  * POST /bookings/:bookingId/confirm
101
106
  */
102
107
  async function confirm(collectionId, appId, bookingId, admin = false, opts) {
103
- return post(`${basePath(collectionId, appId, admin)}/${encodeURIComponent(bookingId)}/confirm`, {}, tokenHeaders(opts));
108
+ return post(`${basePath(collectionId, appId, admin)}/${encodeURIComponent(bookingId)}/confirm`, (opts === null || opts === void 0 ? void 0 : opts.payment) ? { payment: opts.payment } : {}, tokenHeaders(opts));
104
109
  }
105
110
  bookings.confirm = confirm;
106
111
  /**
107
112
  * Cancel and give the places back (idempotent). Public: per `ownerActions.bookings.cancel` and its
108
113
  * cutoff. `reason` is admin-only (public cancels record 'owner').
114
+ *
115
+ * Paid bookings are refunded: the booker's cancel follows the app's `bookingPayments.ownerCancelRefund`
116
+ * (full by default); staff choose with `refund`: 'full' (default) | 'none' | an amount in minor units.
109
117
  * POST /bookings/:bookingId/cancel
110
118
  */
111
119
  async function cancel(collectionId, appId, bookingId, admin = false, opts) {
112
- return post(`${basePath(collectionId, appId, admin)}/${encodeURIComponent(bookingId)}/cancel`, (opts === null || opts === void 0 ? void 0 : opts.reason) ? { reason: opts.reason } : {}, tokenHeaders(opts));
120
+ const body = {};
121
+ if (opts === null || opts === void 0 ? void 0 : opts.reason)
122
+ body.reason = opts.reason;
123
+ if ((opts === null || opts === void 0 ? void 0 : opts.refund) !== undefined)
124
+ body.refund = opts.refund;
125
+ return post(`${basePath(collectionId, appId, admin)}/${encodeURIComponent(bookingId)}/cancel`, body, tokenHeaders(opts));
113
126
  }
114
127
  bookings.cancel = cancel;
128
+ // ==================== PAID BOOKINGS (docs/bookings.md, "Paid bookings") ====================
129
+ /**
130
+ * Book and pay. The same rules as `create` (public), then the app's `bookingPayments` decide:
131
+ * - pay now (the rules book as held / confirmed): the booking is held while the person pays on
132
+ * Stripe's page → go to `checkoutUrl`; Stripe's webhook confirms it.
133
+ * - a request (the rules book as pending): priced, nothing paid, `checkoutUrl: null`; staff approving it
134
+ * sends the booker a pay link.
135
+ * - free (no prices): booked the normal way, `checkoutUrl: null`.
136
+ * Name prices by id (`lines` for ticket types on a slot, `priceId` for an appointment's service); the
137
+ * server sets every amount.
138
+ * POST /bookings/checkout
139
+ */
140
+ async function checkout(collectionId, appId, input) {
141
+ return post(`${basePath(collectionId, appId, false)}/checkout`, input);
142
+ }
143
+ bookings.checkout = checkout;
144
+ /**
145
+ * The thank-you page: the booking a Checkout Session paid for (`session_id` in the success address).
146
+ * `confirming: true` while Stripe's webhook is still on its way: show "confirming your payment…" and
147
+ * read again in a moment.
148
+ * GET /bookings/by-session/:sessionId
149
+ */
150
+ async function bySession(collectionId, appId, sessionId) {
151
+ return request(`${basePath(collectionId, appId, false)}/by-session/${encodeURIComponent(sessionId)}`);
152
+ }
153
+ bookings.bySession = bySession;
154
+ /**
155
+ * An approved request's pay link, for an app with its own pay page (the link in the email goes straight
156
+ * to Stripe). `token` is the `t` of `payment.link`. → `{ checkoutUrl }`, or `{ done: 'paid' | 'closed', url }`.
157
+ * POST /bookings/:bookingId/pay
158
+ */
159
+ async function pay(collectionId, appId, bookingId, token) {
160
+ return post(`${basePath(collectionId, appId, false)}/${encodeURIComponent(bookingId)}/pay`, { token });
161
+ }
162
+ bookings.pay = pay;
163
+ /**
164
+ * Refund a paid booking without cancelling it (admin): all that's left, or `amount` (minor units). A
165
+ * refund Stripe can't take now is retried by the platform (`refundPending: true`).
166
+ * POST /bookings/:bookingId/refund
167
+ */
168
+ async function refund(collectionId, appId, bookingId, opts) {
169
+ return post(`${basePath(collectionId, appId, true)}/${encodeURIComponent(bookingId)}/refund`, opts || {});
170
+ }
171
+ bookings.refund = refund;
115
172
  /**
116
173
  * Move to a new slot / time, all-or-nothing (a failed move leaves the booking as it was).
117
174
  * Public: per `ownerActions.bookings.move`; the create rules are re-checked for the new time.
@@ -45,6 +45,7 @@ export { order } from "./order.js";
45
45
  export { app } from "./appObjects.js";
46
46
  export { bookings } from "./bookings.js";
47
47
  export { shop } from "./shop.js";
48
+ export { payments } from "./payments.js";
48
49
  export { subscriptions } from "./subscriptions.js";
49
50
  export { attestations } from "./attestations.js";
50
51
  export { containers } from "./containers.js";
package/dist/api/index.js CHANGED
@@ -48,6 +48,7 @@ export { order } from "./order.js";
48
48
  export { app } from "./appObjects.js";
49
49
  export { bookings } from "./bookings.js";
50
50
  export { shop } from "./shop.js";
51
+ export { payments } from "./payments.js";
51
52
  export { subscriptions } from "./subscriptions.js";
52
53
  export { attestations } from "./attestations.js";
53
54
  export { containers } from "./containers.js";
@@ -0,0 +1,60 @@
1
+ import type { PaymentsPublicConfig, PaymentIntentInput, PaymentIntentResult, PaymentsStatus, PaymentsConnectInput, PaymentListParams, PaymentList, PaymentDomainResult } from '../types/payments.js';
2
+ export declare namespace payments {
3
+ /**
4
+ * Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
5
+ * connected Stripe in Studio → Payments.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const cfg = await payments.config(collectionId)
10
+ * if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
11
+ * ```
12
+ */
13
+ function config(collectionId: string): Promise<PaymentsPublicConfig>;
14
+ /**
15
+ * Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
16
+ * returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
17
+ * `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
18
+ *
19
+ * The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
20
+ * use a hosted checkout (`shop.checkout`), where the server prices it.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
25
+ * const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
26
+ * // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
27
+ * ```
28
+ */
29
+ function createIntent(collectionId: string, input: PaymentIntentInput): Promise<PaymentIntentResult>;
30
+ namespace admin {
31
+ /**
32
+ * The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
33
+ * what SmartLinks takes from each.
34
+ */
35
+ function status(collectionId: string, params?: {
36
+ appIds?: string[];
37
+ }): Promise<PaymentsStatus>;
38
+ /**
39
+ * Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
40
+ * `url`. The account is made the first time; every app shares it.
41
+ */
42
+ function connect(collectionId: string, input: PaymentsConnectInput): Promise<{
43
+ url: string;
44
+ expiresAt: string;
45
+ }>;
46
+ /**
47
+ * Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments
48
+ * until one is connected again); the Stripe account itself stays the business's own, with the
49
+ * payments already in it. Connecting again makes a new account.
50
+ */
51
+ function disconnect(collectionId: string): Promise<{
52
+ connected: false;
53
+ disconnectedAccountId: string | null;
54
+ }>;
55
+ /** An app's in-page payments on the business's account, newest first (for reconciling). */
56
+ function intents(collectionId: string, params?: PaymentListParams): Promise<PaymentList>;
57
+ /** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
58
+ function registerDomain(collectionId: string, domain: string): Promise<PaymentDomainResult>;
59
+ }
60
+ }
@@ -0,0 +1,94 @@
1
+ // src/api/payments.ts
2
+ // Payments — see docs/payments.md. A business connects ONE Stripe account (Studio → Payments) and every app
3
+ // takes money on it: no Stripe keys in apps. Pages use `payments.config` and `payments.createIntent` for
4
+ // in-page payments (Payment Element, Apple Pay, Google Pay); Studio and admin screens use `payments.admin`.
5
+ // Fixed-price sales use a hosted checkout instead: `shop.checkout`, `memberships`.
6
+ import { request, post } from '../http.js';
7
+ const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/payments`;
8
+ const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/payments`;
9
+ export var payments;
10
+ (function (payments) {
11
+ /**
12
+ * Can this business take payments, and what Stripe.js needs. `ready` is false until the business has
13
+ * connected Stripe in Studio → Payments.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const cfg = await payments.config(collectionId)
18
+ * if (cfg.ready) stripePromise = loadStripe(cfg.publishableKey!, { stripeAccount: cfg.accountId! })
19
+ * ```
20
+ */
21
+ async function config(collectionId) {
22
+ return request(pub(collectionId));
23
+ }
24
+ payments.config = config;
25
+ /**
26
+ * Start an in-page payment on the business's account. Confirm it in the page with Stripe.js, using the
27
+ * returned publishable key AND account id (`loadStripe(publishableKey, { stripeAccount: accountId })`).
28
+ * `amount` is in minor units (500 = £5.00). The app must be installed in the collection.
29
+ *
30
+ * The browser decides the amount, so use this for pay-what-you-want (donations, tips). For a fixed price
31
+ * use a hosted checkout (`shop.checkout`), where the server prices it.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const pi = await payments.createIntent(collectionId, { appId: 'tap-to-donate', amount: 500, currency: 'GBP', email })
36
+ * const stripe = await loadStripe(pi.publishableKey, { stripeAccount: pi.accountId })
37
+ * // <Elements stripe={stripe} options={{ clientSecret: pi.clientSecret }}> … stripe.confirmPayment(…)
38
+ * ```
39
+ */
40
+ async function createIntent(collectionId, input) {
41
+ return post(`${pub(collectionId)}/intent`, input);
42
+ }
43
+ payments.createIntent = createIntent;
44
+ let admin;
45
+ (function (admin) {
46
+ /**
47
+ * The business's payments account: connected, can take payments, can pay out. Pass `appIds` to see
48
+ * what SmartLinks takes from each.
49
+ */
50
+ async function status(collectionId, params) {
51
+ var _a;
52
+ const q = ((_a = params === null || params === void 0 ? void 0 : params.appIds) === null || _a === void 0 ? void 0 : _a.length) ? `?appIds=${encodeURIComponent(params.appIds.join(','))}` : '';
53
+ return request(`${adm(collectionId)}${q}`);
54
+ }
55
+ admin.status = status;
56
+ /**
57
+ * Stripe's page to connect (or finish connecting) the business's Stripe account. Send the person to
58
+ * `url`. The account is made the first time; every app shares it.
59
+ */
60
+ async function connect(collectionId, input) {
61
+ return post(`${adm(collectionId)}/connect`, input);
62
+ }
63
+ admin.connect = connect;
64
+ /**
65
+ * Stop using the business's Stripe account. SmartLinks forgets it (apps can no longer take payments
66
+ * until one is connected again); the Stripe account itself stays the business's own, with the
67
+ * payments already in it. Connecting again makes a new account.
68
+ */
69
+ async function disconnect(collectionId) {
70
+ return post(`${adm(collectionId)}/disconnect`, {});
71
+ }
72
+ admin.disconnect = disconnect;
73
+ /** An app's in-page payments on the business's account, newest first (for reconciling). */
74
+ async function intents(collectionId, params) {
75
+ const q = new URLSearchParams();
76
+ if (params === null || params === void 0 ? void 0 : params.appId)
77
+ q.set('appId', params.appId);
78
+ if (params === null || params === void 0 ? void 0 : params.since)
79
+ q.set('since', params.since);
80
+ if (params === null || params === void 0 ? void 0 : params.limit)
81
+ q.set('limit', String(params.limit));
82
+ if (params === null || params === void 0 ? void 0 : params.after)
83
+ q.set('after', params.after);
84
+ const s = q.toString();
85
+ return request(`${adm(collectionId)}/intents${s ? `?${s}` : ''}`);
86
+ }
87
+ admin.intents = intents;
88
+ /** Let Apple Pay and Google Pay run on a site's own domain (smartlinks.app needs nothing). */
89
+ async function registerDomain(collectionId, domain) {
90
+ return post(`${adm(collectionId)}/domains`, { domain });
91
+ }
92
+ admin.registerDomain = registerDomain;
93
+ })(admin = payments.admin || (payments.admin = {}));
94
+ })(payments || (payments = {}));
@@ -25,6 +25,9 @@ export declare function channel(scope: RealtimeScope & {
25
25
  * records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' |
26
26
  * 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`.
27
27
  *
28
+ * A change with no `id` means many things of that type changed (an import): a `{ type, id }` filter
29
+ * hears it too, so check `change.id` before assuming it is yours.
30
+ *
28
31
  * ```ts
29
32
  * const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch())
30
33
  * ```
@@ -194,8 +194,13 @@ export function channel(scope, name) {
194
194
  }
195
195
  function matches(change, filter) {
196
196
  for (const k of ["type", "id", "appId", "recordType", "productId", "proofId", "kind"]) {
197
- if (filter[k] !== undefined && change[k] !== filter[k])
198
- return false;
197
+ if (filter[k] === undefined || change[k] === filter[k])
198
+ continue;
199
+ // A change that names no id is about many things of its type (an import sends one
200
+ // { type: 'product' } in place of thousands): whoever follows one of them by type and id hears it.
201
+ if (k === "id" && change.id == null && filter.type !== undefined)
202
+ continue;
203
+ return false;
199
204
  }
200
205
  return true;
201
206
  }
@@ -206,6 +211,9 @@ function matches(change, filter) {
206
211
  * records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' |
207
212
  * 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`.
208
213
  *
214
+ * A change with no `id` means many things of that type changed (an import): a `{ type, id }` filter
215
+ * hears it too, so check `change.id` before assuming it is yours.
216
+ *
209
217
  * ```ts
210
218
  * const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch())
211
219
  * ```