windmill-components 1.665.0 → 1.677.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.
Files changed (254) hide show
  1. package/dist/sharedUtils/assets/tokens/colorTokensConfig.d.ts +2 -0
  2. package/dist/sharedUtils/base.d.ts +1 -0
  3. package/dist/sharedUtils/cloud.d.ts +1 -0
  4. package/dist/sharedUtils/common.d.ts +111 -0
  5. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/count.d.ts +5 -0
  6. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/delete.d.ts +5 -0
  7. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/insert.d.ts +5 -0
  8. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/select.d.ts +13 -0
  9. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/update.d.ts +11 -0
  10. package/dist/sharedUtils/components/apps/components/display/dbtable/utils.d.ts +95 -0
  11. package/dist/sharedUtils/components/apps/editor/appPolicy.d.ts +6 -0
  12. package/dist/sharedUtils/components/apps/editor/appUtilsCore.d.ts +7 -0
  13. package/dist/sharedUtils/components/apps/editor/appUtilsS3.d.ts +33 -0
  14. package/dist/sharedUtils/components/apps/editor/commonAppUtils.d.ts +10 -0
  15. package/dist/sharedUtils/components/apps/editor/component/components.d.ts +5371 -0
  16. package/dist/sharedUtils/components/apps/editor/component/default-codes.d.ts +3 -0
  17. package/dist/sharedUtils/components/apps/editor/component/index.d.ts +3 -0
  18. package/dist/sharedUtils/components/apps/editor/component/sets.d.ts +7 -0
  19. package/dist/sharedUtils/components/apps/editor/componentsPanel/componentDefaultProps.d.ts +3 -0
  20. package/dist/sharedUtils/components/apps/gridUtils.d.ts +14 -0
  21. package/dist/sharedUtils/components/apps/inputType.d.ts +178 -0
  22. package/dist/sharedUtils/components/apps/rx.d.ts +29 -0
  23. package/dist/sharedUtils/components/apps/sharedTypes.d.ts +21 -0
  24. package/dist/sharedUtils/components/apps/types.d.ts +274 -0
  25. package/dist/sharedUtils/components/assets/lib.d.ts +25 -0
  26. package/dist/sharedUtils/components/common/alert/model.d.ts +2 -0
  27. package/dist/sharedUtils/components/common/badge/model.d.ts +8 -0
  28. package/dist/sharedUtils/components/common/button/model.d.ts +45 -0
  29. package/dist/sharedUtils/components/common/fileInput/model.d.ts +1 -0
  30. package/dist/sharedUtils/components/common/index.d.ts +24 -0
  31. package/dist/sharedUtils/components/common/skeleton/model.d.ts +21 -0
  32. package/dist/sharedUtils/components/dbTypes.d.ts +14 -0
  33. package/dist/sharedUtils/components/diff_drawer.d.ts +26 -0
  34. package/dist/sharedUtils/components/ducklake.d.ts +1 -0
  35. package/dist/sharedUtils/components/flows/scheduleUtils.d.ts +7 -0
  36. package/dist/sharedUtils/components/icons/index.d.ts +101 -0
  37. package/dist/sharedUtils/components/random_positive_adjetive.d.ts +1 -0
  38. package/dist/sharedUtils/components/raw_apps/rawAppPolicy.d.ts +10 -0
  39. package/dist/sharedUtils/components/raw_apps/utils.d.ts +15 -0
  40. package/dist/sharedUtils/components/triggers/email/utils.d.ts +4 -0
  41. package/dist/sharedUtils/components/triggers/gcp/utils.d.ts +2 -0
  42. package/dist/sharedUtils/components/triggers/http/utils.d.ts +11 -0
  43. package/dist/sharedUtils/components/triggers/kafka/utils.d.ts +2 -0
  44. package/dist/sharedUtils/components/triggers/mqtt/utils.d.ts +2 -0
  45. package/dist/sharedUtils/components/triggers/nats/utils.d.ts +2 -0
  46. package/dist/sharedUtils/components/triggers/postgres/utils.d.ts +8 -0
  47. package/dist/sharedUtils/components/triggers/sqs/utils.d.ts +2 -0
  48. package/dist/sharedUtils/components/triggers/triggers.svelte.d.ts +32 -0
  49. package/dist/sharedUtils/components/triggers/utils.d.ts +80 -0
  50. package/dist/sharedUtils/components/triggers/websocket/utils.d.ts +2 -0
  51. package/dist/sharedUtils/components/triggers.d.ts +20 -0
  52. package/dist/sharedUtils/gen/core/ApiError.d.ts +10 -0
  53. package/dist/sharedUtils/gen/core/ApiRequestOptions.d.ts +13 -0
  54. package/dist/sharedUtils/gen/core/ApiResult.d.ts +7 -0
  55. package/dist/sharedUtils/gen/core/CancelablePromise.d.ts +26 -0
  56. package/dist/sharedUtils/gen/core/OpenAPI.d.ts +27 -0
  57. package/dist/sharedUtils/gen/core/request.d.ts +29 -0
  58. package/dist/sharedUtils/gen/index.d.ts +6 -0
  59. package/dist/sharedUtils/gen/schemas.gen.d.ts +7036 -0
  60. package/dist/sharedUtils/gen/services.gen.d.ts +6047 -0
  61. package/dist/sharedUtils/gen/types.gen.d.ts +21881 -0
  62. package/dist/sharedUtils/history.svelte.d.ts +9 -0
  63. package/dist/sharedUtils/hub.d.ts +49 -0
  64. package/dist/sharedUtils/jsr.json +6 -0
  65. package/dist/sharedUtils/lib.d.ts +5 -0
  66. package/dist/sharedUtils/lib.es.js +1588 -0
  67. package/dist/sharedUtils/package.json +12 -0
  68. package/dist/sharedUtils/schema.d.ts +3 -0
  69. package/dist/sharedUtils/stores.d.ts +97 -0
  70. package/dist/sharedUtils/svelte5Utils.svelte.d.ts +80 -0
  71. package/dist/sharedUtils/toast.d.ts +8 -0
  72. package/dist/sharedUtils/utils.d.ts +265 -0
  73. package/package/components/AddUser.svelte +67 -34
  74. package/package/components/AppConnectInner.svelte +9 -1
  75. package/package/components/ArgInfo.svelte +9 -1
  76. package/package/components/ArgInput.svelte +21 -1
  77. package/package/components/CompareWorkspaces.svelte +11 -2
  78. package/package/components/DedicatedWorkersSelector.svelte +262 -247
  79. package/package/components/DefaultTagsInner.svelte +40 -2
  80. package/package/components/DeployWorkspace.svelte +13 -0
  81. package/package/components/DiffEditor.svelte +44 -1
  82. package/package/components/EditableSchemaForm.svelte +5 -2
  83. package/package/components/EditableSchemaForm.svelte.d.ts +1 -0
  84. package/package/components/Editor.svelte +5 -1
  85. package/package/components/EditorBar.svelte +12 -3
  86. package/package/components/FilterSearchbar.svelte +26 -2
  87. package/package/components/FlowBuilder.svelte +6 -3
  88. package/package/components/FlowGraphDiffViewer.svelte +16 -17
  89. package/package/components/FlowGraphViewer.svelte +20 -6
  90. package/package/components/FlowGraphViewer.svelte.d.ts +2 -0
  91. package/package/components/FlowGraphViewerStep.svelte +14 -32
  92. package/package/components/FlowMetadata.svelte +4 -1
  93. package/package/components/FlowPreviewContent.svelte +2 -0
  94. package/package/components/FlowStatusWaitingForEvents.svelte +25 -4
  95. package/package/components/HighlightCode.svelte +3 -0
  96. package/package/components/InstanceSetting.svelte +9 -25
  97. package/package/components/InstanceSettings.svelte +16 -0
  98. package/package/components/LabelsInput.svelte +149 -0
  99. package/package/components/LabelsInput.svelte.d.ts +8 -0
  100. package/package/components/Login.svelte +6 -1
  101. package/package/components/ObjectStoreConfigSettings.svelte +273 -1
  102. package/package/components/OktaSetting.svelte +6 -5
  103. package/package/components/Password.svelte +74 -20
  104. package/package/components/Password.svelte.d.ts +1 -0
  105. package/package/components/PasswordArgInput.svelte +2 -2
  106. package/package/components/PasswordArgInput.svelte.d.ts +1 -0
  107. package/package/components/Path.svelte +8 -10
  108. package/package/components/PathNameAutocomplete.svelte +308 -0
  109. package/package/components/PathNameAutocomplete.svelte.d.ts +27 -0
  110. package/package/components/PowerShellCommonParams.svelte +84 -0
  111. package/package/components/PowerShellCommonParams.svelte.d.ts +6 -0
  112. package/package/components/Range.svelte +8 -3
  113. package/package/components/ResourceEditor.svelte +6 -2
  114. package/package/components/RunForm.svelte +71 -7
  115. package/package/components/RunForm.svelte.d.ts +2 -1
  116. package/package/components/ScriptBuilder.svelte +7 -3
  117. package/package/components/ScriptEditor.svelte +221 -187
  118. package/package/components/ScriptEditor.svelte.d.ts +1 -1
  119. package/package/components/ScriptSchema.svelte +1 -1
  120. package/package/components/StringTypeNarrowing.svelte +1 -1
  121. package/package/components/StringTypeNarrowing.svelte.d.ts +1 -1
  122. package/package/components/SummaryPathDisplay.svelte +32 -10
  123. package/package/components/SummaryPathDisplay.svelte.d.ts +2 -1
  124. package/package/components/VariableEditor.svelte +9 -2
  125. package/package/components/WorkerGroup.svelte +47 -2
  126. package/package/components/apps/editor/DeploymentHistory.svelte +112 -13
  127. package/package/components/apps/editor/inlineScriptsPanel/InlineScriptRunnableByPath.svelte +135 -35
  128. package/package/components/apps/editor/inlineScriptsPanel/InlineScriptRunnableByPath.svelte.d.ts +3 -1
  129. package/package/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +11 -35
  130. package/package/components/apps/editor/settingsPanel/mainInput/runnableSelectorUtils.d.ts +10 -0
  131. package/package/components/apps/editor/settingsPanel/mainInput/runnableSelectorUtils.js +14 -0
  132. package/package/components/apps/editor/settingsPanel/mainInput/runnableSelectorUtils.test.d.ts +1 -0
  133. package/package/components/apps/editor/settingsPanel/mainInput/runnableSelectorUtils.test.js +34 -0
  134. package/package/components/assets/AssetButtons.svelte +21 -25
  135. package/package/components/assets/AssetsUsageDrawer.svelte +7 -9
  136. package/package/components/common/fileUpload/FileUpload.svelte +6 -2
  137. package/package/components/common/languageIcons/LanguageIcon.svelte +3 -0
  138. package/package/components/common/table/AppRow.svelte +18 -0
  139. package/package/components/common/table/FlowRow.svelte +18 -0
  140. package/package/components/common/table/ScriptRow.svelte +18 -0
  141. package/package/components/copilot/chat/AIChatManager.svelte.js +3 -3
  142. package/package/components/copilot/chat/flow/openFlow.json +1 -1
  143. package/package/components/copilot/chat/flow/openFlowZod.js +3 -3
  144. package/package/components/custom_ui.d.ts +2 -0
  145. package/package/components/details/DetailPageHeader.svelte +2 -2
  146. package/package/components/details/DetailPageHeader.svelte.d.ts +2 -1
  147. package/package/components/flows/agentToolUtils.d.ts +5 -0
  148. package/package/components/flows/agentToolUtils.js +49 -0
  149. package/package/components/flows/agentToolUtils.test.d.ts +1 -0
  150. package/package/components/flows/agentToolUtils.test.js +55 -0
  151. package/package/components/flows/content/FlowInput.svelte +2 -0
  152. package/package/components/flows/content/FlowInputsQuick.svelte +1 -1
  153. package/package/components/flows/content/FlowLoop.svelte +5 -12
  154. package/package/components/flows/content/FlowModuleScript.svelte +5 -3
  155. package/package/components/flows/content/FlowPathViewer.svelte +2 -2
  156. package/package/components/flows/content/FlowPathViewer.svelte.d.ts +1 -0
  157. package/package/components/flows/content/FlowSettings.svelte +2 -0
  158. package/package/components/flows/content/FlowWhileLoop.svelte +5 -12
  159. package/package/components/flows/flowInfers.js +8 -3
  160. package/package/components/flows/map/FlowModuleSchemaMap.svelte +49 -9
  161. package/package/components/flows/pickers/PickHubScriptQuick.svelte +5 -3
  162. package/package/components/flows/pickers/PickHubScriptQuick.svelte.d.ts +1 -1
  163. package/package/components/flows/scheduleUtils.js +2 -1
  164. package/package/components/graph/FlowGraphV2.svelte +13 -1
  165. package/package/components/graph/WacDiagram.svelte +96 -0
  166. package/package/components/graph/WacDiagram.svelte.d.ts +7 -0
  167. package/package/components/graph/noteEditor.svelte.d.ts +1 -1
  168. package/package/components/graph/noteEditor.svelte.js +12 -1
  169. package/package/components/graph/noteUtils.svelte.d.ts +1 -1
  170. package/package/components/graph/noteUtils.svelte.js +9 -2
  171. package/package/components/graph/renderers/edges/WacEdge.svelte +41 -0
  172. package/package/components/graph/renderers/edges/WacEdge.svelte.d.ts +4 -0
  173. package/package/components/graph/renderers/nodes/WacControlNode.svelte +51 -0
  174. package/package/components/graph/renderers/nodes/WacControlNode.svelte.d.ts +9 -0
  175. package/package/components/graph/renderers/nodes/WacStepNode.svelte +35 -0
  176. package/package/components/graph/renderers/nodes/WacStepNode.svelte.d.ts +9 -0
  177. package/package/components/graph/wacDagLayout.d.ts +10 -0
  178. package/package/components/graph/wacDagLayout.js +120 -0
  179. package/package/components/graph/wacToFlow.js +1 -1
  180. package/package/components/home/ItemsList.svelte +28 -4
  181. package/package/components/icons/RIcon.svelte +32 -0
  182. package/package/components/icons/RIcon.svelte.d.ts +7 -0
  183. package/package/components/instanceSettings/DbHealth.svelte +723 -0
  184. package/package/components/instanceSettings/DbHealth.svelte.d.ts +3 -0
  185. package/package/components/instanceSettings/SecretBackendConfig.svelte +343 -304
  186. package/package/components/instanceSettings/SmtpSettings.svelte +8 -0
  187. package/package/components/instanceSettings.js +14 -5
  188. package/package/components/mcp/McpScopeSelector.svelte +82 -16
  189. package/package/components/moveRenameManager.d.ts +1 -0
  190. package/package/components/moveRenameManager.js +7 -4
  191. package/package/components/raw_apps/RawAppInlineScriptRunnable.svelte +14 -1
  192. package/package/components/raw_apps/rawAppPolicy.js +3 -2
  193. package/package/components/raw_apps/utils.test.d.ts +1 -0
  194. package/package/components/raw_apps/utils.test.js +38 -0
  195. package/package/components/recording/ScriptRecordingReplay.svelte +0 -1
  196. package/package/components/resources/resourcesFilter.d.ts +15 -2
  197. package/package/components/resources/resourcesFilter.js +11 -2
  198. package/package/components/runs/JobDetailFieldConfig.js +5 -3
  199. package/package/components/runs/JobDetailHeader.svelte +5 -2
  200. package/package/components/runs/JobRunsPreview.svelte +1 -0
  201. package/package/components/runs/RunBadges.svelte +7 -4
  202. package/package/components/runs/RunRow.svelte +7 -7
  203. package/package/components/schedules/schedulesFilter.d.ts +15 -2
  204. package/package/components/schedules/schedulesFilter.js +11 -2
  205. package/package/components/schema/EditableSchemaWrapper.svelte +6 -8
  206. package/package/components/schema/PropertyEditor.svelte +22 -1
  207. package/package/components/schema/PropertyEditor.svelte.d.ts +1 -0
  208. package/package/components/schema/editable_schema_wrapper.d.ts +1 -0
  209. package/package/components/secretArgUtils.d.ts +7 -0
  210. package/package/components/secretArgUtils.js +45 -0
  211. package/package/components/settings/WorkspaceUserSettings.svelte +359 -286
  212. package/package/components/sidebar/OperatorMenu.svelte +215 -197
  213. package/package/components/triggers/CaptureWrapper.svelte +1 -1
  214. package/package/components/triggers/TriggerFilters.svelte +17 -5
  215. package/package/components/triggers/TriggerFilters.svelte.d.ts +2 -1
  216. package/package/components/triggers/kafka/KafkaCapture.svelte +6 -2
  217. package/package/components/triggers/kafka/KafkaCapture.svelte.d.ts +1 -1
  218. package/package/components/triggers/kafka/KafkaTriggerEditorInner.svelte +5 -1
  219. package/package/components/triggers/kafka/utils.js +1 -0
  220. package/package/components/triggers/schedules/ScheduleEditorInner.svelte +6 -0
  221. package/package/components/triggers/websocket/WebsocketTriggerEditorInner.svelte +87 -1
  222. package/package/components/triggers/websocket/utils.js +2 -0
  223. package/package/components/variables/variablesFilter.d.ts +15 -2
  224. package/package/components/variables/variablesFilter.js +11 -2
  225. package/package/components/worker_group.js +1 -0
  226. package/package/components/workspaceSettings/DucklakeSettings.svelte +33 -41
  227. package/package/consts.d.ts +1 -0
  228. package/package/consts.js +1 -0
  229. package/package/editorLangUtils.d.ts +1 -1
  230. package/package/editorLangUtils.js +2 -0
  231. package/package/forLater.js +4 -0
  232. package/package/gen/core/OpenAPI.js +1 -1
  233. package/package/gen/schemas.gen.d.ts +94 -294
  234. package/package/gen/schemas.gen.js +94 -294
  235. package/package/gen/services.gen.d.ts +5 -121
  236. package/package/gen/services.gen.js +5 -237
  237. package/package/gen/types.gen.d.ts +91 -715
  238. package/package/hubPaths.json +6 -3
  239. package/package/infer.d.ts +55 -0
  240. package/package/infer.js +131 -0
  241. package/package/infer.svelte.js +2 -0
  242. package/package/mcpEndpointTools.js +213 -22
  243. package/package/script_helpers.d.ts +3 -0
  244. package/package/script_helpers.js +26 -0
  245. package/package/scripts.d.ts +2 -1
  246. package/package/scripts.js +15 -3
  247. package/package/stores.d.ts +2 -0
  248. package/package/system_prompts/prompts.d.ts +6 -5
  249. package/package/system_prompts/prompts.js +188 -29
  250. package/package/user.js +5 -1
  251. package/package/utils.js +21 -0
  252. package/package/utils_deployable.d.ts +7 -0
  253. package/package/utils_workspace_deploy.js +36 -8
  254. package/package.json +6 -5
