@adminide-stack/yantra-mobile 12.0.108 → 12.0.109
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/lib/compute.js +57 -1
- package/lib/compute.js.map +1 -1
- package/lib/config/env-config.js +8 -0
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/apps/AppsCatalog.js +10 -0
- package/lib/features/apps/AppsCatalog.js.map +1 -1
- package/lib/features/apps/appArt.js +2 -1
- package/lib/features/apps/appArt.js.map +1 -1
- package/lib/features/apps/mobileAppCatalog.js +11 -0
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/apps/nativeAppHandoff.js +2 -1
- package/lib/features/apps/nativeAppHandoff.js.map +1 -1
- package/lib/features/health/healthSyncStore.js +7 -1
- package/lib/features/health/healthSyncStore.js.map +1 -1
- package/lib/features/messaging/useChatViewer.js +3 -2
- package/lib/features/messaging/useChatViewer.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +474 -0
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -0
- package/lib/features/webbuilder/brandKitStorage.js +69 -0
- package/lib/features/webbuilder/brandKitStorage.js.map +1 -0
- package/lib/features/webbuilder/buildFragments.js +360 -0
- package/lib/features/webbuilder/buildFragments.js.map +1 -0
- package/lib/features/webbuilder/components/BottomTabs.js +65 -0
- package/lib/features/webbuilder/components/BottomTabs.js.map +1 -0
- package/lib/features/webbuilder/components/BrandKitSheet.js +197 -0
- package/lib/features/webbuilder/components/BrandKitSheet.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +99 -0
- package/lib/features/webbuilder/components/CodeView.js.map +1 -0
- package/lib/features/webbuilder/components/Composer.js +217 -0
- package/lib/features/webbuilder/components/Composer.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js +72 -0
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewPlaceholder.js +107 -0
- package/lib/features/webbuilder/components/PreviewPlaceholder.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewScreen.js +200 -0
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -0
- package/lib/features/webbuilder/components/ProjectChat.js +580 -0
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -0
- package/lib/features/webbuilder/components/ProjectsScreen.js +339 -0
- package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -0
- package/lib/features/webbuilder/components/PublishSheet.js +143 -0
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -0
- package/lib/features/webbuilder/components/SiteScoreSheet.js +73 -0
- package/lib/features/webbuilder/components/SiteScoreSheet.js.map +1 -0
- package/lib/features/webbuilder/components/StudioHome.js +367 -0
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -0
- package/lib/features/webbuilder/components/TemplateCard.js +73 -0
- package/lib/features/webbuilder/components/TemplateCard.js.map +1 -0
- package/lib/features/webbuilder/components/TemplatesSheet.js +178 -0
- package/lib/features/webbuilder/components/TemplatesSheet.js.map +1 -0
- package/lib/features/webbuilder/components/VersionsSheet.js +57 -0
- package/lib/features/webbuilder/components/VersionsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/ui.js +291 -0
- package/lib/features/webbuilder/components/ui.js.map +1 -0
- package/lib/features/webbuilder/nativeWebBuilderRegistry.js +15 -0
- package/lib/features/webbuilder/nativeWebBuilderRegistry.js.map +1 -0
- package/lib/features/webbuilder/studioCatalog.js +147 -0
- package/lib/features/webbuilder/studioCatalog.js.map +1 -0
- package/lib/features/webbuilder/webbuilderPrompts.js +42 -0
- package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -0
- package/lib/features/webbuilder/webbuilderTheme.js +63 -0
- package/lib/features/webbuilder/webbuilderTheme.js.map +1 -0
- package/lib/features/webbuilder/workflow.js +540 -0
- package/lib/features/webbuilder/workflow.js.map +1 -0
- package/lib/hooks/useChatApi.js +7 -2
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/hooks/useChatStream.js +1 -1
- package/lib/hooks/useChatStream.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/routes.json +106 -0
- package/lib/screens/WebBuilderNative/index.js +71 -0
- package/lib/screens/WebBuilderNative/index.js.map +1 -0
- package/lib/screens/WebBuilderNative/useCodeAssistantCatalog.js +45 -0
- package/lib/screens/WebBuilderNative/useCodeAssistantCatalog.js.map +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderGallery.js +125 -0
- package/lib/screens/WebBuilderNative/useWebBuilderGallery.js.map +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +408 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -0
- package/lib/screens/WebBuilderNative/webbuilderTransport.js +88 -0
- package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
const CODE_ASSISTANT_TEMPLATE_CONFIG_KEY = "marketplace.templates.codeAssistant";
|
|
33
|
+
const APP_SETTINGS_AIEDITOR_KEY = "appSettings.settings.aieditor";
|
|
34
|
+
const DEFAULT_STACK_TEMPLATE = "vite-react";
|
|
35
|
+
const DEFAULT_MODEL_ID = "yantra-router/medium";
|
|
36
|
+
const WEBBUILDER_CONNECTOR_ID = "yantra-webbuilder";
|
|
37
|
+
const WEBBUILDER_TRIGGER_WORKFLOW_ACTION = "WEBBUILDER_TRIGGER_WORKFLOW";
|
|
38
|
+
const WORKFLOW_DEFAULTS_ID = "codeassistant-workflow-defaults";
|
|
39
|
+
function str(v) {
|
|
40
|
+
if (typeof v === "string") return v.trim();
|
|
41
|
+
return v == null ? "" : String(v).trim();
|
|
42
|
+
}
|
|
43
|
+
function boolTrue(v) {
|
|
44
|
+
return v === true || v === "true" || v === 1 || v === "1";
|
|
45
|
+
}
|
|
46
|
+
function humanizeFormKey(formKey) {
|
|
47
|
+
return formKey.replace(/[-_]+/g, " ").trim().split(/\s+/).map((word) => word ? word[0].toUpperCase() + word.slice(1) : word).join(" ");
|
|
48
|
+
}
|
|
49
|
+
function isDisabled(info) {
|
|
50
|
+
if (info.enabled === false || info.enabled === "false") return true;
|
|
51
|
+
if (info.enable === false || info.enable === "false") return true;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const FALLBACK_TEMPLATES = [{
|
|
55
|
+
id: "assetwise",
|
|
56
|
+
title: "Assetwise",
|
|
57
|
+
description: "Yantra starter template",
|
|
58
|
+
templateName: "vite-react",
|
|
59
|
+
formTemplateId: "assetwise"
|
|
60
|
+
}, {
|
|
61
|
+
id: "arch-studio-v2-by-yantra",
|
|
62
|
+
title: "Arch Studio V2",
|
|
63
|
+
description: "Arch Studio v2 template by Yantra",
|
|
64
|
+
templateName: "vite-react",
|
|
65
|
+
formTemplateId: "arch-studio-v2-by-yantra"
|
|
66
|
+
}, {
|
|
67
|
+
id: "pinpost",
|
|
68
|
+
title: "Pinpost",
|
|
69
|
+
description: "Yantra starter template",
|
|
70
|
+
templateName: "vite-react",
|
|
71
|
+
formTemplateId: "pinpost"
|
|
72
|
+
}, {
|
|
73
|
+
id: "triage-by-yantra",
|
|
74
|
+
title: "Triage by Yantra",
|
|
75
|
+
description: "Yantra starter template",
|
|
76
|
+
templateName: "vite-react",
|
|
77
|
+
formTemplateId: "triage-by-yantra"
|
|
78
|
+
}];
|
|
79
|
+
function extractFlatMap(settings, preferCodeAssistant = false) {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
if (!settings || typeof settings !== "object") return {};
|
|
82
|
+
const root = settings;
|
|
83
|
+
const candidates = preferCodeAssistant ? [(_b = (_a = root.marketplace) == null ? void 0 : _a.templates) == null ? void 0 : _b.codeAssistant, (_c = root.templates) == null ? void 0 : _c.codeAssistant, root.codeAssistant, root.settings, root] : [root.settings, root];
|
|
84
|
+
const hit = candidates.find((c) => c && typeof c === "object" && !Array.isArray(c) && Object.keys(c).length > 0);
|
|
85
|
+
return hit != null ? hit : {};
|
|
86
|
+
}
|
|
87
|
+
function pickMetadata(info, templateTarget) {
|
|
88
|
+
return __spreadValues({
|
|
89
|
+
// The E2B API key is only for local preview/deploy; buildWorkflowPayloadFromTemplate never forwards it.
|
|
90
|
+
formExtensionE2BAPIKey: str(info.formExtensionE2BAPIKey) || void 0,
|
|
91
|
+
formExtensionE2BClaudeTemplateId: str(info.formExtensionE2BClaudeTemplateId) || void 0,
|
|
92
|
+
formExtensionE2BDomain: str(info.formExtensionE2BDomain) || void 0,
|
|
93
|
+
formExtensionE2BTemplateId: str(info.formExtensionE2BTemplateId) || void 0,
|
|
94
|
+
formExtensionE2BViteReactTemplateId: str(info.formExtensionE2BViteReactTemplateId) || void 0,
|
|
95
|
+
formExtensionE2BVueTemplateId: str(info.formExtensionE2BVueTemplateId) || void 0
|
|
96
|
+
}, {
|
|
97
|
+
templateTarget
|
|
98
|
+
} );
|
|
99
|
+
}
|
|
100
|
+
function findWorkflowModel(map) {
|
|
101
|
+
var _a;
|
|
102
|
+
const ranked = [];
|
|
103
|
+
const eligible = Object.entries(map).filter(([, info]) => info && typeof info === "object" && !isDisabled(info) && Boolean(str(info.formId)) && Boolean(str(info.formExtensionId)));
|
|
104
|
+
for (const [key, info] of eligible) {
|
|
105
|
+
const pt = str(info.projectType).toLowerCase();
|
|
106
|
+
const tn = str(info.templateName).toLowerCase();
|
|
107
|
+
const k = key.toLowerCase();
|
|
108
|
+
let rank = 2;
|
|
109
|
+
if (pt === "codeassistant") rank = 0;
|
|
110
|
+
else if (pt === "github-model" || tn === "github-model" || k.includes("github-model") || k.includes("aieditor-form-code-extractor")) {
|
|
111
|
+
rank = 1;
|
|
112
|
+
}
|
|
113
|
+
ranked.push({
|
|
114
|
+
key,
|
|
115
|
+
settings: info,
|
|
116
|
+
rank
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
ranked.sort((a, b) => a.rank - b.rank);
|
|
120
|
+
return (_a = ranked[0]) != null ? _a : null;
|
|
121
|
+
}
|
|
122
|
+
function resolveWorkflowModel(uiMap, appMap) {
|
|
123
|
+
var _a;
|
|
124
|
+
const found = findWorkflowModel(uiMap);
|
|
125
|
+
if (!found) return null;
|
|
126
|
+
const templateName = str(found.settings.templateName) || found.key;
|
|
127
|
+
const appExtras = (_a = appMap[found.key]) != null ? _a : appMap[templateName];
|
|
128
|
+
if (appExtras && typeof appExtras === "object") {
|
|
129
|
+
return __spreadValues(__spreadValues({}, appExtras), found.settings);
|
|
130
|
+
}
|
|
131
|
+
return found.settings;
|
|
132
|
+
}
|
|
133
|
+
const NON_STACK_MARKERS = /* @__PURE__ */ new Set(["github-model", "codeassistant", "multi", "aieditor-code-extractor", "aieditor-form-code-extractor"]);
|
|
134
|
+
function matchStackMarker(raw) {
|
|
135
|
+
const v = raw.toLowerCase().trim();
|
|
136
|
+
if (!v || NON_STACK_MARKERS.has(v)) return null;
|
|
137
|
+
if (v === "nextjs" || v === "next" || v === "nextjs-base" || v.includes("nextjs-base") || v.startsWith("nextjs-") || v.startsWith("next-js")) {
|
|
138
|
+
return "nextjs";
|
|
139
|
+
}
|
|
140
|
+
if (v === "vue" || v.startsWith("vue-") || v.includes("vue-")) return "vue";
|
|
141
|
+
if (v === "vite-react" || v === "vitereact" || v === "react-base" || v === "vite-base" || v === "remix" || v === "vite" || v.startsWith("vite") || v.includes("react-base") || v.includes("react-visual-base") || v === "react") {
|
|
142
|
+
return "vite-react";
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
function normalizeStackTemplate(markers) {
|
|
147
|
+
for (const m of markers) {
|
|
148
|
+
const hit = matchStackMarker(m);
|
|
149
|
+
if (hit) return hit;
|
|
150
|
+
}
|
|
151
|
+
return DEFAULT_STACK_TEMPLATE;
|
|
152
|
+
}
|
|
153
|
+
function pushMarker(out, value) {
|
|
154
|
+
const v = str(value).toLowerCase();
|
|
155
|
+
if (!v || NON_STACK_MARKERS.has(v)) return;
|
|
156
|
+
out.push(v);
|
|
157
|
+
}
|
|
158
|
+
function collectKeywordMarkers(source) {
|
|
159
|
+
const out = [];
|
|
160
|
+
for (const listKey of ["keywords", "tags"]) {
|
|
161
|
+
const raw = source[listKey];
|
|
162
|
+
if (Array.isArray(raw)) {
|
|
163
|
+
for (const item of raw) pushMarker(out, item);
|
|
164
|
+
} else if (raw && typeof raw === "object") {
|
|
165
|
+
for (const item of Object.values(raw)) pushMarker(out, item);
|
|
166
|
+
} else if (typeof raw === "string") {
|
|
167
|
+
for (const part of raw.split(",")) pushMarker(out, part);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
function resolveCardStack(form, parent, formKey, templateKey) {
|
|
173
|
+
const formOwned = [formKey];
|
|
174
|
+
for (const key of ["templateName", "projectType", "modelTemplate"]) {
|
|
175
|
+
pushMarker(formOwned, form[key]);
|
|
176
|
+
}
|
|
177
|
+
formOwned.push(...collectKeywordMarkers(form));
|
|
178
|
+
for (const m of formOwned) {
|
|
179
|
+
const hit = matchStackMarker(m);
|
|
180
|
+
if (hit) return hit;
|
|
181
|
+
}
|
|
182
|
+
const projectType = (str(form.projectType) || str(parent.projectType)).toLowerCase();
|
|
183
|
+
if (projectType === "multi") {
|
|
184
|
+
return DEFAULT_STACK_TEMPLATE;
|
|
185
|
+
}
|
|
186
|
+
const rest = [];
|
|
187
|
+
if (templateKey) pushMarker(rest, templateKey);
|
|
188
|
+
for (const key of ["templateName", "projectType", "modelTemplate"]) {
|
|
189
|
+
pushMarker(rest, parent[key]);
|
|
190
|
+
}
|
|
191
|
+
rest.push(...collectKeywordMarkers(parent));
|
|
192
|
+
return normalizeStackTemplate(rest);
|
|
193
|
+
}
|
|
194
|
+
const TEMPLATE_TARGET = "github-model";
|
|
195
|
+
function formHasOwnPreviewableUrl(form) {
|
|
196
|
+
return Boolean(str(form.previewUrl) || str(form.deployUrl) || str(form.figmaUrl));
|
|
197
|
+
}
|
|
198
|
+
const BASE_PROJECT_TYPES = /* @__PURE__ */ new Set(["react-base", "nextjs-base"]);
|
|
199
|
+
function isBaseTemplateForm(form, formKey, group) {
|
|
200
|
+
const formPt = str(form.projectType).toLowerCase();
|
|
201
|
+
if (BASE_PROJECT_TYPES.has(formPt)) return true;
|
|
202
|
+
const key = formKey.toLowerCase();
|
|
203
|
+
const title = str(form.title).toLowerCase();
|
|
204
|
+
if (key.includes("nextjs-base") || key.includes("react-visual-base") || key.includes("react-base")) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (title.includes("visual base") || title.includes("base visual") || /\b(react|next\s*js?)\b.*\bbase\b/.test(title) || /\bbase\b.*\b(react|next\s*js?)\b/.test(title)) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
const groupPt = str(group.projectType).toLowerCase();
|
|
211
|
+
if (BASE_PROJECT_TYPES.has(groupPt) && (key.includes("base") || title.includes("base"))) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
const BASE_TEMPLATE_DEFAULT_COVER = `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="400" height="225" viewBox="0 0 400 225"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#e2e8f0"/><stop offset="100%" stop-color="#f1f5f9"/></linearGradient></defs><rect width="400" height="225" fill="url(#g)"/><rect x="48" y="48" width="304" height="129" rx="12" fill="#fff" stroke="#cbd5e1" stroke-width="2"/><rect x="72" y="72" width="120" height="10" rx="5" fill="#94a3b8"/><rect x="72" y="96" width="200" height="8" rx="4" fill="#cbd5e1"/><rect x="72" y="116" width="160" height="8" rx="4" fill="#cbd5e1"/><rect x="72" y="144" width="72" height="20" rx="6" fill="#64748b"/></svg>`)}`;
|
|
217
|
+
function cardRichnessScore(card) {
|
|
218
|
+
return (card.hasOwnTitle ? 2 : 0) + (card.description ? 1 : 0) + (card.cover ? 1 : 0);
|
|
219
|
+
}
|
|
220
|
+
function previewUrlDedupeKey(card) {
|
|
221
|
+
var _a, _b;
|
|
222
|
+
const urlKey = `${(_a = card.deployUrl) != null ? _a : ""}|${(_b = card.previewUrl) != null ? _b : ""}|`;
|
|
223
|
+
if (urlKey === "||") return `id:${card.id}`;
|
|
224
|
+
return urlKey;
|
|
225
|
+
}
|
|
226
|
+
function mapYantraFormCards(uiMap, workflowModel) {
|
|
227
|
+
const workflowFormId = workflowModel ? str(workflowModel.formId) : "";
|
|
228
|
+
const workflowExtId = workflowModel ? str(workflowModel.formExtensionId) : "";
|
|
229
|
+
const workflowFnId = workflowModel ? str(workflowModel.formFunctionId) : "";
|
|
230
|
+
const workflowDomain = workflowModel ? str(workflowModel.formExtensionE2BDomain) : "";
|
|
231
|
+
const workflowApiKey = workflowModel ? str(workflowModel.formExtensionModelConfigAPIKey) || str(workflowModel.apiKey) : "";
|
|
232
|
+
const raw = [];
|
|
233
|
+
const groups = Object.entries(uiMap).filter(([, group]) => group && typeof group === "object" && !isDisabled(group) && str(group.projectType).toLowerCase() !== "codeassistant" && group.forms && typeof group.forms === "object");
|
|
234
|
+
for (const [templateKey, group] of groups) {
|
|
235
|
+
const forms = Object.entries(group.forms).filter((entry) => Boolean(entry[1]) && typeof entry[1] === "object" && !isDisabled(entry[1]));
|
|
236
|
+
for (const [formKey, form] of forms) {
|
|
237
|
+
const isBaseTemplate = isBaseTemplateForm(form, formKey, group);
|
|
238
|
+
if (formHasOwnPreviewableUrl(form) || isBaseTemplate) {
|
|
239
|
+
const ownTitle = str(form.title);
|
|
240
|
+
const title = ownTitle || humanizeFormKey(formKey) || "Untitled";
|
|
241
|
+
const formTemplateId = str(form.formTemplateId);
|
|
242
|
+
const id = formTemplateId || formKey;
|
|
243
|
+
const previewUrl = str(form.previewUrl) || str(group.previewUrl) || void 0;
|
|
244
|
+
const deployUrl = str(form.deployUrl) || str(group.deployUrl) || void 0;
|
|
245
|
+
const cover = str(form.coverImageUrl) || str(form.previewImageUrl) || str(group.coverImageUrl) || (isBaseTemplate && !deployUrl ? BASE_TEMPLATE_DEFAULT_COVER : void 0);
|
|
246
|
+
const snapshotId = str(form.snapshotId) || str(form.sourceSnapshotId) || str(group.snapshotId) || void 0;
|
|
247
|
+
const usesSupabase = boolTrue(form.usesSupabase) || boolTrue(group.usesSupabase);
|
|
248
|
+
const stack = resolveCardStack(form, group, formKey, templateKey);
|
|
249
|
+
const metadata = pickMetadata(workflowModel || {}, TEMPLATE_TARGET);
|
|
250
|
+
raw.push({
|
|
251
|
+
id,
|
|
252
|
+
title,
|
|
253
|
+
description: str(form.description) || "Yantra starter template",
|
|
254
|
+
cover,
|
|
255
|
+
category: str(form.category) || void 0,
|
|
256
|
+
templateName: stack,
|
|
257
|
+
formTemplateId: formTemplateId || void 0,
|
|
258
|
+
formExtensionId: workflowExtId || str(group.formExtensionId) || void 0,
|
|
259
|
+
formId: workflowFormId || str(group.formId) || void 0,
|
|
260
|
+
formFunctionId: workflowFnId || str(group.formFunctionId) || void 0,
|
|
261
|
+
domain: workflowDomain || void 0,
|
|
262
|
+
apiKey: workflowApiKey || void 0,
|
|
263
|
+
metadata,
|
|
264
|
+
chatPrompt: str(form.chatPrompt) || void 0,
|
|
265
|
+
previewUrl,
|
|
266
|
+
deployUrl,
|
|
267
|
+
snapshotId,
|
|
268
|
+
usesSupabase,
|
|
269
|
+
skill: str(form.skill) || str(group.skill) || void 0,
|
|
270
|
+
hasOwnTitle: Boolean(ownTitle)
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const bestByUrl = /* @__PURE__ */ new Map();
|
|
276
|
+
for (const card of raw) {
|
|
277
|
+
const key = previewUrlDedupeKey(card);
|
|
278
|
+
const existing = bestByUrl.get(key);
|
|
279
|
+
if (!existing || cardRichnessScore(card) > cardRichnessScore(existing)) {
|
|
280
|
+
bestByUrl.set(key, card);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return [...bestByUrl.values()].map((_a) => {
|
|
284
|
+
var _b = _a, {
|
|
285
|
+
hasOwnTitle: _h
|
|
286
|
+
} = _b, card = __objRest(_b, [
|
|
287
|
+
"hasOwnTitle"
|
|
288
|
+
]);
|
|
289
|
+
return card;
|
|
290
|
+
}).sort((a, b) => a.title.localeCompare(b.title));
|
|
291
|
+
}
|
|
292
|
+
function templatesFromSettings(uiLayoutSettings, appSettings) {
|
|
293
|
+
const uiMap = extractFlatMap(uiLayoutSettings, true);
|
|
294
|
+
const appMap = extractFlatMap(appSettings, false);
|
|
295
|
+
return mapYantraFormCards(uiMap, resolveWorkflowModel(uiMap, appMap));
|
|
296
|
+
}
|
|
297
|
+
function workflowDefaultsFromSettings(uiLayoutSettings, appSettings, stack = DEFAULT_STACK_TEMPLATE) {
|
|
298
|
+
const uiMap = extractFlatMap(uiLayoutSettings, true);
|
|
299
|
+
const appMap = extractFlatMap(appSettings, false);
|
|
300
|
+
const workflowModel = resolveWorkflowModel(uiMap, appMap);
|
|
301
|
+
const normalized = normalizeStackTemplate([stack]);
|
|
302
|
+
if (workflowModel) {
|
|
303
|
+
const formExtensionId = str(workflowModel.formExtensionId) || void 0;
|
|
304
|
+
if (formExtensionId) {
|
|
305
|
+
return {
|
|
306
|
+
id: WORKFLOW_DEFAULTS_ID,
|
|
307
|
+
title: "Code Assistant",
|
|
308
|
+
templateName: normalized,
|
|
309
|
+
formExtensionId,
|
|
310
|
+
formId: str(workflowModel.formId) || void 0,
|
|
311
|
+
formFunctionId: str(workflowModel.formFunctionId) || void 0,
|
|
312
|
+
domain: str(workflowModel.formExtensionE2BDomain) || void 0,
|
|
313
|
+
apiKey: str(workflowModel.formExtensionModelConfigAPIKey) || str(workflowModel.apiKey) || void 0,
|
|
314
|
+
metadata: pickMetadata(workflowModel, TEMPLATE_TARGET)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const card = mapYantraFormCards(uiMap, workflowModel).find((c) => c.formExtensionId);
|
|
319
|
+
if (!(card == null ? void 0 : card.formExtensionId)) return null;
|
|
320
|
+
return __spreadProps(__spreadValues({}, card), {
|
|
321
|
+
id: WORKFLOW_DEFAULTS_ID,
|
|
322
|
+
title: "Code Assistant",
|
|
323
|
+
templateName: normalized || card.templateName
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function buildWorkflowPayloadFromTemplate(template, extras) {
|
|
327
|
+
const rawName = (template == null ? void 0 : template.templateName) || (extras == null ? void 0 : extras.defaultTemplate) || DEFAULT_STACK_TEMPLATE;
|
|
328
|
+
const templateName = normalizeStackTemplate([rawName]) || DEFAULT_STACK_TEMPLATE;
|
|
329
|
+
const m = (template == null ? void 0 : template.metadata) || {};
|
|
330
|
+
const templateTarget = TEMPLATE_TARGET;
|
|
331
|
+
const metadata = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, m.formExtensionE2BClaudeTemplateId ? {
|
|
332
|
+
formExtensionE2BClaudeTemplateId: m.formExtensionE2BClaudeTemplateId
|
|
333
|
+
} : {}), m.formExtensionE2BDomain ? {
|
|
334
|
+
formExtensionE2BDomain: m.formExtensionE2BDomain
|
|
335
|
+
} : {}), m.formExtensionE2BTemplateId ? {
|
|
336
|
+
formExtensionE2BTemplateId: m.formExtensionE2BTemplateId
|
|
337
|
+
} : {}), m.formExtensionE2BViteReactTemplateId ? {
|
|
338
|
+
formExtensionE2BViteReactTemplateId: m.formExtensionE2BViteReactTemplateId
|
|
339
|
+
} : {}), m.formExtensionE2BVueTemplateId ? {
|
|
340
|
+
formExtensionE2BVueTemplateId: m.formExtensionE2BVueTemplateId
|
|
341
|
+
} : {}), {
|
|
342
|
+
templateTarget
|
|
343
|
+
});
|
|
344
|
+
const skill = (extras == null ? void 0 : extras.skill) || (template == null ? void 0 : template.skill);
|
|
345
|
+
if (skill) metadata.skill = skill;
|
|
346
|
+
if (extras == null ? void 0 : extras.skillActionId) metadata.skillActionId = extras.skillActionId;
|
|
347
|
+
if (template == null ? void 0 : template.formTemplateId) metadata.formTemplateId = template.formTemplateId;
|
|
348
|
+
const modelConfig = __spreadProps(__spreadValues({
|
|
349
|
+
template: templateName,
|
|
350
|
+
templateTarget,
|
|
351
|
+
domain: (template == null ? void 0 : template.domain) || "e2b.dev"
|
|
352
|
+
}, (template == null ? void 0 : template.apiKey) ? {
|
|
353
|
+
apiKey: template.apiKey
|
|
354
|
+
} : {}), {
|
|
355
|
+
metadata
|
|
356
|
+
});
|
|
357
|
+
if (extras == null ? void 0 : extras.modelId) {
|
|
358
|
+
modelConfig.model = extras.modelId;
|
|
359
|
+
const slash = extras.modelId.indexOf("/");
|
|
360
|
+
if (slash > 0) modelConfig.provider = extras.modelId.slice(0, slash);
|
|
361
|
+
}
|
|
362
|
+
if (extras == null ? void 0 : extras.systemId) {
|
|
363
|
+
modelConfig.system = extras.systemId;
|
|
364
|
+
modelConfig.designSystem = extras.systemId;
|
|
365
|
+
modelConfig.systemId = extras.systemId;
|
|
366
|
+
}
|
|
367
|
+
if (skill) {
|
|
368
|
+
modelConfig.skill = skill;
|
|
369
|
+
modelConfig.skillId = skill;
|
|
370
|
+
}
|
|
371
|
+
if (extras == null ? void 0 : extras.skillActionId) modelConfig.skillActionId = extras.skillActionId;
|
|
372
|
+
if (extras == null ? void 0 : extras.editProjectId) modelConfig.editProjectId = extras.editProjectId;
|
|
373
|
+
const extensionInput = __spreadProps(__spreadValues({}, (template == null ? void 0 : template.formExtensionId) ? {
|
|
374
|
+
extensionId: template.formExtensionId
|
|
375
|
+
} : {}), {
|
|
376
|
+
stepName: "extractCodeFromExtension",
|
|
377
|
+
formId: (template == null ? void 0 : template.formId) || "form-builder-proxy",
|
|
378
|
+
functionId: (template == null ? void 0 : template.formFunctionId) || "create-channel-function",
|
|
379
|
+
metadata,
|
|
380
|
+
source: "final-submission"
|
|
381
|
+
});
|
|
382
|
+
return {
|
|
383
|
+
modelConfig,
|
|
384
|
+
extensionInput,
|
|
385
|
+
templateName
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function newObjectId() {
|
|
389
|
+
const ts = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0");
|
|
390
|
+
let rand = "";
|
|
391
|
+
for (let i = 0; i < 16; i++) rand += Math.floor(Math.random() * 16).toString(16);
|
|
392
|
+
return ts + rand;
|
|
393
|
+
}
|
|
394
|
+
function decodeBase64(b64) {
|
|
395
|
+
if (typeof atob === "function") return atob(b64);
|
|
396
|
+
const {
|
|
397
|
+
Buffer: Buffer2
|
|
398
|
+
} = require("buffer");
|
|
399
|
+
return Buffer2.from(b64, "base64").toString("binary");
|
|
400
|
+
}
|
|
401
|
+
function tenantIdFromToken(token) {
|
|
402
|
+
if (!token) return void 0;
|
|
403
|
+
try {
|
|
404
|
+
const seg = (token.split(".")[1] || "").replace(/-/g, "+").replace(/_/g, "/");
|
|
405
|
+
const padded = seg + "=".repeat((4 - seg.length % 4) % 4);
|
|
406
|
+
const payload = JSON.parse(decodeBase64(padded));
|
|
407
|
+
return payload.tenant || payload.tid;
|
|
408
|
+
} catch (e) {
|
|
409
|
+
return void 0;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
const NON_PICK_TEMPLATE_IDS = /* @__PURE__ */ new Set([WORKFLOW_DEFAULTS_ID, "bundled", "vite-react", "nextjs", "vue", ""]);
|
|
413
|
+
function explicitTemplateId(template) {
|
|
414
|
+
var _a;
|
|
415
|
+
const id = String((_a = template == null ? void 0 : template.id) != null ? _a : "").trim();
|
|
416
|
+
if (NON_PICK_TEMPLATE_IDS.has(id)) return void 0;
|
|
417
|
+
return id;
|
|
418
|
+
}
|
|
419
|
+
const LOCAL_HOST_RE = /^https?:\/\/(localhost|127\.0\.0\.1)([:/]|$)/i;
|
|
420
|
+
function sandboxIdFromUrl(url) {
|
|
421
|
+
var _a;
|
|
422
|
+
return ((_a = url == null ? void 0 : url.match(/^https?:\/\/3000-([^.]+)\./)) == null ? void 0 : _a[1]) || null;
|
|
423
|
+
}
|
|
424
|
+
function buildTriggerParams(opts) {
|
|
425
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
426
|
+
const {
|
|
427
|
+
channelId,
|
|
428
|
+
projectId,
|
|
429
|
+
defaults
|
|
430
|
+
} = opts;
|
|
431
|
+
const pickedTemplate = opts.mode === "edit" ? void 0 : opts.template;
|
|
432
|
+
const isNewFromTemplate = Boolean(pickedTemplate);
|
|
433
|
+
const isEditTurn = !isNewFromTemplate && opts.mode === "edit" && Boolean(((_a = opts.edit) == null ? void 0 : _a.sandboxId) || ((_b = opts.edit) == null ? void 0 : _b.sandboxUrl));
|
|
434
|
+
const stackHint = (pickedTemplate == null ? void 0 : pickedTemplate.templateName) || (isEditTurn ? opts.stackHint : void 0) || DEFAULT_STACK_TEMPLATE;
|
|
435
|
+
let templateForPayload;
|
|
436
|
+
if (pickedTemplate) {
|
|
437
|
+
templateForPayload = __spreadProps(__spreadValues({}, pickedTemplate), {
|
|
438
|
+
formExtensionId: pickedTemplate.formExtensionId || (defaults == null ? void 0 : defaults.formExtensionId),
|
|
439
|
+
formId: pickedTemplate.formId || (defaults == null ? void 0 : defaults.formId),
|
|
440
|
+
formFunctionId: pickedTemplate.formFunctionId || (defaults == null ? void 0 : defaults.formFunctionId),
|
|
441
|
+
domain: pickedTemplate.domain || (defaults == null ? void 0 : defaults.domain),
|
|
442
|
+
apiKey: pickedTemplate.apiKey || (defaults == null ? void 0 : defaults.apiKey),
|
|
443
|
+
metadata: __spreadValues(__spreadValues({}, (defaults == null ? void 0 : defaults.metadata) || {}), pickedTemplate.metadata || {}),
|
|
444
|
+
// The card's stack wins; never inherit the workflow model's (often nextjs).
|
|
445
|
+
templateName: pickedTemplate.templateName || stackHint
|
|
446
|
+
});
|
|
447
|
+
} else if (defaults) {
|
|
448
|
+
templateForPayload = __spreadProps(__spreadValues({}, defaults), {
|
|
449
|
+
templateName: stackHint
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
const resolvedModelId = opts.modelId || DEFAULT_MODEL_ID;
|
|
453
|
+
const {
|
|
454
|
+
modelConfig,
|
|
455
|
+
extensionInput,
|
|
456
|
+
templateName
|
|
457
|
+
} = buildWorkflowPayloadFromTemplate(templateForPayload, {
|
|
458
|
+
modelId: resolvedModelId,
|
|
459
|
+
defaultTemplate: stackHint
|
|
460
|
+
});
|
|
461
|
+
if (!extensionInput.extensionId) return {
|
|
462
|
+
ok: false,
|
|
463
|
+
reason: "not-configured"
|
|
464
|
+
};
|
|
465
|
+
const templateSnapshotId = ((_c = pickedTemplate == null ? void 0 : pickedTemplate.snapshotId) == null ? void 0 : _c.trim()) || "";
|
|
466
|
+
const sandboxId = isEditTurn ? ((_d = opts.edit) == null ? void 0 : _d.sandboxId) || sandboxIdFromUrl((_e = opts.edit) == null ? void 0 : _e.sandboxUrl) || null : null;
|
|
467
|
+
const sandboxUrl = isEditTurn ? (((_g = (_f = opts.edit) == null ? void 0 : _f.sandboxUrl) == null ? void 0 : _g.trim()) || "").split("?")[0] || null : null;
|
|
468
|
+
const remixFragment = {};
|
|
469
|
+
if (pickedTemplate == null ? void 0 : pickedTemplate.deployUrl) remixFragment.deployUrl = pickedTemplate.deployUrl;
|
|
470
|
+
if (isNewFromTemplate && templateSnapshotId) {
|
|
471
|
+
remixFragment.remix = true;
|
|
472
|
+
remixFragment.mode = "remix";
|
|
473
|
+
remixFragment.snapshotId = templateSnapshotId;
|
|
474
|
+
remixFragment.usesSupabase = (pickedTemplate == null ? void 0 : pickedTemplate.usesSupabase) === true;
|
|
475
|
+
} else if (isEditTurn && (sandboxId || sandboxUrl)) {
|
|
476
|
+
remixFragment.remix = true;
|
|
477
|
+
remixFragment.mode = "edit";
|
|
478
|
+
if (sandboxId) remixFragment.sandboxId = sandboxId;
|
|
479
|
+
if (sandboxUrl) remixFragment.sandboxUrl = sandboxUrl;
|
|
480
|
+
if ((_h = opts.edit) == null ? void 0 : _h.title) remixFragment.title = opts.edit.title;
|
|
481
|
+
remixFragment.projectId = projectId;
|
|
482
|
+
}
|
|
483
|
+
const pickedTemplateId = explicitTemplateId(pickedTemplate);
|
|
484
|
+
const referenceUrl = (_i = opts.referenceUrl) == null ? void 0 : _i.trim();
|
|
485
|
+
const attachments = (_k = (_j = opts.attachments) == null ? void 0 : _j.filter((a) => a && a.url)) != null ? _k : [];
|
|
486
|
+
const createChannelInput = {
|
|
487
|
+
channelId,
|
|
488
|
+
title: "AI Assistant",
|
|
489
|
+
description: "AI Assistant",
|
|
490
|
+
displayName: "AI Assistant",
|
|
491
|
+
topic: "AI Assistant",
|
|
492
|
+
projectId,
|
|
493
|
+
type: "AIASSISTANT",
|
|
494
|
+
postData: {
|
|
495
|
+
type: "AIASSISTANT",
|
|
496
|
+
content: opts.text,
|
|
497
|
+
props: __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues({
|
|
498
|
+
template: templateName,
|
|
499
|
+
templateTarget: TEMPLATE_TARGET,
|
|
500
|
+
projectId,
|
|
501
|
+
role: "USER",
|
|
502
|
+
fragment: remixFragment
|
|
503
|
+
}, sandboxId ? {
|
|
504
|
+
sandboxId
|
|
505
|
+
} : {}), sandboxUrl ? {
|
|
506
|
+
sandboxUrl
|
|
507
|
+
} : {}), {
|
|
508
|
+
model: resolvedModelId
|
|
509
|
+
}), attachments.length ? {
|
|
510
|
+
attachments
|
|
511
|
+
} : {}), pickedTemplateId ? {
|
|
512
|
+
templateId: pickedTemplateId
|
|
513
|
+
} : {}), referenceUrl ? {
|
|
514
|
+
referenceUrl
|
|
515
|
+
} : {})
|
|
516
|
+
},
|
|
517
|
+
additionalProperties: {
|
|
518
|
+
modelConfig
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
const authParams = opts.graphqlUrl && (opts.agentLocal || !LOCAL_HOST_RE.test(opts.graphqlUrl)) ? {
|
|
522
|
+
graphqlUrl: opts.graphqlUrl,
|
|
523
|
+
accessToken: opts.token,
|
|
524
|
+
tenantId: tenantIdFromToken(opts.token)
|
|
525
|
+
} : {};
|
|
526
|
+
return {
|
|
527
|
+
ok: true,
|
|
528
|
+
params: __spreadValues({
|
|
529
|
+
createChannelInput,
|
|
530
|
+
extensionInput
|
|
531
|
+
}, authParams)
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function templateRemixNote(template) {
|
|
535
|
+
var _a;
|
|
536
|
+
const snapshot = (_a = template.snapshotId) == null ? void 0 : _a.trim();
|
|
537
|
+
const boot = snapshot ? `Boot it with WEBBUILDER_CREATE_SANDBOX {"snapshotId":"${snapshot}","builder":"vite","timeoutMs":3600000,"private":true}.` : `Find it with WEBBUILDER_LIST_TEMPLATES and boot it with that card's start.params.`;
|
|
538
|
+
return [`[Template] The user picked the Yantra template "${template.title}" to start from - remix it (Remix a template).`, boot, "They already chose this template: do not ask how to start. Ask only what you still need, then build and give the live preview link."].join(" ");
|
|
539
|
+
}
|
|
540
|
+
const WEBBUILDER_CHAT_SKILL = "yantra-skills/webbuilder-design-pro";export{APP_SETTINGS_AIEDITOR_KEY,CODE_ASSISTANT_TEMPLATE_CONFIG_KEY,DEFAULT_MODEL_ID,DEFAULT_STACK_TEMPLATE,FALLBACK_TEMPLATES,WEBBUILDER_CHAT_SKILL,WEBBUILDER_CONNECTOR_ID,WEBBUILDER_TRIGGER_WORKFLOW_ACTION,buildTriggerParams,buildWorkflowPayloadFromTemplate,newObjectId,normalizeStackTemplate,templateRemixNote,templatesFromSettings,tenantIdFromToken,workflowDefaultsFromSettings};//# sourceMappingURL=workflow.js.map
|