@databricks/appkit 0.37.0 → 0.38.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 (148) hide show
  1. package/CLAUDE.md +3 -2
  2. package/dist/appkit/package.js +1 -1
  3. package/dist/cache/index.js +1 -2
  4. package/dist/cache/index.js.map +1 -1
  5. package/dist/cache/storage/persistent.js +1 -2
  6. package/dist/cache/storage/persistent.js.map +1 -1
  7. package/dist/cli/commands/plugin/add-resource/add-resource.js.map +1 -1
  8. package/dist/cli/commands/plugin/create/resource-defaults.js +2 -1
  9. package/dist/cli/commands/plugin/create/resource-defaults.js.map +1 -1
  10. package/dist/cli/commands/plugin/schema-resources.js +34 -51
  11. package/dist/cli/commands/plugin/schema-resources.js.map +1 -1
  12. package/dist/cli/commands/plugin/sync/sync.js +20 -6
  13. package/dist/cli/commands/plugin/sync/sync.js.map +1 -1
  14. package/dist/cli/commands/plugin/validate/validate-manifest.js +71 -157
  15. package/dist/cli/commands/plugin/validate/validate-manifest.js.map +1 -1
  16. package/dist/cli/commands/plugin/validate/validate.js +2 -2
  17. package/dist/cli/commands/plugin/validate/validate.js.map +1 -1
  18. package/dist/cli/commands/setup.js +2 -2
  19. package/dist/cli/commands/setup.js.map +1 -1
  20. package/dist/connectors/index.js +0 -1
  21. package/dist/connectors/jobs/client.js +1 -2
  22. package/dist/connectors/jobs/client.js.map +1 -1
  23. package/dist/connectors/lakebase/routing-pool.js +1 -2
  24. package/dist/connectors/lakebase/routing-pool.js.map +1 -1
  25. package/dist/connectors/sql-warehouse/client.js +1 -2
  26. package/dist/connectors/sql-warehouse/client.js.map +1 -1
  27. package/dist/context/execution-context.js +9 -13
  28. package/dist/context/execution-context.js.map +1 -1
  29. package/dist/context/index.js +3 -13
  30. package/dist/context/service-context.js +137 -136
  31. package/dist/context/service-context.js.map +1 -1
  32. package/dist/context/user-context.js +1 -5
  33. package/dist/context/user-context.js.map +1 -1
  34. package/dist/core/agent/create-agent.js +1 -2
  35. package/dist/core/agent/create-agent.js.map +1 -1
  36. package/dist/core/appkit.js +1 -2
  37. package/dist/core/appkit.js.map +1 -1
  38. package/dist/errors/authentication.js +44 -40
  39. package/dist/errors/authentication.js.map +1 -1
  40. package/dist/errors/base.js +86 -70
  41. package/dist/errors/base.js.map +1 -1
  42. package/dist/errors/configuration.js +70 -66
  43. package/dist/errors/configuration.js.map +1 -1
  44. package/dist/errors/connection.js +50 -46
  45. package/dist/errors/connection.js.map +1 -1
  46. package/dist/errors/execution.js +47 -43
  47. package/dist/errors/execution.js.map +1 -1
  48. package/dist/errors/index.js +10 -27
  49. package/dist/errors/initialization.js +38 -34
  50. package/dist/errors/initialization.js.map +1 -1
  51. package/dist/errors/server.js +34 -31
  52. package/dist/errors/server.js.map +1 -1
  53. package/dist/errors/tunnel.js +47 -43
  54. package/dist/errors/tunnel.js.map +1 -1
  55. package/dist/errors/validation.js +41 -37
  56. package/dist/errors/validation.js.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +3 -9
  59. package/dist/plugin/dev-reader.js +1 -2
  60. package/dist/plugin/dev-reader.js.map +1 -1
  61. package/dist/plugin/interceptors/retry.js +1 -2
  62. package/dist/plugin/interceptors/retry.js.map +1 -1
  63. package/dist/plugin/interceptors/telemetry.js +1 -2
  64. package/dist/plugin/interceptors/telemetry.js.map +1 -1
  65. package/dist/plugin/plugin.js +2 -4
  66. package/dist/plugin/plugin.js.map +1 -1
  67. package/dist/plugins/analytics/analytics.js +1 -2
  68. package/dist/plugins/analytics/analytics.js.map +1 -1
  69. package/dist/plugins/analytics/manifest.js +9 -1
  70. package/dist/plugins/analytics/query.js +2 -4
  71. package/dist/plugins/analytics/query.js.map +1 -1
  72. package/dist/plugins/files/manifest.js +7 -1
  73. package/dist/plugins/files/plugin.js +3 -6
  74. package/dist/plugins/files/plugin.js.map +1 -1
  75. package/dist/plugins/genie/genie.js +1 -2
  76. package/dist/plugins/genie/genie.js.map +1 -1
  77. package/dist/plugins/genie/manifest.js +7 -1
  78. package/dist/plugins/jobs/plugin.js +2 -4
  79. package/dist/plugins/jobs/plugin.js.map +1 -1
  80. package/dist/plugins/lakebase/lakebase.js +1 -2
  81. package/dist/plugins/lakebase/lakebase.js.map +1 -1
  82. package/dist/plugins/lakebase/manifest.js +26 -4
  83. package/dist/plugins/server/index.js +1 -2
  84. package/dist/plugins/server/index.js.map +1 -1
  85. package/dist/plugins/server/vite-dev-server.js +1 -2
  86. package/dist/plugins/server/vite-dev-server.js.map +1 -1
  87. package/dist/plugins/serving/serving.js +1 -2
  88. package/dist/plugins/serving/serving.js.map +1 -1
  89. package/dist/registry/index.d.ts +1 -1
  90. package/dist/registry/manifest-loader.d.ts +4 -4
  91. package/dist/registry/manifest-loader.d.ts.map +1 -1
  92. package/dist/registry/manifest-loader.js +1 -2
  93. package/dist/registry/manifest-loader.js.map +1 -1
  94. package/dist/registry/resource-registry.js +1 -2
  95. package/dist/registry/resource-registry.js.map +1 -1
  96. package/dist/registry/types.d.ts +21 -7
  97. package/dist/registry/types.d.ts.map +1 -1
  98. package/dist/registry/types.generated.d.ts +1 -1
  99. package/dist/registry/types.generated.js +1 -1
  100. package/dist/registry/types.generated.js.map +1 -1
  101. package/dist/registry/types.js +3 -3
  102. package/dist/registry/types.js.map +1 -1
  103. package/dist/schemas/manifest.d.ts +1139 -0
  104. package/dist/schemas/manifest.d.ts.map +1 -0
  105. package/dist/schemas/manifest.js +524 -0
  106. package/dist/schemas/manifest.js.map +1 -0
  107. package/dist/shared/src/index.d.ts +1 -1
  108. package/dist/shared/src/plugin.d.ts +38 -7
  109. package/dist/shared/src/plugin.d.ts.map +1 -1
  110. package/dist/shared/src/schemas/manifest.d.ts +1110 -0
  111. package/dist/shared/src/schemas/manifest.d.ts.map +1 -0
  112. package/dist/stream/arrow-stream-processor.js +1 -2
  113. package/dist/stream/arrow-stream-processor.js.map +1 -1
  114. package/dist/stream/buffers.js +1 -2
  115. package/dist/stream/buffers.js.map +1 -1
  116. package/docs/api/appkit/Enumeration.ResourceType.md +1 -1
  117. package/docs/api/appkit/Interface.PluginManifest.md +57 -3
  118. package/docs/api/appkit/Interface.ResourceEntry.md +6 -4
  119. package/docs/api/appkit/Interface.ResourceRequirement.md +7 -61
  120. package/docs/api/appkit/TypeAlias.ResourceFieldEntry.md +6 -0
  121. package/docs/api/appkit.md +6 -6
  122. package/docs/app-management.md +1 -1
  123. package/docs/development/ai-assisted-development.md +2 -2
  124. package/docs/development/local-development.md +1 -1
  125. package/docs/development/remote-bridge.md +1 -1
  126. package/docs/development/templates.md +118 -12
  127. package/docs/development.md +1 -1
  128. package/docs/plugins/custom-plugins.md +33 -23
  129. package/docs/plugins/lakebase.md +1 -1
  130. package/docs/plugins/manifest.md +293 -0
  131. package/docs.md +2 -2
  132. package/llms.txt +3 -2
  133. package/package.json +3 -3
  134. package/sbom.cdx.json +1 -1
  135. package/dist/_virtual/_rolldown/runtime.js +0 -7
  136. package/dist/connectors/lakebase-v1/client.js +0 -15
  137. package/dist/connectors/lakebase-v1/client.js.map +0 -1
  138. package/dist/connectors/lakebase-v1/index.js +0 -3
  139. package/dist/context/index.js.map +0 -1
  140. package/dist/errors/index.js.map +0 -1
  141. package/dist/index.js.map +0 -1
  142. package/dist/schemas/plugin-manifest.generated.d.ts +0 -182
  143. package/dist/schemas/plugin-manifest.generated.d.ts.map +0 -1
  144. package/dist/schemas/plugin-manifest.schema.json +0 -489
  145. package/dist/schemas/template-plugins.schema.json +0 -113
  146. package/dist/shared/src/schemas/plugin-manifest.generated.d.ts +0 -182
  147. package/dist/shared/src/schemas/plugin-manifest.generated.d.ts.map +0 -1
  148. package/docs/api/appkit/Interface.ResourceFieldEntry.md +0 -82
@@ -1,28 +1,11 @@
1
- import { __esmMin } from "../_virtual/_rolldown/runtime.js";
2
- import { AppKitError, init_base } from "./base.js";
3
- import { AuthenticationError, init_authentication } from "./authentication.js";
4
- import { ConfigurationError, init_configuration } from "./configuration.js";
5
- import { ConnectionError, init_connection } from "./connection.js";
6
- import { ExecutionError, init_execution } from "./execution.js";
7
- import { InitializationError, init_initialization } from "./initialization.js";
8
- import { ServerError, init_server } from "./server.js";
9
- import { TunnelError, init_tunnel } from "./tunnel.js";
10
- import { ValidationError, init_validation } from "./validation.js";
1
+ import { AppKitError } from "./base.js";
2
+ import { AuthenticationError } from "./authentication.js";
3
+ import { ConfigurationError } from "./configuration.js";
4
+ import { ConnectionError } from "./connection.js";
5
+ import { ExecutionError } from "./execution.js";
6
+ import { InitializationError } from "./initialization.js";
7
+ import { ServerError } from "./server.js";
8
+ import { TunnelError } from "./tunnel.js";
9
+ import { ValidationError } from "./validation.js";
11
10
 