@@ -0,0 +1,1588 @@
1
+ var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __esmMin = (c, L) => () => (c && (L = c(c = 0)), L), __commonJSMin = (c, L) => () => (L || c((L = { exports: {} }).exports, L), L.exports), __export = (L, R) => {
2
+ let z = {};
3
+ for (var B in L) __defProp(z, B, {
4
+ get: L[B],
5
+ enumerable: !0
6
+ });
7
+ return R && __defProp(z, Symbol.toStringTag, { value: "Module" }), z;
8
+ }, __copyProps = (B, V, H, U) => {
9
+ if (V && typeof V == "object" || typeof V == "function") for (var W = __getOwnPropNames(V), G = 0, K = W.length, q; G < K; G++) q = W[G], !__hasOwnProp.call(B, q) && q !== H && __defProp(B, q, {
10
+ get: ((c) => V[c]).bind(null, q),
11
+ enumerable: !(U = __getOwnPropDesc(V, q)) || U.enumerable
12
+ });
13
+ return B;
14
+ }, __toCommonJS = (L) => __hasOwnProp.call(L, "module.exports") ? L["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: !0 }), L), tslib_es6_exports = /* @__PURE__ */ __export({
15
+ __assign: () => __assign,
16
+ __asyncDelegator: () => __asyncDelegator,
17
+ __asyncGenerator: () => __asyncGenerator,
18
+ __asyncValues: () => __asyncValues,
19
+ __await: () => __await,
20
+ __awaiter: () => __awaiter,
21
+ __classPrivateFieldGet: () => __classPrivateFieldGet,
22
+ __classPrivateFieldSet: () => __classPrivateFieldSet,
23
+ __createBinding: () => __createBinding,
24
+ __decorate: () => __decorate,
25
+ __exportStar: () => __exportStar,
26
+ __extends: () => __extends,
27
+ __generator: () => __generator,
28
+ __importDefault: () => __importDefault,
29
+ __importStar: () => __importStar,
30
+ __makeTemplateObject: () => __makeTemplateObject,
31
+ __metadata: () => __metadata,
32
+ __param: () => __param,
33
+ __read: () => __read,
34
+ __rest: () => __rest,
35
+ __spread: () => __spread,
36
+ __spreadArrays: () => __spreadArrays,
37
+ __values: () => __values
38
+ }, 1);
39
+ function __extends(c, L) {
40
+ extendStatics(c, L);
41
+ function R() {
42
+ this.constructor = c;
43
+ }
44
+ c.prototype = L === null ? Object.create(L) : (R.prototype = L.prototype, new R());
45
+ }
46
+ function __rest(c, L) {
47
+ var R = {};
48
+ for (var z in c) Object.prototype.hasOwnProperty.call(c, z) && L.indexOf(z) < 0 && (R[z] = c[z]);
49
+ if (c != null && typeof Object.getOwnPropertySymbols == "function") for (var B = 0, z = Object.getOwnPropertySymbols(c); B < z.length; B++) L.indexOf(z[B]) < 0 && Object.prototype.propertyIsEnumerable.call(c, z[B]) && (R[z[B]] = c[z[B]]);
50
+ return R;
51
+ }
52
+ function __decorate(c, L, R, z) {
53
+ var B = arguments.length, V = B < 3 ? L : z === null ? z = Object.getOwnPropertyDescriptor(L, R) : z, H;
54
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") V = Reflect.decorate(c, L, R, z);
55
+ else for (var U = c.length - 1; U >= 0; U--) (H = c[U]) && (V = (B < 3 ? H(V) : B > 3 ? H(L, R, V) : H(L, R)) || V);
56
+ return B > 3 && V && Object.defineProperty(L, R, V), V;
57
+ }
58
+ function __param(c, L) {
59
+ return function(R, z) {
60
+ L(R, z, c);
61
+ };
62
+ }
63
+ function __metadata(c, L) {
64
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(c, L);
65
+ }
66
+ function __awaiter(c, L, R, z) {
67
+ function B(c) {
68
+ return c instanceof R ? c : new R(function(L) {
69
+ L(c);
70
+ });
71
+ }
72
+ return new (R ||= Promise)(function(R, V) {
73
+ function H(c) {
74
+ try {
75
+ W(z.next(c));
76
+ } catch (c) {
77
+ V(c);
78
+ }
79
+ }
80
+ function U(c) {
81
+ try {
82
+ W(z.throw(c));
83
+ } catch (c) {
84
+ V(c);
85
+ }
86
+ }
87
+ function W(c) {
88
+ c.done ? R(c.value) : B(c.value).then(H, U);
89
+ }
90
+ W((z = z.apply(c, L || [])).next());
91
+ });
92
+ }
93
+ function __generator(c, L) {
94
+ var R = {
95
+ label: 0,
96
+ sent: function() {
97
+ if (V[0] & 1) throw V[1];
98
+ return V[1];
99
+ },
100
+ trys: [],
101
+ ops: []
102
+ }, z, B, V, H;
103
+ return H = {
104
+ next: U(0),
105
+ throw: U(1),
106
+ return: U(2)
107
+ }, typeof Symbol == "function" && (H[Symbol.iterator] = function() {
108
+ return this;
109
+ }), H;
110
+ function U(c) {
111
+ return function(L) {
112
+ return W([c, L]);
113
+ };
114
+ }
115
+ function W(H) {
116
+ if (z) throw TypeError("Generator is already executing.");
117
+ for (; R;) try {
118
+ if (z = 1, B && (V = H[0] & 2 ? B.return : H[0] ? B.throw || ((V = B.return) && V.call(B), 0) : B.next) && !(V = V.call(B, H[1])).done) return V;
119
+ switch (B = 0, V && (H = [H[0] & 2, V.value]), H[0]) {
120
+ case 0:
121
+ case 1:
122
+ V = H;
123
+ break;
124
+ case 4: return R.label++, {
125
+ value: H[1],
126
+ done: !1
127
+ };
128
+ case 5:
129
+ R.label++, B = H[1], H = [0];
130
+ continue;
131
+ case 7:
132
+ H = R.ops.pop(), R.trys.pop();
133
+ continue;
134
+ default:
135
+ if ((V = R.trys, !(V = V.length > 0 && V[V.length - 1])) && (H[0] === 6 || H[0] === 2)) {
136
+ R = 0;
137
+ continue;
138
+ }
139
+ if (H[0] === 3 && (!V || H[1] > V[0] && H[1] < V[3])) {
140
+ R.label = H[1];
141
+ break;
142
+ }
143
+ if (H[0] === 6 && R.label < V[1]) {
144
+ R.label = V[1], V = H;
145
+ break;
146
+ }
147
+ if (V && R.label < V[2]) {
148
+ R.label = V[2], R.ops.push(H);
149
+ break;
150
+ }
151
+ V[2] && R.ops.pop(), R.trys.pop();
152
+ continue;
153
+ }
154
+ H = L.call(c, R);
155
+ } catch (c) {
156
+ H = [6, c], B = 0;
157
+ } finally {
158
+ z = V = 0;
159
+ }
160
+ if (H[0] & 5) throw H[1];
161
+ return {
162
+ value: H[0] ? H[1] : void 0,
163
+ done: !0
164
+ };
165
+ }
166
+ }
167
+ function __createBinding(c, L, R, z) {
168
+ z === void 0 && (z = R), c[z] = L[R];
169
+ }
170
+ function __exportStar(c, L) {
171
+ for (var R in c) R !== "default" && !L.hasOwnProperty(R) && (L[R] = c[R]);
172
+ }
173
+ function __values(c) {
174
+ var L = typeof Symbol == "function" && Symbol.iterator, R = L && c[L], z = 0;
175
+ if (R) return R.call(c);
176
+ if (c && typeof c.length == "number") return { next: function() {
177
+ return c && z >= c.length && (c = void 0), {
178
+ value: c && c[z++],
179
+ done: !c
180
+ };
181
+ } };
182
+ throw TypeError(L ? "Object is not iterable." : "Symbol.iterator is not defined.");
183
+ }
184
+ function __read(c, L) {
185
+ var R = typeof Symbol == "function" && c[Symbol.iterator];
186
+ if (!R) return c;
187
+ var z = R.call(c), B, V = [], H;
188
+ try {
189
+ for (; (L === void 0 || L-- > 0) && !(B = z.next()).done;) V.push(B.value);
190
+ } catch (c) {
191
+ H = { error: c };
192
+ } finally {
193
+ try {
194
+ B && !B.done && (R = z.return) && R.call(z);
195
+ } finally {
196
+ if (H) throw H.error;
197
+ }
198
+ }
199
+ return V;
200
+ }
201
+ function __spread() {
202
+ for (var c = [], L = 0; L < arguments.length; L++) c = c.concat(__read(arguments[L]));
203
+ return c;
204
+ }
205
+ function __spreadArrays() {
206
+ for (var c = 0, L = 0, R = arguments.length; L < R; L++) c += arguments[L].length;
207
+ for (var z = Array(c), B = 0, L = 0; L < R; L++) for (var V = arguments[L], H = 0, U = V.length; H < U; H++, B++) z[B] = V[H];
208
+ return z;
209
+ }
210
+ function __await(c) {
211
+ return this instanceof __await ? (this.v = c, this) : new __await(c);
212
+ }
213
+ function __asyncGenerator(c, L, R) {
214
+ if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
215
+ var z = R.apply(c, L || []), B, V = [];
216
+ return B = {}, H("next"), H("throw"), H("return"), B[Symbol.asyncIterator] = function() {
217
+ return this;
218
+ }, B;
219
+ function H(c) {
220
+ z[c] && (B[c] = function(L) {
221
+ return new Promise(function(R, z) {
222
+ V.push([
223
+ c,
224
+ L,
225
+ R,
226
+ z
227
+ ]) > 1 || U(c, L);
228
+ });
229
+ });
230
+ }
231
+ function U(c, L) {
232
+ try {
233
+ W(z[c](L));
234
+ } catch (c) {
235
+ q(V[0][3], c);
236
+ }
237
+ }
238
+ function W(c) {
239
+ c.value instanceof __await ? Promise.resolve(c.value.v).then(G, K) : q(V[0][2], c);
240
+ }
241
+ function G(c) {
242
+ U("next", c);
243
+ }
244
+ function K(c) {
245
+ U("throw", c);
246
+ }
247
+ function q(c, L) {
248
+ c(L), V.shift(), V.length && U(V[0][0], V[0][1]);
249
+ }
250
+ }
251
+ function __asyncDelegator(c) {
252
+ var L, R;
253
+ return L = {}, z("next"), z("throw", function(c) {
254
+ throw c;
255
+ }), z("return"), L[Symbol.iterator] = function() {
256
+ return this;
257
+ }, L;
258
+ function z(z, B) {
259
+ L[z] = c[z] ? function(L) {
260
+ return (R = !R) ? {
261
+ value: __await(c[z](L)),
262
+ done: z === "return"
263
+ } : B ? B(L) : L;
264
+ } : B;
265
+ }
266
+ }
267
+ function __asyncValues(c) {
268
+ if (!Symbol.asyncIterator) throw TypeError("Symbol.asyncIterator is not defined.");
269
+ var L = c[Symbol.asyncIterator], R;
270
+ return L ? L.call(c) : (c = typeof __values == "function" ? __values(c) : c[Symbol.iterator](), R = {}, z("next"), z("throw"), z("return"), R[Symbol.asyncIterator] = function() {
271
+ return this;
272
+ }, R);
273
+ function z(L) {
274
+ R[L] = c[L] && function(R) {
275
+ return new Promise(function(z, V) {
276
+ R = c[L](R), B(z, V, R.done, R.value);
277
+ });
278
+ };
279
+ }
280
+ function B(c, L, R, z) {
281
+ Promise.resolve(z).then(function(L) {
282
+ c({
283
+ value: L,
284
+ done: R
285
+ });
286
+ }, L);
287
+ }
288
+ }
289
+ function __makeTemplateObject(c, L) {
290
+ return Object.defineProperty ? Object.defineProperty(c, "raw", { value: L }) : c.raw = L, c;
291
+ }
292
+ function __importStar(c) {
293
+ if (c && c.__esModule) return c;
294
+ var L = {};
295
+ if (c != null) for (var R in c) Object.hasOwnProperty.call(c, R) && (L[R] = c[R]);
296
+ return L.default = c, L;
297
+ }
298
+ function __importDefault(c) {
299
+ return c && c.__esModule ? c : { default: c };
300
+ }
301
+ function __classPrivateFieldGet(c, L) {
302
+ if (!L.has(c)) throw TypeError("attempted to get private field on non-instance");
303
+ return L.get(c);
304
+ }
305
+ function __classPrivateFieldSet(c, L, R) {
306
+ if (!L.has(c)) throw TypeError("attempted to set private field on non-instance");
307
+ return L.set(c, R), R;
308
+ }
309
+ var extendStatics, __assign, init_tslib_es6 = __esmMin((() => {
310
+ extendStatics = function(c, L) {
311
+ return extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(c, L) {
312
+ c.__proto__ = L;
313
+ } || function(c, L) {
314
+ for (var R in L) L.hasOwnProperty(R) && (c[R] = L[R]);
315
+ }, extendStatics(c, L);
316
+ }, __assign = function() {
317
+ return __assign = Object.assign || function(c) {
318
+ for (var L, R = 1, z = arguments.length; R < z; R++) for (var B in L = arguments[R], L) Object.prototype.hasOwnProperty.call(L, B) && (c[B] = L[B]);
319
+ return c;
320
+ }, __assign.apply(this, arguments);
321
+ };
322
+ })), require_constants = /* @__PURE__ */ __commonJSMin(((c) => {
323
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.MAX_HASHABLE_LENGTH = c.INIT = c.KEY = c.DIGEST_LENGTH = c.BLOCK_SIZE = void 0, c.BLOCK_SIZE = 64, c.DIGEST_LENGTH = 32, c.KEY = new Uint32Array([
324
+ 1116352408,
325
+ 1899447441,
326
+ 3049323471,
327
+ 3921009573,
328
+ 961987163,
329
+ 1508970993,
330
+ 2453635748,
331
+ 2870763221,
332
+ 3624381080,
333
+ 310598401,
334
+ 607225278,
335
+ 1426881987,
336
+ 1925078388,
337
+ 2162078206,
338
+ 2614888103,
339
+ 3248222580,
340
+ 3835390401,
341
+ 4022224774,
342
+ 264347078,
343
+ 604807628,
344
+ 770255983,
345
+ 1249150122,
346
+ 1555081692,
347
+ 1996064986,
348
+ 2554220882,
349
+ 2821834349,
350
+ 2952996808,
351
+ 3210313671,
352
+ 3336571891,
353
+ 3584528711,
354
+ 113926993,
355
+ 338241895,
356
+ 666307205,
357
+ 773529912,
358
+ 1294757372,
359
+ 1396182291,
360
+ 1695183700,
361
+ 1986661051,
362
+ 2177026350,
363
+ 2456956037,
364
+ 2730485921,
365
+ 2820302411,
366
+ 3259730800,
367
+ 3345764771,
368
+ 3516065817,
369
+ 3600352804,
370
+ 4094571909,
371
+ 275423344,
372
+ 430227734,
373
+ 506948616,
374
+ 659060556,
375
+ 883997877,
376
+ 958139571,
377
+ 1322822218,
378
+ 1537002063,
379
+ 1747873779,
380
+ 1955562222,
381
+ 2024104815,
382
+ 2227730452,
383
+ 2361852424,
384
+ 2428436474,
385
+ 2756734187,
386
+ 3204031479,
387
+ 3329325298
388
+ ]), c.INIT = [
389
+ 1779033703,
390
+ 3144134277,
391
+ 1013904242,
392
+ 2773480762,
393
+ 1359893119,
394
+ 2600822924,
395
+ 528734635,
396
+ 1541459225
397
+ ], c.MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
398
+ })), require_RawSha256 = /* @__PURE__ */ __commonJSMin(((c) => {
399
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.RawSha256 = void 0;
400
+ var L = require_constants();
401
+ c.RawSha256 = function() {
402
+ function c() {
403
+ this.state = Int32Array.from(L.INIT), this.temp = new Int32Array(64), this.buffer = new Uint8Array(64), this.bufferLength = 0, this.bytesHashed = 0, this.finished = !1;
404
+ }
405
+ return c.prototype.update = function(c) {
406
+ if (this.finished) throw Error("Attempted to update an already finished hash.");
407
+ var R = 0, z = c.byteLength;
408
+ if (this.bytesHashed += z, this.bytesHashed * 8 > L.MAX_HASHABLE_LENGTH) throw Error("Cannot hash more than 2^53 - 1 bits");
409
+ for (; z > 0;) this.buffer[this.bufferLength++] = c[R++], z--, this.bufferLength === L.BLOCK_SIZE && (this.hashBuffer(), this.bufferLength = 0);
410
+ }, c.prototype.digest = function() {
411
+ if (!this.finished) {
412
+ var c = this.bytesHashed * 8, R = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength), z = this.bufferLength;
413
+ if (R.setUint8(this.bufferLength++, 128), z % L.BLOCK_SIZE >= L.BLOCK_SIZE - 8) {
414
+ for (var B = this.bufferLength; B < L.BLOCK_SIZE; B++) R.setUint8(B, 0);
415
+ this.hashBuffer(), this.bufferLength = 0;
416
+ }
417
+ for (var B = this.bufferLength; B < L.BLOCK_SIZE - 8; B++) R.setUint8(B, 0);
418
+ R.setUint32(L.BLOCK_SIZE - 8, Math.floor(c / 4294967296), !0), R.setUint32(L.BLOCK_SIZE - 4, c), this.hashBuffer(), this.finished = !0;
419
+ }
420
+ for (var V = new Uint8Array(L.DIGEST_LENGTH), B = 0; B < 8; B++) V[B * 4] = this.state[B] >>> 24 & 255, V[B * 4 + 1] = this.state[B] >>> 16 & 255, V[B * 4 + 2] = this.state[B] >>> 8 & 255, V[B * 4 + 3] = this.state[B] >>> 0 & 255;
421
+ return V;
422
+ }, c.prototype.hashBuffer = function() {
423
+ for (var c = this, R = c.buffer, z = c.state, B = z[0], V = z[1], H = z[2], U = z[3], W = z[4], G = z[5], K = z[6], q = z[7], J = 0; J < L.BLOCK_SIZE; J++) {
424
+ if (J < 16) this.temp[J] = (R[J * 4] & 255) << 24 | (R[J * 4 + 1] & 255) << 16 | (R[J * 4 + 2] & 255) << 8 | R[J * 4 + 3] & 255;
425
+ else {
426
+ var Y = this.temp[J - 2], X = (Y >>> 17 | Y << 15) ^ (Y >>> 19 | Y << 13) ^ Y >>> 10;
427
+ Y = this.temp[J - 15];
428
+ var Z = (Y >>> 7 | Y << 25) ^ (Y >>> 18 | Y << 14) ^ Y >>> 3;
429
+ this.temp[J] = (X + this.temp[J - 7] | 0) + (Z + this.temp[J - 16] | 0);
430
+ }
431
+ var Q = (((W >>> 6 | W << 26) ^ (W >>> 11 | W << 21) ^ (W >>> 25 | W << 7)) + (W & G ^ ~W & K) | 0) + (q + (L.KEY[J] + this.temp[J] | 0) | 0) | 0, $ = ((B >>> 2 | B << 30) ^ (B >>> 13 | B << 19) ^ (B >>> 22 | B << 10)) + (B & V ^ B & H ^ V & H) | 0;
432
+ q = K, K = G, G = W, W = U + Q | 0, U = H, H = V, V = B, B = Q + $ | 0;
433
+ }
434
+ z[0] += B, z[1] += V, z[2] += H, z[3] += U, z[4] += W, z[5] += G, z[6] += K, z[7] += q;
435
+ }, c;
436
+ }();
437
+ })), fromUtf8$1, toUtf8, init_pureJs = __esmMin((() => {
438
+ fromUtf8$1 = (c) => {
439
+ let L = [];
440
+ for (let R = 0, z = c.length; R < z; R++) {
441
+ let z = c.charCodeAt(R);
442
+ if (z < 128) L.push(z);
443
+ else if (z < 2048) L.push(z >> 6 | 192, z & 63 | 128);
444
+ else if (R + 1 < c.length && (z & 64512) == 55296 && (c.charCodeAt(R + 1) & 64512) == 56320) {
445
+ let B = 65536 + ((z & 1023) << 10) + (c.charCodeAt(++R) & 1023);
446
+ L.push(B >> 18 | 240, B >> 12 & 63 | 128, B >> 6 & 63 | 128, B & 63 | 128);
447
+ } else L.push(z >> 12 | 224, z >> 6 & 63 | 128, z & 63 | 128);
448
+ }
449
+ return Uint8Array.from(L);
450
+ }, toUtf8 = (c) => {
451
+ let L = "";
452
+ for (let R = 0, z = c.length; R < z; R++) {
453
+ let z = c[R];
454
+ if (z < 128) L += String.fromCharCode(z);
455
+ else if (192 <= z && z < 224) {
456
+ let B = c[++R];
457
+ L += String.fromCharCode((z & 31) << 6 | B & 63);
458
+ } else if (240 <= z && z < 365) {
459
+ let B = "%" + [
460
+ z,
461
+ c[++R],
462
+ c[++R],
463
+ c[++R]
464
+ ].map((c) => c.toString(16)).join("%");
465
+ L += decodeURIComponent(B);
466
+ } else L += String.fromCharCode((z & 15) << 12 | (c[++R] & 63) << 6 | c[++R] & 63);
467
+ }
468
+ return L;
469
+ };
470
+ }));
471
+ function fromUtf8$2(c) {
472
+ return new TextEncoder().encode(c);
473
+ }
474
+ function toUtf8$1(c) {
475
+ return new TextDecoder("utf-8").decode(c);
476
+ }
477
+ var init_whatwgEncodingApi = __esmMin((() => {})), dist_es_exports = /* @__PURE__ */ __export({
478
+ fromUtf8: () => fromUtf8$3,
479
+ toUtf8: () => toUtf8$2
480
+ }, 1), fromUtf8$3, toUtf8$2, init_dist_es = __esmMin((() => {
481
+ init_pureJs(), init_whatwgEncodingApi(), fromUtf8$3 = (c) => typeof TextEncoder == "function" ? fromUtf8$2(c) : fromUtf8$1(c), toUtf8$2 = (c) => typeof TextDecoder == "function" ? toUtf8$1(c) : toUtf8(c);
482
+ })), require_convertToBuffer = /* @__PURE__ */ __commonJSMin(((c) => {
483
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.convertToBuffer = void 0;
484
+ var L = (init_dist_es(), __toCommonJS(dist_es_exports)), R = typeof Buffer < "u" && Buffer.from ? function(c) {
485
+ return Buffer.from(c, "utf8");
486
+ } : L.fromUtf8;
487
+ function z(c) {
488
+ return c instanceof Uint8Array ? c : typeof c == "string" ? R(c) : ArrayBuffer.isView(c) ? new Uint8Array(c.buffer, c.byteOffset, c.byteLength / Uint8Array.BYTES_PER_ELEMENT) : new Uint8Array(c);
489
+ }
490
+ c.convertToBuffer = z;
491
+ })), require_isEmptyData = /* @__PURE__ */ __commonJSMin(((c) => {
492
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.isEmptyData = void 0;
493
+ function L(c) {
494
+ return typeof c == "string" ? c.length === 0 : c.byteLength === 0;
495
+ }
496
+ c.isEmptyData = L;
497
+ })), require_numToUint8 = /* @__PURE__ */ __commonJSMin(((c) => {
498
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.numToUint8 = void 0;
499
+ function L(c) {
500
+ return new Uint8Array([
501
+ (c & 4278190080) >> 24,
502
+ (c & 16711680) >> 16,
503
+ (c & 65280) >> 8,
504
+ c & 255
505
+ ]);
506
+ }
507
+ c.numToUint8 = L;
508
+ })), require_uint32ArrayFrom = /* @__PURE__ */ __commonJSMin(((c) => {
509
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.uint32ArrayFrom = void 0;
510
+ function L(c) {
511
+ if (!Uint32Array.from) {
512
+ for (var L = new Uint32Array(c.length), R = 0; R < c.length;) L[R] = c[R], R += 1;
513
+ return L;
514
+ }
515
+ return Uint32Array.from(c);
516
+ }
517
+ c.uint32ArrayFrom = L;
518
+ })), require_build$1 = /* @__PURE__ */ __commonJSMin(((c) => {
519
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.uint32ArrayFrom = c.numToUint8 = c.isEmptyData = c.convertToBuffer = void 0;
520
+ var L = require_convertToBuffer();
521
+ Object.defineProperty(c, "convertToBuffer", {
522
+ enumerable: !0,
523
+ get: function() {
524
+ return L.convertToBuffer;
525
+ }
526
+ });
527
+ var R = require_isEmptyData();
528
+ Object.defineProperty(c, "isEmptyData", {
529
+ enumerable: !0,
530
+ get: function() {
531
+ return R.isEmptyData;
532
+ }
533
+ });
534
+ var z = require_numToUint8();
535
+ Object.defineProperty(c, "numToUint8", {
536
+ enumerable: !0,
537
+ get: function() {
538
+ return z.numToUint8;
539
+ }
540
+ });
541
+ var B = require_uint32ArrayFrom();
542
+ Object.defineProperty(c, "uint32ArrayFrom", {
543
+ enumerable: !0,
544
+ get: function() {
545
+ return B.uint32ArrayFrom;
546
+ }
547
+ });
548
+ })), require_jsSha256 = /* @__PURE__ */ __commonJSMin(((c) => {
549
+ Object.defineProperty(c, "__esModule", { value: !0 }), c.Sha256 = void 0;
550
+ var L = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)), R = require_constants(), z = require_RawSha256(), B = require_build$1();
551
+ c.Sha256 = function() {
552
+ function c(c) {
553
+ this.secret = c, this.hash = new z.RawSha256(), this.reset();
554
+ }
555
+ return c.prototype.update = function(c) {
556
+ if (!((0, B.isEmptyData)(c) || this.error)) try {
557
+ this.hash.update((0, B.convertToBuffer)(c));
558
+ } catch (c) {
559
+ this.error = c;
560
+ }
561
+ }, c.prototype.digestSync = function() {
562
+ if (this.error) throw this.error;
563
+ return this.outer ? (this.outer.finished || this.outer.update(this.hash.digest()), this.outer.digest()) : this.hash.digest();
564
+ }, c.prototype.digest = function() {
565
+ return L.__awaiter(this, void 0, void 0, function() {
566
+ return L.__generator(this, function(c) {
567
+ return [2, this.digestSync()];
568
+ });
569
+ });
570
+ }, c.prototype.reset = function() {
571
+ if (this.hash = new z.RawSha256(), this.secret) {
572
+ this.outer = new z.RawSha256();
573
+ var c = V(this.secret), L = new Uint8Array(R.BLOCK_SIZE);
574
+ L.set(c);
575
+ for (var B = 0; B < R.BLOCK_SIZE; B++) c[B] ^= 54, L[B] ^= 92;
576
+ this.hash.update(c), this.outer.update(L);
577
+ for (var B = 0; B < c.byteLength; B++) c[B] = 0;
578
+ }
579
+ }, c;
580
+ }();
581
+ function V(c) {
582
+ var L = (0, B.convertToBuffer)(c);
583
+ if (L.byteLength > R.BLOCK_SIZE) {
584
+ var V = new z.RawSha256();
585
+ V.update(L), L = V.digest();
586
+ }
587
+ var H = new Uint8Array(R.BLOCK_SIZE);
588
+ return H.set(L), H;
589
+ }
590
+ })), require_build = /* @__PURE__ */ __commonJSMin(((c) => {
591
+ Object.defineProperty(c, "__esModule", { value: !0 }), (init_tslib_es6(), __toCommonJS(tslib_es6_exports)).__exportStar(require_jsSha256(), c);
592
+ })), import_build$1 = require_build();
593
+ function wrapDucklakeQuery(c, L) {
594
+ let R = `ATTACH 'ducklake://${L}' AS dl;USE dl;\n`;
595
+ return c.replace(/^(--.*\n)*/, (c) => c + R);
596
+ }
597
+ function getIntrospectionQuery(c) {
598
+ let L = {
599
+ descriptions: !0,
600
+ specifiedByUrl: !1,
601
+ directiveIsRepeatable: !1,
602
+ schemaDescription: !1,
603
+ inputValueDeprecation: !1,
604
+ oneOf: !1,
605
+ ...c
606
+ }, R = L.descriptions ? "description" : "", z = L.specifiedByUrl ? "specifiedByURL" : "", B = L.directiveIsRepeatable ? "isRepeatable" : "", V = L.schemaDescription ? R : "";
607
+ function H(c) {
608
+ return L.inputValueDeprecation ? c : "";
609
+ }
610
+ let U = L.oneOf ? "isOneOf" : "";
611
+ return `
612
+ query IntrospectionQuery {
613
+ __schema {
614
+ ${V}
615
+ queryType { name kind }
616
+ mutationType { name kind }
617
+ subscriptionType { name kind }
618
+ types {
619
+ ...FullType
620
+ }
621
+ directives {
622
+ name
623
+ ${R}
624
+ ${B}
625
+ locations
626
+ args${H("(includeDeprecated: true)")} {
627
+ ...InputValue
628
+ }
629
+ }
630
+ }
631
+ }
632
+
633
+ fragment FullType on __Type {
634
+ kind
635
+ name
636
+ ${R}
637
+ ${z}
638
+ ${U}
639
+ fields(includeDeprecated: true) {
640
+ name
641
+ ${R}
642
+ args${H("(includeDeprecated: true)")} {
643
+ ...InputValue
644
+ }
645
+ type {
646
+ ...TypeRef
647
+ }
648
+ isDeprecated
649
+ deprecationReason
650
+ }
651
+ inputFields${H("(includeDeprecated: true)")} {
652
+ ...InputValue
653
+ }
654
+ interfaces {
655
+ ...TypeRef
656
+ }
657
+ enumValues(includeDeprecated: true) {
658
+ name
659
+ ${R}
660
+ isDeprecated
661
+ deprecationReason
662
+ }
663
+ possibleTypes {
664
+ ...TypeRef
665
+ }
666
+ }
667
+
668
+ fragment InputValue on __InputValue {
669
+ name
670
+ ${R}
671
+ type { ...TypeRef }
672
+ defaultValue
673
+ ${H("isDeprecated")}
674
+ ${H("deprecationReason")}
675
+ }
676
+
677
+ fragment TypeRef on __Type {
678
+ kind
679
+ name
680
+ ofType {
681
+ kind
682
+ name
683
+ ofType {
684
+ kind
685
+ name
686
+ ofType {
687
+ kind
688
+ name
689
+ ofType {
690
+ kind
691
+ name
692
+ ofType {
693
+ kind
694
+ name
695
+ ofType {
696
+ kind
697
+ name
698
+ ofType {
699
+ kind
700
+ name
701
+ ofType {
702
+ kind
703
+ name
704
+ ofType {
705
+ kind
706
+ name
707
+ }
708
+ }
709
+ }
710
+ }
711
+ }
712
+ }
713
+ }
714
+ }
715
+ }
716
+ }
717
+ `;
718
+ }
719
+ let ColumnIdentity = /* @__PURE__ */ function(c) {
720
+ return c.ByDefault = "By Default", c.Always = "Always", c.No = "No", c;
721
+ }({});
722
+ var legacyScripts = {
723
+ postgresql: {
724
+ code: "SELECT table_name, column_name, udt_name, column_default, is_nullable, table_schema FROM information_schema.columns WHERE table_schema != 'pg_catalog' AND table_schema != 'information_schema'",
725
+ processingFn: (c) => {
726
+ let L = c.reduce((c, L) => {
727
+ let R = L.table_schema;
728
+ return delete L.table_schema, c[R] = c[R] || [], (L.table_name || L.column_name) && c[R].push(L), c;
729
+ }, {}), R = {};
730
+ for (let c in L) R[c] = L[c].reduce((c, L) => {
731
+ let R = L.table_name;
732
+ delete L.table_name, c[R] = c[R] || {};
733
+ let z = {
734
+ type: L.udt_name,
735
+ required: L.is_nullable === "NO"
736
+ };
737
+ return L.column_default && (z.default = L.column_default), c[R][L.column_name] = z, c;
738
+ }, {});
739
+ return R;
740
+ },
741
+ lang: "postgresql",
742
+ argName: "database"
743
+ },
744
+ mysql: {
745
+ code: "SELECT DATABASE() AS default_db_name, TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT FROM information_schema.columns WHERE table_schema = DATABASE() OR table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys', '_vt');",
746
+ processingFn: (c) => {
747
+ let L = c.reduce((c, L) => {
748
+ let R = L.TABLE_SCHEMA;
749
+ return delete L.TABLE_SCHEMA, c[R] = c[R] || [], c[R].push(L), c;
750
+ }, {}), R = {};
751
+ for (let c in L) R[c] = L[c].reduce((c, L) => {
752
+ let R = L.TABLE_NAME;
753
+ delete L.TABLE_NAME, c[R] = c[R] || {};
754
+ let z = {
755
+ type: L.DATA_TYPE,
756
+ required: L.is_nullable === "NO"
757
+ };
758
+ return L.column_default && (z.default = L.COLUMN_DEFAULT), c[R][L.COLUMN_NAME] = z, c;
759
+ }, {});
760
+ return R;
761
+ },
762
+ lang: "mysql",
763
+ argName: "database"
764
+ },
765
+ graphql: {
766
+ code: getIntrospectionQuery(),
767
+ lang: "graphql",
768
+ argName: "api"
769
+ },
770
+ bigquery: {
771
+ code: "import { BigQuery } from '@google-cloud/bigquery@7.5.0';\nexport async function main(args: bigquery) {\nconst bq = new BigQuery({\n credentials: args\n})\nconst [datasets] = await bq.getDatasets();\nconst schema = {}\nfor (const dataset of datasets) {\n schema[dataset.id] = {}\n const query = \"SELECT table_name, ARRAY_AGG(STRUCT(if(is_nullable = 'YES', true, false) AS required, column_name AS name, data_type AS type, if(column_default = 'NULL', null, column_default) AS `default`) ORDER BY ordinal_position) AS schema FROM `{dataset.id}`.INFORMATION_SCHEMA.COLUMNS GROUP BY table_name\".replace('{dataset.id}', dataset.id)\n const [rows] = await bq.query(query)\n for (const row of rows) {\n schema[dataset.id][row.table_name] = {}\n for (const col of row.schema) {\n const colName = col.name\n delete col.name\n if (col.default === null) {\n delete col.default\n }\n schema[dataset.id][row.table_name][colName] = col\n }\n }\n}\nreturn schema\n}",
772
+ lang: "bun",
773
+ argName: "args"
774
+ },
775
+ snowflake: {
776
+ code: "select TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE from information_schema.columns where table_schema != 'INFORMATION_SCHEMA'",
777
+ lang: "snowflake",
778
+ processingFn: (c) => {
779
+ let L = {};
780
+ for (let R of c) R.TABLE_SCHEMA in L || (L[R.TABLE_SCHEMA] = {}), R.TABLE_NAME in L[R.TABLE_SCHEMA] || (L[R.TABLE_SCHEMA][R.TABLE_NAME] = {}), L[R.TABLE_SCHEMA][R.TABLE_NAME][R.COLUMN_NAME] = {
781
+ type: R.DATA_TYPE,
782
+ required: R.IS_NULLABLE === "YES"
783
+ }, R.COLUMN_DEFAULT !== null && (L[R.TABLE_SCHEMA][R.TABLE_NAME][R.COLUMN_NAME].default = R.COLUMN_DEFAULT);
784
+ return L;
785
+ },
786
+ argName: "database"
787
+ },
788
+ snowflake_oauth: {
789
+ code: "select TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE from information_schema.columns where table_schema != 'INFORMATION_SCHEMA'",
790
+ lang: "snowflake",
791
+ processingFn: (c) => {
792
+ let L = {};
793
+ for (let R of c) R.TABLE_SCHEMA in L || (L[R.TABLE_SCHEMA] = {}), R.TABLE_NAME in L[R.TABLE_SCHEMA] || (L[R.TABLE_SCHEMA][R.TABLE_NAME] = {}), L[R.TABLE_SCHEMA][R.TABLE_NAME][R.COLUMN_NAME] = {
794
+ type: R.DATA_TYPE,
795
+ required: R.IS_NULLABLE === "YES"
796
+ }, R.COLUMN_DEFAULT !== null && (L[R.TABLE_SCHEMA][R.TABLE_NAME][R.COLUMN_NAME].default = R.COLUMN_DEFAULT);
797
+ return L;
798
+ },
799
+ argName: "database"
800
+ },
801
+ mssql: {
802
+ argName: "database",
803
+ code: "select TABLE_SCHEMA, TABLE_NAME, DATA_TYPE, COLUMN_NAME, COLUMN_DEFAULT from information_schema.columns where table_schema != 'sys'",
804
+ lang: "mssql",
805
+ processingFn: (c) => {
806
+ if (!c || c.length === 0) return {};
807
+ let L = c.reduce((c, L) => {
808
+ let R = L.TABLE_SCHEMA;
809
+ return delete L.TABLE_SCHEMA, c[R] = c[R] || [], c[R].push(L), c;
810
+ }, {}), R = {};
811
+ for (let c in L) R[c] = L[c].reduce((c, L) => {
812
+ let R = L.TABLE_NAME;
813
+ delete L.TABLE_NAME, c[R] = c[R] || {};
814
+ let z = {
815
+ type: L.DATA_TYPE,
816
+ required: L.is_nullable === "NO"
817
+ };
818
+ return L.column_default && (z.default = L.COLUMN_DEFAULT), c[R][L.COLUMN_NAME] = z, c;
819
+ }, {});
820
+ return R;
821
+ }
822
+ }
823
+ };
824
+ ({ ...legacyScripts }), { ...legacyScripts.postgresql };
825
+ function buildVisibleFieldList(c, L) {
826
+ return c.filter((c) => c && c.ignored !== !0).map((c) => renderDbQuotedIdentifier(c?.field, L));
827
+ }
828
+ function renderDbQuotedIdentifier(c, L) {
829
+ switch (L) {
830
+ case "postgresql": return `"${c}"`;
831
+ case "ms_sql_server": return `[${c}]`;
832
+ case "mysql": return `\`${c}\``;
833
+ case "snowflake": return `"${c}"`;
834
+ case "bigquery": return `\`${c}\``;
835
+ case "duckdb": return `"${c}"`;
836
+ default: throw Error("Unsupported database type: " + L);
837
+ }
838
+ }
839
+ function getLanguageByResourceType(c) {
840
+ return {
841
+ postgresql: "postgresql",
842
+ mysql: "mysql",
843
+ ms_sql_server: "mssql",
844
+ mssql: "mssql",
845
+ snowflake: "snowflake",
846
+ snowflake_oauth: "snowflake",
847
+ bigquery: "bigquery",
848
+ duckdb: "duckdb"
849
+ }[c];
850
+ }
851
+ function buildParameters(c, L) {
852
+ return c.map((c, R) => {
853
+ switch (L) {
854
+ case "postgresql": return `-- $${R + 1} ${c.field}`;
855
+ case "mysql": return `-- :${c.field} (${c.datatype.split("(")[0]})`;
856
+ case "ms_sql_server": return `-- @p${R + 1} ${c.field} (${c.datatype.split("(")[0]})`;
857
+ case "snowflake": return `-- ? ${c.field} (${c.datatype.split("(")[0]})`;
858
+ case "bigquery": return `-- @${c.field} (${c.datatype.split("(")[0]})`;
859
+ case "duckdb": return `-- $${c.field} (${c.datatype.split("(")[0]})`;
860
+ }
861
+ }).join("\n");
862
+ }
863
+ function getPrimaryKeys(c) {
864
+ let L = c?.filter((c) => c.isprimarykey)?.map((c) => c.field) ?? [];
865
+ return L?.length === 0 && (L = c?.map((c) => c.field) ?? []), L ?? [];
866
+ }
867
+ function makeCountQuery(c, L, R = void 0, z) {
868
+ let B = " WHERE ", V = " AND ", H = "", U = buildParameters([{
869
+ field: "quicksearch",
870
+ datatype: c === "bigquery" ? "string" : "text"
871
+ }], c);
872
+ U += "\n", R && (H = ` ${R} AND `);
873
+ let W = buildVisibleFieldList(z, c);
874
+ switch (c) {
875
+ case "mysql":
876
+ W.length > 0 ? H += ` (:quicksearch = '' OR CONCAT_WS(' ', ${W.join(", ")}) LIKE CONCAT('%', :quicksearch, '%'))` : H += " (:quicksearch = '' OR 1 = 1)", U += `SELECT COUNT(*) as count FROM ${L}`;
877
+ break;
878
+ case "postgresql":
879
+ W.length > 0 ? H += `($1 = '' OR CONCAT(${W.join(", ")}) ILIKE '%' || $1 || '%')` : H += "($1 = '' OR 1 = 1)", U += `SELECT COUNT(*) as count FROM ${L}`;
880
+ break;
881
+ case "ms_sql_server":
882
+ W.length > 0 ? H += `(@p1 = '' OR CONCAT(${W.join(", +")}) LIKE '%' + @p1 + '%')` : H += "(@p1 = '' OR 1 = 1)", U += `SELECT COUNT(*) as count FROM [${L}]`;
883
+ break;
884
+ case "snowflake":
885
+ U = "", W.length > 0 ? (U += buildParameters([{
886
+ field: "quicksearch",
887
+ datatype: "text"
888
+ }, {
889
+ field: "quicksearch",
890
+ datatype: "text"
891
+ }], c), U += "\n", H += `(? = '' OR CONCAT(${W.join(", ")}) ILIKE '%' || ? || '%')`) : (U += buildParameters([{
892
+ field: "quicksearch",
893
+ datatype: "text"
894
+ }], c), U += "\n", H += "(? = '' OR 1 = 1)"), U += `SELECT COUNT(*) as count FROM ${L}`;
895
+ break;
896
+ case "bigquery":
897
+ if (W.length > 0) {
898
+ let c = W.map((c) => {
899
+ let L = z.find((L) => L.field === c.slice(1, -1));
900
+ return L?.datatype === "JSON" || L?.datatype.startsWith("STRUCT") || L?.datatype.startsWith("ARRAY") ? `TO_JSON_STRING(${c})` : `${c}`;
901
+ }).join(",");
902
+ H += `(@quicksearch = '' OR REGEXP_CONTAINS(CONCAT(${c}), '(?i)' || @quicksearch))`;
903
+ } else H += "(@quicksearch = '' OR 1 = 1)";
904
+ U += `SELECT COUNT(*) as count FROM \`${L}\``;
905
+ break;
906
+ case "duckdb":
907
+ W.length > 0 ? H += ` ($quicksearch = '' OR CONCAT(' ', ${W.join(", ")}) LIKE CONCAT('%', $quicksearch, '%'))` : H += " ($quicksearch = '' OR 1 = 1)", U += `SELECT COUNT(*) as count FROM ${L}`;
908
+ break;
909
+ default: throw Error("Unsupported database type:" + c);
910
+ }
911
+ return R ? U += `${B}${H}` : (U += c === "ms_sql_server" && !R ? B : V, U += H), !R && (c === "mysql" || c === "postgresql" || c === "snowflake" || c === "bigquery" || c === "duckdb") && (U = U.replace(`${V}`, B)), U;
912
+ }
913
+ function getCountInput(c, L, R, z) {
914
+ if (c.type == "ducklake" && !c.ducklake || c.type == "database" && !c.resourcePath || !L || !R?.length) return;
915
+ let B = c.type === "ducklake" ? "duckdb" : c.resourceType, V = makeCountQuery(B, L, z, R);
916
+ return c.type === "ducklake" && (V = wrapDucklakeQuery(V, c.ducklake)), {
917
+ runnable: {
918
+ name: "AppDbExplorer",
919
+ type: "inline",
920
+ inlineScript: {
921
+ content: V,
922
+ language: getLanguageByResourceType(B),
923
+ schema: {
924
+ $schema: "https://json-schema.org/draft/2020-12/schema",
925
+ properties: c.type === "database" ? { database: {
926
+ description: "Database name",
927
+ type: "object",
928
+ format: `resource-${B}`
929
+ } } : {},
930
+ required: ["database"],
931
+ type: "object"
932
+ }
933
+ }
934
+ },
935
+ fields: c.type === "database" ? { database: {
936
+ type: "static",
937
+ value: `$res:${c.resourcePath}`,
938
+ fieldType: "object",
939
+ format: `resource-${B}`
940
+ } } : {},
941
+ type: "runnable",
942
+ fieldType: "object"
943
+ };
944
+ }
945
+ function makeDeleteQuery(c, L, R) {
946
+ let z = buildParameters(R === "snowflake" ? L.flatMap((c) => [c, c]) : L, R);
947
+ switch (R) {
948
+ case "postgresql": {
949
+ let R = L.map((c, L) => `($${L + 1}::text::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${L + 1}::text::${c.datatype})`).join("\n AND ");
950
+ return z += `\nDELETE FROM ${c} \nWHERE ${R} RETURNING 1;`, z;
951
+ }
952
+ case "mysql": {
953
+ let R = L.map((c) => `(:${c.field} IS NULL AND ${c.field} IS NULL OR ${c.field} = :${c.field})`).join("\n AND ");
954
+ return z += `\nDELETE FROM ${c} \nWHERE ${R}`, z;
955
+ }
956
+ case "ms_sql_server": {
957
+ let R = L.map((c, L) => `(@p${L + 1} IS NULL AND ${c.field} IS NULL OR ${c.field} = @p${L + 1})`).join("\n AND ");
958
+ return z += `\nDELETE FROM ${c} \nWHERE ${R}`, z;
959
+ }
960
+ case "snowflake": {
961
+ let R = L.map((c, L) => `(? = 'null' AND ${c.field} IS NULL OR ${c.field} = ?)`).join("\n AND ");
962
+ return z += `\nDELETE FROM ${c} \nWHERE ${R}`, z;
963
+ }
964
+ case "bigquery": {
965
+ let R = L.map((c, L) => `(CAST(@${c.field} AS STRING) = 'null' AND ${c.field} IS NULL OR ${c.field} = @${c.field})`).join("\n AND ");
966
+ return z += `\nDELETE FROM ${c} \nWHERE ${R}`, z;
967
+ }
968
+ case "duckdb": {
969
+ let R = L.map((c) => `($${c.field} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${c.field})`).join("\n AND ");
970
+ return z += `\nDELETE FROM ${c} \nWHERE ${R}`, z;
971
+ }
972
+ default: throw Error("Unsupported database type");
973
+ }
974
+ }
975
+ function getDeleteInput(c, L, R) {
976
+ if (c.type == "ducklake" && !c.ducklake || c.type == "database" && !c.resourcePath || !L) return;
977
+ let z = c.type === "ducklake" ? "duckdb" : c.resourceType, B = makeDeleteQuery(L, R, z);
978
+ return c.type === "ducklake" && (B = wrapDucklakeQuery(B, c.ducklake)), {
979
+ runnable: {
980
+ name: "AppDbExplorer",
981
+ type: "inline",
982
+ inlineScript: {
983
+ content: B,
984
+ language: getLanguageByResourceType(z),
985
+ schema: {
986
+ $schema: "https://json-schema.org/draft/2020-12/schema",
987
+ properties: {},
988
+ required: ["database"],
989
+ type: "object"
990
+ }
991
+ }
992
+ },
993
+ fields: c.type == "database" ? { database: {
994
+ type: "static",
995
+ value: `$res:${c.resourcePath}`,
996
+ fieldType: "object",
997
+ format: `resource-${z}`
998
+ } } : {},
999
+ type: "runnable",
1000
+ fieldType: "object"
1001
+ };
1002
+ }
1003
+ function formatInsertValues(c, L, R = 1) {
1004
+ switch (L) {
1005
+ case "mysql": return c.map((c) => `:${c.field}`).join(", ");
1006
+ case "postgresql": return c.map((c, L) => `$${R + L}::${c.datatype}`).join(", ");
1007
+ case "ms_sql_server": return c.map((c, L) => `@p${R + L}`).join(", ");
1008
+ case "snowflake": return c.map(() => "?").join(", ");
1009
+ case "bigquery": return c.map((c) => `@${c.field}`).join(", ");
1010
+ case "duckdb": return c.map((c) => `$${c.field}`).join(", ");
1011
+ default: throw Error("Unsupported database type");
1012
+ }
1013
+ }
1014
+ function formatColumnNames(c) {
1015
+ return c.map((c) => c.field).join(", ");
1016
+ }
1017
+ function getUserDefaultValue(c) {
1018
+ if (c.defaultValueNull) return "NULL";
1019
+ if (c.defaultUserValue) return typeof c.defaultUserValue == "string" ? `'${c.defaultUserValue}'` : c.defaultUserValue;
1020
+ }
1021
+ function formatDefaultValues(c) {
1022
+ return c.map((c) => {
1023
+ let L = getUserDefaultValue(c);
1024
+ return c.overrideDefaultValue === !0 ? L : L ?? c.defaultvalue;
1025
+ }).join(", ");
1026
+ }
1027
+ function shouldOmitColumnInInsert(c) {
1028
+ if (!c.hideInsert || c.isidentity === ColumnIdentity.Always) return !0;
1029
+ let L = c.defaultUserValue !== void 0 && c.defaultUserValue !== "" || c.defaultValueNull === !0, R = !!c.defaultvalue;
1030
+ if (c.isnullable === "NO") {
1031
+ if (!L && !R && c.isidentity === ColumnIdentity.No) throw Error(`Column ${c.field} is not nullable and has no default value`);
1032
+ return !L && !R ? c.isidentity !== ColumnIdentity.No : !L && R;
1033
+ } else if (c.isnullable === "YES") return !L;
1034
+ return !1;
1035
+ }
1036
+ function makeInsertQuery(c, L, R) {
1037
+ if (!c) throw Error("Table name is required");
1038
+ let z = L.filter((c) => !c.hideInsert && !(R == "postgresql" && c.defaultvalue?.startsWith("nextval("))), B = L.filter((c) => !shouldOmitColumnInInsert(c)), V = z.concat(B), H = buildParameters(z, R);
1039
+ H += "\n";
1040
+ let U = B.length > 0, W = formatColumnNames(V), G = formatInsertValues(z, R), K = formatDefaultValues(B), q = `${G}${U ? ", " : ""}${K}`;
1041
+ return q.trim() ? (H += `INSERT INTO ${c} (${W}) VALUES (${q})`, H) : `INSERT INTO ${c} DEFAULT VALUES`;
1042
+ }
1043
+ function getInsertInput(c, L, R) {
1044
+ let z = c.type === "ducklake" ? "duckdb" : c.resourceType, B = makeInsertQuery(L, R, z);
1045
+ return c.type === "ducklake" && (B = wrapDucklakeQuery(B, c.ducklake)), {
1046
+ runnable: {
1047
+ name: "AppDbExplorer",
1048
+ type: "inline",
1049
+ inlineScript: {
1050
+ content: B,
1051
+ language: getLanguageByResourceType(z),
1052
+ schema: {
1053
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1054
+ properties: {},
1055
+ required: ["database"],
1056
+ type: "object"
1057
+ }
1058
+ }
1059
+ },
1060
+ fields: c.type === "database" ? { database: {
1061
+ type: "static",
1062
+ value: `$res:${c.resourcePath}`,
1063
+ fieldType: "object",
1064
+ format: `resource-${z}`
1065
+ } } : {},
1066
+ type: "runnable",
1067
+ fieldType: "object"
1068
+ };
1069
+ }
1070
+ function makeSnowflakeSelectQuery(c, L, R, z) {
1071
+ let B = coerceToNumber(z?.limit) || 100, V = coerceToNumber(z?.offset) || 0, H = [{
1072
+ field: "quicksearch",
1073
+ datatype: "text"
1074
+ }], U = "";
1075
+ U += "\n";
1076
+ let W = buildVisibleFieldList(L, "snowflake"), G = W.join(", ");
1077
+ U += `SELECT ${G} FROM ${c}`;
1078
+ let K = ["LENGTH(?) = 0", ...W.map((c) => (H.push({
1079
+ field: "quicksearch",
1080
+ datatype: "text"
1081
+ }), `CONCAT(${c}) ILIKE CONCAT('%', ?, '%')`))].join(" OR ");
1082
+ R ? U += ` WHERE ${R} AND (${K})` : U += ` WHERE ${K}`;
1083
+ let q = L.map((c) => (H.push({
1084
+ field: "order_by",
1085
+ datatype: "text"
1086
+ }, {
1087
+ field: "is_desc",
1088
+ datatype: "boolean"
1089
+ }, {
1090
+ field: "order_by",
1091
+ datatype: "text"
1092
+ }, {
1093
+ field: "is_desc",
1094
+ datatype: "boolean"
1095
+ }), `CASE WHEN ? = '${c.field}' AND ? = FALSE THEN "${c.field}" END ASC,
1096
+ CASE WHEN ? = '${c.field}' AND ? = TRUE THEN "${c.field}" END DESC`));
1097
+ return U += ` ORDER BY ${q.join(",\n")}`, U += ` LIMIT ${B} OFFSET ${V}`, U = buildParameters(H, "snowflake") + "\n" + U, U;
1098
+ }
1099
+ function makeSelectQuery(c, L, R, z, B, V) {
1100
+ if (!c) throw Error("Table name is required");
1101
+ let H = "", U = buildParameters([
1102
+ {
1103
+ field: "limit",
1104
+ datatype: z === "bigquery" ? "integer" : "int"
1105
+ },
1106
+ {
1107
+ field: "offset",
1108
+ datatype: z === "bigquery" ? "integer" : "int"
1109
+ },
1110
+ {
1111
+ field: "quicksearch",
1112
+ datatype: z === "bigquery" ? "string" : "text"
1113
+ },
1114
+ {
1115
+ field: "order_by",
1116
+ datatype: z === "bigquery" ? "string" : "text"
1117
+ },
1118
+ {
1119
+ field: "is_desc",
1120
+ datatype: z === "bigquery" ? "bool" : "boolean"
1121
+ }
1122
+ ], z);
1123
+ U += "\n";
1124
+ let W = buildVisibleFieldList(L, z), G = W.join(", ");
1125
+ switch (z) {
1126
+ case "mysql": {
1127
+ let z = L.map((c) => `
1128
+ CASE WHEN :order_by = '${c.field}' AND :is_desc IS false THEN \`${c.field}\` END,
1129
+ CASE WHEN :order_by = '${c.field}' AND :is_desc IS true THEN \`${c.field}\` END DESC`).join(",\n");
1130
+ H = ` (:quicksearch = '' OR CONCAT_WS(' ', ${W.join(", ")}) LIKE CONCAT('%', :quicksearch, '%'))`, U += `SELECT ${G} FROM ${c}`, U += ` WHERE ${R ? `${R} AND` : ""} ${H}`, U += ` ORDER BY ${z}`, U += " LIMIT :limit OFFSET :offset";
1131
+ break;
1132
+ }
1133
+ case "postgresql": {
1134
+ function z({ field: c, is_desc: L = !1, text_cast: R = !1, check_is_number: z }) {
1135
+ return `(CASE WHEN${z === !0 ? ` pg_typeof("${c}")::text IN ('integer', 'bigint', 'smallint', 'numeric', 'real', 'double precision') AND` : z === !1 ? ` pg_typeof("${c}")::text NOT IN ('integer', 'bigint', 'smallint', 'numeric', 'real', 'double precision') AND` : ""} $4 = '${c}' AND $5 IS ${L} THEN "${c}"${R ? "::text" : ""} END)${L ? " DESC" : ""}`;
1136
+ }
1137
+ let B = `
1138
+ ${L.map((c) => V?.fixPgIntTypes ? `
1139
+ ${z({
1140
+ field: c.field,
1141
+ is_desc: !1,
1142
+ text_cast: !0,
1143
+ check_is_number: !1
1144
+ })},
1145
+ ${z({
1146
+ field: c.field,
1147
+ is_desc: !1,
1148
+ text_cast: !1,
1149
+ check_is_number: !0
1150
+ })},
1151
+ ${z({
1152
+ field: c.field,
1153
+ is_desc: !0,
1154
+ text_cast: !0,
1155
+ check_is_number: !1
1156
+ })},
1157
+ ${z({
1158
+ field: c.field,
1159
+ is_desc: !0,
1160
+ text_cast: !1,
1161
+ check_is_number: !0
1162
+ })}` : `
1163
+ ${z({
1164
+ field: c.field,
1165
+ is_desc: !1,
1166
+ text_cast: !0
1167
+ })},
1168
+ ${z({
1169
+ field: c.field,
1170
+ is_desc: !0,
1171
+ text_cast: !0
1172
+ })}`).join(",\n")}`;
1173
+ H = `($3 = '' OR CONCAT(${W.join(", ")}) ILIKE '%' || $3 || '%')`, U += `SELECT ${W.map((c) => `${c}::text`).join(", ")} FROM ${c}\n`, U += ` WHERE ${R ? `${R} AND` : ""} ${H}\n`, U += ` ORDER BY ${B}\n`, U += " LIMIT $1::INT OFFSET $2::INT";
1174
+ break;
1175
+ }
1176
+ case "ms_sql_server": {
1177
+ let z = [
1178
+ "text",
1179
+ "ntext",
1180
+ "image"
1181
+ ], B = L.filter((c) => !z.includes(c.datatype.toLowerCase())).map((c) => `
1182
+ (CASE WHEN @p4 = '${c.field}' AND @p5 = 0 THEN ${c.field} END) ASC,
1183
+ (CASE WHEN @p4 = '${c.field}' AND @p5 = 1 THEN ${c.field} END) DESC`).join(",\n"), V = W.filter((c) => {
1184
+ let R = c.slice(1, -1), B = L.find((c) => c.field === R);
1185
+ return !z.includes(B?.datatype.toLowerCase() ?? "");
1186
+ }).join(", ");
1187
+ H = V ? ` (@p3 = '' OR CONCAT(${V}) LIKE '%' + @p3 + '%')` : " (@p3 = '')", U += `SELECT ${G} FROM ${c}`, U += ` WHERE ${R ? `${R} AND` : ""} ${H}`, U += ` ORDER BY ${B}`, U += " OFFSET @p2 ROWS FETCH NEXT @p1 ROWS ONLY";
1188
+ break;
1189
+ }
1190
+ case "snowflake": return makeSnowflakeSelectQuery(c, L, R, B);
1191
+ case "bigquery": {
1192
+ let z = L.map((c) => c.datatype === "JSON" || c.datatype.startsWith("STRUCT") || c.datatype.startsWith("ARRAY") || c.datatype === "GEOGRAPHY" ? `
1193
+ (CASE WHEN @order_by = '${c.field}' AND @is_desc = false THEN TO_JSON_STRING(${c.field}) END) ASC,
1194
+ (CASE WHEN @order_by = '${c.field}' AND @is_desc = true THEN TO_JSON_STRING(${c.field}) END) DESC` : `
1195
+ (CASE WHEN @order_by = '${c.field}' AND @is_desc = false THEN ${c.field} END) ASC,
1196
+ (CASE WHEN @order_by = '${c.field}' AND @is_desc = true THEN ${c.field} END) DESC`).join(",\n");
1197
+ H = ` (@quicksearch = '' OR REGEXP_CONTAINS(CONCAT(${W.map((c) => {
1198
+ let R = L.find((L) => L.field === c.slice(1, -1));
1199
+ return R?.datatype === "JSON" || R?.datatype.startsWith("STRUCT") || R?.datatype.startsWith("ARRAY") || R?.datatype === "GEOGRAPHY" ? `TO_JSON_STRING(${c})` : `CAST(${c} AS STRING)`;
1200
+ }).join(",")}), '(?i)' || @quicksearch))`, U += `SELECT ${G} FROM ${c}`, U += ` WHERE ${R ? `${R} AND` : ""} ${H}`, U += ` ORDER BY ${z}`, U += " LIMIT @limit OFFSET @offset";
1201
+ break;
1202
+ }
1203
+ case "duckdb": {
1204
+ let z = `
1205
+ ${L.map((c) => `
1206
+ (CASE WHEN $order_by = '${c.field}' AND $is_desc IS false THEN "${c.field}"::text END),
1207
+ (CASE WHEN $order_by = '${c.field}' AND $is_desc IS true THEN "${c.field}"::text END) DESC`).join(",\n")}`;
1208
+ H = `($quicksearch = '' OR CONCAT(${W.join(", ")}) ILIKE '%' || $quicksearch || '%')`, U += `SELECT ${W.join(", ")} FROM ${c}\n`, U += ` WHERE ${R ? `${R} AND` : ""} ${H}\n`, U += ` ORDER BY ${z}\n`, U += " LIMIT $limit::INT OFFSET $offset::INT";
1209
+ break;
1210
+ }
1211
+ default: throw Error("Unsupported database type");
1212
+ }
1213
+ return U;
1214
+ }
1215
+ function coerceToNumber(c) {
1216
+ return typeof c == "number" ? c : typeof c == "string" ? parseInt(c, 10) : 0;
1217
+ }
1218
+ function getSelectInput(c, L, R, z, B) {
1219
+ if (c.type == "ducklake" && !c.ducklake || c.type == "database" && !c.resourcePath || !L || !R?.length) return;
1220
+ let V = c.type === "ducklake" ? "duckdb" : c.resourceType, H = makeSelectQuery(L, R, z, V, B);
1221
+ return c.type === "ducklake" && (H = wrapDucklakeQuery(H, c.ducklake)), {
1222
+ runnable: {
1223
+ name: "AppDbExplorer",
1224
+ type: "inline",
1225
+ inlineScript: {
1226
+ content: H,
1227
+ language: getLanguageByResourceType(V)
1228
+ }
1229
+ },
1230
+ fields: c.type === "database" ? { database: {
1231
+ type: "static",
1232
+ value: `$res:${c.resourcePath}`,
1233
+ fieldType: "object",
1234
+ format: `resource-${V}`
1235
+ } } : {},
1236
+ type: "runnable",
1237
+ fieldType: "object",
1238
+ hideRefreshButton: !0
1239
+ };
1240
+ }
1241
+ function makeUpdateQuery(c, L, R, z) {
1242
+ let B = buildParameters([{
1243
+ field: "value_to_update",
1244
+ datatype: L.datatype
1245
+ }, ...z === "snowflake" ? R.flatMap((c) => [c, c]) : R], z);
1246
+ switch (B += "\n", z) {
1247
+ case "postgresql": {
1248
+ let z = R.map((c, L) => `($${L + 2}::text::${c.datatype} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${L + 2}::text::${c.datatype})`).join("\n AND ");
1249
+ return B += `\nUPDATE ${c} SET ${L.field} = $1::text::${L.datatype} \nWHERE ${z} RETURNING 1`, B;
1250
+ }
1251
+ case "mysql": {
1252
+ let z = R.map((c) => `(:${c.field} IS NULL AND ${c.field} IS NULL OR ${c.field} = :${c.field})`).join("\n AND ");
1253
+ return B += `\nUPDATE ${c} SET ${L.field} = :value_to_update \nWHERE ${z}`, B;
1254
+ }
1255
+ case "ms_sql_server": {
1256
+ let z = R.map((c, L) => `(@p${L + 2} IS NULL AND ${c.field} IS NULL OR ${c.field} = @p${L + 2})`).join("\n AND ");
1257
+ return B += `\nUPDATE ${c} SET ${L.field} = @p1 \nWHERE ${z}`, B;
1258
+ }
1259
+ case "snowflake": {
1260
+ let z = R.map((c, L) => `(? = 'null' AND ${c.field} IS NULL OR ${c.field} = ?)`).join("\n AND ");
1261
+ return B += `\nUPDATE ${c} SET ${L.field} = ? \nWHERE ${z}`, B;
1262
+ }
1263
+ case "bigquery": {
1264
+ let z = R.map((c, L) => `(CAST(@${c.field} AS STRING) = 'null' AND ${c.field} IS NULL OR ${c.field} = @${c.field})`).join("\n AND ");
1265
+ return B += `\nUPDATE ${c} SET ${L.field} = @value_to_update \nWHERE ${z}`, B;
1266
+ }
1267
+ case "duckdb": {
1268
+ let z = R.map((c) => `($${c.field} IS NULL AND ${c.field} IS NULL OR ${c.field} = $${c.field})`).join("\n AND ");
1269
+ return B += `\nUPDATE ${c} SET ${L.field} = $value_to_update \nWHERE ${z}`, B;
1270
+ }
1271
+ default: throw Error("Unsupported database type");
1272
+ }
1273
+ }
1274
+ function getUpdateInput(c, L, R, z) {
1275
+ if (c.type == "ducklake" && !c.ducklake || c.type == "database" && !c.resourcePath || !L) return;
1276
+ let B = c.type === "ducklake" ? "duckdb" : c.resourceType, V = makeUpdateQuery(L, R, z, B);
1277
+ return c.type === "ducklake" && (V = wrapDucklakeQuery(V, c.ducklake)), {
1278
+ runnable: {
1279
+ name: "AppDbExplorer",
1280
+ type: "inline",
1281
+ inlineScript: {
1282
+ content: V,
1283
+ language: getLanguageByResourceType(B),
1284
+ schema: {
1285
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1286
+ properties: {},
1287
+ required: ["database"],
1288
+ type: "object"
1289
+ }
1290
+ }
1291
+ },
1292
+ fields: c.type === "database" ? { database: {
1293
+ type: "static",
1294
+ value: `$res:${c.resourcePath}`,
1295
+ fieldType: "object",
1296
+ format: `resource-${B}`
1297
+ } } : {},
1298
+ type: "runnable",
1299
+ fieldType: "object"
1300
+ };
1301
+ }
1302
+ function isRunnableByPath(c) {
1303
+ return c?.type == "runnableByPath" || c?.type == "path";
1304
+ }
1305
+ function isRunnableByName(c) {
1306
+ return c?.type == "runnableByName" || c?.type == "inline";
1307
+ }
1308
+ function findGridItemById(c, L, R) {
1309
+ for (let z of allItems(c, L)) if (z.id === R) return z;
1310
+ }
1311
+ function allItems(c, L) {
1312
+ return L == null ? c ?? [] : [...c ?? [], ...Object.values(L).flat()];
1313
+ }
1314
+ function findGridItem(c, L) {
1315
+ return findGridItemById(c.grid, c.subgrids, L);
1316
+ }
1317
+ function collectOneOfFields(c, L) {
1318
+ return Object.fromEntries(Object.entries(c ?? {}).filter(([c, L]) => L.type == "evalv2").map(([c, R]) => {
1319
+ let z = R;
1320
+ if (!z.connections || z.connections.length !== 1) return [c, void 0];
1321
+ let B = z.connections[0], V = findGridItem(L, B.componentId);
1322
+ if (z.expr !== B.componentId + "." + B.id) return [c, void 0];
1323
+ if (V) {
1324
+ let L = V.data;
1325
+ if (L && (L.type === "resourceselectcomponent" || L.type === "selectcomponent" || L.type === "multiselectcomponent" || L.type === "multiselectcomponentv2")) {
1326
+ if ((L.type === "selectcomponent" || L.type === "multiselectcomponent" || L.type === "multiselectcomponentv2") && L.configuration?.create?.type === "static" && L.configuration?.create?.value === !0) return [c, void 0];
1327
+ if (L.configuration?.items?.type === "static") {
1328
+ let R = L.configuration.items.value;
1329
+ if (R && Array.isArray(R)) return L.type === "multiselectcomponent" || L.type === "multiselectcomponentv2" ? [c, R] : [c, R.filter((c) => c && typeof c == "object" && "value" in c && c.value).map((c) => c.value)];
1330
+ }
1331
+ }
1332
+ }
1333
+ return [c, void 0];
1334
+ }).filter(([c, L]) => L !== void 0));
1335
+ }
1336
+ function filenameExprToRegex(c) {
1337
+ return `^${c.replaceAll("${file.name}", "<file_name>").slice(1, -1).replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replaceAll("<file_name>", "[^/]+")}$`;
1338
+ }
1339
+ function staticToRegex(c) {
1340
+ return `^${c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
1341
+ }
1342
+ function checkIfExprIsString(c) {
1343
+ return /^(['"`])[^'"`]*\1$/g.test(c);
1344
+ }
1345
+ function checkIfEvalIsStringWithFilename(c) {
1346
+ return c.connections.length > 0 ? !1 : checkIfExprIsString(c.expr.replaceAll("${file.name}", ""));
1347
+ }
1348
+ function removeResourcePrefix(c) {
1349
+ return c.replace(/^\$res:/, "");
1350
+ }
1351
+ function computeWorkspaceS3FileInputPolicy() {
1352
+ return {
1353
+ allow_workspace_resource: !0,
1354
+ allowed_resources: [],
1355
+ allow_user_resources: !1,
1356
+ file_key_regex: ""
1357
+ };
1358
+ }
1359
+ function computeS3FileInputPolicy(c, L) {
1360
+ let R = c?.resource, z = c?.pathTemplate, B = !R || R.type === "static" && !R.value, V = R ? R.type === "static" ? R.value ? [removeResourcePrefix(R.value)] : [] : collectOneOfFields({ s3_resource: R }, L).s3_resource?.map((c) => removeResourcePrefix(c)) ?? [] : [], H = (R?.type === "evalv2" && R?.allowUserResources) ?? !1, U = "^.*$";
1361
+ return z && (z.type === "static" ? U = staticToRegex(z.value) : z.type === "evalv2" && checkIfEvalIsStringWithFilename(z) && (U = filenameExprToRegex(z.expr))), {
1362
+ allow_workspace_resource: B,
1363
+ allowed_resources: V,
1364
+ allow_user_resources: H,
1365
+ file_key_regex: U
1366
+ };
1367
+ }
1368
+ function isPartialS3Object(c) {
1369
+ return typeof c == "object" && !!c && typeof c.s3 == "string";
1370
+ }
1371
+ function computeS3FileViewerPolicy(c) {
1372
+ if (c.source.type === "uploadS3" && isPartialS3Object(c.source.value)) return {
1373
+ s3_path: c.source.value.s3,
1374
+ storage: c.source.value.storage
1375
+ };
1376
+ if (c.source.type === "static" && typeof c.source.value == "string" && (c.sourceKind.type === "static" && c.sourceKind.value === "s3 (workspace storage)" || c.source.value.startsWith("s3://"))) return {
1377
+ s3_path: c.source.value.replace("s3://", ""),
1378
+ storage: void 0
1379
+ };
1380
+ }
1381
+ function collectStaticFields(c) {
1382
+ return Object.fromEntries(Object.entries(c ?? {}).filter(([c, L]) => L.type == "static").map(([c, L]) => [c, L.value]));
1383
+ }
1384
+ async function hash(c) {
1385
+ try {
1386
+ let L = new TextEncoder().encode(c), R = await crypto.subtle.digest("SHA-256", L);
1387
+ return Array.from(new Uint8Array(R)).map((c) => c.toString(16).padStart(2, "0")).join("");
1388
+ } catch {
1389
+ let L = new import_build$1.Sha256();
1390
+ return L.update(c ?? ""), Array.from(await L.digest()).map((c) => c.toString(16).padStart(2, "0")).join("");
1391
+ }
1392
+ }
1393
+ var import_build = require_build();
1394
+ async function updatePolicy(c, L) {
1395
+ let R = allItems(c.grid, c.subgrids), z = await Promise.all(R.flatMap((L) => {
1396
+ let R = L.data, z = [{
1397
+ input: R.componentInput,
1398
+ id: L.id
1399
+ }];
1400
+ if (R.type === "tablecomponent" && z.push(...R.actionButtons.map((c) => ({
1401
+ input: c.componentInput,
1402
+ id: c.id
1403
+ }))), (R.type === "aggridcomponent" || R.type === "aggridcomponentee" || R.type === "dbexplorercomponent" || R.type === "aggridinfinitecomponent" || R.type === "aggridinfinitecomponentee") && Array.isArray(R.actions) && z.push(...R.actions.map((c) => ({
1404
+ input: c.componentInput,
1405
+ id: c.id
1406
+ }))), R.type === "menucomponent" && z.push(...R.menuItems.map((c) => ({
1407
+ input: c.componentInput,
1408
+ id: c.id
1409
+ }))), R.type === "dbexplorercomponent") {
1410
+ let c = [], B = R.configuration, V = B?.type?.selected, H = B?.type?.configuration?.[V];
1411
+ if (H && V) {
1412
+ let { table: c, resource: U, ducklake: W } = H, G = c.value, K = U?.value.split("$res:")[1] ?? (W?.value)?.split("ducklake://")[1], q = R.configuration.columnDefs.value, J = R.configuration.whereClause.value;
1413
+ if (G && K && q) {
1414
+ let c = W ? {
1415
+ type: "ducklake",
1416
+ ducklake: K
1417
+ } : {
1418
+ type: "database",
1419
+ resourcePath: K,
1420
+ resourceType: V
1421
+ };
1422
+ z.push({
1423
+ input: getSelectInput(c, G, q, J),
1424
+ id: L.id
1425
+ }), z.push({
1426
+ input: getCountInput(c, G, q, J),
1427
+ id: L.id + "_count"
1428
+ }), z.push({
1429
+ input: getInsertInput(c, G, q),
1430
+ id: L.id + "_insert"
1431
+ });
1432
+ let R = getPrimaryKeys(q), H = q?.filter((c) => R.includes(c.field));
1433
+ z.push({
1434
+ input: getDeleteInput(c, G, H),
1435
+ id: L.id + "_delete"
1436
+ }), q.filter((c) => c.editable || B.allEditable.value).forEach((R) => {
1437
+ z.push({
1438
+ input: getUpdateInput(c, G, R, H),
1439
+ id: L.id + "_update"
1440
+ });
1441
+ });
1442
+ }
1443
+ }
1444
+ z.push(...c);
1445
+ }
1446
+ return z.filter((c) => c.input).map(async (L) => {
1447
+ if (L.input?.type == "runnable") return await processRunnable$1(L.id, L.input.runnable, L.input.fields, c);
1448
+ });
1449
+ }).concat(Object.values(c.hiddenInlineScripts ?? {}).map(async (L, R) => await processRunnable$1("bg_" + R, L, L.fields, c)))), B = Object.fromEntries(z.filter(Boolean)), V = R.filter((c) => c.data.type === "s3fileinputcomponent").map((L) => {
1450
+ let R = L.data.configuration;
1451
+ return computeS3FileInputPolicy(R?.type?.configuration?.s3, c);
1452
+ }).filter(Boolean);
1453
+ R.findIndex((c) => {
1454
+ let L = c.data;
1455
+ if (L.type === "schemaformcomponent" || L.type === "formbuttoncomponent" || L.type === "formcomponent") {
1456
+ let c = L.type === "schemaformcomponent" ? L.componentInput?.value?.properties : isRunnableByName(L.componentInput?.runnable) ? L.componentInput?.runnable?.inlineScript?.schema?.properties : L.componentInput?.runnable?.schema?.properties;
1457
+ return Object.values(c ?? {}).findIndex((c) => c?.type === "object" && c?.format === "resource-s3_object" || c?.type === "array" && (c?.items?.resourceType === "s3object" || c?.items?.resourceType === "s3_object")) !== -1;
1458
+ } else return !1;
1459
+ }) !== -1 && V.push(computeWorkspaceS3FileInputPolicy());
1460
+ let H = R.filter((c) => c.data.type === "imagecomponent" || c.data.type === "pdfcomponent" || c.data.type === "downloadcomponent").map((c) => {
1461
+ let L = c.data.configuration;
1462
+ return computeS3FileViewerPolicy(L);
1463
+ }).filter(Boolean);
1464
+ return {
1465
+ ...L ?? {},
1466
+ allowed_s3_keys: H,
1467
+ s3_inputs: V,
1468
+ triggerables_v2: B
1469
+ };
1470
+ }
1471
+ async function processRunnable$1(c, L, R, z) {
1472
+ let B = collectStaticFields(R), V = collectOneOfFields(R, z), H = Object.entries(R).map(([c, L]) => L.allowUserResources ? c : void 0).filter(Boolean);
1473
+ if (isRunnableByName(L)) {
1474
+ let R = await hash$1(L.inlineScript?.content);
1475
+ return console.debug("hex", R, c), [`${c}:rawscript/${R}`, {
1476
+ static_inputs: B,
1477
+ one_of_inputs: V,
1478
+ allow_user_resources: H
1479
+ }];
1480
+ } else if (isRunnableByPath(L)) return [`${c}:${L.runType === "hubscript" ? "script" : L.runType}/${L.path}`, {
1481
+ static_inputs: B,
1482
+ one_of_inputs: V,
1483
+ allow_user_resources: H
1484
+ }];
1485
+ }
1486
+ async function hash$1(c) {
1487
+ try {
1488
+ let L = new TextEncoder().encode(c), R = await crypto.subtle.digest("SHA-256", L);
1489
+ return Array.from(new Uint8Array(R)).map((c) => c.toString(16).padStart(2, "0")).join("");
1490
+ } catch {
1491
+ let L = new import_build.Sha256();
1492
+ return L.update(c ?? ""), Array.from(await L.digest()).map((c) => c.toString(16).padStart(2, "0")).join("");
1493
+ }
1494
+ }
1495
+ function schemaToTsType(c) {
1496
+ let L = c.properties, R = c.required;
1497
+ return !c || !L ? "any" : `{ ${Object.keys(L).map((c) => {
1498
+ let z = L[c], B = `${c}${R?.includes(c) ? "" : "?"}`, V = "any";
1499
+ return z.type === "string" ? V = "string" : z.type === "number" || z.type === "integer" ? V = "number" : z.type === "boolean" ? V = "boolean" : z.type === "array" ? (V = z.items?.type ?? "any", V === "integer" && (V = "number"), V = `${V}[]`) : z.type === "object" && z.properties && (V = schemaToTsType(z)), `${B}: ${V}`;
1500
+ }).join("; ")} }`;
1501
+ }
1502
+ function removeStaticFields(c, L) {
1503
+ let R = Object.keys(L).filter((c) => L[c].type == "static");
1504
+ return {
1505
+ ...c,
1506
+ properties: { ...Object.fromEntries(Object.entries(c.properties ?? {}).filter(([c]) => !R.includes(c))) }
1507
+ };
1508
+ }
1509
+ function hiddenRunnableToTsType(c) {
1510
+ return isRunnableByName(c) ? c?.inlineScript?.schema ? schemaToTsType(removeStaticFields(c?.inlineScript?.schema, c?.fields ?? {})) : "{}" : isRunnableByPath(c) ? schemaToTsType(removeStaticFields(c?.schema, c?.fields ?? {})) : "{}";
1511
+ }
1512
+ function genWmillTs(c) {
1513
+ return `// THIS FILE IS READ-ONLY
1514
+ // AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES
1515
+
1516
+ export declare const backend: {
1517
+ ${Object.entries(c).map(([c, L]) => ` ${c}: (args: ${hiddenRunnableToTsType(L)}) => Promise<any>;`).join("\n")}
1518
+ };
1519
+
1520
+ export declare const backendAsync: {
1521
+ ${Object.entries(c).map(([c, L]) => ` ${c}: (args: ${hiddenRunnableToTsType(L)}) => Promise<string>;`).join("\n")}
1522
+ };
1523
+
1524
+ export type Job = {
1525
+ type: "QueuedJob" | "CompletedJob";
1526
+ id: string;
1527
+ created_at: number;
1528
+ started_at: number | undefined;
1529
+ duration_ms: number;
1530
+ success: boolean;
1531
+ args: any;
1532
+ result: any;
1533
+ };
1534
+
1535
+ /**
1536
+ * Execute a job and wait for it to complete and return the completed job
1537
+ * @param id
1538
+ */
1539
+ export declare function waitJob(id: string): Promise<Job>;
1540
+
1541
+ /**
1542
+ * Get a job by id and return immediately with the current state of the job
1543
+ * @param id
1544
+ */
1545
+ export declare function getJob(id: string): Promise<Job>;
1546
+
1547
+ export type StreamUpdate = {
1548
+ new_result_stream?: string;
1549
+ stream_offset?: number;
1550
+ };
1551
+
1552
+ /**
1553
+ * Stream job results using SSE. Calls onUpdate for each stream update,
1554
+ * and resolves with the final result when the job completes.
1555
+ * @param id - The job ID to stream
1556
+ * @param onUpdate - Optional callback for stream updates with new_result_stream data
1557
+ * @returns Promise that resolves with the final job result
1558
+ */
1559
+ export declare function streamJob(id: string, onUpdate?: (data: StreamUpdate) => void): Promise<any>;
1560
+ `;
1561
+ }
1562
+ async function updateRawAppPolicy(c, L) {
1563
+ let R = Object.fromEntries(await Promise.all(Object.entries(c).map(async ([c, L]) => await processRunnable(c, L, L?.fields ?? {}))));
1564
+ return {
1565
+ ...L,
1566
+ triggerables_v2: R
1567
+ };
1568
+ }
1569
+ async function processRunnable(c, L, R) {
1570
+ let z = collectStaticFields(R), B = Object.entries(R).map(([c, L]) => L.allowUserResources ? c : void 0).filter(Boolean);
1571
+ if (isRunnableByName(L)) {
1572
+ let R = await hash(L.inlineScript?.content);
1573
+ return console.log("hex", R, c), [`${c}:rawscript/${R}`, {
1574
+ static_inputs: z,
1575
+ one_of_inputs: {},
1576
+ allow_user_resources: B
1577
+ }];
1578
+ } else if (isRunnableByPath(L)) return [`${c}:${L.runType === "hubscript" ? "script" : L.runType}/${L.path}`, {
1579
+ static_inputs: z,
1580
+ one_of_inputs: {},
1581
+ allow_user_resources: B
1582
+ }];
1583
+ }
1584
+ var rawAppWmillTs_exports = /* @__PURE__ */ __export({ default: () => rawAppWmillTs_default }, 1), rawAppWmillTs_default = "let reqs: Record<string, any> = {}\n\nfunction doRequest(type: string, o: object) {\n return new Promise((resolve, reject) => {\n const reqId = Math.random().toString(36)\n reqs[reqId] = { resolve, reject }\n parent.postMessage({ ...o, type, reqId }, '*')\n })\n}\n\nexport const backend = new Proxy(\n {},\n {\n get(_, runnable_id: string) {\n return (v: any) => {\n return doRequest('backend', { runnable_id, v })\n }\n }\n }\n)\n\nexport const backendAsync = new Proxy(\n {},\n {\n get(_, runnable_id: string) {\n return (v: any) => {\n return doRequest('backendAsync', { runnable_id, v })\n }\n }\n }\n)\n\nexport function waitJob(jobId: string) {\n return doRequest('waitJob', { jobId })\n}\n\nexport function getJob(jobId: string) {\n return doRequest('getJob', { jobId })\n}\n\n/**\n * Stream job results using SSE. Calls onUpdate for each stream update,\n * and resolves with the final result when the job completes.\n * @param jobId - The job ID to stream\n * @param onUpdate - Callback for stream updates with new_result_stream data\n * @returns Promise that resolves with the final job result\n */\nexport function streamJob(\n jobId: string,\n onUpdate?: (data: { new_result_stream?: string; stream_offset?: number }) => void\n): Promise<any> {\n return new Promise((resolve, reject) => {\n const reqId = Math.random().toString(36)\n reqs[reqId] = { resolve, reject, onUpdate }\n parent.postMessage({ jobId, type: 'streamJob', reqId }, '*')\n })\n}\n\nwindow.addEventListener('message', (e) => {\n if (e.data.type == 'streamJobUpdate') {\n // Handle streaming update\n let job = reqs[e.data.reqId]\n if (job && job.onUpdate) {\n job.onUpdate({\n new_result_stream: e.data.new_result_stream,\n stream_offset: e.data.stream_offset\n })\n }\n } else if (e.data.type == 'streamJobRes') {\n // Handle stream completion\n let job = reqs[e.data.reqId]\n if (job) {\n if (e.data.error) {\n job.reject(new Error(e.data.result?.stack ?? e.data.result?.message ?? 'Stream error'))\n } else {\n job.resolve(e.data.result)\n }\n delete reqs[e.data.reqId]\n }\n } else if (e.data.type == 'backendRes' || e.data.type == 'backendAsyncRes') {\n console.log('Message from parent backend', e.data)\n let job = reqs[e.data.reqId]\n if (job) {\n const result = e.data.result\n if (e.data.error) {\n job.reject(new Error(result.stack ?? result.message))\n } else {\n job.resolve(result)\n }\n } else {\n console.error('No job found for', e.data.reqId)\n }\n }\n})\n";
1585
+ function capitalize(c) {
1586
+ return c ? c.charAt(0).toUpperCase() + c.slice(1) : "";
1587
+ }
1588
+ export { capitalize, genWmillTs, updatePolicy, updateRawAppPolicy, rawAppWmillTs_exports as wmillTsRaw };