@verma-consulting/common-library 0.1.44 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ declare const formatPhoneNumber: (value: string) => string;
|
|
|
13
13
|
declare const openInNewTab: (url: string) => void;
|
|
14
14
|
declare function stripHtmlTags(html: string): string;
|
|
15
15
|
declare const toCurrencyValue: (value: number | string) => number;
|
|
16
|
+
declare const formatRelativeTime: (input?: string | Date | number) => string;
|
|
16
17
|
|
|
17
18
|
interface GenericPayload {
|
|
18
19
|
label?: string;
|
|
@@ -3785,4 +3786,4 @@ declare const defaultTypes: {
|
|
|
3785
3786
|
};
|
|
3786
3787
|
};
|
|
3787
3788
|
|
|
3788
|
-
export { type ActivityInterface, type AddressInterface, type AmountDetailsInterface, type AnalyticsQueryInterface, AppMode, type AutomaticPaymentMethodsInterface, type AutomaticTaxInterface, type BatchShipmentInterface, type BillingDetailsInterface, CalculationType, type CampaignInterface, CampaignType, type CancellationDetailsInterface, type CardInterface, type CarrierAccountInterface, type CarrierAccountResponseInterface, type CarrierMappingInterface, CategoryType, ChartType, type ChatInterface, type ClientInterface, type CommentInterface, type ContactInterface, type ContentInterface, ContentType, type CurrentRateInterface, type CustomsItemInterface, type DealInterface, DealType, DeviceNotification, type DisputeInterface, type EmailInterface, type EngagementInterface, type EvidenceDetailsInterface, type EvidenceInterface, FeatureType, type FileInterface, type FilterInterface, FilterType, FormFieldOrder, FormFieldType, FrequencyType, Gender, type GenericPayload, type IntegrationInterface, type InventoryInterface, type InvoiceInterface, type LabelOptionsInterface, LandingPath, LandingView, type LeadInterface, LeadType, type ListInterface, type MarketingFeatureInterface, type ModelInterface, ModelType, type Notation, type NotificationInterface, type OperationInterface, type OrderAddressInterface, type OrderInterface, OrganizationFeatures, type OrganizationInterface, type OrganizationModelInterface, type PackageDimensionsInterface, type ParcelInputInterface, type PauseCollectionInterface, type PaymentInterface, type PaymentMethodInterface, type PermissionInterface, PermissionType, PlatformLanguage, type PoolInterface, type PriceInterface, type PriceRecurringInterface, Priority, type ProductInterface, type PromptInterface, type QueryFilterInterface, type RatesOptionsInterface, type RefundInterface, type RefundResponseInterface, type RegisterInterface, type ReportInterface, type SchemaInterface, type SentEmailInterface, type ServiceLevelsResponseInterface, type ShippingInterface, type ShippingRateInterface, type ShippingTransactionInterface, type ShippoAddressInterface, type ShippoBatchResponseInterface, type ShippoCustomsDeclarationInputInterface, type ShippoCustomsResponseInterface, type ShippoParcelInterface, type ShippoParcelResponseInterface, type ShippoRatesResponseInterface, type ShippoTrackingResponseInterface, type ShippoTransactionResponseInterface, SourceType, type StatisticInterface, type StripeAccountInterface, type StripeCustomer, type StripePaymentIntent, type SubscriptionInterface, type TagInterface, type TaskInterface, type TokenInterface, type TrackingHistoryInterface, type TrackingInfoInterface, type UsageInterface, UsageType, type UserInterface, UserSettingType, type WaitlistInterface, accountType, action, addressType, automaticTaxStatus, billingReason, billingScheme, camelCaseToWords, capitalizeSentence, captureMethod, chatType, clientType, collectionMethod, commentRole, constants, currency, customerType, defaultTypes, defaults, disputeReason, disputeStatus, financialStatus, formatPhoneNumber, fulfillmentStatus, getRandomArbitrary, girth, grabAge, integrationCategory, integrationType, isNumber, largeNumberLabel, missingPaymentMethod, normalizeKey, openInNewTab, operationType, organizationFilterType, packageType, paymentAllowRedirect, paymentCancellationReason, paymentFutureUsage, paymentMethodAllowReDisplay, paymentMethodType, paymentStatus, prettifyString, priceType, productType, refundFailureReason, refundPendingReason, refundReason, refundStatus, shippingProvider, shippingServiceLevel, snakeToPretty, status, stripHtmlTags, subscriptionCancellationReason, taxBehavior, taxExempt, tiersMode, toCurrencyValue, trigger, unit, userRole, userSource, userStatus, validEmail, weightUnit };
|
|
3789
|
+
export { type ActivityInterface, type AddressInterface, type AmountDetailsInterface, type AnalyticsQueryInterface, AppMode, type AutomaticPaymentMethodsInterface, type AutomaticTaxInterface, type BatchShipmentInterface, type BillingDetailsInterface, CalculationType, type CampaignInterface, CampaignType, type CancellationDetailsInterface, type CardInterface, type CarrierAccountInterface, type CarrierAccountResponseInterface, type CarrierMappingInterface, CategoryType, ChartType, type ChatInterface, type ClientInterface, type CommentInterface, type ContactInterface, type ContentInterface, ContentType, type CurrentRateInterface, type CustomsItemInterface, type DealInterface, DealType, DeviceNotification, type DisputeInterface, type EmailInterface, type EngagementInterface, type EvidenceDetailsInterface, type EvidenceInterface, FeatureType, type FileInterface, type FilterInterface, FilterType, FormFieldOrder, FormFieldType, FrequencyType, Gender, type GenericPayload, type IntegrationInterface, type InventoryInterface, type InvoiceInterface, type LabelOptionsInterface, LandingPath, LandingView, type LeadInterface, LeadType, type ListInterface, type MarketingFeatureInterface, type ModelInterface, ModelType, type Notation, type NotificationInterface, type OperationInterface, type OrderAddressInterface, type OrderInterface, OrganizationFeatures, type OrganizationInterface, type OrganizationModelInterface, type PackageDimensionsInterface, type ParcelInputInterface, type PauseCollectionInterface, type PaymentInterface, type PaymentMethodInterface, type PermissionInterface, PermissionType, PlatformLanguage, type PoolInterface, type PriceInterface, type PriceRecurringInterface, Priority, type ProductInterface, type PromptInterface, type QueryFilterInterface, type RatesOptionsInterface, type RefundInterface, type RefundResponseInterface, type RegisterInterface, type ReportInterface, type SchemaInterface, type SentEmailInterface, type ServiceLevelsResponseInterface, type ShippingInterface, type ShippingRateInterface, type ShippingTransactionInterface, type ShippoAddressInterface, type ShippoBatchResponseInterface, type ShippoCustomsDeclarationInputInterface, type ShippoCustomsResponseInterface, type ShippoParcelInterface, type ShippoParcelResponseInterface, type ShippoRatesResponseInterface, type ShippoTrackingResponseInterface, type ShippoTransactionResponseInterface, SourceType, type StatisticInterface, type StripeAccountInterface, type StripeCustomer, type StripePaymentIntent, type SubscriptionInterface, type TagInterface, type TaskInterface, type TokenInterface, type TrackingHistoryInterface, type TrackingInfoInterface, type UsageInterface, UsageType, type UserInterface, UserSettingType, type WaitlistInterface, accountType, action, addressType, automaticTaxStatus, billingReason, billingScheme, camelCaseToWords, capitalizeSentence, captureMethod, chatType, clientType, collectionMethod, commentRole, constants, currency, customerType, defaultTypes, defaults, disputeReason, disputeStatus, financialStatus, formatPhoneNumber, formatRelativeTime, fulfillmentStatus, getRandomArbitrary, girth, grabAge, integrationCategory, integrationType, isNumber, largeNumberLabel, missingPaymentMethod, normalizeKey, openInNewTab, operationType, organizationFilterType, packageType, paymentAllowRedirect, paymentCancellationReason, paymentFutureUsage, paymentMethodAllowReDisplay, paymentMethodType, paymentStatus, prettifyString, priceType, productType, refundFailureReason, refundPendingReason, refundReason, refundStatus, shippingProvider, shippingServiceLevel, snakeToPretty, status, stripHtmlTags, subscriptionCancellationReason, taxBehavior, taxExempt, tiersMode, toCurrencyValue, trigger, unit, userRole, userSource, userStatus, validEmail, weightUnit };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ declare const formatPhoneNumber: (value: string) => string;
|
|
|
13
13
|
declare const openInNewTab: (url: string) => void;
|
|
14
14
|
declare function stripHtmlTags(html: string): string;
|
|
15
15
|
declare const toCurrencyValue: (value: number | string) => number;
|
|
16
|
+
declare const formatRelativeTime: (input?: string | Date | number) => string;
|
|
16
17
|
|
|
17
18
|
interface GenericPayload {
|
|
18
19
|
label?: string;
|
|
@@ -3785,4 +3786,4 @@ declare const defaultTypes: {
|
|
|
3785
3786
|
};
|
|
3786
3787
|
};
|
|
3787
3788
|
|
|
3788
|
-
export { type ActivityInterface, type AddressInterface, type AmountDetailsInterface, type AnalyticsQueryInterface, AppMode, type AutomaticPaymentMethodsInterface, type AutomaticTaxInterface, type BatchShipmentInterface, type BillingDetailsInterface, CalculationType, type CampaignInterface, CampaignType, type CancellationDetailsInterface, type CardInterface, type CarrierAccountInterface, type CarrierAccountResponseInterface, type CarrierMappingInterface, CategoryType, ChartType, type ChatInterface, type ClientInterface, type CommentInterface, type ContactInterface, type ContentInterface, ContentType, type CurrentRateInterface, type CustomsItemInterface, type DealInterface, DealType, DeviceNotification, type DisputeInterface, type EmailInterface, type EngagementInterface, type EvidenceDetailsInterface, type EvidenceInterface, FeatureType, type FileInterface, type FilterInterface, FilterType, FormFieldOrder, FormFieldType, FrequencyType, Gender, type GenericPayload, type IntegrationInterface, type InventoryInterface, type InvoiceInterface, type LabelOptionsInterface, LandingPath, LandingView, type LeadInterface, LeadType, type ListInterface, type MarketingFeatureInterface, type ModelInterface, ModelType, type Notation, type NotificationInterface, type OperationInterface, type OrderAddressInterface, type OrderInterface, OrganizationFeatures, type OrganizationInterface, type OrganizationModelInterface, type PackageDimensionsInterface, type ParcelInputInterface, type PauseCollectionInterface, type PaymentInterface, type PaymentMethodInterface, type PermissionInterface, PermissionType, PlatformLanguage, type PoolInterface, type PriceInterface, type PriceRecurringInterface, Priority, type ProductInterface, type PromptInterface, type QueryFilterInterface, type RatesOptionsInterface, type RefundInterface, type RefundResponseInterface, type RegisterInterface, type ReportInterface, type SchemaInterface, type SentEmailInterface, type ServiceLevelsResponseInterface, type ShippingInterface, type ShippingRateInterface, type ShippingTransactionInterface, type ShippoAddressInterface, type ShippoBatchResponseInterface, type ShippoCustomsDeclarationInputInterface, type ShippoCustomsResponseInterface, type ShippoParcelInterface, type ShippoParcelResponseInterface, type ShippoRatesResponseInterface, type ShippoTrackingResponseInterface, type ShippoTransactionResponseInterface, SourceType, type StatisticInterface, type StripeAccountInterface, type StripeCustomer, type StripePaymentIntent, type SubscriptionInterface, type TagInterface, type TaskInterface, type TokenInterface, type TrackingHistoryInterface, type TrackingInfoInterface, type UsageInterface, UsageType, type UserInterface, UserSettingType, type WaitlistInterface, accountType, action, addressType, automaticTaxStatus, billingReason, billingScheme, camelCaseToWords, capitalizeSentence, captureMethod, chatType, clientType, collectionMethod, commentRole, constants, currency, customerType, defaultTypes, defaults, disputeReason, disputeStatus, financialStatus, formatPhoneNumber, fulfillmentStatus, getRandomArbitrary, girth, grabAge, integrationCategory, integrationType, isNumber, largeNumberLabel, missingPaymentMethod, normalizeKey, openInNewTab, operationType, organizationFilterType, packageType, paymentAllowRedirect, paymentCancellationReason, paymentFutureUsage, paymentMethodAllowReDisplay, paymentMethodType, paymentStatus, prettifyString, priceType, productType, refundFailureReason, refundPendingReason, refundReason, refundStatus, shippingProvider, shippingServiceLevel, snakeToPretty, status, stripHtmlTags, subscriptionCancellationReason, taxBehavior, taxExempt, tiersMode, toCurrencyValue, trigger, unit, userRole, userSource, userStatus, validEmail, weightUnit };
|
|
3789
|
+
export { type ActivityInterface, type AddressInterface, type AmountDetailsInterface, type AnalyticsQueryInterface, AppMode, type AutomaticPaymentMethodsInterface, type AutomaticTaxInterface, type BatchShipmentInterface, type BillingDetailsInterface, CalculationType, type CampaignInterface, CampaignType, type CancellationDetailsInterface, type CardInterface, type CarrierAccountInterface, type CarrierAccountResponseInterface, type CarrierMappingInterface, CategoryType, ChartType, type ChatInterface, type ClientInterface, type CommentInterface, type ContactInterface, type ContentInterface, ContentType, type CurrentRateInterface, type CustomsItemInterface, type DealInterface, DealType, DeviceNotification, type DisputeInterface, type EmailInterface, type EngagementInterface, type EvidenceDetailsInterface, type EvidenceInterface, FeatureType, type FileInterface, type FilterInterface, FilterType, FormFieldOrder, FormFieldType, FrequencyType, Gender, type GenericPayload, type IntegrationInterface, type InventoryInterface, type InvoiceInterface, type LabelOptionsInterface, LandingPath, LandingView, type LeadInterface, LeadType, type ListInterface, type MarketingFeatureInterface, type ModelInterface, ModelType, type Notation, type NotificationInterface, type OperationInterface, type OrderAddressInterface, type OrderInterface, OrganizationFeatures, type OrganizationInterface, type OrganizationModelInterface, type PackageDimensionsInterface, type ParcelInputInterface, type PauseCollectionInterface, type PaymentInterface, type PaymentMethodInterface, type PermissionInterface, PermissionType, PlatformLanguage, type PoolInterface, type PriceInterface, type PriceRecurringInterface, Priority, type ProductInterface, type PromptInterface, type QueryFilterInterface, type RatesOptionsInterface, type RefundInterface, type RefundResponseInterface, type RegisterInterface, type ReportInterface, type SchemaInterface, type SentEmailInterface, type ServiceLevelsResponseInterface, type ShippingInterface, type ShippingRateInterface, type ShippingTransactionInterface, type ShippoAddressInterface, type ShippoBatchResponseInterface, type ShippoCustomsDeclarationInputInterface, type ShippoCustomsResponseInterface, type ShippoParcelInterface, type ShippoParcelResponseInterface, type ShippoRatesResponseInterface, type ShippoTrackingResponseInterface, type ShippoTransactionResponseInterface, SourceType, type StatisticInterface, type StripeAccountInterface, type StripeCustomer, type StripePaymentIntent, type SubscriptionInterface, type TagInterface, type TaskInterface, type TokenInterface, type TrackingHistoryInterface, type TrackingInfoInterface, type UsageInterface, UsageType, type UserInterface, UserSettingType, type WaitlistInterface, accountType, action, addressType, automaticTaxStatus, billingReason, billingScheme, camelCaseToWords, capitalizeSentence, captureMethod, chatType, clientType, collectionMethod, commentRole, constants, currency, customerType, defaultTypes, defaults, disputeReason, disputeStatus, financialStatus, formatPhoneNumber, formatRelativeTime, fulfillmentStatus, getRandomArbitrary, girth, grabAge, integrationCategory, integrationType, isNumber, largeNumberLabel, missingPaymentMethod, normalizeKey, openInNewTab, operationType, organizationFilterType, packageType, paymentAllowRedirect, paymentCancellationReason, paymentFutureUsage, paymentMethodAllowReDisplay, paymentMethodType, paymentStatus, prettifyString, priceType, productType, refundFailureReason, refundPendingReason, refundReason, refundStatus, shippingProvider, shippingServiceLevel, snakeToPretty, status, stripHtmlTags, subscriptionCancellationReason, taxBehavior, taxExempt, tiersMode, toCurrencyValue, trigger, unit, userRole, userSource, userStatus, validEmail, weightUnit };
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
disputeStatus: () => disputeStatus,
|
|
68
68
|
financialStatus: () => financialStatus,
|
|
69
69
|
formatPhoneNumber: () => formatPhoneNumber,
|
|
70
|
+
formatRelativeTime: () => formatRelativeTime,
|
|
70
71
|
fulfillmentStatus: () => fulfillmentStatus,
|
|
71
72
|
getRandomArbitrary: () => getRandomArbitrary,
|
|
72
73
|
girth: () => girth,
|
|
@@ -197,6 +198,26 @@ var toCurrencyValue = (value) => {
|
|
|
197
198
|
const num = parseFloat(String(value)) || 0;
|
|
198
199
|
return parseFloat(num.toFixed(2));
|
|
199
200
|
};
|
|
201
|
+
var formatRelativeTime = (input) => {
|
|
202
|
+
if (input == null) return "";
|
|
203
|
+
const date = typeof input === "number" ? new Date(input) : typeof input === "string" ? new Date(input) : input;
|
|
204
|
+
if (isNaN(date.getTime())) return "";
|
|
205
|
+
const now = /* @__PURE__ */ new Date();
|
|
206
|
+
const diffMs = now.getTime() - date.getTime();
|
|
207
|
+
if (diffMs < 0) return "Just now";
|
|
208
|
+
const diffMins = Math.floor(diffMs / 6e4);
|
|
209
|
+
const diffHours = Math.floor(diffMs / 36e5);
|
|
210
|
+
const diffDays = Math.floor(diffMs / 864e5);
|
|
211
|
+
if (diffMins < 1) return "Just now";
|
|
212
|
+
if (diffMins < 60) return `${diffMins}m ago`;
|
|
213
|
+
if (diffHours < 24) return `${diffHours}h ago`;
|
|
214
|
+
if (diffDays < 7) return `${diffDays}d ago`;
|
|
215
|
+
return date.toLocaleDateString("en-US", {
|
|
216
|
+
month: "short",
|
|
217
|
+
day: "numeric",
|
|
218
|
+
year: date.getFullYear() !== now.getFullYear() ? "numeric" : void 0
|
|
219
|
+
});
|
|
220
|
+
};
|
|
200
221
|
|
|
201
222
|
// src/enums.ts
|
|
202
223
|
var LandingPath = /* @__PURE__ */ ((LandingPath2) => {
|
|
@@ -3196,6 +3217,7 @@ var defaultTypes_default = defaultTypes;
|
|
|
3196
3217
|
disputeStatus,
|
|
3197
3218
|
financialStatus,
|
|
3198
3219
|
formatPhoneNumber,
|
|
3220
|
+
formatRelativeTime,
|
|
3199
3221
|
fulfillmentStatus,
|
|
3200
3222
|
getRandomArbitrary,
|
|
3201
3223
|
girth,
|