@nukleus-sports/core 0.1.0 → 0.2.0

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.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ abbreviatePersonName: () => abbreviatePersonName,
23
24
  canEditMarketingDeals: () => canEditMarketingDeals,
24
25
  canEditProject: () => canEditProject,
25
26
  canEditTaskStatus: () => canEditTaskStatus,
@@ -128,8 +129,19 @@ function canViewMarketingDeals(permission) {
128
129
  function canEditMarketingDeals(permission) {
129
130
  return permission.kind === "levels" && permission.level === "Edit";
130
131
  }
132
+
133
+ // src/personName.ts
134
+ function abbreviatePersonName(name) {
135
+ const trimmed = name?.trim();
136
+ if (!trimmed) return null;
137
+ const parts = trimmed.split(" ");
138
+ const initial = parts[0]?.charAt(0).toUpperCase() ?? "";
139
+ const last = parts[1] ?? "";
140
+ return `${initial}. ${last}`;
141
+ }
131
142
  // Annotate the CommonJS export names for ESM import in node:
132
143
  0 && (module.exports = {
144
+ abbreviatePersonName,
133
145
  canEditMarketingDeals,
134
146
  canEditProject,
135
147
  canEditTaskStatus,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/dealStatus.ts","../src/currency.ts","../src/projectPermissions.ts","../src/marketingPermission.ts"],"sourcesContent":["export * from \"./dealStatus\";\nexport * from \"./currency\";\nexport * from \"./projectPermissions\";\nexport * from \"./marketingPermission\";\n","import { format, parseISO } from \"date-fns\";\n\nexport type DealStatus = \"Active\" | \"Upcoming\" | \"Complete\";\n\ninterface DealLike {\n deal_terms?: {\n startDate?: string | null;\n } | null;\n}\n\n/** Identical logic in both nukleus-app and nukleus-clientapp's ProjectDealCard. */\nexport function getDealStatus(deal: DealLike, isCompleted: boolean): DealStatus {\n if (isCompleted) return \"Complete\";\n const start = deal.deal_terms?.startDate;\n if (start && parseISO(start) > new Date()) return \"Upcoming\";\n return \"Active\";\n}\n\n/** Identical logic in both apps' ProjectDealCard. */\nexport function formatDealDate(dateStr?: string | null): string {\n if (!dateStr) return \"—\";\n try {\n return format(parseISO(dateStr), \"MMM d, yyyy\");\n } catch {\n return dateStr;\n }\n}\n","/** Full-precision USD, e.g. \"$1,234.56\". Both apps' `fmtUSD` are functionally\n * identical (nukleus-app is explicit about the 2-decimal default; clientapp\n * relies on Intl's own default, which is also 2 for USD). */\nexport function fmtUSD(n: number): string {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(n);\n}\n\n/** Whole-dollar USD, e.g. \"$1,235\". Reconciled nullability: nukleus-app's\n * version accepted `n?: number` and fell back to \"--\"; clientapp's required\n * `n: number` with no fallback. Kept the null-safe contract -- a strict\n * superset, since every existing call site passing a real number already\n * satisfies it too. */\nexport function fmtUSDWhole(n?: number): string {\n return n != null\n ? new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n maximumFractionDigits: 0,\n }).format(n)\n : \"--\";\n}\n\n/** \"$54,000\" for whole dollars, \"$84.50\" otherwise -- nukleus-app's payments\n * UI money format. No clientapp equivalent to reconcile against. */\nexport function fmtUSDCompact(n: number): string {\n const cents = Math.round(n * 100);\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: cents % 100 === 0 ? 0 : 2,\n maximumFractionDigits: 2,\n }).format(cents / 100);\n}\n\n/** Generic \"--\"-on-empty stringifier -- identical in both apps' deal preview\n * dialogs. */\nexport function fmt(value: string | number | null | undefined, fallback = \"--\"): string {\n if (value === null || value === undefined || value === \"\") return fallback;\n return String(value);\n}\n\n/** Whole-dollar display with a leading \"$\", no Intl currency formatting --\n * identical in both apps' deal preview dialogs. Distinct from fmtUSDWhole:\n * this is a simpler toLocaleString-based formatter the preview dialogs use\n * directly, kept as its own function to match the exact source behavior\n * rather than merging it into fmtUSDWhole. */\nexport function fmtCurrency(amount: number | null | undefined): string {\n if (amount === null || amount === undefined) return \"--\";\n return `$${Number(amount).toLocaleString(\"en-US\", {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n })}`;\n}\n\n/** MM/DD/YYYY, \"--\" on empty/invalid -- identical in both apps' deal preview\n * dialogs. */\nexport function fmtDate(dateStr: string | null | undefined): string {\n if (!dateStr) return \"--\";\n try {\n return new Date(dateStr).toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n } catch {\n return dateStr;\n }\n}\n","export type ProjectMemberRole = \"Owner\" | \"Editor\" | \"Viewer\";\n\n/** Files + task/deliverable editing are gated on this exact rule in both\n * apps today -- duplicated independently across several files per app\n * (`roleCanEdit`/`canUpload`/`canEditDeliverables`), never centralized.\n * One source of truth instead of several copies that can drift apart. */\nexport function canEditProject(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\" || role === \"Editor\";\n}\n\n/** Task *status* specifically requires Editor, not just \"can edit\" --\n * nukleus-clientapp's own comment: \"only 'Editor' may change task status.\" */\nexport function canEditTaskStatus(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Editor\";\n}\n\n/** Member invite/role management is Owner-only in nukleus-app's UI today.\n * nukleus-clientapp has no edit affordance here at all -- looks like unbuilt\n * feature parity, not an intentional restriction (the role vocabulary\n * already supports it). */\nexport function canManageMembers(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\";\n}\n\ninterface ProjectLike {\n status?: string | null;\n}\n\n/** A project is read-only once cancelled -- no writes are accepted\n * server-side (RLS) regardless of this check; this just drives UI gating. */\nexport function isProjectCancelled(project: ProjectLike | null | undefined): boolean {\n return project?.status === \"Cancelled\";\n}\n\n/**\n * nukleus-app forces every member's effective role to \"Viewer\" once a\n * project is cancelled (`useProjectReadOnly` + `effectiveMemberRole`),\n * regardless of their stored role. nukleus-clientapp does not apply this\n * downgrade anywhere today -- a real, confirmed asymmetry, not a styling\n * difference. Exposed here so both apps can share the same rule once\n * clientapp adopts it; until then, clientapp callers should apply this\n * explicitly rather than assume parity.\n */\nexport function getEffectiveMemberRole(\n role: ProjectMemberRole | null | undefined,\n isCancelled: boolean,\n): ProjectMemberRole | null | undefined {\n return isCancelled ? \"Viewer\" : role;\n}\n","/**\n * Marketing deals' permission check is NOT one shared enum downgraded for\n * the client side -- it's two genuinely different shapes, confirmed against\n * real code:\n *\n * - nukleus-app: a 3-state enum via `getPermissionLevel(PERMISSIONS.CLIENT_MARKETING)`\n * (\"No Access\" | \"View\" | \"Edit\") -- the agency can have no access, view\n * only, or full edit, independent of org membership.\n * - nukleus-clientapp: a boolean `hasActiveAgencyLink` -- the client either\n * has an active link to the agency that owns these deals, or doesn't.\n * There is no view/edit distinction; clients never get write access here.\n *\n * Modeled as a discriminated union so each app's adapter supplies its own\n * real shape rather than being forced through the other's.\n */\nexport type MarketingPermission =\n { kind: \"levels\"; level: \"No Access\" | \"View\" | \"Edit\" } | { kind: \"linked\"; isLinked: boolean };\n\nexport function canViewMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" ? permission.level !== \"No Access\" : permission.isLinked;\n}\n\n/** Always false for the \"linked\" shape -- clients never get write access to\n * Marketing deals today (confirmed: clientapp has zero write UI). */\nexport function canEditMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" && permission.level === \"Edit\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAiC;AAW1B,SAAS,cAAc,MAAgB,aAAkC;AAC9E,MAAI,YAAa,QAAO;AACxB,QAAM,QAAQ,KAAK,YAAY;AAC/B,MAAI,aAAS,0BAAS,KAAK,IAAI,oBAAI,KAAK,EAAG,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,OAAO;AAAA,MACP,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;AClEO,SAAS,eAAe,MAAqD;AAClF,SAAO,SAAS,WAAW,SAAS;AACtC;AAIO,SAAS,kBAAkB,MAAqD;AACrF,SAAO,SAAS;AAClB;AAMO,SAAS,iBAAiB,MAAqD;AACpF,SAAO,SAAS;AAClB;AAQO,SAAS,mBAAmB,SAAkD;AACnF,SAAO,SAAS,WAAW;AAC7B;AAWO,SAAS,uBACd,MACA,aACsC;AACtC,SAAO,cAAc,WAAW;AAClC;;;AC9BO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,WAAW,WAAW,UAAU,cAAc,WAAW;AACtF;AAIO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,YAAY,WAAW,UAAU;AAC9D;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/dealStatus.ts","../src/currency.ts","../src/projectPermissions.ts","../src/marketingPermission.ts","../src/personName.ts"],"sourcesContent":["export * from \"./dealStatus\";\nexport * from \"./currency\";\nexport * from \"./projectPermissions\";\nexport * from \"./marketingPermission\";\nexport * from \"./personName\";\n","import { format, parseISO } from \"date-fns\";\n\nexport type DealStatus = \"Active\" | \"Upcoming\" | \"Complete\";\n\ninterface DealLike {\n deal_terms?: {\n startDate?: string | null;\n } | null;\n}\n\n/** Identical logic in both nukleus-app and nukleus-clientapp's ProjectDealCard. */\nexport function getDealStatus(deal: DealLike, isCompleted: boolean): DealStatus {\n if (isCompleted) return \"Complete\";\n const start = deal.deal_terms?.startDate;\n if (start && parseISO(start) > new Date()) return \"Upcoming\";\n return \"Active\";\n}\n\n/** Identical logic in both apps' ProjectDealCard. */\nexport function formatDealDate(dateStr?: string | null): string {\n if (!dateStr) return \"—\";\n try {\n return format(parseISO(dateStr), \"MMM d, yyyy\");\n } catch {\n return dateStr;\n }\n}\n","/** Full-precision USD, e.g. \"$1,234.56\". Both apps' `fmtUSD` are functionally\n * identical (nukleus-app is explicit about the 2-decimal default; clientapp\n * relies on Intl's own default, which is also 2 for USD). */\nexport function fmtUSD(n: number): string {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(n);\n}\n\n/** Whole-dollar USD, e.g. \"$1,235\". Reconciled nullability: nukleus-app's\n * version accepted `n?: number` and fell back to \"--\"; clientapp's required\n * `n: number` with no fallback. Kept the null-safe contract -- a strict\n * superset, since every existing call site passing a real number already\n * satisfies it too. */\nexport function fmtUSDWhole(n?: number): string {\n return n != null\n ? new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n maximumFractionDigits: 0,\n }).format(n)\n : \"--\";\n}\n\n/** \"$54,000\" for whole dollars, \"$84.50\" otherwise -- nukleus-app's payments\n * UI money format. No clientapp equivalent to reconcile against. */\nexport function fmtUSDCompact(n: number): string {\n const cents = Math.round(n * 100);\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: cents % 100 === 0 ? 0 : 2,\n maximumFractionDigits: 2,\n }).format(cents / 100);\n}\n\n/** Generic \"--\"-on-empty stringifier -- identical in both apps' deal preview\n * dialogs. */\nexport function fmt(value: string | number | null | undefined, fallback = \"--\"): string {\n if (value === null || value === undefined || value === \"\") return fallback;\n return String(value);\n}\n\n/** Whole-dollar display with a leading \"$\", no Intl currency formatting --\n * identical in both apps' deal preview dialogs. Distinct from fmtUSDWhole:\n * this is a simpler toLocaleString-based formatter the preview dialogs use\n * directly, kept as its own function to match the exact source behavior\n * rather than merging it into fmtUSDWhole. */\nexport function fmtCurrency(amount: number | null | undefined): string {\n if (amount === null || amount === undefined) return \"--\";\n return `$${Number(amount).toLocaleString(\"en-US\", {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n })}`;\n}\n\n/** MM/DD/YYYY, \"--\" on empty/invalid -- identical in both apps' deal preview\n * dialogs. */\nexport function fmtDate(dateStr: string | null | undefined): string {\n if (!dateStr) return \"--\";\n try {\n return new Date(dateStr).toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n } catch {\n return dateStr;\n }\n}\n","export type ProjectMemberRole = \"Owner\" | \"Editor\" | \"Viewer\";\n\n/** Files + task/deliverable editing are gated on this exact rule in both\n * apps today -- duplicated independently across several files per app\n * (`roleCanEdit`/`canUpload`/`canEditDeliverables`), never centralized.\n * One source of truth instead of several copies that can drift apart. */\nexport function canEditProject(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\" || role === \"Editor\";\n}\n\n/** Task *status* specifically requires Editor, not just \"can edit\" --\n * nukleus-clientapp's own comment: \"only 'Editor' may change task status.\" */\nexport function canEditTaskStatus(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Editor\";\n}\n\n/** Member invite/role management is Owner-only in nukleus-app's UI today.\n * nukleus-clientapp has no edit affordance here at all -- looks like unbuilt\n * feature parity, not an intentional restriction (the role vocabulary\n * already supports it). */\nexport function canManageMembers(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\";\n}\n\ninterface ProjectLike {\n status?: string | null;\n}\n\n/** A project is read-only once cancelled -- no writes are accepted\n * server-side (RLS) regardless of this check; this just drives UI gating. */\nexport function isProjectCancelled(project: ProjectLike | null | undefined): boolean {\n return project?.status === \"Cancelled\";\n}\n\n/**\n * nukleus-app forces every member's effective role to \"Viewer\" once a\n * project is cancelled (`useProjectReadOnly` + `effectiveMemberRole`),\n * regardless of their stored role. nukleus-clientapp does not apply this\n * downgrade anywhere today -- a real, confirmed asymmetry, not a styling\n * difference. Exposed here so both apps can share the same rule once\n * clientapp adopts it; until then, clientapp callers should apply this\n * explicitly rather than assume parity.\n */\nexport function getEffectiveMemberRole(\n role: ProjectMemberRole | null | undefined,\n isCancelled: boolean,\n): ProjectMemberRole | null | undefined {\n return isCancelled ? \"Viewer\" : role;\n}\n","/**\n * Marketing deals' permission check is NOT one shared enum downgraded for\n * the client side -- it's two genuinely different shapes, confirmed against\n * real code:\n *\n * - nukleus-app: a 3-state enum via `getPermissionLevel(PERMISSIONS.CLIENT_MARKETING)`\n * (\"No Access\" | \"View\" | \"Edit\") -- the agency can have no access, view\n * only, or full edit, independent of org membership.\n * - nukleus-clientapp: a boolean `hasActiveAgencyLink` -- the client either\n * has an active link to the agency that owns these deals, or doesn't.\n * There is no view/edit distinction; clients never get write access here.\n *\n * Modeled as a discriminated union so each app's adapter supplies its own\n * real shape rather than being forced through the other's.\n */\nexport type MarketingPermission =\n { kind: \"levels\"; level: \"No Access\" | \"View\" | \"Edit\" } | { kind: \"linked\"; isLinked: boolean };\n\nexport function canViewMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" ? permission.level !== \"No Access\" : permission.isLinked;\n}\n\n/** Always false for the \"linked\" shape -- clients never get write access to\n * Marketing deals today (confirmed: clientapp has zero write UI). */\nexport function canEditMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" && permission.level === \"Edit\";\n}\n","/** \"J. Smith\" from \"John Smith\" -- both apps' real current behavior for a\n * project deal's owner name (nukleus-app's pre-retrofit local helper and\n * clientapp's current `getInitialFullName(name, null, true)`), reconciled\n * here as the single implementation. Matches the exact algorithm both\n * apps already use: first initial of the first word + the second word\n * verbatim, dropping anything beyond that (e.g. \"John Van Buren\" -> \"J.\n * Van\", not \"J. Buren\") -- not fixed here, since fixing it would make this\n * package's output diverge from what both apps' real data already looks\n * like today. */\nexport function abbreviatePersonName(name: string | null | undefined): string | null {\n const trimmed = name?.trim();\n if (!trimmed) return null;\n const parts = trimmed.split(\" \");\n const initial = parts[0]?.charAt(0).toUpperCase() ?? \"\";\n const last = parts[1] ?? \"\";\n return `${initial}. ${last}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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I,OAAO,MAAM,EAAE,eAAe,SAAS;AAAA,IAChD,uBAAuB;AAAA,IACvB,uBAAuB;AAAA,EACzB,CAAC,CAAC;AACJ;AAIO,SAAS,QAAQ,SAA4C;AAClE,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI;AACF,WAAO,IAAI,KAAK,OAAO,EAAE,mBAAmB,SAAS;AAAA,MACnD,OAAO;AAAA,MACP,KAAK;AAAA,MACL,MAAM;AAAA,IACR,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;AClEO,SAAS,eAAe,MAAqD;AAClF,SAAO,SAAS,WAAW,SAAS;AACtC;AAIO,SAAS,kBAAkB,MAAqD;AACrF,SAAO,SAAS;AAClB;AAMO,SAAS,iBAAiB,MAAqD;AACpF,SAAO,SAAS;AAClB;AAQO,SAAS,mBAAmB,SAAkD;AACnF,SAAO,SAAS,WAAW;AAC7B;AAWO,SAAS,uBACd,MACA,aACsC;AACtC,SAAO,cAAc,WAAW;AAClC;;;AC9BO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,WAAW,WAAW,UAAU,cAAc,WAAW;AACtF;AAIO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,YAAY,WAAW,UAAU;AAC9D;;;ACjBO,SAAS,qBAAqB,MAAgD;AACnF,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,QAAQ,MAAM,GAAG;AAC/B,QAAM,UAAU,MAAM,CAAC,GAAG,OAAO,CAAC,EAAE,YAAY,KAAK;AACrD,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,GAAG,OAAO,KAAK,IAAI;AAC5B;","names":[]}
package/dist/index.d.cts CHANGED
@@ -93,4 +93,15 @@ declare function canViewMarketingDeals(permission: MarketingPermission): boolean
93
93
  * Marketing deals today (confirmed: clientapp has zero write UI). */
94
94
  declare function canEditMarketingDeals(permission: MarketingPermission): boolean;
95
95
 
96
- export { type DealStatus, type MarketingPermission, type ProjectMemberRole, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, getDealStatus, getEffectiveMemberRole, isProjectCancelled };
96
+ /** "J. Smith" from "John Smith" -- both apps' real current behavior for a
97
+ * project deal's owner name (nukleus-app's pre-retrofit local helper and
98
+ * clientapp's current `getInitialFullName(name, null, true)`), reconciled
99
+ * here as the single implementation. Matches the exact algorithm both
100
+ * apps already use: first initial of the first word + the second word
101
+ * verbatim, dropping anything beyond that (e.g. "John Van Buren" -> "J.
102
+ * Van", not "J. Buren") -- not fixed here, since fixing it would make this
103
+ * package's output diverge from what both apps' real data already looks
104
+ * like today. */
105
+ declare function abbreviatePersonName(name: string | null | undefined): string | null;
106
+
107
+ export { type DealStatus, type MarketingPermission, type ProjectMemberRole, abbreviatePersonName, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, getDealStatus, getEffectiveMemberRole, isProjectCancelled };
package/dist/index.d.ts CHANGED
@@ -93,4 +93,15 @@ declare function canViewMarketingDeals(permission: MarketingPermission): boolean
93
93
  * Marketing deals today (confirmed: clientapp has zero write UI). */
94
94
  declare function canEditMarketingDeals(permission: MarketingPermission): boolean;
95
95
 
96
- export { type DealStatus, type MarketingPermission, type ProjectMemberRole, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, getDealStatus, getEffectiveMemberRole, isProjectCancelled };
96
+ /** "J. Smith" from "John Smith" -- both apps' real current behavior for a
97
+ * project deal's owner name (nukleus-app's pre-retrofit local helper and
98
+ * clientapp's current `getInitialFullName(name, null, true)`), reconciled
99
+ * here as the single implementation. Matches the exact algorithm both
100
+ * apps already use: first initial of the first word + the second word
101
+ * verbatim, dropping anything beyond that (e.g. "John Van Buren" -> "J.
102
+ * Van", not "J. Buren") -- not fixed here, since fixing it would make this
103
+ * package's output diverge from what both apps' real data already looks
104
+ * like today. */
105
+ declare function abbreviatePersonName(name: string | null | undefined): string | null;
106
+
107
+ export { type DealStatus, type MarketingPermission, type ProjectMemberRole, abbreviatePersonName, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, getDealStatus, getEffectiveMemberRole, isProjectCancelled };
package/dist/index.js CHANGED
@@ -88,7 +88,18 @@ function canViewMarketingDeals(permission) {
88
88
  function canEditMarketingDeals(permission) {
89
89
  return permission.kind === "levels" && permission.level === "Edit";
90
90
  }
91
+
92
+ // src/personName.ts
93
+ function abbreviatePersonName(name) {
94
+ const trimmed = name?.trim();
95
+ if (!trimmed) return null;
96
+ const parts = trimmed.split(" ");
97
+ const initial = parts[0]?.charAt(0).toUpperCase() ?? "";
98
+ const last = parts[1] ?? "";
99
+ return `${initial}. ${last}`;
100
+ }
91
101
  export {
102
+ abbreviatePersonName,
92
103
  canEditMarketingDeals,
93
104
  canEditProject,
94
105
  canEditTaskStatus,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dealStatus.ts","../src/currency.ts","../src/projectPermissions.ts","../src/marketingPermission.ts"],"sourcesContent":["import { format, parseISO } from \"date-fns\";\n\nexport type DealStatus = \"Active\" | \"Upcoming\" | \"Complete\";\n\ninterface DealLike {\n deal_terms?: {\n startDate?: string | null;\n } | null;\n}\n\n/** Identical logic in both nukleus-app and nukleus-clientapp's ProjectDealCard. */\nexport function getDealStatus(deal: DealLike, isCompleted: boolean): DealStatus {\n if (isCompleted) return \"Complete\";\n const start = deal.deal_terms?.startDate;\n if (start && parseISO(start) > new Date()) return \"Upcoming\";\n return \"Active\";\n}\n\n/** Identical logic in both apps' ProjectDealCard. */\nexport function formatDealDate(dateStr?: string | null): string {\n if (!dateStr) return \"—\";\n try {\n return format(parseISO(dateStr), \"MMM d, yyyy\");\n } catch {\n return dateStr;\n }\n}\n","/** Full-precision USD, e.g. \"$1,234.56\". Both apps' `fmtUSD` are functionally\n * identical (nukleus-app is explicit about the 2-decimal default; clientapp\n * relies on Intl's own default, which is also 2 for USD). */\nexport function fmtUSD(n: number): string {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(n);\n}\n\n/** Whole-dollar USD, e.g. \"$1,235\". Reconciled nullability: nukleus-app's\n * version accepted `n?: number` and fell back to \"--\"; clientapp's required\n * `n: number` with no fallback. Kept the null-safe contract -- a strict\n * superset, since every existing call site passing a real number already\n * satisfies it too. */\nexport function fmtUSDWhole(n?: number): string {\n return n != null\n ? new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n maximumFractionDigits: 0,\n }).format(n)\n : \"--\";\n}\n\n/** \"$54,000\" for whole dollars, \"$84.50\" otherwise -- nukleus-app's payments\n * UI money format. No clientapp equivalent to reconcile against. */\nexport function fmtUSDCompact(n: number): string {\n const cents = Math.round(n * 100);\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: cents % 100 === 0 ? 0 : 2,\n maximumFractionDigits: 2,\n }).format(cents / 100);\n}\n\n/** Generic \"--\"-on-empty stringifier -- identical in both apps' deal preview\n * dialogs. */\nexport function fmt(value: string | number | null | undefined, fallback = \"--\"): string {\n if (value === null || value === undefined || value === \"\") return fallback;\n return String(value);\n}\n\n/** Whole-dollar display with a leading \"$\", no Intl currency formatting --\n * identical in both apps' deal preview dialogs. Distinct from fmtUSDWhole:\n * this is a simpler toLocaleString-based formatter the preview dialogs use\n * directly, kept as its own function to match the exact source behavior\n * rather than merging it into fmtUSDWhole. */\nexport function fmtCurrency(amount: number | null | undefined): string {\n if (amount === null || amount === undefined) return \"--\";\n return `$${Number(amount).toLocaleString(\"en-US\", {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n })}`;\n}\n\n/** MM/DD/YYYY, \"--\" on empty/invalid -- identical in both apps' deal preview\n * dialogs. */\nexport function fmtDate(dateStr: string | null | undefined): string {\n if (!dateStr) return \"--\";\n try {\n return new Date(dateStr).toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n } catch {\n return dateStr;\n }\n}\n","export type ProjectMemberRole = \"Owner\" | \"Editor\" | \"Viewer\";\n\n/** Files + task/deliverable editing are gated on this exact rule in both\n * apps today -- duplicated independently across several files per app\n * (`roleCanEdit`/`canUpload`/`canEditDeliverables`), never centralized.\n * One source of truth instead of several copies that can drift apart. */\nexport function canEditProject(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\" || role === \"Editor\";\n}\n\n/** Task *status* specifically requires Editor, not just \"can edit\" --\n * nukleus-clientapp's own comment: \"only 'Editor' may change task status.\" */\nexport function canEditTaskStatus(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Editor\";\n}\n\n/** Member invite/role management is Owner-only in nukleus-app's UI today.\n * nukleus-clientapp has no edit affordance here at all -- looks like unbuilt\n * feature parity, not an intentional restriction (the role vocabulary\n * already supports it). */\nexport function canManageMembers(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\";\n}\n\ninterface ProjectLike {\n status?: string | null;\n}\n\n/** A project is read-only once cancelled -- no writes are accepted\n * server-side (RLS) regardless of this check; this just drives UI gating. */\nexport function isProjectCancelled(project: ProjectLike | null | undefined): boolean {\n return project?.status === \"Cancelled\";\n}\n\n/**\n * nukleus-app forces every member's effective role to \"Viewer\" once a\n * project is cancelled (`useProjectReadOnly` + `effectiveMemberRole`),\n * regardless of their stored role. nukleus-clientapp does not apply this\n * downgrade anywhere today -- a real, confirmed asymmetry, not a styling\n * difference. Exposed here so both apps can share the same rule once\n * clientapp adopts it; until then, clientapp callers should apply this\n * explicitly rather than assume parity.\n */\nexport function getEffectiveMemberRole(\n role: ProjectMemberRole | null | undefined,\n isCancelled: boolean,\n): ProjectMemberRole | null | undefined {\n return isCancelled ? \"Viewer\" : role;\n}\n","/**\n * Marketing deals' permission check is NOT one shared enum downgraded for\n * the client side -- it's two genuinely different shapes, confirmed against\n * real code:\n *\n * - nukleus-app: a 3-state enum via `getPermissionLevel(PERMISSIONS.CLIENT_MARKETING)`\n * (\"No Access\" | \"View\" | \"Edit\") -- the agency can have no access, view\n * only, or full edit, independent of org membership.\n * - nukleus-clientapp: a boolean `hasActiveAgencyLink` -- the client either\n * has an active link to the agency that owns these deals, or doesn't.\n * There is no view/edit distinction; clients never get write access here.\n *\n * Modeled as a discriminated union so each app's adapter supplies its own\n * real shape rather than being forced through the other's.\n */\nexport type MarketingPermission =\n { kind: \"levels\"; level: \"No Access\" | \"View\" | \"Edit\" } | { kind: \"linked\"; isLinked: boolean };\n\nexport function canViewMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" ? permission.level !== \"No Access\" : permission.isLinked;\n}\n\n/** Always false for the \"linked\" shape -- clients never get write access to\n * Marketing deals today (confirmed: clientapp has zero write UI). */\nexport function canEditMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" && permission.level === \"Edit\";\n}\n"],"mappings":";AAAA,SAAS,QAAQ,gBAAgB;AAW1B,SAAS,cAAc,MAAgB,aAAkC;AAC9E,MAAI,YAAa,QAAO;AACxB,QAAM,QAAQ,KAAK,YAAY;AAC/B,MAAI,SAAS,SAAS,KAAK,IAAI,oBAAI,KAAK,EAAG,QAAO;AAClD,SAAO;AACT;AAGO,SAAS,eAAe,SAAiC;AAC9D,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI;AACF,WAAO,OAAO,SAAS,OAAO,GAAG,aAAa;AAAA,EAChD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;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B,MAAqD;AACrF,SAAO,SAAS;AAClB;AAMO,SAAS,iBAAiB,MAAqD;AACpF,SAAO,SAAS;AAClB;AAQO,SAAS,mBAAmB,SAAkD;AACnF,SAAO,SAAS,WAAW;AAC7B;AAWO,SAAS,uBACd,MACA,aACsC;AACtC,SAAO,cAAc,WAAW;AAClC;;;AC9BO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,WAAW,WAAW,UAAU,cAAc,WAAW;AACtF;AAIO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,YAAY,WAAW,UAAU;AAC9D;","names":[]}
1
+ {"version":3,"sources":["../src/dealStatus.ts","../src/currency.ts","../src/projectPermissions.ts","../src/marketingPermission.ts","../src/personName.ts"],"sourcesContent":["import { format, parseISO } from \"date-fns\";\n\nexport type DealStatus = \"Active\" | \"Upcoming\" | \"Complete\";\n\ninterface DealLike {\n deal_terms?: {\n startDate?: string | null;\n } | null;\n}\n\n/** Identical logic in both nukleus-app and nukleus-clientapp's ProjectDealCard. */\nexport function getDealStatus(deal: DealLike, isCompleted: boolean): DealStatus {\n if (isCompleted) return \"Complete\";\n const start = deal.deal_terms?.startDate;\n if (start && parseISO(start) > new Date()) return \"Upcoming\";\n return \"Active\";\n}\n\n/** Identical logic in both apps' ProjectDealCard. */\nexport function formatDealDate(dateStr?: string | null): string {\n if (!dateStr) return \"—\";\n try {\n return format(parseISO(dateStr), \"MMM d, yyyy\");\n } catch {\n return dateStr;\n }\n}\n","/** Full-precision USD, e.g. \"$1,234.56\". Both apps' `fmtUSD` are functionally\n * identical (nukleus-app is explicit about the 2-decimal default; clientapp\n * relies on Intl's own default, which is also 2 for USD). */\nexport function fmtUSD(n: number): string {\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n }).format(n);\n}\n\n/** Whole-dollar USD, e.g. \"$1,235\". Reconciled nullability: nukleus-app's\n * version accepted `n?: number` and fell back to \"--\"; clientapp's required\n * `n: number` with no fallback. Kept the null-safe contract -- a strict\n * superset, since every existing call site passing a real number already\n * satisfies it too. */\nexport function fmtUSDWhole(n?: number): string {\n return n != null\n ? new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n maximumFractionDigits: 0,\n }).format(n)\n : \"--\";\n}\n\n/** \"$54,000\" for whole dollars, \"$84.50\" otherwise -- nukleus-app's payments\n * UI money format. No clientapp equivalent to reconcile against. */\nexport function fmtUSDCompact(n: number): string {\n const cents = Math.round(n * 100);\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n minimumFractionDigits: cents % 100 === 0 ? 0 : 2,\n maximumFractionDigits: 2,\n }).format(cents / 100);\n}\n\n/** Generic \"--\"-on-empty stringifier -- identical in both apps' deal preview\n * dialogs. */\nexport function fmt(value: string | number | null | undefined, fallback = \"--\"): string {\n if (value === null || value === undefined || value === \"\") return fallback;\n return String(value);\n}\n\n/** Whole-dollar display with a leading \"$\", no Intl currency formatting --\n * identical in both apps' deal preview dialogs. Distinct from fmtUSDWhole:\n * this is a simpler toLocaleString-based formatter the preview dialogs use\n * directly, kept as its own function to match the exact source behavior\n * rather than merging it into fmtUSDWhole. */\nexport function fmtCurrency(amount: number | null | undefined): string {\n if (amount === null || amount === undefined) return \"--\";\n return `$${Number(amount).toLocaleString(\"en-US\", {\n minimumFractionDigits: 0,\n maximumFractionDigits: 0,\n })}`;\n}\n\n/** MM/DD/YYYY, \"--\" on empty/invalid -- identical in both apps' deal preview\n * dialogs. */\nexport function fmtDate(dateStr: string | null | undefined): string {\n if (!dateStr) return \"--\";\n try {\n return new Date(dateStr).toLocaleDateString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n });\n } catch {\n return dateStr;\n }\n}\n","export type ProjectMemberRole = \"Owner\" | \"Editor\" | \"Viewer\";\n\n/** Files + task/deliverable editing are gated on this exact rule in both\n * apps today -- duplicated independently across several files per app\n * (`roleCanEdit`/`canUpload`/`canEditDeliverables`), never centralized.\n * One source of truth instead of several copies that can drift apart. */\nexport function canEditProject(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\" || role === \"Editor\";\n}\n\n/** Task *status* specifically requires Editor, not just \"can edit\" --\n * nukleus-clientapp's own comment: \"only 'Editor' may change task status.\" */\nexport function canEditTaskStatus(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Editor\";\n}\n\n/** Member invite/role management is Owner-only in nukleus-app's UI today.\n * nukleus-clientapp has no edit affordance here at all -- looks like unbuilt\n * feature parity, not an intentional restriction (the role vocabulary\n * already supports it). */\nexport function canManageMembers(role: ProjectMemberRole | null | undefined): boolean {\n return role === \"Owner\";\n}\n\ninterface ProjectLike {\n status?: string | null;\n}\n\n/** A project is read-only once cancelled -- no writes are accepted\n * server-side (RLS) regardless of this check; this just drives UI gating. */\nexport function isProjectCancelled(project: ProjectLike | null | undefined): boolean {\n return project?.status === \"Cancelled\";\n}\n\n/**\n * nukleus-app forces every member's effective role to \"Viewer\" once a\n * project is cancelled (`useProjectReadOnly` + `effectiveMemberRole`),\n * regardless of their stored role. nukleus-clientapp does not apply this\n * downgrade anywhere today -- a real, confirmed asymmetry, not a styling\n * difference. Exposed here so both apps can share the same rule once\n * clientapp adopts it; until then, clientapp callers should apply this\n * explicitly rather than assume parity.\n */\nexport function getEffectiveMemberRole(\n role: ProjectMemberRole | null | undefined,\n isCancelled: boolean,\n): ProjectMemberRole | null | undefined {\n return isCancelled ? \"Viewer\" : role;\n}\n","/**\n * Marketing deals' permission check is NOT one shared enum downgraded for\n * the client side -- it's two genuinely different shapes, confirmed against\n * real code:\n *\n * - nukleus-app: a 3-state enum via `getPermissionLevel(PERMISSIONS.CLIENT_MARKETING)`\n * (\"No Access\" | \"View\" | \"Edit\") -- the agency can have no access, view\n * only, or full edit, independent of org membership.\n * - nukleus-clientapp: a boolean `hasActiveAgencyLink` -- the client either\n * has an active link to the agency that owns these deals, or doesn't.\n * There is no view/edit distinction; clients never get write access here.\n *\n * Modeled as a discriminated union so each app's adapter supplies its own\n * real shape rather than being forced through the other's.\n */\nexport type MarketingPermission =\n { kind: \"levels\"; level: \"No Access\" | \"View\" | \"Edit\" } | { kind: \"linked\"; isLinked: boolean };\n\nexport function canViewMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" ? permission.level !== \"No Access\" : permission.isLinked;\n}\n\n/** Always false for the \"linked\" shape -- clients never get write access to\n * Marketing deals today (confirmed: clientapp has zero write UI). */\nexport function canEditMarketingDeals(permission: MarketingPermission): boolean {\n return permission.kind === \"levels\" && permission.level === \"Edit\";\n}\n","/** \"J. Smith\" from \"John Smith\" -- both apps' real current behavior for a\n * project deal's owner name (nukleus-app's pre-retrofit local helper and\n * clientapp's current `getInitialFullName(name, null, true)`), reconciled\n * here as the single implementation. Matches the exact algorithm both\n * apps already use: first initial of the first word + the second word\n * verbatim, dropping anything beyond that (e.g. \"John Van Buren\" -> \"J.\n * Van\", not \"J. Buren\") -- not fixed here, since fixing it would make this\n * package's output diverge from what both apps' real data already looks\n * like today. */\nexport function abbreviatePersonName(name: string | null | undefined): string | null {\n const trimmed = name?.trim();\n if (!trimmed) return null;\n const parts = trimmed.split(\" \");\n const initial = parts[0]?.charAt(0).toUpperCase() ?? \"\";\n const last = parts[1] ?? \"\";\n return `${initial}. ${last}`;\n}\n"],"mappings":";AAAA,SAAS,QAAQ,gBAAgB;AAW1B,SAAS,cAAc,MAAgB,aAAkC;AAC9E,MAAI,YAAa,QAAO;AACxB,QAAM,QAAQ,KAAK,YAAY;AAC/B,MAAI,SAAS,SAAS,KAAK,IAAI,oBAAI,KAAK,EAAG,QAAO;AAClD,SAAO;AACT;AAGO,SAAS,eAAe,SAAiC;AAC9D,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI;AACF,WAAO,OAAO,SAAS,OAAO,GAAG,aAAa;AAAA,EAChD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACvBO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AqD;AACrF,SAAO,SAAS;AAClB;AAMO,SAAS,iBAAiB,MAAqD;AACpF,SAAO,SAAS;AAClB;AAQO,SAAS,mBAAmB,SAAkD;AACnF,SAAO,SAAS,WAAW;AAC7B;AAWO,SAAS,uBACd,MACA,aACsC;AACtC,SAAO,cAAc,WAAW;AAClC;;;AC9BO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,WAAW,WAAW,UAAU,cAAc,WAAW;AACtF;AAIO,SAAS,sBAAsB,YAA0C;AAC9E,SAAO,WAAW,SAAS,YAAY,WAAW,UAAU;AAC9D;;;ACjBO,SAAS,qBAAqB,MAAgD;AACnF,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,QAAQ,MAAM,GAAG;AAC/B,QAAM,UAAU,MAAM,CAAC,GAAG,OAAO,CAAC,EAAE,YAAY,KAAK;AACrD,QAAM,OAAO,MAAM,CAAC,KAAK;AACzB,SAAO,GAAG,OAAO,KAAK,IAAI;AAC5B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nukleus-sports/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",