@proveanything/smartlinks 2.1.39 → 2.1.41

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 (121) hide show
  1. package/README.md +754 -754
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/adminViews.d.ts +1 -1
  5. package/dist/adminViews.js +3 -1
  6. package/dist/ai-tools.d.ts +2 -1
  7. package/dist/ai-tools.js +3 -0
  8. package/dist/api/ai.d.ts +2 -21
  9. package/dist/api/ai.js +0 -35
  10. package/dist/api/collection.d.ts +8 -1
  11. package/dist/api/collection.js +10 -0
  12. package/dist/api/index.d.ts +1 -0
  13. package/dist/api/index.js +1 -0
  14. package/dist/api/knowledge.d.ts +64 -0
  15. package/dist/api/knowledge.js +97 -0
  16. package/dist/baseline.css +194 -194
  17. package/dist/docs/API_SUMMARY.md +1046 -964
  18. package/dist/docs/admin-cards.md +189 -189
  19. package/dist/docs/admin-views.md +257 -255
  20. package/dist/docs/agent-tools.md +156 -156
  21. package/dist/docs/ai-tools-and-skills.md +180 -180
  22. package/dist/docs/ai.md +1721 -1834
  23. package/dist/docs/analytics.md +39 -39
  24. package/dist/docs/app-data-storage.md +277 -277
  25. package/dist/docs/app-docs.md +73 -73
  26. package/dist/docs/app-manifest.md +852 -852
  27. package/dist/docs/app-records-pattern.md +388 -388
  28. package/dist/docs/appConfig.md +550 -550
  29. package/dist/docs/assistant-apps.md +172 -172
  30. package/dist/docs/assistant-context.md +119 -119
  31. package/dist/docs/bookings.md +442 -442
  32. package/dist/docs/comms.md +686 -686
  33. package/dist/docs/connectors.md +340 -340
  34. package/dist/docs/css-baseline.md +133 -133
  35. package/dist/docs/customer-guide.md +70 -70
  36. package/dist/docs/deploying-apps.md +340 -340
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +210 -210
  40. package/dist/docs/integrations.md +322 -322
  41. package/dist/docs/interactions.md +545 -545
  42. package/dist/docs/item-context.md +181 -181
  43. package/dist/docs/knowledge.md +102 -0
  44. package/dist/docs/lots.md +111 -111
  45. package/dist/docs/loyalty.md +352 -352
  46. package/dist/docs/members.md +182 -182
  47. package/dist/docs/mobile-admin-container.md +693 -693
  48. package/dist/docs/operations.md +281 -281
  49. package/dist/docs/overview.md +482 -482
  50. package/dist/docs/proof-comms-triggers.md +142 -142
  51. package/dist/docs/proof-ownership-transfer.md +155 -155
  52. package/dist/docs/proof-product-data-scoping.md +462 -462
  53. package/dist/docs/proof-share-grants.md +305 -305
  54. package/dist/docs/realtime.md +138 -138
  55. package/dist/docs/records-admin-pattern.md +304 -304
  56. package/dist/docs/standard-query.md +187 -187
  57. package/dist/docs/tag-codes.md +97 -97
  58. package/dist/docs/theme-tokens.md +252 -252
  59. package/dist/docs/wallet-passes.md +107 -107
  60. package/dist/docs/websites.md +123 -123
  61. package/dist/openapi.yaml +320 -306
  62. package/dist/theme-boot.js +78 -78
  63. package/dist/theme.css +75 -75
  64. package/dist/types/ai.d.ts +9 -91
  65. package/dist/types/appManifest.d.ts +21 -0
  66. package/dist/types/collection.d.ts +26 -0
  67. package/dist/types/index.d.ts +1 -0
  68. package/dist/types/index.js +1 -0
  69. package/dist/types/knowledge.d.ts +120 -0
  70. package/dist/types/knowledge.js +2 -0
  71. package/docs/API_SUMMARY.md +1046 -964
  72. package/docs/admin-cards.md +189 -189
  73. package/docs/admin-views.md +257 -255
  74. package/docs/agent-tools.md +156 -156
  75. package/docs/ai-tools-and-skills.md +180 -180
  76. package/docs/ai.md +1721 -1834
  77. package/docs/analytics.md +39 -39
  78. package/docs/app-data-storage.md +277 -277
  79. package/docs/app-docs.md +73 -73
  80. package/docs/app-manifest.md +852 -852
  81. package/docs/app-records-pattern.md +388 -388
  82. package/docs/appConfig.md +550 -550
  83. package/docs/assistant-apps.md +172 -172
  84. package/docs/assistant-context.md +119 -119
  85. package/docs/bookings.md +442 -442
  86. package/docs/comms.md +686 -686
  87. package/docs/connectors.md +340 -340
  88. package/docs/css-baseline.md +133 -133
  89. package/docs/customer-guide.md +70 -70
  90. package/docs/deploying-apps.md +340 -340
  91. package/docs/entitlements.md +90 -90
  92. package/docs/files.md +69 -69
  93. package/docs/host-dependency-contract.md +210 -210
  94. package/docs/integrations.md +322 -322
  95. package/docs/interactions.md +545 -545
  96. package/docs/item-context.md +181 -181
  97. package/docs/knowledge.md +102 -0
  98. package/docs/lots.md +111 -111
  99. package/docs/loyalty.md +352 -352
  100. package/docs/members.md +182 -182
  101. package/docs/mobile-admin-container.md +693 -693
  102. package/docs/operations.md +281 -281
  103. package/docs/overview.md +482 -482
  104. package/docs/proof-comms-triggers.md +142 -142
  105. package/docs/proof-ownership-transfer.md +155 -155
  106. package/docs/proof-product-data-scoping.md +462 -462
  107. package/docs/proof-share-grants.md +305 -305
  108. package/docs/realtime.md +138 -138
  109. package/docs/standard-query.md +187 -187
  110. package/docs/tag-codes.md +97 -97
  111. package/docs/theme-lookbook.v1.json +120 -120
  112. package/docs/theme-tokens.md +252 -252
  113. package/docs/wallet-passes.md +107 -107
  114. package/docs/websites.md +123 -123
  115. package/openapi.yaml +320 -306
  116. package/package.json +87 -87
  117. package/scripts/headless-check.mjs +87 -87
  118. package/scripts/lib/bare-imports.mjs +57 -57
  119. package/scripts/lib/keyed-app-data.mjs +21 -21
  120. package/scripts/publish.mjs +272 -272
  121. package/scripts/register-release.mjs +91 -91
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.39 | Generated: 2026-11-21T14:41:19.071Z
3
+ Version: 2.1.41 | Generated: 2026-11-22T10:02:53.863Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -156,6 +156,7 @@ The Smartlinks SDK is organized into the following namespaces:
156
156
  - **integrations** - Functions for integrations operations
157
157
  - **jobs** - Functions for jobs operations
158
158
  - **journeysAnalytics** - Functions for journeysAnalytics operations
159
+ - **knowledge** - Functions for knowledge operations
159
160
  - **location** - Functions for location operations
160
161
  - **lots** - Functions for lots operations
161
162
  - **navigation** - Functions for navigation operations
@@ -921,116 +922,6 @@ interface AIModelListResponse {
921
922
  }
922
923
  ```
923
924
 
924
- **DocumentChunk** (interface)
925
- ```typescript
926
- interface DocumentChunk {
927
- text: string
928
- embedding: number[]
929
- metadata: {
930
- chunkIndex: number
931
- documentId: string
932
- [key: string]: any
933
- }
934
- }
935
- ```
936
-
937
- **IndexDocumentRequest** (interface)
938
- ```typescript
939
- interface IndexDocumentRequest {
940
- productId: string
941
- text?: string
942
- documentUrl?: string
943
- metadata?: Record<string, any>
944
- chunkSize?: number
945
- overlap?: number
946
- provider?: 'openai' | 'gemini'
947
- }
948
- ```
949
-
950
- **IndexDocumentResponse** (interface)
951
- ```typescript
952
- interface IndexDocumentResponse {
953
- success: boolean
954
- productId: string
955
- documentId: string
956
- chunks: number
957
- metadata: {
958
- textLength: number
959
- chunkSize: number
960
- overlap: number
961
- embeddingDimensions: number
962
- }
963
- sample?: {
964
- text: string
965
- chunkIndex: number
966
- }
967
- }
968
- ```
969
-
970
- **ConfigureAssistantRequest** (interface)
971
- ```typescript
972
- interface ConfigureAssistantRequest {
973
- productId: string
974
- systemPrompt?: string
975
- model?: string
976
- maxTokensPerResponse?: number
977
- temperature?: number
978
- rateLimitPerUser?: number
979
- allowedTopics?: string[]
980
- customInstructions?: {
981
- tone?: string
982
- additionalRules?: string
983
- [key: string]: any
984
- }
985
- }
986
- ```
987
-
988
- **ConfigureAssistantResponse** (interface)
989
- ```typescript
990
- interface ConfigureAssistantResponse {
991
- success: boolean
992
- configuration: {
993
- productId: string
994
- systemPrompt: string
995
- model: string
996
- maxTokensPerResponse: number
997
- temperature: number
998
- rateLimitPerUser: number
999
- allowedTopics: string[]
1000
- customInstructions?: Record<string, any>
1001
- updatedAt: string
1002
- }
1003
- }
1004
- ```
1005
-
1006
- **PublicChatRequest** (interface)
1007
- ```typescript
1008
- interface PublicChatRequest {
1009
- productId: string
1010
- userId: string
1011
- message: string
1012
- sessionId?: string
1013
- stream?: boolean
1014
- }
1015
- ```
1016
-
1017
- **PublicChatResponse** (interface)
1018
- ```typescript
1019
- interface PublicChatResponse {
1020
- message: string
1021
- sessionId: string
1022
- usage: {
1023
- prompt_tokens: number
1024
- completion_tokens: number
1025
- total_tokens: number
1026
- }
1027
- context?: {
1028
- chunksUsed: number
1029
- topSimilarity: number
1030
- }
1031
- }
1032
- ```
1033
-
1034
925
  **Session** (interface)
1035
926
  ```typescript
