@proveanything/smartlinks 1.0.61 → 1.0.63

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/API_SUMMARY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.0.61 | Generated: 2025-12-11T14:28:56.705Z
3
+ Version: 1.0.63 | Generated: 2025-12-17T18:37:00.024Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -19,6 +19,7 @@ The Smartlinks SDK is organized into the following namespaces:
19
19
  - **claimSet** - Claim creation, management, and verification
20
20
  - **collection** - Collection CRUD operations and management
21
21
  - **comms** - Functions for comms operations
22
+ - **contact** - Functions for contact operations
22
23
  - **crate** - Container/crate management for organizing products
23
24
  - **form** - Dynamic form creation and submission
24
25
  - **nfc** - Functions for nfc operations
@@ -65,6 +66,11 @@ Internal helper that performs a POST request to `${baseURL}${path}`, injecting h
65
66
  extraHeaders?: Record<string, string>) → `Promise<T>`
66
67
  Internal helper that performs a PUT request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. If body is FormData, Content-Type is not set. Returns the parsed JSON as T, or throws an Error.
67
68
 
69
+ **patch**(path: string,
70
+ body: any,
71
+ extraHeaders?: Record<string, string>) → `Promise<T>`
72
+ Internal helper that performs a PATCH request to `${baseURL}${path}`, injecting headers for apiKey or bearerToken if present. If body is FormData, Content-Type is not set. Returns the parsed JSON as T, or throws an Error.
73
+
68
74
  **requestWithOptions**(path: string,
69
75
  options: RequestInit) → `Promise<T>`
70
76
  Internal helper that performs a request to `${baseURL}${path}` with custom options, injecting headers for apiKey or bearerToken if present. Returns the parsed JSON as T, or throws an Error.
@@ -485,6 +491,66 @@ interface SendNotificationResponse {
485
491
  }
