@tuturuuu/utils 0.16.0 → 0.17.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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.17.0](https://github.com/tutur3u/platform/compare/utils-v0.16.0...utils-v0.17.0) (2026-07-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * **infrastructure:** manage internal accounts ([02fd9f3](https://github.com/tutur3u/platform/commit/02fd9f3d1b4edb23c881e2dbb04bf244b36e6ed0))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **chat:** harden personal Zalo integration ([f1d12c6](https://github.com/tutur3u/platform/commit/f1d12c60fe12ab3b01a1be3f0381573d44a32226))
14
+ * **ci:** keep task helper collection source-only ([7355a05](https://github.com/tutur3u/platform/commit/7355a05385ccd8d1e2d1bcf6ac15ae5297e057ad))
15
+ * **e2e:** run tasks lifecycle in CI ([bed2cd5](https://github.com/tutur3u/platform/commit/bed2cd590572748f65e75fcb15b7e4b714b9034c))
16
+ * **inventory:** harden sales analytics and access ([53968d3](https://github.com/tutur3u/platform/commit/53968d38a0c5425a3c1065ab2f645e30a0145c8f))
17
+ * resolve code quality findings ([63f10b5](https://github.com/tutur3u/platform/commit/63f10b5ec22a4194f48f448ee2b1b088b5da8f08))
18
+ * **security:** remediate code scanning findings ([023db2e](https://github.com/tutur3u/platform/commit/023db2edf4b0557be108a9d772cbc7e2223af947))
19
+
20
+
21
+ ### Performance Improvements
22
+
23
+ * **storefront:** share customer navigation shell ([21cb78d](https://github.com/tutur3u/platform/commit/21cb78db484d1e1fdb9f2469fcac4e3a948bd176))
24
+
3
25
  ## [0.16.0](https://github.com/tutur3u/platform/compare/utils-v0.15.1...utils-v0.16.0) (2026-07-18)
4
26
 
5
27
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tuturuuu/utils",
3
3
  "license": "MIT",
4
- "version": "0.16.0",
4
+ "version": "0.17.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/tutur3u/platform",
@@ -20,12 +20,12 @@
20
20
  "@noble/ciphers": "^2.2.0",
21
21
  "@noble/hashes": "^2.2.0",
22
22
  "@tanstack/react-query": "^5.101.2",
23
- "@tiptap/core": "3.27.4",
24
- "@tiptap/react": "3.27.4",
23
+ "@tiptap/core": "3.28.0",
24
+ "@tiptap/react": "3.28.0",
25
25
  "@tuturuuu/google": "0.0.3",
26
26
  "@tuturuuu/icons": "0.0.6",
27
- "@tuturuuu/internal-api": "0.19.0",
28
- "@tuturuuu/supabase": "0.4.0",
27
+ "@tuturuuu/internal-api": "0.20.0",
28
+ "@tuturuuu/supabase": "0.4.1",
29
29
  "@upstash/ratelimit": "^2.0.8",
30
30
  "@upstash/redis": "^1.38.0",
31
31
  "clsx": "^2.1.1",
@@ -45,14 +45,14 @@
45
45
  "zod": "^4.4.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@tuturuuu/types": "0.18.0",
48
+ "@tuturuuu/types": "0.19.0",
49
49
  "@tuturuuu/typescript-config": "0.1.1",
50
50
  "@types/diff": "^8.0.0",
51
51
  "@types/node": "^26.1.1",
52
52
  "@types/react": "^19.2.17",
53
53
  "@vitejs/plugin-react": "^6.0.3",
54
54
  "typescript": "7.0.2",
55
- "vite": "^8.1.4",
55
+ "vite": "^8.1.5",
56
56
  "vitest": "^4.1.10"
57
57
  },
58
58
  "exports": {
@@ -60,6 +60,7 @@
60
60
  "./effect": "./src/effect.ts",
61
61
  "./email/validation": "./src/email/validation.ts",
62
62
  "./hooks/*": "./src/hooks/*.ts",
63
+ "./task-helper/personal-external-staging": "./src/task-helper/personal-external-staging.ts",
63
64
  "./*": "./src/*.ts",
64
65
  "./common/scan": "./src/common/scan.tsx",
65
66
  "./common/metadata": "./src/common/metadata.ts",
@@ -1,6 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
3
  import { describe, expect, it } from 'vitest';
4
+ import { ROOT_WORKSPACE_ID } from '../constants';
4
5
  import { permissions } from '../permissions';
5
6
 
6
7
  describe('workspace permission catalog', () => {
@@ -30,9 +31,39 @@ describe('workspace permission catalog', () => {
30
31
  expect(permissionIds).toContain('admin');
31
32
  expect(permissionIds).not.toContain('view_infrastructure');
32
33
  expect(permissionIds).not.toContain('manage_infrastructure_stress_tests');
34
+ expect(permissionIds).not.toContain('manage_internal_accounts');
33
35
  expect(permissionIds).not.toContain('manage_workspace_secrets');
34
36
  });
35
37
 
38
+ it('exposes internal account management only in the root workspace', () => {
39
+ const rootPermissionIds = permissions({
40
+ wsId: ROOT_WORKSPACE_ID,
41
+ user: null,
42
+ }).map((permission) => permission.id);
43
+
44
+ expect(rootPermissionIds).toContain('manage_internal_accounts');
45
+ });
46
+
47
+ it('keeps internal account permission translations in shared role editors', () => {
48
+ for (const app of ['cms', 'infrastructure', 'inventory', 'web']) {
49
+ for (const locale of ['en', 'vi']) {
50
+ const messages = JSON.parse(
51
+ readFileSync(
52
+ resolve(repoRoot, `apps/${app}/messages/${locale}.json`),
53
+ 'utf8'
54
+ )
55
+ ) as { 'ws-roles': Record<string, string> };
56
+
57
+ expect(
58
+ messages['ws-roles'].manage_internal_accounts?.length
59
+ ).toBeGreaterThan(0);
60
+ expect(
61
+ messages['ws-roles'].manage_internal_accounts_description?.length
62
+ ).toBeGreaterThan(0);
63
+ }
64
+ }
65
+ });
66
+
36
67
  it('exposes the full shared catalog for typed defaults', () => {
37
68
  const permissionIds = permissions({
38
69
  catalog: 'full',
@@ -43,6 +74,7 @@ describe('workspace permission catalog', () => {
43
74
  expect(permissionIds).toContain('admin');
44
75
  expect(permissionIds).toContain('view_infrastructure');
45
76
  expect(permissionIds).toContain('manage_infrastructure_stress_tests');
77
+ expect(permissionIds).toContain('manage_internal_accounts');
46
78
  expect(permissionIds).toContain('manage_external_migrations');
47
79
  expect(permissionIds).toContain('manage_workspace_secrets');
48
80
  expect(new Set(permissionIds).size).toBe(permissionIds.length);
@@ -578,7 +578,7 @@ describe('getPermissions membership type gate', () => {
578
578
  );
579
579
  });
580
580
 
581
- it('returns null when caller membership is GUEST without enabled guest defaults', async () => {
581
+ it('returns a read-only permission context for a guest without defaults', async () => {
582
582
  const membershipQuery = {
583
583
  select: vi.fn(),
584
584
  eq: vi.fn(),
@@ -656,7 +656,14 @@ describe('getPermissions membership type gate', () => {
656
656
  wsId: '11111111-1111-4111-8111-111111111111',
657
657
  });
658
658
 
659
- expect(permissions).toBeNull();
659
+ expect(permissions).toMatchObject({
660
+ membershipType: 'GUEST',
661
+ permissions: [],
662
+ wsId: '11111111-1111-4111-8111-111111111111',
663
+ });
664
+ expect(permissions?.containsPermission('manage_workspace_settings')).toBe(
665
+ false
666
+ );
660
667
  expect(defaultPermissionsQuery.eq).toHaveBeenCalledWith(
661
668
  'member_type',
662
669
  'GUEST'
@@ -183,6 +183,21 @@ describe('createPageMetadata', () => {
183
183
  });
184
184
  });
185
185
 
186
+ it('normalizes long runs of boundary slashes in linear time', () => {
187
+ const boundary = '/'.repeat(20_000);
188
+ const metadata = createPageMetadata({
189
+ baseUrl: 'https://test.tuturuuu.com',
190
+ description: 'Stable metadata path normalization.',
191
+ locale: 'en',
192
+ pathname: `${boundary}products/workflows${boundary}`,
193
+ title: 'Workflow Automation',
194
+ });
195
+
196
+ expect(metadata.alternates?.canonical).toBe(
197
+ 'https://test.tuturuuu.com/products/workflows'
198
+ );
199
+ });
200
+
186
201
  it('supports apps that never expose locale prefixes', () => {
187
202
  const metadata = createPageMetadata({
188
203
  baseUrl: 'https://tools.tuturuuu.com',
@@ -282,8 +297,8 @@ describe('application metadata coverage', () => {
282
297
  'apps/tools/src/app/[locale]/page.tsx',
283
298
  'apps/tools/src/app/[locale]/qr/page.tsx',
284
299
  'apps/tools/src/app/[locale]/random/page.tsx',
285
- 'apps/storefront/src/app/[locale]/[storeSlug]/page.tsx',
286
- 'apps/storefront/src/app/[locale]/[storeSlug]/products/[listingId]/page.tsx',
300
+ 'apps/storefront/src/app/[locale]/[storeSlug]/(shop)/page.tsx',
301
+ 'apps/storefront/src/app/[locale]/[storeSlug]/(shop)/products/[listingId]/page.tsx',
287
302
  'apps/nova/src/app/[locale]/(marketing)/layout.tsx',
288
303
  'apps/nova/src/app/[locale]/(marketing)/learn/layout.tsx',
289
304
  ];
@@ -70,6 +70,16 @@ function getOpenGraphLocale(locale: string) {
70
70
  return locale === 'vi' ? 'vi_VN' : 'en_US';
71
71
  }
72
72
 
73
+ function trimSlashes(value: string) {
74
+ let start = 0;
75
+ let end = value.length;
76
+
77
+ while (start < end && value[start] === '/') start += 1;
78
+ while (end > start && value[end - 1] === '/') end -= 1;
79
+
80
+ return value.slice(start, end);
81
+ }
82
+
73
83
  function getLocalizedUrl(
74
84
  baseUrl: string,
75
85
  locale: string,
@@ -77,7 +87,7 @@ function getLocalizedUrl(
77
87
  localePrefix: NonNullable<PageMetadataConfig['localePrefix']>
78
88
  ) {
79
89
  const normalizedPathname =
80
- pathname === '/' ? '' : `/${pathname.replace(/^\/+|\/+$/g, '')}`;
90
+ pathname === '/' ? '' : `/${trimSlashes(pathname)}`;
81
91
  const localizedPrefix =
82
92
  localePrefix === 'never' ||
83
93
  (localePrefix === 'as-needed' && locale === 'en')
@@ -101,6 +101,28 @@ describe('launchable apps', () => {
101
101
  currentOrigin: 'https://calendar.tuturuuu.localhost',
102
102
  })
103
103
  ).toBe('https://tasks.tuturuuu.localhost');
104
+
105
+ expect(
106
+ getLaunchableAppOrigin(app!, {
107
+ currentOrigin: 'https://tuturuuu.localhost:1355',
108
+ })
109
+ ).toBe('https://tasks.tuturuuu.localhost:1355');
110
+ });
111
+
112
+ it('preserves the Portless proxy port in full app URLs', () => {
113
+ const app = getLaunchableApp('tasks');
114
+
115
+ expect(app).not.toBeNull();
116
+ expect(
117
+ resolveLaunchableAppUrl({
118
+ app: app!,
119
+ currentOrigin: 'https://tuturuuu.localhost:1355',
120
+ searchParams: { source: 'sidebar-apps' },
121
+ workspace: teamWorkspace,
122
+ })
123
+ ).toBe(
124
+ 'https://tasks.tuturuuu.localhost:1355/team-workspace/tasks?source=sidebar-apps'
125
+ );
104
126
  });
105
127
 
106
128
  it('uses default paths when no workspace is provided', () => {
@@ -395,6 +395,32 @@ function getAutoEnvironment(currentOrigin?: string): LaunchableAppEnvironment {
395
395
  return process.env.NODE_ENV === 'production' ? 'production' : 'portless';
396
396
  }
397
397
 
398
+ function preservePortlessProxyPort(
399
+ targetOrigin: string,
400
+ currentOrigin?: string
401
+ ): string {
402
+ if (!currentOrigin) return targetOrigin;
403
+
404
+ try {
405
+ const currentUrl = new URL(currentOrigin);
406
+ const targetUrl = new URL(targetOrigin);
407
+ const isCurrentPortlessHost =
408
+ currentUrl.hostname === 'tuturuuu.localhost' ||
409
+ currentUrl.hostname.endsWith('.tuturuuu.localhost');
410
+ const isTargetPortlessHost =
411
+ targetUrl.hostname === 'tuturuuu.localhost' ||
412
+ targetUrl.hostname.endsWith('.tuturuuu.localhost');
413
+
414
+ if (isCurrentPortlessHost && isTargetPortlessHost && currentUrl.port) {
415
+ targetUrl.port = currentUrl.port;
416
+ }
417
+
418
+ return targetUrl.origin;
419
+ } catch {
420
+ return targetOrigin;
421
+ }
422
+ }
423
+
398
424
  export function getLaunchableAppOrigin(
399
425
  app: LaunchableApp,
400
426
  {
@@ -413,7 +439,10 @@ export function getLaunchableAppOrigin(
413
439
  return app.localhostOrigin ?? getTuturuuuPortlessAppOrigin(app.portlessApp);
414
440
  }
415
441
 
416
- return getTuturuuuPortlessAppOrigin(app.portlessApp);
442
+ return preservePortlessProxyPort(
443
+ getTuturuuuPortlessAppOrigin(app.portlessApp),
444
+ currentOrigin
445
+ );
417
446
  }
418
447
 
419
448
  function trimTrailingSlashes(value: string) {
package/src/money.ts CHANGED
@@ -40,7 +40,7 @@ export function getCurrencyFractionDigits(currency = 'USD'): number {
40
40
  const cached = fractionDigitsCache.get(code);
41
41
  if (cached !== undefined) return cached;
42
42
 
43
- let digits = DEFAULT_FRACTION_DIGITS;
43
+ let digits: number;
44
44
  try {
45
45
  digits =
46
46
  new Intl.NumberFormat(getCurrencyLocale(code), {
@@ -4,6 +4,7 @@ import {
4
4
  createTuturuuuNextConfig,
5
5
  isTuturuuuNextCacheComponentsEnabled,
6
6
  isTuturuuuNextReactCompilerEnabled,
7
+ resolveTuturuuuInfrastructureAppUrl,
7
8
  resolveTuturuuuWebAppUrl,
8
9
  TUTURUUU_NEXT_IMAGE_REMOTE_PATTERNS,
9
10
  TUTURUUU_NEXT_OPTIMIZE_PACKAGE_IMPORTS,
@@ -372,6 +373,46 @@ describe('resolveTuturuuuWebAppUrl', () => {
372
373
  });
373
374
  });
374
375
 
376
+ describe('resolveTuturuuuInfrastructureAppUrl', () => {
377
+ it('trims configured infrastructure origins', () => {
378
+ expect(
379
+ resolveTuturuuuInfrastructureAppUrl({
380
+ env: {
381
+ INTERNAL_INFRASTRUCTURE_API_ORIGIN: 'https://example.com///',
382
+ NODE_ENV: 'development',
383
+ },
384
+ })
385
+ ).toBe('https://example.com');
386
+ });
387
+
388
+ it('uses the local Portless infrastructure app in development', () => {
389
+ expect(
390
+ resolveTuturuuuInfrastructureAppUrl({
391
+ env: { NODE_ENV: 'development' },
392
+ })
393
+ ).toBe('https://infra.tuturuuu.localhost');
394
+ });
395
+
396
+ it('uses the canonical production infrastructure app when deployed', () => {
397
+ expect(
398
+ resolveTuturuuuInfrastructureAppUrl({
399
+ env: { VERCEL_ENV: 'production' },
400
+ })
401
+ ).toBe('https://infrastructure.tuturuuu.com');
402
+ });
403
+
404
+ it('ignores origins registered to another Tuturuuu app', () => {
405
+ expect(
406
+ resolveTuturuuuInfrastructureAppUrl({
407
+ env: {
408
+ INTERNAL_INFRASTRUCTURE_API_ORIGIN: 'https://chat.tuturuuu.com',
409
+ VERCEL_ENV: 'production',
410
+ },
411
+ })
412
+ ).toBe('https://infrastructure.tuturuuu.com');
413
+ });
414
+ });
415
+
375
416
  describe('trimTrailingSlashes', () => {
376
417
  it('removes only trailing slash characters', () => {
377
418
  expect(trimTrailingSlashes('https://example.com/path///')).toBe(
@@ -193,3 +193,31 @@ export function resolveTuturuuuWebAppUrl({
193
193
  (isTuturuuuNextDeployedEnvironment(env) ? productionUrl : localUrl)
194
194
  );
195
195
  }
196
+
197
+ export function resolveTuturuuuInfrastructureAppUrl({
198
+ env = process.env,
199
+ localFallbackUrl,
200
+ productionUrl = 'https://infrastructure.tuturuuu.com',
201
+ }: {
202
+ env?: Environment;
203
+ localFallbackUrl?: string;
204
+ productionUrl?: string;
205
+ } = {}) {
206
+ const localUrl =
207
+ localFallbackUrl ??
208
+ getLocalInternalAppUrl('infra', 'http://localhost:7823');
209
+
210
+ return trimTrailingSlashes(
211
+ resolveInternalAppUrl({
212
+ appName: 'infra',
213
+ candidates: [
214
+ env.INTERNAL_INFRASTRUCTURE_API_ORIGIN,
215
+ env.INFRASTRUCTURE_APP_URL,
216
+ env.NEXT_PUBLIC_INFRASTRUCTURE_APP_URL,
217
+ ],
218
+ fallback: isTuturuuuNextDeployedEnvironment(env)
219
+ ? productionUrl
220
+ : localUrl,
221
+ })
222
+ );
223
+ }
@@ -121,6 +121,16 @@ export const permissionGroups = ({
121
121
  disableOnProduction: false,
122
122
  disabled: false,
123
123
  },
124
+ {
125
+ id: 'manage_internal_accounts' as PermissionId,
126
+ icon: <UserCog />,
127
+ title: t('ws-roles.manage_internal_accounts'),
128
+ description: t(
129
+ 'ws-roles.manage_internal_accounts_description'
130
+ ),
131
+ disableOnProduction: false,
132
+ disabled: false,
133
+ },
124
134
  {
125
135
  id: 'manage_mobile_deployment_vault' as PermissionId,
126
136
  icon: <FileKey2 />,
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  describe('platform release metadata', () => {
9
9
  it('uses the centralized shared browser app version', () => {
10
- expect(TUTURUUU_PLATFORM_VERSION).toBe('0.23.0'); // x-release-please-version
10
+ expect(TUTURUUU_PLATFORM_VERSION).toBe('0.24.0'); // x-release-please-version
11
11
  });
12
12
 
13
13
  it('preserves the source timestamp in builtAt and derives a short hash', () => {
@@ -1,6 +1,6 @@
1
1
  import { PLATFORM_BUILD_METADATA } from './generated/platform-build-metadata';
2
2
 
3
- export const TUTURUUU_PLATFORM_VERSION = '0.23.0'; // x-release-please-version
3
+ export const TUTURUUU_PLATFORM_VERSION = '0.24.0'; // x-release-please-version
4
4
 
5
5
  export type PlatformBuildMetadataInput = {
6
6
  /** ISO timestamp of the source commit used for the build, not deployment time. */
@@ -153,9 +153,11 @@ export function useWorkspaceLabels(wsId: string | null | undefined) {
153
153
 
154
154
  export interface BoardConfig {
155
155
  id: string;
156
+ name?: string | null;
156
157
  estimation_type: string | null;
157
158
  extended_estimation: boolean;
158
159
  allow_zero_estimates: boolean;
160
+ count_unestimated_issues?: boolean;
159
161
  ws_id: string;
160
162
  ticket_prefix: string | null;
161
163
  }
@@ -179,9 +181,11 @@ export function useBoardConfig(
179
181
 
180
182
  return {
181
183
  id: board.id,
184
+ name: board.name ?? null,
182
185
  estimation_type: board.estimation_type ?? null,
183
186
  extended_estimation: board.extended_estimation ?? false,
184
187
  allow_zero_estimates: board.allow_zero_estimates ?? false,
188
+ count_unestimated_issues: board.count_unestimated_issues ?? false,
185
189
  ws_id: board.ws_id,
186
190
  ticket_prefix: board.ticket_prefix ?? null,
187
191
  } as BoardConfig;
@@ -828,22 +828,14 @@ async function getPermissionsImpl({
828
828
 
829
829
  const isCreator =
830
830
  membershipType === 'MEMBER' && workspaceData.creator_id === userId;
831
- const hasPermissions =
832
- permissionsData.length > 0 || defaultData.length > 0 || isCreator;
833
-
834
831
  // if (DEV_MODE) {
835
832
  // console.log('--------------------');
836
833
  // console.log('Is creator', isCreator);
837
834
  // console.log('Workspace permissions', permissionsData);
838
835
  // console.log('Default permissions', defaultData);
839
- // console.log('Has permissions', hasPermissions);
840
836
  // console.log('--------------------');
841
837
  // }
842
838
 
843
- if (!isCreator && !hasPermissions) {
844
- return null;
845
- }
846
-
847
839
  const permissions = isCreator
848
840
  ? rolePermissions({
849
841
  wsId: resolvedWorkspaceId,