@proveanything/smartlinks 1.5.6 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse, ContactSchema } from "../types";
1
+ import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse, ContactSchemaResponse } from "../types";
2
2
  export declare namespace contact {
3
3
  function create(collectionId: string, data: ContactCreateRequest): Promise<ContactResponse>;
4
4
  function list(collectionId: string, params?: {
@@ -20,18 +20,34 @@ export declare namespace contact {
20
20
  function publicGetMine(collectionId: string): Promise<PublicGetMyContactResponse>;
21
21
  function publicUpdateMine(collectionId: string, data: ContactPatch): Promise<PublicUpdateMyContactResponse>;
22
22
  /**
23
- * Public: Get contact update schema for a collection
23
+ * Public: Get the contact schema for a collection.
24
+ * GET /public/collection/:collectionId/contact/schema
24
25
  *
25
- * Fetches the public contact schema including core fields, custom fields with
26
- * conditional visibility rules, and visibility/editability settings.
26
+ * Returns a ContactSchemaResponse describing all publicly visible contact fields.
27
+ * Core fields and collection-defined custom fields are merged into a single flat schema.
27
28
  *
28
- * Custom fields may include a `condition` property that specifies when the field
29
- * should be displayed. Apps rendering these forms should:
30
- * 1. Evaluate each field's `condition` against current form values
31
- * 2. Hide fields whose conditions are not met
32
- * 3. Skip validation for hidden fields (they shouldn't be required when not visible)
29
+ * Fields not in `publicVisibleFields` are stripped entirely from the response.
30
+ * Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`.
31
+ *
32
+ * Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions`
33
+ * from the types package to handle conditional field visibility.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { contact, evaluateConditions } from '@proveanything/smartlinks'
38
+ *
39
+ * const schema = await contact.publicGetSchema(collectionId)
40
+ *
41
+ * for (const fieldId of schema.fieldOrder) {
42
+ * const property = schema.schema.properties[fieldId]
43
+ * const ui = schema.uiSchema[fieldId] || {}
44
+ * const visible = evaluateConditions(property.conditions, property.showWhen, formValues)
45
+ * const disabled = ui['ui:disabled'] === true
46
+ * if (visible) renderField({ fieldId, property, ui, disabled })
47
+ * }
48
+ * ```
33
49
  */
34
- function publicGetSchema(collectionId: string): Promise<ContactSchema>;
50
+ function publicGetSchema(collectionId: string): Promise<ContactSchemaResponse>;
35
51
  function erase(collectionId: string, contactId: string, body?: any): Promise<ContactResponse>;
36
52
  function getUser(collectionId: string, userId: string): Promise<UserSearchResponse>;
37
53
  }
@@ -72,16 +72,32 @@ export var contact;
72
72
  }
73
73
  contact.publicUpdateMine = publicUpdateMine;
74
74
  /**
75
- * Public: Get contact update schema for a collection
75
+ * Public: Get the contact schema for a collection.
76
+ * GET /public/collection/:collectionId/contact/schema
76
77
  *
77
- * Fetches the public contact schema including core fields, custom fields with
78
- * conditional visibility rules, and visibility/editability settings.
78
+ * Returns a ContactSchemaResponse describing all publicly visible contact fields.
79
+ * Core fields and collection-defined custom fields are merged into a single flat schema.
79
80
  *
80
- * Custom fields may include a `condition` property that specifies when the field
81
- * should be displayed. Apps rendering these forms should:
82
- * 1. Evaluate each field's `condition` against current form values
83
- * 2. Hide fields whose conditions are not met
84
- * 3. Skip validation for hidden fields (they shouldn't be required when not visible)
81
+ * Fields not in `publicVisibleFields` are stripped entirely from the response.
82
+ * Fields visible but not in `publicEditableFields` have `ui:disabled: true` in `uiSchema`.
83
+ *
84
+ * Use `fieldOrder` to render fields in the correct sequence, and `evaluateConditions`
85
+ * from the types package to handle conditional field visibility.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { contact, evaluateConditions } from '@proveanything/smartlinks'
90
+ *
91
+ * const schema = await contact.publicGetSchema(collectionId)
92
+ *
93
+ * for (const fieldId of schema.fieldOrder) {
94
+ * const property = schema.schema.properties[fieldId]
95
+ * const ui = schema.uiSchema[fieldId] || {}
96
+ * const visible = evaluateConditions(property.conditions, property.showWhen, formValues)
97
+ * const disabled = ui['ui:disabled'] === true
98
+ * if (visible) renderField({ fieldId, property, ui, disabled })
99
+ * }
100
+ * ```
85
101
  */
86
102
  async function publicGetSchema(collectionId) {
87
103
  const path = `/public/collection/${encodeURIComponent(collectionId)}/contact/schema`;
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.5.6 | Generated: 2026-02-26T08:32:23.437Z
3
+ Version: 1.6.0 | Generated: 2026-02-26T10:54:21.851Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -2502,36 +2502,46 @@ interface CommsState {
2502
2502
  **FieldCondition** (interface)
2503
2503
  ```typescript
2504
2504
  interface FieldCondition {
2505
- dependsOn: string // key of the field to check (not path)
2505
+ targetFieldId: string // The field whose value is tested
2506
2506
  operator: ConditionOperator
2507
- value?: string | string[] // required for equals/notEquals/contains/notContains
2507
+ value?: unknown // Required for equals / not_equals / contains / not_contains / greater_than / less_than
2508
2508
  }
2509
2509
  ```
2510
2510
 
2511
- **BaseField** (interface)
2511
+ **ContactSchemaProperty** (interface)
2512
2512
  ```typescript
2513
- interface BaseField {
2514
- key: string
2515
- label: string
2516
- type: FieldType
2517
- widget: FieldWidget
2518
- visible: boolean
2519
- editable: boolean
2520
- readOnly: boolean
2513
+ interface ContactSchemaProperty {
2514
+ type: 'string' | 'number' | 'boolean' | 'array'
2515
+ title?: string
2516
+ description?: string
2517
+ format?: string
2518
+ enum?: string[]
2519
+ conditions?: FieldCondition[]
2520
+ showWhen?: 'all' | 'any'
2521
+ }
2522
+ ```
2523
+
2524
+ **ContactUiSchemaEntry** (interface)
2525
+ ```typescript
2526
+ interface ContactUiSchemaEntry {
2527
+ 'ui:disabled'?: true // Field is visible but not editable
2528
+ 'ui:placeholder'?: string // Placeholder text
2529
+ [key: string]: unknown // Forward-compatible with additional rjsf hints
2521
2530
  }
2522
2531
  ```
2523
2532
 
2524
- **ContactSchema** (interface)
2533
+ **ContactSchemaResponse** (interface)
2525
2534
  ```typescript
2526
- interface ContactSchema {
2527
- version: number // 1
2528
- fields: CoreField[] // core fields
2529
- customFields: CustomField[]
2530
- settings: {
2531
- publicVisibleFields: string[]
2532
- publicEditableFields: string[]
2533
- customFieldsVersion: number
2535
+ interface ContactSchemaResponse {
2536
+ schema: {
2537
+ type: 'object'
2538
+ required?: string[]
2539
+ properties: Record<string, ContactSchemaProperty>
2534
2540
  }
2541
+ uiSchema: Record<string, ContactUiSchemaEntry>
2542
+ fieldOrder: string[]
2543
+ settings: Record<string, unknown>
2544
+ styling: Record<string, unknown>
2535
2545
  }
2536
2546
  ```
2537
2547
 
@@ -2553,9 +2563,7 @@ interface ContactSchema {
2553
2563
 
2554
2564
  **ConditionOperator** = ``
2555
2565
 
2556
- **FieldWidget** = `'text' | 'email' | 'tel' | 'select' | 'multiselect' | 'checkbox' | 'number' | 'date' | 'url'`
2557
-
2558
- **FieldType** = ``
2566
+ **ContactSchema** = `ContactSchemaResponse`
2559
2567
 
2560
2568
  ### crate
2561
2569
 
@@ -4965,15 +4973,15 @@ Logging: Append many communication events for a list of IDs. POST /admin/collect
4965
4973
  **publicUpdateMine**(collectionId: string,
4966
4974
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
4967
4975
 
4968
- **publicGetSchema**(collectionId: string) → `Promise<ContactSchema>`
4969
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4976
+ **publicGetSchema**(collectionId: string) → `Promise<ContactSchemaResponse>`
4977
+ 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 }) } ```
4970
4978
 
4971
4979
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
4972
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4980
+ 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 }) } ```
4973
4981
 
4974
4982
  **getUser**(collectionId: string,
4975
4983
  userId: string,) → `Promise<UserSearchResponse>`
4976
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4984
+ 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 }) } ```
4977
4985
 
4978
4986
  ### crate
4979
4987
 
@@ -131,61 +131,96 @@ export interface CommsState {
131
131
  }
132
132
  /**
133
133
  * Operators for conditional field visibility.
134
- * Use these to control when a custom field is shown based on another field's value.
134
+ * Used in ContactSchemaProperty.conditions[].operator.
135
135
  */
136
- export type ConditionOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'isEmpty' | 'isNotEmpty' | 'isTrue' | 'isFalse';
136
+ export type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'is_empty' | 'is_not_empty' | 'greater_than' | 'less_than';
137
137
  /**
138
- * Condition that determines when a field should be visible.
139
- * When present, the field only renders if the condition evaluates to true.
138
+ * A single visibility condition on a field.
139
+ * The field renders only when its conditions are satisfied (see `showWhen`).
140
140
  */
141
141
  export interface FieldCondition {
142
- dependsOn: string;
142
+ targetFieldId: string;
143
143
  operator: ConditionOperator;
144
- value?: string | string[];
144
+ value?: unknown;
145
145
  }
146
- export type FieldWidget = 'text' | 'email' | 'tel' | 'select' | 'multiselect' | 'checkbox' | 'number' | 'date' | 'url';
147
- export type FieldType = 'string' | 'url' | 'email' | 'tel' | 'text' | 'select' | 'checkbox' | 'boolean';
148
- export interface BaseField {
149
- key: string;
150
- label: string;
151
- type: FieldType;
152
- widget: FieldWidget;
153
- visible: boolean;
154
- editable: boolean;
155
- readOnly: boolean;
146
+ /**
147
+ * A single field property as returned by the contact schema endpoint.
148
+ * Follows JSON Schema conventions with rendering hints via `format`.
149
+ *
150
+ * Format values:
151
+ * (none) → plain text input
152
+ * email → email input
153
+ * uri → URL input
154
+ * tel → phone input
155
+ * date → date picker
156
+ * textarea → multi-line text
157
+ * select → single-select dropdown (requires `enum`)
158
+ * multiselect → multi-select (type will be 'array', requires `enum`)
159
+ * radio → radio button group (requires `enum`)
160
+ */
161
+ export interface ContactSchemaProperty {
162
+ type: 'string' | 'number' | 'boolean' | 'array';
163
+ title?: string;
164
+ description?: string;
165
+ format?: string;
166
+ enum?: string[];
167
+ conditions?: FieldCondition[];
168
+ showWhen?: 'all' | 'any';
156
169
  }
157
- export interface CoreField extends BaseField {
170
+ /**
171
+ * UI rendering hints for a single field, keyed by field ID in `uiSchema`.
172
+ */
173
+ export interface ContactUiSchemaEntry {
174
+ 'ui:disabled'?: true;
175
+ 'ui:placeholder'?: string;
176
+ [key: string]: unknown;
158
177
  }
159
178
  /**
160
- * Custom field definition returned by the schema endpoint.
179
+ * Response from GET /public/collection/:collectionId/contact/schema
180
+ *
181
+ * Core fields and collection-defined custom fields are merged into a single
182
+ * flat schema. Fields not in `publicVisibleFields` are stripped entirely.
183
+ * Fields visible but not in `publicEditableFields` have `ui:disabled: true`
184
+ * in `uiSchema`.
161
185
  */
162
- export interface CustomField extends BaseField {
163
- path: string;
164
- required: boolean;
165
- order?: number;
166
- options?: string[];
167
- placeholder?: string;
168
- description?: string;
169
- condition?: FieldCondition;
170
- }
171
- export interface ContactSchema {
172
- version: number;
173
- fields: CoreField[];
174
- customFields: CustomField[];
175
- settings: {
176
- publicVisibleFields: string[];
177
- publicEditableFields: string[];
178
- customFieldsVersion: number;
186
+ export interface ContactSchemaResponse {
187
+ schema: {
188
+ type: 'object';
189
+ required?: string[];
190
+ properties: Record<string, ContactSchemaProperty>;
179
191
  };
180
- }
192
+ uiSchema: Record<string, ContactUiSchemaEntry>;
193
+ /** Ordered list of field IDs — core fields first, then custom fields */
194
+ fieldOrder: string[];
195
+ /** Pass-through of the collection's SchemaFormConfig settings block */
196
+ settings: Record<string, unknown>;
197
+ /** Pass-through of the collection's SchemaFormConfig styling block */
198
+ styling: Record<string, unknown>;
199
+ }
200
+ /** @deprecated Use ContactSchemaResponse instead */
201
+ export type ContactSchema = ContactSchemaResponse;
181
202
  /**
182
- * Evaluate whether a field's condition is satisfied.
183
- * Returns true if the field should be visible.
203
+ * Evaluate whether a field's conditions are satisfied given the current form values.
204
+ * Returns `true` if the field should be visible.
205
+ *
206
+ * @param conditions The `conditions` array from a ContactSchemaProperty (may be undefined)
207
+ * @param showWhen 'all' requires every condition to pass; 'any' requires at least one
208
+ * @param fieldValues Current form values keyed by field ID
184
209
  *
185
210
  * @example
186
211
  * ```typescript
