mirror of
https://github.com/different-ai/openwork
synced 2026-04-25 17:15:34 +02:00
feat(desktop): persist desktop bootstrap and org restrictions (#1479)
* feat(den-api): expose desktop config from env * feat(desktop): persist den bootstrap config across updates * feat(den): manage desktop restrictions per organization * fix(app): stabilize cloud org selection * docs(desktop): add bootstrap config PRD --------- Co-authored-by: src-opn <src-opn@users.noreply.github.com>
This commit is contained in:
31
packages/types/package.json
Normal file
31
packages/types/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@openwork/types",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"development": "./src/index.ts",
|
||||
"default": "./src/index.ts"
|
||||
},
|
||||
"./den/desktop-app-restrictions": {
|
||||
"types": "./src/den/desktop-app-restrictions.ts",
|
||||
"development": "./src/den/desktop-app-restrictions.ts",
|
||||
"default": "./src/den/desktop-app-restrictions.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
30
packages/types/src/den/desktop-app-restrictions.ts
Normal file
30
packages/types/src/den/desktop-app-restrictions.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const desktopAppRestrictionsSchema = z.object({
|
||||
disallowNonCloudModels: z.boolean().optional(),
|
||||
blockZenModel: z.boolean().optional(),
|
||||
blockMultipleWorkspaces: z.boolean().optional(),
|
||||
}).meta({ ref: "DenDesktopAppRestrictions" })
|
||||
|
||||
export type DesktopAppRestrictions = z.infer<typeof desktopAppRestrictionsSchema>
|
||||
|
||||
export function normalizeDesktopAppRestrictions(value: unknown): DesktopAppRestrictions {
|
||||
const parsed = desktopAppRestrictionsSchema.safeParse(value)
|
||||
if (parsed.success) {
|
||||
return {
|
||||
...(parsed.data.disallowNonCloudModels === true ? { disallowNonCloudModels: true } : {}),
|
||||
...(parsed.data.blockZenModel === true ? { blockZenModel: true } : {}),
|
||||
...(parsed.data.blockMultipleWorkspaces === true ? { blockMultipleWorkspaces: true } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
const legacy = value as {
|
||||
models?: {
|
||||
removeZen?: unknown
|
||||
}
|
||||
} | null
|
||||
|
||||
return {
|
||||
...(legacy?.models?.removeZen === true ? { blockZenModel: true } : {}),
|
||||
}
|
||||
}
|
||||
1
packages/types/src/index.ts
Normal file
1
packages/types/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./den/desktop-app-restrictions"
|
||||
17
packages/types/tsconfig.json
Normal file
17
packages/types/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
20
packages/types/tsup.config.ts
Normal file
20
packages/types/tsup.config.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from "tsup"
|
||||
|
||||
export default defineConfig({
|
||||
entry: {
|
||||
index: "src/index.ts",
|
||||
"den/desktop-app-restrictions": "src/den/desktop-app-restrictions.ts",
|
||||
},
|
||||
tsconfig: "./tsconfig.json",
|
||||
format: ["esm"],
|
||||
dts: {
|
||||
tsconfig: "./tsconfig.json",
|
||||
},
|
||||
clean: true,
|
||||
target: "es2022",
|
||||
platform: "neutral",
|
||||
sourcemap: false,
|
||||
splitting: false,
|
||||
treeshake: true,
|
||||
external: ["zod"],
|
||||
})
|
||||
Reference in New Issue
Block a user