@xanots/sdk 0.0.1

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 (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +384 -0
  3. package/dist/agent-file-refresh-7XCACU34.js +95 -0
  4. package/dist/bin.d.ts +1 -0
  5. package/dist/bin.js +184 -0
  6. package/dist/capture-HUV5BNTC.js +32 -0
  7. package/dist/chunk-26CNBZE2.js +963 -0
  8. package/dist/chunk-33ND6LKO.js +78 -0
  9. package/dist/chunk-3DUAGYGP.js +1550 -0
  10. package/dist/chunk-3IGNIP6R.js +89 -0
  11. package/dist/chunk-47WDWMBJ.js +14 -0
  12. package/dist/chunk-4BXJGVZ3.js +318 -0
  13. package/dist/chunk-4HT3BNZ7.js +675 -0
  14. package/dist/chunk-4YMD2OOZ.js +23 -0
  15. package/dist/chunk-5WGEURVI.js +156 -0
  16. package/dist/chunk-5YTBTF25.js +29 -0
  17. package/dist/chunk-6DHBYBTO.js +166 -0
  18. package/dist/chunk-76QBEIGO.js +66 -0
  19. package/dist/chunk-7DKX2SPN.js +100 -0
  20. package/dist/chunk-7REDODS2.js +468 -0
  21. package/dist/chunk-C56BC2FY.js +254 -0
  22. package/dist/chunk-DGSF2Q5H.js +60 -0
  23. package/dist/chunk-EMCAWMHC.js +3982 -0
  24. package/dist/chunk-EZG76F7R.js +159 -0
  25. package/dist/chunk-FJ6ZS5KB.js +3607 -0
  26. package/dist/chunk-GNPVYOPB.js +17 -0
  27. package/dist/chunk-HJPTWBLH.js +38 -0
  28. package/dist/chunk-IZW6MK3U.js +248 -0
  29. package/dist/chunk-LH6Z6KFV.js +247 -0
  30. package/dist/chunk-MZUI3JNX.js +93 -0
  31. package/dist/chunk-NDZFBZHC.js +167 -0
  32. package/dist/chunk-NOO35BQ2.js +37 -0
  33. package/dist/chunk-NUQCEOKA.js +13 -0
  34. package/dist/chunk-QTNO2WD6.js +56 -0
  35. package/dist/chunk-RVB7ITKN.js +49 -0
  36. package/dist/chunk-TRU5OHQ5.js +6904 -0
  37. package/dist/chunk-VKFQJEMW.js +814 -0
  38. package/dist/chunk-VTIL47DT.js +125 -0
  39. package/dist/chunk-WHOJWOSV.js +112 -0
  40. package/dist/chunk-WKP4D5MO.js +1692 -0
  41. package/dist/chunk-X4DVXBFY.js +38 -0
  42. package/dist/chunk-XQ22GLYS.js +118 -0
  43. package/dist/chunk-YDZYMZBE.js +670 -0
  44. package/dist/chunk-YGPIY3WT.js +1146 -0
  45. package/dist/chunk-YYRDLFSJ.js +602 -0
  46. package/dist/chunk-ZUTSMMAG.js +46 -0
  47. package/dist/cli.d.ts +331 -0
  48. package/dist/cli.js +33 -0
  49. package/dist/codegen-command-OOKK6AZK.js +40 -0
  50. package/dist/codegen.d.ts +114 -0
  51. package/dist/codegen.js +71 -0
  52. package/dist/completion-TIPPZN7H.js +298 -0
  53. package/dist/config-NL33PN4D.js +84 -0
  54. package/dist/deploy-command-4EQ7XX5G.js +451 -0
  55. package/dist/env-target-IFJ5QDHC.js +16 -0
  56. package/dist/ephemeral-command-3X3I4ULC.js +242 -0
  57. package/dist/index.d.ts +4477 -0
  58. package/dist/index.js +300 -0
  59. package/dist/init-command-R6H7ZXW5.js +27 -0
  60. package/dist/internal.d.ts +74 -0
  61. package/dist/internal.js +2065 -0
  62. package/dist/io-AMIKRLPC.js +11 -0
  63. package/dist/live-diff-Y3AKETHE.js +196 -0
  64. package/dist/lock-3CVKALKT.js +37 -0
  65. package/dist/lock-commands-XTR2YKLY.js +232 -0
  66. package/dist/login-command-ACJF6KWQ.js +167 -0
  67. package/dist/logout-command-MX3MJS5U.js +68 -0
  68. package/dist/loop-OM3P2Z6O.js +93 -0
  69. package/dist/marketplace-command-RATXTKXN.js +379 -0
  70. package/dist/meta-client-OW5WKWW7.js +170 -0
  71. package/dist/node.d.ts +59 -0
  72. package/dist/node.js +442 -0
  73. package/dist/profile-command-SWJ3SPKR.js +77 -0
  74. package/dist/release-command-VV5UVZKL.js +427 -0
  75. package/dist/response-CVAE2kMj.d.ts +1915 -0
  76. package/dist/routes-manifest-SP3ZXLMR.js +244 -0
  77. package/dist/runtime-V4C3AC3A.js +13 -0
  78. package/dist/sandbox-details-command-HJE5SPVG.js +18 -0
  79. package/dist/sandbox-export-command-QCJY4GMV.js +24 -0
  80. package/dist/static-host-D6KS7X45.js +138 -0
  81. package/dist/store-BQ97nKIF.d.ts +7760 -0
  82. package/dist/test-command-TSPBQHBM.js +383 -0
  83. package/dist/validate-command-4ERHJSCO.js +122 -0
  84. package/dist/verify-rollout-FAVQ6EJY.js +40 -0
  85. package/dist/workspace-K72NP7SX.js +49 -0
  86. package/dist/workspace-command-OF23DPNI.js +156 -0
  87. package/dist/workspace-export-AJMGN3CQ.js +10 -0
  88. package/llms/fields.md +104 -0
  89. package/llms/filters.md +183 -0
  90. package/llms/kinds-agent-mcp.md +11 -0
  91. package/llms/kinds-core.md +68 -0
  92. package/llms/kinds-realtime.md +76 -0
  93. package/llms/lambda.md +111 -0
  94. package/llms/legacy.md +43 -0
  95. package/llms/object-kinds.md +31 -0
  96. package/llms/statements-calls.md +23 -0
  97. package/llms/statements-catalog.md +309 -0
  98. package/llms/statements-data.md +58 -0
  99. package/llms/statements-runtime.md +48 -0
  100. package/llms/tests.md +58 -0
  101. package/llms/triggers.md +22 -0
  102. package/llms/values.md +29 -0
  103. package/llms-full.txt +1672 -0
  104. package/llms.txt +483 -0
  105. package/manifest.json +9592 -0
  106. package/package.json +110 -0
package/dist/node.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { aT as LambdaOptions, aU as CaptureValue, aV as LambdaSurface, aW as CaptureRecord, aX as LambdaBindings, F as FunctionDef, aY as Xano, h as LockFile } from './store-BQ97nKIF.js';
2
+ export { aZ as AddonDef, a_ as AddonXdo, A as AdoptChange, a as AdoptResult, a$ as AgentDef, b0 as AgentHandle, b1 as AgentOutput, b2 as AgentSettingsXdo, b3 as AgentXdo, b4 as AmbientBindings, b5 as AnthropicLlm, b6 as ApiGroupDef, b7 as ApiGroupXdo, b8 as AuthRef, b9 as Authored, B as Bundle, b as BundlePayload, c as BundleType, ba as Capturable, bb as ChannelConversationDef, bc as ChannelDeliveryDef, bd as ChannelDeliveryGuarantee, be as ChannelPublishDef, bf as ChannelPublishWho, bg as ChannelRateLimitDef, bh as ColumnDef, bi as Comparison, bj as ContainerEnv, bk as ContainerPort, bl as ContainerResources, bm as ContainerVolume, bn as CorsConfig, bo as CorsMode, bp as DatabaseActions, bq as DatabaseInputs, br as DbEval, bs as DbEvalFilter, bt as DbWhere, bu as ErrorInputs, bv as ExceptionPolicy, bw as FieldAccessor, bx as FieldRule, by as GoogleGenAiLlm, bz as HistoryInput, bA as HttpVerb, bB as IndexDef, bC as IndexLang, bD as IndexOp, bE as IndexType, bF as IndexXdo, bG as InferRow, bH as InputDescriptor, bI as InputOptions, bJ as IteratingBindings, bK as LAMBDA_BINDINGS, bL as LAMBDA_CODE_FILTERS, bM as LAMBDA_GLOBALS, bN as LAMBDA_MODULE_GLOBALS, bO as LAMBDA_STATEMENTS, bP as LambdaBody, bQ as LlmPrompt, bR as LlmProvider, bS as LlmSettings, f as LockEntry, g as LockExportContext, M as Manifest, i as ManifestField, j as ManifestKind, k as ManifestStatement, bT as ManifestValue, bU as McpPathOptions, bV as McpServerDef, bW as McpServerHandle, bX as McpServerXdo, l as MergeResult, bY as MessageDeliverTo, bZ as MicroserviceChart, b_ as MicroserviceConfig, b$ as MicroserviceContainer, c0 as MicroserviceDef, c1 as MicroserviceDeployment, c2 as MicroserviceIngress, c3 as MicroserviceRegistryAuth, c4 as MicroserviceVolume, c5 as MicroserviceXdo, c6 as MiddlewareAttach, c7 as MiddlewareAttachEntry, c8 as MiddlewareDef, c9 as MiddlewareXdo, O as ObjectKind, ca as OpenAiLlm, m as PayloadArrayKey, cb as QueryDef, cc as QueryFilterName, cd as QueryHandle, ce as QueryResponseType, cf as QueryXdo, cg as RealtimeActions, ch as RealtimeChannelActions, ci as RealtimeChannelDef, cj as RealtimeChannelHandle, ck as RealtimeChannelRef, cl as RealtimeChannelTriggerInputs, cm as RealtimeChannelXdo, cn as RealtimeClient, co as RealtimeInputs, cp as RealtimeMessageDef, cq as RealtimeMessageXdo, cr as RealtimeServerActions, cs as RealtimeServerDef, ct as RealtimeServerHandle, cu as RealtimeServerRef, cv as RealtimeServerTriggerInputs, cw as RealtimeServerXdo, cx as RealtimeUrlOptions, R as RenameResult, cy as ResultStrategy, cz as Route, cA as RowOf, cB as ScheduleDef, cC as SchemaCols, cD as SchemaDef, cE as SearchComparison, cF as SearchGroup, cG as SearchNode, cH as SearchOp, cI as SearchParamValue, cJ as SeedFileSource, cK as SeedRow, cL as SeedSource, cM as SortDir, cN as SortDirective, S as StatementSpec, cO as TableDef, cP as TableXdo, cQ as TaskDef, cR as TaskXdo, cS as ToolDef, cT as ToolXdo, cU as ToolsetBaseDef, cV as ToolsetBaseXdo, cW as ToolsetInputs, cX as ToolsetToolEntry, cY as ToolsetToolRef, cZ as TriggerDef, c_ as TriggerObjType, c$ as TriggerXdo, d0 as ViewDef, d1 as ViewXdo, d2 as WorkflowTestDef, d3 as WorkflowTestXdo, d4 as WorkspaceActions, d5 as WorkspaceConfigDef, d6 as WorkspaceConfigXdo, d7 as WorkspaceHistoryDef, d8 as WorkspaceHistoryXdo, d9 as WorkspaceInputs, da as WorkspaceMiddlewareDef, db as WorkspaceMiddlewareXdo, dc as XanoFreeLlm, dd as addon, de as agent, df as agentTrigger, dg as and, dh as apiGroup, di as assertLambdaBody, dj as bitwiseAnd, dk as bitwiseOr, dl as bitwiseXor, dm as cmp, dn as defineFunction, dp as emit, dq as emitBundle, dr as errorTrigger, ds as expr, dt as fl, du as input, dv as mathAdd, dw as mathDiv, dx as mathMul, dy as mathSub, dz as mcpServer, dA as mcpServerTrigger, dB as microservice, dC as middleware, dD as mixed, dE as objectEntries, dF as objectKeys, dG as objectValues, dH as or, dI as query, dJ as realtimeChannel, dK as realtimeChannelTrigger, dL as realtimeMessage, dM as realtimeServer, dN as realtimeServerTrigger, dO as realtimeTrigger, dP as resetLockOverrides, dQ as seedFile, dR as seedLockOverrides, dS as table, dT as tableTrigger, dU as task, dV as textAppend, dW as textPrepend, dX as toSearchParams, dY as tool, dZ as workflowTest, d_ as workspace, d$ as workspaceConfig, e0 as workspaceTrigger } from './store-BQ97nKIF.js';
3
+ export { ActionCallArgs, AddonCallArgs, AddonSpec, AgentRunResult, AiAgentRunArgs, AnyAddonDef, AnyFunctionDef, AnyQueryDef, AnyTableDef, ApiCallArgs, ApplyFilter, ApplyFilters, ArrayMapArgs, CloudJobArgs, CloudJobAwaitArgs, CloudJobStatusArgs, CreateAuthTokenArgs, DbAddArgs, DbAddOrEditArgs, DbAggregate, DbAggregatePaging, DbBind, DbBulkAddArgs, DbBulkDeleteArgs, DbBulkWriteArgs, DbDelArgs, DbDirectQueryArgs, DbDistinct, DbEditArgs, DbExternal, DbExternalPermissions, DbExternalQueryArgs, DbField, DbGetArgs, DbHasArgs, DbJoin, DbPaging, DbPatchArgs, DbQueryArgs, DbResponseType, DbReturnType, DbSchemaArgs, DbTransactionArgs, DbTruncateArgs, ExpectToThrowArgs, ExternalSqlEngine, ForArgs, ForeachArgs, FunctionCallArgs, FunctionRunArgs, GetRawInputArgs, HeaderMap, HttpMethod, InferInput, InferResponse, IpLookupArgs, IpLookupResult, MiddlewareCallArgs, RealtimeEventArgs, StackTupleWidened, SwitchArgs, SwitchCaseArgs, TaskCallArgs, ToolCallArgs, TriggerCallArgs, TryCatchArgs, WhileArgs, WorkflowTestCallArgs, actionCall, actionPackageCall, addonCall, aiAgentRun, apiCall, arrayMap, arrayUnion, cloudJob, cloudJobAwait, cloudJobStatus, comment, compile, conditional, createAuthToken, dbAdd, dbAddOrEdit, dbBulkAdd, dbBulkDelete, dbBulkPatch, dbBulkUpdate, dbDel, dbDirectQuery, dbEdit, dbExternalQuery, dbGet, dbHas, dbPatch, dbQuery, dbSchema, dbTransaction, dbTruncate, debugLog, die, expectToThrow, fileUrl, forLoop, foreachBreak, foreachContinue, foreachLoop, foreachRemove, functionCall, functionRun, getRawInput, group, ignored, ipLookup, middlewareCall, postProcess, realtimeEvent, returnValue, s, setVar, switchCase, switchStatement, taskCall, toolCall, triggerCall, tryCatch, updateVar, whileLoop, workflowTestCall } from './index.js';
4
+ import { V as Value } from './response-CVAE2kMj.js';
5
+ export { B as BrandOpts, c as BrandValue, C as CacheXdo, f as CaughtField, h as ConditionalContext, j as ConditionalElifContext, D as DecimalMethod, E as EmailMethod, k as ExprGroup, l as ExprNode, m as ExprOperand, n as ExprStatement, o as FieldAccess, p as FieldDescriptor, q as FieldMap, s as FieldOpts, u as FieldStyleType, v as FieldXdo, w as FilterXdo, x as FilteredValue, y as FromFieldMap, F as FunctionXdo, H as HistoryXdo, I as InputXdo, z as IntMethod, L as ListBoundsXdo, M as MethodArg, A as MethodOpts, G as MethodSpec, J as MethodXdo, K as MockEntry, N as MockMap, O as MockXdo, P as ObjInput, Q as ObjMember, S as ObjValue, T as ObjectRef, U as PasswordMethod, W as PersistedFunctionRow, X as RefValue, Y as RegexValue, Z as ResponseDef, _ as ResultItemXdo, $ as RowFromFieldMap, a0 as StackItemXdo, a1 as Statement, a2 as StatementAnnotations, a3 as StatementInputXdo, a4 as StatementOptions, a5 as TAGS, a6 as TEST_EXPECT_TYPES, a7 as TableRefMethod, a8 as Tag, a9 as TaggedValue, aa as TestDef, ab as TestExpect, ac as TestExpectType, ad as TestXdo, ae as TextFormat, af as TextMethod, ag as TypeBrand, ah as ValueOf, ai as VectorMethod, aj as XanoFileRef, ak as XanoGeoPosition, al as XanoGeoValue, am as annotate, an as auth, ao as c, ap as caught, aq as col, ar as env, as as expect, at as f, au as filter, av as inp, aw as obj, ax as out, ay as ref, az as resp, aA as setting, aB as statements, aC as sys, aD as test, aE as toolset, aF as withFilters } from './response-CVAE2kMj.js';
6
+ export { exportBundleJson, loadDefault, parseArgs, run } from './cli.js';
7
+
8
+ /**
9
+ * Read a lambda body from its own module.
10
+ *
11
+ * `path` resolves against the CALLING module's directory (like an `import`), not
12
+ * the process working directory. The file must default-export exactly one
13
+ * function; its body is extracted and validated exactly as {@link lam.fn}'s is.
14
+ */
15
+ declare function file(path: string, opts?: LambdaOptions<Record<string, CaptureValue>>): Value;
16
+ /**
17
+ * Lambda authoring, with the filesystem form attached.
18
+ *
19
+ * Identical to the `lam` exported from `@xanots/sdk`, plus {@link file}. The
20
+ * isomorphic entry deliberately does not carry it: reading a file is not
21
+ * something a browser bundle can do, and a workspace definition shared with a
22
+ * frontend must keep resolving.
23
+ */
24
+ declare const lam: {
25
+ file: typeof file;
26
+ fn: <S extends LambdaSurface = "reduce", C extends CaptureRecord<C> = Record<string, never>>(body: (bindings: LambdaBindings<S>, captured: C) => unknown, opts?: LambdaOptions<C> & {
27
+ surface?: S;
28
+ }) => Value;
29
+ raw: (code: string, opts?: LambdaOptions<Record<string, CaptureValue>>) => Value;
30
+ };
31
+
32
+ /** Compile a function and write the JSON artifact to `path`. */
33
+ declare function writeArtifact(fn: FunctionDef, path: string, opts?: {
34
+ indent?: number;
35
+ }): void;
36
+ /**
37
+ * Write the aggregate bundle to `path`.
38
+ *
39
+ * `opts.strict` fails the write on any build warning instead of printing it —
40
+ * the same switch `xanots export --strict` throws (issue #15). A script that
41
+ * writes a bundle nobody watches is exactly where a printed warning is lost.
42
+ */
43
+ declare function writeBundle(xano: Xano, path: string, opts?: {
44
+ indent?: number;
45
+ strict?: boolean;
46
+ }): void;
47
+
48
+ /** Read + strictly validate a lock file from disk. The file must exist. */
49
+ declare function readLockFile(path: string): LockFile;
50
+ /**
51
+ * Atomic, idempotent write: unchanged bytes are not rewritten (mtime stays
52
+ * put, watchers stay quiet); changed content lands via temp-file+rename so a
53
+ * crash can never leave a half-written lock.
54
+ *
55
+ * Returns true when the file was (re)written.
56
+ */
57
+ declare function writeLockFile(path: string, lock: LockFile): boolean;
58
+
59
+ export { CaptureRecord, CaptureValue, FunctionDef, LambdaBindings, LambdaOptions, LambdaSurface, LockFile, Value, Xano, lam, readLockFile, writeArtifact, writeBundle, writeLockFile };
package/dist/node.js ADDED
@@ -0,0 +1,442 @@
1
+ import {
2
+ defineFunction,
3
+ fileUrl
4
+ } from "./chunk-4YMD2OOZ.js";
5
+ import {
6
+ TEST_EXPECT_TYPES,
7
+ expect
8
+ } from "./chunk-MZUI3JNX.js";
9
+ import {
10
+ addon,
11
+ agent,
12
+ apiGroup,
13
+ mcpServer,
14
+ middleware,
15
+ realtimeMessage,
16
+ realtimeServer,
17
+ task,
18
+ tool,
19
+ workflowTest
20
+ } from "./chunk-YDZYMZBE.js";
21
+ import {
22
+ actionCall,
23
+ actionPackageCall,
24
+ addonCall,
25
+ agentTrigger,
26
+ aiAgentRun,
27
+ apiCall,
28
+ arrayMap,
29
+ arrayUnion,
30
+ bitwiseAnd,
31
+ bitwiseOr,
32
+ bitwiseXor,
33
+ cloudJob,
34
+ cloudJobAwait,
35
+ cloudJobStatus,
36
+ comment,
37
+ createAuthToken,
38
+ dbAdd,
39
+ dbAddOrEdit,
40
+ dbBulkAdd,
41
+ dbBulkDelete,
42
+ dbBulkPatch,
43
+ dbBulkUpdate,
44
+ dbDel,
45
+ dbDirectQuery,
46
+ dbEdit,
47
+ dbExternalQuery,
48
+ dbGet,
49
+ dbHas,
50
+ dbPatch,
51
+ dbQuery,
52
+ dbSchema,
53
+ dbTransaction,
54
+ dbTruncate,
55
+ debugLog,
56
+ die,
57
+ errorTrigger,
58
+ expectToThrow,
59
+ forLoop,
60
+ foreachBreak,
61
+ foreachContinue,
62
+ foreachLoop,
63
+ foreachRemove,
64
+ functionCall,
65
+ functionRun,
66
+ getRawInput,
67
+ group,
68
+ ignored,
69
+ ipLookup,
70
+ mathAdd,
71
+ mathDiv,
72
+ mathMul,
73
+ mathSub,
74
+ mcpServerTrigger,
75
+ microservice,
76
+ middlewareCall,
77
+ objectEntries,
78
+ objectKeys,
79
+ objectValues,
80
+ postProcess,
81
+ realtimeChannel,
82
+ realtimeChannelTrigger,
83
+ realtimeEvent,
84
+ realtimeServerTrigger,
85
+ realtimeTrigger,
86
+ returnValue,
87
+ s,
88
+ setVar,
89
+ switchCase,
90
+ switchStatement,
91
+ tableTrigger,
92
+ taskCall,
93
+ textAppend,
94
+ textPrepend,
95
+ toolCall,
96
+ triggerCall,
97
+ tryCatch,
98
+ updateVar,
99
+ whileLoop,
100
+ workflowTestCall,
101
+ workspaceConfig,
102
+ workspaceTrigger
103
+ } from "./chunk-FJ6ZS5KB.js";
104
+ import {
105
+ exportBundleJson,
106
+ loadDefault,
107
+ parseArgs,
108
+ run,
109
+ writeArtifact,
110
+ writeBundle
111
+ } from "./chunk-YGPIY3WT.js";
112
+ import "./chunk-IZW6MK3U.js";
113
+ import "./chunk-EZG76F7R.js";
114
+ import {
115
+ Xano,
116
+ workspace
117
+ } from "./chunk-3DUAGYGP.js";
118
+ import "./chunk-YYRDLFSJ.js";
119
+ import {
120
+ LAMBDA_BINDINGS,
121
+ LAMBDA_CODE_FILTERS,
122
+ LAMBDA_GLOBALS,
123
+ LAMBDA_MODULE_GLOBALS,
124
+ LAMBDA_STATEMENTS,
125
+ and,
126
+ assertLambdaBody,
127
+ auth,
128
+ c,
129
+ caught,
130
+ cmp,
131
+ col,
132
+ compile,
133
+ conditional,
134
+ emit,
135
+ emitBundle,
136
+ env,
137
+ expr,
138
+ extractFunctionBody,
139
+ f,
140
+ filter,
141
+ fl,
142
+ inp,
143
+ input,
144
+ lam,
145
+ lambdaValue,
146
+ maskNonCode,
147
+ mixed,
148
+ obj,
149
+ or,
150
+ out,
151
+ query,
152
+ ref,
153
+ resp,
154
+ seedFile,
155
+ setting,
156
+ sys,
157
+ table,
158
+ test,
159
+ toSearchParams,
160
+ toolset,
161
+ withFilters
162
+ } from "./chunk-EMCAWMHC.js";
163
+ import "./chunk-WHOJWOSV.js";
164
+ import {
165
+ annotate,
166
+ statements
167
+ } from "./chunk-LH6Z6KFV.js";
168
+ import {
169
+ readLockFile,
170
+ writeLockFile
171
+ } from "./chunk-HJPTWBLH.js";
172
+ import "./chunk-GNPVYOPB.js";
173
+ import {
174
+ resetLockOverrides,
175
+ seedLockOverrides
176
+ } from "./chunk-4HT3BNZ7.js";
177
+
178
+ // src/values/lambda-file.ts
179
+ import { readFileSync } from "fs";
180
+ import { dirname, isAbsolute, resolve } from "path";
181
+ import { fileURLToPath } from "url";
182
+ var PREFIX = "lam.file";
183
+ var LOADER_FRAME = /[/\\]node_modules[/\\](?:\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?(?:vite-node|vite|vitest|tsx|ts-node|jiti|esbuild-register|@esbuild-kit)[/\\]/;
184
+ var SELF = fileURLToPath(import.meta.url);
185
+ function callerDir() {
186
+ const stack = new Error().stack ?? "";
187
+ const frames = [];
188
+ for (const line of stack.split("\n").slice(1)) {
189
+ const match = /\((.*?):\d+:\d+\)\s*$/.exec(line) ?? /at (.*?):\d+:\d+\s*$/.exec(line);
190
+ const raw = match?.[1];
191
+ if (raw === void 0 || raw.startsWith("node:")) continue;
192
+ const path = raw.startsWith("file:") ? fileURLToPath(raw) : raw;
193
+ if (path === SELF) continue;
194
+ frames.push(path);
195
+ }
196
+ const authored = frames.find((p) => !LOADER_FRAME.test(p));
197
+ return dirname(authored ?? frames[0] ?? process.cwd());
198
+ }
199
+ var ALLOWED_TOP_LEVEL = ["type", "interface", "declare"];
200
+ function assertOnlyDefaultExport(mask, path) {
201
+ let depth = 0;
202
+ let atStatementStart = true;
203
+ for (let i = 0; i < mask.length; i++) {
204
+ const ch = mask[i] ?? "";
205
+ if (ch === "(" || ch === "[" || ch === "{") {
206
+ depth++;
207
+ continue;
208
+ }
209
+ if (ch === ")" || ch === "]" || ch === "}") {
210
+ depth--;
211
+ continue;
212
+ }
213
+ if (depth === 0 && (ch === ";" || ch === "\n")) {
214
+ atStatementStart = true;
215
+ continue;
216
+ }
217
+ if (/\s/.test(ch) || depth > 0) continue;
218
+ if (!atStatementStart) continue;
219
+ atStatementStart = false;
220
+ const rest = mask.slice(i);
221
+ const word = /^[A-Za-z_$][A-Za-z0-9_$]*/.exec(rest)?.[0];
222
+ if (word === void 0 || ALLOWED_TOP_LEVEL.includes(word)) continue;
223
+ if (word === "export") {
224
+ if (/^export\s+(?:default\b|type\b|interface\b)/.test(rest)) continue;
225
+ throw new Error(
226
+ `${PREFIX}: ${path} exports something besides its default. Only the default export's BODY is sent to the engine, so a second export is undefined at runtime \u2014 the engine returns that failure as diagnostic text in the value slot rather than as an error. A lambda module is one \`export default\` function and nothing else: move it inside that function. (issue #221)`
227
+ );
228
+ }
229
+ if (word === "import") {
230
+ if (/^import\s+type\b/.test(rest)) continue;
231
+ throw new Error(
232
+ `${PREFIX}: ${path} imports a value at the top level, which the engine never resolves \u2014 only the default export's body is sent, so the import is undefined at runtime. Use \`import type\` for types, or reach a dependency through the PRELOADED globals, which need no specifier and are the only route that works on every instance: ${LAMBDA_MODULE_GLOBALS.join(", ")} (plus ${LAMBDA_GLOBALS.join(" / ")}, fetch, Buffer, TextEncoder). (issues #221, #265)`
233
+ );
234
+ }
235
+ const declared = /^(?:const|let|var|function|class|async)\s+([A-Za-z_$][A-Za-z0-9_$]*)/.exec(mask.slice(i))?.[1];
236
+ throw new Error(
237
+ `${PREFIX}: ${path} declares \`${declared ?? word}\` at the top level, and only the default export's BODY is sent to the engine \u2014 anything beside it is undefined at runtime, and the engine returns that failure as diagnostic text in the value slot rather than as an error. Move it inside the default-exported function. (issue #221)`
238
+ );
239
+ }
240
+ }
241
+ function functionExtent(mask) {
242
+ let depth = 0;
243
+ let seenBody = false;
244
+ for (let i = 0; i < mask.length; i++) {
245
+ const ch = mask[i] ?? "";
246
+ if (ch === "(" || ch === "[" || ch === "{") {
247
+ depth++;
248
+ if (ch === "{" && depth === 1) seenBody = true;
249
+ continue;
250
+ }
251
+ if (ch === ")" || ch === "]" || ch === "}") {
252
+ depth--;
253
+ if (depth === 0 && ch === "}" && seenBody) return i + 1;
254
+ continue;
255
+ }
256
+ if (depth === 0 && (ch === ";" || ch === "\n")) return i;
257
+ }
258
+ return mask.length;
259
+ }
260
+ function file(path, opts) {
261
+ const resolved = isAbsolute(path) ? path : resolve(callerDir(), path);
262
+ let source;
263
+ try {
264
+ source = readFileSync(resolved, "utf8");
265
+ } catch {
266
+ throw new Error(
267
+ `${PREFIX}: cannot read ${resolved} (resolved from ${JSON.stringify(path)}, relative to the calling module rather than the working directory). (issue #221)`
268
+ );
269
+ }
270
+ const mask = maskNonCode(source);
271
+ assertOnlyDefaultExport(mask, resolved);
272
+ const marker = /(^|[;}\n])\s*export\s+default\s+/.exec(mask);
273
+ if (marker === null) {
274
+ throw new Error(
275
+ `${PREFIX}: ${resolved} has no \`export default\`. A lambda module is one default-exported function whose first parameter destructures the bindings \u2014 \`export default ({ $this }: LambdaBindings<"map">) => \u2026\`. (issue #221)`
276
+ );
277
+ }
278
+ if (mask.slice(marker.index + marker[0].length).match(/(^|[;}\n])\s*export\s+default\s+/)) {
279
+ throw new Error(`${PREFIX}: ${resolved} has more than one \`export default\`.`);
280
+ }
281
+ const start = marker.index + marker[0].length;
282
+ const afterMask = mask.slice(start);
283
+ if (!/^\s*(?:async\s+)?(?:function\b|\(|[A-Za-z_$])/.test(afterMask)) {
284
+ throw new Error(
285
+ `${PREFIX}: ${resolved} default-exports something that is not a function. Export the lambda itself: \`export default ({ $this }: LambdaBindings<"map">) => \u2026\`. (issue #221)`
286
+ );
287
+ }
288
+ const end = start + functionExtent(afterMask);
289
+ return lambdaValue(extractFunctionBody(source.slice(start, end), PREFIX), opts, `${PREFIX}(${path})`);
290
+ }
291
+ var lam2 = { ...lam, file };
292
+ export {
293
+ LAMBDA_BINDINGS,
294
+ LAMBDA_CODE_FILTERS,
295
+ LAMBDA_GLOBALS,
296
+ LAMBDA_MODULE_GLOBALS,
297
+ LAMBDA_STATEMENTS,
298
+ TEST_EXPECT_TYPES,
299
+ Xano,
300
+ actionCall,
301
+ actionPackageCall,
302
+ addon,
303
+ addonCall,
304
+ agent,
305
+ agentTrigger,
306
+ aiAgentRun,
307
+ and,
308
+ annotate,
309
+ apiCall,
310
+ apiGroup,
311
+ arrayMap,
312
+ arrayUnion,
313
+ assertLambdaBody,
314
+ auth,
315
+ bitwiseAnd,
316
+ bitwiseOr,
317
+ bitwiseXor,
318
+ c,
319
+ caught,
320
+ cloudJob,
321
+ cloudJobAwait,
322
+ cloudJobStatus,
323
+ cmp,
324
+ col,
325
+ comment,
326
+ compile,
327
+ conditional,
328
+ createAuthToken,
329
+ dbAdd,
330
+ dbAddOrEdit,
331
+ dbBulkAdd,
332
+ dbBulkDelete,
333
+ dbBulkPatch,
334
+ dbBulkUpdate,
335
+ dbDel,
336
+ dbDirectQuery,
337
+ dbEdit,
338
+ dbExternalQuery,
339
+ dbGet,
340
+ dbHas,
341
+ dbPatch,
342
+ dbQuery,
343
+ dbSchema,
344
+ dbTransaction,
345
+ dbTruncate,
346
+ debugLog,
347
+ defineFunction,
348
+ die,
349
+ emit,
350
+ emitBundle,
351
+ env,
352
+ errorTrigger,
353
+ expect,
354
+ expectToThrow,
355
+ exportBundleJson,
356
+ expr,
357
+ f,
358
+ fileUrl,
359
+ filter,
360
+ fl,
361
+ forLoop,
362
+ foreachBreak,
363
+ foreachContinue,
364
+ foreachLoop,
365
+ foreachRemove,
366
+ functionCall,
367
+ functionRun,
368
+ getRawInput,
369
+ group,
370
+ ignored,
371
+ inp,
372
+ input,
373
+ ipLookup,
374
+ lam2 as lam,
375
+ loadDefault,
376
+ mathAdd,
377
+ mathDiv,
378
+ mathMul,
379
+ mathSub,
380
+ mcpServer,
381
+ mcpServerTrigger,
382
+ microservice,
383
+ middleware,
384
+ middlewareCall,
385
+ mixed,
386
+ obj,
387
+ objectEntries,
388
+ objectKeys,
389
+ objectValues,
390
+ or,
391
+ out,
392
+ parseArgs,
393
+ postProcess,
394
+ query,
395
+ readLockFile,
396
+ realtimeChannel,
397
+ realtimeChannelTrigger,
398
+ realtimeEvent,
399
+ realtimeMessage,
400
+ realtimeServer,
401
+ realtimeServerTrigger,
402
+ realtimeTrigger,
403
+ ref,
404
+ resetLockOverrides,
405
+ resp,
406
+ returnValue,
407
+ run,
408
+ s,
409
+ seedFile,
410
+ seedLockOverrides,
411
+ setVar,
412
+ setting,
413
+ statements,
414
+ switchCase,
415
+ switchStatement,
416
+ sys,
417
+ table,
418
+ tableTrigger,
419
+ task,
420
+ taskCall,
421
+ test,
422
+ textAppend,
423
+ textPrepend,
424
+ toSearchParams,
425
+ tool,
426
+ toolCall,
427
+ toolset,
428
+ triggerCall,
429
+ tryCatch,
430
+ updateVar,
431
+ whileLoop,
432
+ withFilters,
433
+ workflowTest,
434
+ workflowTestCall,
435
+ workspace,
436
+ workspaceConfig,
437
+ workspaceTrigger,
438
+ writeArtifact,
439
+ writeBundle,
440
+ writeLockFile
441
+ };
442
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1,77 @@
1
+ import {
2
+ isMachineOutput,
3
+ writeJson
4
+ } from "./chunk-NUQCEOKA.js";
5
+ import {
6
+ fetchOrExplain,
7
+ httpFailure
8
+ } from "./chunk-3IGNIP6R.js";
9
+ import {
10
+ getAccessToken
11
+ } from "./chunk-C56BC2FY.js";
12
+ import "./chunk-7REDODS2.js";
13
+ import {
14
+ formatFields,
15
+ stdoutStyle
16
+ } from "./chunk-EZG76F7R.js";
17
+ import "./chunk-GNPVYOPB.js";
18
+
19
+ // src/emit/profile-command.ts
20
+ var PROFILE_TIMEOUT_MS = 3e4;
21
+ function asString(v) {
22
+ return typeof v === "string" && v !== "" ? v : void 0;
23
+ }
24
+ async function fetchProfile(args) {
25
+ const { access_token, instance } = await getAccessToken(args);
26
+ const url = new URL("/api:meta/auth/me", instance);
27
+ const res = await fetchOrExplain(
28
+ url.href,
29
+ {
30
+ headers: { Authorization: `Bearer ${access_token}` },
31
+ signal: AbortSignal.timeout(PROFILE_TIMEOUT_MS)
32
+ },
33
+ "profile me",
34
+ PROFILE_TIMEOUT_MS
35
+ );
36
+ const text = await res.text();
37
+ if (!res.ok) {
38
+ throw new Error(httpFailure("profile me", res, text));
39
+ }
40
+ let data = {};
41
+ try {
42
+ data = JSON.parse(text);
43
+ } catch {
44
+ throw new Error(`profile me: could not parse the ${url.pathname} response as JSON:
45
+ ${text}`);
46
+ }
47
+ return {
48
+ instance,
49
+ user: {
50
+ id: typeof data.id === "number" ? data.id : void 0,
51
+ name: asString(data.name),
52
+ email: asString(data.email)
53
+ }
54
+ };
55
+ }
56
+ function prettyProfile(p) {
57
+ const s = stdoutStyle();
58
+ const who = [p.user.name, p.user.email && `<${p.user.email}>`].filter(Boolean).join(" ");
59
+ const id = p.user.id !== void 0 ? ` ${s.dim(`\xB7 id ${p.user.id}`)}` : "";
60
+ return "\n" + formatFields([
61
+ ["Signed in", who !== "" ? `${who}${id}` : s.dim("(unknown user)")],
62
+ ["Instance", s.bold(s.cyan(p.instance))]
63
+ ]);
64
+ }
65
+ async function runProfileCommand(args) {
66
+ const profile = await fetchProfile(args);
67
+ if (isMachineOutput(args)) {
68
+ writeJson(profile);
69
+ } else {
70
+ process.stdout.write(prettyProfile(profile));
71
+ }
72
+ }
73
+ export {
74
+ fetchProfile,
75
+ runProfileCommand
76
+ };
77
+ //# sourceMappingURL=profile-command-SWJ3SPKR.js.map