@proveanything/smartlinks 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -129,7 +129,21 @@ export interface CommsState {
129
129
  /** Keyed by `_default` or `${type}_${id}` */
130
130
  preferences?: Record<string, PreferenceEntry>;
131
131
  }
132
- export type FieldWidget = 'text' | 'email' | 'tel' | 'select' | 'checkbox';
132
+ /**
133
+ * Operators for conditional field visibility.
134
+ * Use these to control when a custom field is shown based on another field's value.
135
+ */
136
+ export type ConditionOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'isEmpty' | 'isNotEmpty' | 'isTrue' | 'isFalse';
137
+ /**
138
+ * Condition that determines when a field should be visible.
139
+ * When present, the field only renders if the condition evaluates to true.
140
+ */
141
+ export interface FieldCondition {
142
+ dependsOn: string;
143
+ operator: ConditionOperator;
144
+ value?: string | string[];
145
+ }
146
+ export type FieldWidget = 'text' | 'email' | 'tel' | 'select' | 'multiselect' | 'checkbox' | 'number' | 'date' | 'url';
133
147
  export type FieldType = 'string' | 'url' | 'email' | 'tel' | 'text' | 'select' | 'checkbox' | 'boolean';
134
148
  export interface BaseField {
135
149
  key: string;
@@ -142,11 +156,17 @@ export interface BaseField {
142
156
  }
143
157
  export interface CoreField extends BaseField {
144
158
  }
159
+ /**
160
+ * Custom field definition returned by the schema endpoint.
161
+ */
145
162
  export interface CustomField extends BaseField {
146
163
  path: string;
147
164
  required: boolean;
148
165
  order?: number;
149
166
  options?: string[];
167
+ placeholder?: string;
168
+ description?: string;
169
+ condition?: FieldCondition;
150
170
  }
151
171
  export interface ContactSchema {
152
172
  version: number;
@@ -158,3 +178,14 @@ export interface ContactSchema {
158
178
  customFieldsVersion: number;
159
179
  };
160
180
  }
181
+ /**
182
+ * Evaluate whether a field's condition is satisfied.
183
+ * Returns true if the field should be visible.
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const field = schema.customFields.find(f => f.key === 'city')
188
+ * const isVisible = evaluateCondition(field.condition, formValues)
189
+ * ```
190
+ */
191
+ export declare function evaluateCondition(condition: FieldCondition | undefined, fieldValues: Record<string, any>): boolean;
@@ -1 +1,35 @@
1
- export {};
1
+ /**
2
+ * Evaluate whether a field's condition is satisfied.
3
+ * Returns true if the field should be visible.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const field = schema.customFields.find(f => f.key === 'city')
8
+ * const isVisible = evaluateCondition(field.condition, formValues)
9
+ * ```
10
+ */
11
+ export function evaluateCondition(condition, fieldValues) {
12
+ 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
+ }
35
+ }
@@ -22,3 +22,5 @@ export * from "./interaction";
22
22
  export * from "./location";
23
23
  export * from "./jobs";
24
24
  export * from "./realtime";
25
+ export * from "./tags";
26
+ export * from "./order";
@@ -24,3 +24,5 @@ export * from "./interaction";
24
24
  export * from "./location";
25
25
  export * from "./jobs";
26
26
  export * from "./realtime";
