@proveanything/smartlinks 2.1.20 → 2.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/openapi.yaml CHANGED
@@ -3223,6 +3223,70 @@ paths:
3223
3223
  application/json:
3224
3224
  schema:
3225
3225
  $ref: "#/components/schemas/ContactCreateRequest"
3226
+ /admin/collection/{collectionId}/contacts/duplicates:
3227
+ get:
3228
+ tags:
3229
+ - contact
3230
+ summary: "Admin: pairs of contacts that look like one person."
3231
+ operationId: contact_findDuplicates
3232
+ security:
3233
+ - bearerAuth: []
3234
+ parameters:
3235
+ - name: collectionId
3236
+ in: path
3237
+ required: true
3238
+ schema:
3239
+ type: string
3240
+ - name: limit
3241
+ in: query
3242
+ required: false
3243
+ schema:
3244
+ type: string
3245
+ - name: offset
3246
+ in: query
3247
+ required: false
3248
+ schema:
3249
+ type: string
3250
+ responses:
3251
+ 200:
3252
+ description: Success
3253
+ content:
3254
+ application/json:
3255
+ schema:
3256
+ $ref: "#/components/schemas/ContactDuplicatesResponse"
3257
+ 400:
3258
+ description: Bad request
3259
+ 401:
3260
+ description: Unauthorized
3261
+ 404:
3262
+ description: Not found
3263
+ /admin/collection/{collectionId}/contacts/link-login:
3264
+ post:
3265
+ tags:
3266
+ - contact
3267
+ summary: "Admin: the contact that carries a sign-in, attaching the sign-in first to the contact that already holds its verified email or phone."
3268
+ operationId: contact_linkLogin
3269
+ security:
3270
+ - bearerAuth: []
3271
+ parameters:
3272
+ - name: collectionId
3273
+ in: path
3274
+ required: true
3275
+ schema:
3276
+ type: string
3277
+ responses:
3278
+ 200:
3279
+ description: Success
3280
+ content:
3281
+ application/json:
3282
+ schema:
3283
+ $ref: "#/components/schemas/ContactLinkLoginResponse"
3284
+ 400:
3285
+ description: Bad request
3286
+ 401:
3287
+ description: Unauthorized
3288
+ 404:
3289
+ description: Not found
3226
3290
  /admin/collection/{collectionId}/contacts/lookup:
3227
3291
  get:
3228
3292
  tags:
@@ -3538,6 +3602,38 @@ paths:
3538
3602
  description: Unauthorized
3539
3603
  404:
3540
3604
  description: Not found
3605
+ /admin/collection/{collectionId}/contacts/{keepContactId}/merge:
3606
+ post:
3607
+ tags:
3608
+ - contact
3609
+ summary: "Admin: fold contact `fromContactId` INTO contact `keepContactId`."
3610
+ operationId: contact_merge
3611
+ security:
3612
+ - bearerAuth: []
3613
+ parameters:
3614
+ - name: collectionId
3615
+ in: path
3616
+ required: true
3617
+ schema:
3618
+ type: string
3619
+ - name: keepContactId
3620
+ in: path
3621
+ required: true
3622
+ schema:
3623
+ type: string
3624
+ responses:
3625
+ 200:
3626
+ description: Success
3627
+ content:
3628
+ application/json:
3629
+ schema:
3630
+ $ref: "#/components/schemas/ContactMergeResponse"
3631
+ 400:
3632
+ description: Bad request
3633
+ 401:
3634
+ description: Unauthorized
3635
+ 404:
3636
+ description: Not found
3541
3637
  /admin/collection/{collectionId}/containers:
3542
3638
  get:
3543
3639
  tags:
@@ -21669,6 +21765,8 @@ components:
21669
21765
  type: string
21670
21766
  admin:
21671
21767
  type: string
21768
+ adminPage:
21769
+ type: string
21672
21770
  widgets:
21673
21771
  $ref: "#/components/schemas/AppManifestWidgets"
21674
21772
  containers:
@@ -21699,6 +21797,14 @@ components:
21699
21797
  realtime:
21700
21798
  type: object
21701
21799
  additionalProperties: true
21800
+ channels:
21801
+ type: array
21802
+ items:
21803
+ $ref: "#/components/schemas/RealtimeChannelDeclaration"
21804
+ staff:
21805
+ type: array
21806
+ items:
21807
+ type: string
21702
21808
  adminCards:
21703
21809
  $ref: "#/components/schemas/AppManifestAdminCards"
21704
21810
  data:
@@ -21741,6 +21847,55 @@ components:
21741
21847
  $ref: "#/components/schemas/AppAssistantFile"
21742
21848
  preview:
21743
21849
  type: string
21850
+ purpose:
21851
+ type: string
21852
+ objects:
21853
+ type: array
21854
+ items:
21855
+ $ref: "#/components/schemas/AssistantObject"
21856
+ words:
21857
+ type: object
21858
+ additionalProperties:
21859
+ type: string
21860
+ recipes:
21861
+ type: array
21862
+ items:
21863
+ $ref: "#/components/schemas/AssistantRecipe"
21864
+ AssistantObject:
21865
+ type: object
21866
+ properties:
21867
+ object:
21868
+ type: string
21869
+ where:
21870
+ type: object
21871
+ additionalProperties:
21872
+ type: object
21873
+ additionalProperties: true
21874
+ means:
21875
+ type: string
21876
+ fields:
21877
+ type: object
21878
+ additionalProperties:
21879
+ type: string
21880
+ write:
21881
+ type: string
21882
+ enum:
21883
+ - direct
21884
+ - actions
21885
+ - none
21886
+ required:
21887
+ - object
21888
+ - means
21889
+ AssistantRecipe:
21890
+ type: object
21891
+ properties:
21892
+ question:
21893
+ type: string
21894
+ answer:
21895
+ type: string
21896
+ required:
21897
+ - question
21898
+ - answer
21744
21899
  ConnectorConnectionField:
21745
21900
  type: object
21746
21901
  properties:
@@ -28537,6 +28692,91 @@ components:
28537
28692
  - items
28538
28693
  - limit
28539
28694
  - offset
28695
+ ContactDuplicatePair:
28696
+ type: object
28697
+ properties:
28698
+ keep:
28699
+ $ref: "#/components/schemas/Contact"
28700
+ merge:
28701
+ $ref: "#/components/schemas/Contact"
28702
+ matchedOn:
28703
+ type: object
28704
+ additionalProperties: true
28705
+ required:
28706
+ - keep
28707
+ - merge
28708
+ - matchedOn
28709
+ ContactDuplicatesResponse:
28710
+ type: object
28711
+ properties:
28712
+ pairs:
28713
+ type: array
28714
+ items:
28715
+ $ref: "#/components/schemas/ContactDuplicatePair"
28716
+ scanned:
28717
+ type: number
28718
+ more:
28719
+ type: boolean
28720
+ required:
28721
+ - pairs
28722
+ - scanned
28723
+ - more
28724
+ ContactMergeResponse:
28725
+ type: object
28726
+ properties:
28727
+ contactId:
28728
+ type: string
28729
+ mergedFrom:
28730
+ type: string
28731
+ moved:
28732
+ type: object
28733
+ additionalProperties: true
28734
+ login:
28735
+ type: boolean
28736
+ identities:
28737
+ type: number
28738
+ records:
28739
+ type: number
28740
+ cases:
28741
+ type: number
28742
+ threads:
28743
+ type: number
28744
+ bookings:
28745
+ type: number
28746
+ loyaltyMembers:
28747
+ type: number
28748
+ assets:
28749
+ type: number
28750
+ uploadTokens:
28751
+ type: number
28752
+ aiSessions:
28753
+ type: number
28754
+ messages:
28755
+ type: number
28756
+ conversations:
28757
+ type: number
28758
+ contact:
28759
+ $ref: "#/components/schemas/Contact"
28760
+ required:
28761
+ - contactId
28762
+ - mergedFrom
28763
+ - moved
28764
+ - login
28765
+ - identities
28766
+ - contact
28767
+ ContactLinkLoginResponse:
28768
+ type: object
28769
+ properties:
28770
+ contactId:
28771
+ type: string
28772
+ linked:
28773
+ type: boolean
28774
+ contact:
28775
+ $ref: "#/components/schemas/Contact"
28776
+ required:
28777
+ - contactId
28778
+ - linked
28779
+ - contact
28540
28780
  ContactSearchParams:
28541
28781
  type: object
28542
28782
  properties:
@@ -28904,6 +29144,9 @@ components:
28904
29144
  $ref: "#/components/schemas/Contact"
28905
29145
  ContactUpdateRequest:
28906
29146
  $ref: "#/components/schemas/ContactCreateRequest"
29147
+ ContactMergeErrorCode:
29148
+ type: object
29149
+ additionalProperties: true
28907
29150
  PublicContactUpsertRequest:
28908
29151
  $ref: "#/components/schemas/Contact"
28909
29152
  ContactPatch:
@@ -35373,6 +35616,8 @@ components:
35373
35616
  type: string
35374
35617
  status:
35375
35618
  type: string
35619
+ kind:
35620
+ type: string
35376
35621
  at:
35377
35622
  type: number
35378
35623
  required:
@@ -35393,6 +35638,8 @@ components:
35393
35638
  type: string
35394
35639
  proofId:
35395
35640
  type: string
35641
+ kind:
35642
+ type: string
35396
35643
  RealtimeChannelDeclaration:
35397
35644
  type: object
35398
35645
  properties:
@@ -1244,6 +1244,14 @@ export interface AppManifest {
1244
1244
  * Absent when the app has no admin UI.
1245
1245
  */
1246
1246
  admin?: string;
1247
+ /**
1248
+ * The page a host opens as this app's ADMIN screen, from the app's root: `"admin.html"` or
1249
+ * `"index.html"`. Hosts (Studio, the console, Forge's preview) read it instead of guessing.
1250
+ * Absent → the host's default: `admin.html` for an installed app, the root page (`index.html`) for a
1251
+ * core app. Declare it when that default is wrong — e.g. AuthKit (`core-account`), whose root page
1252
+ * is the PUBLIC sign-in screen every site redirects to, and whose admin is `admin.html`.
1253
+ */
1254
+ adminPage?: string;
1247
1255
  /** Widget bundle definition. Presence means a widget bundle exists for this app. */
1248
1256
  widgets?: AppManifestWidgets;
1249
1257
  /** Container bundle definition. Presence means a container bundle exists. */
@@ -1297,7 +1305,13 @@ export interface AppManifest {
1297
1305
  * ```
1298
1306
  */
1299
1307
  realtime?: {
1300
- channels: RealtimeChannelDeclaration[];
1308
+ channels?: RealtimeChannelDeclaration[];
1309
+ /**
1310
+ * Who hears changes to what this app works on (`realtime.onStaffChange`: its work orders, the
1311
+ * containers and stock it moves), as user group keys. Absent: every user group the app's server
1312
+ * functions are limited to. `[]`: nobody but collection admins.
1313
+ */
1314
+ staff?: string[];
1301
1315
  };
1302
1316
  /**
1303
1317
  * Cards this app adds to the collection's dashboard in Studio. A `data` card names an ADMIN server
@@ -1376,6 +1390,55 @@ export interface AppAssistantDeclaration {
1376
1390
  * Relative to the app's admin surface, e.g. `"/admin/preview?changeSet={id}"`.
1377
1391
  */
1378
1392
  preview?: string;
1393
+ /**
1394
+ * One line (≤ 200 characters): what this app or site is for. Always in the assistant's view, in the
1395
+ * line for this app: "Production manager for a fragrance filling and decorating factory".
1396
+ */
1397
+ purpose?: string;
1398
+ /**
1399
+ * What each standard object MEANS in this app ("a work order here is a job"), and whether the
1400
+ * assistant may change it directly or only through one of the app's actions. Up to 20. Record types
1401
+ * declared in the manifest's `data` block needn't be repeated: the assistant gets their titles and
1402
+ * fields from there. @see AssistantObject
1403
+ */
1404
+ objects?: AssistantObject[];
1405
+ /** The business's own terms: `{ "GMP": "the batch manufacturing record printed for each job" }`. Up to 40. */
1406
+ words?: Record<string, string>;
1407
+ /** How to answer the questions people actually ask. Up to 30. @see AssistantRecipe */
1408
+ recipes?: AssistantRecipe[];
1409
+ }
1410
+ /**
1411
+ * What one standard object means in this app. A SITE may also describe objects other installed apps
1412
+ * keep (narrow them with `where: { appId }`); there, what the site says wins over the app's own words.
1413
+ */
1414
+ export interface AssistantObject {
1415
+ /** The standard object: `workOrder`, `workOrderStage`, `container`, `stock`, `booking`, `record`, `contact`, `product`, `history`. */
1416
+ object: string;
1417
+ /**
1418
+ * Which ones, with the same filters the SDK takes: `{ appId: "accord-production" }`,
1419
+ * `{ containerType: "drum" }`, `{ recordType: "smell-test" }`, `{ "data.event": "christmas-fair" }`.
1420
+ */
1421
+ where?: Record<string, string | number | boolean>;
1422
+ /** What it is here, in a sentence (≤ 300 characters): "A job." */
1423
+ means: string;
1424
+ /** What its fields hold, where the name doesn't say: `{ "ref": "job number", "data.stage": "the stage shown on screen" }`. Up to 20. */
1425
+ fields?: Record<string, string>;
1426
+ /**
1427
+ * May the assistant change it?
1428
+ * - `direct`: through the API, as a planned change the person applies;
1429
+ * - `actions`: ONLY through one of this app's actions (functions with `agent.tool`), because the
1430
+ * app's rules live in its code (numbering, checks, who is told);
1431
+ * - `none`: never.
1432
+ * Absent: nothing is said (the platform's usual rules apply).
1433
+ */
1434
+ write?: 'direct' | 'actions' | 'none';
1435
+ }
1436
+ /** One common question and how to answer it: an object query in plain words, or the action that knows. */
1437
+ export interface AssistantRecipe {
1438
+ /** The question as people ask it (≤ 160 characters): "What's on tomorrow?" */
1439
+ question: string;
1440
+ /** How to answer (≤ 400 characters): "work order stages of this app planned for that day, by stage; show machine or crew". */
1441
+ answer: string;
1379
1442
  }
1380
1443
  /** One field of a connector's "Connect" form. */
1381
1444
  export interface ConnectorConnectionField {
@@ -34,6 +34,61 @@ export interface ContactListResponse {
34
34
  limit: number;
35
35
  offset: number;
36
36
  }
37
+ /**
38
+ * Two contacts that look like one person (`contact.findDuplicates`): `keep` has a sign-in but no email
39
+ * (or phone); `merge` has no sign-in and holds that sign-in's verified email (or phone).
40
+ */
41
+ export interface ContactDuplicatePair {
42
+ /** The contact with the sign-in — the one `contact.merge` should keep. */
43
+ keep: Contact;
44
+ /** The contact holding the address — the one to fold into `keep`. */
45
+ merge: Contact;
46
+ /** What ties them together. */
47
+ matchedOn: "email" | "phone";
48
+ }
49
+ export interface ContactDuplicatesResponse {
50
+ pairs: ContactDuplicatePair[];
51
+ /** How many contacts with a sign-in were checked in this call. */
52
+ scanned: number;
53
+ /** More contacts remain beyond this window: call again with `offset` + `scanned`. */
54
+ more: boolean;
55
+ }
56
+ /** What `contact.merge` did. */
57
+ export interface ContactMergeResponse {
58
+ /** The contact that was kept. */
59
+ contactId: string;
60
+ /** The contact that was retired (soft-deleted, marked `customFields.mergedInto`). */
61
+ mergedFrom: string;
62
+ moved: {
63
+ /** The sign-in moved onto the kept contact. */
64
+ login: boolean;
65
+ /** Emails and phones moved across. */
66
+ identities: number;
67
+ records?: number;
68
+ cases?: number;
69
+ threads?: number;
70
+ bookings?: number;
71
+ loyaltyMembers?: number;
72
+ assets?: number;
73
+ uploadTokens?: number;
74
+ aiSessions?: number;
75
+ /** One-to-one messages and Inbox conversations with them. */
76
+ messages?: number;
77
+ conversations?: number;
78
+ };
79
+ /** The kept contact after the merge. */
80
+ contact: Contact;
81
+ }
82
+ /** What `contact.linkLogin` found. */
83
+ export interface ContactLinkLoginResponse {
84
+ /** The contact that carries the sign-in. */
85
+ contactId: string;
86
+ /** True when this call attached the sign-in to that contact (or merged a duplicate into it). */
87
+ linked: boolean;
88
+ contact: Contact;
89
+ }
90
+ /** `error` codes `contact.merge` can refuse with. */
91
+ export type ContactMergeErrorCode = "INVALID_CONTACT" | "SAME_CONTACT" | "NOT_FOUND" | "KEEP_DELETED" | "LOGIN_CONFLICT" | "LOYALTY_CONFLICT";
37
92
  export interface ContactSearchParams {
38
93
  collectionId: string;
39
94
  q?: string;
@@ -57,7 +57,10 @@ export interface RealtimeMessage {
57
57
  }
58
58
  /** "This changed" — ids only; refetch through the normal API. */
59
59
  export interface RealtimeChangeEvent {
60
- /** 'product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings' | … */
60
+ /**
61
+ * 'product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings' | …
62
+ * and, on an app's staff feed (`onStaffChange`): 'workOrder' | 'container' | 'stock'.
63
+ */
61
64
  type: string;
62
65
  id?: string;
63
66
  appId?: string;
@@ -66,6 +69,8 @@ export interface RealtimeChangeEvent {
66
69
  proofId?: string;
67
70
  /** 'created' | 'updated' | 'deleted' (records) or 'create' | 'update' | 'delete' (products, proofs…) */
68
71
  status?: string;
72
+ /** A container's type ("drum", "pallet"), on a 'container' change. */
73
+ kind?: string;
69
74
  at: number;
70
75
  }
71
76
  /** Which changes to hear about — every field given must match. */
@@ -76,6 +81,7 @@ export interface RealtimeChangeFilter {
76
81
  recordType?: string;
77
82
  productId?: string;
78
83
  proofId?: string;
84
+ kind?: string;
79
85
  }
80
86
  /** A channel an app declares in its manifest (`realtime.channels`). */
81
87
  export interface RealtimeChannelDeclaration {
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 2.1.20 | Generated: 2026-11-16T21:00:34.061Z
3
+ Version: 2.1.22 | Generated: 2026-11-18T08:01:22.740Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -3186,6 +3186,7 @@ interface AppManifest {
3186
3186
  };
3187
3187
  };
3188
3188
  admin?: string;
3189
+ adminPage?: string;
3189
3190
  widgets?: AppManifestWidgets;
3190
3191
  containers?: {
3191
3192
  files: AppManifestFiles;
@@ -3196,7 +3197,10 @@ interface AppManifest {
3196
3197
  adminViews?: AdminView[];
3197
3198
  executor?: AppManifestExecutor;
3198
3199
  functions?: AppManifestFunctions;
3199
- realtime?: { channels: RealtimeChannelDeclaration[] };
3200
+ realtime?: {
3201
+ channels?: RealtimeChannelDeclaration[];
3202
+ staff?: string[];
3203
+ };
3200
3204
  adminCards?: AppManifestAdminCards;
3201
3205
  data?: AppDataDeclaration;
3202
3206
  headless?: AppHeadlessDeclaration;
@@ -3221,6 +3225,29 @@ interface AppAssistantDeclaration {
3221
3225
  skills?: AppAssistantFile[];
3222
3226
  knowledge?: AppAssistantFile[];
3223
3227
  preview?: string;
3228
+ purpose?: string;
3229
+ objects?: AssistantObject[];
3230
+ words?: Record<string, string>;
3231
+ recipes?: AssistantRecipe[];
3232
+ }
3233
+ ```
3234
+
3235
+ **AssistantObject** (interface)
3236
+ ```typescript
3237
+ interface AssistantObject {
3238
+ object: string;
3239
+ where?: Record<string, string | number | boolean>;
3240
+ means: string;
3241
+ fields?: Record<string, string>;
3242
+ write?: 'direct' | 'actions' | 'none';
3243
+ }
3244
+ ```
3245
+
3246
+ **AssistantRecipe** (interface)
3247
+ ```typescript
3248
+ interface AssistantRecipe {
3249
+ question: string;
3250
+ answer: string;
3224
3251
  }
3225
3252
  ```
3226
3253
 
@@ -7440,6 +7467,56 @@ interface ContactListResponse {
7440
7467
  }
7441
7468
  ```
7442
7469
 
7470
+ **ContactDuplicatePair** (interface)
7471
+ ```typescript
7472
+ interface ContactDuplicatePair {
7473
+ keep: Contact
7474
+ merge: Contact
7475
+ matchedOn: "email" | "phone"
7476
+ }
7477
+ ```
7478
+
7479
+ **ContactDuplicatesResponse** (interface)
7480
+ ```typescript
7481
+ interface ContactDuplicatesResponse {
7482
+ pairs: ContactDuplicatePair[]
7483
+ scanned: number
7484
+ more: boolean
7485
+ }
7486
+ ```
7487
+
7488
+ **ContactMergeResponse** (interface)
7489
+ ```typescript
7490
+ interface ContactMergeResponse {
7491
+ contactId: string
7492
+ mergedFrom: string
7493
+ moved: {
7494
+ login: boolean
7495
+ identities: number
7496
+ records?: number
7497
+ cases?: number
7498
+ threads?: number
7499
+ bookings?: number
7500
+ loyaltyMembers?: number
7501
+ assets?: number
7502
+ uploadTokens?: number
7503
+ aiSessions?: number
7504
+ messages?: number
7505
+ conversations?: number
7506
+ }
7507
+ contact: Contact
7508
+ }
7509
+ ```
7510
+
7511
+ **ContactLinkLoginResponse** (interface)
7512
+ ```typescript
7513
+ interface ContactLinkLoginResponse {
7514
+ contactId: string
7515
+ linked: boolean
7516
+ contact: Contact
7517
+ }
7518
+ ```
7519
+
7443
7520
  **ContactSearchParams** (interface)
7444
7521
  ```typescript
7445
7522
  interface ContactSearchParams {
@@ -7660,6 +7737,8 @@ interface ContactSchemaResponse {
7660
7737
 
7661
7738
  **ContactUpdateRequest** = `Partial<ContactCreateRequest>`
7662
7739
 
7740
+ **ContactMergeErrorCode** = ``
7741
+
7663
7742
  **PublicContactUpsertRequest** = `Partial<`
7664
7743
 
7665
7744
  **ContactPatch** = `Partial<`
@@ -11336,6 +11415,7 @@ interface RealtimeChangeEvent {
11336
11415
  productId?: string
11337
11416
  proofId?: string
11338
11417
  status?: string
11418
+ kind?: string
11339
11419
  at: number
11340
11420
  }
11341
11421
  ```
@@ -11349,6 +11429,7 @@ interface RealtimeChangeFilter {
11349
11429
  recordType?: string
11350
11430
  productId?: string
11351
11431
  proofId?: string
11432
+ kind?: string
11352
11433
  }
11353
11434
  ```
11354
11435
 
@@ -13804,9 +13885,22 @@ Public: Get the contact schema for a collection. GET /public/collection/:collect
13804
13885
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
13805
13886
  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 }) } ```
13806
13887
 
13888
+ **findDuplicates**(collectionId: string,
13889
+ params?: { limit?: number; offset?: number }) → `Promise<ContactDuplicatesResponse>`
13890
+ 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) } ```
13891
+
13892
+ **merge**(collectionId: string,
13893
+ keepContactId: string,
13894
+ fromContactId: string) → `Promise<ContactMergeResponse>`
13895
+ 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`).
13896
+
13897
+ **linkLogin**(collectionId: string,
13898
+ userId: string) → `Promise<ContactLinkLoginResponse>`
13899
+ 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 } ```
13900
+
13807
13901
  **getUser**(collectionId: string,
13808
13902
  userId: string,) → `Promise<UserSearchResponse>`
13809
- 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 }) } ```
13903
+ 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 } ```
13810
13904
 