12
- //#region src/errors/index.ts
13
- var init_errors = __esmMin((() => {
14
- init_authentication();
15
- init_base();
16
- init_configuration();
17
- init_connection();
18
- init_execution();
19
- init_initialization();
20
- init_server();
21
- init_tunnel();
22
- init_validation();
23
- }));
24
-
25
- //#endregion
26
- init_errors();
27
- export { init_errors };
28
- //# sourceMappingURL=index.js.map
11
+ export { };
@@ -1,39 +1,43 @@
1
- import { __esmMin } from "../_virtual/_rolldown/runtime.js";
2
- import { AppKitError, init_base } from "./base.js";
1
+ import { AppKitError } from "./base.js";
3
2
 
4
3
  //#region src/errors/initialization.ts
5
- var InitializationError;
6
- var init_initialization = __esmMin((() => {
7
- init_base();
8
- InitializationError = class InitializationError extends AppKitError {
9
- code = "INITIALIZATION_ERROR";
10
- statusCode = 500;
11
- isRetryable = true;
12
- /**
13
- * Create an initialization error for a service that is not ready
14
- */
15
- static notInitialized(serviceName, hint) {
16
- return new InitializationError(hint ? `${serviceName} not initialized. ${hint}` : `${serviceName} not initialized`, { context: { service: serviceName } });
17
- }
18
- /**
19
- * Create an initialization error for setup failure
20
- */
21
- static setupFailed(component, cause) {
22
- return new InitializationError(`Failed to initialize ${component}`, {
23
- cause,
24
- context: { component }
25
- });
26
- }
27
- /**
28
- * Create an initialization error for migration failure
29
- */
30
- static migrationFailed(cause) {
31
- return new InitializationError("Error in running migrations for persistent storage", { cause });
32
- }
33
- };
34
- }));
4
+ /**
5
+ * Error thrown when a service or component is not properly initialized.
6
+ * Use when accessing services before they are ready.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new InitializationError("CacheManager not initialized");
11
+ * throw new InitializationError("ServiceContext not initialized. Call ServiceContext.initialize() first.");
12
+ * ```
13
+ */
14
+ var InitializationError = class InitializationError extends AppKitError {
15
+ code = "INITIALIZATION_ERROR";
16
+ statusCode = 500;
17
+ isRetryable = true;
18
+ /**
19
+ * Create an initialization error for a service that is not ready
20
+ */
21
+ static notInitialized(serviceName, hint) {
22
+ return new InitializationError(hint ? `${serviceName} not initialized. ${hint}` : `${serviceName} not initialized`, { context: { service: serviceName } });
23
+ }
24
+ /**
25
+ * Create an initialization error for setup failure
26
+ */
27
+ static setupFailed(component, cause) {
28
+ return new InitializationError(`Failed to initialize ${component}`, {
29
+ cause,
30
+ context: { component }
31
+ });
32
+ }
33
+ /**
34
+ * Create an initialization error for migration failure
35
+ */
36
+ static migrationFailed(cause) {
37
+ return new InitializationError("Error in running migrations for persistent storage", { cause });
38
+ }
39
+ };
35
40
 
36
41
  //#endregion
37
- init_initialization();
38
- export { InitializationError, init_initialization };
42
+ export { InitializationError };
39
43
  //# sourceMappingURL=initialization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialization.js","names":[],"sources":["../../src/errors/initialization.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when a service or component is not properly initialized.\n * Use when accessing services before they are ready.\n *\n * @example\n * ```typescript\n * throw new InitializationError(\"CacheManager not initialized\");\n * throw new InitializationError(\"ServiceContext not initialized. Call ServiceContext.initialize() first.\");\n * ```\n */\nexport class InitializationError extends AppKitError {\n readonly code = \"INITIALIZATION_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = true;\n\n /**\n * Create an initialization error for a service that is not ready\n */\n static notInitialized(\n serviceName: string,\n hint?: string,\n ): InitializationError {\n const message = hint\n ? `${serviceName} not initialized. ${hint}`\n : `${serviceName} not initialized`;\n return new InitializationError(message, {\n context: { service: serviceName },\n });\n }\n\n /**\n * Create an initialization error for setup failure\n */\n static setupFailed(component: string, cause?: Error): InitializationError {\n return new InitializationError(`Failed to initialize ${component}`, {\n cause,\n context: { component },\n });\n }\n\n /**\n * Create an initialization error for migration failure\n */\n static migrationFailed(cause?: Error): InitializationError {\n return new InitializationError(\n \"Error in running migrations for persistent storage\",\n { cause },\n );\n }\n}\n"],"mappings":";;;;;;YAAqC;CAYxB,sBAAb,MAAa,4BAA4B,YAAY;EACnD,AAAS,OAAO;EAChB,AAAS,aAAa;EACtB,AAAS,cAAc;;;;EAKvB,OAAO,eACL,aACA,MACqB;AAIrB,UAAO,IAAI,oBAHK,OACZ,GAAG,YAAY,oBAAoB,SACnC,GAAG,YAAY,mBACqB,EACtC,SAAS,EAAE,SAAS,aAAa,EAClC,CAAC;;;;;EAMJ,OAAO,YAAY,WAAmB,OAAoC;AACxE,UAAO,IAAI,oBAAoB,wBAAwB,aAAa;IAClE;IACA,SAAS,EAAE,WAAW;IACvB,CAAC;;;;;EAMJ,OAAO,gBAAgB,OAAoC;AACzD,UAAO,IAAI,oBACT,sDACA,EAAE,OAAO,CACV"}
