@nuskin/shipping-address-form 1.7.9 → 1.7.10-6614-dev.2

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 (28) hide show
  1. package/dist/addressLookup/components/SmartyIntlResults.js +6 -4
  2. package/dist/addressLookup/components/SmartyIntlResults.js.map +1 -1
  3. package/dist/addressLookup/components/SmartyUSResults.js +6 -4
  4. package/dist/addressLookup/components/SmartyUSResults.js.map +1 -1
  5. package/dist/addressLookup/components/smartyResults/useSmartyAddressController.js +6 -2
  6. package/dist/addressLookup/components/smartyResults/useSmartyAddressController.js.map +1 -1
  7. package/dist/addressLookup/components/smartyResults/useSmartyServiceErrors.js.map +1 -1
  8. package/dist/addressLookup/hooks/useAddressValidationBase.js +4 -1
  9. package/dist/addressLookup/hooks/useAddressValidationBase.js.map +1 -1
  10. package/dist/addressLookup/hooks/useIntlAddressValidation.js +24 -6
  11. package/dist/addressLookup/hooks/useIntlAddressValidation.js.map +1 -1
  12. package/dist/addressLookup/hooks/useSmartyInternationalLookup.js +47 -7
  13. package/dist/addressLookup/hooks/useSmartyInternationalLookup.js.map +1 -1
  14. package/dist/addressLookup/hooks/useSmartyLookupBase.js +6 -1
  15. package/dist/addressLookup/hooks/useSmartyLookupBase.js.map +1 -1
  16. package/dist/addressLookup/hooks/useSmartyUSLookup.js +30 -8
  17. package/dist/addressLookup/hooks/useSmartyUSLookup.js.map +1 -1
  18. package/dist/addressLookup/hooks/useUSAddressValidation.js +25 -6
  19. package/dist/addressLookup/hooks/useUSAddressValidation.js.map +1 -1
  20. package/dist/addressLookup/utils/addressForm.js +86 -2
  21. package/dist/addressLookup/utils/addressForm.js.map +1 -1
  22. package/dist/addressLookup/utils/smartyConfig.js +240 -5
  23. package/dist/addressLookup/utils/smartyConfig.js.map +1 -1
  24. package/dist/index.js +7 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/shippingAddressForm/utils/shippingAddressForm.js +13 -0
  27. package/dist/shippingAddressForm/utils/shippingAddressForm.js.map +1 -1
  28. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useUSAddressValidation.js","names":["_smartyConfig","require","_validators","_useAddressValidationBase","_interopRequireDefault","e","__esModule","default","VALID_DPV_CODES","Set","CACHE_NAMESPACE","CACHE_TTL_MS","RATE_LIMIT_NAMESPACE","RATE_LIMIT_CONFIG","limit","windowMs","cooldownMs","VALIDATION_URL","parseDpvFootnotes","footnotes","normalized","String","result","index","length","code","slice","add","trimZipPlus4","value","replace","buildDisplayText","item","_item$components","_item$components2","_item$components3","line1","delivery_line_1","line2","delivery_line_2","city","components","city_name","region","state_abbreviation","postalCode","zipcode","lastLine","filter","Boolean","join","last_line","buildValidationSummary","analysis","dpvMatchCode","dpv_match_code","dpv_footnotes","isVacant","dpv_vacant","isNoStat","dpv_no_stat","level","title","message","sortPriority","has","buildValidationParams","formData","params","key","SMARTY_US_STREET_KEY","street","address1","secondary","address2","state","normalizePostalCodeValue","candidates","Object","keys","forEach","undefined","buildRequestKey","JSON","stringify","transformSuggestions","responseData","map","_item$analysis","_item$metadata","_item$metadata2","isDeliverable","latitude","metadata","longitude","displayText","validationSummary","sort","left","right","useUSAddressValidation","trigger","isEnabled","requestParams","requestKey","useAddressValidationBase","cacheNamespace","cacheTtlMs","rateLimitNamespace","rateLimitConfig","requestUrl","transformResponse","effectDeps","_default","exports"],"sources":["../../../src/addressLookup/hooks/useUSAddressValidation.jsx"],"sourcesContent":["import { SMARTY_US_STREET_KEY } from '../utils/smartyConfig';\nimport { normalizePostalCodeValue } from '../utils/validators';\nimport useAddressValidationBase from './useAddressValidationBase';\n\nconst VALID_DPV_CODES = new Set(['Y', 'S', 'D']);\nconst CACHE_NAMESPACE = 'smarty-us-validation';\nconst CACHE_TTL_MS = 60 * 1000;\nconst RATE_LIMIT_NAMESPACE = 'smarty-us-validation';\nconst RATE_LIMIT_CONFIG = {\n limit: 60,\n windowMs: 60 * 1000,\n cooldownMs: 60 * 1000\n};\nconst VALIDATION_URL = 'https://us-street.api.smarty.com/street-address';\n\nconst parseDpvFootnotes = (footnotes = '') => {\n const normalized = String(footnotes || '');\n const result = new Set();\n\n for (let index = 0; index < normalized.length; index += 2) {\n const code = normalized.slice(index, index + 2);\n if (code.length === 2) {\n result.add(code);\n }\n }\n\n return result;\n};\n\nconst trimZipPlus4 = (value = '') => String(value).replace(/(\\b\\d{5})-\\d{4}\\b/g, '$1');\n\nconst buildDisplayText = (item) => {\n const line1 = item.delivery_line_1;\n const line2 = item.delivery_line_2;\n const city = item.components?.city_name;\n const region = item.components?.state_abbreviation;\n const postalCode = item.components?.zipcode;\n\n const lastLine = city && region ?\n [city, region, postalCode].filter(Boolean).join(' ') :\n trimZipPlus4(item.last_line || '');\n\n return [\n line1,\n line2,\n lastLine\n ].filter(Boolean).join(', ');\n};\n\nconst buildValidationSummary = (item) => {\n const analysis = item.analysis || {};\n const dpvMatchCode = analysis.dpv_match_code || '';\n const footnotes = parseDpvFootnotes(analysis.dpv_footnotes);\n const isVacant = analysis.dpv_vacant === 'Y';\n const isNoStat = analysis.dpv_no_stat === 'Y';\n\n if (dpvMatchCode === 'Y' && !isVacant && !isNoStat) {\n return {\n level: 'verified',\n code: 'verified',\n title: 'Verified',\n message: 'This address is fully verified.',\n sortPriority: 1\n };\n }\n\n if (dpvMatchCode === 'S' && footnotes.has('CC')) {\n return {\n level: 'warning',\n code: 'invalid-secondary-optional',\n title: 'Unit not recognized',\n message: 'The main address is valid, but the unit number was not recognized.',\n sortPriority: 2\n };\n }\n\n if (dpvMatchCode === 'D' || footnotes.has('N1')) {\n return {\n level: 'warning',\n code: 'missing-secondary',\n title: 'Apartment or suite needed',\n message: 'The main address is valid, but a unit number is required.',\n sortPriority: 3\n };\n }\n\n if (dpvMatchCode === 'S' && footnotes.has('C1')) {\n return {\n level: 'warning',\n code: 'invalid-secondary-required',\n title: 'Apartment or suite not recognized',\n message: 'The street address is valid, but the unit number was not recognized and is required.',\n sortPriority: 4\n };\n }\n\n if ((dpvMatchCode === 'Y' || dpvMatchCode === 'S' || dpvMatchCode === 'D') && isVacant) {\n return {\n level: 'warning',\n code: 'vacant',\n title: 'Verified, but marked vacant',\n message: 'This address is valid but marked as vacant.',\n sortPriority: 5\n };\n }\n\n if ((dpvMatchCode === 'Y' || dpvMatchCode === 'S' || dpvMatchCode === 'D') && isNoStat) {\n return {\n level: 'warning',\n code: 'no-stat',\n title: 'Verified with caution',\n message: 'This address is valid, but USPS indicates limited delivery status.',\n sortPriority: 6\n };\n }\n\n return {\n level: 'invalid',\n code: 'not-confirmed',\n title: 'Not verified',\n message: 'This address could not be confirmed.',\n sortPriority: 7\n };\n};\n\nconst buildValidationParams = (formData) => {\n const params = {\n key: SMARTY_US_STREET_KEY,\n street: formData.address1 || '',\n secondary: formData.address2 || '',\n city: formData.city || '',\n state: formData.region || '',\n zipcode: normalizePostalCodeValue(formData.postalCode || ''),\n candidates: 10\n };\n\n Object.keys(params).forEach((key) => {\n if (params[key] === '' || params[key] === null || params[key] === undefined) {\n delete params[key];\n }\n });\n\n return params;\n};\n\nconst buildRequestKey = (formData) => JSON.stringify({\n street: formData.address1 || '',\n secondary: formData.address2 || '',\n city: formData.city || '',\n state: formData.region || '',\n zipcode: normalizePostalCodeValue(formData.postalCode || '')\n});\n\nconst transformSuggestions = (responseData = []) => responseData\n .map((item) => {\n const dpvMatchCode = item.analysis?.dpv_match_code || '';\n\n return {\n ...item,\n dpvMatchCode,\n isDeliverable: VALID_DPV_CODES.has(dpvMatchCode),\n latitude: item.metadata?.latitude,\n longitude: item.metadata?.longitude,\n displayText: buildDisplayText(item),\n validationSummary: buildValidationSummary(item)\n };\n })\n .sort((left, right) => left.validationSummary.sortPriority - right.validationSummary.sortPriority);\n\nconst useUSAddressValidation = (formData, trigger) => {\n const isEnabled = Boolean(trigger && trigger !== 0 && formData?.address1);\n const requestParams = buildValidationParams(formData);\n const requestKey = `smarty-us-validation:${buildRequestKey(formData)}`;\n\n return useAddressValidationBase({\n isEnabled,\n cacheNamespace: CACHE_NAMESPACE,\n cacheTtlMs: CACHE_TTL_MS,\n rateLimitNamespace: RATE_LIMIT_NAMESPACE,\n rateLimitConfig: RATE_LIMIT_CONFIG,\n requestKey,\n requestUrl: VALIDATION_URL,\n requestParams,\n transformResponse: transformSuggestions,\n effectDeps: [trigger]\n });\n};\n\nexport default useUSAddressValidation;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAkE,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElE,MAAMG,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChD,MAAMC,eAAe,GAAG,sBAAsB;AAC9C,MAAMC,YAAY,GAAG,EAAE,GAAG,IAAI;AAC9B,MAAMC,oBAAoB,GAAG,sBAAsB;AACnD,MAAMC,iBAAiB,GAAG;EACxBC,KAAK,EAAE,EAAE;EACTC,QAAQ,EAAE,EAAE,GAAG,IAAI;EACnBC,UAAU,EAAE,EAAE,GAAG;AACnB,CAAC;AACD,MAAMC,cAAc,GAAG,iDAAiD;AAExE,MAAMC,iBAAiB,GAAGA,CAACC,SAAS,GAAG,EAAE,KAAK;EAC5C,MAAMC,UAAU,GAAGC,MAAM,CAACF,SAAS,IAAI,EAAE,CAAC;EAC1C,MAAMG,MAAM,GAAG,IAAIb,GAAG,CAAC,CAAC;EAExB,KAAK,IAAIc,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGH,UAAU,CAACI,MAAM,EAAED,KAAK,IAAI,CAAC,EAAE;IACzD,MAAME,IAAI,GAAGL,UAAU,CAACM,KAAK,CAACH,KAAK,EAAEA,KAAK,GAAG,CAAC,CAAC;IAC/C,IAAIE,IAAI,CAACD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,KAAK,KAAKD,IAAI,CAACF,iBAAiB,CAAChC,YAAY,GAAGmC,KAAK,CAACH,iBAAiB,CAAChC,YAAY,CAAC;AAEpG,MAAMoC,sBAAsB,GAAGA,CAACjC,QAAQ,EAAEkC,OAAO,KAAK;EACpD,MAAMC,SAAS,GAAGrD,OAAO,CAACoD,OAAO,IAAIA,OAAO,KAAK,CAAC,KAAIlC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEK,QAAQ,EAAC;EACzE,MAAM+B,aAAa,GAAGrC,qBAAqB,CAACC,QAAQ,CAAC;EACrD,MAAMqC,UAAU,GAAG,wBAAwBtB,eAAe,CAACf,QAAQ,CAAC,EAAE;EAEtE,OAAO,IAAAsC,iCAAwB,EAAC;IAC9BH,SAAS;IACTI,cAAc,EAAEhG,eAAe;IAC/BiG,UAAU,EAAEhG,YAAY;IACxBiG,kBAAkB,EAAEhG,oBAAoB;IACxCiG,eAAe,EAAEhG,iBAAiB;IAClC2F,UAAU;IACVM,UAAU,EAAE7F,cAAc;IAC1BsF,aAAa;IACbQ,iBAAiB,EAAE1B,oBAAoB;IACvC2B,UAAU,EAAE,CAACX,OAAO;EACtB,CAAC,CAAC;AACJ,CAAC;AAAC,IAAAY,QAAA,GAAAC,OAAA,CAAA3G,OAAA,GAEa6F,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"useUSAddressValidation.js","names":["_smartyConfig","require","_validators","_useAddressValidationBase","_interopRequireDefault","e","__esModule","default","VALID_DPV_CODES","Set","CACHE_NAMESPACE","CACHE_TTL_MS","RATE_LIMIT_NAMESPACE","RATE_LIMIT_CONFIG","limit","windowMs","cooldownMs","SMARTY_US_STREET_URL","parseDpvFootnotes","footnotes","normalized","String","result","index","length","code","slice","add","trimZipPlus4","value","replace","buildDisplayText","item","_item$components","_item$components2","_item$components3","line1","delivery_line_1","line2","delivery_line_2","city","components","city_name","region","state_abbreviation","postalCode","zipcode","lastLine","filter","Boolean","join","last_line","buildValidationSummary","analysis","dpvMatchCode","dpv_match_code","dpv_footnotes","isVacant","dpv_vacant","isNoStat","dpv_no_stat","level","title","message","sortPriority","has","buildRequestBody","formData","body","street","address1","candidates","address2","secondary","state","normalizePostalCodeValue","buildRequestParams","key","params","Object","keys","forEach","undefined","buildRequestKey","JSON","stringify","transformSuggestions","responseData","map","_item$analysis","_item$metadata","_item$metadata2","isDeliverable","latitude","metadata","longitude","displayText","validationSummary","sort","left","right","useUSAddressValidation","trigger","smartyConfig","cfg","deriveSmartyConfig","isEnabled","lambdaEnabled","smartyLambdaEnabled","requestBody","requestParams","smartyKeys","usStreet","requestKey","lambdaUrl","appendLambdaQueryParams","buildSmartyEndpoint","skipCache","smartyResponse","useAddressValidationBase","cacheNamespace","cacheTtlMs","rateLimitNamespace","rateLimitConfig","requestUrl","transformResponse","effectDeps","_default","exports"],"sources":["../../../src/addressLookup/hooks/useUSAddressValidation.jsx"],"sourcesContent":["import {\n appendLambdaQueryParams,\n buildSmartyEndpoint,\n deriveSmartyConfig\n} from '../utils/smartyConfig';\nimport { normalizePostalCodeValue } from '../utils/validators';\nimport useAddressValidationBase from './useAddressValidationBase';\n\nconst VALID_DPV_CODES = new Set(['Y', 'S', 'D']);\nconst CACHE_NAMESPACE = 'smarty-us-validation';\nconst CACHE_TTL_MS = 60 * 1000;\nconst RATE_LIMIT_NAMESPACE = 'smarty-us-validation';\nconst RATE_LIMIT_CONFIG = {\n limit: 60,\n windowMs: 60 * 1000,\n cooldownMs: 60 * 1000\n};\nconst SMARTY_US_STREET_URL = 'https://us-street.api.smarty.com/street-address';\n\nconst parseDpvFootnotes = (footnotes = '') => {\n const normalized = String(footnotes || '');\n const result = new Set();\n\n for (let index = 0; index < normalized.length; index += 2) {\n const code = normalized.slice(index, index + 2);\n if (code.length === 2) {\n result.add(code);\n }\n }\n\n return result;\n};\n\nconst trimZipPlus4 = (value = '') => String(value).replace(/(\\b\\d{5})-\\d{4}\\b/g, '$1');\n\nconst buildDisplayText = (item) => {\n const line1 = item.delivery_line_1;\n const line2 = item.delivery_line_2;\n const city = item.components?.city_name;\n const region = item.components?.state_abbreviation;\n const postalCode = item.components?.zipcode;\n\n const lastLine = city && region ?\n [city, region, postalCode].filter(Boolean).join(' ') :\n trimZipPlus4(item.last_line || '');\n\n return [\n line1,\n line2,\n lastLine\n ].filter(Boolean).join(', ');\n};\n\nconst buildValidationSummary = (item) => {\n const analysis = item.analysis || {};\n const dpvMatchCode = analysis.dpv_match_code || '';\n const footnotes = parseDpvFootnotes(analysis.dpv_footnotes);\n const isVacant = analysis.dpv_vacant === 'Y';\n const isNoStat = analysis.dpv_no_stat === 'Y';\n\n if (dpvMatchCode === 'Y' && !isVacant && !isNoStat) {\n return {\n level: 'verified',\n code: 'verified',\n title: 'Verified',\n message: 'This address is fully verified.',\n sortPriority: 1\n };\n }\n if (dpvMatchCode === 'S' && footnotes.has('CC')) {\n return {\n level: 'warning',\n code: 'invalid-secondary-optional',\n title: 'Unit not recognized',\n message: 'The main address is valid, but the unit number was not recognized.',\n sortPriority: 2\n };\n }\n if (dpvMatchCode === 'D' || footnotes.has('N1')) {\n return {\n level: 'warning',\n code: 'missing-secondary',\n title: 'Apartment or suite needed',\n message: 'The main address is valid, but a unit number is required.',\n sortPriority: 3\n };\n }\n if (dpvMatchCode === 'S' && footnotes.has('C1')) {\n return {\n level: 'warning',\n code: 'invalid-secondary-required',\n title: 'Apartment or suite not recognized',\n message: 'The street address is valid, but the unit number was not recognized and is required.',\n sortPriority: 4\n };\n }\n if ((dpvMatchCode === 'Y' || dpvMatchCode === 'S' || dpvMatchCode === 'D') && isVacant) {\n return {\n level: 'warning',\n code: 'vacant',\n title: 'Verified, but marked vacant',\n message: 'This address is valid but marked as vacant.',\n sortPriority: 5\n };\n }\n if ((dpvMatchCode === 'Y' || dpvMatchCode === 'S' || dpvMatchCode === 'D') && isNoStat) {\n return {\n level: 'warning',\n code: 'no-stat',\n title: 'Verified with caution',\n message: 'This address is valid, but USPS indicates limited delivery status.',\n sortPriority: 6\n };\n }\n\n return {\n level: 'invalid',\n code: 'not-confirmed',\n title: 'Not verified',\n message: 'This address could not be confirmed.',\n sortPriority: 7\n };\n};\n\nconst buildRequestBody = (formData) => {\n const body = {\n street: formData.address1 || '',\n candidates: 10\n };\n\n if (formData.address2) body.secondary = formData.address2;\n if (formData.city) body.city = formData.city;\n if (formData.region) body.state = formData.region;\n if (formData.postalCode) body.zipcode = normalizePostalCodeValue(formData.postalCode);\n\n return body;\n};\n\nconst buildRequestParams = (formData, key) => {\n const params = {\n key,\n street: formData.address1 || '',\n secondary: formData.address2 || '',\n city: formData.city || '',\n state: formData.region || '',\n zipcode: normalizePostalCodeValue(formData.postalCode || ''),\n candidates: 10\n };\n\n Object.keys(params).forEach((key) => {\n if (params[key] === '' || params[key] === null || params[key] === undefined) {\n delete params[key];\n }\n });\n\n return params;\n};\n\nconst buildRequestKey = (formData) => JSON.stringify({\n street: formData.address1 || '',\n secondary: formData.address2 || '',\n city: formData.city || '',\n state: formData.region || '',\n zipcode: normalizePostalCodeValue(formData.postalCode || '')\n});\n\nconst transformSuggestions = (responseData = []) => responseData\n .map((item) => {\n const dpvMatchCode = item.analysis?.dpv_match_code || '';\n return {\n ...item,\n dpvMatchCode,\n isDeliverable: VALID_DPV_CODES.has(dpvMatchCode),\n latitude: item.metadata?.latitude,\n longitude: item.metadata?.longitude,\n displayText: buildDisplayText(item),\n validationSummary: buildValidationSummary(item)\n };\n })\n .sort((left, right) => left.validationSummary.sortPriority - right.validationSummary.sortPriority);\n\nconst useUSAddressValidation = (formData, trigger, smartyConfig = null) => {\n const cfg = smartyConfig ?? deriveSmartyConfig(null);\n const isEnabled = Boolean(trigger && trigger !== 0 && formData?.address1);\n const lambdaEnabled = cfg.smartyLambdaEnabled;\n const requestBody = lambdaEnabled ? buildRequestBody(formData) : null;\n const requestParams = lambdaEnabled ? null : buildRequestParams(formData, cfg.smartyKeys.usStreet);\n const requestKey = `smarty-us-validation:${buildRequestKey(formData)}`;\n const lambdaUrl = appendLambdaQueryParams(\n buildSmartyEndpoint(cfg, 'validate', 'US'),\n { skipCache: cfg.skipCache, smartyResponse: cfg.smartyResponse }\n );\n\n return useAddressValidationBase({\n isEnabled,\n cacheNamespace: CACHE_NAMESPACE,\n cacheTtlMs: CACHE_TTL_MS,\n rateLimitNamespace: RATE_LIMIT_NAMESPACE,\n rateLimitConfig: RATE_LIMIT_CONFIG,\n requestKey,\n requestUrl: lambdaEnabled ? lambdaUrl : SMARTY_US_STREET_URL,\n requestBody,\n requestParams,\n transformResponse: transformSuggestions,\n effectDeps: [trigger]\n });\n};\n\nexport default useUSAddressValidation;\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAkE,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElE,MAAMG,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAChD,MAAMC,eAAe,GAAG,sBAAsB;AAC9C,MAAMC,YAAY,GAAG,EAAE,GAAG,IAAI;AAC9B,MAAMC,oBAAoB,GAAG,sBAAsB;AACnD,MAAMC,iBAAiB,GAAG;EACxBC,KAAK,EAAE,EAAE;EACTC,QAAQ,EAAE,EAAE,GAAG,IAAI;EACnBC,UAAU,EAAE,EAAE,GAAG;AACnB,CAAC;AACD,MAAMC,oBAAoB,GAAG,iDAAiD;AAE9E,MAAMC,iBAAiB,GAAGA,CAACC,SAAS,GAAG,EAAE,KAAK;EAC5C,MAAMC,UAAU,GAAGC,MAAM,CAACF,SAAS,IAAI,EAAE,CAAC;EAC1C,MAAMG,MAAM,GAAG,IAAIb,GAAG,CAAC,CAAC;EAExB,KAAK,IAAIc,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGH,UAAU,CAAC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,CAAC,GAAG,IAAI;EACrE,MAAM2C,aAAa,GAAGH,aAAa,GAAG,IAAI,GAAG/B,kBAAkB,CAACT,QAAQ,EAAEqC,GAAG,CAACO,UAAU,CAACC,QAAQ,CAAC;EAClG,MAAMC,UAAU,GAAG,wBAAwB9B,eAAe,CAAChB,QAAQ,CAAC,EAAE;EACtE,MAAM+C,SAAS,GAAG,IAAAC,qCAAuB,EACvC,IAAAC,iCAAmB,EAACZ,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAC1C;IAAEa,SAAS,EAAEb,GAAG,CAACa,SAAS;IAAEC,cAAc,EAAEd,GAAG,CAACc;EAAe,CACjE,CAAC;EAED,OAAO,IAAAC,iCAAwB,EAAC;IAC9Bb,SAAS;IACTc,cAAc,EAAE9G,eAAe;IAC/B+G,UAAU,EAAE9G,YAAY;IACxB+G,kBAAkB,EAAE9G,oBAAoB;IACxC+G,eAAe,EAAE9G,iBAAiB;IAClCoG,UAAU;IACVW,UAAU,EAAEjB,aAAa,GAAGO,SAAS,GAAGjG,oBAAoB;IAC5D4F,WAAW;IACXC,aAAa;IACbe,iBAAiB,EAAEvC,oBAAoB;IACvCwC,UAAU,EAAE,CAACxB,OAAO;EACtB,CAAC,CAAC;AACJ,CAAC;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAzH,OAAA,GAEa8F,sBAAsB","ignoreList":[]}