187
- * const field = schema.customFields.find(f => f.key === 'city')
188
- * const isVisible = evaluateCondition(field.condition, formValues)
212
+ * const property = schema.schema.properties[fieldId]
213
+ * const visible = evaluateConditions(property.conditions, property.showWhen, formValues)
189
214
  * ```
190
215
  */
191
- export declare function evaluateCondition(condition: FieldCondition | undefined, fieldValues: Record<string, any>): boolean;
216
+ export declare function evaluateConditions(conditions: FieldCondition[] | undefined, showWhen: 'all' | 'any' | undefined, fieldValues: Record<string, unknown>): boolean;
217
+ /**
218
+ * @deprecated Use evaluateConditions (plural) instead.
219
+ * Shim for code using the old single-condition API.
220
+ */
221
+ export declare function evaluateCondition(condition: {
222
+ dependsOn?: string;
223
+ targetFieldId?: string;
224
+ operator: string;
225
+ value?: unknown;
226
+ } | undefined, fieldValues: Record<string, unknown>): boolean;
@@ -1,35 +1,65 @@
1
1
  /**
2
- * Evaluate whether a field's condition is satisfied.
3
- * Returns true if the field should be visible.
2
+ * Evaluate whether a field's conditions are satisfied given the current form values.
3
+ * Returns `true` if the field should be visible.
4
+ *
5
+ * @param conditions The `conditions` array from a ContactSchemaProperty (may be undefined)
6
+ * @param showWhen 'all' requires every condition to pass; 'any' requires at least one
7
+ * @param fieldValues Current form values keyed by field ID
4
8
  *
5
9
  * @example
6
10
  * ```typescript
