@explorins/pers-sdk 2.1.40 → 2.2.0-alpha.1

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 (33) hide show
  1. package/dist/chunks/{pers-sdk-DuDWwRWC.js → pers-sdk-CBRtrG03.js} +458 -4
  2. package/dist/chunks/pers-sdk-CBRtrG03.js.map +1 -0
  3. package/dist/chunks/{pers-sdk-CBvzmlL_.cjs → pers-sdk-DcNDMx1Y.cjs} +457 -2
  4. package/dist/chunks/pers-sdk-DcNDMx1Y.cjs.map +1 -0
  5. package/dist/core/events/event-types.d.ts +5 -1
  6. package/dist/core/events/event-types.d.ts.map +1 -1
  7. package/dist/core.cjs +2 -1
  8. package/dist/core.cjs.map +1 -1
  9. package/dist/core.js +1 -1
  10. package/dist/custom-field/api/custom-field-api.d.ts +58 -0
  11. package/dist/custom-field/api/custom-field-api.d.ts.map +1 -0
  12. package/dist/custom-field/index.d.ts +2 -0
  13. package/dist/custom-field/index.d.ts.map +1 -0
  14. package/dist/index.cjs +141 -26
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +82 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/managers/custom-field-definition-manager.d.ts +317 -0
  19. package/dist/managers/custom-field-definition-manager.d.ts.map +1 -0
  20. package/dist/managers/index.d.ts +1 -0
  21. package/dist/managers/index.d.ts.map +1 -1
  22. package/dist/node.cjs +1 -1
  23. package/dist/node.js +1 -1
  24. package/dist/package.json +2 -2
  25. package/dist/pers-sdk.d.ts +28 -1
  26. package/dist/pers-sdk.d.ts.map +1 -1
  27. package/dist/shared/index.d.ts +1 -0
  28. package/dist/shared/index.d.ts.map +1 -1
  29. package/dist/shared/utils/image-url-utils.d.ts +76 -0
  30. package/dist/shared/utils/image-url-utils.d.ts.map +1 -0
  31. package/package.json +2 -2
  32. package/dist/chunks/pers-sdk-CBvzmlL_.cjs.map +0 -1
  33. package/dist/chunks/pers-sdk-DuDWwRWC.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persSdk = require('./chunks/pers-sdk-CBvzmlL_.cjs');
3
+ var persSdk = require('./chunks/pers-sdk-DcNDMx1Y.cjs');
4
4
  var persShared = require('@explorins/pers-shared');
5
5
  var environment = require('./chunks/environment-C_hPDl8L.cjs');
6
6
  var index = require('./chunks/index-C4K-jkRO.cjs');
@@ -22,7 +22,82 @@ var triggerSource = require('./trigger-source.cjs');
22
22
  var platformAdapters = require('./platform-adapters.cjs');
23
23
  var nodeHttpClient = require('./chunks/node-http-client-D_avaa5F.cjs');
24
24
 
25
-
25
+ /**
26
+ * Build optimized image URL with automatic IPFS resolution and CDN options
27
+ *
28
+ * Single entry point for all image URL building:
29
+ * - IPFS URIs → resolved via gateway + CDN options applied
30
+ * - HTTP URLs → CDN options applied directly
31
+ *
32
+ * @param url - Image URL (ipfs://, https://, or any URL)
33
+ * @param options - CDN optimization options (preset, quality, format, fit)
34
+ * @param gateway - IPFS gateway domain (required for ipfs:// URLs)
35
+ * @returns Optimized URL with query parameters
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // IPFS thumbnail
40
+ * buildImageUrl('ipfs://QmHash', { preset: 'thumb' }, 'cdn.example.com')
41
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=thumb'
42
+ *
43
+ * // IPFS hero with high quality
44
+ * buildImageUrl('ipfs://QmHash', { preset: 'hero', q: 95, fit: 'cover' }, 'cdn.example.com')
45
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=hero&q=95&fit=cover'
46
+ *
47
+ * // HTTP URL (gateway ignored)
48
+ * buildImageUrl('https://example.com/photo.jpg', { preset: 'card' })
49
+ * // => 'https://example.com/photo.jpg?preset=card'
50
+ *
51
+ * // No options - just IPFS resolution
52
+ * buildImageUrl('ipfs://QmHash', undefined, 'cdn.example.com')
53
+ * // => 'https://cdn.example.com/ipfs/QmHash'
54
+ * ```
55
+ */
56
+ function buildImageUrl(url, options, gateway) {
57
+ if (!url)
58
+ return '';
59
+ let resolvedUrl = url;
60
+ // Resolve IPFS to HTTP via gateway
61
+ if (url.startsWith('ipfs://')) {
62
+ if (!gateway) {
63
+ console.warn('[buildImageUrl] IPFS URL requires gateway parameter');
64
+ return url;
65
+ }
66
+ const cid = url.replace('ipfs://', '');
67
+ resolvedUrl = `https://${gateway}/ipfs/${cid}`;
68
+ }
69
+ // Apply CDN options
70
+ return persShared.buildImageCdnUrl(resolvedUrl, options);
71
+ }
72
+ /**
73
+ * Check if a URL is an IPFS URI
74
+ *
75
+ * @param url - URL to check
76
+ * @returns True if URL starts with ipfs://
77
+ */
78
+ function isIpfsUrl(url) {
79
+ return !!url && url.startsWith('ipfs://');
80
+ }
81
+ /**
82
+ * Extract CID from IPFS URI
83
+ *
84
+ * @param ipfsUri - IPFS URI (ipfs://Qm... or ipfs://baf...)
85
+ * @returns CID string, or null if not a valid IPFS URI
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * extractIpfsCid('ipfs://QmHash123')
90
+ * // => 'QmHash123'
91
+ *
92
+ * extractIpfsCid('https://example.com/image.jpg')
93
+ * // => null
94
+ * ```
95
+ */
96
+ function extractIpfsCid(ipfsUri) {
97
+ if (!isIpfsUrl(ipfsUri))
98
+ return null;
99
+ return ipfsUri.replace('ipfs://', '');
100
+ }
26
101
 