13811
13905
  ### containers
13812
13906
 
@@ -14888,6 +14982,9 @@ One of your app's declared channels (manifest `realtime.channels`). ```ts const
14888
14982
  **onChange**(scope: RealtimeScope, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
14889
14983
  Something changed: refetch it. IDs only — never data. Admins of the collection see every change; everyone else sees changes to public things (public app records, products). Filter by `type` ('product' | 'proof' | 'asset' | 'record' | 'collection' | 'collection.apps' | 'settings'), `id`, `appId`, `recordType`, `productId`, `proofId`. ```ts const off = realtime.onChange({ collectionId }, { type: "record", appId, recordType: "entry" }, () => refetch()) ```
14890
14984
 
14985
+ **onStaffChange**(scope: RealtimeScope & { appId: string }, filter: RealtimeChangeFilter, onChangeFn: (change: RealtimeChangeEvent) → `void`
14986
+ Something this APP works on changed: one of its work orders, a container or stock it moved, or one of its own records. For the people who use the app, admins or not: someone hears these when they are in one of the app's user groups (the ones its server functions are limited to, or `realtime.staff` in its manifest), and so does a collection admin. IDs only — refetch through your own API. Types: 'workOrder' (`id`, `appId`), 'container' (`id`, `kind` = its container type), 'stock' (`id` = the container, `productId`), 'record' (`id`, `recordType`). Filter as with `onChange`; an empty filter hears them all. ```ts // A production app's screens refetch when anything on the floor changes. useEffect(() => realtime.onStaffChange({ collectionId, appId }, {}, () => queryClient.invalidateQueries()), [collectionId, appId]) ```
14987
+
14891
14988
  **onMine**(scope: RealtimeScope, onMessage: (msg: RealtimeMessage) → `void`
14892
14989
  Messages for the signed-in person only (e.g. "scan" — a tag they just scanned on another device).
14893
14990
 
@@ -219,6 +219,25 @@ A relative path (from the app's public root) to the `app.admin.json` file. Omit
219
219
  "admin": "app.admin.json"
220
220
  ```
221
221
 
222
+ #### `adminPage`
223
+
224
+ The page a host opens as the app's **admin screen**, from the app's root: `"admin.html"` or `"index.html"`.
225
+ Studio, the console and Forge's preview read it rather than guess. Omit it to take the host's default:
226
+
227
+ | App | Default admin page |
228
+ |-----|--------------------|
229
+ | An installed app | `admin.html` |
230
+ | A core app (`core-<name>`, one of Studio's own sections) | the root page, `index.html` |
231
+
232
+ Declare it when the default is wrong. AuthKit (`core-account`) is the example: its root page is the
233
+ **public sign-in screen** every site sends people to, so its admin lives at `admin.html`:
234
+
235
+ ```json
236
+ "adminPage": "admin.html"
237
+ ```
238
+
239
+ Never move a public page off the root to make room for the admin: sign-in links and embeds point at the root.
240
+
222
241
  #### `widgets`
223
242
 
224
243
  Declares the widget bundle. Omit if the app has no widget component.