7
- * const field = schema.customFields.find(f => f.key === 'city')
8
- * const isVisible = evaluateCondition(field.condition, formValues)
11
+ * const property = schema.schema.properties[fieldId]
12
+ * const visible = evaluateConditions(property.conditions, property.showWhen, formValues)
9
13
  * ```
10
14
  */
15
+ export function evaluateConditions(conditions, showWhen, fieldValues) {
16
+ if (!conditions || conditions.length === 0)
17
+ return true;
18
+ const results = conditions.map(condition => {
19
+ const value = fieldValues[condition.targetFieldId];
20
+ switch (condition.operator) {
21
+ case 'is_empty':
22
+ return value == null || value === '' || (Array.isArray(value) && value.length === 0);
23
+ case 'is_not_empty':
24
+ return value != null && value !== '' && !(Array.isArray(value) && value.length === 0);
25
+ case 'equals':
26
+ return value === condition.value;
27
+ case 'not_equals':
28
+ return value !== condition.value;
29
+ case 'contains':
30
+ return Array.isArray(value)
31
+ ? value.includes(condition.value)
32
+ : typeof value === 'string' && value.includes(String(condition.value));
33
+ case 'not_contains':
34
+ return Array.isArray(value)
35
+ ? !value.includes(condition.value)
36
+ : typeof value === 'string' && !value.includes(String(condition.value));
37
+ case 'greater_than':
38
+ return typeof value === 'number' && typeof condition.value === 'number'
39
+ ? value > condition.value
40
+ : String(value) > String(condition.value);
41
+ case 'less_than':
42
+ return typeof value === 'number' && typeof condition.value === 'number'
43
+ ? value < condition.value
44
+ : String(value) < String(condition.value);
45
+ default:
46
+ return true;
47
+ }
48
+ });
49
+ return (showWhen !== null && showWhen !== void 0 ? showWhen : 'all') === 'any'
50
+ ? results.some(Boolean)
51
+ : results.every(Boolean);
52
+ }
53
+ /**
54
+ * @deprecated Use evaluateConditions (plural) instead.
55
+ * Shim for code using the old single-condition API.
56
+ */
11
57
  export function evaluateCondition(condition, fieldValues) {
58
+ var _a;
12
59
  if (!condition)
13
- return true; // No condition = always visible
14
- const value = fieldValues[condition.dependsOn];
15
- switch (condition.operator) {
16
- case 'isEmpty':
17
- return value == null || value === '' || (Array.isArray(value) && !value.length);
18
- case 'isNotEmpty':
19
- return value != null && value !== '' && !(Array.isArray(value) && !value.length);
20
- case 'isTrue':
21
- return value === true;
22
- case 'isFalse':
23
- return value === false;
24
- case 'equals':
25
- return value === condition.value;
26
- case 'notEquals':
27
- return value !== condition.value;
28
- case 'contains':
29
- return Array.isArray(value) && value.includes(condition.value);
30
- case 'notContains':
31
- return !Array.isArray(value) || !value.includes(condition.value);
32
- default:
33
- return true;
34
- }
60
+ return true;
61
+ const targetFieldId = (_a = condition.dependsOn) !== null && _a !== void 0 ? _a : condition.targetFieldId;
62
+ if (!targetFieldId)
63
+ return true;
64
+ return evaluateConditions([{ targetFieldId, operator: condition.operator, value: condition.value }], 'all', fieldValues);
35
65
  }
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.5.6 | Generated: 2026-02-26T08:32:23.437Z
3
+ Version: 1.6.0 | Generated: 2026-02-26T10:54:21.851Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -2502,36 +2502,46 @@ interface CommsState {
2502
2502
  **FieldCondition** (interface)
2503
2503
  ```typescript