1036
927
  interface Session {
@@ -1815,6 +1706,13 @@ interface HttpRequestArgs {
1815
1706
  }
1816
1707
  ```
1817
1708
 
1709
+ **KnowledgeSearchArgs** (interface)
1710
+ ```typescript
1711
+ interface KnowledgeSearchArgs {
1712
+ query: string; sets?: string[]; filters?: Record<string, any>; k?: number
1713
+ }
1714
+ ```
1715
+
1818
1716
  **TranslateArgs** (interface)
1819
1717
  ```typescript
1820
1718
  interface TranslateArgs {
@@ -1851,6 +1749,7 @@ interface AiToolArgsMap {
1851
1749
  'pdf.printReady': PdfPrintReadyArgs
1852
1750
  'http.request': HttpRequestArgs
1853
1751
  'translate': TranslateArgs
1752
+ 'knowledge.search': KnowledgeSearchArgs
1854
1753
  }
1855
1754
  ```
1856
1755
 
@@ -3264,6 +3163,7 @@ interface AppManifest {
3264
3163
  linkable?: DeepLinkEntry[];
3265
3164
  publicViews?: PublicView[];
3266
3165
  adminViews?: AdminView[];
3166
+ requires?: AppRequirement[];
3267
3167
  executor?: AppManifestExecutor;
3268
3168
  functions?: AppManifestFunctions;
3269
3169
  realtime?: {
@@ -3571,6 +3471,10 @@ type ServerFunctionFileInput = { base64: string; contentType: string }
3571
3471
 
3572
3472
  **AppDocsAudience** = `'team' | 'admin' | 'customer' | 'developer'`
3573
3473
 
3474
+ **AppNeed** = `'signIn' | 'crm' | 'products' | 'claimableItems'`
3475
+
3476
+ **AppRequirement** = `AppNeed | { need: AppNeed`
3477
+
3574
3478
  ### appObjects
3575
3479
 
3576
3480
  **PaginatedResponse<T>** (interface)
@@ -6637,6 +6541,26 @@ interface InviteUserInput {
6637
6541
  }
6638
6542
  ```
6639
6543
 
6544
+ **ReadinessItem** (interface)
6545
+ ```typescript
6546
+ interface ReadinessItem {
6547
+ level: 'problem' | 'warning' | 'info'
6548
+ code: string
6549
+ message: string
6550
+ app?: string
6551
+ appName?: string
6552
+ fix?: { label: string; open: { appId: string; view?: string }; studioPath: string }
6553
+ }
6554
+ ```
6555
+
6556
+ **CollectionReadiness** (interface)
6557
+ ```typescript
6558
+ interface CollectionReadiness {
6559
+ ready: boolean
6560
+ items: ReadinessItem[]
6561
+ }
6562
+ ```
6563
+
6640
6564
  **CollectionResponse** = `Collection`
6641
6565
 
6642
6566
  **CollectionCreateRequest** = `Omit<Collection, 'id' | 'shortId'>`
@@ -7092,424 +7016,424 @@ interface TransactionalSendError {
7092
7016
 
7093
7017
  **Recipient** = `import('./contact').Contact`
7094
7018
 
7095
- **CommsSettingsPatchBody** = `Partial<CommsSettings>`
7096
-
7097
- **ConsentChannels** = `Partial<Record<BroadcastChannel, boolean>>`
7098
-
7099
- **EmailAttachmentSpec** = ``
7100
-
7101
- **TransactionalSendResult** = `// src/types/comms.ts
7102
- // Communication and notification types for the Smartlinks API
7103
- import type { IdField } from './common'
7104
- import type { BroadcastChannel } from './broadcasts'
7105
-
7106
- /**
7107
- * Target subject for notifications (product, collection, etc.)
7108
- */
7109
- export interface NotificationSubjectTarget {
7110
- /** Type of target entity */
7111
- type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
7112
- /** ID of the target entity */
7113
- id: string
7114
- }
7115
-
7116
-
7117
- // Analytics & logging (communication events)
7118
-
7119
- export interface CommunicationEvent {
7120
- orgId: string
7121
- broadcastId?: string
7122
- journeyId?: string
7123
- userId?: string
7124
- contactId?: string
7125
- channel?: string
7126
- timestamp: string
7127
- eventType: string
7128
- outcome?: string | null
7129
- templateId?: string | null
7130
- [k: string]: any
7131
- }
7132
-
7133
- export interface CommsQueryByUser {
7134
- userId?: string
7135
- contactId?: string
7136
- from?: string
7137
- to?: string
7138
- limit?: number
7139
- }
7140
-
7141
- export type RecipientId = string
7142
- export interface RecipientWithOutcome { id: string; outcome: string }
7143
-
7144
- export interface CommsRecipientIdsQuery {
7145
- broadcastId?: string
7146
- journeyId?: string
7147
- journeyStepId?: string
7148
- idField?: IdField
7149
- from?: string
7150
- to?: string
7151
- limit?: number
7152
- }
7153
-
7154
- export interface CommsRecipientsWithoutActionQuery {
7155
- broadcastId?: string
7156
- journeyId?: string
7157
- actionId?: string
7158
- appId?: string
7159
- idField?: IdField
7160
- from?: string
7161
- to?: string
7162
- limit?: number
7163
- }
7164
-
7165
- export interface CommsRecipientsWithActionQuery {
7166
- broadcastId?: string
7167
- journeyId?: string
7168
- actionId?: string
7169
- appId?: string
7170
- outcome?: string
7171
- idField?: IdField
7172
- includeOutcome?: boolean
7173
- from?: string
7174
- to?: string
7175
- limit?: number
7176
- }
7177
-
7178
- export interface LogCommunicationEventBody {
7179
- broadcastId?: string
7180
- journeyId?: string
7181
- userId?: string
7182
- contactId?: string
7183
- channel?: string
7184
- eventType: string
7185
- outcome?: string
7186
- templateId?: string
7187
- timestamp?: string
7188
- [k: string]: any
7189
- }
7190
-
7191
- export interface LogBulkCommunicationEventsBody {
7192
- params: { broadcastId?: string; journeyId?: string; [k: string]: any }
7193
- ids: string[]
7194
- idField?: IdField
7195
- }
7196
-
7197
- export interface AppendResult { success: true }
7198
- export interface AppendBulkResult { success: true; count: number }
7199
-
7200
- // Common recipient type used by segments and broadcasts
7201
- export type Recipient = import('./contact').Contact
7202
-
7203
- // Shared page response shape for recipient listings
7204
- export interface RecipientsPage {
7205
- items: Recipient[]
7206
- total: number
7207
- limit: number
7208
- offset: number
7209
- note?: string
7210
- }
7211
-
7212
- // Web Push (public client registration)
7213
-
7214
- export interface PushSubscriptionJSON {
7215
- endpoint: string
7216
- keys?: {
7217
- p256dh?: string
7218
- auth?: string
7219
- }
7220
- }
7221
-
7222
- export interface PushVapidResponse { publicKey: string }
7223
- export interface PushSubscribeResponse { ok: true; id: string }
7224
-
7225
- // Public: register a push contact method
7226
- export interface RegisterPushMethodRequest {
7227
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7228
- contactId?: string
7229
- endpoint: string
7230
- keys: { p256dh: string; auth: string }
7231
- meta?: Record<string, any>
7232
- }
7233
-
7234
- // Admin Comms Settings
7235
-
7236
- export interface CommsSettings {
7237
- unsub?: {
7238
- requireToken?: boolean
7239
- /** Secret for token generation; omitted unless includeSecret=true */
7240
- secret?: string
7241
- /** Convenience flag indicating a secret is set (masked responses) */
7242
- hasSecret?: boolean
7243
- }
7244
- /** Map of topic keys to topic config */
7245
- topics?: Record<string, TopicConfig>
7246
- [k: string]: any
7247
- }
7248
-
7249
- export interface TopicConfig {
7250
- label?: string
7251
- description?: string
7252
- /** Optional UI-only grouping labels */
7253
- labels?: string[]
7254
- /** Classification for UI and default policy guidance */
7255
- classification?: 'transactional' | 'marketing'
7256
- defaults?: {
7257
- channels?: Partial<Record<BroadcastChannel, boolean>>
7258
- topics?: Record<string, boolean | undefined>
7259
- /** Default consent policy when explicit preferences are absent */
7260
- policy?: 'opt-in' | 'opt-out'
7261
- /** Per-channel default policy (overrides policy when present) */
7262
- byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7263
- }
7264
- rules?: {
7265
- allowChannels?: BroadcastChannel[]
7266
- allowUnsubscribe?: boolean
7267
- required?: boolean
7268
- }
7269
- [k: string]: any
7270
- }
7271
-
7272
- export interface CommsSettingsGetResponse {
7273
- ok: true
7274
- settings: CommsSettings
7275
- }
7276
-
7277
- export type CommsSettingsPatchBody = Partial<CommsSettings>
7278
-
7279
- // Public types listing (array form for public API)
7280
- export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7281
-
7282
- export interface UnsubscribeQuery {
7283
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7284
- contactId?: string
7285
- topic?: string
7286
- channel?: BroadcastChannel
7287
- token?: string
7288
- }
7289
-
7290
- export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7291
-
7292
- // Public sign-up (double opt-in)
7293
- export interface CommsSignupRequest {
7294
- email: string
7295
- /**
7296
- * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7297
- * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7298
- * platform sends no default sign-up email.
7299
- */
7300
- templateId: string
7301
- /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7302
- topics?: string[]
7303
- firstName?: string
7304
- /**
7305
- * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7306
- * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7307
- * has no value yet (never overwritten). Small: ~2 KB.
7308
- */
7309
- fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7310
- /** Your app id, recorded with the sent email. */
7311
- appId?: string
7312
- }
7313
- export interface CommsSignupResponse { ok: true; pending: true }
7314
-
7315
- // Public consent/preferences/subscribe
7316
- export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7317
- type SubjectType = import('./contact').SubjectType
7318
-
7319
- export interface CommsConsentUpsertRequest {
7320
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7321
- contactId?: string
7322
- channels?: ConsentChannels
7323
- topics?: Record<string, boolean>
7324
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7325
- }
7326
-
7327
- export interface CommsPreferencesUpsertRequest {
7328
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7329
- contactId?: string
7330
- subject?: { type: SubjectType; id: string; productId?: string }
7331
- channels?: ConsentChannels
7332
- topics?: Record<string, boolean>
7333
- topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7334
- }
7335
-
7336
- export interface CommsSubscribeRequest {
7337
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7338
- contactId?: string
7339
- subject: { type: SubjectType; id: string; productId?: string }
7340
- subscribe: boolean
7341
- source?: string
7342
- }
7343
- export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7344
-
7345
- export interface CommsSubscriptionCheckQuery {
7346
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7347
- contactId?: string
7348
- subjectType: SubjectType
7349
- subjectId: string
7350
- productId?: string
7351
- }
7352
- export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7353
-
7354
- export interface CommsListMethodsQuery {
7355
- /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7356
- contactId?: string
7357
- type?: BroadcastChannel
7358
- }
7359
- export interface CommsListMethodsResponse { ok: true; methods: import('./contact').CommMethod[] }
7360
-
7361
- export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7362
- export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7363
- export interface RegisterMethodResponse { ok: true; contactId: string }
7364
-
7365
- export interface SubscriptionsResolveRequest {
7366
- subject: { type: SubjectType; id: string; productId?: string }
7367
- hints: { userId?: string; pushEndpoint?: string; email?: string }
7368
- }
7369
- export interface SubscriptionsResolveResponse {
7370
- ok: true
7371
- subject: { type: SubjectType; id: string; productId?: string }
7372
- contacts: Array<{
7373
- contactId: string
7374
- subscribed: boolean
7375
- channels?: Partial<Record<BroadcastChannel, boolean>>
7376
- }>
7377
- anySubscribed: boolean
7378
- anyMethods: boolean
7379
- }
7380
-
7381
- // Transactional send (single-contact, single-message)
7382
-
7383
- /**
7384
- * Send a single message to one contact using a template.
7385
- * No broadcast record is created; the send is logged directly to the
7386
- * contact's communication history with sourceType: 'transactional'.
7387
- *
7388
- * POST /admin/collection/:collectionId/comm/send
7389
- */
7390
- export interface TransactionalSendRequest {
7391
- /** CRM contact UUID */
7392
- contactId: string
7393
- /** A saved template's id. Give this or `message`. */
7394
- templateId?: string
7395
- /**
7396
- * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7397
- * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7398
- */
7399
- message?: TypedMessage
7400
- /**
7401
- * Channel to send on. Defaults to 'preferred', which auto-selects the
7402
- * contact's best available channel respecting consent, suppression, and
7403
- * template availability.
7404
- */
7405
- channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7406
- /** Extra Liquid variables merged into the top-level render context */
7407
- props?: Record<string, unknown>
7408
- /** Context objects to hydrate into the Liquid template */
7409
- include?: {
7410
- /** Hydrate {{ collection }}. Default: true */
7411
- collection?: boolean
7412
- /** Hydrate {{ product }} from this product ID */
7413
- productId?: string
7414
- /** Hydrate {{ proof }} (requires productId) */
7415
- proofId?: string
7416
- /** Hydrate {{ user }} from contact.userId */
7417
- user?: boolean
7418
- /** Hydrate {{ appCase }} from this case UUID */
7419
- appCase?: string
7420
- /** Hydrate {{ appThread }} from this thread UUID */
7421
- appThread?: string
7422
- /** Hydrate {{ appRecord }} from this record UUID */
7423
- appRecord?: string
7424
- }
7425
- /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7426
- ref?: string
7427
- /** App context stored on the comms-events row */
7428
- appId?: string
7429
- /**
7430
- * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7431
- * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7432
- * to the sending app.
7433
- */
7434
- about?: MessageAbout
7435
- /**
7436
- * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7437
- * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7438
- */
7439
- category?: 'service'
7440
- /**
7441
- * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7442
- * `attachmentsLeftOut` — the email still goes.
7443
- */
7444
- attach?: EmailAttachmentSpec[]
7445
- }
7446
-
7447
- /**
7448
- * One file for an email:
7449
- * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7450
- * - `{ asset }` — a file uploaded to this collection's assets
7451
- * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7452
- * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7453
- * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7454
- */
7455
- export type EmailAttachmentSpec =
7456
- | 'calendar'
7457
- | { asset: string }
7458
- | { function: string }
7459
- | { filename: string; contentType: string; content: string }
7460
- | { filename: string; contentType?: string; file: string }
7461
-
7462
- export interface TransactionalSendResponse {
7463
- ok: true
7464
- /** The channel the message was actually sent on */
7465
- channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7466
- /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7467
- messageId?: string
7468
- /** Attachments that couldn't be made, and why (the email went without them) */
7469
- attachmentsLeftOut?: string[]
7470
- }
7471
-
7472
- /** A message written there and then rather than a saved template. */
7473
- export interface TypedMessage {
7474
- subject?: string
7475
- body: string
7476
- /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7477
- sms?: string
7478
- }
7479
-
7480
- /**
7481
- * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7482
- * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7483
- */
7484
- export interface MessageAbout {
7485
- appId?: string
7486
- /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7487
- type: string
7488
- id: string
7489
- view?: string
7490
- params?: Record<string, string>
7491
- /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7492
- label?: string
7493
- }
7494
-
7495
- export interface TransactionalSendError {
7496
- ok: false
7497
- /**
7498
- * Error code. Known values:
7499
- * - `transactional.contact_not_found`
7500
- * - `transactional.template_not_found`
7501
- * - `transactional.no_channel_available`
7502
- * - `transactional.email_missing`
7503
- * - `transactional.phone_missing`
7504
- * - `transactional.whatsapp_missing`
7505
- * - `transactional.no_push_methods`
7506
- * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7507
- * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7508
- * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7509
- */
7510
- error: string
7511
- }
7019
+ **CommsSettingsPatchBody** = `Partial<CommsSettings>`
7020
+
7021
+ **ConsentChannels** = `Partial<Record<BroadcastChannel, boolean>>`
7022
+
7023
+ **EmailAttachmentSpec** = ``
7512
7024
 
7025
+ **TransactionalSendResult** = `// src/types/comms.ts
7026
+ // Communication and notification types for the Smartlinks API
7027
+ import type { IdField } from './common'
7028
+ import type { BroadcastChannel } from './broadcasts'
7029
+
7030
+ /**
7031
+ * Target subject for notifications (product, collection, etc.)
7032
+ */
7033
+ export interface NotificationSubjectTarget {
7034
+ /** Type of target entity */
7035
+ type: 'product' | 'collection' | 'user' | 'batch' | 'proof'
7036
+ /** ID of the target entity */
7037
+ id: string
7038
+ }
7039
+
7040
+
7041
+ // Analytics & logging (communication events)
7042
+
7043
+ export interface CommunicationEvent {
7044
+ orgId: string
7045
+ broadcastId?: string
7046
+ journeyId?: string
7047
+ userId?: string
7048
+ contactId?: string
7049
+ channel?: string
7050
+ timestamp: string
7051
+ eventType: string
7052
+ outcome?: string | null
7053
+ templateId?: string | null
7054
+ [k: string]: any
7055
+ }
7056
+
7057
+ export interface CommsQueryByUser {
7058
+ userId?: string
7059
+ contactId?: string
7060
+ from?: string
7061
+ to?: string
7062
+ limit?: number
7063
+ }
7064
+
7065
+ export type RecipientId = string
7066
+ export interface RecipientWithOutcome { id: string; outcome: string }
7067
+
7068
+ export interface CommsRecipientIdsQuery {
7069
+ broadcastId?: string
7070
+ journeyId?: string
7071
+ journeyStepId?: string
7072
+ idField?: IdField
7073
+ from?: string
7074
+ to?: string
7075
+ limit?: number
7076
+ }
7077
+
7078
+ export interface CommsRecipientsWithoutActionQuery {
7079
+ broadcastId?: string
7080
+ journeyId?: string
7081
+ actionId?: string
7082
+ appId?: string
7083
+ idField?: IdField
7084
+ from?: string
7085
+ to?: string
7086
+ limit?: number
7087
+ }
7088
+
7089
+ export interface CommsRecipientsWithActionQuery {
7090
+ broadcastId?: string
7091
+ journeyId?: string
7092
+ actionId?: string
7093
+ appId?: string
7094
+ outcome?: string
7095
+ idField?: IdField
7096
+ includeOutcome?: boolean
7097
+ from?: string
7098
+ to?: string
7099
+ limit?: number
7100
+ }
7101
+
7102
+ export interface LogCommunicationEventBody {
7103
+ broadcastId?: string
7104
+ journeyId?: string
7105
+ userId?: string
7106
+ contactId?: string
7107
+ channel?: string
7108
+ eventType: string
7109
+ outcome?: string
7110
+ templateId?: string
7111
+ timestamp?: string
7112
+ [k: string]: any
7113
+ }
7114
+
7115
+ export interface LogBulkCommunicationEventsBody {
7116
+ params: { broadcastId?: string; journeyId?: string; [k: string]: any }
7117
+ ids: string[]
7118
+ idField?: IdField
7119
+ }
7120
+
7121
+ export interface AppendResult { success: true }
7122
+ export interface AppendBulkResult { success: true; count: number }
7123
+
7124
+ // Common recipient type used by segments and broadcasts
7125
+ export type Recipient = import('./contact').Contact
7126
+
7127
+ // Shared page response shape for recipient listings
7128
+ export interface RecipientsPage {
7129
+ items: Recipient[]
7130
+ total: number
7131
+ limit: number
7132
+ offset: number
7133
+ note?: string
7134
+ }
7135
+
7136
+ // Web Push (public client registration)
7137
+
7138
+ export interface PushSubscriptionJSON {
7139
+ endpoint: string
7140
+ keys?: {
7141
+ p256dh?: string
7142
+ auth?: string
7143
+ }
7144
+ }
7145
+
7146
+ export interface PushVapidResponse { publicKey: string }
7147
+ export interface PushSubscribeResponse { ok: true; id: string }
7148
+
7149
+ // Public: register a push contact method
7150
+ export interface RegisterPushMethodRequest {
7151
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7152
+ contactId?: string
7153
+ endpoint: string
7154
+ keys: { p256dh: string; auth: string }
7155
+ meta?: Record<string, any>
7156
+ }
7157
+
7158
+ // Admin Comms Settings
7159
+
7160
+ export interface CommsSettings {
7161
+ unsub?: {
7162
+ requireToken?: boolean
7163
+ /** Secret for token generation; omitted unless includeSecret=true */
7164
+ secret?: string
7165
+ /** Convenience flag indicating a secret is set (masked responses) */
7166
+ hasSecret?: boolean
7167
+ }
7168
+ /** Map of topic keys to topic config */
7169
+ topics?: Record<string, TopicConfig>
7170
+ [k: string]: any
7171
+ }
7172
+
7173
+ export interface TopicConfig {
7174
+ label?: string
7175
+ description?: string
7176
+ /** Optional UI-only grouping labels */
7177
+ labels?: string[]
7178
+ /** Classification for UI and default policy guidance */
7179
+ classification?: 'transactional' | 'marketing'
7180
+ defaults?: {
7181
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7182
+ topics?: Record<string, boolean | undefined>
7183
+ /** Default consent policy when explicit preferences are absent */
7184
+ policy?: 'opt-in' | 'opt-out'
7185
+ /** Per-channel default policy (overrides policy when present) */
7186
+ byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
7187
+ }
7188
+ rules?: {
7189
+ allowChannels?: BroadcastChannel[]
7190
+ allowUnsubscribe?: boolean
7191
+ required?: boolean
7192
+ }
7193
+ [k: string]: any
7194
+ }
7195
+
7196
+ export interface CommsSettingsGetResponse {
7197
+ ok: true
7198
+ settings: CommsSettings
7199
+ }
7200
+
7201
+ export type CommsSettingsPatchBody = Partial<CommsSettings>
7202
+
7203
+ // Public types listing (array form for public API)
7204
+ export interface CommsPublicTopicsResponse { ok: true; topics: Record<string, TopicConfig> }
7205
+
7206
+ export interface UnsubscribeQuery {
7207
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7208
+ contactId?: string
7209
+ topic?: string
7210
+ channel?: BroadcastChannel
7211
+ token?: string
7212
+ }
7213
+
7214
+ export interface UnsubscribeResponse { ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> } }
7215
+
7216
+ // Public sign-up (double opt-in)
7217
+ export interface CommsSignupRequest {
7218
+ email: string
7219
+ /**
7220
+ * Required: YOUR app's confirmation email — a template in this collection (SL.template) whose body
7221
+ * uses `{{ action_url }}` for the confirm link (`{{ topics }}` lists what they signed up for). The
7222
+ * platform sends no default sign-up email.
7223
+ */
7224
+ templateId: string
7225
+ /** Topic ids from the collection's comm settings (e.g. ["newsletter"]). */
7226
+ topics?: string[]
7227
+ firstName?: string
7228
+ /**
7229
+ * The form's other answers — firstName/lastName/displayName/company/locale/timezone and
7230
+ * `customFields`. Applied to the contact when the address is confirmed, and only where the contact
7231
+ * has no value yet (never overwritten). Small: ~2 KB.
7232
+ */
7233
+ fields?: { firstName?: string; lastName?: string; displayName?: string; company?: string; locale?: string; timezone?: string; customFields?: Record<string, string | number | boolean> }
7234
+ /** Your app id, recorded with the sent email. */
7235
+ appId?: string
7236
+ }
7237
+ export interface CommsSignupResponse { ok: true; pending: true }
7238
+
7239
+ // Public consent/preferences/subscribe
7240
+ export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>
7241
+ type SubjectType = import('./contact').SubjectType
7242
+
7243
+ export interface CommsConsentUpsertRequest {
7244
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7245
+ contactId?: string
7246
+ channels?: ConsentChannels
7247
+ topics?: Record<string, boolean>
7248
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7249
+ }
7250
+
7251
+ export interface CommsPreferencesUpsertRequest {
7252
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7253
+ contactId?: string
7254
+ subject?: { type: SubjectType; id: string; productId?: string }
7255
+ channels?: ConsentChannels
7256
+ topics?: Record<string, boolean>
7257
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
7258
+ }
7259
+
7260
+ export interface CommsSubscribeRequest {
7261
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7262
+ contactId?: string
7263
+ subject: { type: SubjectType; id: string; productId?: string }
7264
+ subscribe: boolean
7265
+ source?: string
7266
+ }
7267
+ export interface CommsSubscribeResponse { ok: true; subscriptionId: string }
7268
+
7269
+ export interface CommsSubscriptionCheckQuery {
7270
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7271
+ contactId?: string
7272
+ subjectType: SubjectType
7273
+ subjectId: string
7274
+ productId?: string
7275
+ }
7276
+ export interface CommsSubscriptionCheckResponse { ok: true; subscribed: boolean }
7277
+
7278
+ export interface CommsListMethodsQuery {
7279
+ /** Optional: defaults to the signed-in user's own contact. Only collection admins may name another contact. */
7280
+ contactId?: string
7281
+ type?: BroadcastChannel
7282
+ }
7283
+ export interface CommsListMethodsResponse { ok: true; methods: import('./contact').CommMethod[] }
7284
+
7285
+ export interface RegisterEmailMethodRequest { contactId?: string; email?: string; userId?: string }
7286
+ export interface RegisterSmsMethodRequest { contactId?: string; phone?: string; userId?: string }
7287
+ export interface RegisterMethodResponse { ok: true; contactId: string }
7288
+
7289
+ export interface SubscriptionsResolveRequest {
7290
+ subject: { type: SubjectType; id: string; productId?: string }
7291
+ hints: { userId?: string; pushEndpoint?: string; email?: string }
7292
+ }
7293
+ export interface SubscriptionsResolveResponse {
7294
+ ok: true
7295
+ subject: { type: SubjectType; id: string; productId?: string }
7296
+ contacts: Array<{
7297
+ contactId: string
7298
+ subscribed: boolean
7299
+ channels?: Partial<Record<BroadcastChannel, boolean>>
7300
+ }>
7301
+ anySubscribed: boolean
7302
+ anyMethods: boolean
7303
+ }
7304
+
7305
+ // Transactional send (single-contact, single-message)
7306
+
7307
+ /**
7308
+ * Send a single message to one contact using a template.
7309
+ * No broadcast record is created; the send is logged directly to the
7310
+ * contact's communication history with sourceType: 'transactional'.
7311
+ *
7312
+ * POST /admin/collection/:collectionId/comm/send
7313
+ */
7314
+ export interface TransactionalSendRequest {
7315
+ /** CRM contact UUID */
7316
+ contactId: string
7317
+ /** A saved template's id. Give this or `message`. */
7318
+ templateId?: string
7319
+ /**
7320
+ * A typed message instead of a template: plain text, Liquid allowed (`{{ contact.firstName }}`).
7321
+ * `sms` is the shorter text for SMS and WhatsApp (defaults to `body`).
7322
+ */
7323
+ message?: TypedMessage
7324
+ /**
7325
+ * Channel to send on. Defaults to 'preferred', which auto-selects the
7326
+ * contact's best available channel respecting consent, suppression, and
7327
+ * template availability.
7328
+ */
7329
+ channel?: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet' | 'preferred'
7330
+ /** Extra Liquid variables merged into the top-level render context */
7331
+ props?: Record<string, unknown>
7332
+ /** Context objects to hydrate into the Liquid template */
7333
+ include?: {
7334
+ /** Hydrate {{ collection }}. Default: true */
7335
+ collection?: boolean
7336
+ /** Hydrate {{ product }} from this product ID */
7337
+ productId?: string
7338
+ /** Hydrate {{ proof }} (requires productId) */
7339
+ proofId?: string
7340
+ /** Hydrate {{ user }} from contact.userId */
7341
+ user?: boolean
7342
+ /** Hydrate {{ appCase }} from this case UUID */
7343
+ appCase?: string
7344
+ /** Hydrate {{ appThread }} from this thread UUID */
7345
+ appThread?: string
7346
+ /** Hydrate {{ appRecord }} from this record UUID */
7347
+ appRecord?: string
7348
+ }
7349
+ /** Arbitrary label stored on the comms-events row (e.g. 'warranty-step-2') */
7350
+ ref?: string
7351
+ /** App context stored on the comms-events row */
7352
+ appId?: string
7353
+ /**
7354
+ * What the message is about: the record it was sent for and the admin screen that shows it, so it is a
7355
+ * link in Messages, on the contact's Activity, and on the conversation a reply opens. `appId` defaults
7356
+ * to the sending app.
7357
+ */
7358
+ about?: MessageAbout
7359
+ /**
7360
+ * `'service'` (a confirmation, a reminder, an update): an asked-for channel the person turned off, or a
7361
+ * suppressed email, is refused (`transactional.opted_out`). Marketing goes out as a campaign.
7362
+ */
7363
+ category?: 'service'
7364
+ /**
7365
+ * Files to attach (email only; at most 5, 10 MB in all). What can't be made is left out and listed in
7366
+ * `attachmentsLeftOut` — the email still goes.
7367
+ */
7368
+ attach?: EmailAttachmentSpec[]
7369
+ }
7370
+
7371
+ /**
7372
+ * One file for an email:
7373
+ * - `'calendar'` — the booking's `.ics` calendar invite (needs `include.booking` and `appId`)
7374
+ * - `{ asset }` — a file uploaded to this collection's assets
7375
+ * - `{ function }` — the app's (`appId`) own server function makes it (see server-functions.md, "Making an email attachment")
7376
+ * - `{ filename, contentType, content }` — a file you made, base64 (PDF, Office documents, images, text, CSV, calendar)
7377
+ * - `{ filename, file }` — a private file you made (e.g. `pdf.create` with `return: 'signedUrl'`)
7378
+ */
7379
+ export type EmailAttachmentSpec =
7380
+ | 'calendar'
7381
+ | { asset: string }
7382
+ | { function: string }
7383
+ | { filename: string; contentType: string; content: string }
7384
+ | { filename: string; contentType?: string; file: string }
7385
+
7386
+ export interface TransactionalSendResponse {
7387
+ ok: true
7388
+ /** The channel the message was actually sent on */
7389
+ channel: 'email' | 'sms' | 'whatsapp' | 'push' | 'wallet'
7390
+ /** Provider message ID (email/SMS/WhatsApp); absent for push/wallet */
7391
+ messageId?: string
7392
+ /** Attachments that couldn't be made, and why (the email went without them) */
7393
+ attachmentsLeftOut?: string[]
7394
+ }
7395
+
7396
+ /** A message written there and then rather than a saved template. */
7397
+ export interface TypedMessage {
7398
+ subject?: string
7399
+ body: string
7400
+ /** The shorter text for SMS and WhatsApp (defaults to `body`). */
7401
+ sms?: string
7402
+ }
7403
+
7404
+ /**
7405
+ * What a message is about (docs/comms.md, "What a message is about"). Ids only, never content.
7406
+ * `view` and `params` name one of the app's admin views (manifest `adminViews`, docs/admin-views.md).
7407
+ */
7408
+ export interface MessageAbout {
7409
+ appId?: string
7410
+ /** What kind of record: `'booking'`, `'entry'`, `'case'`. */
7411
+ type: string
7412
+ id: string
7413
+ view?: string
7414
+ params?: Record<string, string>
7415
+ /** A short label to show without looking the record up: `'Sat 3pm, table for 4'`. */
7416
+ label?: string
7417
+ }
7418
+
7419
+ export interface TransactionalSendError {
7420
+ ok: false
7421
+ /**
7422
+ * Error code. Known values:
7423
+ * - `transactional.contact_not_found`
7424
+ * - `transactional.template_not_found`
7425
+ * - `transactional.no_channel_available`
7426
+ * - `transactional.email_missing`
7427
+ * - `transactional.phone_missing`
7428
+ * - `transactional.whatsapp_missing`
7429
+ * - `transactional.no_push_methods`
7430
+ * - `transactional.no_wallet_passes` (`channel: 'wallet'`: the person has no wallet passes from this app)
7431
+ * - `transactional.opted_out` (category `'service'`: the person turned that channel off, or the email is suppressed)
7432
+ * - `transactional.template_or_message` / `transactional.message_invalid` / `transactional.about_invalid`
7433
+ */
7434
+ error: string
7435
+ }
7436
+
7513
7437
  export type TransactionalSendResult =`
7514
7438
 
7515
7439
  ### config
@@ -9899,6 +9823,131 @@ interface JourneyFunnelReportResponse {
9899
9823
 
9900
9824
  **JourneyStepRecipientsResponse** = `string[]`
9901
9825
 
9826
+ ### knowledge
9827
+
9828
+ **KnowledgeSet** (interface)
9829
+ ```typescript
9830
+ interface KnowledgeSet {
9831
+ id: string
9832
+ key: string
9833
+ name: string
9834
+ description: string | null
9835
+ visibility: KnowledgeVisibility
9836
+ ownerAppId: string | null
9837
+ embedModel: string | null
9838
+ createdAt: string
9839
+ updatedAt: string
9840
+ sourceCount?: number
9841
+ passageCount?: number
9842
+ }
9843
+ ```
9844
+
9845
+ **SaveKnowledgeSetRequest** (interface)
9846
+ ```typescript
9847
+ interface SaveKnowledgeSetRequest {
9848
+ key: string
9849
+ name: string
9850
+ description?: string | null
9851
+ visibility?: KnowledgeVisibility
9852
+ }
9853
+ ```
9854
+
9855
+ **UpdateKnowledgeSetRequest** (interface)
9856
+ ```typescript
9857
+ interface UpdateKnowledgeSetRequest {
9858
+ name?: string
9859
+ description?: string | null
9860
+ visibility?: KnowledgeVisibility
9861
+ }
9862
+ ```
9863
+
9864
+ **KnowledgeSource** (interface)
9865
+ ```typescript
9866
+ interface KnowledgeSource {
9867
+ id: string
9868
+ setId: string
9869
+ kind: KnowledgeSourceKind
9870
+ name: string | null
9871
+ config: Record<string, any>
9872
+ refreshHours: number | null
9873
+ status: 'pending' | 'indexing' | 'ready' | 'failed'
9874
+ error: string | null
9875
+ passageCount: number
9876
+ lastIndexedAt: string | null
9877
+ createdAt: string
9878
+ updatedAt: string
9879
+ }
9880
+ ```
9881
+
9882
+ **AddKnowledgeSourceRequest** (interface)
9883
+ ```typescript
9884
+ interface AddKnowledgeSourceRequest {
9885
+ kind: KnowledgeSourceKind
9886
+ config?: { url?: string; [key: string]: any }
9887
+ name?: string
9888
+ refreshHours?: number | null
9889
+ }
9890
+ ```
9891
+
9892
+ **UpdateKnowledgeSourceRequest** (interface)
9893
+ ```typescript
9894
+ interface UpdateKnowledgeSourceRequest {
9895
+ config?: { url?: string; [key: string]: any }
9896
+ name?: string
9897
+ refreshHours?: number | null
9898
+ }
9899
+ ```
9900
+
9901
+ **KnowledgeDocument** (interface)
9902
+ ```typescript
9903
+ interface KnowledgeDocument {
9904
+ ref: string
9905
+ title: string
9906
+ body: string
9907
+ url?: string
9908
+ meta?: Record<string, any>
9909
+ }
9910
+ ```
9911
+
9912
+ **KnowledgeSearchRequest** (interface)
9913
+ ```typescript
9914
+ interface KnowledgeSearchRequest {
9915
+ query: string
9916
+ sets?: string[]
9917
+ filters?: Record<string, any>
9918
+ k?: number
9919
+ }
9920
+ ```
9921
+
9922
+ **KnowledgeSearchResult** (interface)
9923
+ ```typescript
9924
+ interface KnowledgeSearchResult {
9925
+ id: string
9926
+ title: string
9927
+ heading: string | null
9928
+ url: string | null
9929
+ snippet: string
9930
+ text: string
9931
+ score: number
9932
+ set: { id: string; key: string; name: string }
9933
+ sourceId: string
9934
+ meta: Record<string, any>
9935
+ }
9936
+ ```
9937
+
9938
+ **KnowledgeSearchResponse** (interface)
9939
+ ```typescript
9940
+ interface KnowledgeSearchResponse {
9941
+ query: string
9942
+ results: KnowledgeSearchResult[]
9943
+ mode: 'hybrid' | 'keywords' | 'none'
9944
+ }
9945
+ ```
9946
+
9947
+ **KnowledgeVisibility** = `'public' | 'customer' | 'staff'`
9948
+
9949
+ **KnowledgeSourceKind** = ``
9950
+
9902
9951
  ### location
9903
9952
 
9904
9953
  **Location** (interface)
@@ -12958,36 +13007,36 @@ interface GuideStartOptions {
12958
13007
 
12959
13008
  **AppConfigOptions** (type)
12960
13009
  ```typescript
12961
- type AppConfigOptions = {
12962
- /** The app ID */
12963
- appId: string
12964
-
12965
- /** Collection ID (required for most operations) */
12966
- collectionId?: string
12967
- /** Product ID (optional - for product-scoped config) */
12968
- productId?: string
12969
- /** Variant ID (optional - for variant-scoped config) */
12970
- variantId?: string
12971
- /** Batch ID (optional - for batch-scoped config) */
12972
- batchId?: string
12973
-
12974
- /** Item ID - required for getDataItem/deleteDataItem */
12975
- itemId?: string
12976
-
12977
- /**
12978
- * Use admin endpoints instead of public.
12979
- * This selects which endpoint is called; it does not by itself make root-level config fields private.
12980
- */
12981
- admin?: boolean
12982
-
12983
- /**
12984
- * Configuration object for setConfig.
12985
- * For admin-only values in app config, store them under a top-level `admin` object.
12986
- * Public reads return the root config but omit `config.admin`.
12987
- */
12988
- config?: any
12989
- /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
12990
- data?: any
13010
+ type AppConfigOptions = {
13011
+ /** The app ID */
13012
+ appId: string
13013
+
13014
+ /** Collection ID (required for most operations) */
13015
+ collectionId?: string
13016
+ /** Product ID (optional - for product-scoped config) */
13017
+ productId?: string
13018
+ /** Variant ID (optional - for variant-scoped config) */
13019
+ variantId?: string
13020
+ /** Batch ID (optional - for batch-scoped config) */
13021
+ batchId?: string
13022
+
13023
+ /** Item ID - required for getDataItem/deleteDataItem */
13024
+ itemId?: string
13025
+
13026
+ /**
13027
+ * Use admin endpoints instead of public.
13028
+ * This selects which endpoint is called; it does not by itself make root-level config fields private.
13029
+ */
13030
+ admin?: boolean
13031
+
13032
+ /**
13033
+ * Configuration object for setConfig.
13034
+ * For admin-only values in app config, store them under a top-level `admin` object.
13035
+ * Public reads return the root config but omit `config.admin`.
13036
+ */
13037
+ config?: any
13038
+ /** Data object for setDataItem. Best for small keyed scoped documents rather than richer app domain objects. */
13039
+ data?: any
12991
13040
  }
12992
13041
  ```
12993
13042
 
@@ -13411,70 +13460,70 @@ Fire-and-forget tag analytics event. Uses `navigator.sendBeacon()` when availabl
13411
13460
 
13412
13461
  Workflow-oriented app objects for issues, requests, claims, and tasks that move through statuses and often need assignment or history.
13413
13462
 
13414
- **create**(collectionId: string,
13415
- appId: string,
13416
- input: CreateCaseInput,
13463
+ **create**(collectionId: string,
13464
+ appId: string,
13465
+ input: CreateCaseInput,
13417
13466
  admin: boolean = false) → `Promise<AppCase>`
13418
13467
  Create a new case POST /cases
13419
13468
 
13420
- **list**(collectionId: string,
13421
- appId: string,
13422
- params?: CaseListQueryParams,
13469
+ **list**(collectionId: string,
13470
+ appId: string,
13471
+ params?: CaseListQueryParams,
13423
13472
  admin: boolean = false) → `Promise<PaginatedResponse<AppCase>>`
13424
13473
  List cases with optional query parameters GET /cases
13425
13474
 
13426
- **get**(collectionId: string,
13427
- appId: string,
13428
- caseId: string,
13475
+ **get**(collectionId: string,
13476
+ appId: string,
13477
+ caseId: string,
13429
13478
  admin: boolean = false) → `Promise<AppCase>`
13430
13479
  Get a single case by ID GET /cases/:caseId
13431
13480
 
13432
- **update**(collectionId: string,
13433
- appId: string,
13434
- caseId: string,
13435
- input: UpdateCaseInput,
13481
+ **update**(collectionId: string,
13482
+ appId: string,
13483
+ caseId: string,
13484
+ input: UpdateCaseInput,
13436
13485
  admin: boolean = false) → `Promise<AppCase>`
13437
13486
  Update a case PATCH /cases/:caseId Admin can update any field, public (owner) can only update data and owner zones
13438
13487
 
13439
- **remove**(collectionId: string,
13440
- appId: string,
13441
- caseId: string,
13488
+ **remove**(collectionId: string,
13489
+ appId: string,
13490
+ caseId: string,
13442
13491
  admin: boolean = false) → `Promise<`
13443
13492
  Soft delete a case DELETE /cases/:caseId
13444
13493
 
13445
- **aggregate**(collectionId: string,
13446
- appId: string,
13447
- request: AggregateRequest,
13494
+ **aggregate**(collectionId: string,
13495
+ appId: string,
13496
+ request: AggregateRequest,
13448
13497
  admin: boolean = false) → `Promise<AggregateResponse>`
13449
13498
  Get aggregate statistics for cases POST /cases/aggregate
13450
13499
 
13451
- **summary**(collectionId: string,
13452
- appId: string,
13500
+ **summary**(collectionId: string,
13501
+ appId: string,
13453
13502
  request?: CaseSummaryRequest) → `Promise<CaseSummaryResponse>`
13454
13503
  Get case summary (admin only) POST /cases/summary
13455
13504
 
13456
- **appendHistory**(collectionId: string,
13457
- appId: string,
13458
- caseId: string,
13505
+ **appendHistory**(collectionId: string,
13506
+ appId: string,
13507
+ caseId: string,
13459
13508
  input: AppendHistoryInput) → `Promise<AppCase>`
13460
13509
  Append an entry to case history (admin only) POST /cases/:caseId/history
13461
13510
 
13462
- **related**(collectionId: string,
13463
- appId: string,
13511
+ **related**(collectionId: string,
13512
+ appId: string,
13464
13513
  caseId: string) → `Promise<RelatedResponse>`
13465
13514
  Get related threads and records for a case (admin only) GET /cases/:caseId/related
13466
13515
 
13467
13516
  ### app.options
13468
13517
 
13469
- **get**(collectionId: string,
13470
- appId: string,
13471
- source: string,
13518
+ **get**(collectionId: string,
13519
+ appId: string,
13520
+ source: string,
13472
13521
  opts: { q?: string; version?: string; admin?: boolean } = {},) → `Promise<import('../types/appOptions').AppOptionsResponse>`
13473
13522
  `source` = `type:<record type or declared type id>` | `list:<list id>`. Admins (`admin: true`) see every entry; the public API lists public records and lists the app declares public. Hold on to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
13474
13523
 
13475
- **saveList**(collectionId: string,
13476
- appId: string,
13477
- listId: string,
13524
+ **saveList**(collectionId: string,
13525
+ appId: string,
13526
+ listId: string,
13478
13527
  values: import('../types/appOptions') → `void`
13479
13528
  Save a value list's values, in order (admins). Codes never change and are never lost: a value left out stays, switched off, at the end. → the list as saved.
13480
13529
 
@@ -13482,92 +13531,92 @@ Save a value list's values, in order (admins). Codes never change and are never
13482
13531
 
13483
13532
  General-purpose structured app objects. Use these when a simple scoped data item grows into something queryable, lifecycle-aware, or access-controlled.
13484
13533
 
13485
- **create**(collectionId: string,
13486
- appId: string,
13487
- input: CreateRecordInput,
13534
+ **create**(collectionId: string,
13535
+ appId: string,
13536
+ input: CreateRecordInput,
13488
13537
  admin: boolean = false) → `Promise<CreateRecordResponse>`
13489
13538
  Create a new record POST /records When called on the public endpoint (admin = false) with an anonymous caller, and the app's `publicCreate.records.anonymous.edit.editToken` policy is enabled, the response includes a one-time `editToken` string. Store it immediately — it is never returned again.
13490
13539
 
13491
- **query**(collectionId: string,
13492
- appId: string,
13540
+ **query**(collectionId: string,
13541
+ appId: string,
13493
13542
  body: StandardQuery = {}) → `Promise<QueryResult>`
13494
13543
  The standard query on an app's records (admin only): filter, sort, page, count and total in one call, reaching into a record's own fields by path, and following a record to its `product` and its `contact`. POST /admin/collection/:collectionId/app/:appId/records/query Fields: id, recordType, ref, status, visibility, customId, productId, variantId, batchId, proofId, contactId, authorId, parentType, parentId, createdAt, updatedAt, startsAt, expiresAt, and the documents data, owner and admin, reached by path: `"data.status"`, `"data.line.name"`. ```typescript // How many work orders by status, and how many units on each await app.records.query(collectionId, appId, { where: { recordType: 'work_order' }, groupBy: ['data.status'], aggregates: { orders: { count: true }, units: { sum: 'data.qty' } }, }) ```
13495
13544
 
13496
13545
  **queryFields**(collectionId: string, appId: string) → `Promise<QueryDescription>`
13497
13546
  What a records query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/app/:appId/records/query
13498
13547
 
13499
- **list**(collectionId: string,
13500
- appId: string,
13501
- params?: RecordListQueryParams,
13548
+ **list**(collectionId: string,
13549
+ appId: string,
13550
+ params?: RecordListQueryParams,
13502
13551
  admin: boolean = false) → `Promise<PaginatedResponse<AppRecord>>`
13503
13552
  List records with optional query parameters GET /records Public/owner callers only receive records with `status: "active"`. Admin callers can query all statuses (for example `draft`/`archived`).
13504
13553
 
13505
- **get**(collectionId: string,
13506
- appId: string,
13507
- recordId: string,
13554
+ **get**(collectionId: string,
13555
+ appId: string,
13556
+ recordId: string,
13508
13557
  admin: boolean = false) → `Promise<AppRecord>`
13509
13558
  Get a single record by ID GET /records/:recordId
13510
13559
 
13511
- **update**(collectionId: string,
13512
- appId: string,
13513
- recordId: string,
13514
- input: UpdateRecordInput,
13560
+ **update**(collectionId: string,
13561
+ appId: string,
13562
+ recordId: string,
13563
+ input: UpdateRecordInput,
13515
13564
  admin: boolean = false) → `Promise<AppRecord>`
13516
13565
  Update a record PATCH /records/:recordId Admin can update any field, public (owner) can only update data and owner
13517
13566
 
13518
- **updateWithToken**(collectionId: string,
13519
- appId: string,
13520
- recordId: string,
13521
- data: Record<string, unknown>,
13567
+ **updateWithToken**(collectionId: string,
13568
+ appId: string,
13569
+ recordId: string,
13570
+ data: Record<string, unknown>,
13522
13571
  editToken: string) → `Promise<AppRecord>`
13523
13572
  Amend the `data` zone of a record using an anonymous edit token. PATCH /records/:recordId (public endpoint, no auth) This is the follow-up call after an anonymous `create()` that returned an `editToken`. Present the token via `X-Edit-Token` — the server validates it with a constant-time comparison and, if `windowMinutes` is configured in the policy, checks that the token has not expired. **Scope:** only the `data` zone may be modified via this path. `owner`, `admin`, `status`, `visibility`, and indexed fields are immutable to anonymous token holders. ```ts const record = await app.records.create(collectionId, appId, { recordType: 'payment', visibility: 'public', data: { amount: 9900, currency: 'USD' }, }) const { editToken } = record // store this immediately! // Later, once the payment gateway confirms: const updated = await app.records.updateWithToken( collectionId, appId, record.id, { amount: 9900, currency: 'USD', transactionId: 'txn_abc123' }, editToken, ) ``` ### Error codes | HTTP | `errorCode` | Meaning | |------|-----------------------|---------------------------------------------------| | 401 | `UNAUTHORIZED` | No auth token and no `X-Edit-Token` header | | 403 | `FORBIDDEN` | Policy not enabled, or token does not match | | 403 | `EDIT_WINDOW_EXPIRED` | `windowMinutes` elapsed since record creation | | 404 | `NOT_FOUND` | Record does not exist |
13524
13573
 
13525
- **remove**(collectionId: string,
13526
- appId: string,
13527
- recordId: string,
13574
+ **remove**(collectionId: string,
13575
+ appId: string,
13576
+ recordId: string,
13528
13577
  admin: boolean = false) → `Promise<`
13529
13578
  Soft delete a record DELETE /records/:recordId
13530
13579
 
13531
- **aggregate**(collectionId: string,
13532
- appId: string,
13533
- request: AggregateRequest,
13580
+ **aggregate**(collectionId: string,
13581
+ appId: string,
13582
+ request: AggregateRequest,
13534
13583
  admin: boolean = false) → `Promise<AggregateResponse>`
13535
13584
  Get aggregate statistics for records POST /records/aggregate
13536
13585
 
13537
- **restore**(collectionId: string,
13538
- appId: string,
13586
+ **restore**(collectionId: string,
13587
+ appId: string,
13539
13588
  recordId: string) → `Promise<AppRecord>`
13540
13589
  Restore a soft-deleted record. POST /records/:recordId/restore (admin only)
13541
13590
 
13542
- **upsert**(collectionId: string,
13543
- appId: string,
13591
+ **upsert**(collectionId: string,
13592
+ appId: string,
13544
13593
  input: UpsertRecordInput) → `Promise<UpsertRecordResponse>`
13545
13594
  Upsert a record by ref — creates if no record with that ref exists, otherwise updates. Scope, specificity, and ref are canonicalized on write. POST /records/upsert (admin only)
13546
13595
 
13547
- **match**(collectionId: string,
13548
- appId: string,
13549
- input: MatchRecordsInput,
13596
+ **match**(collectionId: string,
13597
+ appId: string,
13598
+ input: MatchRecordsInput,
13550
13599
  admin: boolean = false) → `Promise<MatchResult>`
13551
13600
  Match records against a runtime target scope. Returns records whose scope is satisfied by the target, ordered by specificity descending (most specific first). POST /records/match ```ts const { records, best } = await app.records.match(collectionId, appId, { target: { productId: 'prod_abc', facets: { tier: ['gold'] } }, strategy: 'best', recordType: 'nutrition', }, true); // best.nutrition → the single highest-specificity nutrition record ```
13552
13601
 
13553
- **bulkUpsert**(collectionId: string,
13554
- appId: string,
13602
+ **bulkUpsert**(collectionId: string,
13603
+ appId: string,
13555
13604
  records: BulkUpsertItem[]) → `Promise<BulkUpsertResult>`
13556
13605
  Upsert up to 500 records in a single transaction. Each row is individually error-isolated — a failure on one row does not abort the others. POST /records/bulk-upsert (admin only)
13557
13606
 
13558
- **bulkDelete**(collectionId: string,
13559
- appId: string,
13607
+ **bulkDelete**(collectionId: string,
13608
+ appId: string,
13560
13609
  input: BulkDeleteInput) → `Promise<BulkDeleteResult>`
13561
13610
  Soft-delete records in bulk. Supports two modes: - **refs mode**: explicit list of refs (max 1000) - **scope mode**: delete by scope anchor (productId / variantId / etc.) POST /records/bulk-delete (admin only) ```ts // Refs mode await app.records.bulkDelete(collectionId, appId, { refs: ['product:prod_abc', 'product:prod_xyz'], recordType: 'nutrition', }); // Scope mode await app.records.bulkDelete(collectionId, appId, { scope: { productId: 'prod_abc' }, }); ```
13562
13611
 
13563
- **resolveAll**(collectionId: string,
13564
- appId: string,
13565
- input: ResolveAllParams,
13612
+ **resolveAll**(collectionId: string,
13613
+ appId: string,
13614
+ input: ResolveAllParams,
13566
13615
  admin: boolean = false) → `Promise<ResolveAllResult>`
13567
13616
  Resolve every applicable record for a product context in one call. Returns records across all tiers (proof, batch, variant, product, rule, facet, collection) deduplicated and sorted by specificity descending. POST /records/resolve-all
13568
13617
 
13569
- **previewRule**(collectionId: string,
13570
- appId: string,
13618
+ **previewRule**(collectionId: string,
13619
+ appId: string,
13571
13620
  input: PreviewRuleParams) → `Promise<PreviewRuleResult>`
13572
13621
  Preview which products in the collection match a given facetRule. Admin only. Use for live "matches N products" feedback while authoring a rule. POST /records/preview-rule
13573
13622
 
@@ -13575,54 +13624,54 @@ Preview which products in the collection match a given facetRule. Admin only. Us
13575
13624
 
13576
13625
  Conversation-oriented app objects for comments, discussions, Q&A, and reply-driven experiences.
13577
13626
 
13578
- **create**(collectionId: string,
13579
- appId: string,
13580
- input: CreateThreadInput,
13627
+ **create**(collectionId: string,
13628
+ appId: string,
13629
+ input: CreateThreadInput,
13581
13630
  admin: boolean = false) → `Promise<AppThread>`
13582
13631
  Create a new thread POST /threads
13583
13632
 
13584
- **list**(collectionId: string,
13585
- appId: string,
13586
- params?: ThreadListQueryParams,
13633
+ **list**(collectionId: string,
13634
+ appId: string,
13635
+ params?: ThreadListQueryParams,
13587
13636
  admin: boolean = false) → `Promise<PaginatedResponse<AppThread>>`
13588
13637
  List threads with optional query parameters GET /threads
13589
13638
 
13590
- **get**(collectionId: string,
13591
- appId: string,
13592
- threadId: string,
13639
+ **get**(collectionId: string,
13640
+ appId: string,
13641
+ threadId: string,
13593
13642
  admin: boolean = false) → `Promise<AppThread>`
13594
13643
  Get a single thread by ID GET /threads/:threadId
13595
13644
 
13596
- **update**(collectionId: string,
13597
- appId: string,
13598
- threadId: string,
13599
- input: UpdateThreadInput,
13645
+ **update**(collectionId: string,
13646
+ appId: string,
13647
+ threadId: string,
13648
+ input: UpdateThreadInput,
13600
13649
  admin: boolean = false) → `Promise<AppThread>`
13601
13650
  Update a thread PATCH /threads/:threadId Admin can update any field, public (owner) can only update body, tags, data, owner
13602
13651
 
13603
- **remove**(collectionId: string,
13604
- appId: string,
13605
- threadId: string,
13652
+ **remove**(collectionId: string,
13653
+ appId: string,
13654
+ threadId: string,
13606
13655
  admin: boolean = false) → `Promise<`
13607
13656
  Soft delete a thread DELETE /threads/:threadId
13608
13657
 
13609
- **reply**(collectionId: string,
13610
- appId: string,
13611
- threadId: string,
13612
- input: ReplyInput,
13658
+ **reply**(collectionId: string,
13659
+ appId: string,
13660
+ threadId: string,
13661
+ input: ReplyInput,
13613
13662
  admin: boolean = false) → `Promise<AppThread>`
13614
13663
  Add a reply to a thread POST /threads/:threadId/reply Atomically appends to replies array, increments replyCount, updates lastReplyAt
13615
13664
 
13616
- **deleteReply**(collectionId: string,
13617
- appId: string,
13618
- threadId: string,
13619
- replyId: string,
13665
+ **deleteReply**(collectionId: string,
13666
+ appId: string,
13667
+ threadId: string,
13668
+ replyId: string,
13620
13669
  admin: boolean = false) → `Promise<AppThread>`
13621
13670
  Delete a single reply from a thread by its reply id (moderation). DELETE /threads/:threadId/reply/:replyId Authorised for the reply's author, the proof owner, or a collection admin.
13622
13671
 
13623
- **aggregate**(collectionId: string,
13624
- appId: string,
13625
- request: AggregateRequest,
13672
+ **aggregate**(collectionId: string,
13673
+ appId: string,
13674
+ request: AggregateRequest,
13626
13675
  admin: boolean = false) → `Promise<AggregateResponse>`
13627
13676
  Get aggregate statistics for threads POST /threads/aggregate
13628
13677
 
@@ -13657,19 +13706,19 @@ Set/create a keyed data item within a scope. Requires admin authentication. Use
13657
13706
  **deleteDataItem**(opts: AppConfigOptions) → `Promise<void>`
13658
13707
  Delete a keyed data item by ID within a scope. Requires admin authentication. ```typescript await appConfiguration.deleteDataItem({ appId: 'product-docs', collectionId: 'my-collection', productId: 'product-123', admin: true, itemId: 'manual-1' }); ```
13659
13708
 
13660
- **getWidgets**(collectionId: string,
13709
+ **getWidgets**(collectionId: string,
13661
13710
  options?: GetCollectionWidgetsOptions) → `Promise<CollectionWidgetsResponse>`
13662
13711
  Fetches ALL widget data (manifests + bundle files) for a collection in one call. Returns everything needed to render widgets with zero additional requests. This solves N+1 query problems by fetching manifests, JavaScript bundles, and CSS files in parallel on the server. ```typescript // Fetch all widget data for a collection const { apps } = await Api.AppConfiguration.getWidgets(collectionId); // Returns: [{ appId, manifest, widget, container, admin }, ...] // widget / container: { js: { umd?, esm? }, css?, source?, styles? } // source / styles - the bundle inlined (when small enough); js / css - URLs otherwise. // admin - URL of the app's app.admin.json (setup / tunable options), or null. // Bundles don't ship React: they resolve shared libraries from the HOST's globals // (host-dependency-contract.md), so loading one is a host's job. // // Inside a host (Portal / Hub), an app showing ANOTHER app's widget should not load // bundles itself - use the host-provided EmbeddedWidget prop: // <EmbeddedWidget appId="raffle" size="standard" /> (docs/widgets.md) // Force refresh all widgets const { apps } = await Api.AppConfiguration.getWidgets(collectionId, { force: true }); ```
13663
13712
 
13664
13713
  **resolveFeature**(system: SystemBlock | undefined, flag: string) → `boolean`
13665
13714
  Resolve whether a feature flag is on, applying the `accountType` default: `enterprise` accounts default every flag to **on** unless `features[flag]` is explicitly `false`; `standard` accounts (or missing `accountType`) default every flag to **off** unless `features[flag]` is explicitly `true`. An explicit value always wins over the default either way. This is the same logic `isFeatureEnabled()` / `isFeatureEnabledSync()` use internally — call those instead in normal code. `system.features` and `accountType` are public data (no admin-only feature-check path exists), so there's no reason to fetch differently for an admin surface. This is exposed separately only for the rare case where you already have a `system` block in hand from somewhere other than `getAppConfig()` (e.g. server-rendered props) and want to resolve a flag from it directly. ```typescript const enabled = appConfiguration.resolveFeature(someSystemBlock, 'custom_domain'); ```
13666
13715
 
13667
- **getAppConfig**(collectionId: string,
13716
+ **getAppConfig**(collectionId: string,
13668
13717
  options?: { force?: boolean }) → `Promise<AppsConfigResponse>`
13669
13718
  Fetch the collection's app catalog + `appConfig` entitlements data in one call — installed modules (`apps`), resolved entitlements (`system.features`, `system.meters`, etc.), and item-handling settings. This is `/public/collection/:id/app/config` (`collection.getAppsConfig()`), which now carries both; there's no need to separately call `appConfiguration.getConfig({ appId: 'appConfig' })` for public reads. Cached in-memory (and sessionStorage) for `ttl` so repeated calls across a page/session are cheap; pass `force` to bypass the cache after a mutation (e.g. after `entitlements-reconcile`). For admin-only data (`systemPrivate`), use `appConfiguration.getConfig({ collectionId, appId: 'appConfig', admin: true })` directly — this endpoint is public-only and never returns it. See docs/appConfig.md for the full contract. ```typescript const cfg = await appConfiguration.getAppConfig(collectionId); console.log(cfg.system?.features); ```
13670
13719
 
13671
- **isFeatureEnabled**(collectionId: string,
13672
- flag: string,
13720
+ **isFeatureEnabled**(collectionId: string,
13721
+ flag: string,
13673
13722
  options?: { force?: boolean }) → `Promise<boolean>`
13674
13723
  Check whether a feature flag is enabled for a collection, per `appConfig.system.features` — applying the `accountType` default (see `resolveFeature()`): enterprise accounts default every flag to on unless explicitly set to `false`. This is the standard way for subapps to gate features — it reads through the same cache as `getAppConfig`, so calling it repeatedly (e.g. once per component) does not re-fetch on every call. This is always async because the very first call for a collection has nothing to read yet. If you need a synchronous check (e.g. inside a render function), call this once during app init to warm the cache, then use `isFeatureEnabledSync()` afterwards. ```typescript if (await appConfiguration.isFeatureEnabled(collectionId, 'custom_domain')) { enableCustomDomainUI(); } ```
13675
13724
 
@@ -14301,13 +14350,13 @@ Delete a slot (admin; refused while places are booked).
14301
14350
 
14302
14351
  ### chat.completions
14303
14352
 
14304
- **create**(collectionId: string,
14353
+ **create**(collectionId: string,
14305
14354
  request: ChatCompletionRequest) → `Promise<ChatCompletionResponse | AsyncIterable<ChatCompletionChunk>>`
14306
14355
  Create a chat completion (streaming or non-streaming)
14307
14356
 
14308
14357
  ### chat.responses
14309
14358
 
14310
- **create**(collectionId: string,
14359
+ **create**(collectionId: string,
14311
14360
  request: ResponsesRequest) → `Promise<ResponsesResult | AsyncIterable<ResponsesStreamEvent>>`
14312
14361
  Create a Responses API request (streaming or non-streaming)
14313
14362
 
@@ -14401,6 +14450,9 @@ Record the chip a phone just programmed with this code.
14401
14450
 
14402
14451
  ### collection
14403
14452
 
14453
+ **readiness**(collectionId: string) → `Promise<CollectionReadiness>`
14454
+ What the collection's installed apps need and whether it's there (sign-in, customers, products, something to claim), in plain words, each with the screen that fixes it. Admin. Never fails on a part it can't read: that part is left out.
14455
+
14404
14456
  **get**(collectionId: string, admin?: boolean) → `Promise<CollectionResponse>`
14405
14457
  Retrieves a single Collection by its ID.
14406
14458
 
@@ -14480,86 +14532,86 @@ Invite a user to a collection by email (admin only). Creates or links their acco
14480
14532
  **getPushVapidPublicKey**(collectionId: string) → `Promise<import("../types/comms").PushVapidResponse>`
14481
14533
  Public: Get VAPID public key used for Web Push subscriptions. GET /public/collection/:collectionId/comm/push/vapidPublicKey Note: Key may be global; path is collection-scoped for consistency.
14482
14534
 
14483
- **registerPush**(collectionId: string,
14535
+ **registerPush**(collectionId: string,
14484
14536
  body: import("../types/comms") → `void`
14485
14537
  Public: Register a Web Push subscription under unified comms. POST /public/collection/:collectionId/comm/push/register
14486
14538
 
14487
- **getSettings**(collectionId: string,
14539
+ **getSettings**(collectionId: string,
14488
14540
  opts: { includeSecret?: boolean } = {}) → `Promise<import("../types/comms").CommsSettingsGetResponse>`
14489
14541
  Admin: Get current comms settings for a collection. GET /admin/collection/:collectionId/comm.settings Optional query: includeSecret=true to include unsub.secret in response.
14490
14542
 
14491
- **patchSettings**(collectionId: string,
14543
+ **patchSettings**(collectionId: string,
14492
14544
  body: import("../types/comms") → `void`
14493
14545
  Admin: Patch comms settings for a collection. PATCH /admin/collection/:collectionId/comm.settings
14494
14546
 
14495
14547
  **getPublicTopics**(collectionId: string) → `Promise<import("../types/comms").CommsPublicTopicsResponse>`
14496
14548
  Public: Fetch configured topics for a collection. GET /public/collection/:collectionId/comm/topics
14497
14549
 
14498
- **unsubscribe**(collectionId: string,
14550
+ **unsubscribe**(collectionId: string,
14499
14551
  query: import("../types/comms") → `void`
14500
14552
  Public: Unsubscribe a contact from a category or channel. GET /public/collection/:collectionId/comm/unsubscribe
14501
14553
 
14502
- **signup**(collectionId: string,
14554
+ **signup**(collectionId: string,
14503
14555
  body: import("../types/comms") → `void`
14504
14556
  Public: sign an email address up for topics (a newsletter, updates) — works signed out. Double opt-in: nothing is consented until the address's owner clicks the confirmation link SmartLinks emails them. Always answers `{ ok: true, pending: true }` (it never reveals whether the address is already known). Topics must be ones configured in the collection's comm settings. Set comm settings `signup.confirmedUrl` to send people to your own page after confirming. POST /public/collection/:collectionId/comm/signup
14505
14557
 
14506
- **upsertConsent**(collectionId: string,
14558
+ **upsertConsent**(collectionId: string,
14507
14559
  body: import("../types/comms") → `void`
14508
14560
  Public: Upsert default consent for a contact. POST /public/collection/:collectionId/comm/consent
14509
14561
 
14510
- **upsertPreferences**(collectionId: string,
14562
+ **upsertPreferences**(collectionId: string,
14511
14563
  body: import("../types/comms") → `void`
14512
14564
  Public: Upsert preferences for a specific subject (or default if subject omitted). POST /public/collection/:collectionId/comm/preferences
14513
14565
 
14514
- **subscribe**(collectionId: string,
14566
+ **subscribe**(collectionId: string,
14515
14567
  body: import("../types/comms") → `void`
14516
14568
  Public: Subscribe/unsubscribe contact to a subject. POST /public/collection/:collectionId/comm/subscribe
14517
14569
 
14518
- **checkSubscription**(collectionId: string,
14570
+ **checkSubscription**(collectionId: string,
14519
14571
  query: import("../types/comms") → `void`
14520
14572
  Public: Check subscription status for a subject. GET /public/collection/:collectionId/comm/subscription/check
14521
14573
 
14522
- **listMethods**(collectionId: string,
14574
+ **listMethods**(collectionId: string,
14523
14575
  query: import("../types/comms") → `void`
14524
14576
  Public: List registered contact methods. GET /public/collection/:collectionId/comm/methods
14525
14577
 
14526
- **registerEmail**(collectionId: string,
14578
+ **registerEmail**(collectionId: string,
14527
14579
  body: import("../types/comms") → `void`
14528
14580
  Public: Register email method for a contact. POST /public/collection/:collectionId/comm/email/register
14529
14581
 
14530
- **registerSms**(collectionId: string,
14582
+ **registerSms**(collectionId: string,
14531
14583
  body: import("../types/comms") → `void`
14532
14584
  Public: Register SMS method for a contact. POST /public/collection/:collectionId/comm/sms/register
14533
14585
 
14534
- **resolveSubscriptions**(collectionId: string,
14586
+ **resolveSubscriptions**(collectionId: string,
14535
14587
  body: import("../types/comms") → `void`
14536
14588
  Public: Resolve contacts for a subject with identity hints. POST /public/collection/:collectionId/comm/subscriptions/resolve
14537
14589
 
14538
- **queryByUser**(collectionId: string,
14590
+ **queryByUser**(collectionId: string,
14539
14591
  body: CommsQueryByUser = {}) → `Promise<CommunicationEvent[]>`
14540
14592
  Analytics: Query communication events by user or contact. POST /admin/collection/:collectionId/comm/query/by-user
14541
14593
 
14542
- **queryRecipientIds**(collectionId: string,
14594
+ **queryRecipientIds**(collectionId: string,
14543
14595
  body: CommsRecipientIdsQuery) → `Promise<RecipientId[]>`
14544
14596
  Analytics: Recipient IDs for a communication source. POST /admin/collection/:collectionId/comm/query/recipient-ids
14545
14597
 
14546
- **queryRecipientsWithoutAction**(collectionId: string,
14598
+ **queryRecipientsWithoutAction**(collectionId: string,
14547
14599
  body: CommsRecipientsWithoutActionQuery) → `Promise<RecipientId[]>`
14548
14600
  Analytics: Recipients who did not perform an action. POST /admin/collection/:collectionId/comm/query/recipients/without-action
14549
14601
 
14550
- **queryRecipientsWithAction**(collectionId: string,
14602
+ **queryRecipientsWithAction**(collectionId: string,
14551
14603
  body: CommsRecipientsWithActionQuery) → `Promise<RecipientId[] | RecipientWithOutcome[]>`
14552
14604
  Analytics: Recipients who performed an action, optionally with outcome. POST /admin/collection/:collectionId/comm/query/recipients/with-action
14553
14605
 
14554
- **sendTransactional**(collectionId: string,
14606
+ **sendTransactional**(collectionId: string,
14555
14607
  body: TransactionalSendRequest) → `Promise<TransactionalSendResult>`
14556
14608
  Send a single transactional message to one contact using a template. No broadcast record is created. The send is logged to the contact's communication history with sourceType: 'transactional'. POST /admin/collection/:collectionId/comm/send ```typescript const result = await comms.sendTransactional(collectionId, { contactId: 'e4f2a1b0-...', templateId: 'warranty-update', channel: 'preferred', props: { claimRef: 'CLM-0042', decision: 'approved' }, include: { productId: 'prod-abc123', appCase: 'c9d1e2f3-...' }, ref: 'warranty-decision-notification', appId: 'warrantyApp', }) if (result.ok) { console.log(`Sent via ${result.channel}`, result.messageId) } else { console.error('Send failed:', result.error) } ```
14557
14609
 
14558
- **logCommunicationEvent**(collectionId: string,
14610
+ **logCommunicationEvent**(collectionId: string,
14559
14611
  body: LogCommunicationEventBody) → `Promise<AppendResult>`
14560
14612
  Logging: Append a single communication event. POST /admin/collection/:collectionId/comm/log
14561
14613
 
14562
- **logBulkCommunicationEvents**(collectionId: string,
14614
+ **logBulkCommunicationEvents**(collectionId: string,
14563
14615
  body: LogBulkCommunicationEventsBody | ({ sourceId: string; ids: string[]; idField?: 'userId'|'contactId'; [k: string]: any }) → `void`
14564
14616
  Logging: Append many communication events for a list of IDs. POST /admin/collection/:collectionId/comm/log/bulk
14565
14617
 
@@ -14590,7 +14642,7 @@ Returns all proof type definitions. Proof types are templates that specify which
14590
14642
 
14591
14643
  ### contact
14592
14644
 
14593
- **query**(collectionId: string,
14645
+ **query**(collectionId: string,
14594
14646
  body: StandardQuery = {}) → `Promise<QueryResult>`
14595
14647
  The standard query on contacts (admin only): filter, sort, page, count and total in one call. POST /admin/collection/:collectionId/contacts/query Fields: contactId, userId, firstName, lastName, displayName, company, email, phone, tags, source, locale, createdAt, updatedAt. Email and phone are the contact's main one. Deleted and erased contacts are never returned. ```typescript await contact.query(collectionId, { where: { tags: { hasAny: ['vip', 'trade'] }, createdAt: { gte: '2026-01-01' } }, select: ['contactId', 'firstName', 'email'], count: true, }) await contact.query(collectionId, { groupBy: ['company'], aggregates: { people: { count: true } } }) ```
14596
14648
 
@@ -14600,62 +14652,62 @@ What a contacts query can use: its fields and what each can filter, sort, group
14600
14652
  **create**(collectionId: string, data: ContactCreateRequest) → `Promise<ContactResponse>`
14601
14653
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14602
14654
 
14603
- **list**(collectionId: string,
14655
+ **list**(collectionId: string,
14604
14656
  params?: { limit?: number; offset?: number; includeDeleted?: boolean }) → `Promise<ContactListResponse>`
14605
14657
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14606
14658
 
14607
- **search**({
14608
- collectionId,
14609
- q,
14610
- typeahead,
14611
- email,
14612
- phone,
14613
- id,
14614
- userId,
14615
- tags,
14616
- tagsAll,
14617
- source,
14618
- locale,
14619
- createdFrom,
14620
- createdTo,
14621
- externalIdKey,
14622
- externalIdValue,
14623
- customFieldKey,
14624
- customFieldValue,
14625
- limit,
14626
- offset,
14659
+ **search**({
14660
+ collectionId,
14661
+ q,
14662
+ typeahead,
14663
+ email,
14664
+ phone,
14665
+ id,
14666
+ userId,
14667
+ tags,
14668
+ tagsAll,
14669
+ source,
14670
+ locale,
14671
+ createdFrom,
14672
+ createdTo,
14673
+ externalIdKey,
14674
+ externalIdValue,
14675
+ customFieldKey,
14676
+ customFieldValue,
14677
+ limit,
14678
+ offset,
14627
14679
  }: ContactSearchParams) → `Promise<ContactSearchResponse>`
14628
14680
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14629
14681
 
14630
- **get**(collectionId: string,
14631
- contactId: string,
14682
+ **get**(collectionId: string,
14683
+ contactId: string,
14632
14684
  params?: { includeDeleted?: boolean }) → `Promise<ContactResponse>`
14633
14685
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14634
14686
 
14635
- **update**(collectionId: string,
14636
- contactId: string,
14687
+ **update**(collectionId: string,
14688
+ contactId: string,
14637
14689
  data: ContactUpdateRequest) → `Promise<ContactResponse>`
14638
14690
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14639
14691
 
14640
14692
  **remove**(collectionId: string, contactId: string) → `Promise<void>`
14641
14693
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14642
14694
 
14643
- **lookup**(collectionId: string,
14695
+ **lookup**(collectionId: string,
14644
14696
  params: { email?: string; phone?: string }) → `Promise<ContactResponse>`
14645
14697
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14646
14698
 
14647
- **upsert**(collectionId: string,
14699
+ **upsert**(collectionId: string,
14648
14700
  data: ContactCreateRequest) → `Promise<ContactResponse>`
14649
14701
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14650
14702
 
14651
- **publicUpsert**(collectionId: string,
14703
+ **publicUpsert**(collectionId: string,
14652
14704
  data: PublicContactUpsertRequest) → `Promise<PublicContactUpsertResponse>`
14653
14705
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14654
14706
 
14655
14707
  **publicGetMine**(collectionId: string) → `Promise<PublicGetMyContactResponse>`
14656
14708
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14657
14709
 
14658
- **publicUpdateMine**(collectionId: string,
14710
+ **publicUpdateMine**(collectionId: string,
14659
14711
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
14660
14712
  What a contacts query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/contacts/query
14661
14713
 
@@ -14665,77 +14717,77 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
14665
14717
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
14666
14718
  Public: Get the contact schema for a collection. GET /public/collection/:collectionId/contact/schema Returns a ContactSchemaResponse describing all publicly visible contact fields. Core fields and collection-defined custom fields are merged into a single flat schema. Fields not in `publicVisibleFields` are stripped entirely from the response. Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`. Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions` from the types package to handle conditional field visibility. ```typescript import { contact, evaluateConditions } from '@proveanything/smartlinks' const schema = await contact.publicGetSchema(collectionId) for (const fieldId of schema.fieldOrder) { const property = schema.schema.properties[fieldId] const ui = schema.uiSchema[fieldId] || {} const visible = evaluateConditions(property.conditions, property.showWhen, formValues) const disabled = ui['ui:disabled'] === true if (visible) renderField({ fieldId, property, ui, disabled }) } ```
14667
14719
 
14668
- **findDuplicates**(collectionId: string,
14720
+ **findDuplicates**(collectionId: string,
14669
14721
  params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
14670
14722
  Admin: pairs of contacts that look like one person. GET /admin/collection/:collectionId/contacts/duplicates The pattern it finds: someone the collection knew by email first (an import, a list, a form) who later signed in. Their sign-in got a second contact, which could not take the email the first one already held — so one contact has the email and no sign-in, the other the sign-in (and everything they did) and no email. The match is made on the server, on verified addresses only. Checks a window of contacts per call; while `more` is true, call again with `offset` moved on by `scanned`. ```typescript const { pairs } = await contact.findDuplicates(collectionId) for (const pair of pairs) { await contact.merge(collectionId, pair.keep.contactId, pair.merge.contactId) } ```
14671
14723
 
14672
- **merge**(collectionId: string,
14673
- keepContactId: string,
14724
+ **merge**(collectionId: string,
14725
+ keepContactId: string,
14674
14726
  fromContactId: string) → `Promise<ContactMergeResponse>`
14675
14727
  Admin: fold contact `fromContactId` INTO contact `keepContactId`. POST /admin/collection/:collectionId/contacts/:keepContactId/merge The kept contact gains the other's sign-in, emails and phones, and anything it had no value for; its own values win. Everything recorded against the other contact moves to the kept one. Consent is never loosened: an opt-out on either contact stays an opt-out. The other contact is soft-deleted and marked with `customFields.mergedInto`. Refused (HTTP 409, `error` = a `ContactMergeErrorCode`) when the two have different sign-ins (`LOGIN_CONFLICT`) or are both members of the same loyalty scheme (`LOYALTY_CONFLICT`).
14676
14728
 
14677
- **linkLogin**(collectionId: string,
14729
+ **linkLogin**(collectionId: string,
14678
14730
  userId: string) → `Promise<ContactLinkLoginResponse>`
14679
14731
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
14680
14732
 
14681
- **getUser**(collectionId: string,
14733
+ **getUser**(collectionId: string,
14682
14734
  userId: string,) → `Promise<UserSearchResponse>`
14683
14735
  Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone. POST /admin/collection/:collectionId/contacts/link-login For a service about to create a contact for a `userId`: call this first and only create when it throws 404 (`NOTHING_TO_LINK`), so a person the collection already knows by email stays one contact. The address is read from the sign-in itself and must be verified; nothing the caller says about an email is used. Never creates a contact. ```typescript let contactId: string try { contactId = (await contact.linkLogin(collectionId, userId)).contactId } catch (err) { if (err.statusCode !== 404) throw err contactId = (await contact.create(collectionId, { userId, source: 'my-service' })).contactId } ```
14684
14736
 
14685
14737
  ### containers
14686
14738
 
14687
- **create**(collectionId: string,
14739
+ **create**(collectionId: string,
14688
14740
  data: CreateContainerInput) → `Promise<Container>`
14689
14741
  Create a new container (admin). ```typescript const cask = await containers.create('coll_123', { containerType: 'cask', ref: 'CASK-0042', name: 'Cask 42 — Single Malt', metadata: { distilleryYear: 2019, capacity: 200 }, }) ```
14690
14742
 
14691
- **list**(collectionId: string,
14743
+ **list**(collectionId: string,
14692
14744
  params?: ListContainersParams) → `Promise<ListContainersResponse>`
14693
14745
  List containers (admin). Supports filtering by type, status, ref, parent, and top-level flag. ```typescript // All active pallets const { containers: pallets } = await containers.list('coll_123', { containerType: 'pallet', status: 'active', limit: 50, }) // Top-level containers only const { containers: roots } = await containers.list('coll_123', { topLevel: true }) ```
14694
14746
 
14695
- **findForItem**(collectionId: string,
14747
+ **findForItem**(collectionId: string,
14696
14748
  params: FindContainersForItemParams) → `Promise<FindContainersForItemResponse>`
14697
14749
  Reverse lookup — find all containers currently holding a specific item (admin). ```typescript const { containers: holding } = await containers.findForItem('coll_123', { itemType: 'proof', itemId: 'unit-0007', productId: 'drill', }) ```
14698
14750
 
14699
- **get**(collectionId: string,
14700
- containerId: string,
14751
+ **get**(collectionId: string,
14752
+ containerId: string,
14701
14753
  params?: GetContainerParams) → `Promise<Container>`
14702
14754
  Get a single container by ID (admin). Pass `?tree=true` to recursively embed children, and/or `?includeContents=true` to embed the current item list. ```typescript // Flat const cask = await containers.get('coll_123', 'cask-uuid') // Full tree with contents const tree = await containers.get('coll_123', 'warehouse-uuid', { tree: true, treeDepth: 3, includeContents: true, }) ```
14703
14755
 
14704
- **update**(collectionId: string,
14705
- containerId: string,
14756
+ **update**(collectionId: string,
14757
+ containerId: string,
14706
14758
  data: UpdateContainerInput) → `Promise<Container>`
14707
14759
  Partially update a container (admin). Only fields present in the request body are modified. Pass `parentContainerId: null` to promote a container to top-level. ```typescript const updated = await containers.update('coll_123', 'cask-uuid', { status: 'archived', metadata: { bottledAt: '2025-04-01' }, }) ```
14708
14760
 
14709
- **remove**(collectionId: string,
14761
+ **remove**(collectionId: string,
14710
14762
  containerId: string) → `Promise<`
14711
14763
  Soft-delete a container (admin). Sets `deletedAt`; the record and its full item history remain queryable by admins. Public API responses automatically exclude deleted containers.
14712
14764
 
14713
- **listItems**(collectionId: string,
14714
- containerId: string,
14765
+ **listItems**(collectionId: string,
14766
+ containerId: string,
14715
14767
  params?: ListContainerItemsParams) → `Promise<ContainerItemsResponse>`
14716
14768
  List items currently (or historically) inside a container (admin). Pass `history: true` to include removed items and see the full membership log. ```typescript // Current contents const { items } = await containers.listItems('coll_123', 'cask-uuid') // Full history including removed items const { items: history } = await containers.listItems('coll_123', 'cask-uuid', { history: true }) ```
14717
14769
 
14718
- **addItems**(collectionId: string,
14719
- containerId: string,
14770
+ **addItems**(collectionId: string,
14771
+ containerId: string,
14720
14772
  data: AddContainerItemsInput) → `Promise<AddContainerItemsResponse>`
14721
14773
  Add one or more items to a container (admin). Each item requires `itemType` and `itemId`. Pass `productId` / `proofId` for denormalisation convenience. ```typescript const { items } = await containers.addItems('coll_123', 'pallet-uuid', { items: [ { itemType: 'tag', itemId: 'NFC-00AABBCC' }, { itemType: 'proof', itemId: 'proof-uuid', productId: 'product-id' }, ], }) ```
14722
14774
 
14723
- **removeItems**(collectionId: string,
14724
- containerId: string,
14775
+ **removeItems**(collectionId: string,
14776
+ containerId: string,
14725
14777
  data: RemoveContainerItemsInput) → `Promise<RemoveContainerItemsResponse>`
14726
14778
  Soft-remove items from a container (admin). Sets `removedAt` on the specified `ContainerItem` records. The records are retained in the history log and can be queried with `history: true`. ```typescript const result = await containers.removeItems('coll_123', 'pallet-uuid', { ids: ['container-item-uuid-1', 'container-item-uuid-2'], }) console.log(`Removed ${result.removedCount} items`) ```
14727
14779
 
14728
- **publicList**(collectionId: string,
14780
+ **publicList**(collectionId: string,
14729
14781
  params?: ListContainersParams) → `Promise<PublicListContainersResponse>`
14730
14782
  List containers (public). Soft-deleted containers and containers with `metadata.publicListing === false` are excluded from results.
14731
14783
 
14732
- **publicGet**(collectionId: string,
14733
- containerId: string,
14784
+ **publicGet**(collectionId: string,
14785
+ containerId: string,
14734
14786
  params?: GetContainerParams) → `Promise<Container>`
14735
14787
  Get a single container (public). Soft-deleted containers return a 404. Same `?tree` and `?includeContents` options as the admin version.
14736
14788
 
14737
- **publicListItems**(collectionId: string,
14738
- containerId: string,
14789
+ **publicListItems**(collectionId: string,
14790
+ containerId: string,
14739
14791
  params?: Pick<ListContainerItemsParams, 'limit' | 'offset'>) → `Promise<ContainerItemsResponse>`
14740
14792
  List current contents of a container (public). Returns only items where `removedAt` is null. No `?history` option on the public side.
14741
14793
 
@@ -14958,8 +15010,8 @@ Update whitelisted fields. PUT /integrations/flows/:id
14958
15010
  **deleteFlow**(collectionId: string, id: string) → `Promise<`
14959
15011
  Soft-delete a flow. DELETE /integrations/flows/:id
14960
15012
 
14961
- **runFlow**(collectionId: string,
14962
- id: string,
15013
+ **runFlow**(collectionId: string,
15014
+ id: string,
14963
15015
  options: RunFlowInput & { async?: boolean } = {}) → `Promise<RunFlowResult>`
14964
15016
  Run a flow now. POST /integrations/flows/:id/run - inline (default): resolves and returns the run summary. - options.async: enqueue on the worker, returns { enqueued: true }. Pass options.entityId to run for a single source entity.
14965
15017
 
@@ -14987,8 +15039,8 @@ Is enhanced logging active for a connection? GET /integrations/logging/:connecti
14987
15039
  **setLogging**(collectionId: string, connectionId: string, input: SetLoggingInput = {}) → `Promise<`
14988
15040
  Enable enhanced logging. POST /integrations/logging/:connectionId (omit ttlMinutes = until cancelled)
14989
15041
 
14990
- **listFailed**(collectionId: string,
14991
- flowId: string,
15042
+ **listFailed**(collectionId: string,
15043
+ flowId: string,
14992
15044
  query: { status?: 'failed' | 'dead'; limit?: number; cursor?: string } = {}) → `Promise<FailedRecordList>`
14993
15045
  A flow's failed / dead records. GET /integrations/flows/:id/failed
14994
15046
 
@@ -15013,30 +15065,30 @@ Cancel enhanced logging now. DELETE /integrations/logging/:connectionId
15013
15065
  **listConnectors**(collectionId: string) → `Promise<`
15014
15066
  The collection's installed connector apps. GET /integrations/connectors
15015
15067
 
15016
- **saveConnectorInstallation**(collectionId: string,
15017
- appId: string,
15068
+ **saveConnectorInstallation**(collectionId: string,
15069
+ appId: string,
15018
15070
  input: SaveConnectorInstallationInput) → `Promise<`
15019
15071
  Save a connector's non-secret Connect-form values and/or settings. PUT /integrations/connectors/:appId/installation
15020
15072
 
15021
- **runConnectorStep**(collectionId: string,
15022
- appId: string,
15023
- step: ConnectorConsoleStep,
15073
+ **runConnectorStep**(collectionId: string,
15074
+ appId: string,
15075
+ step: ConnectorConsoleStep,
15024
15076
  input: Record<string, unknown> & { flowId?: string } = {}) → `Promise<T>`
15025
15077
  Run a connector step from the console: `testConnection` → ConnectorTestResult, `describeTarget` → ConnectorTargetSchema, `sample` → ConnectorRecords, and dry runs of `shape` ({ records }) → ConnectorShapeResult and `serialize` ({ documents }) → ConnectorSerializeResult. The server adds the installation; pass `flowId` to layer that flow's settings. POST /integrations/connectors/:appId/steps/:step
15026
15078
 
15027
- **runConnectorAction**(collectionId: string,
15028
- appId: string,
15029
- action: string,
15079
+ **runConnectorAction**(collectionId: string,
15080
+ appId: string,
15081
+ action: string,
15030
15082
  input: Record<string, unknown> = {}) → `Promise<T>`
15031
15083
  Invoke a connector ACTION from the console (any visibility): redeem, enrol, adjust points, issue a coupon… The connector's function runs with its own credentials and is told who asked. POST /integrations/connectors/:appId/actions/:action { input }
15032
15084
 
15033
- **listConnectorActions**(collectionId: string,
15085
+ **listConnectorActions**(collectionId: string,
15034
15086
  appId: string) → `Promise<`
15035
15087
  PUBLIC (the Hub, a site): the connector actions the caller may invoke — those declared `public`, plus `member` ones when signed in. GET /public/collection/:collectionId/connectors/:appId/actions
15036
15088
 
15037
- **callConnectorAction**(collectionId: string,
15038
- appId: string,
15039
- action: string,
15089
+ **callConnectorAction**(collectionId: string,
15090
+ appId: string,
15091
+ action: string,
15040
15092
  input: Record<string, unknown> = {}) → `Promise<T>`
15041
15093
  PUBLIC (the Hub, a site): invoke a connector action — e.g. redeem a reward for the signed-in member. 401 SIGN_IN_REQUIRED for a `member` action without a session; 403 for an admin-only one; 400 with `missing[]` when a required input is absent. POST /public/collection/:collectionId/connectors/:appId/actions/:action { input }
15042
15094
 
@@ -15159,6 +15211,50 @@ POST /admin/collection/:collectionId/journeys.analytics/:journeyId/steps/:stepId
15159
15211
  body: JourneyFunnelReportRequest) → `Promise<JourneyFunnelReportResponse>`
15160
15212
  POST /admin/collection/:collectionId/journeys.analytics/:journeyId/funnel-report Computes conversion, counts, and avg time across mapped steps in a period.
15161
15213
 
15214
+ ### knowledge
15215
+
15216
+ **listSets**(collectionId: string) → `Promise<KnowledgeSet[]>`
15217
+ Every set, with its source and passage counts (admin).
15218
+
15219
+ **saveSet**(collectionId: string, body: SaveKnowledgeSetRequest) → `Promise<KnowledgeSet>`
15220
+ Create a set, or update the one with this key (admin).
15221
+
15222
+ **getSet**(collectionId: string, set: string) → `Promise<KnowledgeSet>`
15223
+ One set, by id or key (admin).
15224
+
15225
+ **updateSet**(collectionId: string, set: string, body: UpdateKnowledgeSetRequest) → `Promise<KnowledgeSet>`
15226
+ One set, by id or key (admin).
15227
+
15228
+ **deleteSet**(collectionId: string, set: string) → `Promise<`
15229
+ Delete a set with its sources and passages (admin).
15230
+
15231
+ **listSources**(collectionId: string, set: string) → `Promise<KnowledgeSource[]>`
15232
+ A set's sources, with their status (admin).
15233
+
15234
+ **addSource**(collectionId: string, set: string, body: AddKnowledgeSourceRequest) → `Promise<KnowledgeSource>`
15235
+ Add a source; feeds and pages are read in the background (admin).
15236
+
15237
+ **updateSource**(collectionId: string, sourceId: string, body: UpdateKnowledgeSourceRequest) → `Promise<KnowledgeSource>`
15238
+ Add a source; feeds and pages are read in the background (admin).
15239
+
15240
+ **deleteSource**(collectionId: string, sourceId: string) → `Promise<`
15241
+ Add a source; feeds and pages are read in the background (admin).
15242
+
15243
+ **reindex**(collectionId: string, sourceId: string, opts: { force?: boolean } = {}) → `Promise<`
15244
+ Read a source again now (`force` re-splits even if it hasn't changed) (admin).
15245
+
15246
+ **upsertDocuments**(collectionId: string, sourceId: string, documents: KnowledgeDocument[]) → `Promise<`
15247
+ Push documents into a `documents` source; the same `ref` replaces its earlier version. Up to 500 at a time (admin).
15248
+
15249
+ **removeDocuments**(collectionId: string, sourceId: string, refs: string[]) → `Promise<`
15250
+ Remove pushed documents by `ref` (admin).
15251
+
15252
+ **search**(collectionId: string, body: KnowledgeSearchRequest) → `Promise<KnowledgeSearchResponse>`
15253
+ Search every set, staff ones included (admin).
15254
+
15255
+ **publicSearch**(collectionId: string, body: KnowledgeSearchRequest) → `Promise<KnowledgeSearchResponse>`
15256
+ Search from a website, Portal or Hub: public sets, plus customer sets for a signed-in person.
15257
+
15162
15258
  ### location
15163
15259
 
15164
15260
  **createGlobal**(params: LocationPayload) → `Promise<Location>`
@@ -15226,82 +15322,82 @@ Paginated member product summaries.
15226
15322
 
15227
15323
  Loyalty programmes built on top of collections. Configure schemes and earning rules; contacts earn points automatically via interaction events. See the [Loyalty guide](loyalty.md) for the full walkthrough.
15228
15324
 
15229
- **list**(collectionId: string,
15325
+ **list**(collectionId: string,
15230
15326
  params: { includeDeleted?: boolean } = {}) → `Promise<LoyaltyScheme[]>`
15231
15327
 
15232
- **get**(collectionId: string,
15328
+ **get**(collectionId: string,
15233
15329
  schemeId: string) → `Promise<LoyaltyScheme>`
15234
15330
 
15235
- **create**(collectionId: string,
15331
+ **create**(collectionId: string,
15236
15332
  body: CreateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
15237
15333
 
15238
- **update**(collectionId: string,
15239
- schemeId: string,
15334
+ **update**(collectionId: string,
15335
+ schemeId: string,
15240
15336
  body: UpdateLoyaltySchemeBody) → `Promise<LoyaltyScheme>`
15241
15337
 
15242
- **remove**(collectionId: string,
15338
+ **remove**(collectionId: string,
15243
15339
  schemeId: string) → `Promise<LoyaltyScheme>`
15244
15340
 
15245
- **listEarningRules**(collectionId: string,
15341
+ **listEarningRules**(collectionId: string,
15246
15342
  schemeId: string) → `Promise<LoyaltyEarningRule[]>`
15247
15343
 
15248
- **getEarningRule**(collectionId: string,
15249
- schemeId: string,
15344
+ **getEarningRule**(collectionId: string,
15345
+ schemeId: string,
15250
15346
  ruleId: string) → `Promise<LoyaltyEarningRule>`
15251
15347
 
15252
- **createEarningRule**(collectionId: string,
15253
- schemeId: string,
15348
+ **createEarningRule**(collectionId: string,
15349
+ schemeId: string,
15254
15350
  body: CreateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
15255
15351
 
15256
- **updateEarningRule**(collectionId: string,
15257
- schemeId: string,
15258
- ruleId: string,
15352
+ **updateEarningRule**(collectionId: string,
15353
+ schemeId: string,
15354
+ ruleId: string,
15259
15355
  body: UpdateLoyaltyEarningRuleBody) → `Promise<LoyaltyEarningRule>`
15260
15356
 
15261
- **removeEarningRule**(collectionId: string,
15262
- schemeId: string,
15357
+ **removeEarningRule**(collectionId: string,
15358
+ schemeId: string,
15263
15359
  ruleId: string) → `Promise<LoyaltyEarningRule>`
15264
15360
 
15265
- **listMembers**(collectionId: string,
15266
- schemeId: string,
15361
+ **listMembers**(collectionId: string,
15362
+ schemeId: string,
15267
15363
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyMember>>`
15268
15364
 
15269
- **getMember**(collectionId: string,
15270
- schemeId: string,
15365
+ **getMember**(collectionId: string,
15366
+ schemeId: string,
15271
15367
  contactId: string) → `Promise<LoyaltyMember>`
15272
15368
 
15273
- **recordTransaction**(collectionId: string,
15274
- schemeId: string,
15275
- contactId: string,
15369
+ **recordTransaction**(collectionId: string,
15370
+ schemeId: string,
15371
+ contactId: string,
15276
15372
  body: RecordLoyaltyTransactionBody) → `Promise<LoyaltyTransactionResult>`
15277
15373
  Manually award or deduct points for a contact. - `points` must be a non-zero integer - Positive = award, negative = deduct - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE` - Supply `idempotencyKey` to safely retry without double-crediting Points earned via interaction events are awarded automatically by the server — this endpoint is for manual adjustments and admin overrides.
15278
15374
 
15279
- **getMemberHistory**(collectionId: string,
15280
- schemeId: string,
15281
- contactId: string,
15375
+ **getMemberHistory**(collectionId: string,
15376
+ schemeId: string,
15377
+ contactId: string,
15282
15378
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>`
15283
15379
  Manually award or deduct points for a contact. - `points` must be a non-zero integer - Positive = award, negative = deduct - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE` - Supply `idempotencyKey` to safely retry without double-crediting Points earned via interaction events are awarded automatically by the server — this endpoint is for manual adjustments and admin overrides.
15284
15380
 
15285
15381
  **publicList**(collectionId: string) → `Promise<LoyaltyScheme[]>`
15286
15382
  List active schemes for a collection. No authentication required.
15287
15383
 
15288
- **publicGet**(collectionId: string,
15384
+ **publicGet**(collectionId: string,
15289
15385
  schemeId: string) → `Promise<LoyaltyScheme>`
15290
15386
  Get a single active scheme. No authentication required.
15291
15387
 
15292
- **publicListEarningRules**(collectionId: string,
15388
+ **publicListEarningRules**(collectionId: string,
15293
15389
  schemeId: string) → `Promise<LoyaltyEarningRule[]>`
15294
15390
  List active earning rules for a scheme — useful for showing "how to earn" in a loyalty UI. No authentication required.
15295
15391
 
15296
15392
  **publicGetMe**(collectionId: string) → `Promise<LoyaltySchemeWithMembership[]>`
15297
15393
  Get all active schemes with the caller's membership embedded in each. This is the primary entry point for a loyalty widget — one call gives you everything needed to render a user's loyalty status across all programs in a collection. - Authenticated: `member` is populated with balance + lifetimePoints (or null if not yet enrolled in that scheme) - Unauthenticated: `member` is null on all schemes
15298
15394
 
15299
- **publicGetMine**(collectionId: string,
15395
+ **publicGetMine**(collectionId: string,
15300
15396
  schemeId: string) → `Promise<LoyaltyMember>`
15301
15397
  Get the authenticated caller's membership (balance + lifetimePoints) on a specific scheme. Requires authentication.
15302
15398
 
15303
- **publicGetMineHistory**(collectionId: string,
15304
- schemeId: string,
15399
+ **publicGetMineHistory**(collectionId: string,
15400
+ schemeId: string,
15305
15401
  params: LoyaltyPaginationParams = {}) → `Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>`
15306
15402
  Get the authenticated caller's transaction history on a specific scheme. Ordered newest first. Requires authentication.
15307
15403
 
@@ -15339,98 +15435,98 @@ What the server offers, by group: `{ workOrders: [...], stock: [...], boms: [...
15339
15435
 
15340
15436
  ### order
15341
15437
 
15342
- **create**(collectionId: string,
15438
+ **create**(collectionId: string,
15343
15439
  data: CreateOrderRequest) → `Promise<CreateOrderResponse>`
15344
15440
  Create a new order with items. ```typescript const order = await order.create('coll_123', { orderRef: 'ORD-12345', customerId: 'CUST-789', items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'tag', itemId: 'TAG002' }, { itemType: 'serial', itemId: 'SN12345' } ], status: 'pending', metadata: { shipmentId: 'SHIP-789', destination: 'Warehouse B' } }) ```
15345
15441
 
15346
- **get**(collectionId: string,
15347
- orderId: string,
15442
+ **get**(collectionId: string,
15443
+ orderId: string,
15348
15444
  params?: GetOrderParams) → `Promise<GetOrderResponse>`
15349
15445
  Get a single order by ID. ```typescript // Get order without items (faster) const order = await order.get('coll_123', 'order_abc123') console.log(`Order has ${order.itemCount} items`) // Get order with items const orderWithItems = await order.get('coll_123', 'order_abc123', { includeItems: true }) console.log(orderWithItems.items) // Items array available ```
15350
15446
 
15351
- **update**(collectionId: string,
15352
- orderId: string,
15447
+ **update**(collectionId: string,
15448
+ orderId: string,
15353
15449
  data: UpdateOrderRequest) → `Promise<UpdateOrderResponse>`
15354
15450
  Update order status or metadata. Items are managed separately via addItems/removeItems. ```typescript const updated = await order.update('coll_123', 'order_abc123', { status: 'shipped', metadata: { trackingNumber: '1Z999AA10123456784', shippedAt: '2026-02-02T14:30:00Z' } }) ```
15355
15451
 
15356
- **remove**(collectionId: string,
15452
+ **remove**(collectionId: string,
15357
15453
  orderId: string) → `Promise<DeleteOrderResponse>`
15358
15454
  Delete an order and all its items (cascade delete). ```typescript await order.remove('coll_123', 'order_abc123') ```
15359
15455
 
15360
- **list**(collectionId: string,
15456
+ **list**(collectionId: string,
15361
15457
  params?: ListOrdersRequest) → `Promise<ListOrdersResponse>`
15362
15458
  List orders for a collection with optional filters and pagination. Orders are returned in descending order by createdAt (newest first). ```typescript // List all orders (without items for better performance) const all = await order.list('coll_123') // List with filters const pending = await order.list('coll_123', { status: 'pending', limit: 50, offset: 0 }) // Filter by customer with items const customerOrders = await order.list('coll_123', { customerId: 'CUST-789', includeItems: true }) ```
15363
15459
 
15364
- **getItems**(collectionId: string,
15365
- orderId: string,
15460
+ **getItems**(collectionId: string,
15461
+ orderId: string,
15366
15462
  params?: GetOrderItemsParams) → `Promise<GetOrderItemsResponse>`
15367
15463
  Get items from an order with pagination support. Use this for orders with many items instead of includeItems. ```typescript // Get first page of items const page1 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 0 }) // Get next page const page2 = await order.getItems('coll_123', 'order_abc123', { limit: 100, offset: 100 }) ```
15368
15464
 
15369
- **addItems**(collectionId: string,
15370
- orderId: string,
15465
+ **addItems**(collectionId: string,
15466
+ orderId: string,
15371
15467
  data: AddItemsRequest) → `Promise<AddItemsResponse>`
15372
15468
  Add additional items to an existing order. ```typescript const updated = await order.addItems('coll_123', 'order_abc123', { items: [ { itemType: 'tag', itemId: 'TAG003' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) console.log(`Order now has ${updated.itemCount} items`) ```
15373
15469
 
15374
15470
  **lineDone**(collectionId: string, orderId: string, itemId: string, by: number) → `Promise<OrderItem>`
15375
15471
  Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
15376
15472
 
15377
- **removeItems**(collectionId: string,
15378
- orderId: string,
15473
+ **removeItems**(collectionId: string,
15474
+ orderId: string,
15379
15475
  data: RemoveItemsRequest) → `Promise<RemoveItemsResponse>`
15380
15476
  Add to (or take from) how much of a line has been shipped or received. Atomic, so two receipts at once both count; it can't go below zero. ```typescript // 20 more caps arrived against a purchase order line await order.lineDone('coll_123', orderId, lineId, 20) ```
15381
15477
 
15382
- **lookup**(collectionId: string,
15478
+ **lookup**(collectionId: string,
15383
15479
  data: LookupOrdersRequest) → `Promise<LookupOrdersResponse>`
15384
15480
  Find all orders containing specific items (tags, proofs, or serial numbers). Use case: Scan a tag and immediately see if it's part of any order. ```typescript // Scan a tag and find associated orders const result = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' } ] }) if (result.orders.length > 0) { console.log(`Tag is part of ${result.orders.length} order(s)`) result.orders.forEach(ord => { console.log(`Order ${ord.orderRef}: ${ord.status}`) }) } // Batch lookup multiple items const batchResult = await order.lookup('coll_123', { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' }, { itemType: 'proof', itemId: 'proof_xyz' } ] }) ```
15385
15481
 
15386
- **query**(collectionId: string,
15482
+ **query**(collectionId: string,
15387
15483
  data: QueryOrdersRequest) → `Promise<QueryOrdersResponse>`
15388
15484
  Advanced query for orders with order-level and item-level filtering. More powerful than the basic list() function. ```typescript // Find pending orders created in January 2026 const result = await order.query('coll_123', { query: { status: 'pending', createdAfter: '2026-01-01T00:00:00Z', createdBefore: '2026-02-01T00:00:00Z', sortBy: 'createdAt', sortOrder: 'desc' }, limit: 50 }) // Find orders with specific metadata and item count const highPriority = await order.query('coll_123', { query: { metadata: { priority: 'high' }, minItemCount: 10, maxItemCount: 100 }, includeItems: true }) // Find orders containing a specific product batch const batchOrders = await order.query('coll_123', { query: { productId: 'prod_789', batchId: 'BATCH-2024-001' }, includeItems: true }) // Find an order containing one of several specific items const matched = await order.query('coll_123', { query: { items: [ { itemType: 'tag', itemId: 'TAG001' }, { itemType: 'serial', itemId: 'SN12345' } ] }, includeItems: true }) ```
15389
15485
 
15390
- **reports**(collectionId: string,
15486
+ **reports**(collectionId: string,
15391
15487
  params?: ReportsParams) → `Promise<ReportsResponse>`
15392
15488
  Get reports and aggregations for orders. Provides analytics grouped by status, customer, product, date, etc. ```typescript // Get order counts by status const statusReport = await order.reports('coll_123', { groupByStatus: true }) console.log(statusReport.ordersByStatus) // { pending: 45, shipped: 123, completed: 789 } // Get comprehensive analytics const fullReport = await order.reports('coll_123', { groupByStatus: true, groupByProduct: true, includeItemStats: true, createdAfter: '2026-01-01T00:00:00Z' }) console.log(fullReport.itemStats?.avgItemsPerOrder) // Get top 10 customers by order count const topCustomers = await order.reports('coll_123', { groupByCustomer: true, topN: 10 }) ```
15393
15489
 
15394
- **findByProduct**(collectionId: string,
15395
- productId: string,
15490
+ **findByProduct**(collectionId: string,
15491
+ productId: string,
15396
15492
  params?: LookupByProductParams) → `Promise<LookupByProductResponse>`
15397
15493
  Find all orders containing items with a specific product ID. Uses the automatic productSummary tracking in order metadata. ```typescript // Find all orders with a specific product const result = await order.findByProduct('coll_123', 'product_abc123', { limit: 50, includeItems: false }) result.orders.forEach(ord => { const count = ord.metadata.productSummary?.['product_abc123'] ?? 0 console.log(`Order ${ord.orderRef} has ${count} items of this product`) }) ```
15398
15494
 
15399
- **getAnalytics**(collectionId: string,
15495
+ **getAnalytics**(collectionId: string,
15400
15496
  orderId: string) → `Promise<OrderAnalyticsResponse>`
15401
15497
  Get comprehensive scan analytics for all tags in an order. Returns scan counts, timestamps, locations, devices, and per-tag summaries. ```typescript const analytics = await order.getAnalytics('coll_123', 'order_abc123') if (analytics.analytics) { console.log(`Total scans: ${analytics.analytics.totalScans}`) console.log(`Admin scans: ${analytics.analytics.adminScans}`) console.log(`Created at: ${analytics.analytics.estimatedCreatedAt}`) console.log(`Unique locations: ${analytics.analytics.uniqueLocations}`) analytics.analytics.tagSummaries.forEach(tag => { console.log(`Tag ${tag.tagId}: ${tag.totalScans} scans`) }) } ```
15402
15498
 
15403
- **getTimeline**(collectionId: string,
15404
- orderId: string,
15499
+ **getTimeline**(collectionId: string,
15500
+ orderId: string,
15405
15501
  params?: TimelineRequest) → `Promise<TimelineResponse>`
15406
15502
  Get chronological timeline of all scan events for an order's tags. Supports filtering by date range and admin/customer scans. ```typescript // Get all scan events const timeline = await order.getTimeline('coll_123', 'order_abc123') timeline.timeline.forEach(event => { console.log(`${event.timestamp}: ${event.eventType} by ${event.isAdmin ? 'admin' : 'customer'}`) }) // Get admin scans only from last week const adminScans = await order.getTimeline('coll_123', 'order_abc123', { isAdmin: true, from: '2026-02-01T00:00:00Z', limit: 500 }) ```
15407
15503
 
15408
- **getLocationHistory**(collectionId: string,
15409
- orderId: string,
15504
+ **getLocationHistory**(collectionId: string,
15505
+ orderId: string,
15410
15506
  params?: LocationRequest) → `Promise<LocationResponse>`
15411
15507
  Get location-based scan history for an order's tags. Shows where the order's tags have been scanned. ```typescript const locations = await order.getLocationHistory('coll_123', 'order_abc123', { limit: 100 }) console.log(`Order scanned in ${locations.count} locations`) locations.locations.forEach(scan => { console.log(`${scan.location} at ${scan.timestamp}`) }) ```
15412
15508
 
15413
- **getBulkAnalytics**(collectionId: string,
15509
+ **getBulkAnalytics**(collectionId: string,
15414
15510
  data: BulkAnalyticsRequest) → `Promise<BulkAnalyticsResponse>`
15415
15511
  Get analytics summary for multiple orders at once. Efficient way to retrieve scan data for many orders. ```typescript const bulk = await order.getBulkAnalytics('coll_123', { orderIds: ['order_1', 'order_2', 'order_3'], from: '2026-01-01T00:00:00Z' }) bulk.results.forEach(result => { if (result.analytics) { console.log(`${result.orderRef}: ${result.analytics.totalScans} scans`) } }) ```
15416
15512
 
15417
- **getCollectionSummary**(collectionId: string,
15513
+ **getCollectionSummary**(collectionId: string,
15418
15514
  params?: SummaryRequest) → `Promise<CollectionSummaryResponse>`
15419
15515
  Get collection-wide analytics summary across all orders. Returns daily scan counts and admin activity overview. ```typescript // Get all-time collection summary const summary = await order.getCollectionSummary('coll_123') console.log(`Admin activity count: ${summary.adminActivity.count}`) console.log('Scans by day:') summary.scansByDay.forEach(day => { console.log(` ${day.date}: ${day.scanCount} scans`) }) // Get summary for last 30 days const recentSummary = await order.getCollectionSummary('coll_123', { from: '2026-01-08T00:00:00Z', to: '2026-02-08T00:00:00Z' }) ```
15420
15516
 
15421
- **findOrdersByProduct**(collectionId: string,
15422
- productId: string,
15517
+ **findOrdersByProduct**(collectionId: string,
15518
+ productId: string,
15423
15519
  params?: FindOrdersByAttributeParams) → `Promise<FindOrdersByAttributeResponse>`
15424
15520
  Find all orders containing items from a specific product. Uses indexed queries for fast lookups across order items. ```typescript // Find all orders containing a product const { orders, limit, offset } = await order.findOrdersByProduct('coll_123', 'prod_789', { limit: 100 }) console.log(`Product appears in ${orders.length} orders`) ```
15425
15521
 
15426
- **findItemsByProduct**(collectionId: string,
15427
- productId: string,
15522
+ **findItemsByProduct**(collectionId: string,
15523
+ productId: string,
15428
15524
  params?: FindItemsByAttributeParams) → `Promise<FindItemsByAttributeResponse>`
15429
15525
  Get individual order items for a specific product. Returns all matching items with optional order summary. ```typescript // Get all items for a product const { items } = await order.findItemsByProduct('coll_123', 'prod_789', { includeOrder: true }) console.log(`Product delivered in ${items.length} order items`) ```
15430
15526
 
15431
- **getOrderIdsByAttribute**(collectionId: string,
15432
- attribute: 'productId',
15433
- value: string,
15527
+ **getOrderIdsByAttribute**(collectionId: string,
15528
+ attribute: 'productId',
15529
+ value: string,
15434
15530
  params?: GetOrderIdsParams) → `Promise<GetOrderIdsResponse>`
15435
15531
  Get unique order IDs containing items for a specific product. Lightweight query that only returns order IDs, not full order objects. ```typescript // Get order IDs for a product const productOrders = await order.getOrderIdsByAttribute( 'coll_123', 'productId', 'prod_789', { limit: 500 } ) ```
15436
15532
 
@@ -15464,7 +15560,7 @@ Move items (by membership), chips without an item (by membership) or containers
15464
15560
 
15465
15561
  ### podcast
15466
15562
 
15467
- **generate**(collectionId: string,
15563
+ **generate**(collectionId: string,
15468
15564
  request: GeneratePodcastRequest) → `Promise<GeneratePodcastResponse>`
15469
15565
  Generate a NotebookLM-style conversational podcast from product documents
15470
15566
 
@@ -15473,282 +15569,278 @@ Get podcast generation status
15473
15569
 
15474
15570
  ### product
15475
15571
 
15476
- **get**(collectionId: string,
15477
- productId: string,
15572
+ **get**(collectionId: string,
15573
+ productId: string,
15478
15574
  admin?: boolean) → `Promise<ProductResponse>`
15479
15575
  Retrieves a single Product Item by Collection ID and Product ID.
15480
15576
 
15481
- **list**(collectionId: string,
15577
+ **list**(collectionId: string,
15482
15578
  admin?: boolean) → `Promise<ProductResponse[]>`
15483
15579
  List all Product Items for a Collection.
15484
15580
 
15485
- **create**(collectionId: string,
15581
+ **create**(collectionId: string,
15486
15582
  data: ProductCreateRequest) → `Promise<ProductResponse>`
15487
15583
  Create a new product for a collection (admin only). The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`. **Hero Image Auto-Fetch:** You can pass `heroImage` as either: - A full asset object: `{ url: '...', thumbnails: {...} }` - A string URL: The system automatically fetches and stores the image ```typescript // Using a URL - auto-fetched and stored const product = await product.create(collectionId, { name: 'Wine Bottle', description: 'Premium red wine', heroImage: 'https://example.com/wine.jpg', // Auto-fetched! data: {} }); ```
15488
15584
 
15489
- **update**(collectionId: string,
15490
- productId: string,
15585
+ **update**(collectionId: string,
15586
+ productId: string,
15491
15587
  data: ProductUpdateRequest) → `Promise<ProductResponse>`
15492
15588
  Update a product for a collection (admin only). The `data` payload is a partial of ProductResponse minus `id` and `collectionId`. **Hero Image Auto-Fetch:** You can pass `heroImage` as either: - A full asset object: `{ url: '...', thumbnails: {...} }` - A string URL: The system automatically fetches and stores the image ```typescript // Update with new URL - auto-fetched and stored const product = await product.update(collectionId, productId, { heroImage: 'https://example.com/new-wine.jpg' // Auto-fetched! }); ```
15493
15589
 
15494
- **remove**(collectionId: string,
15590
+ **remove**(collectionId: string,
15495
15591
  productId: string) → `Promise<void>`
15496
15592
  Delete a product for a collection (admin only).
15497
15593
 
15498
- **find**(collectionId: string,
15594
+ **find**(collectionId: string,
15499
15595
  body: ProductQueryRequest) → `Promise<ProductQueryResponse>`
15500
15596
 
15501
- **publicFind**(collectionId: string,
15597
+ **publicFind**(collectionId: string,
15502
15598
  params?: ProductPublicFindParams) → `Promise<ProductResponse[]>`
15503
15599
 
15504
- **clone**(collectionId: string,
15505
- productId: string,
15600
+ **clone**(collectionId: string,
15601
+ productId: string,
15506
15602
  body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
15507
15603
 
15508
- **listAssets**(collectionId: string,
15509
- productId: string,
15604
+ **listAssets**(collectionId: string,
15605
+ productId: string,
15510
15606
  admin?: boolean) → `Promise<unknown>`
15511
15607
 
15512
- **createClaimWindow**(collectionId: string,
15513
- productId: string,
15608
+ **createClaimWindow**(collectionId: string,
15609
+ productId: string,
15514
15610
  body: Record<string, JsonValue>) → `Promise<unknown>`
15515
15611
 
15516
- **updateClaimWindow**(collectionId: string,
15517
- productId: string,
15518
- claimId: string,
15612
+ **updateClaimWindow**(collectionId: string,
15613
+ productId: string,
15614
+ claimId: string,
15519
15615
  body: Record<string, JsonValue>) → `Promise<unknown>`
15520
15616
 
15521
- **refresh**(collectionId: string,
15617
+ **refresh**(collectionId: string,
15522
15618
  productId: string) → `Promise<ProductResponse>`
15523
15619
 
15524
- **getSN**(collectionId: string,
15525
- productId: string,
15526
- startIndex: number = 0,
15620
+ **getSN**(collectionId: string,
15621
+ productId: string,
15622
+ startIndex: number = 0,
15527
15623
  count: number = 10) → `Promise<unknown>`
15528
15624
  Get serial numbers for a product (admin only).
15529
15625
 
15530
- **lookupSN**(collectionId: string,
15531
- productId: string,
15626
+ **lookupSN**(collectionId: string,
15627
+ productId: string,
15532
15628
  codeId: string) → `Promise<unknown>`
15533
15629
  Look up a serial number by code for a product (admin only).
15534
15630
 
15535
- **publicLookupClaim**(collectionId: string,
15536
- productId: string,
15631
+ **publicLookupClaim**(collectionId: string,
15632
+ productId: string,
15537
15633
  claimId: string) → `Promise<unknown>`
15538
15634
 
15539
- **publicCreateClaim**(collectionId: string,
15540
- productId: string,
15635
+ **publicCreateClaim**(collectionId: string,
15636
+ productId: string,
15541
15637
  body: ProductClaimCreateRequestBody) → `Promise<unknown>`
15542
15638
 
15543
15639
  ### products
15544
15640
 
15545
- **get**(collectionId: string,
15546
- productId: string,
15641
+ **get**(collectionId: string,
15642
+ productId: string,
15547
15643
  admin?: boolean) → `Promise<ProductResponse>`
15548
15644
 
15549
- **list**(collectionId: string,
15645
+ **list**(collectionId: string,
15550
15646
  admin?: boolean) → `Promise<ProductResponse[]>`
15551
15647
 
15552
- **create**(collectionId: string,
15648
+ **create**(collectionId: string,
15553
15649
  data: ProductCreateRequest) → `Promise<ProductResponse>`
15554
15650
 
15555
- **update**(collectionId: string,
15556
- productId: string,
15651
+ **update**(collectionId: string,
15652
+ productId: string,
15557
15653
  data: ProductUpdateRequest) → `Promise<ProductResponse>`
15558
15654
 
15559
- **remove**(collectionId: string,
15655
+ **remove**(collectionId: string,
15560
15656
  productId: string) → `Promise<void>`
15561
15657
 
15562
- **query**(collectionId: string,
15563
- body: ProductQueryRequest,
15658
+ **query**(collectionId: string,
15659
+ body: ProductQueryRequest,
15564
15660
  admin?: boolean) → `Promise<ProductQueryResponse>`
15565
15661
  Query products in a collection with filtering, sorting, and pagination. authenticated admin context). Defaults to `false`, which targets the `/public` endpoint — consistent with `get`, `list`, and `listAssets`. ```typescript // Public query (default) await products.query(collectionId, { query: { search: 'cabernet' } }) // Admin query (authenticated) await products.query(collectionId, { query: { search: 'cabernet' } }, true) ```
15566
15662
 
15567
- **standardQuery**(collectionId: string,
15663
+ **standardQuery**(collectionId: string,
15568
15664
  body: StandardQuery = {}) → `Promise<QueryResult>`
15569
15665
  The standard query on products (admin only): the one query shape every resource is moving to, with counts, totals and filtering by facet. It sits beside `products.query`, whose own body is unchanged. POST /admin/collection/:collectionId/products/standard/query Fields: id, name, description, sku, gtin, schemaType, status, sortOrder, createdAt, updatedAt, facets. Facets are filtered by key: the facet by its key or name, the value by its key or name. ```typescript await products.standardQuery(collectionId, { where: { facets: { brand: 'Breville', category: { in: ['Toasters', 'Kettles'] } }, status: 'active' }, select: ['id', 'name', 'sku'], count: true, }) ```
15570
15666
 
15571
15667
  **standardQueryFields**(collectionId: string) → `Promise<QueryDescription>`
15572
15668
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15573
15669
 
15574
- **clone**(collectionId: string,
15575
- productId: string,
15670
+ **clone**(collectionId: string,
15671
+ productId: string,
15576
15672
  body: Record<string, JsonValue> = {}) → `Promise<ProductResponse>`
15577
15673
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15578
15674
 
15579
- **listAssets**(collectionId: string,
15580
- productId: string,
15675
+ **listAssets**(collectionId: string,
15676
+ productId: string,
15581
15677
  admin?: boolean) → `Promise<unknown>`
15582
15678
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15583
15679
 
15584
- **createClaimWindow**(collectionId: string,
15585
- productId: string,
15680
+ **createClaimWindow**(collectionId: string,
15681
+ productId: string,
15586
15682
  body: Record<string, JsonValue>) → `Promise<unknown>`
15587
15683
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15588
15684
 
15589
- **updateClaimWindow**(collectionId: string,
15590
- productId: string,
15591
- claimId: string,
15685
+ **updateClaimWindow**(collectionId: string,
15686
+ productId: string,
15687
+ claimId: string,
15592
15688
  body: Record<string, JsonValue>) → `Promise<unknown>`
15593
15689
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15594
15690
 
15595
- **refresh**(collectionId: string,
15691
+ **refresh**(collectionId: string,
15596
15692
  productId: string) → `Promise<ProductResponse>`
15597
15693
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15598
15694
 
15599
- **getSN**(collectionId: string,
15600
- productId: string,
15601
- startIndex: number = 0,
15695
+ **getSN**(collectionId: string,
15696
+ productId: string,
15697
+ startIndex: number = 0,
15602
15698
  count: number = 10) → `Promise<unknown>`
15603
15699
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15604
15700
 
15605
- **lookupSN**(collectionId: string,
15606
- productId: string,
15701
+ **lookupSN**(collectionId: string,
15702
+ productId: string,
15607
15703
  codeId: string) → `Promise<unknown>`
15608
15704
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15609
15705
 
15610
- **publicLookupClaim**(collectionId: string,
15611
- productId: string,
15706
+ **publicLookupClaim**(collectionId: string,
15707
+ productId: string,
15612
15708
  claimId: string) → `Promise<unknown>`
15613
15709
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15614
15710
 
15615
- **publicCreateClaim**(collectionId: string,
15616
- productId: string,
15711
+ **publicCreateClaim**(collectionId: string,
15712
+ productId: string,
15617
15713
  body: ProductClaimCreateRequestBody) → `Promise<unknown>`
15618
15714
  What a products standard query can use: its fields and what each can filter, sort, group or total. GET /admin/collection/:collectionId/products/standard/query
15619
15715
 
15620
15716
  ### proof
15621
15717
 
15622
- **query**(collectionId: string,
15718
+ **query**(collectionId: string,
15623
15719
  body: StandardQuery = {}) → `Promise<QueryResult>`
15624
15720
  The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs in one call, and follow a proof to its `product` and its `owner` (the owner's contact). POST /admin/collection/:collectionId/proof/query Fields: id, productId, userId (the owner's login id), batchId, variantId, lotId, status, claimable, createdAt, updatedAt. A proof's own values are not returned by this call. ```typescript // How many people own each product await proof.query(collectionId, { where: { userId: { isNull: false } }, groupBy: ['productId'], aggregates: { owners: { countDistinct: 'userId' } }, }) // The most recent owner of a product, with their name await proof.query(collectionId, { where: { productId: 'toaster', userId: { isNull: false } }, orderBy: [{ createdAt: 'desc' }], limit: 1, expand: { owner: ['firstName', 'lastName', 'email'] }, }) ```
15625
15721
 
15626
15722
  **queryFields**(collectionId: string) → `Promise<QueryDescription>`
15627
15723
  What a proofs query can use: its fields, what each can filter, sort, group or total, and its links. GET /admin/collection/:collectionId/proof/query
15628
15724
 
15629
- **get**(collectionId: string,
15630
- productId: string,
15631
- proofId: string,
15632
- admin?: boolean,
15725
+ **get**(collectionId: string,
15726
+ productId: string,
15727
+ proofId: string,
15728
+ admin?: boolean,
15633
15729
  include?: string[]) → `Promise<ProofResponse>`
15634
15730
  Retrieves a single Proof by Collection ID, Product ID, and Proof ID. Both public and admin endpoints now include productId in the path.
15635
15731
 
15636
- **list**(collectionId: string,
15732
+ **list**(collectionId: string,
15637
15733
  include?: string[]) → `Promise<ProofResponse[]>`
15638
15734
  List all Proofs for a Collection.
15639
15735
 
15640
- **create**(collectionId: string,
15641
- productId: string,
15736
+ **create**(collectionId: string,
15737
+ productId: string,
15642
15738
  request: ProofCreateRequest) → `Promise<ProofResponse>`
15643
15739
  Create a proof for a product (admin only). POST /admin/collection/:collectionId/product/:productId/proof Pass the proof's content in a `proof` block, keyed by zone (see {@link ProofWrite}): ```ts proof.create(collectionId, productId, { proof: { values: { colour: 'red' }, // public + owner readable, owner + admin writable data: { serialNo: 1001 }, // public + owner readable, ADMIN-only writable admin: { costPrice: 4.20 }, // admin-only }, claimable: true, }) ``` Note: a top-level `data`/`admin` on the request body is legacy — top-level `data` gets folded into the values bag, so use `proof.data` for `proof.data`.
15644
15740
 
15645
- **update**(collectionId: string,
15646
- productId: string,
15647
- proofId: string,
15741
+ **update**(collectionId: string,
15742
+ productId: string,
15743
+ proofId: string,
15648
15744
  values: ProofUpdateRequest) → `Promise<ProofResponse>`
15649
15745
  Update a proof for a product (admin only). PUT /admin/collection/:collectionId/product/:productId/proof/:proofId Pass the fields to change **at the root**, keyed by zone (see {@link ProofWrite}): ```ts proof.update(collectionId, productId, proofId, { data: { serialNo: 1002 }, // → proof.data (admin-only writable) values: { colour: 'blue' }, // → proof.values }) ``` Object zones deep-merge, so you can change one field without wiping the rest.
15650
15746
 
15651
- **updateValues**(collectionId: string,
15652
- productId: string,
15653
- proofId: string,
15747
+ **updateValues**(collectionId: string,
15748
+ productId: string,
15749
+ proofId: string,
15654
15750
  values: ProofValuesUpdateRequest) → `Promise<ProofResponse>`
15655
15751
  Owner self-service update of a proof's owner-writable data. PUT /public/collection/:collectionId/product/:productId/proof/:proofId/values The public counterpart to admin `update` — the current OWNER (or a collection admin) editing their own proof, no admin credentials required. Only owner-writable zones are honoured (see {@link ProofValuesUpdateRequest}): ```ts proof.updateValues(collectionId, productId, proofId, { colour: 'blue', // → proof.values.colour (public) owner: { warranty: '2y' }, // → proof.values.owner (owner-scoped) personal: { nickname: 'Bo' }, // → proof.values.personal[callerUid] (private, own slot only) }) ``` `personal` always targets the caller's OWN slot — you cannot write another user's personal data, even as an admin. Object zones deep-merge (owner/personal merge field-by-field), so you can change one field without wiping the rest. Business-only zones (`data`/`admin`/`private`) are not writable here — use the admin `update` for those.
15656
15752
 
15657
- **claim**(collectionId: string,
15658
- productId: string,
15659
- proofId: string,
15753
+ **claim**(collectionId: string,
15754
+ productId: string,
15755
+ proofId: string,
15660
15756
  values: ProofClaimRequest) → `Promise<ProofResponse>`
15661
15757
  Claim a proof for a product using a proof ID (serial number, NFC tag, etc.). PUT /public/collection/:collectionId/product/:productId/proof/:proofId/claim
15662
15758
 
15663
- **claimProduct**(collectionId: string,
15664
- productId: string,
15759
+ **claimProduct**(collectionId: string,
15760
+ productId: string,
15665
15761
  values?: ProofClaimRequest) → `Promise<ProofResponse>`
15666
15762
  Claim a product without providing a proof ID. System auto-generates a unique serial number on-demand. Requires allowAutoGenerateClaims to be enabled on the collection or product. PUT /public/collection/:collectionId/product/:productId/proof/claim ```typescript const proof = await proof.claimProduct( 'beauty-brand', 'moisturizer-pro', { purchaseDate: '2026-02-17', store: 'Target' } ); console.log('Auto-generated ID:', proof.id); ```
15667
15763
 
15668
- **remove**(collectionId: string,
15669
- productId: string,
15764
+ **remove**(collectionId: string,
15765
+ productId: string,
15670
15766
  proofId: string) → `Promise<void>`
15671
15767
  Delete a proof for a product (admin only). DELETE /admin/collection/:collectionId/product/:productId/proof/:proofId
15672
15768
 
15673
- **getByUser**(collectionId: string,
15769
+ **getByUser**(collectionId: string,
15674
15770
  userId: string) → `Promise<ProofResponse[]>`
15675
15771
  Get proofs for a user in a collection (admin only). GET /admin/collection/:collectionId/proof/findByUser/:userId
15676
15772
 
15677
- **getByProduct**(collectionId: string,
15773
+ **getByProduct**(collectionId: string,
15678
15774
  productId: string) → `Promise<ProofResponse[]>`
15679
15775
  Get proofs for a product (admin only). GET /admin/collection/:collectionId/product/:productId/proof
15680
15776
 
15681
- **findByProduct**(collectionId: string,
15682
- productId: string,
15777
+ **findByProduct**(collectionId: string,
15778
+ productId: string,
15683
15779
  query: any) → `Promise<ProofResponse[]>`
15684
15780
  Find proofs for a product (admin only). POST /admin/collection/:collectionId/product/:productId/proof/find
15685
15781
 
15686
- **getByBatch**(collectionId: string,
15687
- productId: string,
15782
+ **getByBatch**(collectionId: string,
15783
+ productId: string,
15688
15784
  batchId: string) → `Promise<ProofResponse[]>`
15689
15785
  Get proofs for a batch (admin only). GET /admin/collection/:collectionId/product/:productId/batch/:batchId/proof
15690
15786
 
15691
- **migrate**(collectionId: string,
15692
- productId: string,
15693
- proofId: string,
15694
- /** The destination product ID */
15787
+ **migrate**(collectionId: string,
15788
+ productId: string,
15789
+ proofId: string,
15790
+ /** The destination product ID */
15695
15791
  data: { targetProductId: string }) → `Promise<ProofResponse>`
15696
15792
  Migrate a proof to a different product within the same collection (admin only). Because the Firestore ledger document ID is `{productId}-{proofId}`, a proof cannot simply be re-assigned to another product by updating a field — the document must be re-keyed. This endpoint handles that atomically: 1. Reads the source ledger document (`{sourceProductId}-{proofId}`). 2. Writes a new document (`{targetProductId}-{proofId}`) with `productId` and `proofGroup` updated. The short `proofId` (nanoid) is unchanged. 3. Writes a migration history entry to the new document's `history` subcollection (snapshot of the original proof + migration metadata). 4. Copies all subcollections — `assets`, `attestations`, `history` — from the old document to the new one. 5. Deletes the old subcollections and then the old document. Repeated migrations are safe — each one appends a history record; no migration metadata is stored on the proof document itself. ```typescript const migrated = await proof.migrate('coll_123', 'prod_old', 'proof_abc', { targetProductId: 'prod_new', }) console.log(migrated.productId) // 'prod_new' ```
15697
15793
 
15698
- **createGrant**(collectionId: string,
15699
- productId: string,
15700
- proofId: string,
15794
+ **createGrant**(collectionId: string,
15795
+ productId: string,
15796
+ proofId: string,
15701
15797
  options: CreateGrantOptions) → `Promise<ProofGrant>`
15702
15798
  Create a share grant on a proof (owner / collection admin only). The returned grant includes `token` — the opaque bearer secret, available ONLY on this response. Embed it in a share link and hand recipients {@link redeemGrant} / {@link setGrantToken}.
15703
15799
 
15704
- **listGrants**(collectionId: string,
15705
- productId: string,
15800
+ **listGrants**(collectionId: string,
15801
+ productId: string,
15706
15802
  proofId: string) → `Promise<ProofGrant[]>`
15707
15803
  List the active + past grants on a proof (owner / collection admin only). Tokens are never returned here.
15708
15804
 
15709
- **revokeGrant**(collectionId: string,
15710
- productId: string,
15711
- proofId: string,
15805
+ **revokeGrant**(collectionId: string,
15806
+ productId: string,
15807
+ proofId: string,
15712
15808
  grantId: string) → `Promise<void>`
15713
15809
  Revoke a grant by id (owner / collection admin only). Takes effect immediately.
15714
15810
 
15715
- **redeemGrant**(collectionId: string,
15716
- productId: string,
15717
- proofId: string,
15718
- token: string,
15811
+ **redeemGrant**(collectionId: string,
15812
+ productId: string,
15813
+ proofId: string,
15814
+ token: string,
15719
15815
  options?: RedeemGrantOptions) → `Promise<RedeemGrantResult>`
15720
15816
  Redeem a grant token (anonymous or signed-in). Records the redemption and returns the granted scope, or — for a `verify_owner` grant — an ownership assertion (never the account). After redeeming, call {@link setGrantToken} so subsequent data requests carry the token.
15721
15817
 
15722
- **transfer**(collectionId: string,
15723
- productId: string,
15724
- proofId: string,
15818
+ **transfer**(collectionId: string,
15819
+ productId: string,
15820
+ proofId: string,
15725
15821
  options: TransferProofOptions) → `Promise<TransferProofResult>`
15726
15822
  Start a push transfer of a proof (current owner / collection admin only). Directed — hand it to a named recipient who then calls {@link acceptTransfer}: ```ts await proof.transfer(collectionId, productId, proofId, { toEmail: 'buyer@example.com' }) ``` Open release — make the proof claimable by anyone: ```ts await proof.transfer(collectionId, productId, proofId, { release: true }) ``` Send comms by naming templates per role (server decides who receives each): ```ts await proof.transfer(collectionId, productId, proofId, { toEmail: 'buyer@example.com', comms: { recipient: { templateId: 'transfer-incoming', props: { note: 'Enjoy!' } }, sender: { templateId: 'transfer-sent' }, }, }) ``` Direct to an SMS recipient by phone (E.164) and notify them by text: ```ts await proof.transfer(collectionId, productId, proofId, { toPhone: '+14155551234', comms: { recipient: { templateId: 'transfer-incoming', channel: 'sms' } }, }) ```
15727
15823
 
15728
- **acceptTransfer**(collectionId: string,
15729
- productId: string,
15730
- proofId: string,
15824
+ **acceptTransfer**(collectionId: string,
15825
+ productId: string,
15826
+ proofId: string,
15731
15827
  options: AcceptTransferOptions = {}) → `Promise<`
15732
15828
  Accept a directed transfer (the named recipient only). Completes the ownership move — the proof's `userId` becomes the caller and the previous owner's private data and share grants are cleared/voided.
15733
15829
 
15734
- **cancelTransfer**(collectionId: string,
15735
- productId: string,
15736
- proofId: string,
15830
+ **cancelTransfer**(collectionId: string,
15831
+ productId: string,
15832
+ proofId: string,
15737
15833
  options: CancelTransferOptions = {}) → `Promise<`
15738
15834
  Cancel a pending push transfer (current owner / collection admin only).
15739
15835
 
15740
- **getTransfer**(collectionId: string,
15741
- productId: string,
15836
+ **getTransfer**(collectionId: string,
15837
+ productId: string,
15742
15838
  proofId: string) → `Promise<`
15743
15839
  Get the active transfer/status for a proof (owner, collection admin, or the named recipient). Returns `{ transfer: null }` when nothing is in flight.
15744
15840
 
15745
15841
  ### publicClient
15746
15842
 
15747
- **chat**(collectionId: string,
15748
- request: PublicChatRequest) → `Promise<PublicChatResponse>`
15749
- Chat with product assistant (RAG)
15750
-
15751
- **agentRun**(collectionId: string,
15843
+ **agentRun**(collectionId: string,
15752
15844
  body: PublicAgentRunRequest) → `Promise<AgentRunResult>`
15753
15845
  Public agent loop — run the orchestration-neutral tool loop on the consumer surface. Exposes an app's PUBLIC server functions (`agent.tool:true`, `visibility:'public'`) to a consumer assistant; built-in tools are opt-in by explicit `server_tools[]` allowlist only. The caller runs as the signed-in consumer ('owner', send the authKit bearer) or anonymous ('public'). POST /public/collection/:collectionId/ai/agent/run
15754
15846
 
@@ -15763,19 +15855,19 @@ Check rate limit status
15763
15855
 
15764
15856
  ### publicClient.sessions
15765
15857
 
15766
- **create**(collectionId: string,
15858
+ **create**(collectionId: string,
15767
15859
  body: AiSessionCreate & { scope?: 'owner' | 'public' } = {}) → `Promise<AiSession>`
15768
15860
 
15769
- **list**(collectionId: string,
15861
+ **list**(collectionId: string,
15770
15862
  params?: { appId?: string; limit?: number }) → `Promise<`
15771
15863
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15772
15864
 
15773
15865
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15774
15866
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15775
15867
 
15776
- **append**(collectionId: string,
15777
- id: string,
15778
- items: ResponseInputItem[],
15868
+ **append**(collectionId: string,
15869
+ id: string,
15870
+ items: ResponseInputItem[],
15779
15871
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15780
15872
  List the signed-in consumer's own ('owner') sessions — requires an authKit bearer.
15781
15873
 
@@ -15787,16 +15879,6 @@ List the signed-in consumer's own ('owner') sessions — requires an authKit bea
15787
15879
  **lookupShortCode**(shortId: string, code: string) → `Promise<QrShortCodeLookupResponse>`
15788
15880
  Resolve a short code to related resource identifiers.
15789
15881
 
15790
- ### rag
15791
-
15792
- **indexDocument**(collectionId: string,
15793
- request: IndexDocumentRequest) → `Promise<IndexDocumentResponse>`
15794
- Index a document for RAG
15795
-
15796
- **configureAssistant**(collectionId: string,
15797
- request: ConfigureAssistantRequest) → `Promise<ConfigureAssistantResponse>`
15798
- Configure AI assistant behavior
15799
-
15800
15882
  ### rateLimit
15801
15883
 
15802
15884
  **reset**(collectionId: string, userId: string) → `Promise<`
@@ -15892,9 +15974,9 @@ List sessions, most-recently-active first (optionally filtered by app).
15892
15974
  **get**(collectionId: string, id: string) → `Promise<AiSession>`
15893
15975
  Get one session, including its full transcript.
15894
15976
 
15895
- **append**(collectionId: string,
15896
- id: string,
15897
- items: ResponseInputItem[],
15977
+ **append**(collectionId: string,
15978
+ id: string,
15979
+ items: ResponseInputItem[],
15898
15980
  opts?: { usage?: Record<string, any> }) → `Promise<AiSession>`
15899
15981
  Append Responses items (input/output/tool) to a session — the manual-persistence path.
15900
15982
 
@@ -16074,17 +16156,17 @@ Reverse lookup by ref via POST (public). `POST /public/collection/:collectionId/
16074
16156
 
16075
16157
  ### tools
16076
16158
 
16077
- **run**(collectionId: string,
16078
- name: K,
16079
- args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
16080
- export async function run<T = any>(
16081
- collectionId: string,
16082
- name: string,
16083
- args?: Record<string, any>,
16084
- ): Promise<ToolRunResult<T>>
16085
- export async function run(
16086
- collectionId: string,
16087
- name: string,
16159
+ **run**(collectionId: string,
16160
+ name: K,
16161
+ args: AiToolArgsMap[K],) → `Promise<ToolRunResult>
16162
+ export async function run<T = any>(
16163
+ collectionId: string,
16164
+ name: string,
16165
+ args?: Record<string, any>,
16166
+ ): Promise<ToolRunResult<T>>
16167
+ export async function run(
16168
+ collectionId: string,
16169
+ name: string,
16088
16170
  args: Record<string, any> =`
16089
16171
  Invoke ONE built-in server tool directly — no model in the loop. This is the "direct code" caller of the orchestration-neutral tool registry: the SAME tools the agent loop and the Responses `server_tools` path run, but called as a plain, typed, deterministic API. A front end can use it two ways: (1) call a tool straight as an API (e.g. `pdf.render` / `pdf.extract` behind a PDF UX), or (2) drive its OWN agent loop and execute each model tool-call here. Capability-gated server-side to the caller's grants (same blast-radius rules as the agent loop). POST /admin/collection/:collectionId/ai/tools/:name/run
16090
16172
 
@@ -16148,7 +16230,7 @@ Admin: replace the site's translation rules. They apply to new translations from
16148
16230
 
16149
16231
  ### tts
16150
16232
 
16151
- **generate**(collectionId: string,
16233
+ **generate**(collectionId: string,
16152
16234
  request: TTSRequest) → `Promise<Blob>`
16153
16235
  Generate text-to-speech audio
16154
16236