1
+ {"version":3,"file":"initialization.js","names":[],"sources":["../../src/errors/initialization.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when a service or component is not properly initialized.\n * Use when accessing services before they are ready.\n *\n * @example\n * ```typescript\n * throw new InitializationError(\"CacheManager not initialized\");\n * throw new InitializationError(\"ServiceContext not initialized. Call ServiceContext.initialize() first.\");\n * ```\n */\nexport class InitializationError extends AppKitError {\n readonly code = \"INITIALIZATION_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = true;\n\n /**\n * Create an initialization error for a service that is not ready\n */\n static notInitialized(\n serviceName: string,\n hint?: string,\n ): InitializationError {\n const message = hint\n ? `${serviceName} not initialized. ${hint}`\n : `${serviceName} not initialized`;\n return new InitializationError(message, {\n context: { service: serviceName },\n });\n }\n\n /**\n * Create an initialization error for setup failure\n */\n static setupFailed(component: string, cause?: Error): InitializationError {\n return new InitializationError(`Failed to initialize ${component}`, {\n cause,\n context: { component },\n });\n }\n\n /**\n * Create an initialization error for migration failure\n */\n static migrationFailed(cause?: Error): InitializationError {\n return new InitializationError(\n \"Error in running migrations for persistent storage\",\n { cause },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,sBAAb,MAAa,4BAA4B,YAAY;CACnD,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,eACL,aACA,MACqB;AAIrB,SAAO,IAAI,oBAHK,OACZ,GAAG,YAAY,oBAAoB,SACnC,GAAG,YAAY,mBACqB,EACtC,SAAS,EAAE,SAAS,aAAa,EAClC,CAAC;;;;;CAMJ,OAAO,YAAY,WAAmB,OAAoC;AACxE,SAAO,IAAI,oBAAoB,wBAAwB,aAAa;GAClE;GACA,SAAS,EAAE,WAAW;GACvB,CAAC;;;;;CAMJ,OAAO,gBAAgB,OAAoC;AACzD,SAAO,IAAI,oBACT,sDACA,EAAE,OAAO,CACV"}
@@ -1,36 +1,39 @@
1
- import { __esmMin } from "../_virtual/_rolldown/runtime.js";
2
- import { AppKitError, init_base } from "./base.js";
1
+ import { AppKitError } from "./base.js";
3
2
 
4
3
  //#region src/errors/server.ts
5
- var ServerError;
6
- var init_server = __esmMin((() => {
7
- init_base();
8
- ServerError = class ServerError extends AppKitError {
9
- code = "SERVER_ERROR";
10
- statusCode = 500;
11
- isRetryable = false;
12
- /**
13
- * Create a server error for server not started
14
- */
15
- static notStarted() {
16
- return new ServerError("Server not started. Please start the server first by calling the start() method");
17
- }
18
- /**
19
- * Create a server error for Vite dev server not initialized
20
- */
21
- static viteNotInitialized() {
22
- return new ServerError("Vite dev server not initialized");
23
- }
24
- /**
25
- * Create a server error for missing client directory
26
- */
27
- static clientDirectoryNotFound(searchedPaths) {
28
- return new ServerError(`Could not find client directory. Searched for vite.config.ts/js + index.html in: ${searchedPaths.join(", ")}`, { context: { searchedPaths } });
29
- }
30
- };
31
- }));
4
+ /**
5
+ * Error thrown when server lifecycle operations fail.
6
+ * Use for server start/stop issues, configuration conflicts, etc.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new ServerError("Server not started");
11
+ * ```
12
+ */
13
+ var ServerError = class ServerError extends AppKitError {
14
+ code = "SERVER_ERROR";
15
+ statusCode = 500;
16
+ isRetryable = false;
17
+ /**
18
+ * Create a server error for server not started
19
+ */
20
+ static notStarted() {
21
+ return new ServerError("Server not started. Please start the server first by calling the start() method");
22
+ }
23
+ /**
24
+ * Create a server error for Vite dev server not initialized
25
+ */
26
+ static viteNotInitialized() {
27
+ return new ServerError("Vite dev server not initialized");
28
+ }
29
+ /**
30
+ * Create a server error for missing client directory
31
+ */
32
+ static clientDirectoryNotFound(searchedPaths) {
33
+ return new ServerError(`Could not find client directory. Searched for vite.config.ts/js + index.html in: ${searchedPaths.join(", ")}`, { context: { searchedPaths } });
34
+ }
35
+ };
32
36
 
33
37
  //#endregion
34
- init_server();
35
- export { ServerError, init_server };
38
+ export { ServerError };
36
39
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../../src/errors/server.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when server lifecycle operations fail.\n * Use for server start/stop issues, configuration conflicts, etc.\n *\n * @example\n * ```typescript\n * throw new ServerError(\"Server not started\");\n * ```\n */\nexport class ServerError extends AppKitError {\n readonly code = \"SERVER_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = false;\n\n /**\n * Create a server error for server not started\n */\n static notStarted(): ServerError {\n return new ServerError(\n \"Server not started. Please start the server first by calling the start() method\",\n );\n }\n\n /**\n * Create a server error for Vite dev server not initialized\n */\n static viteNotInitialized(): ServerError {\n return new ServerError(\"Vite dev server not initialized\");\n }\n\n /**\n * Create a server error for missing client directory\n */\n static clientDirectoryNotFound(searchedPaths: string[]): ServerError {\n return new ServerError(\n `Could not find client directory. Searched for vite.config.ts/js + index.html in: ${searchedPaths.join(\", \")}`,\n { context: { searchedPaths } },\n );\n }\n}\n"],"mappings":";;;;;;YAAqC;CAWxB,cAAb,MAAa,oBAAoB,YAAY;EAC3C,AAAS,OAAO;EAChB,AAAS,aAAa;EACtB,AAAS,cAAc;;;;EAKvB,OAAO,aAA0B;AAC/B,UAAO,IAAI,YACT,kFACD;;;;;EAMH,OAAO,qBAAkC;AACvC,UAAO,IAAI,YAAY,kCAAkC;;;;;EAM3D,OAAO,wBAAwB,eAAsC;AACnE,UAAO,IAAI,YACT,oFAAoF,cAAc,KAAK,KAAK,IAC5G,EAAE,SAAS,EAAE,eAAe,EAAE,CAC/B"}
1
+ {"version":3,"file":"server.js","names":[],"sources":["../../src/errors/server.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when server lifecycle operations fail.\n * Use for server start/stop issues, configuration conflicts, etc.\n *\n * @example\n * ```typescript\n * throw new ServerError(\"Server not started\");\n * ```\n */\nexport class ServerError extends AppKitError {\n readonly code = \"SERVER_ERROR\";\n readonly statusCode = 500;\n readonly isRetryable = false;\n\n /**\n * Create a server error for server not started\n */\n static notStarted(): ServerError {\n return new ServerError(\n \"Server not started. Please start the server first by calling the start() method\",\n );\n }\n\n /**\n * Create a server error for Vite dev server not initialized\n */\n static viteNotInitialized(): ServerError {\n return new ServerError(\"Vite dev server not initialized\");\n }\n\n /**\n * Create a server error for missing client directory\n */\n static clientDirectoryNotFound(searchedPaths: string[]): ServerError {\n return new ServerError(\n `Could not find client directory. Searched for vite.config.ts/js + index.html in: ${searchedPaths.join(\", \")}`,\n { context: { searchedPaths } },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,cAAb,MAAa,oBAAoB,YAAY;CAC3C,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,aAA0B;AAC/B,SAAO,IAAI,YACT,kFACD;;;;;CAMH,OAAO,qBAAkC;AACvC,SAAO,IAAI,YAAY,kCAAkC;;;;;CAM3D,OAAO,wBAAwB,eAAsC;AACnE,SAAO,IAAI,YACT,oFAAoF,cAAc,KAAK,KAAK,IAC5G,EAAE,SAAS,EAAE,eAAe,EAAE,CAC/B"}
@@ -1,48 +1,52 @@
1
- import { __esmMin } from "../_virtual/_rolldown/runtime.js";
2
- import { AppKitError, init_base } from "./base.js";
1
+ import { AppKitError } from "./base.js";
3
2
 
4
3
  //#region src/errors/tunnel.ts
5
- var TunnelError;
6
- var init_tunnel = __esmMin((() => {
7
- init_base();
8
- TunnelError = class TunnelError extends AppKitError {
9
- code = "TUNNEL_ERROR";
10
- statusCode = 502;
11
- isRetryable = true;
12
- /**
13
- * Create a tunnel error for missing tunnel getter
14
- */
15
- static getterNotRegistered() {
16
- return new TunnelError("Tunnel getter not registered for DevFileReader singleton");
17
- }
18
- /**
19
- * Create a tunnel error for no available connection
20
- */
21
- static noConnection() {
22
- return new TunnelError("No tunnel connection available for file read");
23
- }
24
- /**
25
- * Create a tunnel error for asset fetch failure
26
- */
27
- static fetchFailed(path, cause) {
28
- return new TunnelError("Failed to fetch asset", {
29
- cause,
30
- context: { path }
31
- });
32
- }
33
- /**
34
- * Create a tunnel error for message parsing failure
35
- */
36
- static parseError(messageType, cause) {
37
- return new TunnelError(`Failed to parse ${messageType} message`, {
38
- cause,
39
- context: { messageType }
40
- });
41
- }
42
- };
43
- }));
4
+ /**
5
+ * Error thrown when remote tunnel operations fail.
6
+ * Use for tunnel connection issues, message parsing failures, etc.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new TunnelError("No tunnel connection available");
11
+ * throw new TunnelError("Failed to parse WebSocket message", { cause: parseError });
12
+ * ```
13
+ */
14
+ var TunnelError = class TunnelError extends AppKitError {
15
+ code = "TUNNEL_ERROR";
16
+ statusCode = 502;
17
+ isRetryable = true;
18
+ /**
19
+ * Create a tunnel error for missing tunnel getter
20
+ */
21
+ static getterNotRegistered() {
22
+ return new TunnelError("Tunnel getter not registered for DevFileReader singleton");
23
+ }
24
+ /**
25
+ * Create a tunnel error for no available connection
26
+ */
27
+ static noConnection() {
28
+ return new TunnelError("No tunnel connection available for file read");
29
+ }
30
+ /**
31
+ * Create a tunnel error for asset fetch failure
32
+ */
33
+ static fetchFailed(path, cause) {
34
+ return new TunnelError("Failed to fetch asset", {
35
+ cause,
36
+ context: { path }
37
+ });
38
+ }
39
+ /**
40
+ * Create a tunnel error for message parsing failure
41
+ */
42
+ static parseError(messageType, cause) {
43
+ return new TunnelError(`Failed to parse ${messageType} message`, {
44
+ cause,
45
+ context: { messageType }
46
+ });
47
+ }
48
+ };
44
49
 
45
50
  //#endregion
46
- init_tunnel();
47
- export { TunnelError, init_tunnel };
51
+ export { TunnelError };
48
52
  //# sourceMappingURL=tunnel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.js","names":[],"sources":["../../src/errors/tunnel.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when remote tunnel operations fail.\n * Use for tunnel connection issues, message parsing failures, etc.\n *\n * @example\n * ```typescript\n * throw new TunnelError(\"No tunnel connection available\");\n * throw new TunnelError(\"Failed to parse WebSocket message\", { cause: parseError });\n * ```\n */\nexport class TunnelError extends AppKitError {\n readonly code = \"TUNNEL_ERROR\";\n readonly statusCode = 502;\n readonly isRetryable = true;\n\n /**\n * Create a tunnel error for missing tunnel getter\n */\n static getterNotRegistered(): TunnelError {\n return new TunnelError(\n \"Tunnel getter not registered for DevFileReader singleton\",\n );\n }\n\n /**\n * Create a tunnel error for no available connection\n */\n static noConnection(): TunnelError {\n return new TunnelError(\"No tunnel connection available for file read\");\n }\n\n /**\n * Create a tunnel error for asset fetch failure\n */\n static fetchFailed(path: string, cause?: Error): TunnelError {\n return new TunnelError(\"Failed to fetch asset\", {\n cause,\n context: { path },\n });\n }\n\n /**\n * Create a tunnel error for message parsing failure\n */\n static parseError(messageType: string, cause?: Error): TunnelError {\n return new TunnelError(`Failed to parse ${messageType} message`, {\n cause,\n context: { messageType },\n });\n }\n}\n"],"mappings":";;;;;;YAAqC;CAYxB,cAAb,MAAa,oBAAoB,YAAY;EAC3C,AAAS,OAAO;EAChB,AAAS,aAAa;EACtB,AAAS,cAAc;;;;EAKvB,OAAO,sBAAmC;AACxC,UAAO,IAAI,YACT,2DACD;;;;;EAMH,OAAO,eAA4B;AACjC,UAAO,IAAI,YAAY,+CAA+C;;;;;EAMxE,OAAO,YAAY,MAAc,OAA4B;AAC3D,UAAO,IAAI,YAAY,yBAAyB;IAC9C;IACA,SAAS,EAAE,MAAM;IAClB,CAAC;;;;;EAMJ,OAAO,WAAW,aAAqB,OAA4B;AACjE,UAAO,IAAI,YAAY,mBAAmB,YAAY,WAAW;IAC/D;IACA,SAAS,EAAE,aAAa;IACzB,CAAC"}
1
+ {"version":3,"file":"tunnel.js","names":[],"sources":["../../src/errors/tunnel.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when remote tunnel operations fail.\n * Use for tunnel connection issues, message parsing failures, etc.\n *\n * @example\n * ```typescript\n * throw new TunnelError(\"No tunnel connection available\");\n * throw new TunnelError(\"Failed to parse WebSocket message\", { cause: parseError });\n * ```\n */\nexport class TunnelError extends AppKitError {\n readonly code = \"TUNNEL_ERROR\";\n readonly statusCode = 502;\n readonly isRetryable = true;\n\n /**\n * Create a tunnel error for missing tunnel getter\n */\n static getterNotRegistered(): TunnelError {\n return new TunnelError(\n \"Tunnel getter not registered for DevFileReader singleton\",\n );\n }\n\n /**\n * Create a tunnel error for no available connection\n */\n static noConnection(): TunnelError {\n return new TunnelError(\"No tunnel connection available for file read\");\n }\n\n /**\n * Create a tunnel error for asset fetch failure\n */\n static fetchFailed(path: string, cause?: Error): TunnelError {\n return new TunnelError(\"Failed to fetch asset\", {\n cause,\n context: { path },\n });\n }\n\n /**\n * Create a tunnel error for message parsing failure\n */\n static parseError(messageType: string, cause?: Error): TunnelError {\n return new TunnelError(`Failed to parse ${messageType} message`, {\n cause,\n context: { messageType },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,cAAb,MAAa,oBAAoB,YAAY;CAC3C,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,sBAAmC;AACxC,SAAO,IAAI,YACT,2DACD;;;;;CAMH,OAAO,eAA4B;AACjC,SAAO,IAAI,YAAY,+CAA+C;;;;;CAMxE,OAAO,YAAY,MAAc,OAA4B;AAC3D,SAAO,IAAI,YAAY,yBAAyB;GAC9C;GACA,SAAS,EAAE,MAAM;GAClB,CAAC;;;;;CAMJ,OAAO,WAAW,aAAqB,OAA4B;AACjE,SAAO,IAAI,YAAY,mBAAmB,YAAY,WAAW;GAC/D;GACA,SAAS,EAAE,aAAa;GACzB,CAAC"}
@@ -1,42 +1,46 @@
1
- import { __esmMin } from "../_virtual/_rolldown/runtime.js";
2
- import { AppKitError, init_base } from "./base.js";
1
+ import { AppKitError } from "./base.js";
3
2
 
4
3
  //#region src/errors/validation.ts
5
- var ValidationError;
6
- var init_validation = __esmMin((() => {
7
- init_base();
8
- ValidationError = class ValidationError extends AppKitError {
9
- code = "VALIDATION_ERROR";
10
- statusCode = 400;
11
- isRetryable = false;
12
- /**
13
- * Create a validation error for a missing required field
14
- */
15
- static missingField(fieldName) {
16
- return new ValidationError(`Missing required field: ${fieldName}`, { context: { field: fieldName } });
17
- }
18
- /**
19
- * Create a validation error for an invalid field value.
20
- * Note: The actual value is not stored in context for security reasons.
21
- * Only the value's type is recorded.
22
- */
23
- static invalidValue(fieldName, value, expected) {
24
- return new ValidationError(expected ? `Invalid value for ${fieldName}: expected ${expected}` : `Invalid value for ${fieldName}`, { context: {
25
- field: fieldName,
26
- valueType: value === null ? "null" : typeof value,
27
- expected
28
- } });
29
- }
30
- /**
31
- * Create a validation error for missing environment variables
32
- */
33
- static missingEnvVars(vars) {
34
- return new ValidationError(`Missing required environment variables: ${vars.join(", ")}`, { context: { missingVars: vars } });
35
- }
36
- };
37
- }));
4
+ /**
5
+ * Error thrown when input validation fails.
6
+ * Use for invalid parameters, missing required fields, or type mismatches.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * throw new ValidationError("Statement is required", { context: { field: "statement" } });
11
+ * throw new ValidationError("maxPoolSize must be at least 1", { context: { value: config.maxPoolSize } });
12
+ * ```
13
+ */
14
+ var ValidationError = class ValidationError extends AppKitError {
15
+ code = "VALIDATION_ERROR";
16
+ statusCode = 400;
17
+ isRetryable = false;
18
+ /**
19
+ * Create a validation error for a missing required field
20
+ */
21
+ static missingField(fieldName) {
22
+ return new ValidationError(`Missing required field: ${fieldName}`, { context: { field: fieldName } });
23
+ }
24
+ /**
25
+ * Create a validation error for an invalid field value.
26
+ * Note: The actual value is not stored in context for security reasons.
27
+ * Only the value's type is recorded.
28
+ */
29
+ static invalidValue(fieldName, value, expected) {
30
+ return new ValidationError(expected ? `Invalid value for ${fieldName}: expected ${expected}` : `Invalid value for ${fieldName}`, { context: {
31
+ field: fieldName,
32
+ valueType: value === null ? "null" : typeof value,
33
+ expected
34
+ } });
35
+ }
36
+ /**
37
+ * Create a validation error for missing environment variables
38
+ */
39
+ static missingEnvVars(vars) {
40
+ return new ValidationError(`Missing required environment variables: ${vars.join(", ")}`, { context: { missingVars: vars } });
41
+ }
42
+ };
38
43
 
39
44
  //#endregion
40
- init_validation();
41
- export { ValidationError, init_validation };
45
+ export { ValidationError };
42
46
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":[],"sources":["../../src/errors/validation.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when input validation fails.\n * Use for invalid parameters, missing required fields, or type mismatches.\n *\n * @example\n * ```typescript\n * throw new ValidationError(\"Statement is required\", { context: { field: \"statement\" } });\n * throw new ValidationError(\"maxPoolSize must be at least 1\", { context: { value: config.maxPoolSize } });\n * ```\n */\nexport class ValidationError extends AppKitError {\n readonly code = \"VALIDATION_ERROR\";\n readonly statusCode = 400;\n readonly isRetryable = false;\n\n /**\n * Create a validation error for a missing required field\n */\n static missingField(fieldName: string): ValidationError {\n return new ValidationError(`Missing required field: ${fieldName}`, {\n context: { field: fieldName },\n });\n }\n\n /**\n * Create a validation error for an invalid field value.\n * Note: The actual value is not stored in context for security reasons.\n * Only the value's type is recorded.\n */\n static invalidValue(\n fieldName: string,\n value: unknown,\n expected?: string,\n ): ValidationError {\n const msg = expected\n ? `Invalid value for ${fieldName}: expected ${expected}`\n : `Invalid value for ${fieldName}`;\n return new ValidationError(msg, {\n context: {\n field: fieldName,\n valueType: value === null ? \"null\" : typeof value,\n expected,\n },\n });\n }\n\n /**\n * Create a validation error for missing environment variables\n */\n static missingEnvVars(vars: string[]): ValidationError {\n return new ValidationError(\n `Missing required environment variables: ${vars.join(\", \")}`,\n { context: { missingVars: vars } },\n );\n }\n}\n"],"mappings":";;;;;;YAAqC;CAYxB,kBAAb,MAAa,wBAAwB,YAAY;EAC/C,AAAS,OAAO;EAChB,AAAS,aAAa;EACtB,AAAS,cAAc;;;;EAKvB,OAAO,aAAa,WAAoC;AACtD,UAAO,IAAI,gBAAgB,2BAA2B,aAAa,EACjE,SAAS,EAAE,OAAO,WAAW,EAC9B,CAAC;;;;;;;EAQJ,OAAO,aACL,WACA,OACA,UACiB;AAIjB,UAAO,IAAI,gBAHC,WACR,qBAAqB,UAAU,aAAa,aAC5C,qBAAqB,aACO,EAC9B,SAAS;IACP,OAAO;IACP,WAAW,UAAU,OAAO,SAAS,OAAO;IAC5C;IACD,EACF,CAAC;;;;;EAMJ,OAAO,eAAe,MAAiC;AACrD,UAAO,IAAI,gBACT,2CAA2C,KAAK,KAAK,KAAK,IAC1D,EAAE,SAAS,EAAE,aAAa,MAAM,EAAE,CACnC"}
1
+ {"version":3,"file":"validation.js","names":[],"sources":["../../src/errors/validation.ts"],"sourcesContent":["import { AppKitError } from \"./base\";\n\n/**\n * Error thrown when input validation fails.\n * Use for invalid parameters, missing required fields, or type mismatches.\n *\n * @example\n * ```typescript\n * throw new ValidationError(\"Statement is required\", { context: { field: \"statement\" } });\n * throw new ValidationError(\"maxPoolSize must be at least 1\", { context: { value: config.maxPoolSize } });\n * ```\n */\nexport class ValidationError extends AppKitError {\n readonly code = \"VALIDATION_ERROR\";\n readonly statusCode = 400;\n readonly isRetryable = false;\n\n /**\n * Create a validation error for a missing required field\n */\n static missingField(fieldName: string): ValidationError {\n return new ValidationError(`Missing required field: ${fieldName}`, {\n context: { field: fieldName },\n });\n }\n\n /**\n * Create a validation error for an invalid field value.\n * Note: The actual value is not stored in context for security reasons.\n * Only the value's type is recorded.\n */\n static invalidValue(\n fieldName: string,\n value: unknown,\n expected?: string,\n ): ValidationError {\n const msg = expected\n ? `Invalid value for ${fieldName}: expected ${expected}`\n : `Invalid value for ${fieldName}`;\n return new ValidationError(msg, {\n context: {\n field: fieldName,\n valueType: value === null ? \"null\" : typeof value,\n expected,\n },\n });\n }\n\n /**\n * Create a validation error for missing environment variables\n */\n static missingEnvVars(vars: string[]): ValidationError {\n return new ValidationError(\n `Missing required environment variables: ${vars.join(\", \")}`,\n { context: { missingVars: vars } },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAC/C,AAAS,OAAO;CAChB,AAAS,aAAa;CACtB,AAAS,cAAc;;;;CAKvB,OAAO,aAAa,WAAoC;AACtD,SAAO,IAAI,gBAAgB,2BAA2B,aAAa,EACjE,SAAS,EAAE,OAAO,WAAW,EAC9B,CAAC;;;;;;;CAQJ,OAAO,aACL,WACA,OACA,UACiB;AAIjB,SAAO,IAAI,gBAHC,WACR,qBAAqB,UAAU,aAAa,aAC5C,qBAAqB,aACO,EAC9B,SAAS;GACP,OAAO;GACP,WAAW,UAAU,OAAO,SAAS,OAAO;GAC5C;GACD,EACF,CAAC;;;;;CAMJ,OAAO,eAAe,MAAiC;AACrD,SAAO,IAAI,gBACT,2CAA2C,KAAK,KAAK,KAAK,IAC1D,EAAE,SAAS,EAAE,aAAa,MAAM,EAAE,CACnC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ResourceFieldEntry } from "./shared/src/schemas/plugin-manifest.generated.js";
1
+ import { ResourceFieldEntry } from "./shared/src/schemas/manifest.js";
2
2
  import { BasePluginConfig, IAppRouter, PluginData, ToPlugin } from "./shared/src/plugin.js";
3
3
  import { CacheConfig } from "./shared/src/cache.js";
4
4
  import { StreamExecutionSettings } from "./shared/src/execute.js";
package/dist/index.js CHANGED
@@ -10,12 +10,12 @@ import { InitializationError } from "./errors/initialization.js";
10
10
  import { ServerError } from "./errors/server.js";
11
11
  import { TunnelError } from "./errors/tunnel.js";
12
12
  import { ValidationError } from "./errors/validation.js";
13
- import { init_errors } from "./errors/index.js";
13
+ import "./errors/index.js";
14
14
  import { getExecutionContext } from "./context/execution-context.js";
15
15
  import { RequestedClaimsPermissionSet, createLakebasePool, generateDatabaseCredential, getLakebaseOrmConfig, getLakebasePgConfig, getUsernameWithApiLookup, getWorkspaceClient } from "./connectors/lakebase/index.js";
16
16
  import { SeverityNumber, SpanStatusCode } from "./telemetry/index.js";
17
17
  import { CacheManager } from "./cache/index.js";
18
- import { init_context } from "./context/index.js";
18
+ import "./context/index.js";
19
19
  import { Plugin } from "./plugin/plugin.js";
20
20
  import { ResourceType } from "./registry/types.generated.js";
21
21
  import { getPluginManifest, getResourceRequirements } from "./registry/manifest-loader.js";
@@ -38,10 +38,4 @@ import { server } from "./plugins/server/index.js";
38
38
  import { serving } from "./plugins/serving/serving.js";
39
39
  import "./plugins/ga-exports.generated.js";
40
40
 
41
- //#region src/index.ts
42
- init_context();
43
- init_errors();
44
-
45
- //#endregion
46
- export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, PolicyDeniedError, READ_ACTIONS, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, createLakebasePoolManager, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, jobs, lakebase, server, serving, sql, toPlugin };
47
- //# sourceMappingURL=index.js.map
41
+ export { AppKitError, AuthenticationError, CacheManager, ConfigurationError, ConnectionError, ExecutionError, InitializationError, Plugin, PolicyDeniedError, READ_ACTIONS, RequestedClaimsPermissionSet, ResourceRegistry, ResourceType, ServerError, SeverityNumber, SpanStatusCode, TunnelError, ValidationError, WRITE_ACTIONS, analytics, appKitServingTypesPlugin, appKitTypesPlugin, createApp, createLakebasePool, createLakebasePoolManager, extractServingEndpoints, files, findServerFile, generateDatabaseCredential, genie, getExecutionContext, getLakebaseOrmConfig, getLakebasePgConfig, getPluginManifest, getResourceRequirements, getUsernameWithApiLookup, getWorkspaceClient, isSQLTypeMarker, jobs, lakebase, server, serving, sql, toPlugin };
@@ -1,11 +1,10 @@
1
1
  import { createLogger } from "../logging/logger.js";
2
2
  import { TunnelError } from "../errors/tunnel.js";
3
- import { init_errors } from "../errors/index.js";
3
+ import "../errors/index.js";
4
4
  import { isRemoteTunnelAllowedByEnv } from "../plugins/server/remote-tunnel/gate.js";
5
5
  import { randomUUID } from "node:crypto";
6
6
 
7
7
  //#region src/plugin/dev-reader.ts
8
- init_errors();
9
8
  const logger = createLogger("plugin:dev-reader");
10
9
  /**
11
10
  * This class is used to read files from the local filesystem in dev mode
@@ -1 +1 @@
1
- {"version":3,"file":"dev-reader.js","names":[],"sources":["../../src/plugin/dev-reader.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { TunnelConnection } from \"shared\";\nimport { TunnelError } from \"../errors\";\nimport { createLogger } from \"../logging/logger\";\nimport { isRemoteTunnelAllowedByEnv } from \"../plugins/server/remote-tunnel/gate\";\n\nconst logger = createLogger(\"plugin:dev-reader\");\n\ntype TunnelConnectionGetter = (\n req: import(\"express\").Request,\n) => TunnelConnection | null;\n\n/**\n * This class is used to read files from the local filesystem in dev mode\n * through the WebSocket tunnel.\n */\nexport class DevFileReader {\n private static instance: DevFileReader | null = null;\n private getTunnelForRequest: TunnelConnectionGetter | null = null;\n\n private constructor() {}\n\n static getInstance(): DevFileReader {\n if (!DevFileReader.instance) {\n DevFileReader.instance = new Proxy(new DevFileReader(), {\n /**\n * We proxy the reader to return a noop function if the remote server is disabled.\n */\n get(target, prop, receiver) {\n if (isRemoteTunnelAllowedByEnv()) {\n return Reflect.get(target, prop, receiver);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === \"function\") {\n return function noop() {\n logger.debug(\"Noop: %s (remote server disabled)\", String(prop));\n return Promise.resolve(\"\");\n };\n }\n\n return value;\n },\n set(target, prop, value, receiver) {\n return Reflect.set(target, prop, value, receiver);\n },\n });\n }\n\n return DevFileReader.instance;\n }\n\n registerTunnelGetter(getter: TunnelConnectionGetter) {\n this.getTunnelForRequest = getter;\n }\n\n async readFile(\n filePath: string,\n req: import(\"express\").Request,\n ): Promise<string> {\n if (!this.getTunnelForRequest) {\n throw TunnelError.getterNotRegistered();\n }\n const tunnel = this.getTunnelForRequest(req);\n\n if (!tunnel) {\n throw TunnelError.noConnection();\n }\n\n const { ws, pendingFileReads } = tunnel;\n const requestId = randomUUID();\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n pendingFileReads.delete(requestId);\n reject(new Error(`File read timeout: ${filePath}`));\n }, 10000);\n\n pendingFileReads.set(requestId, { resolve, reject, timeout });\n\n ws.send(\n JSON.stringify({\n type: \"file:read\",\n requestId,\n path: filePath,\n }),\n );\n });\n }\n\n async readdir(\n dirPath: string,\n req: import(\"express\").Request,\n ): Promise<string[]> {\n if (!this.getTunnelForRequest) {\n throw TunnelError.getterNotRegistered();\n }\n const tunnel = this.getTunnelForRequest(req);\n\n if (!tunnel) {\n throw TunnelError.noConnection();\n }\n\n const { ws, pendingFileReads } = tunnel;\n const requestId = randomUUID();\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n pendingFileReads.delete(requestId);\n reject(new Error(`Directory read timeout: ${dirPath}`));\n }, 10000);\n\n pendingFileReads.set(requestId, {\n resolve: (data: string) => {\n try {\n const files = JSON.parse(data);\n // Validate it's an array of strings\n if (!Array.isArray(files)) {\n reject(\n new Error(\n \"Invalid directory listing format: expected array, got \" +\n typeof files,\n ),\n );\n return;\n }\n if (!files.every((f) => typeof f === \"string\")) {\n reject(\n new Error(\n \"Invalid directory listing format: expected array of strings\",\n ),\n );\n return;\n }\n resolve(files);\n } catch (error) {\n reject(\n new Error(\n `Failed to parse directory listing: ${(error as Error).message}`,\n ),\n );\n }\n },\n reject,\n timeout,\n });\n\n ws.send(\n JSON.stringify({\n type: \"dir:list\",\n requestId,\n path: dirPath,\n }),\n );\n });\n }\n}\n"],"mappings":";;;;;;;aAEwC;AAIxC,MAAM,SAAS,aAAa,oBAAoB;;;;;AAUhD,IAAa,gBAAb,MAAa,cAAc;CACzB,OAAe,WAAiC;CAChD,AAAQ,sBAAqD;CAE7D,AAAQ,cAAc;CAEtB,OAAO,cAA6B;AAClC,MAAI,CAAC,cAAc,SACjB,eAAc,WAAW,IAAI,MAAM,IAAI,eAAe,EAAE;GAItD,IAAI,QAAQ,MAAM,UAAU;AAC1B,QAAI,4BAA4B,CAC9B,QAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAG5C,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,QAAI,OAAO,UAAU,WACnB,QAAO,SAAS,OAAO;AACrB,YAAO,MAAM,qCAAqC,OAAO,KAAK,CAAC;AAC/D,YAAO,QAAQ,QAAQ,GAAG;;AAI9B,WAAO;;GAET,IAAI,QAAQ,MAAM,OAAO,UAAU;AACjC,WAAO,QAAQ,IAAI,QAAQ,MAAM,OAAO,SAAS;;GAEpD,CAAC;AAGJ,SAAO,cAAc;;CAGvB,qBAAqB,QAAgC;AACnD,OAAK,sBAAsB;;CAG7B,MAAM,SACJ,UACA,KACiB;AACjB,MAAI,CAAC,KAAK,oBACR,OAAM,YAAY,qBAAqB;EAEzC,MAAM,SAAS,KAAK,oBAAoB,IAAI;AAE5C,MAAI,CAAC,OACH,OAAM,YAAY,cAAc;EAGlC,MAAM,EAAE,IAAI,qBAAqB;EACjC,MAAM,YAAY,YAAY;AAE9B,SAAO,IAAI,SAAS,SAAS,WAAW;GACtC,MAAM,UAAU,iBAAiB;AAC/B,qBAAiB,OAAO,UAAU;AAClC,2BAAO,IAAI,MAAM,sBAAsB,WAAW,CAAC;MAClD,IAAM;AAET,oBAAiB,IAAI,WAAW;IAAE;IAAS;IAAQ;IAAS,CAAC;AAE7D,MAAG,KACD,KAAK,UAAU;IACb,MAAM;IACN;IACA,MAAM;IACP,CAAC,CACH;IACD;;CAGJ,MAAM,QACJ,SACA,KACmB;AACnB,MAAI,CAAC,KAAK,oBACR,OAAM,YAAY,qBAAqB;EAEzC,MAAM,SAAS,KAAK,oBAAoB,IAAI;AAE5C,MAAI,CAAC,OACH,OAAM,YAAY,cAAc;EAGlC,MAAM,EAAE,IAAI,qBAAqB;EACjC,MAAM,YAAY,YAAY;AAE9B,SAAO,IAAI,SAAS,SAAS,WAAW;GACtC,MAAM,UAAU,iBAAiB;AAC/B,qBAAiB,OAAO,UAAU;AAClC,2BAAO,IAAI,MAAM,2BAA2B,UAAU,CAAC;MACtD,IAAM;AAET,oBAAiB,IAAI,WAAW;IAC9B,UAAU,SAAiB;AACzB,SAAI;MACF,MAAM,QAAQ,KAAK,MAAM,KAAK;AAE9B,UAAI,CAAC,MAAM,QAAQ,MAAM,EAAE;AACzB,8BACE,IAAI,MACF,2DACE,OAAO,MACV,CACF;AACD;;AAEF,UAAI,CAAC,MAAM,OAAO,MAAM,OAAO,MAAM,SAAS,EAAE;AAC9C,8BACE,IAAI,MACF,8DACD,CACF;AACD;;AAEF,cAAQ,MAAM;cACP,OAAO;AACd,6BACE,IAAI,MACF,sCAAuC,MAAgB,UACxD,CACF;;;IAGL;IACA;IACD,CAAC;AAEF,MAAG,KACD,KAAK,UAAU;IACb,MAAM;IACN;IACA,MAAM;IACP,CAAC,CACH;IACD"}
1
+ {"version":3,"file":"dev-reader.js","names":[],"sources":["../../src/plugin/dev-reader.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { TunnelConnection } from \"shared\";\nimport { TunnelError } from \"../errors\";\nimport { createLogger } from \"../logging/logger\";\nimport { isRemoteTunnelAllowedByEnv } from \"../plugins/server/remote-tunnel/gate\";\n\nconst logger = createLogger(\"plugin:dev-reader\");\n\ntype TunnelConnectionGetter = (\n req: import(\"express\").Request,\n) => TunnelConnection | null;\n\n/**\n * This class is used to read files from the local filesystem in dev mode\n * through the WebSocket tunnel.\n */\nexport class DevFileReader {\n private static instance: DevFileReader | null = null;\n private getTunnelForRequest: TunnelConnectionGetter | null = null;\n\n private constructor() {}\n\n static getInstance(): DevFileReader {\n if (!DevFileReader.instance) {\n DevFileReader.instance = new Proxy(new DevFileReader(), {\n /**\n * We proxy the reader to return a noop function if the remote server is disabled.\n */\n get(target, prop, receiver) {\n if (isRemoteTunnelAllowedByEnv()) {\n return Reflect.get(target, prop, receiver);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === \"function\") {\n return function noop() {\n logger.debug(\"Noop: %s (remote server disabled)\", String(prop));\n return Promise.resolve(\"\");\n };\n }\n\n return value;\n },\n set(target, prop, value, receiver) {\n return Reflect.set(target, prop, value, receiver);\n },\n });\n }\n\n return DevFileReader.instance;\n }\n\n registerTunnelGetter(getter: TunnelConnectionGetter) {\n this.getTunnelForRequest = getter;\n }\n\n async readFile(\n filePath: string,\n req: import(\"express\").Request,\n ): Promise<string> {\n if (!this.getTunnelForRequest) {\n throw TunnelError.getterNotRegistered();\n }\n const tunnel = this.getTunnelForRequest(req);\n\n if (!tunnel) {\n throw TunnelError.noConnection();\n }\n\n const { ws, pendingFileReads } = tunnel;\n const requestId = randomUUID();\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n pendingFileReads.delete(requestId);\n reject(new Error(`File read timeout: ${filePath}`));\n }, 10000);\n\n pendingFileReads.set(requestId, { resolve, reject, timeout });\n\n ws.send(\n JSON.stringify({\n type: \"file:read\",\n requestId,\n path: filePath,\n }),\n );\n });\n }\n\n async readdir(\n dirPath: string,\n req: import(\"express\").Request,\n ): Promise<string[]> {\n if (!this.getTunnelForRequest) {\n throw TunnelError.getterNotRegistered();\n }\n const tunnel = this.getTunnelForRequest(req);\n\n if (!tunnel) {\n throw TunnelError.noConnection();\n }\n\n const { ws, pendingFileReads } = tunnel;\n const requestId = randomUUID();\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n pendingFileReads.delete(requestId);\n reject(new Error(`Directory read timeout: ${dirPath}`));\n }, 10000);\n\n pendingFileReads.set(requestId, {\n resolve: (data: string) => {\n try {\n const files = JSON.parse(data);\n // Validate it's an array of strings\n if (!Array.isArray(files)) {\n reject(\n new Error(\n \"Invalid directory listing format: expected array, got \" +\n typeof files,\n ),\n );\n return;\n }\n if (!files.every((f) => typeof f === \"string\")) {\n reject(\n new Error(\n \"Invalid directory listing format: expected array of strings\",\n ),\n );\n return;\n }\n resolve(files);\n } catch (error) {\n reject(\n new Error(\n `Failed to parse directory listing: ${(error as Error).message}`,\n ),\n );\n }\n },\n reject,\n timeout,\n });\n\n ws.send(\n JSON.stringify({\n type: \"dir:list\",\n requestId,\n path: dirPath,\n }),\n );\n });\n }\n}\n"],"mappings":";;;;;;;AAMA,MAAM,SAAS,aAAa,oBAAoB;;;;;AAUhD,IAAa,gBAAb,MAAa,cAAc;CACzB,OAAe,WAAiC;CAChD,AAAQ,sBAAqD;CAE7D,AAAQ,cAAc;CAEtB,OAAO,cAA6B;AAClC,MAAI,CAAC,cAAc,SACjB,eAAc,WAAW,IAAI,MAAM,IAAI,eAAe,EAAE;GAItD,IAAI,QAAQ,MAAM,UAAU;AAC1B,QAAI,4BAA4B,CAC9B,QAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAG5C,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,QAAI,OAAO,UAAU,WACnB,QAAO,SAAS,OAAO;AACrB,YAAO,MAAM,qCAAqC,OAAO,KAAK,CAAC;AAC/D,YAAO,QAAQ,QAAQ,GAAG;;AAI9B,WAAO;;GAET,IAAI,QAAQ,MAAM,OAAO,UAAU;AACjC,WAAO,QAAQ,IAAI,QAAQ,MAAM,OAAO,SAAS;;GAEpD,CAAC;AAGJ,SAAO,cAAc;;CAGvB,qBAAqB,QAAgC;AACnD,OAAK,sBAAsB;;CAG7B,MAAM,SACJ,UACA,KACiB;AACjB,MAAI,CAAC,KAAK,oBACR,OAAM,YAAY,qBAAqB;EAEzC,MAAM,SAAS,KAAK,oBAAoB,IAAI;AAE5C,MAAI,CAAC,OACH,OAAM,YAAY,cAAc;EAGlC,MAAM,EAAE,IAAI,qBAAqB;EACjC,MAAM,YAAY,YAAY;AAE9B,SAAO,IAAI,SAAS,SAAS,WAAW;GACtC,MAAM,UAAU,iBAAiB;AAC/B,qBAAiB,OAAO,UAAU;AAClC,2BAAO,IAAI,MAAM,sBAAsB,WAAW,CAAC;MAClD,IAAM;AAET,oBAAiB,IAAI,WAAW;IAAE;IAAS;IAAQ;IAAS,CAAC;AAE7D,MAAG,KACD,KAAK,UAAU;IACb,MAAM;IACN;IACA,MAAM;IACP,CAAC,CACH;IACD;;CAGJ,MAAM,QACJ,SACA,KACmB;AACnB,MAAI,CAAC,KAAK,oBACR,OAAM,YAAY,qBAAqB;EAEzC,MAAM,SAAS,KAAK,oBAAoB,IAAI;AAE5C,MAAI,CAAC,OACH,OAAM,YAAY,cAAc;EAGlC,MAAM,EAAE,IAAI,qBAAqB;EACjC,MAAM,YAAY,YAAY;AAE9B,SAAO,IAAI,SAAS,SAAS,WAAW;GACtC,MAAM,UAAU,iBAAiB;AAC/B,qBAAiB,OAAO,UAAU;AAClC,2BAAO,IAAI,MAAM,2BAA2B,UAAU,CAAC;MACtD,IAAM;AAET,oBAAiB,IAAI,WAAW;IAC9B,UAAU,SAAiB;AACzB,SAAI;MACF,MAAM,QAAQ,KAAK,MAAM,KAAK;AAE9B,UAAI,CAAC,MAAM,QAAQ,MAAM,EAAE;AACzB,8BACE,IAAI,MACF,2DACE,OAAO,MACV,CACF;AACD;;AAEF,UAAI,CAAC,MAAM,OAAO,MAAM,OAAO,MAAM,SAAS,EAAE;AAC9C,8BACE,IAAI,MACF,8DACD,CACF;AACD;;AAEF,cAAQ,MAAM;cACP,OAAO;AACd,6BACE,IAAI,MACF,sCAAuC,MAAgB,UACxD,CACF;;;IAGL;IACA;IACD,CAAC;AAEF,MAAG,KACD,KAAK,UAAU;IACb,MAAM;IACN;IACA,MAAM;IACP,CAAC,CACH;IACD"}
@@ -1,8 +1,7 @@
1
1
  import { createLogger } from "../../logging/logger.js";
2
- import { AppKitError, init_base } from "../../errors/base.js";
2
+ import { AppKitError } from "../../errors/base.js";
3
3
 
4
4
  //#region src/plugin/interceptors/retry.ts
5
- init_base();
6
5
  const logger = createLogger("interceptors:retry");
7
6
  /**
8
7
  * Determines whether an error is safe to retry.
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","names":[],"sources":["../../../src/plugin/interceptors/retry.ts"],"sourcesContent":["import type { RetryConfig } from \"shared\";\nimport { AppKitError } from \"../../errors/base\";\nimport { createLogger } from \"../../logging/logger\";\nimport type { ExecutionInterceptor, InterceptorContext } from \"./types\";\n\nconst logger = createLogger(\"interceptors:retry\");\n\n/**\n * Determines whether an error is safe to retry.\n *\n * Priority:\n * 1. AppKitError — reads the `isRetryable` boolean property.\n * 2. Databricks SDK ApiError (duck-typed) — calls `isRetryable()` method,\n * or falls back to status-code heuristic (5xx / 429 → retryable).\n * 3. Unknown errors — treated as retryable to preserve backward compatibility.\n */\nfunction isRetryableError(error: unknown): boolean {\n if (error instanceof AppKitError) {\n return error.isRetryable;\n }\n\n if (error instanceof Error && \"statusCode\" in error) {\n const record = error as Record<string, unknown>;\n if (typeof record.statusCode !== \"number\") {\n return true;\n }\n if (typeof record.isRetryable === \"function\") {\n return (record.isRetryable as () => boolean)();\n }\n return record.statusCode >= 500 || record.statusCode === 429;\n }\n\n return true;\n}\n\nexport class RetryInterceptor implements ExecutionInterceptor {\n private attempts: number;\n private initialDelay: number;\n private maxDelay: number;\n\n constructor(config: RetryConfig) {\n this.attempts = config.attempts ?? 3;\n this.initialDelay = config.initialDelay ?? 1000;\n this.maxDelay = config.maxDelay ?? 30000;\n }\n\n async intercept<T>(\n fn: () => Promise<T>,\n context: InterceptorContext,\n ): Promise<T> {\n let lastError: Error | unknown;\n\n for (let attempt = 1; attempt <= this.attempts; attempt++) {\n try {\n const result = await fn();\n\n if (attempt > 1) {\n logger.event()?.setExecution({\n retry_attempts: attempt - 1,\n });\n }\n\n return result;\n } catch (error) {\n lastError = error;\n\n if (attempt === this.attempts) {\n logger.event()?.setExecution({\n retry_attempts: attempt - 1,\n });\n throw error;\n }\n\n if (context.signal?.aborted) {\n throw error;\n }\n\n if (!isRetryableError(error)) {\n throw error;\n }\n\n const delay = this.calculateDelay(attempt);\n await this.sleep(delay);\n }\n }\n\n throw lastError;\n }\n\n private calculateDelay(attempt: number): number {\n const delay = this.initialDelay * 2 ** (attempt - 1);\n const capped = Math.min(delay, this.maxDelay);\n\n return capped * Math.random();\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n"],"mappings":";;;;WACgD;AAIhD,MAAM,SAAS,aAAa,qBAAqB;;;;;;;;;;AAWjD,SAAS,iBAAiB,OAAyB;AACjD,KAAI,iBAAiB,YACnB,QAAO,MAAM;AAGf,KAAI,iBAAiB,SAAS,gBAAgB,OAAO;EACnD,MAAM,SAAS;AACf,MAAI,OAAO,OAAO,eAAe,SAC/B,QAAO;AAET,MAAI,OAAO,OAAO,gBAAgB,WAChC,QAAQ,OAAO,aAA+B;AAEhD,SAAO,OAAO,cAAc,OAAO,OAAO,eAAe;;AAG3D,QAAO;;AAGT,IAAa,mBAAb,MAA8D;CAC5D,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAAqB;AAC/B,OAAK,WAAW,OAAO,YAAY;AACnC,OAAK,eAAe,OAAO,gBAAgB;AAC3C,OAAK,WAAW,OAAO,YAAY;;CAGrC,MAAM,UACJ,IACA,SACY;EACZ,IAAI;AAEJ,OAAK,IAAI,UAAU,GAAG,WAAW,KAAK,UAAU,UAC9C,KAAI;GACF,MAAM,SAAS,MAAM,IAAI;AAEzB,OAAI,UAAU,EACZ,QAAO,OAAO,EAAE,aAAa,EAC3B,gBAAgB,UAAU,GAC3B,CAAC;AAGJ,UAAO;WACA,OAAO;AACd,eAAY;AAEZ,OAAI,YAAY,KAAK,UAAU;AAC7B,WAAO,OAAO,EAAE,aAAa,EAC3B,gBAAgB,UAAU,GAC3B,CAAC;AACF,UAAM;;AAGR,OAAI,QAAQ,QAAQ,QAClB,OAAM;AAGR,OAAI,CAAC,iBAAiB,MAAM,CAC1B,OAAM;GAGR,MAAM,QAAQ,KAAK,eAAe,QAAQ;AAC1C,SAAM,KAAK,MAAM,MAAM;;AAI3B,QAAM;;CAGR,AAAQ,eAAe,SAAyB;EAC9C,MAAM,QAAQ,KAAK,eAAe,MAAM,UAAU;AAGlD,SAFe,KAAK,IAAI,OAAO,KAAK,SAAS,GAE7B,KAAK,QAAQ;;CAG/B,AAAQ,MAAM,IAA2B;AACvC,SAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC"}
1
+ {"version":3,"file":"retry.js","names":[],"sources":["../../../src/plugin/interceptors/retry.ts"],"sourcesContent":["import type { RetryConfig } from \"shared\";\nimport { AppKitError } from \"../../errors/base\";\nimport { createLogger } from \"../../logging/logger\";\nimport type { ExecutionInterceptor, InterceptorContext } from \"./types\";\n\nconst logger = createLogger(\"interceptors:retry\");\n\n/**\n * Determines whether an error is safe to retry.\n *\n * Priority:\n * 1. AppKitError — reads the `isRetryable` boolean property.\n * 2. Databricks SDK ApiError (duck-typed) — calls `isRetryable()` method,\n * or falls back to status-code heuristic (5xx / 429 → retryable).\n * 3. Unknown errors — treated as retryable to preserve backward compatibility.\n */\nfunction isRetryableError(error: unknown): boolean {\n if (error instanceof AppKitError) {\n return error.isRetryable;\n }\n\n if (error instanceof Error && \"statusCode\" in error) {\n const record = error as Record<string, unknown>;\n if (typeof record.statusCode !== \"number\") {\n return true;\n }\n if (typeof record.isRetryable === \"function\") {\n return (record.isRetryable as () => boolean)();\n }\n return record.statusCode >= 500 || record.statusCode === 429;\n }\n\n return true;\n}\n\nexport class RetryInterceptor implements ExecutionInterceptor {\n private attempts: number;\n private initialDelay: number;\n private maxDelay: number;\n\n constructor(config: RetryConfig) {\n this.attempts = config.attempts ?? 3;\n this.initialDelay = config.initialDelay ?? 1000;\n this.maxDelay = config.maxDelay ?? 30000;\n }\n\n async intercept<T>(\n fn: () => Promise<T>,\n context: InterceptorContext,\n ): Promise<T> {\n let lastError: Error | unknown;\n\n for (let attempt = 1; attempt <= this.attempts; attempt++) {\n try {\n const result = await fn();\n\n if (attempt > 1) {\n logger.event()?.setExecution({\n retry_attempts: attempt - 1,\n });\n }\n\n return result;\n } catch (error) {\n lastError = error;\n\n if (attempt === this.attempts) {\n logger.event()?.setExecution({\n retry_attempts: attempt - 1,\n });\n throw error;\n }\n\n if (context.signal?.aborted) {\n throw error;\n }\n\n if (!isRetryableError(error)) {\n throw error;\n }\n\n const delay = this.calculateDelay(attempt);\n await this.sleep(delay);\n }\n }\n\n throw lastError;\n }\n\n private calculateDelay(attempt: number): number {\n const delay = this.initialDelay * 2 ** (attempt - 1);\n const capped = Math.min(delay, this.maxDelay);\n\n return capped * Math.random();\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n"],"mappings":";;;;AAKA,MAAM,SAAS,aAAa,qBAAqB;;;;;;;;;;AAWjD,SAAS,iBAAiB,OAAyB;AACjD,KAAI,iBAAiB,YACnB,QAAO,MAAM;AAGf,KAAI,iBAAiB,SAAS,gBAAgB,OAAO;EACnD,MAAM,SAAS;AACf,MAAI,OAAO,OAAO,eAAe,SAC/B,QAAO;AAET,MAAI,OAAO,OAAO,gBAAgB,WAChC,QAAQ,OAAO,aAA+B;AAEhD,SAAO,OAAO,cAAc,OAAO,OAAO,eAAe;;AAG3D,QAAO;;AAGT,IAAa,mBAAb,MAA8D;CAC5D,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,QAAqB;AAC/B,OAAK,WAAW,OAAO,YAAY;AACnC,OAAK,eAAe,OAAO,gBAAgB;AAC3C,OAAK,WAAW,OAAO,YAAY;;CAGrC,MAAM,UACJ,IACA,SACY;EACZ,IAAI;AAEJ,OAAK,IAAI,UAAU,GAAG,WAAW,KAAK,UAAU,UAC9C,KAAI;GACF,MAAM,SAAS,MAAM,IAAI;AAEzB,OAAI,UAAU,EACZ,QAAO,OAAO,EAAE,aAAa,EAC3B,gBAAgB,UAAU,GAC3B,CAAC;AAGJ,UAAO;WACA,OAAO;AACd,eAAY;AAEZ,OAAI,YAAY,KAAK,UAAU;AAC7B,WAAO,OAAO,EAAE,aAAa,EAC3B,gBAAgB,UAAU,GAC3B,CAAC;AACF,UAAM;;AAGR,OAAI,QAAQ,QAAQ,QAClB,OAAM;AAGR,OAAI,CAAC,iBAAiB,MAAM,CAC1B,OAAM;GAGR,MAAM,QAAQ,KAAK,eAAe,QAAQ;AAC1C,SAAM,KAAK,MAAM,MAAM;;AAI3B,QAAM;;CAGR,AAAQ,eAAe,SAAyB;EAC9C,MAAM,QAAQ,KAAK,eAAe,MAAM,UAAU;AAGlD,SAFe,KAAK,IAAI,OAAO,KAAK,SAAS,GAE7B,KAAK,QAAQ;;CAG/B,AAAQ,MAAM,IAA2B;AACvC,SAAO,IAAI,SAAS,YAAY,WAAW,SAAS,GAAG,CAAC"}
@@ -1,9 +1,8 @@
1
- import { getCurrentUserId, init_execution_context, isInUserContext } from "../../context/execution-context.js";
1
+ import { getCurrentUserId, isInUserContext } from "../../context/execution-context.js";
2
2
  import { SpanStatusCode } from "../../telemetry/index.js";
3
3
  import { isDevOboFallback } from "../plugin.js";
4
4
 
5
5
  //#region src/plugin/interceptors/telemetry.ts
6
- init_execution_context();
7
6
  var TelemetryInterceptor = class {
8
7
  constructor(telemetry, config) {
9
8
  this.telemetry = telemetry;
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","names":[],"sources":["../../../src/plugin/interceptors/telemetry.ts"],"sourcesContent":["import type { TelemetryConfig } from \"shared\";\nimport {\n getCurrentUserId,\n isInUserContext,\n} from \"../../context/execution-context\";\nimport type { ITelemetry, Span } from \"../../telemetry\";\nimport { SpanStatusCode } from \"../../telemetry\";\nimport { isDevOboFallback } from \"../plugin\";\nimport type { ExecutionInterceptor, InterceptorContext } from \"./types\";\n\nexport class TelemetryInterceptor implements ExecutionInterceptor {\n constructor(\n private telemetry: ITelemetry,\n private config?: TelemetryConfig,\n ) {}\n\n async intercept<T>(\n fn: () => Promise<T>,\n context: InterceptorContext,\n ): Promise<T> {\n const spanName = this.config?.spanName || \"plugin.execute\";\n\n // abort operation if signal is aborted\n if (context.signal?.aborted) {\n throw new Error(\"Operation aborted before execution\");\n }\n\n return this.telemetry.startActiveSpan(\n spanName,\n { attributes: this.config?.attributes },\n async (span: Span) => {\n let abortHandler: (() => void) | undefined;\n let isAborted = false;\n\n if (context.signal) {\n abortHandler = () => {\n // abort span if not recording\n if (!span.isRecording()) return;\n isAborted = true;\n span.setAttribute(\"cancelled\", true);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"Operation cancelled by client\",\n });\n span.end();\n };\n context.signal.addEventListener(\"abort\", abortHandler, {\n once: true,\n });\n }\n\n try {\n span.setAttribute(\n \"execution.context\",\n isInUserContext() ? \"user\" : \"service\",\n );\n span.setAttribute(\"caller.id\", getCurrentUserId());\n if (isDevOboFallback()) {\n span.setAttribute(\"execution.obo_dev_fallback\", true);\n }\n\n const result = await fn();\n if (!isAborted) {\n span.setStatus({ code: SpanStatusCode.OK });\n }\n return result;\n } catch (error) {\n if (!isAborted) {\n span.recordException(error as Error);\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n throw error;\n } finally {\n if (abortHandler && context.signal) {\n context.signal.removeEventListener(\"abort\", abortHandler);\n }\n if (!isAborted) {\n span.end();\n }\n }\n },\n );\n }\n}\n"],"mappings":";;;;;wBAIyC;AAMzC,IAAa,uBAAb,MAAkE;CAChE,YACE,AAAQ,WACR,AAAQ,QACR;EAFQ;EACA;;CAGV,MAAM,UACJ,IACA,SACY;EACZ,MAAM,WAAW,KAAK,QAAQ,YAAY;AAG1C,MAAI,QAAQ,QAAQ,QAClB,OAAM,IAAI,MAAM,qCAAqC;AAGvD,SAAO,KAAK,UAAU,gBACpB,UACA,EAAE,YAAY,KAAK,QAAQ,YAAY,EACvC,OAAO,SAAe;GACpB,IAAI;GACJ,IAAI,YAAY;AAEhB,OAAI,QAAQ,QAAQ;AAClB,yBAAqB;AAEnB,SAAI,CAAC,KAAK,aAAa,CAAE;AACzB,iBAAY;AACZ,UAAK,aAAa,aAAa,KAAK;AACpC,UAAK,UAAU;MACb,MAAM,eAAe;MACrB,SAAS;MACV,CAAC;AACF,UAAK,KAAK;;AAEZ,YAAQ,OAAO,iBAAiB,SAAS,cAAc,EACrD,MAAM,MACP,CAAC;;AAGJ,OAAI;AACF,SAAK,aACH,qBACA,iBAAiB,GAAG,SAAS,UAC9B;AACD,SAAK,aAAa,aAAa,kBAAkB,CAAC;AAClD,QAAI,kBAAkB,CACpB,MAAK,aAAa,8BAA8B,KAAK;IAGvD,MAAM,SAAS,MAAM,IAAI;AACzB,QAAI,CAAC,UACH,MAAK,UAAU,EAAE,MAAM,eAAe,IAAI,CAAC;AAE7C,WAAO;YACA,OAAO;AACd,QAAI,CAAC,WAAW;AACd,UAAK,gBAAgB,MAAe;AACpC,UAAK,UAAU,EAAE,MAAM,eAAe,OAAO,CAAC;;AAEhD,UAAM;aACE;AACR,QAAI,gBAAgB,QAAQ,OAC1B,SAAQ,OAAO,oBAAoB,SAAS,aAAa;AAE3D,QAAI,CAAC,UACH,MAAK,KAAK;;IAIjB"}
1
+ {"version":3,"file":"telemetry.js","names":[],"sources":["../../../src/plugin/interceptors/telemetry.ts"],"sourcesContent":["import type { TelemetryConfig } from \"shared\";\nimport {\n getCurrentUserId,\n isInUserContext,\n} from \"../../context/execution-context\";\nimport type { ITelemetry, Span } from \"../../telemetry\";\nimport { SpanStatusCode } from \"../../telemetry\";\nimport { isDevOboFallback } from \"../plugin\";\nimport type { ExecutionInterceptor, InterceptorContext } from \"./types\";\n\nexport class TelemetryInterceptor implements ExecutionInterceptor {\n constructor(\n private telemetry: ITelemetry,\n private config?: TelemetryConfig,\n ) {}\n\n async intercept<T>(\n fn: () => Promise<T>,\n context: InterceptorContext,\n ): Promise<T> {\n const spanName = this.config?.spanName || \"plugin.execute\";\n\n // abort operation if signal is aborted\n if (context.signal?.aborted) {\n throw new Error(\"Operation aborted before execution\");\n }\n\n return this.telemetry.startActiveSpan(\n spanName,\n { attributes: this.config?.attributes },\n async (span: Span) => {\n let abortHandler: (() => void) | undefined;\n let isAborted = false;\n\n if (context.signal) {\n abortHandler = () => {\n // abort span if not recording\n if (!span.isRecording()) return;\n isAborted = true;\n span.setAttribute(\"cancelled\", true);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"Operation cancelled by client\",\n });\n span.end();\n };\n context.signal.addEventListener(\"abort\", abortHandler, {\n once: true,\n });\n }\n\n try {\n span.setAttribute(\n \"execution.context\",\n isInUserContext() ? \"user\" : \"service\",\n );\n span.setAttribute(\"caller.id\", getCurrentUserId());\n if (isDevOboFallback()) {\n span.setAttribute(\"execution.obo_dev_fallback\", true);\n }\n\n const result = await fn();\n if (!isAborted) {\n span.setStatus({ code: SpanStatusCode.OK });\n }\n return result;\n } catch (error) {\n if (!isAborted) {\n span.recordException(error as Error);\n span.setStatus({ code: SpanStatusCode.ERROR });\n }\n throw error;\n } finally {\n if (abortHandler && context.signal) {\n context.signal.removeEventListener(\"abort\", abortHandler);\n }\n if (!isAborted) {\n span.end();\n }\n }\n },\n );\n }\n}\n"],"mappings":";;;;;AAUA,IAAa,uBAAb,MAAkE;CAChE,YACE,AAAQ,WACR,AAAQ,QACR;EAFQ;EACA;;CAGV,MAAM,UACJ,IACA,SACY;EACZ,MAAM,WAAW,KAAK,QAAQ,YAAY;AAG1C,MAAI,QAAQ,QAAQ,QAClB,OAAM,IAAI,MAAM,qCAAqC;AAGvD,SAAO,KAAK,UAAU,gBACpB,UACA,EAAE,YAAY,KAAK,QAAQ,YAAY,EACvC,OAAO,SAAe;GACpB,IAAI;GACJ,IAAI,YAAY;AAEhB,OAAI,QAAQ,QAAQ;AAClB,yBAAqB;AAEnB,SAAI,CAAC,KAAK,aAAa,CAAE;AACzB,iBAAY;AACZ,UAAK,aAAa,aAAa,KAAK;AACpC,UAAK,UAAU;MACb,MAAM,eAAe;MACrB,SAAS;MACV,CAAC;AACF,UAAK,KAAK;;AAEZ,YAAQ,OAAO,iBAAiB,SAAS,cAAc,EACrD,MAAM,MACP,CAAC;;AAGJ,OAAI;AACF,SAAK,aACH,qBACA,iBAAiB,GAAG,SAAS,UAC9B;AACD,SAAK,aAAa,aAAa,kBAAkB,CAAC;AAClD,QAAI,kBAAkB,CACpB,MAAK,aAAa,8BAA8B,KAAK;IAGvD,MAAM,SAAS,MAAM,IAAI;AACzB,QAAI,CAAC,UACH,MAAK,UAAU,EAAE,MAAM,eAAe,IAAI,CAAC;AAE7C,WAAO;YACA,OAAO;AACd,QAAI,CAAC,WAAW;AACd,UAAK,gBAAgB,MAAe;AACpC,UAAK,UAAU,EAAE,MAAM,eAAe,OAAO,CAAC;;AAEhD,UAAM;aACE;AACR,QAAI,gBAAgB,QAAQ,OAC1B,SAAQ,OAAO,oBAAoB,SAAS,aAAa;AAE3D,QAAI,CAAC,UACH,MAAK,KAAK;;IAIjB"}
@@ -1,7 +1,7 @@
1
1
  import { createLogger } from "../logging/logger.js";
2
2
  import { AppKitError } from "../errors/base.js";
3
3
  import { AuthenticationError } from "../errors/authentication.js";
4
- import { init_errors } from "../errors/index.js";
4
+ import "../errors/index.js";
5
5
  import { ServiceContext } from "../context/service-context.js";
6
6
  import { getCurrentUserId, runInUserContext } from "../context/execution-context.js";
7
7
  import { normalizeTelemetryOptions } from "../telemetry/config.js";
@@ -9,7 +9,7 @@ import { TelemetryManager } from "../telemetry/telemetry-manager.js";
9
9
  import "../telemetry/index.js";
10
10
  import { deepMerge } from "../utils/merge.js";
11
11
  import { CacheManager } from "../cache/index.js";
12
- import { init_context } from "../context/index.js";
12
+ import "../context/index.js";
13
13
  import { AppManager } from "../app/index.js";
14
14
  import { StreamManager } from "../stream/stream-manager.js";
15
15
  import "../stream/index.js";
@@ -21,8 +21,6 @@ import { TimeoutInterceptor } from "./interceptors/timeout.js";
21
21
  import { context, createContextKey } from "@opentelemetry/api";
22
22
 
23
23
  //#region src/plugin/plugin.ts
24
- init_context();
25
- init_errors();
26
24
  const logger = createLogger("plugin");
27
25
  /**
28
26
  * OTel context key for marking OBO dev mode fallback.