syncorejs 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_vendor/cli/app.d.mts.map +1 -1
- package/dist/_vendor/cli/app.mjs +8 -5
- package/dist/_vendor/cli/app.mjs.map +1 -1
- package/dist/_vendor/cli/context.mjs.map +1 -1
- package/dist/_vendor/cli/dev-session.mjs.map +1 -1
- package/dist/_vendor/cli/doctor.mjs.map +1 -1
- package/dist/_vendor/cli/errors.mjs.map +1 -1
- package/dist/_vendor/cli/help.mjs.map +1 -1
- package/dist/_vendor/cli/index.mjs +9 -2
- package/dist/_vendor/cli/index.mjs.map +1 -1
- package/dist/_vendor/cli/messages.mjs.map +1 -1
- package/dist/_vendor/cli/preflight.mjs.map +1 -1
- package/dist/_vendor/cli/project.mjs +20 -20
- package/dist/_vendor/cli/project.mjs.map +1 -1
- package/dist/_vendor/cli/render.mjs.map +1 -1
- package/dist/_vendor/cli/targets.mjs.map +1 -1
- package/dist/_vendor/core/cli.d.mts +8 -2
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +510 -71
- package/dist/_vendor/core/cli.mjs.map +1 -1
- package/dist/_vendor/core/devtools-auth.mjs.map +1 -1
- package/dist/_vendor/core/index.d.mts +3 -3
- package/dist/_vendor/core/runtime/components.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/components.mjs.map +1 -1
- package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/devtools.mjs +261 -23
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +388 -6
- package/dist/_vendor/core/runtime/functions.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/functions.mjs +72 -1
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/id.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/id.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +12 -6
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +123 -20
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +56 -8
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs +49 -14
- package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs +4 -7
- package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +81 -2
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +100 -13
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +42 -7
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeStatus.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/systemMeta.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs +4 -0
- package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs.map +1 -1
- package/dist/_vendor/core/runtime/runtime.d.mts +1100 -12
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs +63 -0
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts +2 -0
- package/dist/_vendor/core/transport.d.mts.map +1 -1
- package/dist/_vendor/core/transport.mjs +61 -27
- package/dist/_vendor/core/transport.mjs.map +1 -1
- package/dist/_vendor/devtools-protocol/index.d.ts +223 -4
- package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
- package/dist/_vendor/devtools-protocol/index.js.map +1 -1
- package/dist/_vendor/next/config.d.ts +3 -4
- package/dist/_vendor/next/config.d.ts.map +1 -1
- package/dist/_vendor/next/config.js +37 -19
- package/dist/_vendor/next/config.js.map +1 -1
- package/dist/_vendor/next/index.d.ts +109 -29
- package/dist/_vendor/next/index.d.ts.map +1 -1
- package/dist/_vendor/next/index.js +86 -18
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +146 -27
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +81 -10
- package/dist/_vendor/platform-expo/index.js.map +1 -1
- package/dist/_vendor/platform-expo/react.js.map +1 -1
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js +16 -0
- package/dist/_vendor/platform-expo/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-node/index.d.mts +174 -9
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +251 -95
- package/dist/_vendor/platform-node/index.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.mjs +4 -0
- package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc.d.mts.map +1 -1
- package/dist/_vendor/platform-node/ipc.mjs.map +1 -1
- package/dist/_vendor/platform-web/external-change.d.ts +41 -0
- package/dist/_vendor/platform-web/external-change.d.ts.map +1 -1
- package/dist/_vendor/platform-web/external-change.js +30 -0
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +312 -37
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +247 -25
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.d.ts +12 -0
- package/dist/_vendor/platform-web/indexeddb.d.ts.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.js +10 -0
- package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
- package/dist/_vendor/platform-web/opfs.d.ts +16 -1
- package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
- package/dist/_vendor/platform-web/opfs.js +41 -3
- package/dist/_vendor/platform-web/opfs.js.map +1 -1
- package/dist/_vendor/platform-web/persistence.d.ts +85 -1
- package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
- package/dist/_vendor/platform-web/persistence.js +15 -0
- package/dist/_vendor/platform-web/persistence.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts +1 -2
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +11 -5
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/platform-web/sqljs.js +10 -1
- package/dist/_vendor/platform-web/sqljs.js.map +1 -1
- package/dist/_vendor/platform-web/web-sqljs-wasm.js +8 -0
- package/dist/_vendor/platform-web/web-sqljs-wasm.js.map +1 -0
- package/dist/_vendor/platform-web/worker.d.ts +60 -9
- package/dist/_vendor/platform-web/worker.d.ts.map +1 -1
- package/dist/_vendor/platform-web/worker.js +37 -4
- package/dist/_vendor/platform-web/worker.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +197 -13
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +209 -17
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/schema/definition.d.ts +129 -0
- package/dist/_vendor/schema/definition.d.ts.map +1 -1
- package/dist/_vendor/schema/definition.js +99 -0
- package/dist/_vendor/schema/definition.js.map +1 -1
- package/dist/_vendor/schema/planner.d.ts.map +1 -1
- package/dist/_vendor/schema/planner.js.map +1 -1
- package/dist/_vendor/schema/validators.d.ts +180 -4
- package/dist/_vendor/schema/validators.d.ts.map +1 -1
- package/dist/_vendor/schema/validators.js +35 -1
- package/dist/_vendor/schema/validators.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +207 -7
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +201 -6
- package/dist/_vendor/svelte/index.js.map +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +24 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-auth.mjs","names":[],"sources":["../src/devtools-auth.ts"],"sourcesContent":["import { randomBytes, timingSafeEqual } from \"node:crypto\";\n\nconst TOKEN_ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\nexport function sanitizeDevtoolsToken(value: string | undefined): string | null {\n if (!value) {\n return null;\n }\n const sanitized = value.replace(/[^A-Za-z0-9]/g, \"\");\n return sanitized.length > 0 ? sanitized : null;\n}\n\nexport function generateDevtoolsToken(length = 20): string {\n let token = \"\";\n while (token.length < length) {\n const bytes = randomBytes(length);\n for (const byte of bytes) {\n if (byte >= 248) {\n continue;\n }\n token += TOKEN_ALPHABET[byte % TOKEN_ALPHABET.length];\n if (token.length === length) {\n break;\n }\n }\n }\n return token;\n}\n\nexport function readDevtoolsTokenFromUrl(requestUrl: string | undefined): string | null {\n if (!requestUrl) {\n return null;\n }\n try {\n const url = new URL(requestUrl, \"ws://localhost\");\n return url.searchParams.get(\"token\") ?? url.searchParams.get(\"hubToken\");\n } catch {\n return null;\n }\n}\n\nexport function isAllowedDashboardOrigin(\n originHeader: string | undefined,\n dashboardPort: number\n): boolean {\n if (!originHeader) {\n return false;\n }\n try {\n const origin = new URL(originHeader);\n if (!isLoopbackHostname(origin.hostname)) {\n return false;\n }\n const expectedPort = String(dashboardPort);\n const originPort =\n origin.port ||\n (origin.protocol === \"https:\" ? \"443\" : origin.protocol === \"http:\" ? \"80\" : \"\");\n return originPort === expectedPort;\n } catch {\n return false;\n }\n}\n\nexport function isAuthorizedDashboardRequest(input: {\n requestUrl: string | undefined;\n originHeader: string | undefined;\n dashboardPort: number;\n expectedToken: string;\n}): boolean {\n if (!isAllowedDashboardOrigin(input.originHeader, input.dashboardPort)) {\n return false;\n }\n const providedToken = readDevtoolsTokenFromUrl(input.requestUrl);\n if (!providedToken) {\n return false;\n }\n return tokensMatch(providedToken, input.expectedToken);\n}\n\nfunction isLoopbackHostname(hostname: string): boolean {\n const normalized = hostname.toLowerCase();\n return (\n normalized === \"localhost\" ||\n normalized === \"127.0.0.1\" ||\n normalized === \"::1\" ||\n normalized === \"[::1]\"\n );\n}\n\nfunction tokensMatch(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left, \"utf8\");\n const rightBuffer = Buffer.from(right, \"utf8\");\n if (leftBuffer.length !== rightBuffer.length) {\n return false;\n }\n return timingSafeEqual(leftBuffer, rightBuffer);\n}\n"],"mappings":";;AAEA,MAAM,iBAAiB;AAEvB,SAAgB,sBAAsB,OAA0C;
|
|
1
|
+
{"version":3,"file":"devtools-auth.mjs","names":[],"sources":["../src/devtools-auth.ts"],"sourcesContent":["import { randomBytes, timingSafeEqual } from \"node:crypto\";\n\nconst TOKEN_ALPHABET = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\nexport function sanitizeDevtoolsToken(value: string | undefined): string | null {\n if (!value) {\n return null;\n }\n const sanitized = value.replace(/[^A-Za-z0-9]/g, \"\");\n return sanitized.length > 0 ? sanitized : null;\n}\n\nexport function generateDevtoolsToken(length = 20): string {\n let token = \"\";\n while (token.length < length) {\n const bytes = randomBytes(length);\n for (const byte of bytes) {\n if (byte >= 248) {\n continue;\n }\n token += TOKEN_ALPHABET[byte % TOKEN_ALPHABET.length];\n if (token.length === length) {\n break;\n }\n }\n }\n return token;\n}\n\nexport function readDevtoolsTokenFromUrl(requestUrl: string | undefined): string | null {\n if (!requestUrl) {\n return null;\n }\n try {\n const url = new URL(requestUrl, \"ws://localhost\");\n return url.searchParams.get(\"token\") ?? url.searchParams.get(\"hubToken\");\n } catch {\n return null;\n }\n}\n\nexport function isAllowedDashboardOrigin(\n originHeader: string | undefined,\n dashboardPort: number\n): boolean {\n if (!originHeader) {\n return false;\n }\n try {\n const origin = new URL(originHeader);\n if (!isLoopbackHostname(origin.hostname)) {\n return false;\n }\n const expectedPort = String(dashboardPort);\n const originPort =\n origin.port ||\n (origin.protocol === \"https:\" ? \"443\" : origin.protocol === \"http:\" ? \"80\" : \"\");\n return originPort === expectedPort;\n } catch {\n return false;\n }\n}\n\nexport function isAuthorizedDashboardRequest(input: {\n requestUrl: string | undefined;\n originHeader: string | undefined;\n dashboardPort: number;\n expectedToken: string;\n}): boolean {\n if (!isAllowedDashboardOrigin(input.originHeader, input.dashboardPort)) {\n return false;\n }\n const providedToken = readDevtoolsTokenFromUrl(input.requestUrl);\n if (!providedToken) {\n return false;\n }\n return tokensMatch(providedToken, input.expectedToken);\n}\n\nfunction isLoopbackHostname(hostname: string): boolean {\n const normalized = hostname.toLowerCase();\n return (\n normalized === \"localhost\" ||\n normalized === \"127.0.0.1\" ||\n normalized === \"::1\" ||\n normalized === \"[::1]\"\n );\n}\n\nfunction tokensMatch(left: string, right: string): boolean {\n const leftBuffer = Buffer.from(left, \"utf8\");\n const rightBuffer = Buffer.from(right, \"utf8\");\n if (leftBuffer.length !== rightBuffer.length) {\n return false;\n }\n return timingSafeEqual(leftBuffer, rightBuffer);\n}\n"],"mappings":";;AAEA,MAAM,iBAAiB;AAEvB,SAAgB,sBAAsB,OAA0C;CAC9E,IAAI,CAAC,OACH,OAAO;CAET,MAAM,YAAY,MAAM,QAAQ,iBAAiB,EAAE;CACnD,OAAO,UAAU,SAAS,IAAI,YAAY;AAC5C;AAEA,SAAgB,sBAAsB,SAAS,IAAY;CACzD,IAAI,QAAQ;CACZ,OAAO,MAAM,SAAS,QAAQ;EAC5B,MAAM,QAAQ,YAAY,MAAM;EAChC,KAAK,MAAM,QAAQ,OAAO;GACxB,IAAI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ionReference, FunctionReferenceFor, FunctionResult, FunctionResultFromDefinition, InferArgs, MisfirePolicy, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, SyncoreFunctionDefinition, SyncoreFunctionKind, action, cronJobs, mutation, query } from "./runtime/functions.mjs";
|
|
2
|
-
import { ActionCtx, CapabilityDescriptor, ComparisonOperator, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DocumentForTable, ExecutionResult, FilterBuilder, ImpactScope, ImpactSet, IndexRangeBuilder, InsertValueForTable, JsonObject, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RegisteredSyncoreFunction, RegisteredSyncoreHandler, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, SyncoreCapabilities, SyncoreClient, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionRegistry, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, createFunctionReference, createFunctionReferenceFor } from "./runtime/runtime.mjs";
|
|
2
|
+
import { ActionCtx, CapabilityDescriptor, ComparisonOperator, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DocumentForTable, ExecutionResult, FilterBuilder, ImpactScope, ImpactSet, IndexRangeBuilder, InsertValueForTable, JsonObject, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RegisteredSyncoreFunction, RegisteredSyncoreHandler, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, SyncoreCapabilities, SyncoreClient, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionRegistry, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeCapabilities, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, SyncoreRuntimeStorageCapability, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, createFunctionReference, createFunctionReferenceFor } from "./runtime/runtime.mjs";
|
|
3
3
|
import { AnySyncoreFunctionDefinition, ComponentPath, FunctionReferencesForTree, InstalledComponentApi, InstalledComponentsApi, ResolvedSyncoreComponent, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreFunctionTree, SyncoreHostServiceName, SyncoreRequestedCapability, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createInstalledComponentsApi, defineComponent, defineComponents, installComponent, resolveComponentsManifest, toCanonicalComponentFunctionName } from "./runtime/components.mjs";
|
|
4
4
|
import { DevtoolsCommandHandler, DevtoolsCommandHandlerDeps, DevtoolsSqlAnalysis, DevtoolsSqlMode, DevtoolsSqlReadResult, DevtoolsSqlSupport, DevtoolsSubscriptionHost, DevtoolsSubscriptionListener, createDevtoolsCommandHandler, createDevtoolsSubscriptionHost } from "./runtime/devtools.mjs";
|
|
5
5
|
import { generateId } from "./runtime/id.mjs";
|
|
@@ -9,9 +9,9 @@ export * from "../schema/index.d.ts";
|
|
|
9
9
|
|
|
10
10
|
//#region src/index.d.ts
|
|
11
11
|
declare namespace index_d_exports {
|
|
12
|
-
export { ActionCtx, AnySyncoreFunctionDefinition, AttachRuntimeBridgeOptions, AttachedRuntimeBridge, BridgeQueryWatch, CapabilityDescriptor, ComparisonOperator, ComponentPath, CronJobs, DevtoolsCommandHandler, DevtoolsCommandHandlerDeps, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DevtoolsSqlAnalysis, DevtoolsSqlMode, DevtoolsSqlReadResult, DevtoolsSqlSupport, DevtoolsSubscriptionHost, DevtoolsSubscriptionListener, DocumentForTable, EmptyArgs, ExecutionResult, FilterBuilder, FunctionArgs, FunctionArgsFromDefinition, FunctionConfig, FunctionKindFromDefinition, FunctionReference, FunctionReferenceFor, FunctionReferencesForTree, FunctionResult, FunctionResultFromDefinition, ImpactScope, ImpactSet, IndexRangeBuilder, InferArgs, InsertValueForTable, InstalledComponentApi, InstalledComponentsApi, JsonObject, MisfirePolicy, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, RegisteredSyncoreFunction, RegisteredSyncoreHandler, ResolvedSyncoreComponent, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, SyncoreActiveQueryInfo, SyncoreBridgeClient, SyncoreBridgeMessageEndpoint, SyncoreBridgeRequest, SyncoreBridgeResponse, SyncoreCapabilities, SyncoreClient, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, SyncoreDevtoolsEvent, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionDefinition, SyncoreFunctionKind, SyncoreFunctionRegistry, SyncoreFunctionTree, SyncoreHostServiceName, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreRequestedCapability, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, SyncoreRuntimeSummary, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, action, attachRuntimeBridge, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createDeferredSyncoreClient, createDevtoolsCommandHandler, createDevtoolsSubscriptionHost, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, createInvokeRequest, createUnavailableSyncoreClient, createWatchKey, cronJobs, defineComponent, defineComponents, generateId, installComponent, mutation, normalizeOptionalArgs, query, resolveComponentsManifest, stableStringify, toCanonicalComponentFunctionName };
|
|
12
|
+
export { ActionCtx, AnySyncoreFunctionDefinition, AttachRuntimeBridgeOptions, AttachedRuntimeBridge, BridgeQueryWatch, CapabilityDescriptor, ComparisonOperator, ComponentPath, CronJobs, DevtoolsCommandHandler, DevtoolsCommandHandlerDeps, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DevtoolsSqlAnalysis, DevtoolsSqlMode, DevtoolsSqlReadResult, DevtoolsSqlSupport, DevtoolsSubscriptionHost, DevtoolsSubscriptionListener, DocumentForTable, EmptyArgs, ExecutionResult, FilterBuilder, FunctionArgs, FunctionArgsFromDefinition, FunctionConfig, FunctionKindFromDefinition, FunctionReference, FunctionReferenceFor, FunctionReferencesForTree, FunctionResult, FunctionResultFromDefinition, ImpactScope, ImpactSet, IndexRangeBuilder, InferArgs, InsertValueForTable, InstalledComponentApi, InstalledComponentsApi, JsonObject, MisfirePolicy, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, RegisteredSyncoreFunction, RegisteredSyncoreHandler, ResolvedSyncoreComponent, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, SyncoreActiveQueryInfo, SyncoreBridgeClient, SyncoreBridgeMessageEndpoint, SyncoreBridgeRequest, SyncoreBridgeResponse, SyncoreCapabilities, SyncoreClient, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, SyncoreDevtoolsEvent, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionDefinition, SyncoreFunctionKind, SyncoreFunctionRegistry, SyncoreFunctionTree, SyncoreHostServiceName, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreRequestedCapability, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeCapabilities, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, SyncoreRuntimeStorageCapability, SyncoreRuntimeSummary, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, action, attachRuntimeBridge, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createDeferredSyncoreClient, createDevtoolsCommandHandler, createDevtoolsSubscriptionHost, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, createInvokeRequest, createUnavailableSyncoreClient, createWatchKey, cronJobs, defineComponent, defineComponents, generateId, installComponent, mutation, normalizeOptionalArgs, query, resolveComponentsManifest, stableStringify, toCanonicalComponentFunctionName };
|
|
13
13
|
}
|
|
14
14
|
import * as import__syncore_schema from "../schema/index.d.ts";
|
|
15
15
|
//#endregion
|
|
16
|
-
export { ActionCtx, AnySyncoreFunctionDefinition, AttachRuntimeBridgeOptions, AttachedRuntimeBridge, BridgeQueryWatch, CapabilityDescriptor, ComparisonOperator, ComponentPath, CronJobs, DevtoolsCommandHandler, DevtoolsCommandHandlerDeps, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DevtoolsSqlAnalysis, DevtoolsSqlMode, DevtoolsSqlReadResult, DevtoolsSqlSupport, DevtoolsSubscriptionHost, DevtoolsSubscriptionListener, DocumentForTable, EmptyArgs, ExecutionResult, FilterBuilder, FunctionArgs, FunctionArgsFromDefinition, FunctionConfig, FunctionKindFromDefinition, FunctionReference, FunctionReferenceFor, FunctionReferencesForTree, FunctionResult, FunctionResultFromDefinition, ImpactScope, ImpactSet, IndexRangeBuilder, InferArgs, InsertValueForTable, InstalledComponentApi, InstalledComponentsApi, JsonObject, MisfirePolicy, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, RegisteredSyncoreFunction, RegisteredSyncoreHandler, ResolvedSyncoreComponent, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, type SyncoreActiveQueryInfo, SyncoreBridgeClient, SyncoreBridgeMessageEndpoint, SyncoreBridgeRequest, SyncoreBridgeResponse, SyncoreCapabilities, SyncoreClient, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, type SyncoreDevtoolsEvent, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionDefinition, SyncoreFunctionKind, SyncoreFunctionRegistry, SyncoreFunctionTree, SyncoreHostServiceName, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreRequestedCapability, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, type SyncoreRuntimeSummary, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, action, attachRuntimeBridge, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createDeferredSyncoreClient, createDevtoolsCommandHandler, createDevtoolsSubscriptionHost, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, createInvokeRequest, createUnavailableSyncoreClient, createWatchKey, cronJobs, defineComponent, defineComponents, generateId, index_d_exports, installComponent, mutation, normalizeOptionalArgs, query, resolveComponentsManifest, stableStringify, toCanonicalComponentFunctionName };
|
|
16
|
+
export { ActionCtx, AnySyncoreFunctionDefinition, AttachRuntimeBridgeOptions, AttachedRuntimeBridge, BridgeQueryWatch, CapabilityDescriptor, ComparisonOperator, ComponentPath, CronJobs, DevtoolsCommandHandler, DevtoolsCommandHandlerDeps, DevtoolsLiveQueryScope, DevtoolsLiveQuerySnapshot, DevtoolsSink, DevtoolsSqlAnalysis, DevtoolsSqlMode, DevtoolsSqlReadResult, DevtoolsSqlSupport, DevtoolsSubscriptionHost, DevtoolsSubscriptionListener, DocumentForTable, EmptyArgs, ExecutionResult, FilterBuilder, FunctionArgs, FunctionArgsFromDefinition, FunctionConfig, FunctionKindFromDefinition, FunctionReference, FunctionReferenceFor, FunctionReferencesForTree, FunctionResult, FunctionResultFromDefinition, ImpactScope, ImpactSet, IndexRangeBuilder, InferArgs, InsertValueForTable, InstalledComponentApi, InstalledComponentsApi, JsonObject, MisfirePolicy, MutationCtx, PaginationOptions, PaginationResult, PatchValueForTable, QueryBuilder, QueryCondition, QueryCtx, QueryExpression, RecurringDailySchedule, RecurringIntervalSchedule, RecurringJobDefinition, RecurringSchedule, RecurringWeeklySchedule, RegisteredSyncoreFunction, RegisteredSyncoreHandler, ResolvedSyncoreComponent, RunResult, SchedulerApi, SchedulerOptions, SearchIndexBuilder, SearchQuery, StorageObject, StorageWriteInput, type SyncoreActiveQueryInfo, SyncoreBridgeClient, SyncoreBridgeMessageEndpoint, SyncoreBridgeRequest, SyncoreBridgeResponse, SyncoreCapabilities, SyncoreClient, SyncoreComponent, SyncoreComponentFunctionMetadata, SyncoreComponentHookContext, SyncoreComponentInstall, SyncoreComponentsManifest, SyncoreCoreCapability, SyncoreDataModel, SyncoreDatabaseReader, SyncoreDatabaseWriter, type SyncoreDevtoolsEvent, SyncoreExternalChangeApplier, SyncoreExternalChangeEvent, SyncoreExternalChangeReason, SyncoreExternalChangeScope, SyncoreExternalChangeSignal, SyncoreFunctionDefinition, SyncoreFunctionKind, SyncoreFunctionRegistry, SyncoreFunctionTree, SyncoreHostServiceName, SyncorePaginatedQueryStatus, SyncoreQueriesRequest, SyncoreQueryRequest, SyncoreQueryState, SyncoreQueryStatus, SyncoreRequestedCapability, SyncoreResolvedComponents, SyncoreRuntime, SyncoreRuntimeAdmin, SyncoreRuntimeCapabilities, SyncoreRuntimeOptions, SyncoreRuntimeStatus, SyncoreRuntimeStatusKind, SyncoreRuntimeStatusReason, SyncoreRuntimeStorageCapability, type SyncoreRuntimeSummary, SyncoreSqlDriver, SyncoreStorageAdapter, SyncoreStorageApi, SyncoreWatch, TableNames, UpdateScheduledJobOptions, UsePaginatedQueryResult, action, attachRuntimeBridge, composeProjectFunctionRegistry, composeProjectSchema, createBindingFunctionReference, createComponentPhysicalTableName, createDeferredSyncoreClient, createDevtoolsCommandHandler, createDevtoolsSubscriptionHost, createFunctionReference, createFunctionReferenceFor, createInstalledComponentsApi, createInvokeRequest, createUnavailableSyncoreClient, createWatchKey, cronJobs, defineComponent, defineComponents, generateId, index_d_exports, installComponent, mutation, normalizeOptionalArgs, query, resolveComponentsManifest, stableStringify, toCanonicalComponentFunctionName };
|
|
17
17
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.mts","names":[],"sources":["../../src/runtime/components.ts"],"mappings":";;;;;;KAqBY,aAAA;AAAA,KAEA,qBAAA;AAAA,KAQA,sBAAA;AAAA,KAQA,0BAAA,GACR,qBAAA,WACQ,
|
|
1
|
+
{"version":3,"file":"components.d.mts","names":[],"sources":["../../src/runtime/components.ts"],"mappings":";;;;;;KAqBY,aAAA;AAAA,KAEA,qBAAA;AAAA,KAQA,sBAAA;AAAA,KAQA,0BAAA,GACR,qBAAA,WACQ,sBAAsB;AAAA,KAEtB,4BAAA,GAA+B,yBAAyB,CAClE,mBAAA;AAAA,KAMU,mBAAA;EAAA,UACA,GAAA,WACN,4BAAA,GACA,mBAAmB;AAAA;AAAA,UAIR,2BAAA;EACf,SAAA;EACA,QAAA;EACA,aAAA,EAAe,aAAA;EACf,aAAA;EACA,OAAA;EACA,MAAA;EACA,YAAA,WAAuB,0BAAA;EACvB,YAAA,CAAa,KAAA,EAAO,oBAAA;AAAA;AAAA,UAGL,gBAAA,oCAEC,gBAAA,eACZ,gBAAA,8BAEY,mBAAA,eACZ,mBAAA,gCAEc,mBAAA,eACd,mBAAA;EAAA,SAGK,IAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;E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N,UAAA,oBAAA,CAGR,IAAA,EAAM,KAAA,EACN,WAAA,UACA,YAAA,WACC,iBAAA,CAAkB,KAAA,EAAO,KAAA,EAAO,OAAA;AAAA,iBAOnB,oBAAA,qBACM,gBAAA,CAAA,CAEpB,UAAA,EAAY,WAAA,EACZ,QAAA,GAAW,yBAAA,GACV,aAAA,CAAc,cAAA,CAAe,WAAA,IAAe,MAAA,SAAe,kBAAA;AAAA,iBAuB9C,8BAAA,CACd,aAAA,EAAe,uBAAA,EACf,QAAA,GAAW,yBAAA,GACV,uBAAA;AAAA,iBAea,4BAAA,mBACI,yBAAA,CAAA,CAClB,QAAA,EAAU,SAAA,GAAY,sBAAA,CAAuB,SAAA;AAAA,iBAI/B,yBAAA,CACd,QAAA,GAAW,yBAAA,GACV,wBAAwB;AAAA,iBAUX,gCAAA,CACd,aAAA,EAAe,aAAa,EAC5B,UAAA,yBACA,SAAA;AAAA,iBAOc,gCAAA,CACd,aAAA,EAAe,aAAa,EAC5B,SAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/runtime/components.ts"],"sourcesContent":["import {\n SyncoreSchema,\n TableDefinition,\n defineSchema,\n type AnyTableDefinition,\n type Validator\n} from \"@syncore/schema\";\nimport type { SyncoreDevtoolsEvent } from \"@syncore/devtools-protocol\";\nimport {\n type FunctionReference,\n type FunctionReferenceFor,\n type SyncoreFunctionDefinition,\n type SyncoreFunctionKind\n} from \"./functions.js\";\nimport type {\n JsonObject,\n RegisteredSyncoreFunction,\n SyncoreDataModel,\n SyncoreFunctionRegistry\n} from \"./runtime.js\";\n\nexport type ComponentPath = string;\n\nexport type SyncoreCoreCapability =\n | \"storage\"\n | \"scheduler\"\n | \"devtools\"\n | \"ownTables\"\n | \"publicExports\"\n | \"internalActions\";\n\nexport type SyncoreHostServiceName =\n | \"http\"\n | \"notifications\"\n | \"secureStore\"\n | \"filesystem\"\n | \"backgroundTasks\"\n | \"crypto\";\n\nexport type SyncoreRequestedCapability =\n | SyncoreCoreCapability\n | `host:${SyncoreHostServiceName}`;\n\nexport type AnySyncoreFunctionDefinition = SyncoreFunctionDefinition<\n SyncoreFunctionKind,\n any,\n any,\n unknown\n>;\n\nexport type SyncoreFunctionTree = {\n readonly [key: string]:\n | AnySyncoreFunctionDefinition\n | SyncoreFunctionTree\n | undefined;\n};\n\nexport interface SyncoreComponentHookContext {\n runtimeId: string;\n platform: string;\n componentPath: ComponentPath;\n componentName: string;\n version: string;\n config: unknown;\n capabilities: readonly SyncoreRequestedCapability[];\n emitDevtools(event: SyncoreDevtoolsEvent): void;\n}\n\nexport interface SyncoreComponent<\n TConfig = unknown,\n TSchema extends SyncoreDataModel | undefined =\n | SyncoreDataModel\n | undefined,\n TPublic extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined,\n TInternal extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined\n> {\n readonly kind: \"syncore.component\";\n readonly name: string;\n readonly version: string;\n readonly config?: Validator<TConfig>;\n readonly requestedCapabilities?: readonly SyncoreRequestedCapability[];\n readonly schema?: TSchema;\n readonly public?: TPublic;\n readonly internal?: TInternal;\n readonly dependencies?: readonly string[];\n onStart?(context: SyncoreComponentHookContext): Promise<void> | void;\n onStop?(context: SyncoreComponentHookContext): Promise<void> | void;\n}\n\nexport interface SyncoreComponentInstall<\n TComponent extends SyncoreComponent = SyncoreComponent,\n TChildren extends SyncoreComponentsManifest = SyncoreComponentsManifest\n> {\n readonly kind: \"syncore.component.install\";\n readonly component: TComponent;\n readonly source: string;\n readonly config?: TComponent extends SyncoreComponent<infer TConfig, any, any, any>\n ? TConfig\n : unknown;\n readonly capabilities?: readonly SyncoreRequestedCapability[];\n readonly bindings?: Record<string, string>;\n readonly children?: TChildren;\n}\n\nexport type SyncoreComponentsManifest = Record<string, SyncoreComponentInstall>;\n\nexport interface SyncoreComponentFunctionMetadata {\n componentPath: ComponentPath;\n componentName: string;\n version: string;\n visibility: \"public\" | \"internal\";\n localName: string;\n localTables: Record<string, string>;\n grantedCapabilities: readonly SyncoreRequestedCapability[];\n bindings: Record<string, string>;\n}\n\nexport interface ResolvedSyncoreComponent {\n alias: string;\n path: ComponentPath;\n source: string;\n name: string;\n version: string;\n config: unknown;\n grantedCapabilities: readonly SyncoreRequestedCapability[];\n requestedCapabilities: readonly SyncoreRequestedCapability[];\n bindings: Record<string, string>;\n schema: SyncoreDataModel | undefined;\n public: SyncoreFunctionTree | undefined;\n internal: SyncoreFunctionTree | undefined;\n publicEntries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }>;\n internalEntries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }>;\n localTables: Record<string, string>;\n onStart: SyncoreComponent[\"onStart\"] | undefined;\n onStop: SyncoreComponent[\"onStop\"] | undefined;\n children: ResolvedSyncoreComponent[];\n}\n\ntype Simplify<T> = { [K in keyof T]: T[K] } & {};\n\ntype PublicFunctionTreeOf<TComponent> = TComponent extends SyncoreComponent<\n any,\n any,\n infer TPublic,\n any\n>\n ? NonNullable<TPublic>\n : never;\n\nexport type FunctionReferencesForTree<TTree extends SyncoreFunctionTree> = Simplify<{\n [TKey in keyof TTree]: TTree[TKey] extends AnySyncoreFunctionDefinition\n ? FunctionReferenceFor<TTree[TKey]>\n : Record<string, unknown>;\n}>;\n\nexport type InstalledComponentApi<\n TInstall extends SyncoreComponentInstall\n> = Simplify<\n FunctionReferencesForTree<PublicFunctionTreeOf<TInstall[\"component\"]>> &\n Record<string, unknown>\n>;\n\nexport type InstalledComponentsApi<\n TManifest extends SyncoreComponentsManifest\n> = Simplify<{\n [TAlias in keyof TManifest]: InstalledComponentApi<TManifest[TAlias]>;\n}>;\n\ntype TablesOfSchema<TSchema extends SyncoreDataModel> = TSchema[\"tables\"];\n\nexport function defineComponent<\n TConfig = unknown,\n TSchema extends SyncoreDataModel | undefined =\n | SyncoreDataModel\n | undefined,\n TPublic extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined,\n TInternal extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined\n>(\n component: Omit<\n SyncoreComponent<TConfig, TSchema, TPublic, TInternal>,\n \"kind\"\n >\n): SyncoreComponent<TConfig, TSchema, TPublic, TInternal> {\n return {\n kind: \"syncore.component\",\n ...component\n };\n}\n\nexport function installComponent<\n TComponent extends SyncoreComponent,\n TChildren extends SyncoreComponentsManifest = {}\n>(install: {\n component: TComponent;\n source: string;\n config?: TComponent extends SyncoreComponent<infer TConfig, any, any, any>\n ? TConfig\n : unknown;\n capabilities?: readonly SyncoreRequestedCapability[];\n bindings?: Record<string, string>;\n children?: TChildren;\n}): SyncoreComponentInstall<TComponent, TChildren> {\n return {\n kind: \"syncore.component.install\",\n ...install\n };\n}\n\nexport function defineComponents<TManifest extends SyncoreComponentsManifest>(\n components: TManifest\n): TManifest {\n return components;\n}\n\nexport function createBindingFunctionReference<\n TKind extends SyncoreFunctionKind,\n TArgs = JsonObject,\n TResult = unknown\n>(\n kind: TKind,\n bindingName: string,\n functionName: string\n): FunctionReference<TKind, TArgs, TResult> {\n return {\n kind,\n name: `binding:${bindingName}/${functionName}`\n };\n}\n\nexport function composeProjectSchema<\n TRootSchema extends SyncoreDataModel\n>(\n rootSchema: TRootSchema,\n manifest?: SyncoreComponentsManifest\n): SyncoreSchema<TablesOfSchema<TRootSchema> & Record<string, AnyTableDefinition>> {\n const tables: Record<string, AnyTableDefinition> = {\n ...rootSchema.tables\n };\n\n for (const component of resolveComponentsManifest(manifest)) {\n for (const [physicalTableName, tableDefinition] of composeComponentTables(\n component\n )) {\n if (tables[physicalTableName]) {\n throw new Error(\n `Component table collision detected for ${JSON.stringify(physicalTableName)}.`\n );\n }\n tables[physicalTableName] = tableDefinition;\n }\n }\n\n return defineSchema(tables) as unknown as SyncoreSchema<\n TablesOfSchema<TRootSchema> & Record<string, AnyTableDefinition>\n >;\n}\n\nexport function composeProjectFunctionRegistry(\n rootFunctions: SyncoreFunctionRegistry,\n manifest?: SyncoreComponentsManifest\n): SyncoreFunctionRegistry {\n const registry: Record<string, RegisteredSyncoreFunction> = {};\n for (const [name, definition] of Object.entries(rootFunctions)) {\n if (definition) {\n registry[name] = definition;\n }\n }\n\n for (const component of resolveComponentsManifest(manifest)) {\n appendResolvedComponentFunctions(registry, component);\n }\n\n return registry;\n}\n\nexport function createInstalledComponentsApi<\n TManifest extends SyncoreComponentsManifest\n>(manifest: TManifest): InstalledComponentsApi<TManifest> {\n return createInstalledComponentsApiObject(resolveComponentsManifest(manifest)) as InstalledComponentsApi<TManifest>;\n}\n\nexport function resolveComponentsManifest(\n manifest?: SyncoreComponentsManifest\n): ResolvedSyncoreComponent[] {\n if (!manifest) {\n return [];\n }\n\n return Object.entries(manifest)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([alias, install]) => resolveInstalledComponent(alias, install, []));\n}\n\nexport function toCanonicalComponentFunctionName(\n componentPath: ComponentPath,\n visibility: \"public\" | \"internal\",\n localName: string\n): string {\n return [\"components\", componentPath, visibility, localName]\n .filter(Boolean)\n .join(\"/\");\n}\n\nexport function createComponentPhysicalTableName(\n componentPath: ComponentPath,\n tableName: string\n): string {\n const pathPart = sanitizeComponentPath(componentPath);\n return `__syncore_component__${pathPart}__${tableName}`;\n}\n\nfunction resolveInstalledComponent(\n alias: string,\n install: SyncoreComponentInstall,\n parentPath: string[]\n): ResolvedSyncoreComponent {\n const pathSegments = [...parentPath, alias];\n const componentPath = pathSegments.join(\"/\");\n const component = install.component;\n const requestedCapabilities = [\n ...(component.requestedCapabilities ?? [])\n ];\n const localTables = createLocalTableMap(componentPath, component.schema);\n const defaultCapabilities = new Set<SyncoreRequestedCapability>(\n component.schema ? [\"ownTables\"] : []\n );\n if (component.public) {\n defaultCapabilities.add(\"publicExports\");\n }\n if (component.internal) {\n defaultCapabilities.add(\"internalActions\");\n }\n const grantedCapabilities = Array.from(\n new Set([\n ...defaultCapabilities,\n ...(install.capabilities ?? requestedCapabilities)\n ])\n );\n\n for (const capability of requestedCapabilities) {\n if (!grantedCapabilities.includes(capability)) {\n throw new Error(\n `Component ${JSON.stringify(component.name)} at ${JSON.stringify(componentPath)} requested capability ${JSON.stringify(capability)} but it was not granted.`\n );\n }\n }\n\n if (component.config) {\n component.config.parse(install.config);\n }\n\n const bindings = { ...(install.bindings ?? {}) };\n for (const dependency of component.dependencies ?? []) {\n if (!bindings[dependency]) {\n throw new Error(\n `Component ${JSON.stringify(component.name)} at ${JSON.stringify(componentPath)} requires binding ${JSON.stringify(dependency)}.`\n );\n }\n }\n\n const children = Object.entries(install.children ?? {})\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([childAlias, childInstall]) =>\n resolveInstalledComponent(childAlias, childInstall, pathSegments)\n );\n\n return {\n alias,\n path: componentPath,\n source: install.source,\n name: component.name,\n version: component.version,\n config: install.config,\n grantedCapabilities,\n requestedCapabilities,\n bindings,\n schema: component.schema,\n public: component.public,\n internal: component.internal,\n publicEntries: flattenComponentFunctionTree(\n component.public,\n componentPath,\n component.name,\n component.version,\n \"public\",\n localTables,\n grantedCapabilities,\n bindings\n ),\n internalEntries: flattenComponentFunctionTree(\n component.internal,\n componentPath,\n component.name,\n component.version,\n \"internal\",\n localTables,\n grantedCapabilities,\n bindings\n ),\n localTables,\n onStart: component.onStart,\n onStop: component.onStop,\n children\n };\n}\n\nfunction createLocalTableMap(\n componentPath: string,\n schema?: SyncoreDataModel\n): Record<string, string> {\n if (!schema) {\n return {};\n }\n return Object.fromEntries(\n schema.tableNames().map((tableName) => [\n tableName,\n createComponentPhysicalTableName(componentPath, tableName)\n ])\n );\n}\n\nfunction composeComponentTables(\n component: ResolvedSyncoreComponent\n): Array<[string, AnyTableDefinition]> {\n const entries: Array<[string, AnyTableDefinition]> = [];\n if (component.schema) {\n for (const localTableName of component.schema.tableNames()) {\n const original = component.schema.getTable(localTableName);\n const cloned = new TableDefinition(original.validator, {\n ...original.options,\n tableName: localTableName,\n componentPath: component.path,\n componentName: component.name\n });\n for (const index of original.indexes) {\n if (index.fields.length > 0) {\n cloned.index(index.name, [...index.fields] as [string, ...string[]]);\n }\n }\n for (const index of original.searchIndexes) {\n cloned.searchIndex(index.name, {\n searchField: index.searchField,\n filterFields: [...index.filterFields]\n });\n }\n entries.push([component.localTables[localTableName]!, cloned]);\n }\n }\n for (const child of component.children) {\n entries.push(...composeComponentTables(child));\n }\n return entries;\n}\n\nfunction appendResolvedComponentFunctions(\n registry: Record<string, RegisteredSyncoreFunction>,\n component: ResolvedSyncoreComponent\n): void {\n for (const entry of component.publicEntries) {\n registry[entry.canonicalName] = entry.definition;\n }\n for (const entry of component.internalEntries) {\n registry[entry.canonicalName] = entry.definition;\n }\n for (const child of component.children) {\n appendResolvedComponentFunctions(registry, child);\n }\n}\n\nfunction flattenComponentFunctionTree(\n tree: SyncoreFunctionTree | undefined,\n componentPath: string,\n componentName: string,\n version: string,\n visibility: \"public\" | \"internal\",\n localTables: Record<string, string>,\n grantedCapabilities: readonly SyncoreRequestedCapability[],\n bindings: Record<string, string>,\n prefix: string[] = []\n): Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n}> {\n if (!tree) {\n return [];\n }\n\n const entries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }> = [];\n\n for (const [key, value] of Object.entries(tree).sort(([left], [right]) =>\n left.localeCompare(right)\n )) {\n if (!value) {\n continue;\n }\n if (isFunctionDefinition(value)) {\n const localName = [...prefix, key].join(\"/\");\n entries.push({\n localName,\n canonicalName: toCanonicalComponentFunctionName(\n componentPath,\n visibility,\n localName\n ),\n definition: decorateComponentFunctionDefinition(value, {\n componentPath,\n componentName,\n version,\n visibility,\n localName,\n localTables,\n grantedCapabilities,\n bindings\n })\n });\n continue;\n }\n entries.push(\n ...flattenComponentFunctionTree(\n value,\n componentPath,\n componentName,\n version,\n visibility,\n localTables,\n grantedCapabilities,\n bindings,\n [...prefix, key]\n )\n );\n }\n\n return entries;\n}\n\nfunction decorateComponentFunctionDefinition(\n definition: AnySyncoreFunctionDefinition,\n metadata: SyncoreComponentFunctionMetadata\n): RegisteredSyncoreFunction {\n return {\n ...definition,\n __syncoreComponent: metadata\n } as RegisteredSyncoreFunction;\n}\n\nfunction createInstalledComponentsApiObject(\n components: ResolvedSyncoreComponent[]\n): Record<string, unknown> {\n return Object.fromEntries(\n components.map((component) => [\n component.alias,\n createInstalledComponentApiNode(component)\n ])\n );\n}\n\nfunction createInstalledComponentApiNode(\n component: ResolvedSyncoreComponent\n): Record<string, unknown> {\n const node: Record<string, unknown> = {};\n for (const entry of component.publicEntries) {\n assignFunctionReference(\n node,\n entry.localName.split(\"/\"),\n {\n kind: entry.definition.kind,\n name: entry.canonicalName\n }\n );\n }\n for (const child of component.children) {\n node[child.alias] = createInstalledComponentApiNode(child);\n }\n return node;\n}\n\nfunction assignFunctionReference(\n node: Record<string, unknown>,\n pathParts: string[],\n reference: FunctionReference\n): void {\n const [head, ...tail] = pathParts;\n if (!head) {\n return;\n }\n if (tail.length === 0) {\n node[head] = reference;\n return;\n }\n const child =\n node[head] && typeof node[head] === \"object\"\n ? (node[head] as Record<string, unknown>)\n : {};\n node[head] = child;\n assignFunctionReference(child, tail, reference);\n}\n\nfunction isFunctionDefinition(value: unknown): value is AnySyncoreFunctionDefinition {\n return (\n Boolean(value) &&\n typeof value === \"object\" &&\n \"kind\" in (value as Record<string, unknown>) &&\n \"argsValidator\" in (value as Record<string, unknown>) &&\n \"handler\" in (value as Record<string, unknown>)\n );\n}\n\nfunction sanitizeComponentPath(componentPath: string): string {\n return componentPath.replace(/[^a-zA-Z0-9_]+/g, \"_\");\n}\n"],"mappings":";;AAsLA,SAAgB,gBAYd,WAIwD;AACxD,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;AAGH,SAAgB,iBAGd,SASiD;AACjD,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;AAGH,SAAgB,iBACd,YACW;AACX,QAAO;;AAGT,SA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AI,CAAC,KACH;AAEF,KAAI,KAAK,WAAW,GAAG;AACrB,OAAK,QAAQ;AACb;;CAEF,MAAM,QACJ,KAAK,SAAS,OAAO,KAAK,UAAU,WAC/B,KAAK,QACN,EAAE;AACR,MAAK,QAAQ;AACb,yBAAwB,OAAO,MAAM,UAAU;;AAGjD,SAAS,qBAAqB,OAAuD;AACnF,QACE,QAAQ,MAAM,IACd,OAAO,UAAU,YACjB,UAAW,SACX,mBAAoB,SACpB,aAAc;;AAIlB,SAAS,sBAAsB,eAA+B;AAC5D,QAAO,cAAc,QAAQ,mBAAmB,IAAI"}
|
|
1
|
+
{"version":3,"file":"components.mjs","names":[],"sources":["../../src/runtime/components.ts"],"sourcesContent":["import {\n SyncoreSchema,\n TableDefinition,\n defineSchema,\n type AnyTableDefinition,\n type Validator\n} from \"@syncore/schema\";\nimport type { SyncoreDevtoolsEvent } from \"@syncore/devtools-protocol\";\nimport {\n type FunctionReference,\n type FunctionReferenceFor,\n type SyncoreFunctionDefinition,\n type SyncoreFunctionKind\n} from \"./functions.js\";\nimport type {\n JsonObject,\n RegisteredSyncoreFunction,\n SyncoreDataModel,\n SyncoreFunctionRegistry\n} from \"./runtime.js\";\n\nexport type ComponentPath = string;\n\nexport type SyncoreCoreCapability =\n | \"storage\"\n | \"scheduler\"\n | \"devtools\"\n | \"ownTables\"\n | \"publicExports\"\n | \"internalActions\";\n\nexport type SyncoreHostServiceName =\n | \"http\"\n | \"notifications\"\n | \"secureStore\"\n | \"filesystem\"\n | \"backgroundTasks\"\n | \"crypto\";\n\nexport type SyncoreRequestedCapability =\n | SyncoreCoreCapability\n | `host:${SyncoreHostServiceName}`;\n\nexport type AnySyncoreFunctionDefinition = SyncoreFunctionDefinition<\n SyncoreFunctionKind,\n any,\n any,\n unknown\n>;\n\nexport type SyncoreFunctionTree = {\n readonly [key: string]:\n | AnySyncoreFunctionDefinition\n | SyncoreFunctionTree\n | undefined;\n};\n\nexport interface SyncoreComponentHookContext {\n runtimeId: string;\n platform: string;\n componentPath: ComponentPath;\n componentName: string;\n version: string;\n config: unknown;\n capabilities: readonly SyncoreRequestedCapability[];\n emitDevtools(event: SyncoreDevtoolsEvent): void;\n}\n\nexport interface SyncoreComponent<\n TConfig = unknown,\n TSchema extends SyncoreDataModel | undefined =\n | SyncoreDataModel\n | undefined,\n TPublic extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined,\n TInternal extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined\n> {\n readonly kind: \"syncore.component\";\n readonly name: string;\n readonly version: string;\n readonly config?: Validator<TConfig>;\n readonly requestedCapabilities?: readonly SyncoreRequestedCapability[];\n readonly schema?: TSchema;\n readonly public?: TPublic;\n readonly internal?: TInternal;\n readonly dependencies?: readonly string[];\n onStart?(context: SyncoreComponentHookContext): Promise<void> | void;\n onStop?(context: SyncoreComponentHookContext): Promise<void> | void;\n}\n\nexport interface SyncoreComponentInstall<\n TComponent extends SyncoreComponent = SyncoreComponent,\n TChildren extends SyncoreComponentsManifest = SyncoreComponentsManifest\n> {\n readonly kind: \"syncore.component.install\";\n readonly component: TComponent;\n readonly source: string;\n readonly config?: TComponent extends SyncoreComponent<infer TConfig, any, any, any>\n ? TConfig\n : unknown;\n readonly capabilities?: readonly SyncoreRequestedCapability[];\n readonly bindings?: Record<string, string>;\n readonly children?: TChildren;\n}\n\nexport type SyncoreComponentsManifest = Record<string, SyncoreComponentInstall>;\n\nexport interface SyncoreComponentFunctionMetadata {\n componentPath: ComponentPath;\n componentName: string;\n version: string;\n visibility: \"public\" | \"internal\";\n localName: string;\n localTables: Record<string, string>;\n grantedCapabilities: readonly SyncoreRequestedCapability[];\n bindings: Record<string, string>;\n}\n\nexport interface ResolvedSyncoreComponent {\n alias: string;\n path: ComponentPath;\n source: string;\n name: string;\n version: string;\n config: unknown;\n grantedCapabilities: readonly SyncoreRequestedCapability[];\n requestedCapabilities: readonly SyncoreRequestedCapability[];\n bindings: Record<string, string>;\n schema: SyncoreDataModel | undefined;\n public: SyncoreFunctionTree | undefined;\n internal: SyncoreFunctionTree | undefined;\n publicEntries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }>;\n internalEntries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }>;\n localTables: Record<string, string>;\n onStart: SyncoreComponent[\"onStart\"] | undefined;\n onStop: SyncoreComponent[\"onStop\"] | undefined;\n children: ResolvedSyncoreComponent[];\n}\n\ntype Simplify<T> = { [K in keyof T]: T[K] } & {};\n\ntype PublicFunctionTreeOf<TComponent> = TComponent extends SyncoreComponent<\n any,\n any,\n infer TPublic,\n any\n>\n ? NonNullable<TPublic>\n : never;\n\nexport type FunctionReferencesForTree<TTree extends SyncoreFunctionTree> = Simplify<{\n [TKey in keyof TTree]: TTree[TKey] extends AnySyncoreFunctionDefinition\n ? FunctionReferenceFor<TTree[TKey]>\n : Record<string, unknown>;\n}>;\n\nexport type InstalledComponentApi<\n TInstall extends SyncoreComponentInstall\n> = Simplify<\n FunctionReferencesForTree<PublicFunctionTreeOf<TInstall[\"component\"]>> &\n Record<string, unknown>\n>;\n\nexport type InstalledComponentsApi<\n TManifest extends SyncoreComponentsManifest\n> = Simplify<{\n [TAlias in keyof TManifest]: InstalledComponentApi<TManifest[TAlias]>;\n}>;\n\ntype TablesOfSchema<TSchema extends SyncoreDataModel> = TSchema[\"tables\"];\n\nexport function defineComponent<\n TConfig = unknown,\n TSchema extends SyncoreDataModel | undefined =\n | SyncoreDataModel\n | undefined,\n TPublic extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined,\n TInternal extends SyncoreFunctionTree | undefined =\n | SyncoreFunctionTree\n | undefined\n>(\n component: Omit<\n SyncoreComponent<TConfig, TSchema, TPublic, TInternal>,\n \"kind\"\n >\n): SyncoreComponent<TConfig, TSchema, TPublic, TInternal> {\n return {\n kind: \"syncore.component\",\n ...component\n };\n}\n\nexport function installComponent<\n TComponent extends SyncoreComponent,\n TChildren extends SyncoreComponentsManifest = {}\n>(install: {\n component: TComponent;\n source: string;\n config?: TComponent extends SyncoreComponent<infer TConfig, any, any, any>\n ? TConfig\n : unknown;\n capabilities?: readonly SyncoreRequestedCapability[];\n bindings?: Record<string, string>;\n children?: TChildren;\n}): SyncoreComponentInstall<TComponent, TChildren> {\n return {\n kind: \"syncore.component.install\",\n ...install\n };\n}\n\nexport function defineComponents<TManifest extends SyncoreComponentsManifest>(\n components: TManifest\n): TManifest {\n return components;\n}\n\nexport function createBindingFunctionReference<\n TKind extends SyncoreFunctionKind,\n TArgs = JsonObject,\n TResult = unknown\n>(\n kind: TKind,\n bindingName: string,\n functionName: string\n): FunctionReference<TKind, TArgs, TResult> {\n return {\n kind,\n name: `binding:${bindingName}/${functionName}`\n };\n}\n\nexport function composeProjectSchema<\n TRootSchema extends SyncoreDataModel\n>(\n rootSchema: TRootSchema,\n manifest?: SyncoreComponentsManifest\n): SyncoreSchema<TablesOfSchema<TRootSchema> & Record<string, AnyTableDefinition>> {\n const tables: Record<string, AnyTableDefinition> = {\n ...rootSchema.tables\n };\n\n for (const component of resolveComponentsManifest(manifest)) {\n for (const [physicalTableName, tableDefinition] of composeComponentTables(\n component\n )) {\n if (tables[physicalTableName]) {\n throw new Error(\n `Component table collision detected for ${JSON.stringify(physicalTableName)}.`\n );\n }\n tables[physicalTableName] = tableDefinition;\n }\n }\n\n return defineSchema(tables) as unknown as SyncoreSchema<\n TablesOfSchema<TRootSchema> & Record<string, AnyTableDefinition>\n >;\n}\n\nexport function composeProjectFunctionRegistry(\n rootFunctions: SyncoreFunctionRegistry,\n manifest?: SyncoreComponentsManifest\n): SyncoreFunctionRegistry {\n const registry: Record<string, RegisteredSyncoreFunction> = {};\n for (const [name, definition] of Object.entries(rootFunctions)) {\n if (definition) {\n registry[name] = definition;\n }\n }\n\n for (const component of resolveComponentsManifest(manifest)) {\n appendResolvedComponentFunctions(registry, component);\n }\n\n return registry;\n}\n\nexport function createInstalledComponentsApi<\n TManifest extends SyncoreComponentsManifest\n>(manifest: TManifest): InstalledComponentsApi<TManifest> {\n return createInstalledComponentsApiObject(resolveComponentsManifest(manifest)) as InstalledComponentsApi<TManifest>;\n}\n\nexport function resolveComponentsManifest(\n manifest?: SyncoreComponentsManifest\n): ResolvedSyncoreComponent[] {\n if (!manifest) {\n return [];\n }\n\n return Object.entries(manifest)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([alias, install]) => resolveInstalledComponent(alias, install, []));\n}\n\nexport function toCanonicalComponentFunctionName(\n componentPath: ComponentPath,\n visibility: \"public\" | \"internal\",\n localName: string\n): string {\n return [\"components\", componentPath, visibility, localName]\n .filter(Boolean)\n .join(\"/\");\n}\n\nexport function createComponentPhysicalTableName(\n componentPath: ComponentPath,\n tableName: string\n): string {\n const pathPart = sanitizeComponentPath(componentPath);\n return `__syncore_component__${pathPart}__${tableName}`;\n}\n\nfunction resolveInstalledComponent(\n alias: string,\n install: SyncoreComponentInstall,\n parentPath: string[]\n): ResolvedSyncoreComponent {\n const pathSegments = [...parentPath, alias];\n const componentPath = pathSegments.join(\"/\");\n const component = install.component;\n const requestedCapabilities = [\n ...(component.requestedCapabilities ?? [])\n ];\n const localTables = createLocalTableMap(componentPath, component.schema);\n const defaultCapabilities = new Set<SyncoreRequestedCapability>(\n component.schema ? [\"ownTables\"] : []\n );\n if (component.public) {\n defaultCapabilities.add(\"publicExports\");\n }\n if (component.internal) {\n defaultCapabilities.add(\"internalActions\");\n }\n const grantedCapabilities = Array.from(\n new Set([\n ...defaultCapabilities,\n ...(install.capabilities ?? requestedCapabilities)\n ])\n );\n\n for (const capability of requestedCapabilities) {\n if (!grantedCapabilities.includes(capability)) {\n throw new Error(\n `Component ${JSON.stringify(component.name)} at ${JSON.stringify(componentPath)} requested capability ${JSON.stringify(capability)} but it was not granted.`\n );\n }\n }\n\n if (component.config) {\n component.config.parse(install.config);\n }\n\n const bindings = { ...(install.bindings ?? {}) };\n for (const dependency of component.dependencies ?? []) {\n if (!bindings[dependency]) {\n throw new Error(\n `Component ${JSON.stringify(component.name)} at ${JSON.stringify(componentPath)} requires binding ${JSON.stringify(dependency)}.`\n );\n }\n }\n\n const children = Object.entries(install.children ?? {})\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([childAlias, childInstall]) =>\n resolveInstalledComponent(childAlias, childInstall, pathSegments)\n );\n\n return {\n alias,\n path: componentPath,\n source: install.source,\n name: component.name,\n version: component.version,\n config: install.config,\n grantedCapabilities,\n requestedCapabilities,\n bindings,\n schema: component.schema,\n public: component.public,\n internal: component.internal,\n publicEntries: flattenComponentFunctionTree(\n component.public,\n componentPath,\n component.name,\n component.version,\n \"public\",\n localTables,\n grantedCapabilities,\n bindings\n ),\n internalEntries: flattenComponentFunctionTree(\n component.internal,\n componentPath,\n component.name,\n component.version,\n \"internal\",\n localTables,\n grantedCapabilities,\n bindings\n ),\n localTables,\n onStart: component.onStart,\n onStop: component.onStop,\n children\n };\n}\n\nfunction createLocalTableMap(\n componentPath: string,\n schema?: SyncoreDataModel\n): Record<string, string> {\n if (!schema) {\n return {};\n }\n return Object.fromEntries(\n schema.tableNames().map((tableName) => [\n tableName,\n createComponentPhysicalTableName(componentPath, tableName)\n ])\n );\n}\n\nfunction composeComponentTables(\n component: ResolvedSyncoreComponent\n): Array<[string, AnyTableDefinition]> {\n const entries: Array<[string, AnyTableDefinition]> = [];\n if (component.schema) {\n for (const localTableName of component.schema.tableNames()) {\n const original = component.schema.getTable(localTableName);\n const cloned = new TableDefinition(original.validator, {\n ...original.options,\n tableName: localTableName,\n componentPath: component.path,\n componentName: component.name\n });\n for (const index of original.indexes) {\n if (index.fields.length > 0) {\n cloned.index(index.name, [...index.fields] as [string, ...string[]]);\n }\n }\n for (const index of original.searchIndexes) {\n cloned.searchIndex(index.name, {\n searchField: index.searchField,\n filterFields: [...index.filterFields]\n });\n }\n entries.push([component.localTables[localTableName]!, cloned]);\n }\n }\n for (const child of component.children) {\n entries.push(...composeComponentTables(child));\n }\n return entries;\n}\n\nfunction appendResolvedComponentFunctions(\n registry: Record<string, RegisteredSyncoreFunction>,\n component: ResolvedSyncoreComponent\n): void {\n for (const entry of component.publicEntries) {\n registry[entry.canonicalName] = entry.definition;\n }\n for (const entry of component.internalEntries) {\n registry[entry.canonicalName] = entry.definition;\n }\n for (const child of component.children) {\n appendResolvedComponentFunctions(registry, child);\n }\n}\n\nfunction flattenComponentFunctionTree(\n tree: SyncoreFunctionTree | undefined,\n componentPath: string,\n componentName: string,\n version: string,\n visibility: \"public\" | \"internal\",\n localTables: Record<string, string>,\n grantedCapabilities: readonly SyncoreRequestedCapability[],\n bindings: Record<string, string>,\n prefix: string[] = []\n): Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n}> {\n if (!tree) {\n return [];\n }\n\n const entries: Array<{\n localName: string;\n canonicalName: string;\n definition: RegisteredSyncoreFunction;\n }> = [];\n\n for (const [key, value] of Object.entries(tree).sort(([left], [right]) =>\n left.localeCompare(right)\n )) {\n if (!value) {\n continue;\n }\n if (isFunctionDefinition(value)) {\n const localName = [...prefix, key].join(\"/\");\n entries.push({\n localName,\n canonicalName: toCanonicalComponentFunctionName(\n componentPath,\n visibility,\n localName\n ),\n definition: decorateComponentFunctionDefinition(value, {\n componentPath,\n componentName,\n version,\n visibility,\n localName,\n localTables,\n grantedCapabilities,\n bindings\n })\n });\n continue;\n }\n entries.push(\n ...flattenComponentFunctionTree(\n value,\n componentPath,\n componentName,\n version,\n visibility,\n localTables,\n grantedCapabilities,\n bindings,\n [...prefix, key]\n )\n );\n }\n\n return entries;\n}\n\nfunction decorateComponentFunctionDefinition(\n definition: AnySyncoreFunctionDefinition,\n metadata: SyncoreComponentFunctionMetadata\n): RegisteredSyncoreFunction {\n return {\n ...definition,\n __syncoreComponent: metadata\n } as RegisteredSyncoreFunction;\n}\n\nfunction createInstalledComponentsApiObject(\n components: ResolvedSyncoreComponent[]\n): Record<string, unknown> {\n return Object.fromEntries(\n components.map((component) => [\n component.alias,\n createInstalledComponentApiNode(component)\n ])\n );\n}\n\nfunction createInstalledComponentApiNode(\n component: ResolvedSyncoreComponent\n): Record<string, unknown> {\n const node: Record<string, unknown> = {};\n for (const entry of component.publicEntries) {\n assignFunctionReference(\n node,\n entry.localName.split(\"/\"),\n {\n kind: entry.definition.kind,\n name: entry.canonicalName\n }\n );\n }\n for (const child of component.children) {\n node[child.alias] = createInstalledComponentApiNode(child);\n }\n return node;\n}\n\nfunction assignFunctionReference(\n node: Record<string, unknown>,\n pathParts: string[],\n reference: FunctionReference\n): void {\n const [head, ...tail] = pathParts;\n if (!head) {\n return;\n }\n if (tail.length === 0) {\n node[head] = reference;\n return;\n }\n const child =\n node[head] && typeof node[head] === \"object\"\n ? (node[head] as Record<string, unknown>)\n : {};\n node[head] = child;\n assignFunctionReference(child, tail, reference);\n}\n\nfunction isFunctionDefinition(value: unknown): value is AnySyncoreFunctionDefinition {\n return (\n Boolean(value) &&\n typeof value === \"object\" &&\n \"kind\" in (value as Record<string, unknown>) &&\n \"argsValidator\" in (value as Record<string, unknown>) &&\n \"handler\" in (value as Record<string, unknown>)\n );\n}\n\nfunction sanitizeComponentPath(componentPath: string): string {\n return componentPath.replace(/[^a-zA-Z0-9_]+/g, \"_\");\n}\n"],"mappings":";;AAsLA,SAAgB,gBAYd,WAIwD;CACxD,OAAO;EACL,MAAM;EACN,GAAG;CACL;AACF;AAEA,SAAgB,iBAGd,SASiD;CACjD,OAAO;EACL,MAAM;EACN,GAAG;CACL;AACF;AAEA,SAAgB,iBACd,YACW;CACX,OAAO;AACT;AAEA,SAAgB,+BAKd,MACA,aACA,cAC0C;CAC1C,OAAO;EACL;EACA,MAAM,WAAW,YAAY,GAAG;CAClC;AACF;AAEA,SAAgB,qBAGd,YACA,UACiF;CACjF,MAAM,SAA6C,EACjD,GAAG,WAAW,OAChB;CAEA,KAAK,MAAM,aAAa,0BAA0B,QAAQ,GACxD,KAAK,MAAM,CAAC,mBAAmB,oBAAoB,uBACjD,SACF,GAAG;E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,MAAM,SAAS;AAChD;AAEA,SAAS,qBAAqB,OAAuD;CACnF,OACE,QAAQ,KAAK,KACb,OAAO,UAAU,YACjB,UAAW,SACX,mBAAoB,SACpB,aAAc;AAElB;AAEA,SAAS,sBAAsB,eAA+B;CAC5D,OAAO,cAAc,QAAQ,mBAAmB,GAAG;AACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.d.mts","names":[],"sources":["../../src/runtime/devtools.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"devtools.d.mts","names":[],"sources":["../../src/runtime/devtools.ts"],"mappings":";;;;UA4BiB,0BAAA;EACf,MAAA,EAAQ,gBAAA;EACR,MAAA,EAAQ,gBAAA;EACR,SAAA,EAAW,qBAAA,CAAsB,gBAAA;EACjC,KAAA,EAAO,mBAAA,CAAoB,gBAAA;EAC3B,GAAA,GAAM,kBAAA;AAAA;AAAA,KAGI,eAAA;AAAA,UAEK,mBAAA;EACf,IAAA,EAAM,eAAA;EACN,UAAA;EACA,WAAA;EACA,aAAA;EACA,cAAA,EAAgB,sBAAsB;AAAA;AAAA,UAGvB,qBAAA;EACf,OAAA;EACA,IAAA;EACA,cAAA;AAAA;AAAA,UAGe,kBAAA;EACf,mBAAA,CAAoB,KAAA,WAAgB,mBAAA;EACpC,aAAA,CACE,QAAA,EAAU,mBAAA,EACV,QAAA,EAAU,eAAA;EAEZ,gBAAA,CAAiB,YAAA,UAAsB,KAAA,WAAgB,qBAAA;AAAA;AAAA,KAG7C,sBAAA,IACV,OAAA,EAAS,6BAAA,KACN,OAAA,CAAQ,mCAAA;AAAA,KAED,4BAAA,IACV,OAAiD,EAAxC,wCAAwC;AAAA,UAGlC,wBAAA;EACf,SAAA,CACE,cAAA,UACA,OAAA,EAAS,kCAAA,EACT,QAAA,EAAU,4BAAA,GACT,OAAA;EACH,WAAA,CAAY,cAAA;EACZ,OAAA;AAAA;AAAA,iBAYc,4BAAA,CACd,IAAA,EAAM,0BAAA,GACL,sBAAsB;AAAA,iBAkZT,8BAAA,CACd,IAAA,EAAM,0BAAA,GACL,wBAAwB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseCanonicalComponentFunctionName, parseComponentScopedIdentifier, safeReadRecurringSchedule } from "./internal/engines/shared.mjs";
|
|
1
|
+
import { parseCanonicalComponentFunctionName, parseComponentScopedIdentifier, quoteIdentifier, safeReadRecurringSchedule } from "./internal/engines/shared.mjs";
|
|
2
2
|
import { createFunctionReference } from "./runtime.mjs";
|
|
3
3
|
import { describeValidator } from "../../schema/index.js";
|
|
4
4
|
//#region src/runtime/devtools.ts
|
|
@@ -36,10 +36,12 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
case "data.insert": try {
|
|
39
|
+
const id = await runDevtoolsMutation(admin, async (ctx) => ctx.db.insert(payload.table, payload.document), { origin: "dashboard" });
|
|
40
|
+
notifyDataMutationScopes(admin, payload.table);
|
|
39
41
|
return {
|
|
40
42
|
kind: "data.mutate.result",
|
|
41
43
|
success: true,
|
|
42
|
-
id
|
|
44
|
+
id
|
|
43
45
|
};
|
|
44
46
|
} catch (error) {
|
|
45
47
|
return {
|
|
@@ -53,6 +55,7 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
53
55
|
await ctx.db.patch(payload.table, payload.id, payload.fields);
|
|
54
56
|
return null;
|
|
55
57
|
}, { origin: "dashboard" });
|
|
58
|
+
notifyDataMutationScopes(admin, payload.table);
|
|
56
59
|
return {
|
|
57
60
|
kind: "data.mutate.result",
|
|
58
61
|
success: true,
|
|
@@ -70,6 +73,7 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
70
73
|
await ctx.db.delete(payload.table, payload.id);
|
|
71
74
|
return null;
|
|
72
75
|
}, { origin: "dashboard" });
|
|
76
|
+
notifyDataMutationScopes(admin, payload.table);
|
|
73
77
|
return {
|
|
74
78
|
kind: "data.mutate.result",
|
|
75
79
|
success: true
|
|
@@ -81,6 +85,51 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
81
85
|
error: error instanceof Error ? error.message : String(error)
|
|
82
86
|
};
|
|
83
87
|
}
|
|
88
|
+
case "data.export": try {
|
|
89
|
+
const requestedTables = payload.tables && payload.tables.length > 0 ? payload.tables : deps.schema.tableNames();
|
|
90
|
+
return {
|
|
91
|
+
kind: "data.export.result",
|
|
92
|
+
tables: await Promise.all(requestedTables.map(async (name) => {
|
|
93
|
+
const result = await queryTable(driver, name);
|
|
94
|
+
return {
|
|
95
|
+
name,
|
|
96
|
+
rows: result.rows,
|
|
97
|
+
totalCount: result.totalCount
|
|
98
|
+
};
|
|
99
|
+
}))
|
|
100
|
+
};
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
kind: "data.export.result",
|
|
104
|
+
tables: [],
|
|
105
|
+
error: error instanceof Error ? error.message : String(error)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
case "data.referenceOptions": {
|
|
109
|
+
const limit = Math.min(Math.max(payload.limit ?? 100, 1), 200);
|
|
110
|
+
const offset = Math.max(payload.offset ?? 0, 0);
|
|
111
|
+
try {
|
|
112
|
+
const result = await queryReferenceOptions(driver, payload.table, payload.search, limit, offset);
|
|
113
|
+
return {
|
|
114
|
+
kind: "data.referenceOptions.result",
|
|
115
|
+
table: payload.table,
|
|
116
|
+
rows: result.rows,
|
|
117
|
+
totalCount: result.totalCount,
|
|
118
|
+
offset,
|
|
119
|
+
hasMore: offset + result.rows.length < result.totalCount
|
|
120
|
+
};
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return {
|
|
123
|
+
kind: "data.referenceOptions.result",
|
|
124
|
+
table: payload.table,
|
|
125
|
+
rows: [],
|
|
126
|
+
totalCount: 0,
|
|
127
|
+
offset,
|
|
128
|
+
hasMore: false,
|
|
129
|
+
error: error instanceof Error ? error.message : String(error)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
84
133
|
case "sql.read": try {
|
|
85
134
|
const sqlSupport = requireDevtoolsSqlSupport(sql);
|
|
86
135
|
const databasePath = admin.getDriverDatabasePath();
|
|
@@ -118,6 +167,94 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
118
167
|
error: error instanceof Error ? error.message : String(error)
|
|
119
168
|
};
|
|
120
169
|
}
|
|
170
|
+
case "storage.list": {
|
|
171
|
+
const limit = normalizeStorageLimit(payload.limit);
|
|
172
|
+
const offset = Math.max(payload.offset ?? 0, 0);
|
|
173
|
+
try {
|
|
174
|
+
const result = await admin.listStorageObjects({
|
|
175
|
+
limit,
|
|
176
|
+
offset,
|
|
177
|
+
...payload.search ? { search: payload.search } : {}
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
kind: "storage.list.result",
|
|
181
|
+
entries: result.entries,
|
|
182
|
+
totalCount: result.totalCount,
|
|
183
|
+
offset,
|
|
184
|
+
hasMore: offset + result.entries.length < result.totalCount
|
|
185
|
+
};
|
|
186
|
+
} catch (error) {
|
|
187
|
+
return {
|
|
188
|
+
kind: "storage.list.result",
|
|
189
|
+
entries: [],
|
|
190
|
+
totalCount: 0,
|
|
191
|
+
offset,
|
|
192
|
+
hasMore: false,
|
|
193
|
+
error: error instanceof Error ? error.message : String(error)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
case "storage.access.create": try {
|
|
198
|
+
const object = await admin.getStorageObjectAccessInfo(payload.id);
|
|
199
|
+
if (!object) return {
|
|
200
|
+
kind: "storage.access.create.result",
|
|
201
|
+
error: `Storage object ${JSON.stringify(payload.id)} was not found.`
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
kind: "storage.access.create.result",
|
|
205
|
+
entry: object.entry,
|
|
206
|
+
supportsRange: object.supportsRange,
|
|
207
|
+
error: "Storage access URLs must be created by the Syncore devtools hub."
|
|
208
|
+
};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
return {
|
|
211
|
+
kind: "storage.access.create.result",
|
|
212
|
+
error: error instanceof Error ? error.message : String(error)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
case "storage.readRange": try {
|
|
216
|
+
const object = await admin.readStorageObjectRange(payload.id, payload.offset, payload.length);
|
|
217
|
+
if (!object) return {
|
|
218
|
+
kind: "storage.readRange.result",
|
|
219
|
+
offset: payload.offset,
|
|
220
|
+
bytesRead: 0,
|
|
221
|
+
done: true,
|
|
222
|
+
supportsRange: false,
|
|
223
|
+
error: `Storage object ${JSON.stringify(payload.id)} was not found.`
|
|
224
|
+
};
|
|
225
|
+
return {
|
|
226
|
+
kind: "storage.readRange.result",
|
|
227
|
+
entry: object.entry,
|
|
228
|
+
offset: object.offset,
|
|
229
|
+
bytesRead: object.bytesRead,
|
|
230
|
+
done: object.done,
|
|
231
|
+
supportsRange: object.supportsRange,
|
|
232
|
+
base64: bytesToBase64(object.bytes)
|
|
233
|
+
};
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return {
|
|
236
|
+
kind: "storage.readRange.result",
|
|
237
|
+
offset: payload.offset,
|
|
238
|
+
bytesRead: 0,
|
|
239
|
+
done: true,
|
|
240
|
+
supportsRange: false,
|
|
241
|
+
error: error instanceof Error ? error.message : String(error)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
case "storage.delete": try {
|
|
245
|
+
return {
|
|
246
|
+
kind: "storage.delete.result",
|
|
247
|
+
success: true,
|
|
248
|
+
deleted: await admin.deleteStorageObject(payload.id, { origin: "dashboard" })
|
|
249
|
+
};
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return {
|
|
252
|
+
kind: "storage.delete.result",
|
|
253
|
+
success: false,
|
|
254
|
+
deleted: false,
|
|
255
|
+
error: error instanceof Error ? error.message : String(error)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
121
258
|
case "scheduler.cancel": try {
|
|
122
259
|
return {
|
|
123
260
|
kind: "scheduler.cancel.result",
|
|
@@ -135,9 +272,9 @@ function createDevtoolsCommandHandler(deps) {
|
|
|
135
272
|
case "scheduler.update": try {
|
|
136
273
|
const updated = await admin.updateScheduledJob({
|
|
137
274
|
id: payload.jobId,
|
|
138
|
-
schedule: payload.schedule,
|
|
139
275
|
args: payload.args,
|
|
140
|
-
|
|
276
|
+
...payload.schedule ? { schedule: payload.schedule } : {},
|
|
277
|
+
...payload.misfirePolicy ? { misfirePolicy: payload.misfirePolicy } : {},
|
|
141
278
|
...payload.runAt !== void 0 ? { runAt: payload.runAt } : {}
|
|
142
279
|
});
|
|
143
280
|
const updatedJob = (updated ? await listSchedulerJobs(driver) : []).find((job) => job.id === payload.jobId);
|
|
@@ -296,6 +433,33 @@ async function resolveSubscriptionPayload(payload, deps) {
|
|
|
296
433
|
kind: "functions.catalog.result",
|
|
297
434
|
functions: listFunctions(functions)
|
|
298
435
|
};
|
|
436
|
+
case "storage.list": {
|
|
437
|
+
const limit = normalizeStorageLimit(payload.limit);
|
|
438
|
+
const offset = Math.max(payload.offset ?? 0, 0);
|
|
439
|
+
try {
|
|
440
|
+
const result = await admin.listStorageObjects({
|
|
441
|
+
limit,
|
|
442
|
+
offset,
|
|
443
|
+
...payload.search ? { search: payload.search } : {}
|
|
444
|
+
});
|
|
445
|
+
return {
|
|
446
|
+
kind: "storage.list.result",
|
|
447
|
+
entries: result.entries,
|
|
448
|
+
totalCount: result.totalCount,
|
|
449
|
+
offset,
|
|
450
|
+
hasMore: offset + result.entries.length < result.totalCount
|
|
451
|
+
};
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return {
|
|
454
|
+
kind: "storage.list.result",
|
|
455
|
+
entries: [],
|
|
456
|
+
totalCount: 0,
|
|
457
|
+
offset,
|
|
458
|
+
hasMore: false,
|
|
459
|
+
error: error instanceof Error ? error.message : String(error)
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}
|
|
299
463
|
case "sql.watch": {
|
|
300
464
|
const sqlSupport = requireDevtoolsSqlSupport(deps.sql);
|
|
301
465
|
const databasePath = admin.getDriverDatabasePath();
|
|
@@ -311,12 +475,16 @@ async function resolveSubscriptionPayload(payload, deps) {
|
|
|
311
475
|
}
|
|
312
476
|
}
|
|
313
477
|
async function queryTable(driver, table, filters, limit) {
|
|
314
|
-
let sql = `SELECT _id, _creationTime, _json FROM
|
|
478
|
+
let sql = `SELECT _id, _creationTime, _json FROM ${quoteIdentifier(table)}`;
|
|
315
479
|
const params = [];
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
480
|
+
const whereClauses = [];
|
|
481
|
+
if (filters && filters.length > 0) {
|
|
482
|
+
for (const filter of filters) {
|
|
483
|
+
whereClauses.push(filterToSql(filter));
|
|
484
|
+
params.push(normalizeFilterValue(filter));
|
|
485
|
+
}
|
|
486
|
+
sql += ` WHERE ${whereClauses.join(" AND ")}`;
|
|
487
|
+
}
|
|
320
488
|
sql += " ORDER BY _creationTime DESC";
|
|
321
489
|
if (limit) sql += ` LIMIT ${limit}`;
|
|
322
490
|
return {
|
|
@@ -325,7 +493,30 @@ async function queryTable(driver, table, filters, limit) {
|
|
|
325
493
|
_creationTime: row._creationTime,
|
|
326
494
|
...JSON.parse(row._json)
|
|
327
495
|
})),
|
|
328
|
-
totalCount: (await driver.get(`SELECT COUNT(*) as count FROM
|
|
496
|
+
totalCount: (await driver.get(`SELECT COUNT(*) as count FROM ${quoteIdentifier(table)}${whereClauses.length > 0 ? ` WHERE ${whereClauses.join(" AND ")}` : ""}`, params))?.count ?? 0
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
async function queryReferenceOptions(driver, table, search, limit, offset) {
|
|
500
|
+
let sql = `SELECT _id, _creationTime, _json FROM ${quoteIdentifier(table)}`;
|
|
501
|
+
const params = [];
|
|
502
|
+
const trimmedSearch = search?.trim();
|
|
503
|
+
const whereClause = trimmedSearch ? " WHERE _id LIKE ? OR _json LIKE ?" : "";
|
|
504
|
+
if (trimmedSearch) {
|
|
505
|
+
const like = `%${trimmedSearch}%`;
|
|
506
|
+
params.push(like, like);
|
|
507
|
+
}
|
|
508
|
+
sql += `${whereClause} ORDER BY _creationTime DESC LIMIT ? OFFSET ?`;
|
|
509
|
+
return {
|
|
510
|
+
rows: (await driver.all(sql, [
|
|
511
|
+
...params,
|
|
512
|
+
limit,
|
|
513
|
+
offset
|
|
514
|
+
])).map((row) => ({
|
|
515
|
+
_id: row._id,
|
|
516
|
+
_creationTime: row._creationTime,
|
|
517
|
+
...JSON.parse(row._json)
|
|
518
|
+
})),
|
|
519
|
+
totalCount: (await driver.get(`SELECT COUNT(*) as count FROM ${quoteIdentifier(table)}${whereClause}`, params))?.count ?? 0
|
|
329
520
|
};
|
|
330
521
|
}
|
|
331
522
|
async function getSchemaTables(driver, schema) {
|
|
@@ -337,7 +528,8 @@ async function getSchemaTables(driver, schema) {
|
|
|
337
528
|
return {
|
|
338
529
|
name: fieldName,
|
|
339
530
|
type: field.validator.kind,
|
|
340
|
-
optional: field.optional
|
|
531
|
+
optional: field.optional,
|
|
532
|
+
...field.validator.kind === "id" && field.validator.tableName ? { referenceTable: field.validator.tableName } : {}
|
|
341
533
|
};
|
|
342
534
|
}) : [];
|
|
343
535
|
fields.unshift({
|
|
@@ -349,12 +541,7 @@ async function getSchemaTables(driver, schema) {
|
|
|
349
541
|
type: "number",
|
|
350
542
|
optional: false
|
|
351
543
|
});
|
|
352
|
-
|
|
353
|
-
try {
|
|
354
|
-
documentCount = (await driver.get(`SELECT COUNT(*) as count FROM "${name}"`))?.count ?? 0;
|
|
355
|
-
} catch {
|
|
356
|
-
documentCount = 0;
|
|
357
|
-
}
|
|
544
|
+
const documentCount = await driver.get(`SELECT COUNT(*) as count FROM "${name}"`).then((countRow) => countRow?.count ?? 0).catch(() => 0);
|
|
358
545
|
return {
|
|
359
546
|
name,
|
|
360
547
|
...table.options.tableName ? { displayName: table.options.tableName } : {},
|
|
@@ -410,12 +597,18 @@ function listFunctions(functions) {
|
|
|
410
597
|
const descriptor = {
|
|
411
598
|
name,
|
|
412
599
|
type: fn.kind,
|
|
413
|
-
file: inferFileFromFunctionName(name),
|
|
414
600
|
owner: componentFunction ? "component" : "root",
|
|
601
|
+
namespace: inferFunctionNamespace(name),
|
|
602
|
+
metadataAvailable: componentFunction !== null || name.includes(":"),
|
|
415
603
|
...componentFunction ? {
|
|
604
|
+
file: `components/${componentFunction.componentPath}`,
|
|
605
|
+
modulePath: componentFunction.componentPath,
|
|
416
606
|
componentPath: componentFunction.componentPath,
|
|
417
607
|
visibility: componentFunction.visibility,
|
|
418
608
|
localName: componentFunction.localName
|
|
609
|
+
} : inferFileFromFunctionName(name) ? {
|
|
610
|
+
file: inferFileFromFunctionName(name),
|
|
611
|
+
modulePath: inferFunctionNamespace(name)
|
|
419
612
|
} : {}
|
|
420
613
|
};
|
|
421
614
|
const argsDesc = describeValidator(fn.argsValidator);
|
|
@@ -428,14 +621,40 @@ function inferFileFromFunctionName(name) {
|
|
|
428
621
|
if (componentFunction) return `components/${componentFunction.componentPath}`;
|
|
429
622
|
const parts = name.split(":");
|
|
430
623
|
if (parts.length > 1) return `${parts[0]}.ts`;
|
|
431
|
-
return "
|
|
624
|
+
return "";
|
|
625
|
+
}
|
|
626
|
+
function inferFunctionNamespace(name) {
|
|
627
|
+
const componentFunction = parseCanonicalComponentFunctionName(name);
|
|
628
|
+
if (componentFunction) return componentFunction.componentPath;
|
|
629
|
+
if (name.includes(":")) return name.split(":")[0] ?? "root";
|
|
630
|
+
if (name.includes("/")) return name.split("/")[0] ?? "root";
|
|
631
|
+
return "root";
|
|
432
632
|
}
|
|
433
633
|
function normalizeFilterValue(filter) {
|
|
634
|
+
const value = coerceFilterValue(filter.value);
|
|
434
635
|
switch (filter.operator) {
|
|
435
|
-
case "contains": return `%${String(
|
|
436
|
-
case "startsWith": return `${String(
|
|
437
|
-
default: return
|
|
636
|
+
case "contains": return `%${String(value)}%`;
|
|
637
|
+
case "startsWith": return `${String(value)}%`;
|
|
638
|
+
default: return value;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function filterToSql(filter) {
|
|
642
|
+
const operator = filterOperatorToSql(filter.operator);
|
|
643
|
+
if (filter.field === "_id") return `_id ${operator} ?`;
|
|
644
|
+
if (filter.field === "_creationTime") return `_creationTime ${operator} ?`;
|
|
645
|
+
return `json_extract(_json, ${JSON.stringify(`$.${filter.field}`)}) ${operator} ?`;
|
|
646
|
+
}
|
|
647
|
+
function coerceFilterValue(value) {
|
|
648
|
+
if (typeof value !== "string") return value;
|
|
649
|
+
const trimmed = value.trim();
|
|
650
|
+
if (trimmed === "true") return true;
|
|
651
|
+
if (trimmed === "false") return false;
|
|
652
|
+
if (trimmed === "null") return null;
|
|
653
|
+
if (/^-?\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
654
|
+
const numberValue = Number(trimmed);
|
|
655
|
+
if (Number.isFinite(numberValue)) return numberValue;
|
|
438
656
|
}
|
|
657
|
+
return value;
|
|
439
658
|
}
|
|
440
659
|
function filterOperatorToSql(operator) {
|
|
441
660
|
switch (operator) {
|
|
@@ -491,6 +710,24 @@ function capitalize(value) {
|
|
|
491
710
|
async function runDevtoolsMutation(admin, callback, meta) {
|
|
492
711
|
return admin.runDevtoolsMutation(callback, meta);
|
|
493
712
|
}
|
|
713
|
+
function notifyDataMutationScopes(admin, tableName) {
|
|
714
|
+
admin.notifyDevtoolsScopes(["schema.tables", `table:${tableName}`]);
|
|
715
|
+
}
|
|
716
|
+
function normalizeStorageLimit(limit) {
|
|
717
|
+
return Math.min(Math.max(limit ?? 100, 1), 500);
|
|
718
|
+
}
|
|
719
|
+
function bytesToBase64(bytes) {
|
|
720
|
+
const binaryChunkSize = 32768;
|
|
721
|
+
let binary = "";
|
|
722
|
+
for (let offset = 0; offset < bytes.length; offset += binaryChunkSize) {
|
|
723
|
+
const chunk = bytes.slice(offset, offset + binaryChunkSize);
|
|
724
|
+
binary += String.fromCharCode(...chunk);
|
|
725
|
+
}
|
|
726
|
+
if (typeof btoa === "function") return btoa(binary);
|
|
727
|
+
const buffer = globalThis;
|
|
728
|
+
if (buffer.Buffer) return buffer.Buffer.from(bytes).toString("base64");
|
|
729
|
+
throw new Error("Base64 encoding is not available in this environment.");
|
|
730
|
+
}
|
|
494
731
|
function scopesForSubscription(payload, sql) {
|
|
495
732
|
switch (payload.kind) {
|
|
496
733
|
case "runtime.summary": return new Set(["runtime.summary"]);
|
|
@@ -500,6 +737,7 @@ function scopesForSubscription(payload, sql) {
|
|
|
500
737
|
case "data.table": return new Set([`table:${payload.table}`]);
|
|
501
738
|
case "scheduler.jobs": return new Set(["scheduler.jobs"]);
|
|
502
739
|
case "functions.catalog": return new Set(["all"]);
|
|
740
|
+
case "storage.list": return new Set(["storage.objects"]);
|
|
503
741
|
case "sql.watch": try {
|
|
504
742
|
const sqlSupport = requireDevtoolsSqlSupport(sql);
|
|
505
743
|
const analysis = sqlSupport.analyzeSqlStatement(payload.query);
|
|
@@ -517,7 +755,7 @@ function intersects(a, b) {
|
|
|
517
755
|
return false;
|
|
518
756
|
}
|
|
519
757
|
function requireDevtoolsSqlSupport(sql) {
|
|
520
|
-
if (!sql) throw new Error("SQL
|
|
758
|
+
if (!sql) throw new Error("SQL Console is not available for this runtime.");
|
|
521
759
|
return sql;
|
|
522
760
|
}
|
|
523
761
|
//#endregion
|