27
102
  exports.AUTH_STORAGE_KEYS = persSdk.AUTH_STORAGE_KEYS;
28
103
  exports.AnalyticsManager = persSdk.AnalyticsManager;
@@ -32,12 +107,13 @@ exports.AuthApi = persSdk.AuthApi;
32
107
  exports.AuthManager = persSdk.AuthManager;
33
108
  exports.AuthService = persSdk.AuthService;
34
109
  Object.defineProperty(exports, "AuthStatus", {
35
- enumerable: true,
36
- get: function () { return persSdk.AuthStatus; }
110
+ enumerable: true,
111
+ get: function () { return persSdk.AuthStatus; }
37
112
  });
38
113
  exports.AuthTokenManager = persSdk.AuthTokenManager;
39
114
  exports.BusinessManager = persSdk.BusinessManager;
40
115
  exports.CampaignManager = persSdk.CampaignManager;
116
+ exports.CustomFieldDefinitionManager = persSdk.CustomFieldDefinitionManager;
41
117
  exports.DEFAULT_PERS_CONFIG = persSdk.DEFAULT_PERS_CONFIG;
42
118
  exports.DPOP_STORAGE_KEYS = persSdk.DPOP_STORAGE_KEYS;
43
119
  exports.DPoPManager = persSdk.DPoPManager;
@@ -77,40 +153,76 @@ exports.createPersSDK = persSdk.createPersSDK;
77
153
  exports.isFatalAuthErrorInMessage = persSdk.isFatalAuthErrorInMessage;
78
154
  exports.mergeWithDefaults = persSdk.mergeWithDefaults;
79
155
  Object.defineProperty(exports, "AccountOwnerType", {
80
- enumerable: true,
81
- get: function () { return persShared.AccountOwnerType; }
156
+ enumerable: true,
157
+ get: function () { return persShared.AccountOwnerType; }
158
+ });
159
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_FIT", {
160
+ enumerable: true,
161
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_FIT; }
162
+ });
163
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_FORMAT", {
164
+ enumerable: true,
165
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_FORMAT; }
166
+ });
167
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_QUALITY", {
168
+ enumerable: true,
169
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_QUALITY; }
170
+ });
171
+ Object.defineProperty(exports, "IMAGE_CDN_MAX_DIMENSION", {
172
+ enumerable: true,
173
+ get: function () { return persShared.IMAGE_CDN_MAX_DIMENSION; }
174
+ });
175
+ Object.defineProperty(exports, "IMAGE_CDN_PRESETS", {
176
+ enumerable: true,
177
+ get: function () { return persShared.IMAGE_CDN_PRESETS; }
82
178
  });
83
179
  Object.defineProperty(exports, "SortOrder", {
84
- enumerable: true,
85
- get: function () { return persShared.SortOrder; }
180
+ enumerable: true,
181
+ get: function () { return persShared.SortOrder; }
86
182
  });