486
492
  ```
487
493
 
494
+ ### contact
495
+
496
+ **ContactResponse** (interface)
497
+ ```typescript
498
+ interface ContactResponse {
499
+ contactId: string
500
+ orgId: string
501
+ firstName: string | null
502
+ lastName: string | null
503
+ displayName: string | null
504
+ company: string | null
505
+ email: string | null
506
+ phone: string | null
507
+ emails?: string[]
508
+ phones?: string[]
509
+ customFields: ContactCustomFields
510
+ createdAt: string
511
+ updatedAt: string
512
+ deletedAt: string | null
513
+ erasedAt: string | null
514
+ }
515
+ ```
516
+
517
+ **ContactCreateRequest** (interface)
518
+ ```typescript
519
+ interface ContactCreateRequest {
520
+ firstName?: string | null
521
+ lastName?: string | null
522
+ displayName?: string | null
523
+ company?: string | null
524
+ email?: string | null
525
+ phone?: string | null
526
+ customFields?: ContactCustomFields
527
+ }
528
+ ```
529
+
530
+ **ContactUpdateRequest** (interface)
531
+ ```typescript
532
+ interface ContactUpdateRequest {
533
+ firstName?: string | null
534
+ lastName?: string | null
535
+ displayName?: string | null
536
+ company?: string | null
537
+ email?: string | null
538
+ phone?: string | null
539
+ customFields?: ContactCustomFields
540
+ }
541
+ ```
542
+
543
+ **ContactListResponse** (interface)
544
+ ```typescript
545
+ interface ContactListResponse {
546
+ items: ContactResponse[]
547
+ limit: number
548
+ offset: number
549
+ }
550
+ ```
551
+
552
+ **ContactCustomFields** = `Record<string, any>`
553
+
488
554
  ### error
489
555
 
490
556
  **ErrorResponse** (interface)
@@ -1089,6 +1155,31 @@ Assign a value to a serial number for a collection (admin only).
1089
1155
  request: SendNotificationRequest) → `Promise<SendNotificationResponse>`
1090
1156
  Send a notification to specified targets within a collection. Supports multiple delivery methods including push notifications, email, and wallet pass updates. The notification will be delivered based on user preferences and the specified delivery mode. ```typescript const result = await comms.sendNotification('my-collection', { subjectTargets: [{ type: 'product', id: 'prod_123' }], severity: 'important', mode: 'preferred', template: { push: { title: 'Update available', body: 'We\'ve shipped an important update.', icon: 'https://cdn.example.com/brand/logo-128.png' }, email: { subject: 'Important update for your product', body: 'There\'s an important update. Open your pass or profile to learn more.' }, walletUpdate: { textModulesData: [ { id: 'notice', header: 'Update', body: 'Open your wallet pass for details.' } ] } } }) if (result.ok) { console.log('Notification queued:', result.notificationId) console.log('Totals:', result.status.totals) } ```
1091
1157
 
1158
+ ### contact
1159
+
1160
+ **create**(collectionId: string, data: ContactCreateRequest) → `Promise<ContactResponse>`
1161
+
1162
+ **list**(collectionId: string,
1163
+ params?: { limit?: number; offset?: number; includeDeleted?: boolean }) → `Promise<ContactListResponse>`
1164
+
1165
+ **get**(collectionId: string,
1166
+ contactId: string,
1167
+ params?: { includeDeleted?: boolean }) → `Promise<ContactResponse>`
1168
+
1169
+ **update**(collectionId: string,
1170
+ contactId: string,
1171
+ data: ContactUpdateRequest) → `Promise<ContactResponse>`
1172
+
1173
+ **remove**(collectionId: string, contactId: string) → `Promise<void>`
1174
+
1175
+ **lookup**(collectionId: string,
1176
+ params: { email?: string; phone?: string }) → `Promise<ContactResponse>`
1177
+
1178
+ **upsert**(collectionId: string,
1179
+ data: ContactCreateRequest) → `Promise<ContactResponse>`
1180
+
1181
+ **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
1182
+
1092
1183
  ### crate
1093
1184
 
1094
1185
  **get**(collectionId: string, crateId: string) → `Promise<any>`
@@ -0,0 +1,20 @@
1
+ import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse } from "../types";
2
+ export declare namespace contact {
3
+ function create(collectionId: string, data: ContactCreateRequest): Promise<ContactResponse>;
4
+ function list(collectionId: string, params?: {
5
+ limit?: number;
6
+ offset?: number;
7
+ includeDeleted?: boolean;
8
+ }): Promise<ContactListResponse>;
9
+ function get(collectionId: string, contactId: string, params?: {
10
+ includeDeleted?: boolean;
11
+ }): Promise<ContactResponse>;
12
+ function update(collectionId: string, contactId: string, data: ContactUpdateRequest): Promise<ContactResponse>;
13
+ function remove(collectionId: string, contactId: string): Promise<void>;
14
+ function lookup(collectionId: string, params: {
15
+ email?: string;
16
+ phone?: string;
17
+ }): Promise<ContactResponse>;
18
+ function upsert(collectionId: string, data: ContactCreateRequest): Promise<ContactResponse>;
19
+ function erase(collectionId: string, contactId: string, body?: any): Promise<ContactResponse>;
20
+ }
@@ -0,0 +1,61 @@
1
+ import { request, post, del, patch } from "../http";
2
+ export var contact;
3
+ (function (contact) {
4
+ async function create(collectionId, data) {
5
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts`;
6
+ return post(path, data);
7
+ }
8
+ contact.create = create;
9
+ async function list(collectionId, params) {
10
+ const query = new URLSearchParams();
11
+ if ((params === null || params === void 0 ? void 0 : params.limit) !== undefined)
12
+ query.set("limit", String(params.limit));
13
+ if ((params === null || params === void 0 ? void 0 : params.offset) !== undefined)
14
+ query.set("offset", String(params.offset));
15
+ if ((params === null || params === void 0 ? void 0 : params.includeDeleted) !== undefined)
16
+ query.set("includeDeleted", String(params.includeDeleted));
17
+ const qs = query.toString();
18
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts${qs ? `?${qs}` : ""}`;
19
+ return request(path);
20
+ }
21
+ contact.list = list;
22
+ async function get(collectionId, contactId, params) {
23
+ const query = new URLSearchParams();
24
+ if ((params === null || params === void 0 ? void 0 : params.includeDeleted) !== undefined)
25
+ query.set("includeDeleted", String(params.includeDeleted));
26
+ const qs = query.toString();
27
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts/${encodeURIComponent(contactId)}${qs ? `?${qs}` : ""}`;
28
+ return request(path);
29
+ }
30
+ contact.get = get;
31
+ async function update(collectionId, contactId, data) {
32
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts/${encodeURIComponent(contactId)}`;
33
+ return patch(path, data);
34
+ }
35
+ contact.update = update;
36
+ async function remove(collectionId, contactId) {
37
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts/${encodeURIComponent(contactId)}`;
38
+ return del(path);
39
+ }
40
+ contact.remove = remove;
41
+ async function lookup(collectionId, params) {
42
+ const query = new URLSearchParams();
43
+ if (params.email)
44
+ query.set("email", params.email);
45
+ if (params.phone)
46
+ query.set("phone", params.phone);
47
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts/lookup?${query.toString()}`;
48
+ return request(path);
49
+ }
50
+ contact.lookup = lookup;
51
+ async function upsert(collectionId, data) {
52
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts:upsert`;
53
+ return post(path, data);
54
+ }
55
+ contact.upsert = upsert;
56
+ async function erase(collectionId, contactId, body) {
57
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/crm/contacts/${encodeURIComponent(contactId)}/erase`;
58
+ return post(path, body || {});
59
+ }
60
+ contact.erase = erase;
61
+ })(contact || (contact = {}));
@@ -15,4 +15,5 @@ export { variant } from "./variant";
15
15
  export { ai } from "./ai";
16
16
  export { comms } from "./comms";
17
17
  export { nfc } from "./nfc";
18
+ export { contact } from "./contact";
18
19
  export type { AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "./ai";
package/dist/api/index.js CHANGED
@@ -17,3 +17,4 @@ export { variant } from "./variant";
17
17
  export { ai } from "./ai";
18
18
  export { comms } from "./comms";
19
19
  export { nfc } from "./nfc";
20
+ export { contact } from "./contact";
package/dist/http.d.ts CHANGED
@@ -43,6 +43,13 @@ export declare function post<T>(path: string, body: any, extraHeaders?: Record<s
43
43
  * Returns the parsed JSON as T, or throws an Error.
44
44
  */
45
45
  export declare function put<T>(path: string, body: any, extraHeaders?: Record<string, string>): Promise<T>;
46
+ /**
47
+ * Internal helper that performs a PATCH request to `${baseURL}${path}`,
48
+ * injecting headers for apiKey or bearerToken if present.
49
+ * If body is FormData, Content-Type is not set.
50
+ * Returns the parsed JSON as T, or throws an Error.
51
+ */
52
+ export declare function patch<T>(path: string, body: any, extraHeaders?: Record<string, string>): Promise<T>;
46
53
  /**
47
54
  * Internal helper that performs a request to `${baseURL}${path}` with custom options,
48
55
  * injecting headers for apiKey or bearerToken if present.
package/dist/http.js CHANGED
@@ -292,6 +292,53 @@ export async function put(path, body, extraHeaders) {
292
292
  }
293
293
  return (await response.json());
294
294
  }
295
+ /**
296
+ * Internal helper that performs a PATCH request to `${baseURL}${path}`,
297
+ * injecting headers for apiKey or bearerToken if present.
298
+ * If body is FormData, Content-Type is not set.
299
+ * Returns the parsed JSON as T, or throws an Error.
300
+ */
301
+ export async function patch(path, body, extraHeaders) {
302
+ if (proxyMode) {
303
+ logDebug('[smartlinks] PATCH via proxy', { path, body: safeBodyPreview(body) });
304
+ return proxyRequest("PATCH", path, body, extraHeaders);
305
+ }
306
+ if (!baseURL) {
307
+ throw new Error("HTTP client is not initialized. Call initializeApi(...) first.");
308
+ }
309
+ const url = `${baseURL}${path}`;
310
+ const headers = extraHeaders ? Object.assign({}, extraHeaders) : {};
311
+ if (apiKey)
312
+ headers["X-API-Key"] = apiKey;
313
+ if (bearerToken)
314
+ headers["AUTHORIZATION"] = `Bearer ${bearerToken}`;
315
+ if (ngrokSkipBrowserWarning)
316
+ headers["ngrok-skip-browser-warning"] = "true";
317
+ for (const [k, v] of Object.entries(extraHeadersGlobal))
318
+ if (!(k in headers))
319
+ headers[k] = v;
320
+ // Only set Content-Type for non-FormData bodies
321
+ if (!(body instanceof FormData)) {
322
+ headers["Content-Type"] = "application/json";
323
+ }
324
+ logDebug('[smartlinks] PATCH fetch', { url, headers: redactHeaders(headers), body: safeBodyPreview(body) });
325
+ const response = await fetch(url, {
326
+ method: "PATCH",
327
+ headers,
328
+ body: body instanceof FormData ? body : JSON.stringify(body),
329
+ });
330
+ logDebug('[smartlinks] PATCH response', { url, status: response.status, ok: response.ok });
331
+ if (!response.ok) {
332
+ try {
333
+ const errBody = (await response.json());
334
+ throw new Error(`Error ${errBody.code}: ${errBody.message}`);
335
+ }
336
+ catch (_a) {
337
+ throw new Error(`Request to ${url} failed with status ${response.status}`);
338
+ }
339
+ }
340
+ return (await response.json());
341
+ }
295
342
  /**
296
343
  * Internal helper that performs a request to `${baseURL}${path}` with custom options,
297
344
  * injecting headers for apiKey or bearerToken if present.
@@ -0,0 +1,41 @@
1
+ export type ContactCustomFields = Record<string, any>;
2
+ export interface ContactResponse {
3
+ contactId: string;
4
+ orgId: string;
5
+ firstName: string | null;
6
+ lastName: string | null;
7
+ displayName: string | null;
8
+ company: string | null;
9
+ email: string | null;
10
+ phone: string | null;
11
+ emails?: string[];
12
+ phones?: string[];
13
+ customFields: ContactCustomFields;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ deletedAt: string | null;
17
+ erasedAt: string | null;
18
+ }
19
+ export interface ContactCreateRequest {
20
+ firstName?: string | null;
21
+ lastName?: string | null;
22
+ displayName?: string | null;
23
+ company?: string | null;
24
+ email?: string | null;
25
+ phone?: string | null;
26
+ customFields?: ContactCustomFields;
27
+ }
28
+ export interface ContactUpdateRequest {
29
+ firstName?: string | null;
30
+ lastName?: string | null;
31
+ displayName?: string | null;
32
+ company?: string | null;
33
+ email?: string | null;
34
+ phone?: string | null;
35
+ customFields?: ContactCustomFields;
36
+ }
37
+ export interface ContactListResponse {
38
+ items: ContactResponse[];
39
+ limit: number;
40
+ offset: number;
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -10,3 +10,4 @@ export * from "./claimSet";
10
10
  export * from "./auth";
11
11
  export * from "./comms";
12
12
  export * from "./nfc";
13
+ export * from "./contact";
@@ -12,3 +12,4 @@ export * from "./claimSet";
12
12
  export * from "./auth";
13
13
  export * from "./comms";
14
14
  export * from "./nfc";
15
+ export * from "./contact";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",