2504
2504
  interface FieldCondition {
2505
- dependsOn: string // key of the field to check (not path)
2505
+ targetFieldId: string // The field whose value is tested
2506
2506
  operator: ConditionOperator
2507
- value?: string | string[] // required for equals/notEquals/contains/notContains
2507
+ value?: unknown // Required for equals / not_equals / contains / not_contains / greater_than / less_than
2508
2508
  }
2509
2509
  ```
2510
2510
 
2511
- **BaseField** (interface)
2511
+ **ContactSchemaProperty** (interface)
2512
2512
  ```typescript
2513
- interface BaseField {
2514
- key: string
2515
- label: string
2516
- type: FieldType
2517
- widget: FieldWidget
2518
- visible: boolean
2519
- editable: boolean
2520
- readOnly: boolean
2513
+ interface ContactSchemaProperty {
2514
+ type: 'string' | 'number' | 'boolean' | 'array'
2515
+ title?: string
2516
+ description?: string
2517
+ format?: string
2518
+ enum?: string[]
2519
+ conditions?: FieldCondition[]
2520
+ showWhen?: 'all' | 'any'
2521
+ }
2522
+ ```
2523
+
2524
+ **ContactUiSchemaEntry** (interface)
2525
+ ```typescript
2526
+ interface ContactUiSchemaEntry {
2527
+ 'ui:disabled'?: true // Field is visible but not editable
2528
+ 'ui:placeholder'?: string // Placeholder text
2529
+ [key: string]: unknown // Forward-compatible with additional rjsf hints
2521
2530
  }
2522
2531
  ```
2523
2532
 
2524
- **ContactSchema** (interface)
2533
+ **ContactSchemaResponse** (interface)
2525
2534
  ```typescript
2526
- interface ContactSchema {
2527
- version: number // 1
2528
- fields: CoreField[] // core fields
2529
- customFields: CustomField[]
2530
- settings: {
2531
- publicVisibleFields: string[]
2532
- publicEditableFields: string[]
2533
- customFieldsVersion: number
2535
+ interface ContactSchemaResponse {
2536
+ schema: {
2537
+ type: 'object'
2538
+ required?: string[]
2539
+ properties: Record<string, ContactSchemaProperty>
2534
2540
  }
2541
+ uiSchema: Record<string, ContactUiSchemaEntry>
2542
+ fieldOrder: string[]
2543
+ settings: Record<string, unknown>
2544
+ styling: Record<string, unknown>
2535
2545
  }
2536
2546
  ```
2537
2547
 
@@ -2553,9 +2563,7 @@ interface ContactSchema {
2553
2563
 
2554
2564
  **ConditionOperator** = ``
2555
2565
 
2556
- **FieldWidget** = `'text' | 'email' | 'tel' | 'select' | 'multiselect' | 'checkbox' | 'number' | 'date' | 'url'`
2557
-
2558
- **FieldType** = ``
2566
+ **ContactSchema** = `ContactSchemaResponse`
2559
2567
 
2560
2568
  ### crate
2561
2569
 
@@ -4965,15 +4973,15 @@ Logging: Append many communication events for a list of IDs. POST /admin/collect
4965
4973
  **publicUpdateMine**(collectionId: string,
4966
4974
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
4967
4975
 
4968
- **publicGetSchema**(collectionId: string) → `Promise<ContactSchema>`
4969
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4976
+ **publicGetSchema**(collectionId: string) → `Promise<ContactSchemaResponse>`
4977
+ 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 }) } ```
4970
4978
 
4971
4979
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
4972
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4980
+ 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 }) } ```
4973
4981
 
4974
4982
  **getUser**(collectionId: string,
4975
4983
  userId: string,) → `Promise<UserSearchResponse>`
4976
- Public: Get contact update schema for a collection Fetches the public contact schema including core fields, custom fields with conditional visibility rules, and visibility/editability settings. Custom fields may include a `condition` property that specifies when the field should be displayed. Apps rendering these forms should: 1. Evaluate each field's `condition` against current form values 2. Hide fields whose conditions are not met 3. Skip validation for hidden fields (they shouldn't be required when not visible)
4984
+ 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 }) } ```
4977
4985
 
4978
4986
  ### crate
4979
4987
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.5.6",
3
+ "version": "1.6.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",