87
183
  Object.defineProperty(exports, "VALID_USER_RELATIONS", {
88
- enumerable: true,
89
- get: function () { return persShared.VALID_USER_RELATIONS; }
184
+ enumerable: true,
185
+ get: function () { return persShared.VALID_USER_RELATIONS; }
186
+ });
187
+ Object.defineProperty(exports, "buildImageCdnUrl", {
188
+ enumerable: true,
189
+ get: function () { return persShared.buildImageCdnUrl; }
190
+ });
191
+ Object.defineProperty(exports, "getPresetDimensions", {
192
+ enumerable: true,
193
+ get: function () { return persShared.getPresetDimensions; }
90
194
  });
91
195
  Object.defineProperty(exports, "isConnectedMessage", {
92
- enumerable: true,
93
- get: function () { return persShared.isConnectedMessage; }
196
+ enumerable: true,
197
+ get: function () { return persShared.isConnectedMessage; }
94
198
  });
95
199
  Object.defineProperty(exports, "isErrorMessage", {
96
- enumerable: true,
97
- get: function () { return persShared.isErrorMessage; }
200
+ enumerable: true,
201
+ get: function () { return persShared.isErrorMessage; }
98
202
  });
99
203
  Object.defineProperty(exports, "isEventMessage", {
100
- enumerable: true,
101
- get: function () { return persShared.isEventMessage; }
204
+ enumerable: true,
205
+ get: function () { return persShared.isEventMessage; }
102
206
  });
103
207
  Object.defineProperty(exports, "isServerMessage", {
104
- enumerable: true,
105
- get: function () { return persShared.isServerMessage; }
208
+ enumerable: true,
209
+ get: function () { return persShared.isServerMessage; }
106
210
  });
107
211
  Object.defineProperty(exports, "isSubscribedMessage", {
108
- enumerable: true,
109
- get: function () { return persShared.isSubscribedMessage; }
212
+ enumerable: true,
213
+ get: function () { return persShared.isSubscribedMessage; }
214
+ });
215
+ Object.defineProperty(exports, "isSupportedImageFormat", {
216
+ enumerable: true,
217
+ get: function () { return persShared.isSupportedImageFormat; }
218
+ });
219
+ Object.defineProperty(exports, "isValidPreset", {
220
+ enumerable: true,
221
+ get: function () { return persShared.isValidPreset; }
110
222
  });
111
223
  Object.defineProperty(exports, "isValidUserRelation", {
112
- enumerable: true,
113
- get: function () { return persShared.isValidUserRelation; }
224
+ enumerable: true,
225
+ get: function () { return persShared.isValidUserRelation; }
114
226
  });
115
227
  exports.detectEnvironment = environment.detectEnvironment;
116
228
  exports.environment = environment.environment;
@@ -179,10 +291,13 @@ exports.TriggerSourceService = triggerSource.TriggerSourceService;
179
291
  exports.AngularHttpClientAdapter = platformAdapters.AngularHttpClientAdapter;
180
292
  exports.BrowserFetchClientAdapter = platformAdapters.BrowserFetchClientAdapter;
181
293
  exports.NodeHttpClientAdapter = nodeHttpClient.NodeHttpClientAdapter;
294
+ exports.buildImageUrl = buildImageUrl;
295
+ exports.extractIpfsCid = extractIpfsCid;
296
+ exports.isIpfsUrl = isIpfsUrl;
182
297
  Object.keys(persShared).forEach(function (k) {
183
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
184
- enumerable: true,
185
- get: function () { return persShared[k]; }
186
- });
298
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
299
+ enumerable: true,
300
+ get: function () { return persShared[k]; }
301
+ });
187
302
  });