@@ -5,7 +5,24 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.normalizeAddressForm = exports.getAddressForm = exports.clearAddressFormCache = exports.DEFAULT_ADDRESS_FORM = void 0;
7
7
  var _contentstackLib = require("@nuskin/contentstack-lib");
8
+ var _smartyConfig = require("./smartyConfig");
8
9
  const cache = {};
10
+ const DEFAULT_URL_DOMAINS = {
11
+ dev: '',
12
+ test: '',
13
+ sit: '',
14
+ prod: ''
15
+ };
16
+ const DEFAULT_SMARTY_KEYS = {
17
+ usAutocomplete: _smartyConfig.DEFAULT_SMARTY_KEY,
18
+ intlAutocomplete: _smartyConfig.DEFAULT_SMARTY_KEY,
19
+ intlStreet: _smartyConfig.DEFAULT_SMARTY_KEY,
20
+ usStreet: _smartyConfig.DEFAULT_SMARTY_KEY
21
+ };
22
+ const DEFAULT_API_PATHS = {
23
+ validate: _smartyConfig.DEFAULT_VALIDATE_PATH,
24
+ autocomplete: _smartyConfig.DEFAULT_AUTOCOMPLETE_PATH
25
+ };
9
26
  const DEFAULT_ADDRESS_FORM = exports.DEFAULT_ADDRESS_FORM = {
10
27
  addressElements: [],
11
28
  lookupField: 'address1',
@@ -16,7 +33,19 @@ const DEFAULT_ADDRESS_FORM = exports.DEFAULT_ADDRESS_FORM = {
16
33
  entryMode: 'both',
17
34
  validationMode: 'required',
18
35
  minimumAcceptedLevel: 'verified',
19
- includeOrganizationInAddress1: false
36
+ includeOrganizationInAddress1: false,
37
+ urlDomains: {
38
+ ...DEFAULT_URL_DOMAINS
39
+ },
40
+ smartyLambdaEnabled: true,
41
+ skipCache: false,
42
+ smartyResponse: false,
43
+ smartyKeys: {
44
+ ...DEFAULT_SMARTY_KEYS
45
+ },
46
+ apiPaths: {
47
+ ...DEFAULT_API_PATHS
48
+ }
20
49
  };
21
50
  const coerceAddressElement = (element = {}) => {
22
51
  const nextElement = {
@@ -125,6 +154,43 @@ const normalizePostalCodeRegex = postalCodeRegex => {
125
154
  const normalizeEntryMode = entryMode => ['both', 'autocomplete', 'manual'].includes(entryMode) ? entryMode : DEFAULT_ADDRESS_FORM.entryMode;
126
155
  const normalizeValidationMode = validationMode => ['required', 'optional', 'disabled'].includes(validationMode) ? validationMode : DEFAULT_ADDRESS_FORM.validationMode;
127
156
  const normalizeMinimumAcceptedLevel = minimumAcceptedLevel => ['verified', 'partial'].includes(minimumAcceptedLevel) ? minimumAcceptedLevel : DEFAULT_ADDRESS_FORM.minimumAcceptedLevel;
157
+ const normalizeUrlDomain = value => typeof value === 'string' && value.trim() ? value.trim() : '';
158
+ const normalizeUrlDomains = (result = {}) => ({
159
+ dev: normalizeUrlDomain(result.dev_url_domain || result.devUrlDomain),
160
+ test: normalizeUrlDomain(result.test_url_domain || result.testUrlDomain),
161
+ sit: normalizeUrlDomain(result.sit_url_domain || result.sitUrlDomain),
162
+ prod: normalizeUrlDomain(result.prod_url_domain || result.prodUrlDomain)
163
+ });
164
+ const normalizeSmartyLambdaFlag = value => {
165
+ if (value === undefined || value === null || value === '') {
166
+ return true;
167
+ }
168
+ if (typeof value === 'string') {
169
+ return value.trim().toLowerCase() !== 'false';
170
+ }
171
+ return Boolean(value);
172
+ };
173
+ const normalizeOptionalFlag = value => {
174
+ if (value === undefined || value === null || value === '') {
175
+ return false;
176
+ }
177
+ if (typeof value === 'string') {
178
+ return value.trim().toLowerCase() === 'true';
179
+ }
180
+ return Boolean(value);
181
+ };
182
+ const normalizeSmartyKey = value => typeof value === 'string' && value.trim() ? value.trim() : _smartyConfig.DEFAULT_SMARTY_KEY;
183
+ const normalizeSmartyKeys = (result = {}) => ({
184
+ usAutocomplete: normalizeSmartyKey(result.smarty_us_autocomplete_key || result.smartyUsAutocompleteKey),
185
+ intlAutocomplete: normalizeSmartyKey(result.smarty_intl_autocomplete_key || result.smartyIntlAutocompleteKey),
186
+ intlStreet: normalizeSmartyKey(result.smarty_intl_street_key || result.smartyIntlStreetKey),
187
+ usStreet: normalizeSmartyKey(result.smarty_us_street_key || result.smartyUsStreetKey)
188
+ });
189
+ const normalizeApiPath = (value, fallback) => typeof value === 'string' && value.trim() ? value.trim() : fallback;
190
+ const normalizeApiPaths = (result = {}) => ({
191
+ validate: normalizeApiPath(result.validate_path || result.validatePath, _smartyConfig.DEFAULT_VALIDATE_PATH),
192
+ autocomplete: normalizeApiPath(result.autocomplete_path || result.autocompletePath, _smartyConfig.DEFAULT_AUTOCOMPLETE_PATH)
193
+ });
128
194
  const normalizeAddressForm = (result = {}) => {
129
195
  var _addressElements$;
130
196
  const addressElementsSource = result.address_elements || result.addressElements;
@@ -140,20 +206,38 @@ const normalizeAddressForm = (result = {}) => {
140
206
  entryMode: normalizeEntryMode(addressEntry.entry_mode || addressEntry.entryMode),
141
207
  validationMode: normalizeValidationMode(addressEntry.validation_mode || addressEntry.validationMode),
142
208
  minimumAcceptedLevel: normalizeMinimumAcceptedLevel(addressEntry.minimum_accepted_level || addressEntry.minimumAcceptedLevel),
143
- includeOrganizationInAddress1: Boolean(addressEntry.include_organization_in_address1 || addressEntry.includeOrganizationInAddress1)
209
+ includeOrganizationInAddress1: Boolean(addressEntry.include_organization_in_address1 || addressEntry.includeOrganizationInAddress1),
210
+ urlDomains: normalizeUrlDomains(result),
211
+ smartyLambdaEnabled: normalizeSmartyLambdaFlag(result.enable_smarty_lambda !== undefined ? result.enable_smarty_lambda : result.enableSmartyLambda),
212
+ skipCache: normalizeOptionalFlag(result.skip_cache !== undefined ? result.skip_cache : result.skipCache),
213
+ smartyResponse: normalizeOptionalFlag(result.smarty_response !== undefined ? result.smarty_response : result.smartyResponse),
214
+ smartyKeys: normalizeSmartyKeys(result),
215
+ apiPaths: normalizeApiPaths(result)
144
216
  };
145
217
  };
146
218
  exports.normalizeAddressForm = normalizeAddressForm;
219
+ const applySmartyRuntimeConfig = (form = {}) => {
220
+ var _window$location;
221
+ const hostname = typeof window !== 'undefined' && ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || '';
222
+ (0, _smartyConfig.applyStreetAddressApiDomains)(form.urlDomains, hostname);
223
+ (0, _smartyConfig.setSmartyLambdaEnabled)(form.smartyLambdaEnabled);
224
+ (0, _smartyConfig.setSkipCache)(form.skipCache);
225
+ (0, _smartyConfig.setSmartyResponseEnabled)(form.smartyResponse);
226
+ (0, _smartyConfig.applySmartyKeys)(form.smartyKeys);
227
+ (0, _smartyConfig.applySmartyApiPaths)(form.apiPaths);
228
+ };
147
229
  const getAddressForm = async country => {
148
230
  const countryCode = country || 'US';
149
231
  const cacheKey = `${countryCode}`;
150
232
  if (cache[cacheKey]) {
233
+ applySmartyRuntimeConfig(cache[cacheKey]);
151
234
  return cache[cacheKey];
152
235
  }
153
236
  try {
154
237
  const stack = (0, _contentstackLib.getStack)();
155
238
  const results = await stack.getMultiEntries('address_form', true, [countryCode]);
156
239
  const form = normalizeAddressForm(extractAddressForm(results === null || results === void 0 ? void 0 : results[0]));
240
+ applySmartyRuntimeConfig(form);
157
241
  cache[cacheKey] = form;
158
242
  return form;
159
243
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"addressForm.js","names":["_contentstackLib","require","cache","DEFAULT_ADDRESS_FORM","exports","addressElements","lookupField","requiredFields","postalCodeRegex","verifyAfterAutocomplete","wrapAddress1ToAddress2","entryMode","validationMode","minimumAcceptedLevel","includeOrganizationInAddress1","coerceAddressElement","element","nextElement","max_length","undefined","Number","extractAddressForm","addressForm","address_elements","Array","isArray","map","normalizeApiMappings","apiMappings","autocomplete","verification","normalizeAllowedCharacters","allowedCharacters","RegExp","err","normalizeMaxLength","maxLength","trim","parsed","isNaN","normalizeWidth","width","normalizeInputType","fieldType","normalizeAddressElement","field","editable","Boolean","required","inputType","field_type","allowMissingAfterVerification","allow_missing_after_verification","trustVerifiedFormat","trust_verified_format","allowed_characters","api_mappings","normalizeRequiredFields","seen","Set","filter","has","add","normalizePostalCodeRegex","normalizeEntryMode","includes","normalizeValidationMode","normalizeMinimumAcceptedLevel","normalizeAddressForm","result","_addressElements$","addressElementsSource","addressEntry","address_entry","postal_code_regex","verify_after_autocomplete","wrap_address1_to_address2","entry_mode","validation_mode","minimum_accepted_level","include_organization_in_address1","getAddressForm","country","countryCode","cacheKey","stack","getStack","results","getMultiEntries","form","fallback","clearAddressFormCache","Object","keys","forEach"],"sources":["../../../src/addressLookup/utils/addressForm.js"],"sourcesContent":["import { getStack } from '@nuskin/contentstack-lib';\n\nconst cache = {};\nconst DEFAULT_ADDRESS_FORM = {\n addressElements: [],\n lookupField: 'address1',\n requiredFields: [],\n postalCodeRegex: null,\n verifyAfterAutocomplete: false,\n wrapAddress1ToAddress2: false,\n entryMode: 'both',\n validationMode: 'required',\n minimumAcceptedLevel: 'verified',\n includeOrganizationInAddress1: false\n};\n\nconst coerceAddressElement = (element = {}) => {\n const nextElement = { ...element };\n\n if (nextElement.max_length !== undefined && nextElement.max_length !== null) {\n nextElement.max_length = Number(nextElement.max_length);\n }\n\n return nextElement;\n};\n\nconst extractAddressForm = (addressForm = null) => {\n if (!addressForm || typeof addressForm !== 'object') {\n return addressForm;\n }\n\n return {\n ...addressForm,\n address_elements: Array.isArray(addressForm.address_elements) ?\n addressForm.address_elements.map(coerceAddressElement) :\n []\n };\n};\n\nconst normalizeApiMappings = (apiMappings = null) => {\n if (!apiMappings || typeof apiMappings !== 'object') {\n return null;\n }\n\n const autocomplete = typeof apiMappings.autocomplete === 'string' ? apiMappings.autocomplete : '';\n const verification = typeof apiMappings.verification === 'string' ? apiMappings.verification : '';\n\n if (!autocomplete && !verification) {\n return null;\n }\n\n return {\n autocomplete: autocomplete || null,\n verification: verification || null\n };\n};\n\nconst normalizeAllowedCharacters = (allowedCharacters) => {\n if (!allowedCharacters || typeof allowedCharacters !== 'string') {\n return null;\n }\n\n try {\n return new RegExp(allowedCharacters);\n } catch (err) {\n return null;\n }\n};\n\nconst normalizeMaxLength = (element = {}) => {\n if (typeof element.maxLength === 'number') {\n return element.maxLength;\n }\n\n if (typeof element.maxLength === 'string' && element.maxLength.trim() !== '') {\n const parsed = Number(element.maxLength);\n return Number.isNaN(parsed) ? null : parsed;\n }\n\n if (typeof element.max_length === 'number') {\n return element.max_length;\n }\n\n if (typeof element.max_length === 'string' && element.max_length.trim() !== '') {\n const parsed = Number(element.max_length);\n return Number.isNaN(parsed) ? null : parsed;\n }\n\n return null;\n};\n\nconst normalizeWidth = (width) => {\n if (width === 'half' || width === 'third') {\n return width;\n }\n\n return 'full';\n};\n\nconst normalizeInputType = (fieldType) => (fieldType === 'select' ? 'select' : 'text');\n\nconst normalizeAddressElement = (element = {}) => ({\n field: element.field || '',\n width: normalizeWidth(element.width),\n editable: Boolean(element.editable),\n maxLength: normalizeMaxLength(element),\n required: Boolean(element.required),\n inputType: normalizeInputType(element.field_type || element.fieldType),\n allowMissingAfterVerification: Boolean(\n element.allow_missing_after_verification || element.allowMissingAfterVerification\n ),\n trustVerifiedFormat: Boolean(element.trust_verified_format || element.trustVerifiedFormat),\n allowedCharacters: normalizeAllowedCharacters(element.allowedCharacters || element.allowed_characters),\n apiMappings: normalizeApiMappings(element.api_mappings || element.apiMappings)\n});\n\nconst normalizeRequiredFields = (addressElements = []) => {\n const seen = new Set();\n\n return addressElements\n .filter((element) => element.required && element.field)\n .map((element) => element.field)\n .filter((field) => {\n if (seen.has(field)) {\n return false;\n }\n seen.add(field);\n return true;\n });\n};\n\nconst normalizePostalCodeRegex = (postalCodeRegex) => {\n if (!postalCodeRegex) {\n return null;\n }\n\n if (postalCodeRegex instanceof RegExp) {\n return postalCodeRegex;\n }\n\n if (typeof postalCodeRegex !== 'string') {\n return null;\n }\n\n try {\n return new RegExp(postalCodeRegex);\n } catch (err) {\n return null;\n }\n};\n\nconst normalizeEntryMode = (entryMode) => (\n ['both', 'autocomplete', 'manual'].includes(entryMode) ? entryMode : DEFAULT_ADDRESS_FORM.entryMode\n);\n\nconst normalizeValidationMode = (validationMode) => (\n ['required', 'optional', 'disabled'].includes(validationMode) ?\n validationMode :\n DEFAULT_ADDRESS_FORM.validationMode\n);\n\nconst normalizeMinimumAcceptedLevel = (minimumAcceptedLevel) => (\n ['verified', 'partial'].includes(minimumAcceptedLevel) ?\n minimumAcceptedLevel :\n DEFAULT_ADDRESS_FORM.minimumAcceptedLevel\n);\n\nexport const normalizeAddressForm = (result = {}) => {\n const addressElementsSource = result.address_elements || result.addressElements;\n const addressEntry = result.address_entry || result.addressEntry || result;\n\n const addressElements = Array.isArray(addressElementsSource) ?\n addressElementsSource.map(normalizeAddressElement).filter((element) => element.field) :\n [];\n\n return {\n addressElements,\n lookupField: addressElements[0]?.field || DEFAULT_ADDRESS_FORM.lookupField,\n requiredFields: normalizeRequiredFields(addressElements),\n postalCodeRegex: normalizePostalCodeRegex(result.postal_code_regex || result.postalCodeRegex),\n verifyAfterAutocomplete: Boolean(result.verify_after_autocomplete || result.verifyAfterAutocomplete),\n wrapAddress1ToAddress2: Boolean(result.wrap_address1_to_address2 || result.wrapAddress1ToAddress2),\n entryMode: normalizeEntryMode(addressEntry.entry_mode || addressEntry.entryMode),\n validationMode: normalizeValidationMode(addressEntry.validation_mode || addressEntry.validationMode),\n minimumAcceptedLevel: normalizeMinimumAcceptedLevel(\n addressEntry.minimum_accepted_level || addressEntry.minimumAcceptedLevel\n ),\n includeOrganizationInAddress1: Boolean(\n addressEntry.include_organization_in_address1 || addressEntry.includeOrganizationInAddress1\n )\n };\n};\n\nexport const getAddressForm = async (country) => {\n const countryCode = country || 'US';\n const cacheKey = `${countryCode}`;\n\n if (cache[cacheKey]) {\n return cache[cacheKey];\n }\n\n try {\n const stack = getStack();\n const results = await stack.getMultiEntries('address_form', true, [countryCode]);\n const form = normalizeAddressForm(extractAddressForm(results?.[0]));\n cache[cacheKey] = form;\n return form;\n } catch (err) {\n const fallback = { ...DEFAULT_ADDRESS_FORM };\n cache[cacheKey] = fallback;\n return fallback;\n }\n};\n\nexport const clearAddressFormCache = () => {\n Object.keys(cache).forEach((cacheKey) => {\n delete cache[cacheKey];\n });\n};\n\nexport { DEFAULT_ADDRESS_FORM };\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,MAAMC,KAAK,GAAG,CAAC,CAAC;AAChB,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG;EAC3BE,eAAe,EAAE,EAAE;EACnBC,WAAW,EAAE,UAAU;EACvBC,cAAc,EAAE,EAAE;EAClBC,eAAe,EAAE,IAAI;EACrBC,uBAAuB,EAAE,KAAK;EAC9BC,sBAAsB,EAAE,KAAK;EAC7BC,SAAS,EAAE,MAAM;EACjBC,cAAc,EAAE,UAAU;EAC1BC,oBAAoB,EAAE,UAAU;EAChCC,6BAA6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,GAAG,GAAGD,WAAW,EAAE;EAEjC,IAAIjF,KAAK,CAACkF,QAAQ,CAAC,EAAE;IACnB,OAAOlF,KAAK,CAACkF,QAAQ,CAAC;EACxB;EAEA,IAAI;IACF,MAAMC,KAAK,GAAG,IAAAC,yBAAQ,EAAC,CAAC;IACxB,MAAMC,OAAO,GAAG,MAAMF,KAAK,CAACG,eAAe,CAAC,cAAc,EAAE,IAAI,EAAE,CAACL,WAAW,CAAC,CAAC;IAChF,MAAMM,IAAI,GAAGrB,oBAAoB,CAAC/C,kBAAkB,CAACkE,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAG,CAAC,CAAC,CAAC,CAAC;IACnErF,KAAK,CAACkF,QAAQ,CAAC,GAAGK,IAAI;IACtB,OAAOA,IAAI;EACb,CAAC,CAAC,OAAOvD,GAAG,EAAE;IACZ,MAAMwD,QAAQ,GAAG;MAAE,GAAGvF;IAAqB,CAAC;IAC5CD,KAAK,CAACkF,QAAQ,CAAC,GAAGM,QAAQ;IAC1B,OAAOA,QAAQ;EACjB;AACF,CAAC;AAACtF,OAAA,CAAA6E,cAAA,GAAAA,cAAA;AAEK,MAAMU,qBAAqB,GAAGA,CAAA,KAAM;EACzCC,MAAM,CAACC,IAAI,CAAC3F,KAAK,CAAC,CAAC4F,OAAO,CAAEV,QAAQ,IAAK;IACvC,OAAOlF,KAAK,CAACkF,QAAQ,CAAC;EACxB,CAAC,CAAC;AACJ,CAAC;AAAChF,OAAA,CAAAuF,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"addressForm.js","names":["_contentstackLib","require","_smartyConfig","cache","DEFAULT_URL_DOMAINS","dev","test","sit","prod","DEFAULT_SMARTY_KEYS","usAutocomplete","DEFAULT_SMARTY_KEY","intlAutocomplete","intlStreet","usStreet","DEFAULT_API_PATHS","validate","DEFAULT_VALIDATE_PATH","autocomplete","DEFAULT_AUTOCOMPLETE_PATH","DEFAULT_ADDRESS_FORM","exports","addressElements","lookupField","requiredFields","postalCodeRegex","verifyAfterAutocomplete","wrapAddress1ToAddress2","entryMode","validationMode","minimumAcceptedLevel","includeOrganizationInAddress1","urlDomains","smartyLambdaEnabled","skipCache","smartyResponse","smartyKeys","apiPaths","coerceAddressElement","element","nextElement","max_length","undefined","Number","extractAddressForm","addressForm","address_elements","Array","isArray","map","normalizeApiMappings","apiMappings","verification","normalizeAllowedCharacters","allowedCharacters","RegExp","err","normalizeMaxLength","maxLength","trim","parsed","isNaN","normalizeWidth","width","normalizeInputType","fieldType","normalizeAddressElement","field","editable","Boolean","required","inputType","field_type","allowMissingAfterVerification","allow_missing_after_verification","trustVerifiedFormat","trust_verified_format","allowed_characters","api_mappings","normalizeRequiredFields","seen","Set","filter","has","add","normalizePostalCodeRegex","normalizeEntryMode","includes","normalizeValidationMode","normalizeMinimumAcceptedLevel","normalizeUrlDomain","value","normalizeUrlDomains","result","dev_url_domain","devUrlDomain","test_url_domain","testUrlDomain","sit_url_domain","sitUrlDomain","prod_url_domain","prodUrlDomain","normalizeSmartyLambdaFlag","toLowerCase","normalizeOptionalFlag","normalizeSmartyKey","normalizeSmartyKeys","smarty_us_autocomplete_key","smartyUsAutocompleteKey","smarty_intl_autocomplete_key","smartyIntlAutocompleteKey","smarty_intl_street_key","smartyIntlStreetKey","smarty_us_street_key","smartyUsStreetKey","normalizeApiPath","fallback","normalizeApiPaths","validate_path","validatePath","autocomplete_path","autocompletePath","normalizeAddressForm","_addressElements$","addressElementsSource","addressEntry","address_entry","postal_code_regex","verify_after_autocomplete","wrap_address1_to_address2","entry_mode","validation_mode","minimum_accepted_level","include_organization_in_address1","enable_smarty_lambda","enableSmartyLambda","skip_cache","smarty_response","applySmartyRuntimeConfig","form","_window$location","hostname","window","location","applyStreetAddressApiDomains","setSmartyLambdaEnabled","setSkipCache","setSmartyResponseEnabled","applySmartyKeys","applySmartyApiPaths","getAddressForm","country","countryCode","cacheKey","stack","getStack","results","getMultiEntries","clearAddressFormCache","Object","keys","forEach"],"sources":["../../../src/addressLookup/utils/addressForm.js"],"sourcesContent":["import { getStack } from '@nuskin/contentstack-lib';\nimport {\n applyStreetAddressApiDomains,\n setSmartyLambdaEnabled,\n applySmartyKeys,\n applySmartyApiPaths,\n setSkipCache,\n setSmartyResponseEnabled,\n DEFAULT_SMARTY_KEY,\n DEFAULT_VALIDATE_PATH,\n DEFAULT_AUTOCOMPLETE_PATH\n} from './smartyConfig';\n\nconst cache = {};\nconst DEFAULT_URL_DOMAINS = {\n dev: '',\n test: '',\n sit: '',\n prod: ''\n};\nconst DEFAULT_SMARTY_KEYS = {\n usAutocomplete: DEFAULT_SMARTY_KEY,\n intlAutocomplete: DEFAULT_SMARTY_KEY,\n intlStreet: DEFAULT_SMARTY_KEY,\n usStreet: DEFAULT_SMARTY_KEY\n};\nconst DEFAULT_API_PATHS = {\n validate: DEFAULT_VALIDATE_PATH,\n autocomplete: DEFAULT_AUTOCOMPLETE_PATH\n};\nconst DEFAULT_ADDRESS_FORM = {\n addressElements: [],\n lookupField: 'address1',\n requiredFields: [],\n postalCodeRegex: null,\n verifyAfterAutocomplete: false,\n wrapAddress1ToAddress2: false,\n entryMode: 'both',\n validationMode: 'required',\n minimumAcceptedLevel: 'verified',\n includeOrganizationInAddress1: false,\n urlDomains: { ...DEFAULT_URL_DOMAINS },\n smartyLambdaEnabled: true,\n skipCache: false,\n smartyResponse: false,\n smartyKeys: { ...DEFAULT_SMARTY_KEYS },\n apiPaths: { ...DEFAULT_API_PATHS }\n};\n\nconst coerceAddressElement = (element = {}) => {\n const nextElement = { ...element };\n\n if (nextElement.max_length !== undefined && nextElement.max_length !== null) {\n nextElement.max_length = Number(nextElement.max_length);\n }\n\n return nextElement;\n};\n\nconst extractAddressForm = (addressForm = null) => {\n if (!addressForm || typeof addressForm !== 'object') {\n return addressForm;\n }\n\n return {\n ...addressForm,\n address_elements: Array.isArray(addressForm.address_elements) ?\n addressForm.address_elements.map(coerceAddressElement) :\n []\n };\n};\n\nconst normalizeApiMappings = (apiMappings = null) => {\n if (!apiMappings || typeof apiMappings !== 'object') {\n return null;\n }\n\n const autocomplete = typeof apiMappings.autocomplete === 'string' ? apiMappings.autocomplete : '';\n const verification = typeof apiMappings.verification === 'string' ? apiMappings.verification : '';\n\n if (!autocomplete && !verification) {\n return null;\n }\n\n return {\n autocomplete: autocomplete || null,\n verification: verification || null\n };\n};\n\nconst normalizeAllowedCharacters = (allowedCharacters) => {\n if (!allowedCharacters || typeof allowedCharacters !== 'string') {\n return null;\n }\n\n try {\n return new RegExp(allowedCharacters);\n } catch (err) {\n return null;\n }\n};\n\nconst normalizeMaxLength = (element = {}) => {\n if (typeof element.maxLength === 'number') {\n return element.maxLength;\n }\n\n if (typeof element.maxLength === 'string' && element.maxLength.trim() !== '') {\n const parsed = Number(element.maxLength);\n return Number.isNaN(parsed) ? null : parsed;\n }\n\n if (typeof element.max_length === 'number') {\n return element.max_length;\n }\n\n if (typeof element.max_length === 'string' && element.max_length.trim() !== '') {\n const parsed = Number(element.max_length);\n return Number.isNaN(parsed) ? null : parsed;\n }\n\n return null;\n};\n\nconst normalizeWidth = (width) => {\n if (width === 'half' || width === 'third') {\n return width;\n }\n\n return 'full';\n};\n\nconst normalizeInputType = (fieldType) => (fieldType === 'select' ? 'select' : 'text');\n\nconst normalizeAddressElement = (element = {}) => ({\n field: element.field || '',\n width: normalizeWidth(element.width),\n editable: Boolean(element.editable),\n maxLength: normalizeMaxLength(element),\n required: Boolean(element.required),\n inputType: normalizeInputType(element.field_type || element.fieldType),\n allowMissingAfterVerification: Boolean(\n element.allow_missing_after_verification || element.allowMissingAfterVerification\n ),\n trustVerifiedFormat: Boolean(element.trust_verified_format || element.trustVerifiedFormat),\n allowedCharacters: normalizeAllowedCharacters(element.allowedCharacters || element.allowed_characters),\n apiMappings: normalizeApiMappings(element.api_mappings || element.apiMappings)\n});\n\nconst normalizeRequiredFields = (addressElements = []) => {\n const seen = new Set();\n\n return addressElements\n .filter((element) => element.required && element.field)\n .map((element) => element.field)\n .filter((field) => {\n if (seen.has(field)) {\n return false;\n }\n seen.add(field);\n return true;\n });\n};\n\nconst normalizePostalCodeRegex = (postalCodeRegex) => {\n if (!postalCodeRegex) {\n return null;\n }\n\n if (postalCodeRegex instanceof RegExp) {\n return postalCodeRegex;\n }\n\n if (typeof postalCodeRegex !== 'string') {\n return null;\n }\n\n try {\n return new RegExp(postalCodeRegex);\n } catch (err) {\n return null;\n }\n};\n\nconst normalizeEntryMode = (entryMode) => (\n ['both', 'autocomplete', 'manual'].includes(entryMode) ? entryMode : DEFAULT_ADDRESS_FORM.entryMode\n);\n\nconst normalizeValidationMode = (validationMode) => (\n ['required', 'optional', 'disabled'].includes(validationMode) ?\n validationMode :\n DEFAULT_ADDRESS_FORM.validationMode\n);\n\nconst normalizeMinimumAcceptedLevel = (minimumAcceptedLevel) => (\n ['verified', 'partial'].includes(minimumAcceptedLevel) ?\n minimumAcceptedLevel :\n DEFAULT_ADDRESS_FORM.minimumAcceptedLevel\n);\n\nconst normalizeUrlDomain = (value) => (\n typeof value === 'string' && value.trim() ? value.trim() : ''\n);\n\nconst normalizeUrlDomains = (result = {}) => ({\n dev: normalizeUrlDomain(result.dev_url_domain || result.devUrlDomain),\n test: normalizeUrlDomain(result.test_url_domain || result.testUrlDomain),\n sit: normalizeUrlDomain(result.sit_url_domain || result.sitUrlDomain),\n prod: normalizeUrlDomain(result.prod_url_domain || result.prodUrlDomain)\n});\n\nconst normalizeSmartyLambdaFlag = (value) => {\n if (value === undefined || value === null || value === '') {\n return true;\n }\n\n if (typeof value === 'string') {\n return value.trim().toLowerCase() !== 'false';\n }\n\n return Boolean(value);\n};\n\nconst normalizeOptionalFlag = (value) => {\n if (value === undefined || value === null || value === '') {\n return false;\n }\n\n if (typeof value === 'string') {\n return value.trim().toLowerCase() === 'true';\n }\n\n return Boolean(value);\n};\n\nconst normalizeSmartyKey = (value) => (\n typeof value === 'string' && value.trim() ? value.trim() : DEFAULT_SMARTY_KEY\n);\n\nconst normalizeSmartyKeys = (result = {}) => ({\n usAutocomplete: normalizeSmartyKey(result.smarty_us_autocomplete_key || result.smartyUsAutocompleteKey),\n intlAutocomplete: normalizeSmartyKey(result.smarty_intl_autocomplete_key || result.smartyIntlAutocompleteKey),\n intlStreet: normalizeSmartyKey(result.smarty_intl_street_key || result.smartyIntlStreetKey),\n usStreet: normalizeSmartyKey(result.smarty_us_street_key || result.smartyUsStreetKey)\n});\n\nconst normalizeApiPath = (value, fallback) => (\n typeof value === 'string' && value.trim() ? value.trim() : fallback\n);\n\nconst normalizeApiPaths = (result = {}) => ({\n validate: normalizeApiPath(result.validate_path || result.validatePath, DEFAULT_VALIDATE_PATH),\n autocomplete: normalizeApiPath(\n result.autocomplete_path || result.autocompletePath,\n DEFAULT_AUTOCOMPLETE_PATH\n )\n});\n\nexport const normalizeAddressForm = (result = {}) => {\n const addressElementsSource = result.address_elements || result.addressElements;\n const addressEntry = result.address_entry || result.addressEntry || result;\n\n const addressElements = Array.isArray(addressElementsSource) ?\n addressElementsSource.map(normalizeAddressElement).filter((element) => element.field) :\n [];\n\n return {\n addressElements,\n lookupField: addressElements[0]?.field || DEFAULT_ADDRESS_FORM.lookupField,\n requiredFields: normalizeRequiredFields(addressElements),\n postalCodeRegex: normalizePostalCodeRegex(result.postal_code_regex || result.postalCodeRegex),\n verifyAfterAutocomplete: Boolean(result.verify_after_autocomplete || result.verifyAfterAutocomplete),\n wrapAddress1ToAddress2: Boolean(result.wrap_address1_to_address2 || result.wrapAddress1ToAddress2),\n entryMode: normalizeEntryMode(addressEntry.entry_mode || addressEntry.entryMode),\n validationMode: normalizeValidationMode(addressEntry.validation_mode || addressEntry.validationMode),\n minimumAcceptedLevel: normalizeMinimumAcceptedLevel(\n addressEntry.minimum_accepted_level || addressEntry.minimumAcceptedLevel\n ),\n includeOrganizationInAddress1: Boolean(\n addressEntry.include_organization_in_address1 || addressEntry.includeOrganizationInAddress1\n ),\n urlDomains: normalizeUrlDomains(result),\n smartyLambdaEnabled: normalizeSmartyLambdaFlag(\n result.enable_smarty_lambda !== undefined ? result.enable_smarty_lambda : result.enableSmartyLambda\n ),\n skipCache: normalizeOptionalFlag(\n result.skip_cache !== undefined ? result.skip_cache : result.skipCache\n ),\n smartyResponse: normalizeOptionalFlag(\n result.smarty_response !== undefined ? result.smarty_response : result.smartyResponse\n ),\n smartyKeys: normalizeSmartyKeys(result),\n apiPaths: normalizeApiPaths(result)\n };\n};\n\nconst applySmartyRuntimeConfig = (form = {}) => {\n const hostname = (typeof window !== 'undefined' && window.location?.hostname) || '';\n applyStreetAddressApiDomains(form.urlDomains, hostname);\n setSmartyLambdaEnabled(form.smartyLambdaEnabled);\n setSkipCache(form.skipCache);\n setSmartyResponseEnabled(form.smartyResponse);\n applySmartyKeys(form.smartyKeys);\n applySmartyApiPaths(form.apiPaths);\n};\n\nexport const getAddressForm = async (country) => {\n const countryCode = country || 'US';\n const cacheKey = `${countryCode}`;\n\n if (cache[cacheKey]) {\n applySmartyRuntimeConfig(cache[cacheKey]);\n return cache[cacheKey];\n }\n\n try {\n const stack = getStack();\n const results = await stack.getMultiEntries('address_form', true, [countryCode]);\n const form = normalizeAddressForm(extractAddressForm(results?.[0]));\n applySmartyRuntimeConfig(form);\n cache[cacheKey] = form;\n return form;\n } catch (err) {\n const fallback = { ...DEFAULT_ADDRESS_FORM };\n cache[cacheKey] = fallback;\n return fallback;\n }\n};\n\nexport const clearAddressFormCache = () => {\n Object.keys(cache).forEach((cacheKey) => {\n delete cache[cacheKey];\n });\n};\n\nexport { DEFAULT_ADDRESS_FORM };\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAYA,MAAME,KAAK,GAAG,CAAC,CAAC;AAChB,MAAMC,mBAAmB,GAAG;EAC1BC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE,EAAE;EACRC,GAAG,EAAE,EAAE;EACPC,IAAI,EAAE;AACR,CAAC;AACD,MAAMC,mBAAmB,GAAG;EAC1BC,c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Z,MAAM4D,QAAQ,GAAG;MAAE,GAAGhG;IAAqB,CAAC;IAC5CjB,KAAK,CAACsJ,QAAQ,CAAC,GAAGrC,QAAQ;IAC1B,OAAOA,QAAQ;EACjB;AACF,CAAC;AAAC/F,OAAA,CAAAiI,cAAA,GAAAA,cAAA;AAEK,MAAMQ,qBAAqB,GAAGA,CAAA,KAAM;EACzCC,MAAM,CAACC,IAAI,CAAC7J,KAAK,CAAC,CAAC8J,OAAO,CAAER,QAAQ,IAAK;IACvC,OAAOtJ,KAAK,CAACsJ,QAAQ,CAAC;EACxB,CAAC,CAAC;AACJ,CAAC;AAACpI,OAAA,CAAAyI,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -3,9 +3,244 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SMARTY_US_STREET_KEY = exports.SMARTY_US_AUTOCOMPLETE_KEY = exports.SMARTY_INTL_STREET_KEY = exports.SMARTY_INTL_AUTOCOMPLETE_KEY = void 0;
7
- const SMARTY_US_AUTOCOMPLETE_KEY = exports.SMARTY_US_AUTOCOMPLETE_KEY = '22361352819063501';
8
- const SMARTY_INTL_AUTOCOMPLETE_KEY = exports.SMARTY_INTL_AUTOCOMPLETE_KEY = '22361352819063501';
9
- const SMARTY_INTL_STREET_KEY = exports.SMARTY_INTL_STREET_KEY = '22361352819063501';
10
- const SMARTY_US_STREET_KEY = exports.SMARTY_US_STREET_KEY = '22361352819063501';
6
+ exports.setStreetAddressApiUrl = exports.setSmartyResponseEnabled = exports.setSmartyLambdaEnabled = exports.setSkipCache = exports.resolveStreetAddressApiUrl = exports.resolveEnvironment = exports.isSmartyResponseEnabled = exports.isSmartyLambdaEnabled = exports.isSkipCacheEnabled = exports.getStreetAddressApiUrl = exports.getSmartyUsStreetKey = exports.getSmartyUsAutocompleteKey = exports.getSmartyIntlStreetKey = exports.getSmartyIntlAutocompleteKey = exports.getSmartyApiPaths = exports.deriveSmartyConfig = exports.buildSmartyEndpoint = exports.applyStreetAddressApiDomains = exports.applySmartyKeys = exports.applySmartyApiPaths = exports.appendLambdaQueryParams = exports.DEFAULT_VALIDATE_PATH = exports.DEFAULT_STREET_ADDRESS_API_URL = exports.DEFAULT_SMARTY_KEY = exports.DEFAULT_AUTOCOMPLETE_PATH = void 0;
7
+ const STREET_ADDRESS_PATH = '/street-address';
8
+ const DEFAULT_STREET_ADDRESS_API_URL = exports.DEFAULT_STREET_ADDRESS_API_URL = `https://apis.nuskin.com${STREET_ADDRESS_PATH}`;
9
+ const DEFAULT_SMARTY_KEY = exports.DEFAULT_SMARTY_KEY = '22361352819063501';
10
+ const DEFAULT_VALIDATE_PATH = exports.DEFAULT_VALIDATE_PATH = '/validate/v1';
11
+ const DEFAULT_AUTOCOMPLETE_PATH = exports.DEFAULT_AUTOCOMPLETE_PATH = '/autocomplete/v1';
12
+ const DEFAULT_API_PATHS = {
13
+ validate: DEFAULT_VALIDATE_PATH,
14
+ autocomplete: DEFAULT_AUTOCOMPLETE_PATH
15
+ };
16
+ let _streetAddressApiUrl = DEFAULT_STREET_ADDRESS_API_URL;
17
+ let _smartyLambdaEnabled = true;
18
+ let _skipCache = false;
19
+ let _smartyResponse = false;
20
+ const _smartyKeys = {
21
+ usAutocomplete: DEFAULT_SMARTY_KEY,
22
+ intlAutocomplete: DEFAULT_SMARTY_KEY,
23
+ intlStreet: DEFAULT_SMARTY_KEY,
24
+ usStreet: DEFAULT_SMARTY_KEY
25
+ };
26
+ const _apiPaths = {
27
+ ...DEFAULT_API_PATHS
28
+ };
29
+ const setStreetAddressApiUrl = url => {
30
+ _streetAddressApiUrl = url;
31
+ };
32
+ exports.setStreetAddressApiUrl = setStreetAddressApiUrl;
33
+ const getStreetAddressApiUrl = () => _streetAddressApiUrl;
34
+ exports.getStreetAddressApiUrl = getStreetAddressApiUrl;
35
+ const setSmartyLambdaEnabled = enabled => {
36
+ _smartyLambdaEnabled = enabled !== false;
37
+ };
38
+ exports.setSmartyLambdaEnabled = setSmartyLambdaEnabled;
39
+ const isSmartyLambdaEnabled = () => _smartyLambdaEnabled;
40
+ exports.isSmartyLambdaEnabled = isSmartyLambdaEnabled;
41
+ const setSkipCache = enabled => {
42
+ _skipCache = Boolean(enabled);
43
+ };
44
+ exports.setSkipCache = setSkipCache;
45
+ const isSkipCacheEnabled = () => _skipCache;
46
+ exports.isSkipCacheEnabled = isSkipCacheEnabled;
47
+ const setSmartyResponseEnabled = enabled => {
48
+ _smartyResponse = Boolean(enabled);
49
+ };
50
+ exports.setSmartyResponseEnabled = setSmartyResponseEnabled;
51
+ const isSmartyResponseEnabled = () => _smartyResponse;
52
+ exports.isSmartyResponseEnabled = isSmartyResponseEnabled;
53
+ const appendLambdaQueryParams = (url, {
54
+ skipCache = false,
55
+ smartyResponse = false
56
+ } = {}) => {
57
+ const params = [];
58
+ if (skipCache) params.push('skipCache=true');
59
+ if (smartyResponse) params.push('smartyResponse=true');
60
+ if (!params.length) {
61
+ return url;
62
+ }
63
+ const separator = url.includes('?') ? '&' : '?';
64
+ return `${url}${separator}${params.join('&')}`;
65
+ };
66
+ exports.appendLambdaQueryParams = appendLambdaQueryParams;
67
+ const getSmartyUsAutocompleteKey = () => _smartyKeys.usAutocomplete;
68
+ exports.getSmartyUsAutocompleteKey = getSmartyUsAutocompleteKey;
69
+ const getSmartyIntlAutocompleteKey = () => _smartyKeys.intlAutocomplete;
70
+ exports.getSmartyIntlAutocompleteKey = getSmartyIntlAutocompleteKey;
71
+ const getSmartyIntlStreetKey = () => _smartyKeys.intlStreet;
72
+ exports.getSmartyIntlStreetKey = getSmartyIntlStreetKey;
73
+ const getSmartyUsStreetKey = () => _smartyKeys.usStreet;
74
+ exports.getSmartyUsStreetKey = getSmartyUsStreetKey;
75
+ const applySmartyKeys = (keys = {}) => {
76
+ if (!keys || typeof keys !== 'object') {
77
+ return;
78
+ }
79
+ if (keys.usAutocomplete) _smartyKeys.usAutocomplete = keys.usAutocomplete;
80
+ if (keys.intlAutocomplete) _smartyKeys.intlAutocomplete = keys.intlAutocomplete;
81
+ if (keys.intlStreet) _smartyKeys.intlStreet = keys.intlStreet;
82
+ if (keys.usStreet) _smartyKeys.usStreet = keys.usStreet;
83
+ };
84
+ exports.applySmartyKeys = applySmartyKeys;
85
+ const applySmartyApiPaths = (paths = {}) => {
86
+ if (!paths || typeof paths !== 'object') {
87
+ return;
88
+ }
89
+ if (paths.validate) _apiPaths.validate = paths.validate;
90
+ if (paths.autocomplete) _apiPaths.autocomplete = paths.autocomplete;
91
+ };
92
+ exports.applySmartyApiPaths = applySmartyApiPaths;
93
+ const getSmartyApiPaths = () => ({
94
+ ..._apiPaths
95
+ });
96
+ exports.getSmartyApiPaths = getSmartyApiPaths;
97
+ const getCurrentHostname = () => {
98
+ if (typeof window === 'undefined' || !window.location) {
99
+ return '';
100
+ }
101
+ return window.location.hostname || '';
102
+ };
103
+ const ENV_TOKEN_PATTERNS = {
104
+ local: /(^|[.-])local([.-]|$)/,
105
+ sit: /(^|[.-])sit([.-]|$)/,
106
+ dev: /(^|[.-])dev([.-]|$)/,
107
+ test: /(^|[.-])(test|tst)([.-]|$)/
108
+ };
109
+ const resolveEnvironment = hostname => {
110
+ const resolvedHost = typeof hostname === 'string' && hostname ? hostname : getCurrentHostname();
111
+ const normalized = resolvedHost.toLowerCase();
112
+ if (!normalized || normalized === 'localhost' || ENV_TOKEN_PATTERNS.local.test(normalized)) {
113
+ return 'dev';
114
+ }
115
+ if (ENV_TOKEN_PATTERNS.sit.test(normalized)) {
116
+ return 'sit';
117
+ }
118
+ if (ENV_TOKEN_PATTERNS.dev.test(normalized)) {
119
+ return 'dev';
120
+ }
121
+ if (ENV_TOKEN_PATTERNS.test.test(normalized)) {
122
+ return 'test';
123
+ }
124
+ return 'prod';
125
+ };
126
+ exports.resolveEnvironment = resolveEnvironment;
127
+ const SLASH_CHAR_CODE = 47;
128
+ const stripTrailingSlashes = value => {
129
+ let endIndex = value.length;
130
+ while (endIndex > 0 && value.charCodeAt(endIndex - 1) === SLASH_CHAR_CODE) {
131
+ endIndex -= 1;
132
+ }
133
+ return value.slice(0, endIndex);
134
+ };
135
+ const normalizeDomain = domain => typeof domain === 'string' ? stripTrailingSlashes(domain.trim()) : '';
136
+ const buildStreetAddressUrl = domain => {
137
+ const normalized = normalizeDomain(domain);
138
+ if (!normalized) {
139
+ return '';
140
+ }
141
+ const hasProtocol = normalized.startsWith('http://') || normalized.startsWith('https://');
142
+ const base = hasProtocol ? normalized : `https://${normalized}`;
143
+ return `${base}${STREET_ADDRESS_PATH}`;
144
+ };
145
+
146
+ // Content authors may omit the leading slash or add a trailing one.
147
+ const normalizePathSegment = (value, fallback) => {
148
+ const trimmed = typeof value === 'string' ? stripTrailingSlashes(value.trim()) : '';
149
+ if (!trimmed) {
150
+ return fallback;
151
+ }
152
+ return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
153
+ };
154
+ const buildSmartyEndpoint = (cfg, operation, countryCode) => {
155
+ var _cfg$apiPaths;
156
+ const fallback = DEFAULT_API_PATHS[operation] || '';
157
+ const path = normalizePathSegment(cfg === null || cfg === void 0 || (_cfg$apiPaths = cfg.apiPaths) === null || _cfg$apiPaths === void 0 ? void 0 : _cfg$apiPaths[operation], fallback);
158
+ return `${(cfg === null || cfg === void 0 ? void 0 : cfg.streetAddressApiUrl) || ''}${path}/${countryCode}`;
159
+ };
160
+ exports.buildSmartyEndpoint = buildSmartyEndpoint;
161
+ const getAppConfigApiDomain = () => {
162
+ if (typeof window === 'undefined' || !window.APP_CONFIG) {
163
+ return '';
164
+ }
165
+ const domain = window.APP_CONFIG.apiDomainName;
166
+ return typeof domain === 'string' ? domain.trim() : '';
167
+ };
168
+ const isLocalHost = hostname => {
169
+ const host = (typeof hostname === 'string' && hostname ? hostname : getCurrentHostname()).toLowerCase();
170
+ return !host || host === 'localhost' || host.includes('local.');
171
+ };
172
+ const resolveStreetAddressApiUrl = (urlDomains, hostname) => {
173
+ const appConfigDomain = getAppConfigApiDomain();
174
+
175
+ // window.APP_CONFIG.apiDomainName is injected per deployed environment. On local
176
+ // dev it is absent or points at the default host, so skip it there and fall through
177
+ // to the Contentstack domain switch (which maps localhost -> dev).
178
+ if (appConfigDomain && !isLocalHost(hostname)) {
179
+ return buildStreetAddressUrl(appConfigDomain);
180
+ }
181
+ if (!urlDomains || typeof urlDomains !== 'object') {
182
+ return '';
183
+ }
184
+
185
+ // Guard: if hostname cannot be determined (SSR or uninitialized browser), skip
186
+ // environment-based lookup entirely. Without this, an empty hostname maps to 'dev',
187
+ // silently routing production traffic to the dev base URL.
188
+ const effectiveHostname = typeof hostname === 'string' && hostname ? hostname : getCurrentHostname();
189
+ if (!effectiveHostname) {
190
+ return '';
191
+ }
192
+ const environment = resolveEnvironment(effectiveHostname);
193
+ const lookupOrder = [environment, 'prod', 'sit', 'test', 'dev'];
194
+ const domain = lookupOrder.map(key => normalizeDomain(urlDomains[key])).find(Boolean);
195
+ return domain ? buildStreetAddressUrl(domain) : '';
196
+ };
197
+ exports.resolveStreetAddressApiUrl = resolveStreetAddressApiUrl;
198
+ const applyStreetAddressApiDomains = (urlDomains, hostname) => {
199
+ const resolvedUrl = resolveStreetAddressApiUrl(urlDomains, hostname);
200
+ if (resolvedUrl) {
201
+ setStreetAddressApiUrl(resolvedUrl);
202
+ }
203
+ return resolvedUrl;
204
+ };
205
+
206
+ // Returns a per-instance config snapshot derived from an address form object so
207
+ // concurrent form instances do not share module-level mutable state. Falls back
208
+ // to the module globals when `addressForm` is null/loading or has no urlDomains
209
+ // (e.g. a caller-supplied formDefinition without Contentstack config).
210
+ exports.applyStreetAddressApiDomains = applyStreetAddressApiDomains;
211
+ const deriveSmartyConfig = addressForm => {
212
+ var _addressForm$smartyKe, _addressForm$smartyKe2, _addressForm$smartyKe3, _addressForm$smartyKe4, _addressForm$apiPaths, _addressForm$apiPaths2;
213
+ if (!addressForm || !('urlDomains' in addressForm)) {
214
+ return {
215
+ streetAddressApiUrl: getStreetAddressApiUrl(),
216
+ smartyLambdaEnabled: isSmartyLambdaEnabled(),
217
+ skipCache: isSkipCacheEnabled(),
218
+ smartyResponse: isSmartyResponseEnabled(),
219
+ smartyKeys: {
220
+ usAutocomplete: getSmartyUsAutocompleteKey(),
221
+ intlAutocomplete: getSmartyIntlAutocompleteKey(),
222
+ intlStreet: getSmartyIntlStreetKey(),
223
+ usStreet: getSmartyUsStreetKey()
224
+ },
225
+ apiPaths: getSmartyApiPaths()
226
+ };
227
+ }
228
+ return {
229
+ streetAddressApiUrl: resolveStreetAddressApiUrl(addressForm.urlDomains) || getStreetAddressApiUrl(),
230
+ smartyLambdaEnabled: addressForm.smartyLambdaEnabled !== false,
231
+ skipCache: Boolean(addressForm.skipCache),
232
+ smartyResponse: Boolean(addressForm.smartyResponse),
233
+ smartyKeys: {
234
+ usAutocomplete: ((_addressForm$smartyKe = addressForm.smartyKeys) === null || _addressForm$smartyKe === void 0 ? void 0 : _addressForm$smartyKe.usAutocomplete) || getSmartyUsAutocompleteKey(),
235
+ intlAutocomplete: ((_addressForm$smartyKe2 = addressForm.smartyKeys) === null || _addressForm$smartyKe2 === void 0 ? void 0 : _addressForm$smartyKe2.intlAutocomplete) || getSmartyIntlAutocompleteKey(),
236
+ intlStreet: ((_addressForm$smartyKe3 = addressForm.smartyKeys) === null || _addressForm$smartyKe3 === void 0 ? void 0 : _addressForm$smartyKe3.intlStreet) || getSmartyIntlStreetKey(),
237
+ usStreet: ((_addressForm$smartyKe4 = addressForm.smartyKeys) === null || _addressForm$smartyKe4 === void 0 ? void 0 : _addressForm$smartyKe4.usStreet) || getSmartyUsStreetKey()
238
+ },
239
+ apiPaths: {
240
+ validate: ((_addressForm$apiPaths = addressForm.apiPaths) === null || _addressForm$apiPaths === void 0 ? void 0 : _addressForm$apiPaths.validate) || _apiPaths.validate,
241
+ autocomplete: ((_addressForm$apiPaths2 = addressForm.apiPaths) === null || _addressForm$apiPaths2 === void 0 ? void 0 : _addressForm$apiPaths2.autocomplete) || _apiPaths.autocomplete
242
+ }
243
+ };
244
+ };
245
+ exports.deriveSmartyConfig = deriveSmartyConfig;
11
246
  //# sourceMappingURL=smartyConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smartyConfig.js","names":["SMARTY_US_AUTOCOMPLETE_KEY","exports","SMARTY_INTL_AUTOCOMPLETE_KEY","SMARTY_INTL_STREET_KEY","SMARTY_US_STREET_KEY"],"sources":["../../../src/addressLookup/utils/smartyConfig.js"],"sourcesContent":["export const SMARTY_US_AUTOCOMPLETE_KEY = '22361352819063501';\nexport const SMARTY_INTL_AUTOCOMPLETE_KEY = '22361352819063501';\nexport const SMARTY_INTL_STREET_KEY = '22361352819063501';\nexport const SMARTY_US_STREET_KEY = '22361352819063501';\n\n"],"mappings":";;;;;;AAAO,MAAMA,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,mBAAmB;AACtD,MAAME,4BAA4B,GAAAD,OAAA,CAAAC,4BAAA,GAAG,mBAAmB;AACxD,MAAMC,sBAAsB,GAAAF,OAAA,CAAAE,sBAAA,GAAG,mBAAmB;AAClD,MAAMC,oBAAoB,GAAAH,OAAA,CAAAG,oBAAA,GAAG,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"smartyConfig.js","names":["STREET_ADDRESS_PATH","DEFAULT_STREET_ADDRESS_API_URL","exports","DEFAULT_SMARTY_KEY","DEFAULT_VALIDATE_PATH","DEFAULT_AUTOCOMPLETE_PATH","DEFAULT_API_PATHS","validate","autocomplete","_streetAddressApiUrl","_smartyLambdaEnabled","_skipCache","_smartyResponse","_smartyKeys","usAutocomplete","intlAutocomplete","intlStreet","usStreet","_apiPaths","setStreetAddressApiUrl","url","getStreetAddressApiUrl","setSmartyLambdaEnabled","enabled","isSmartyLambdaEnabled","setSkipCache","Boolean","isSkipCacheEnabled","setSmartyResponseEnabled","isSmartyResponseEnabled","appendLambdaQueryParams","skipCache","smartyResponse","params","push","length","separator","includes","join","getSmartyUsAutocompleteKey","getSmartyIntlAutocompleteKey","getSmartyIntlStreetKey","getSmartyUsStreetKey","applySmartyKeys","keys","applySmartyApiPaths","paths","getSmartyApiPaths","getCurrentHostname","window","location","hostname","ENV_TOKEN_PATTERNS","local","sit","dev","test","resolveEnvironment","resolvedHost","normalized","toLowerCase","SLASH_CHAR_CODE","stripTrailingSlashes","value","endIndex","charCodeAt","slice","normalizeDomain","domain","trim","buildStreetAddressUrl","hasProtocol","startsWith","base","normalizePathSegment","fallback","trimmed","buildSmartyEndpoint","cfg","operation","countryCode","_cfg$apiPaths","path","apiPaths","streetAddressApiUrl","getAppConfigApiDomain","APP_CONFIG","apiDomainName","isLocalHost","host","resolveStreetAddressApiUrl","urlDomains","appConfigDomain","effectiveHostname","environment","lookupOrder","map","key","find","applyStreetAddressApiDomains","resolvedUrl","deriveSmartyConfig","addressForm","_addressForm$smartyKe","_addressForm$smartyKe2","_addressForm$smartyKe3","_addressForm$smartyKe4","_addressForm$apiPaths","_addressForm$apiPaths2","smartyLambdaEnabled","smartyKeys"],"sources":["../../../src/addressLookup/utils/smartyConfig.js"],"sourcesContent":["const STREET_ADDRESS_PATH = '/street-address';\nconst DEFAULT_STREET_ADDRESS_API_URL = `https://apis.nuskin.com${STREET_ADDRESS_PATH}`;\nconst DEFAULT_SMARTY_KEY = '22361352819063501';\nconst DEFAULT_VALIDATE_PATH = '/validate/v1';\nconst DEFAULT_AUTOCOMPLETE_PATH = '/autocomplete/v1';\nconst DEFAULT_API_PATHS = {\n validate: DEFAULT_VALIDATE_PATH,\n autocomplete: DEFAULT_AUTOCOMPLETE_PATH\n};\n\nlet _streetAddressApiUrl = DEFAULT_STREET_ADDRESS_API_URL;\nlet _smartyLambdaEnabled = true;\nlet _skipCache = false;\nlet _smartyResponse = false;\nconst _smartyKeys = {\n usAutocomplete: DEFAULT_SMARTY_KEY,\n intlAutocomplete: DEFAULT_SMARTY_KEY,\n intlStreet: DEFAULT_SMARTY_KEY,\n usStreet: DEFAULT_SMARTY_KEY\n};\nconst _apiPaths = { ...DEFAULT_API_PATHS };\n\nexport const setStreetAddressApiUrl = (url) => {\n _streetAddressApiUrl = url;\n};\n\nexport const getStreetAddressApiUrl = () => _streetAddressApiUrl;\n\nexport const setSmartyLambdaEnabled = (enabled) => {\n _smartyLambdaEnabled = enabled !== false;\n};\n\nexport const isSmartyLambdaEnabled = () => _smartyLambdaEnabled;\n\nexport const setSkipCache = (enabled) => {\n _skipCache = Boolean(enabled);\n};\n\nexport const isSkipCacheEnabled = () => _skipCache;\n\nexport const setSmartyResponseEnabled = (enabled) => {\n _smartyResponse = Boolean(enabled);\n};\n\nexport const isSmartyResponseEnabled = () => _smartyResponse;\n\nexport const appendLambdaQueryParams = (url, { skipCache = false, smartyResponse = false } = {}) => {\n const params = [];\n if (skipCache) params.push('skipCache=true');\n if (smartyResponse) params.push('smartyResponse=true');\n\n if (!params.length) {\n return url;\n }\n\n const separator = url.includes('?') ? '&' : '?';\n return `${url}${separator}${params.join('&')}`;\n};\n\nexport const getSmartyUsAutocompleteKey = () => _smartyKeys.usAutocomplete;\nexport const getSmartyIntlAutocompleteKey = () => _smartyKeys.intlAutocomplete;\nexport const getSmartyIntlStreetKey = () => _smartyKeys.intlStreet;\nexport const getSmartyUsStreetKey = () => _smartyKeys.usStreet;\n\nexport const applySmartyKeys = (keys = {}) => {\n if (!keys || typeof keys !== 'object') {\n return;\n }\n\n if (keys.usAutocomplete) _smartyKeys.usAutocomplete = keys.usAutocomplete;\n if (keys.intlAutocomplete) _smartyKeys.intlAutocomplete = keys.intlAutocomplete;\n if (keys.intlStreet) _smartyKeys.intlStreet = keys.intlStreet;\n if (keys.usStreet) _smartyKeys.usStreet = keys.usStreet;\n};\n\nexport const applySmartyApiPaths = (paths = {}) => {\n if (!paths || typeof paths !== 'object') {\n return;\n }\n\n if (paths.validate) _apiPaths.validate = paths.validate;\n if (paths.autocomplete) _apiPaths.autocomplete = paths.autocomplete;\n};\n\nexport const getSmartyApiPaths = () => ({ ..._apiPaths });\n\nconst getCurrentHostname = () => {\n if (typeof window === 'undefined' || !window.location) {\n return '';\n }\n\n return window.location.hostname || '';\n};\n\nconst ENV_TOKEN_PATTERNS = {\n local: /(^|[.-])local([.-]|$)/,\n sit: /(^|[.-])sit([.-]|$)/,\n dev: /(^|[.-])dev([.-]|$)/,\n test: /(^|[.-])(test|tst)([.-]|$)/\n};\n\nexport const resolveEnvironment = (hostname) => {\n const resolvedHost = typeof hostname === 'string' && hostname ? hostname : getCurrentHostname();\n const normalized = resolvedHost.toLowerCase();\n\n if (!normalized || normalized === 'localhost' || ENV_TOKEN_PATTERNS.local.test(normalized)) {\n return 'dev';\n }\n\n if (ENV_TOKEN_PATTERNS.sit.test(normalized)) {\n return 'sit';\n }\n\n if (ENV_TOKEN_PATTERNS.dev.test(normalized)) {\n return 'dev';\n }\n\n if (ENV_TOKEN_PATTERNS.test.test(normalized)) {\n return 'test';\n }\n\n return 'prod';\n};\n\nconst SLASH_CHAR_CODE = 47;\n\nconst stripTrailingSlashes = (value) => {\n let endIndex = value.length;\n\n while (endIndex > 0 && value.charCodeAt(endIndex - 1) === SLASH_CHAR_CODE) {\n endIndex -= 1;\n }\n\n return value.slice(0, endIndex);\n};\n\nconst normalizeDomain = (domain) => (\n typeof domain === 'string' ? stripTrailingSlashes(domain.trim()) : ''\n);\n\nconst buildStreetAddressUrl = (domain) => {\n const normalized = normalizeDomain(domain);\n\n if (!normalized) {\n return '';\n }\n\n const hasProtocol = normalized.startsWith('http://') || normalized.startsWith('https://');\n const base = hasProtocol ? normalized : `https://${normalized}`;\n\n return `${base}${STREET_ADDRESS_PATH}`;\n};\n\n// Content authors may omit the leading slash or add a trailing one.\nconst normalizePathSegment = (value, fallback) => {\n const trimmed = typeof value === 'string' ? stripTrailingSlashes(value.trim()) : '';\n\n if (!trimmed) {\n return fallback;\n }\n\n return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;\n};\n\nexport const buildSmartyEndpoint = (cfg, operation, countryCode) => {\n const fallback = DEFAULT_API_PATHS[operation] || '';\n const path = normalizePathSegment(cfg?.apiPaths?.[operation], fallback);\n\n return `${cfg?.streetAddressApiUrl || ''}${path}/${countryCode}`;\n};\n\nconst getAppConfigApiDomain = () => {\n if (typeof window === 'undefined' || !window.APP_CONFIG) {\n return '';\n }\n\n const domain = window.APP_CONFIG.apiDomainName;\n\n return typeof domain === 'string' ? domain.trim() : '';\n};\n\nconst isLocalHost = (hostname) => {\n const host = (typeof hostname === 'string' && hostname ? hostname : getCurrentHostname()).toLowerCase();\n\n return !host || host === 'localhost' || host.includes('local.');\n};\n\nexport const resolveStreetAddressApiUrl = (urlDomains, hostname) => {\n const appConfigDomain = getAppConfigApiDomain();\n\n // window.APP_CONFIG.apiDomainName is injected per deployed environment. On local\n // dev it is absent or points at the default host, so skip it there and fall through\n // to the Contentstack domain switch (which maps localhost -> dev).\n if (appConfigDomain && !isLocalHost(hostname)) {\n return buildStreetAddressUrl(appConfigDomain);\n }\n\n if (!urlDomains || typeof urlDomains !== 'object') {\n return '';\n }\n\n // Guard: if hostname cannot be determined (SSR or uninitialized browser), skip\n // environment-based lookup entirely. Without this, an empty hostname maps to 'dev',\n // silently routing production traffic to the dev base URL.\n const effectiveHostname = (typeof hostname === 'string' && hostname) ? hostname : getCurrentHostname();\n if (!effectiveHostname) {\n return '';\n }\n\n const environment = resolveEnvironment(effectiveHostname);\n const lookupOrder = [environment, 'prod', 'sit', 'test', 'dev'];\n\n const domain = lookupOrder\n .map((key) => normalizeDomain(urlDomains[key]))\n .find(Boolean);\n\n return domain ? buildStreetAddressUrl(domain) : '';\n};\n\nexport const applyStreetAddressApiDomains = (urlDomains, hostname) => {\n const resolvedUrl = resolveStreetAddressApiUrl(urlDomains, hostname);\n\n if (resolvedUrl) {\n setStreetAddressApiUrl(resolvedUrl);\n }\n\n return resolvedUrl;\n};\n\n// Returns a per-instance config snapshot derived from an address form object so\n// concurrent form instances do not share module-level mutable state. Falls back\n// to the module globals when `addressForm` is null/loading or has no urlDomains\n// (e.g. a caller-supplied formDefinition without Contentstack config).\nexport const deriveSmartyConfig = (addressForm) => {\n if (!addressForm || !('urlDomains' in addressForm)) {\n return {\n streetAddressApiUrl: getStreetAddressApiUrl(),\n smartyLambdaEnabled: isSmartyLambdaEnabled(),\n skipCache: isSkipCacheEnabled(),\n smartyResponse: isSmartyResponseEnabled(),\n smartyKeys: {\n usAutocomplete: getSmartyUsAutocompleteKey(),\n intlAutocomplete: getSmartyIntlAutocompleteKey(),\n intlStreet: getSmartyIntlStreetKey(),\n usStreet: getSmartyUsStreetKey()\n },\n apiPaths: getSmartyApiPaths()\n };\n }\n\n return {\n streetAddressApiUrl: resolveStreetAddressApiUrl(addressForm.urlDomains) || getStreetAddressApiUrl(),\n smartyLambdaEnabled: addressForm.smartyLambdaEnabled !== false,\n skipCache: Boolean(addressForm.skipCache),\n smartyResponse: Boolean(addressForm.smartyResponse),\n smartyKeys: {\n usAutocomplete: addressForm.smartyKeys?.usAutocomplete || getSmartyUsAutocompleteKey(),\n intlAutocomplete: addressForm.smartyKeys?.intlAutocomplete || getSmartyIntlAutocompleteKey(),\n intlStreet: addressForm.smartyKeys?.intlStreet || getSmartyIntlStreetKey(),\n usStreet: addressForm.smartyKeys?.usStreet || getSmartyUsStreetKey()\n },\n apiPaths: {\n validate: addressForm.apiPaths?.validate || _apiPaths.validate,\n autocomplete: addressForm.apiPaths?.autocomplete || _apiPaths.autocomplete\n }\n };\n};\n\nexport {\n DEFAULT_STREET_ADDRESS_API_URL,\n DEFAULT_SMARTY_KEY,\n DEFAULT_VALIDATE_PATH,\n DEFAULT_AUTOCOMPLETE_PATH\n};\n"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAG,iBAAiB;AAC7C,MAAMC,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GAAG,0BAA0BD,mBAAmB,EAAE;AACtF,MAAMG,kBAAkB,GAAAD,OAAA,CAAAC,kBAAA,GAAG,mBAAmB;AAC9C,MAAMC,qBAAqB,GAAAF,OAAA,CAAAE,qBAAA,GAAG,cAAc;AAC5C,MAAMC,yBAAy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IAChE;EACF,CAAC;AACH,CAAC;AAACN,OAAA,CAAAmG,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/dist/index.js CHANGED
@@ -39,9 +39,16 @@ Object.defineProperty(exports, "normalizeAddressForm", {
39
39
  return _addressForm.normalizeAddressForm;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "setStreetAddressApiUrl", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _smartyConfig.setStreetAddressApiUrl;
46
+ }
47
+ });
42
48
  var _ShippingAddressForm = _interopRequireDefault(require("./shippingAddressForm/ShippingAddressForm"));
43
49
  var _addressLookup = _interopRequireDefault(require("./addressLookup"));
44
50
  var _addressForm = require("./addressLookup/utils/addressForm");
45
51
  var _countries = require("./addressLookup/countries");
52
+ var _smartyConfig = require("./addressLookup/utils/smartyConfig");
46
53
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
47
54
  //# sourceMappingURL=index.js.map