27
+ export * from "./tags";
28
+ export * from "./order";
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Order Management Types
3
+ *
4
+ * Types for grouping scanned tags, proofs, or serial numbers into orders
5
+ * with flexible metadata.
6
+ */
7
+ /**
8
+ * Represents a single item within an order.
9
+ */
10
+ export interface OrderItem {
11
+ id: string;
12
+ orderId: string;
13
+ itemType: 'tag' | 'proof' | 'serial';
14
+ itemId: string;
15
+ metadata: Record<string, any>;
16
+ createdAt: string;
17
+ }
18
+ /**
19
+ * Represents an order containing multiple items.
20
+ */
21
+ export interface Order {
22
+ id: string;
23
+ orgId: string;
24
+ collectionId: string;
25
+ orderRef?: string;
26
+ customerId?: string;
27
+ status: string;
28
+ itemCount: number;
29
+ metadata: Record<string, any>;
30
+ items: OrderItem[];
31
+ createdAt: string;
32
+ updatedAt: string;
33
+ }
34
+ /**
35
+ * Request to create a new order with items.
36
+ */
37
+ export interface CreateOrderRequest {
38
+ items: Array<{
39
+ itemType: 'tag' | 'proof' | 'serial';
40
+ itemId: string;
41
+ metadata?: Record<string, any>;
42
+ }>;
43
+ orderRef?: string;
44
+ customerId?: string;
45
+ status?: string;
46
+ metadata?: Record<string, any>;
47
+ }
48
+ /**
49
+ * Response from creating an order.
50
+ */
51
+ export interface CreateOrderResponse extends Order {
52
+ }
53
+ /**
54
+ * Response from getting a single order.
55
+ */
56
+ export interface GetOrderResponse extends Order {
57
+ }
58
+ /**
59
+ * Request to update an existing order.
60
+ * Items are managed separately via add/remove endpoints.
61
+ */
62
+ export interface UpdateOrderRequest {
63
+ orderRef?: string;
64
+ customerId?: string;
65
+ status?: string;
66
+ metadata?: Record<string, any>;
67
+ }
68
+ /**
69
+ * Response from updating an order.
70
+ */
71
+ export interface UpdateOrderResponse extends Order {
72
+ }
73
+ /**
74
+ * Response from deleting an order.
75
+ */
76
+ export interface DeleteOrderResponse {
77
+ success: boolean;
78
+ }
79
+ /**
80
+ * Request parameters for listing orders.
81
+ */
82
+ export interface ListOrdersRequest {
83
+ limit?: number;
84
+ offset?: number;
85
+ status?: string;
86
+ orderRef?: string;
87
+ customerId?: string;
88
+ }
89
+ /**
90
+ * Response from listing orders.
91
+ */
92
+ export interface ListOrdersResponse {
93
+ orders: Order[];
94
+ limit: number;
95
+ offset: number;
96
+ }
97
+ /**
98
+ * Request to add items to an existing order.
99
+ */
100
+ export interface AddItemsRequest {
101
+ items: Array<{
102
+ itemType: 'tag' | 'proof' | 'serial';
103
+ itemId: string;
104
+ metadata?: Record<string, any>;
105
+ }>;
106
+ }
107
+ /**
108
+ * Response from adding items to an order.
109
+ */
110
+ export interface AddItemsResponse extends Order {
111
+ }
112
+ /**
113
+ * Request to remove items from an order.
114
+ */
115
+ export interface RemoveItemsRequest {
116
+ itemIds: string[];
117
+ }
118
+ /**
119
+ * Response from removing items from an order.
120
+ */
121
+ export interface RemoveItemsResponse extends Order {
122
+ }
123
+ /**
124
+ * Request to lookup orders by item.
125
+ */
126
+ export interface LookupOrdersRequest {
127
+ items: Array<{
128
+ itemType: 'tag' | 'proof' | 'serial';
129
+ itemId: string;
130
+ }>;
131
+ }
132
+ /**
133
+ * Response from looking up orders by item.
134
+ */
135
+ export interface LookupOrdersResponse {
136
+ orders: Order[];
137
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Order Management Types
3
+ *
4
+ * Types for grouping scanned tags, proofs, or serial numbers into orders
5
+ * with flexible metadata.
6
+ */
7
+ export {};
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Tag Management Types
3
+ *
4
+ * Types for creating mappings between physical tags (NFC tags, QR codes, etc.)
5
+ * and digital proofs.
6
+ */
7
+ /**
8
+ * Represents a tag mapping in the system.
9
+ */
10
+ export interface Tag {
11
+ id: string;
12
+ orgId: string;
13
+ tagId: string;
14
+ collectionId: string;
15
+ productId: string;
16
+ variantId?: string | null;
17
+ batchId?: string | null;
18
+ proofId: string;
19
+ metadata: Record<string, any>;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ }
23
+ /**
24
+ * Request to create a single tag mapping.
25
+ * If proofId is not provided, automatically generates a serial number.
26
+ */
27
+ export interface CreateTagRequest {
28
+ tagId: string;
29
+ productId: string;
30
+ variantId?: string;
31
+ batchId?: string;
32
+ proofId?: string;
33
+ useSerialNumber?: boolean;
34
+ metadata?: Record<string, any>;
35
+ force?: boolean;
36
+ }
37
+ /**
38
+ * Response from creating a single tag.
39
+ */
40
+ export interface CreateTagResponse extends Tag {
41
+ wasUpdated?: boolean;
42
+ }
43
+ /**
44
+ * Request to create multiple tag mappings efficiently.
45
+ * By default, auto-generates serial numbers for all tags without explicit proofId.
46
+ */
47
+ export interface CreateTagsBatchRequest {
48
+ tags: Array<{
49
+ tagId: string;
50
+ productId: string;
51
+ variantId?: string;
52
+ batchId?: string;
53
+ proofId?: string;
54
+ metadata?: Record<string, any>;
55
+ }>;
56
+ force?: boolean;
57
+ }
58
+ /**
59
+ * Response from batch creating tags.
60
+ */
61
+ export interface CreateTagsBatchResponse {
62
+ summary: {
63
+ total: number;
64
+ created: number;
65
+ updated: number;
66
+ failed: number;
67
+ conflicts: number;
68
+ };
69
+ results: {
70
+ created: Tag[];
71
+ updated: Tag[];
72
+ failed: Array<{
73
+ tagId: string;
74
+ reason: string;
75
+ message: string;
76
+ existingTag?: Tag;
77
+ }>;
78
+ conflicts: Array<{
79
+ tagId: string;
80
+ reason: string;
81
+ message: string;
82
+ existingTag: Tag;
83
+ }>;
84
+ };
85
+ }
86
+ /**
87
+ * Request to update an existing tag mapping.
88
+ */
89
+ export interface UpdateTagRequest {
90
+ productId?: string;
91
+ variantId?: string | null;
92
+ batchId?: string | null;
93
+ proofId?: string;
94
+ metadata?: Record<string, any>;
95
+ }
96
+ /**
97
+ * Response from updating a tag.
98
+ */
99
+ export interface UpdateTagResponse extends Tag {
100
+ }
101
+ /**
102
+ * Response from deleting a tag.
103
+ */
104
+ export interface DeleteTagResponse {
105
+ success: boolean;
106
+ }
107
+ /**
108
+ * Response from getting a single tag.
109
+ */
110
+ export interface GetTagResponse extends Tag {
111
+ }
112
+ /**
113
+ * Request parameters for listing tags.
114
+ */
115
+ export interface ListTagsRequest {
116
+ limit?: number;
117
+ offset?: number;
118
+ productId?: string;
119
+ variantId?: string;
120
+ batchId?: string;
121
+ }
122
+ /**
123
+ * Response from listing tags.
124
+ */
125
+ export interface ListTagsResponse {
126
+ tags: Tag[];
127
+ limit: number;
128
+ offset: number;
129
+ }
130
+ /**
131
+ * Request parameters for public tag lookup.
132
+ */
133
+ export interface PublicGetTagRequest {
134
+ embed?: string;
135
+ }
136
+ /**
137
+ * Response from public tag lookup with optional embedded data.
138
+ */
139
+ export interface PublicGetTagResponse {
140
+ tag: Tag;
141
+ collection?: any;
142
+ product?: any;
143
+ proof?: any;
144
+ }
145
+ /**
146
+ * Request to lookup multiple tags in a single request.
147
+ */
148
+ export interface PublicBatchLookupRequest {
149
+ tagIds: string[];
150
+ embed?: string;
151
+ }
152
+ /**
153
+ * Response from batch lookup with deduplicated related data.
154
+ */
155
+ export interface PublicBatchLookupResponse {
156
+ tags: Record<string, Tag>;
157
+ collections?: Record<string, any>;
158
+ products?: Record<string, any>;
159
+ proofs?: Record<string, any>;
160
+ }
161
+ /**
162
+ * Query parameters for public batch lookup (GET).
163
+ */
164
+ export interface PublicBatchLookupQueryRequest {
165
+ tagIds: string;
166
+ embed?: string;
167
+ }
168
+ /**
169
+ * Response from public batch lookup (GET).
170
+ */
171
+ export interface PublicBatchLookupQueryResponse extends PublicBatchLookupResponse {
172
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tag Management Types
3
+ *
4
+ * Types for creating mappings between physical tags (NFC tags, QR codes, etc.)
5
+ * and digital proofs.
6
+ */
7
+ export {};