188
303
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/shared/utils/image-url-utils.ts"],"sourcesContent":[null],"names":["buildImageCdnUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;SACa,aAAa,CAC3B,GAAW,EACX,OAAyB,EACzB,OAAgB,EAAA;AAEhB,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;IAEnB,IAAI,WAAW,GAAG,GAAG;;AAGrB,IAAA,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;AACnE,YAAA,OAAO,GAAG;QACZ;QACA,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACtC,QAAA,WAAW,GAAG,CAAA,QAAA,EAAW,OAAO,CAAA,MAAA,EAAS,GAAG,EAAE;IAChD;;AAGA,IAAA,OAAOA,2BAAgB,CAAC,WAAW,EAAE,OAAO,CAAC;AAC/C;AAEA;;;;;AAKG;AACG,SAAU,SAAS,CAAC,GAAW,EAAA;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;AAC3C;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,cAAc,CAAC,OAAe,EAAA;AAC5C,IAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AAAE,QAAA,OAAO,IAAI;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
- export { b as AUTH_STORAGE_KEYS, x as AnalyticsManager, K as ApiKeyApi, w as ApiKeyManager, l as AuthApi, r as AuthManager, o as AuthService, A as AuthStatus, a as AuthTokenManager, B as BusinessManager, C as CampaignManager, h as DEFAULT_PERS_CONFIG, d as DPOP_STORAGE_KEYS, p as DPoPManager, D as DefaultAuthProvider, y as DonationManager, F as FATAL_AUTH_CODES, H as FileApi, v as FileManager, J as FileService, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, g as PersApiClient, q as PersEventEmitter, Q as PersEventsClient, P as PersSDK, u as PurchaseManager, R as RedemptionManager, S as SDK_NAME, f as SDK_USER_AGENT, e as SDK_VERSION, k as StaticJwtAuthProvider, T as TokenManager, t as TransactionManager, z as TriggerSourceManager, U as UserManager, s as UserStatusManager, G as WalletEventsManager, W as WebDPoPCryptoProvider, N as WebhookApi, E as WebhookManager, O as WebhookService, i as buildApiRoot, j as buildWalletEventsWsUrl, V as createPersEventsClient, c as createPersSDK, n as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-DuDWwRWC.js';
1
+ export { a as AUTH_STORAGE_KEYS, w as AnalyticsManager, N as ApiKeyApi, v as ApiKeyManager, k as AuthApi, q as AuthManager, n as AuthService, H as AuthStatus, A as AuthTokenManager, B as BusinessManager, C as CampaignManager, G as CustomFieldDefinitionManager, g as DEFAULT_PERS_CONFIG, b as DPOP_STORAGE_KEYS, o as DPoPManager, D as DefaultAuthProvider, x as DonationManager, F as FATAL_AUTH_CODES, J as FileApi, u as FileManager, K as FileService, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, f as PersApiClient, p as PersEventEmitter, V as PersEventsClient, P as PersSDK, t as PurchaseManager, R as RedemptionManager, S as SDK_NAME, d as SDK_USER_AGENT, c as SDK_VERSION, j as StaticJwtAuthProvider, T as TokenManager, s as TransactionManager, y as TriggerSourceManager, U as UserManager, r as UserStatusManager, E as WalletEventsManager, W as WebDPoPCryptoProvider, O as WebhookApi, z as WebhookManager, Q as WebhookService, h as buildApiRoot, i as buildWalletEventsWsUrl, X as createPersEventsClient, e as createPersSDK, l as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-CBRtrG03.js';
2
+ import { buildImageCdnUrl } from '@explorins/pers-shared';
2
3
  export * from '@explorins/pers-shared';
3
- export { AccountOwnerType, SortOrder, VALID_USER_RELATIONS, isConnectedMessage, isErrorMessage, isEventMessage, isServerMessage, isSubscribedMessage, isValidUserRelation } from '@explorins/pers-shared';
4
+ export { AccountOwnerType, IMAGE_CDN_DEFAULT_FIT, IMAGE_CDN_DEFAULT_FORMAT, IMAGE_CDN_DEFAULT_QUALITY, IMAGE_CDN_MAX_DIMENSION, IMAGE_CDN_PRESETS, SortOrder, VALID_USER_RELATIONS, buildImageCdnUrl, getPresetDimensions, isConnectedMessage, isErrorMessage, isEventMessage, isServerMessage, isSubscribedMessage, isSupportedImageFormat, isValidPreset, isValidUserRelation } from '@explorins/pers-shared';
4
5
  export { d as detectEnvironment, e as environment, w as warnIfProblematicEnvironment } from './chunks/environment-DEI_L882.js';
5
6
  export { c as ApiErrorDetector, A as AuthenticationError, a as CacheService, C as CacheTTL, E as ErrorUtils, L as LogoutRequired, N as NetworkError, b as PersApiError, P as ProviderTokenRefreshNeeded, S as SdkErrorCodes, T as TokenRefreshNeeded, g as globalCacheService } from './chunks/index--OssIds0.js';
6
7
  export { T as TenantManager } from './chunks/tenant-manager-xmYKBFGu.js';
@@ -20,4 +21,83 @@ export { UserStatusApi, UserStatusService, createUserStatusSDK } from './user-st
20
21
  export { TriggerSourceApi, TriggerSourceService } from './trigger-source.js';
21
22
  export { AngularHttpClientAdapter, BrowserFetchClientAdapter } from './platform-adapters.js';
22
23
  export { N as NodeHttpClientAdapter } from './chunks/node-http-client-DloDLfm9.js';
24
+
25
+ /**
26
+ * Build optimized image URL with automatic IPFS resolution and CDN options
27
+ *
28
+ * Single entry point for all image URL building:
29
+ * - IPFS URIs → resolved via gateway + CDN options applied
30
+ * - HTTP URLs → CDN options applied directly
31
+ *
32
+ * @param url - Image URL (ipfs://, https://, or any URL)
33
+ * @param options - CDN optimization options (preset, quality, format, fit)
34
+ * @param gateway - IPFS gateway domain (required for ipfs:// URLs)
35
+ * @returns Optimized URL with query parameters
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // IPFS thumbnail
40
+ * buildImageUrl('ipfs://QmHash', { preset: 'thumb' }, 'cdn.example.com')
41
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=thumb'
42
+ *
43
+ * // IPFS hero with high quality
44
+ * buildImageUrl('ipfs://QmHash', { preset: 'hero', q: 95, fit: 'cover' }, 'cdn.example.com')
45
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=hero&q=95&fit=cover'
46
+ *
47
+ * // HTTP URL (gateway ignored)
48
+ * buildImageUrl('https://example.com/photo.jpg', { preset: 'card' })
49
+ * // => 'https://example.com/photo.jpg?preset=card'
50
+ *
51
+ * // No options - just IPFS resolution
52
+ * buildImageUrl('ipfs://QmHash', undefined, 'cdn.example.com')
53
+ * // => 'https://cdn.example.com/ipfs/QmHash'
54
+ * ```
55
+ */
56
+ function buildImageUrl(url, options, gateway) {
57
+ if (!url)
58
+ return '';
59
+ let resolvedUrl = url;
60
+ // Resolve IPFS to HTTP via gateway
61
+ if (url.startsWith('ipfs://')) {
62
+ if (!gateway) {
63
+ console.warn('[buildImageUrl] IPFS URL requires gateway parameter');
64
+ return url;
65
+ }
66
+ const cid = url.replace('ipfs://', '');
67
+ resolvedUrl = `https://${gateway}/ipfs/${cid}`;
68
+ }
69
+ // Apply CDN options
70
+ return buildImageCdnUrl(resolvedUrl, options);
71
+ }
72
+ /**
73
+ * Check if a URL is an IPFS URI
74
+ *
75
+ * @param url - URL to check
76
+ * @returns True if URL starts with ipfs://
77
+ */
78
+ function isIpfsUrl(url) {
79
+ return !!url && url.startsWith('ipfs://');
80
+ }
81
+ /**
82
+ * Extract CID from IPFS URI
83
+ *
84
+ * @param ipfsUri - IPFS URI (ipfs://Qm... or ipfs://baf...)
85
+ * @returns CID string, or null if not a valid IPFS URI
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * extractIpfsCid('ipfs://QmHash123')
90
+ * // => 'QmHash123'
91
+ *
92
+ * extractIpfsCid('https://example.com/image.jpg')
93
+ * // => null
94
+ * ```
95
+ */
96
+ function extractIpfsCid(ipfsUri) {
97
+ if (!isIpfsUrl(ipfsUri))
98
+ return null;
99
+ return ipfsUri.replace('ipfs://', '');
100
+ }
101
+
102
+ export { buildImageUrl, extractIpfsCid, isIpfsUrl };
23
103
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/shared/utils/image-url-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;SACa,aAAa,CAC3B,GAAW,EACX,OAAyB,EACzB,OAAgB,EAAA;AAEhB,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;IAEnB,IAAI,WAAW,GAAG,GAAG;;AAGrB,IAAA,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;AACnE,YAAA,OAAO,GAAG;QACZ;QACA,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACtC,QAAA,WAAW,GAAG,CAAA,QAAA,EAAW,OAAO,CAAA,MAAA,EAAS,GAAG,EAAE;IAChD;;AAGA,IAAA,OAAO,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC;AAC/C;AAEA;;;;;AAKG;AACG,SAAU,SAAS,CAAC,GAAW,EAAA;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;AAC3C;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,cAAc,CAAC,OAAe,EAAA;AAC5C,IAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AAAE,QAAA,OAAO,IAAI;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACvC;;;;"}
@@ -0,0 +1,317 @@
1
+ import { PersApiClient } from '../core/pers-api-client';
2
+ import { PersEventEmitter } from '../core/events';
3
+ import { CustomFieldDefinitionDTO, CreateCustomFieldDefinitionDTO, UpdateCustomFieldDefinitionDTO, CustomFieldEntityType, CustomFieldSelectOption, type FieldDefinition, type ValidationErrorDetail } from '@explorins/pers-shared';
4
+ export type { CustomFieldDefinitionDTO, CreateCustomFieldDefinitionDTO, UpdateCustomFieldDefinitionDTO, CustomFieldEntityType, CustomFieldSelectOption, FieldDefinition, ValidationErrorDetail, };
5
+ /**
6
+ * Options for querying custom field definitions
7
+ */
8
+ export interface CustomFieldQueryOptions {
9
+ /** Filter by entity type (default: 'user') */
10
+ entityType?: CustomFieldEntityType;
11
+ }
12
+ /**
13
+ * Custom Field Definition Manager - Manage tenant-specific custom fields
14
+ *
15
+ * Provides CRUD operations for custom field definitions that extend the built-in
16
+ * user profile fields. Custom fields are defined per-tenant and can be used for
17
+ * additional user data collection, redemption requirements, and form validation.
18
+ *
19
+ * @group Managers
20
+ * @category Custom Fields
21
+ *
22
+ * @example Basic Operations
23
+ * ```typescript
24
+ * // List all user custom fields
25
+ * const fields = await sdk.customFields.getDefinitions();
26
+ *
27
+ * // Create a new custom field
28
+ * const field = await sdk.customFields.createDefinition({
29
+ * key: 'employee_id',
30
+ * label: 'Employee ID',
31
+ * fieldType: 'text',
32
+ * validation: { required: true, pattern: '^E[0-9]{5}$' }
33
+ * });
34
+ *
35
+ * // Update a field
36
+ * await sdk.customFields.updateDefinition(field.id, {
37
+ * label: 'Company Employee ID'
38
+ * });
39
+ *
40
+ * // Delete a field
41
+ * await sdk.customFields.deleteDefinition(field.id);
42
+ * ```
43
+ *
44
+ * @example Validation
45
+ * ```typescript
46
+ * // Validate user custom data against definitions
47
+ * const definitions = await sdk.customFields.getDefinitions();
48
+ * const errors = sdk.customFields.validateUserData(
49
+ * { employee_id: 'INVALID' },
50
+ * definitions
51
+ * );
52
+ * if (errors.length > 0) {
53
+ * console.log('Validation errors:', errors);
54
+ * }
55
+ * ```
56
+ */
57
+ export declare class CustomFieldDefinitionManager {
58
+ private events?;
59
+ private readonly api;
60
+ constructor(apiClient: PersApiClient, events?: PersEventEmitter | undefined);
61
+ /**
62
+ * List all custom field definitions for the tenant
63
+ *
64
+ * Retrieves all custom field definitions, optionally filtered by entity type.
65
+ * Results are sorted by sortOrder (ascending).
66
+ *
67
+ * @param options - Query options including entity type filter
68
+ * @returns Array of custom field definitions
69
+ *
70
+ * @example List All User Fields
71
+ * ```typescript
72
+ * const fields = await sdk.customFields.getDefinitions();
73
+ * console.log(`Found ${fields.length} custom fields`);
74
+ *
75
+ * fields.forEach(field => {
76
+ * console.log(`${field.key}: ${field.label} (${field.fieldType})`);
77
+ * });
78
+ * ```
79
+ *
80
+ * @example Filter by Entity Type
81
+ * ```typescript
82
+ * // Get only business custom fields
83
+ * const businessFields = await sdk.customFields.getDefinitions({
84
+ * entityType: 'business'
85
+ * });
86
+ * ```
87
+ */
88
+ getDefinitions(options?: CustomFieldQueryOptions): Promise<CustomFieldDefinitionDTO[]>;
89
+ /**
90
+ * Get a single custom field definition by ID
91
+ *
92
+ * @param id - The UUID of the custom field definition
93
+ * @returns The custom field definition
94
+ * @throws {PersApiError} When definition not found (404)
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * try {
99
+ * const field = await sdk.customFields.getDefinition('uuid-here');
100
+ * console.log('Field:', field.label);
101
+ * } catch (error) {
102
+ * if (error.statusCode === 404) {
103
+ * console.log('Field not found');
104
+ * }
105
+ * }
106
+ * ```
107
+ */
108
+ getDefinition(id: string): Promise<CustomFieldDefinitionDTO>;
109
+ /**
110
+ * Create a new custom field definition
111
+ *
112
+ * Creates a new custom field for the tenant. The field key must be unique
113
+ * within the tenant and entity type combination.
114
+ *
115
+ * @param data - The field definition data
116
+ * @returns The created custom field definition
117
+ * @throws {PersApiError} When key already exists (409) or validation fails (400)
118
+ *
119
+ * @example Text Field with Pattern
120
+ * ```typescript
121
+ * const employeeIdField = await sdk.customFields.createDefinition({
122
+ * key: 'employee_id',
123
+ * label: 'Employee ID',
124
+ * description: 'Your company employee ID (E + 5 digits)',
125
+ * fieldType: 'text',
126
+ * validation: {
127
+ * required: true,
128
+ * pattern: '^E[0-9]{5}$',
129
+ * patternMessage: 'Must be E followed by 5 digits'
130
+ * },
131
+ * sortOrder: 1
132
+ * });
133
+ * ```
134
+ *
135
+ * @example Date Field with Comparison
136
+ * ```typescript
137
+ * const checkOutField = await sdk.customFields.createDefinition({
138
+ * key: 'check_out',
139
+ * label: 'Check-out Date',
140
+ * fieldType: 'date',
141
+ * validation: {
142
+ * required: true,
143
+ * comparisons: [
144
+ * { field: 'check_in', operator: '>', message: 'Must be after check-in' }
145
+ * ]
146
+ * },
147
+ * sortOrder: 2
148
+ * });
149
+ * ```
150
+ *
151
+ * @example Select Field with Static Options
152
+ * ```typescript
153
+ * const departmentField = await sdk.customFields.createDefinition({
154
+ * key: 'department',
155
+ * label: 'Department',
156
+ * fieldType: 'select',
157
+ * selectOptions: [
158
+ * { value: 'engineering', label: 'Engineering' },
159
+ * { value: 'sales', label: 'Sales' },
160
+ * { value: 'hr', label: 'Human Resources' }
161
+ * ],
162
+ * validation: { required: true }
163
+ * });
164
+ * ```
165
+ *
166
+ * @example Select Field with Dynamic Options
167
+ * ```typescript
168
+ * const hotelField = await sdk.customFields.createDefinition({
169
+ * key: 'preferred_hotel',
170
+ * label: 'Preferred Hotel',
171
+ * fieldType: 'select',
172
+ * selectOptionsSource: {
173
+ * entity: 'business',
174
+ * valueField: 'id',
175
+ * labelField: 'name',
176
+ * filter: { tags: ['hotel'], isActive: true }
177
+ * },
178
+ * validation: { required: true }
179
+ * });
180
+ * ```
181
+ */
182
+ createDefinition(data: CreateCustomFieldDefinitionDTO): Promise<CustomFieldDefinitionDTO>;
183
+ /**
184
+ * Update an existing custom field definition
185
+ *
186
+ * Updates a custom field definition. Note that key and entityType cannot
187
+ * be changed after creation.
188
+ *
189
+ * @param id - The UUID of the custom field definition to update
190
+ * @param data - The fields to update (partial update supported)
191
+ * @returns The updated custom field definition
192
+ * @throws {PersApiError} When definition not found (404) or validation fails (400)
193
+ *
194
+ * @example Update Label and Validation
195
+ * ```typescript
196
+ * const updated = await sdk.customFields.updateDefinition('uuid-here', {
197
+ * label: 'Employee ID (Required)',
198
+ * validation: {
199
+ * required: true,
200
+ * minLength: 6,
201
+ * maxLength: 6
202
+ * }
203
+ * });
204
+ * ```
205
+ *
206
+ * @example Update Sort Order
207
+ * ```typescript
208
+ * await sdk.customFields.updateDefinition('uuid-here', {
209
+ * sortOrder: 5
210
+ * });
211
+ * ```
212
+ */
213
+ updateDefinition(id: string, data: UpdateCustomFieldDefinitionDTO): Promise<CustomFieldDefinitionDTO>;
214
+ /**
215
+ * Delete a custom field definition (soft delete)
216
+ *
217
+ * Soft deletes a custom field definition. Existing user data in customData
218
+ * is preserved, but the field will no longer appear in forms or validation.
219
+ *
220
+ * ⚠️ Consider the impact on existing user data before deleting.
221
+ *
222
+ * @param id - The UUID of the custom field definition to delete
223
+ * @throws {PersApiError} When definition not found (404)
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * try {
228
+ * await sdk.customFields.deleteDefinition('uuid-here');
229
+ * console.log('Field deleted');
230
+ * } catch (error) {
231
+ * console.log('Failed to delete:', error.message);
232
+ * }
233
+ * ```
234
+ */
235
+ deleteDefinition(id: string): Promise<void>;
236
+ /**
237
+ * Resolve dynamic select options for a field
238
+ *
239
+ * For fields with selectOptionsSource (dynamic options from entities),
240
+ * this resolves the actual options by querying the source entity.
241
+ *
242
+ * @param id - The UUID of the custom field definition
243
+ * @returns Array of select options
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const field = await sdk.customFields.getDefinition('hotel-field-id');
248
+ *
249
+ * if (field.selectOptionsSource) {
250
+ * // Options come from entity - need to resolve
251
+ * const options = await sdk.customFields.resolveSelectOptions(field.id);
252
+ * console.log('Available hotels:', options);
253
+ * } else {
254
+ * // Static options
255
+ * console.log('Options:', field.selectOptions);
256
+ * }
257
+ * ```
258
+ */
259
+ resolveSelectOptions(id: string): Promise<CustomFieldSelectOption[]>;
260
+ /**
261
+ * Validate user custom data against field definitions
262
+ *
263
+ * Client-side validation using the same rules as the backend. Use this
264
+ * to validate form data before submission.
265
+ *
266
+ * @param data - User's custom data (key-value pairs)
267
+ * @param definitions - Custom field definitions to validate against
268
+ * @returns Array of validation errors (empty if valid)
269
+ *
270
+ * @example Form Validation
271
+ * ```typescript
272
+ * const definitions = await sdk.customFields.getDefinitions();
273
+ * const formData = {
274
+ * employee_id: 'E123', // Missing a digit
275
+ * department: 'engineering'
276
+ * };
277
+ *
278
+ * const errors = sdk.customFields.validateUserData(formData, definitions);
279
+ * if (errors.length > 0) {
280
+ * errors.forEach(err => {
281
+ * console.log(`${err.field}: ${err.message}`);
282
+ * });
283
+ * return; // Don't submit
284
+ * }
285
+ *
286
+ * // No errors, safe to submit
287
+ * await sdk.users.updateCurrentUser({ customData: formData });
288
+ * ```
289
+ */
290
+ validateUserData(data: Record<string, unknown>, definitions: CustomFieldDefinitionDTO[]): ValidationErrorDetail[];
291
+ /**
292
+ * Validate a single field value
293
+ *
294
+ * Validates a single value against a field's rules. Useful for
295
+ * real-time validation as the user types.
296
+ *
297
+ * @param value - The value to validate
298
+ * @param definition - The field definition
299
+ * @returns Validation error or null if valid
300
+ *
301
+ * @example Real-time Validation
302
+ * ```typescript
303
+ * const employeeIdField = definitions.find(d => d.key === 'employee_id');
304
+ *
305
+ * const handleBlur = (value: string) => {
306
+ * const error = sdk.customFields.validateFieldValue(value, employeeIdField);
307
+ * if (error) {
308
+ * setFieldError('employee_id', error.message);
309
+ * } else {
310
+ * clearFieldError('employee_id');
311
+ * }
312
+ * };
313
+ * ```
314
+ */
315
+ validateFieldValue(value: unknown, definition: CustomFieldDefinitionDTO): ValidationErrorDetail | null;
316
+ }
317
+ //# sourceMappingURL=custom-field-definition-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-field-definition-manager.d.ts","sourceRoot":"","sources":["../../src/managers/custom-field-definition-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EAGvB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,qBAAqB,GACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8CAA8C;IAC9C,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBAAa,4BAA4B;IAKrC,OAAO,CAAC,MAAM,CAAC;IAJjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAiB;gBAGnC,SAAS,EAAE,aAAa,EAChB,MAAM,CAAC,8BAAkB;IAKnC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,cAAc,CAClB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAItC;;;;;;;;;;;;;;;;;;OAkBG;IACG,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwEG;IACG,gBAAgB,CACpB,IAAI,EAAE,8BAA8B,GACnC,OAAO,CAAC,wBAAwB,CAAC;IAcpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,gBAAgB,CACpB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,8BAA8B,GACnC,OAAO,CAAC,wBAAwB,CAAC;IAcpC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAK1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,gBAAgB,CACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,wBAAwB,EAAE,GACtC,qBAAqB,EAAE;IAY1B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,kBAAkB,CAChB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,wBAAwB,GACnC,qBAAqB,GAAG,IAAI;CAchC"}
@@ -22,4 +22,5 @@ export { DonationManager } from './donation-manager';
22
22
  export { TriggerSourceManager } from './trigger-source-manager';
23
23
  export { WebhookManager } from './webhook-manager';
24
24
  export { WalletEventsManager, type WalletEventsConfig } from './events-manager';
25
+ export { CustomFieldDefinitionManager, type CustomFieldQueryOptions } from './custom-field-definition-manager';
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/managers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/managers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC"}
package/dist/node.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persSdk = require('./chunks/pers-sdk-CBvzmlL_.cjs');
3
+ var persSdk = require('./chunks/pers-sdk-DcNDMx1Y.cjs');
4
4
  var persShared = require('@explorins/pers-shared');
5
5
  var nodeHttpClient = require('./chunks/node-http-client-D_avaa5F.cjs');
6
6
  require('./chunks/index-C4K-jkRO.cjs');