Skip to content

Commit fe8a2b2

Browse files
improvement(files): drop reserved public_share columns until used; sync audit mock
1 parent 6236944 commit fe8a2b2

8 files changed

Lines changed: 8 additions & 59 deletions

File tree

apps/sim/app/api/workspaces/[id]/files/[fileId]/share/route.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ const SHARE = {
4545
token: 'tok_1',
4646
url: 'https://sim.ai/f/tok_1',
4747
isActive: true,
48-
accessLevel: 'view' as const,
49-
authType: 'public' as const,
5048
resourceType: 'file' as const,
5149
resourceId: FILE_ID,
5250
}

apps/sim/lib/api/contracts/public-shares.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ import { workspaceIdSchema } from '@/lib/api/contracts/primitives'
33
import { defineRouteContract } from '@/lib/api/contracts/types'
44

55
export const shareResourceTypeSchema = z.enum(['file', 'folder'])
6-
export const shareAccessLevelSchema = z.enum(['view', 'edit'])
7-
export const shareAuthTypeSchema = z.enum(['public', 'password', 'email'])
86

97
/**
10-
* Public-safe representation of a `public_share` row. Never carries the encrypted
11-
* password or the underlying storage key.
8+
* Public-safe representation of a `public_share` row. Never carries the
9+
* underlying storage key.
1210
*/
1311
export const shareRecordSchema = z.object({
1412
id: z.string(),
1513
token: z.string(),
1614
url: z.string(),
1715
isActive: z.boolean(),
18-
accessLevel: shareAccessLevelSchema,
19-
authType: shareAuthTypeSchema,
2016
resourceType: shareResourceTypeSchema,
2117
resourceId: z.string(),
2218
})

apps/sim/lib/public-shares/share-manager.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@ import { createLogger } from '@sim/logger'
44
import { generateId, generateShortId } from '@sim/utils/id'
55
import { and, eq, inArray } from 'drizzle-orm'
66
import type { z } from 'zod'
7-
import type {
8-
ShareRecord,
9-
shareAccessLevelSchema,
10-
shareAuthTypeSchema,
11-
shareResourceTypeSchema,
12-
} from '@/lib/api/contracts/public-shares'
7+
import type { ShareRecord, shareResourceTypeSchema } from '@/lib/api/contracts/public-shares'
138
import { getBaseUrl } from '@/lib/core/utils/urls'
149

1510
const logger = createLogger('PublicShareManager')
1611

1712
type ShareResourceType = z.infer<typeof shareResourceTypeSchema>
18-
type ShareAccessLevel = z.infer<typeof shareAccessLevelSchema>
19-
type ShareAuthType = z.infer<typeof shareAuthTypeSchema>
2013

2114
type PublicShareRow = typeof publicShare.$inferSelect
2215

@@ -31,8 +24,6 @@ function mapShareRecord(row: PublicShareRow): ShareRecord {
3124
token: row.token,
3225
url: buildShareUrl(row.token),
3326
isActive: row.isActive,
34-
accessLevel: row.accessLevel as ShareAccessLevel,
35-
authType: row.authType as ShareAuthType,
3627
resourceType: row.resourceType as ShareResourceType,
3728
resourceId: row.resourceId,
3829
}

packages/db/migrations/0242_public_share.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ CREATE TABLE "public_share" (
66
"created_by" text NOT NULL,
77
"token" text NOT NULL,
88
"is_active" boolean DEFAULT true NOT NULL,
9-
"access_level" text DEFAULT 'view' NOT NULL,
10-
"auth_type" text DEFAULT 'public' NOT NULL,
11-
"password" text,
12-
"allowed_emails" json DEFAULT '[]',
139
"created_at" timestamp DEFAULT now() NOT NULL,
1410
"updated_at" timestamp DEFAULT now() NOT NULL
1511
);

packages/db/migrations/meta/0242_snapshot.json

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "379b2199-4050-4575-bd20-38fb9bbde6c2",
2+
"id": "a99c0c8d-17cb-4153-8888-409e9af9c167",
33
"prevId": "f7a9fd28-8bd2-4421-a048-a0a768fc8475",
44
"version": "7",
55
"dialect": "postgresql",
@@ -10005,33 +10005,6 @@
1000510005
"notNull": true,
1000610006
"default": true
1000710007
},
10008-
"access_level": {
10009-
"name": "access_level",
10010-
"type": "text",
10011-
"primaryKey": false,
10012-
"notNull": true,
10013-
"default": "'view'"
10014-
},
10015-
"auth_type": {
10016-
"name": "auth_type",
10017-
"type": "text",
10018-
"primaryKey": false,
10019-
"notNull": true,
10020-
"default": "'public'"
10021-
},
10022-
"password": {
10023-
"name": "password",
10024-
"type": "text",
10025-
"primaryKey": false,
10026-
"notNull": false
10027-
},
10028-
"allowed_emails": {
10029-
"name": "allowed_emails",
10030-
"type": "json",
10031-
"primaryKey": false,
10032-
"notNull": false,
10033-
"default": "'[]'"
10034-
},
1003510008
"created_at": {
1003610009
"name": "created_at",
1003710010
"type": "timestamp",

packages/db/migrations/meta/_journal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@
16921692
{
16931693
"idx": 242,
16941694
"version": "7",
1695-
"when": 1781815945803,
1695+
"when": 1781816705434,
16961696
"tag": "0242_public_share",
16971697
"breakpoints": true
16981698
}

packages/db/schema.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,10 +1392,7 @@ export const workspaceFiles = pgTable(
13921392
/**
13931393
* Public share links for workspace resources. Polymorphic on `resourceType` so a
13941394
* single mechanism serves files now and folders later. One row per resource
1395-
* (disable/re-enable flips `isActive` and keeps the same token). `accessLevel`,
1396-
* `authType`, `password`, and `allowedEmails` are reserved for future
1397-
* password/email gating and edit links — v1 honors only `accessLevel='view'` and
1398-
* `authType='public'`.
1395+
* (disable/re-enable flips `isActive` and keeps the same token).
13991396
*/
14001397
export const publicShare = pgTable(
14011398
'public_share',
@@ -1411,10 +1408,6 @@ export const publicShare = pgTable(
14111408
.references(() => user.id, { onDelete: 'cascade' }),
14121409
token: text('token').notNull(),
14131410
isActive: boolean('is_active').notNull().default(true),
1414-
accessLevel: text('access_level').notNull().default('view'), // 'view' | 'edit' (v1 honors only 'view')
1415-
authType: text('auth_type').notNull().default('public'), // 'public' | 'password' | 'email' (future)
1416-
password: text('password'), // encrypted, populated when authType is 'password' (future)
1417-
allowedEmails: json('allowed_emails').default('[]'), // emails/domains when authType is 'email' (future)
14181411
createdAt: timestamp('created_at').notNull().defaultNow(),
14191412
updatedAt: timestamp('updated_at').notNull().defaultNow(),
14201413
},

packages/testing/src/mocks/audit.mock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ export const auditMock = {
7676
FILE_DELETED: 'file.deleted',
7777
FILE_RESTORED: 'file.restored',
7878
FILE_MOVED: 'file.moved',
79+
FILE_SHARED: 'file.shared',
80+
FILE_SHARE_DISABLED: 'file.share_disabled',
7981
FOLDER_CREATED: 'folder.created',
8082
FOLDER_UPDATED: 'folder.updated',
8183
FOLDER_DELETED: 'folder.deleted',

0 commit comments

Comments
 (0)