raw app improvements
This commit is contained in:
@@ -35,6 +35,8 @@ function respecializeFields(fields: Record<string, any>) {
|
||||
if (typeof v == "object") {
|
||||
if (v.value !== undefined) {
|
||||
fields[k] = { value: v.value, type: "static" };
|
||||
} else if (v.ctx !== undefined) {
|
||||
fields[k] = { ctx: v.ctx, type: "ctx" };
|
||||
} else if (v.expr !== undefined) {
|
||||
fields[k] = {
|
||||
expr: v.expr,
|
||||
|
||||
@@ -28,7 +28,7 @@ import * as wmill from "../../../gen/services.gen.ts";
|
||||
import { resolveWorkspace } from "../../core/context.ts";
|
||||
import { requireLogin } from "../../core/auth.ts";
|
||||
import { GLOBAL_CONFIG_OPT } from "../../core/conf.ts";
|
||||
import { replaceInlineScripts } from "./app.ts";
|
||||
import { replaceInlineScripts, repopulateFields } from "./app.ts";
|
||||
import { Runnable } from "./metadata.ts";
|
||||
import {
|
||||
APP_BACKEND_FOLDER,
|
||||
@@ -1439,6 +1439,7 @@ async function loadRunnables(): Promise<Record<string, Runnable>> {
|
||||
convertRunnablesToApiFormat(runnables);
|
||||
|
||||
replaceInlineScripts(runnables, backendPath + SEP, true);
|
||||
repopulateFields(runnables);
|
||||
|
||||
return runnables;
|
||||
} catch (error: any) {
|
||||
@@ -1462,11 +1463,14 @@ async function executeRunnable(
|
||||
force_viewer_allow_user_resources: [],
|
||||
};
|
||||
|
||||
// Handle static fields
|
||||
// Handle fields (static, ctx, user)
|
||||
if (runnable.fields) {
|
||||
for (const [key, field] of Object.entries(runnable.fields)) {
|
||||
if (field?.type === "static") {
|
||||
requestBody.force_viewer_static_fields[key] = field.value;
|
||||
} else if (field?.type === "ctx" && field?.ctx) {
|
||||
// Convert ctx fields to $ctx:property format for backend resolution
|
||||
requestBody.args[key] = `$ctx:${field.ctx}`;
|
||||
}
|
||||
if (field?.type === "user" && field?.allowUserResources) {
|
||||
requestBody.force_viewer_allow_user_resources.push(key);
|
||||
|
||||
@@ -932,6 +932,29 @@ function ZipFSElement(
|
||||
};
|
||||
}
|
||||
|
||||
// Helper to simplify fields for YAML output
|
||||
// { type: 'static', value: X } -> { value: X }
|
||||
// { type: 'ctx', ctx: X } -> { ctx: X }
|
||||
function simplifyFields(fields: Record<string, any> | undefined) {
|
||||
if (!fields) return undefined;
|
||||
const simplified: Record<string, any> = {};
|
||||
for (const [k, v] of Object.entries(fields)) {
|
||||
if (typeof v === "object" && v !== null) {
|
||||
if (v.type === "static" && v.value !== undefined) {
|
||||
simplified[k] = { value: v.value };
|
||||
} else if (v.type === "ctx" && v.ctx !== undefined) {
|
||||
simplified[k] = { ctx: v.ctx };
|
||||
} else {
|
||||
// Keep other field types as-is
|
||||
simplified[k] = v;
|
||||
}
|
||||
} else {
|
||||
simplified[k] = v;
|
||||
}
|
||||
}
|
||||
return simplified;
|
||||
}
|
||||
|
||||
// Yield each runnable as a separate YAML file in the backend folder
|
||||
// For inline scripts, simplify the YAML - inlineScript is not needed since
|
||||
// content/lock/language can be derived from sibling files
|
||||
@@ -969,6 +992,11 @@ function ZipFSElement(
|
||||
simplifiedRunnable = runnableObj;
|
||||
}
|
||||
|
||||
// Simplify fields for cleaner YAML output
|
||||
if (simplifiedRunnable.fields) {
|
||||
simplifiedRunnable.fields = simplifyFields(simplifiedRunnable.fields);
|
||||
}
|
||||
|
||||
yield {
|
||||
isDirectory: false,
|
||||
path: path.join(
|
||||
|
||||
@@ -20,7 +20,7 @@ console.log('Running postinstall for root project');
|
||||
|
||||
import { x } from 'tar'
|
||||
|
||||
const tarUrl = 'https://pub-06154ed168a24e73a86ab84db6bf15d8.r2.dev/ui_builder-e2864ec.tar.gz'
|
||||
const tarUrl = 'https://pub-06154ed168a24e73a86ab84db6bf15d8.r2.dev/ui_builder-c37c2f6.tar.gz'
|
||||
const outputTarPath = path.join(process.cwd(), 'ui_builder.tar.gz')
|
||||
const extractTo = path.join(process.cwd(), 'static/ui_builder/')
|
||||
|
||||
|
||||
@@ -162,6 +162,9 @@
|
||||
sendUserToast(`App hasn't been loaded yet`, true)
|
||||
return
|
||||
}
|
||||
if (!policy.execution_mode) {
|
||||
policy.execution_mode = 'publisher'
|
||||
}
|
||||
await computeTriggerables()
|
||||
try {
|
||||
const { js, css } = await getBundle()
|
||||
@@ -266,6 +269,9 @@
|
||||
}
|
||||
const { js, css } = await getBundle()
|
||||
await computeTriggerables()
|
||||
if (!policy.execution_mode) {
|
||||
policy.execution_mode = 'publisher'
|
||||
}
|
||||
await AppService.updateAppRaw({
|
||||
workspace: $workspaceStore!,
|
||||
path: appPath!,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { base } from '$lib/base'
|
||||
import CenteredModal from '$lib/components/CenteredModal.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { userStore, workspaceStore } from '$lib/stores'
|
||||
|
||||
let port = Number($page.url.searchParams.get('port'))
|
||||
let host: string = $page.url.searchParams.get('host') || 'localhost'
|
||||
@@ -12,9 +12,11 @@
|
||||
port = port == 0 || Number.isNaN(port) ? 80 : port
|
||||
|
||||
async function authorizeToken(): Promise<void> {
|
||||
const username = $userStore?.username
|
||||
const label = username ? `cli-${username}` : 'cli'
|
||||
const newToken = await UserService.createToken({
|
||||
requestBody: {
|
||||
label: 'External tool token',
|
||||
label,
|
||||
expiration: undefined
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user