@dxos/functions 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/lib/browser/index.mjs +767 -884
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +767 -884
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/errors.d.ts +44 -60
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/example/fib.d.ts +1 -1
- package/dist/types/src/example/index.d.ts +3 -3
- package/dist/types/src/example/index.d.ts.map +1 -1
- package/dist/types/src/example/reply.d.ts +1 -1
- package/dist/types/src/example/sleep.d.ts +1 -1
- package/dist/types/src/index.d.ts +2 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operation-compatibility.test.d.ts +2 -0
- package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
- package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
- package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
- package/dist/types/src/protocol/index.d.ts +2 -0
- package/dist/types/src/protocol/index.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.d.ts +7 -0
- package/dist/types/src/protocol/protocol.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.test.d.ts +2 -0
- package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
- package/dist/types/src/sdk.d.ts +114 -0
- package/dist/types/src/sdk.d.ts.map +1 -0
- package/dist/types/src/services/credentials.d.ts +6 -4
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/event-logger.d.ts +33 -27
- package/dist/types/src/services/event-logger.d.ts.map +1 -1
- package/dist/types/src/services/function-invocation-service.d.ts +7 -19
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/index.d.ts +2 -4
- package/dist/types/src/services/index.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +4 -4
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/src/services/tracing.d.ts +41 -12
- package/dist/types/src/services/tracing.d.ts.map +1 -1
- package/dist/types/src/types/Function.d.ts +40 -35
- package/dist/types/src/types/Function.d.ts.map +1 -1
- package/dist/types/src/types/Script.d.ts +9 -16
- package/dist/types/src/types/Script.d.ts.map +1 -1
- package/dist/types/src/types/Trigger.d.ts +58 -76
- package/dist/types/src/types/Trigger.d.ts.map +1 -1
- package/dist/types/src/types/TriggerEvent.d.ts +43 -13
- package/dist/types/src/types/TriggerEvent.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/url.d.ts +13 -0
- package/dist/types/src/types/url.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -58
- package/src/errors.ts +4 -4
- package/src/example/fib.ts +1 -1
- package/src/example/reply.ts +1 -1
- package/src/example/sleep.ts +1 -1
- package/src/index.ts +2 -5
- package/src/operation-compatibility.test.ts +185 -0
- package/src/protocol/functions-ai-http-client.ts +67 -0
- package/src/{executor → protocol}/index.ts +1 -1
- package/src/protocol/protocol.test.ts +59 -0
- package/src/protocol/protocol.ts +262 -0
- package/src/{handler.ts → sdk.ts} +129 -66
- package/src/services/credentials.ts +32 -17
- package/src/services/event-logger.ts +10 -4
- package/src/services/function-invocation-service.ts +23 -70
- package/src/services/index.ts +2 -4
- package/src/services/queues.ts +5 -7
- package/src/services/tracing.ts +68 -44
- package/src/types/Function.ts +39 -8
- package/src/types/Script.ts +10 -9
- package/src/types/Trigger.ts +18 -14
- package/src/types/TriggerEvent.ts +29 -29
- package/src/types/index.ts +1 -0
- package/src/types/url.ts +32 -0
- package/dist/lib/browser/bundler/index.mjs +0 -256
- package/dist/lib/browser/bundler/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/browser/chunk-M6EXIREF.mjs +0 -610
- package/dist/lib/browser/chunk-M6EXIREF.mjs.map +0 -7
- package/dist/lib/browser/edge/index.mjs +0 -83
- package/dist/lib/browser/edge/index.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -131
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/bundler/index.mjs +0 -257
- package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-P3IATZMZ.mjs +0 -612
- package/dist/lib/node-esm/chunk-P3IATZMZ.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -84
- package/dist/lib/node-esm/edge/index.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -132
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/bundler/bundler.d.ts +0 -49
- package/dist/types/src/bundler/bundler.d.ts.map +0 -1
- package/dist/types/src/bundler/bundler.test.d.ts +0 -2
- package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
- package/dist/types/src/bundler/index.d.ts +0 -2
- package/dist/types/src/bundler/index.d.ts.map +0 -1
- package/dist/types/src/e2e/deploy.test.d.ts +0 -2
- package/dist/types/src/e2e/deploy.test.d.ts.map +0 -1
- package/dist/types/src/edge/functions.d.ts +0 -17
- package/dist/types/src/edge/functions.d.ts.map +0 -1
- package/dist/types/src/edge/index.d.ts +0 -2
- package/dist/types/src/edge/index.d.ts.map +0 -1
- package/dist/types/src/executor/executor.d.ts +0 -14
- package/dist/types/src/executor/executor.d.ts.map +0 -1
- package/dist/types/src/executor/index.d.ts +0 -2
- package/dist/types/src/executor/index.d.ts.map +0 -1
- package/dist/types/src/handler.d.ts +0 -102
- package/dist/types/src/handler.d.ts.map +0 -1
- package/dist/types/src/services/database.d.ts +0 -67
- package/dist/types/src/services/database.d.ts.map +0 -1
- package/dist/types/src/services/function-invocation-service.test.d.ts +0 -2
- package/dist/types/src/services/function-invocation-service.test.d.ts.map +0 -1
- package/dist/types/src/services/local-function-execution.d.ts +0 -34
- package/dist/types/src/services/local-function-execution.d.ts.map +0 -1
- package/dist/types/src/services/remote-function-execution-service.d.ts +0 -22
- package/dist/types/src/services/remote-function-execution-service.d.ts.map +0 -1
- package/dist/types/src/services/service-container.d.ts +0 -57
- package/dist/types/src/services/service-container.d.ts.map +0 -1
- package/dist/types/src/services/service-registry.d.ts +0 -31
- package/dist/types/src/services/service-registry.d.ts.map +0 -1
- package/dist/types/src/services/service-registry.test.d.ts +0 -2
- package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -3
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/layer.d.ts +0 -18
- package/dist/types/src/testing/layer.d.ts.map +0 -1
- package/dist/types/src/testing/logger.d.ts +0 -5
- package/dist/types/src/testing/logger.d.ts.map +0 -1
- package/dist/types/src/testing/persist-database.test.d.ts +0 -2
- package/dist/types/src/testing/persist-database.test.d.ts.map +0 -1
- package/dist/types/src/testing/services.d.ts +0 -59
- package/dist/types/src/testing/services.d.ts.map +0 -1
- package/dist/types/src/trace.d.ts +0 -122
- package/dist/types/src/trace.d.ts.map +0 -1
- package/dist/types/src/translations.d.ts +0 -12
- package/dist/types/src/translations.d.ts.map +0 -1
- package/dist/types/src/triggers/index.d.ts +0 -4
- package/dist/types/src/triggers/index.d.ts.map +0 -1
- package/dist/types/src/triggers/input-builder.d.ts +0 -3
- package/dist/types/src/triggers/input-builder.d.ts.map +0 -1
- package/dist/types/src/triggers/invocation-tracer.d.ts +0 -37
- package/dist/types/src/triggers/invocation-tracer.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-dispatcher.d.ts +0 -78
- package/dist/types/src/triggers/trigger-dispatcher.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-dispatcher.test.d.ts +0 -2
- package/dist/types/src/triggers/trigger-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-state-store.d.ts +0 -28
- package/dist/types/src/triggers/trigger-state-store.d.ts.map +0 -1
- package/dist/types/src/url.d.ts +0 -21
- package/dist/types/src/url.d.ts.map +0 -1
- package/src/bundler/bundler.test.ts +0 -58
- package/src/bundler/bundler.ts +0 -295
- package/src/bundler/index.ts +0 -5
- package/src/e2e/deploy.test.ts +0 -69
- package/src/edge/functions.ts +0 -67
- package/src/edge/index.ts +0 -9
- package/src/executor/executor.ts +0 -58
- package/src/services/database.ts +0 -175
- package/src/services/function-invocation-service.test.ts +0 -81
- package/src/services/local-function-execution.ts +0 -153
- package/src/services/remote-function-execution-service.ts +0 -63
- package/src/services/service-container.ts +0 -115
- package/src/services/service-registry.test.ts +0 -45
- package/src/services/service-registry.ts +0 -63
- package/src/testing/index.ts +0 -6
- package/src/testing/layer.ts +0 -114
- package/src/testing/logger.ts +0 -17
- package/src/testing/persist-database.test.ts +0 -87
- package/src/testing/services.ts +0 -115
- package/src/trace.ts +0 -178
- package/src/translations.ts +0 -20
- package/src/triggers/index.ts +0 -7
- package/src/triggers/input-builder.ts +0 -35
- package/src/triggers/invocation-tracer.ts +0 -101
- package/src/triggers/trigger-dispatcher.test.ts +0 -664
- package/src/triggers/trigger-dispatcher.ts +0 -521
- package/src/triggers/trigger-state-store.ts +0 -61
- package/src/url.ts +0 -55
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/errors.ts", "../../../src/url.ts", "../../../src/services/database.ts", "../../../src/services/credentials.ts", "../../../src/services/tracing.ts", "../../../src/services/event-logger.ts", "../../../src/services/queues.ts", "../../../src/services/remote-function-execution-service.ts", "../../../src/services/service-container.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\nexport class ServiceNotAvailableError extends BaseError.extend('SERVICE_NOT_AVAILABLE', 'Service not available') {\n constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { service }, ...options });\n }\n}\n\nexport class FunctionNotFoundError extends BaseError.extend('FUNCTION_NOT_FOUND', 'Function not found') {\n constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { function: functionKey }, ...options });\n }\n}\n\nexport class FunctionError extends BaseError.extend('FUNCTION_ERROR', 'Function invocation error') {}\n\nexport class TriggerStateNotFoundError extends BaseError.extend('TRIGGER_STATE_NOT_FOUND', 'Trigger state not found') {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo/internal';\nimport { type SpaceId } from '@dxos/keys';\n\n// TODO: use URL scheme for source?\nexport const FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getUserFunctionIdInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const setUserFunctionIdInMetadata = (meta: ObjectMeta, functionId: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionId) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });\n }\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getInvocationUrl = (functionId: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const url = new URL(`./${functionId}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\n\nimport {\n type Filter,\n type Live,\n Obj,\n ObjectNotFoundError,\n type Query,\n type Ref,\n type Relation,\n type Type,\n} from '@dxos/echo';\nimport type { EchoSchema } from '@dxos/echo/internal';\nimport type { EchoDatabase, FlushOptions, OneShotQueryResult, QueryResult, SchemaRegistryQuery } from '@dxos/echo-db';\nimport type { SchemaRegistryPreparedQuery } from '@dxos/echo-db';\nimport { promiseWithCauseCapture } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport type { DXN } from '@dxos/keys';\n\nexport class DatabaseService extends Context.Tag('@dxos/functions/DatabaseService')<\n DatabaseService,\n {\n readonly db: EchoDatabase;\n }\n>() {\n static notAvailable = Layer.succeed(DatabaseService, {\n get db(): EchoDatabase {\n throw new Error('Database not available');\n },\n });\n\n static make = (db: EchoDatabase): Context.Tag.Service<DatabaseService> => {\n return {\n get db() {\n return db;\n },\n };\n };\n\n static layer = (db: EchoDatabase): Layer.Layer<DatabaseService> => {\n return Layer.succeed(DatabaseService, DatabaseService.make(db));\n };\n\n /**\n * Resolves an object by its DXN.\n */\n static resolve: {\n // No type check.\n (dxn: DXN): Effect.Effect<Obj.Any | Relation.Any, never, DatabaseService>;\n // Check matches schema.\n <S extends Type.Obj.Any | Type.Relation.Any>(\n dxn: DXN,\n schema: S,\n ): Effect.Effect<Schema.Schema.Type<S>, ObjectNotFoundError, DatabaseService>;\n } = (<S extends Type.Obj.Any | Type.Relation.Any>(\n dxn: DXN,\n schema?: S,\n ): Effect.Effect<Schema.Schema.Type<S>, ObjectNotFoundError, DatabaseService> =>\n Effect.gen(function* () {\n const { db } = yield* DatabaseService;\n const object = yield* promiseWithCauseCapture(() =>\n db.graph\n .createRefResolver({\n context: {\n space: db.spaceId,\n },\n })\n .resolve(dxn),\n );\n\n if (!object) {\n return yield* Effect.fail(new ObjectNotFoundError(dxn));\n }\n invariant(!schema || Obj.instanceOf(schema, object), 'Object type mismatch.');\n return object as any;\n })) as any;\n\n /**\n * Loads an object reference.\n */\n static load: <T>(ref: Ref.Ref<T>) => Effect.Effect<T, ObjectNotFoundError, never> = Effect.fn(function* (ref) {\n const object = yield* promiseWithCauseCapture(() => ref.tryLoad());\n if (!object) {\n return yield* Effect.fail(new ObjectNotFoundError(ref.dxn));\n }\n return object;\n });\n\n /**\n * Loads an object reference option.\n */\n // TODO(burdon): Option?\n static loadOption: <T>(ref: Ref.Ref<T>) => Effect.Effect<Option.Option<T>, never, never> = Effect.fn(function* (ref) {\n const object = yield* DatabaseService.load(ref).pipe(\n Effect.catchTag('OBJECT_NOT_FOUND', () => Effect.succeed(undefined)),\n );\n return Option.fromNullable(object);\n });\n\n // TODO(burdon): Can we create a proxy for the following methods on EchoDatabase? Use @inheritDoc?\n // TODO(burdon): Figure out how to chain query().run();\n\n /**\n * @link EchoDatabase.add\n */\n static add = <T extends Obj.Any | Relation.Any>(obj: T): Effect.Effect<T, never, DatabaseService> =>\n DatabaseService.pipe(Effect.map(({ db }) => db.add(obj)));\n\n /**\n * @link EchoDatabase.remove\n */\n static remove = <T extends Obj.Any | Relation.Any>(obj: T): Effect.Effect<void, never, DatabaseService> =>\n DatabaseService.pipe(Effect.map(({ db }) => db.remove(obj)));\n\n /**\n * @link EchoDatabase.flush\n */\n static flush = (opts?: FlushOptions) =>\n DatabaseService.pipe(Effect.flatMap(({ db }) => promiseWithCauseCapture(() => db.flush(opts))));\n\n /**\n * @link EchoDatabase.getObjectById\n */\n static getObjectById = <T extends Obj.Any | Relation.Any>(\n id: string,\n ): Effect.Effect<Live<T> | undefined, never, DatabaseService> => {\n return DatabaseService.pipe(Effect.map(({ db }) => db.getObjectById(id)));\n };\n\n /**\n * Creates a `QueryResult` object that can be subscribed to.\n */\n static query: {\n <Q extends Query.Any>(query: Q): Effect.Effect<QueryResult<Live<Query.Type<Q>>>, never, DatabaseService>;\n <F extends Filter.Any>(filter: F): Effect.Effect<QueryResult<Live<Filter.Type<F>>>, never, DatabaseService>;\n } = (queryOrFilter: Query.Any | Filter.Any) =>\n DatabaseService.pipe(\n Effect.map(({ db }) => db.query(queryOrFilter as any)),\n Effect.withSpan('DatabaseService.query'),\n );\n\n /**\n * Executes the query once and returns the results.\n */\n static runQuery: {\n <Q extends Query.Any>(query: Q): Effect.Effect<OneShotQueryResult<Live<Query.Type<Q>>>, never, DatabaseService>;\n <F extends Filter.Any>(filter: F): Effect.Effect<OneShotQueryResult<Live<Filter.Type<F>>>, never, DatabaseService>;\n } = (queryOrFilter: Query.Any | Filter.Any) =>\n DatabaseService.query(queryOrFilter as any).pipe(\n Effect.flatMap((queryResult) => promiseWithCauseCapture(() => queryResult.run())),\n );\n\n static schemaQuery = <Q extends SchemaRegistryQuery>(\n query: Q,\n ): Effect.Effect<SchemaRegistryPreparedQuery<EchoSchema>, never, DatabaseService> =>\n DatabaseService.pipe(\n Effect.map(({ db }) => db.schemaRegistry.query(query)),\n Effect.withSpan('DatabaseService.schemaQuery'),\n );\n\n static runSchemaQuery = <Q extends SchemaRegistryQuery>(\n query: Q,\n ): Effect.Effect<EchoSchema[], never, DatabaseService> =>\n DatabaseService.schemaQuery(query).pipe(\n Effect.flatMap((queryResult) => promiseWithCauseCapture(() => queryResult.run())),\n );\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport type * as Config from 'effect/Config';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Redacted from 'effect/Redacted';\n\nimport { Query } from '@dxos/echo';\nimport { DataType } from '@dxos/schema';\n\nimport { DatabaseService } from './database';\n\nexport type CredentialQuery = {\n service?: string;\n};\n\n// TODO(dmaretskyi): Unify with other apis.\n// packages/sdk/schema/src/common/access-token.ts\nexport type ServiceCredential = {\n service: string;\n\n // TODO(dmaretskyi): Build out.\n apiKey?: string;\n};\n\nexport class CredentialsService extends Context.Tag('@dxos/functions/CredentialsService')<\n CredentialsService,\n {\n /**\n * Query all.\n */\n queryCredentials: (query: CredentialQuery) => Promise<ServiceCredential[]>;\n\n /**\n * Get a single credential.\n * @throws {Error} If no credential is found.\n */\n getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;\n }\n>() {\n static getCredential = (query: CredentialQuery): Effect.Effect<ServiceCredential, never, CredentialsService> =>\n Effect.gen(function* () {\n const credentials = yield* CredentialsService;\n return yield* Effect.promise(() => credentials.getCredential(query));\n });\n\n static getApiKey = (query: CredentialQuery): Effect.Effect<Redacted.Redacted<string>, never, CredentialsService> =>\n Effect.gen(function* () {\n const credential = yield* CredentialsService.getCredential(query);\n if (!credential.apiKey) {\n throw new Error(`API key not found for service: ${query.service}`);\n }\n return Redacted.make(credential.apiKey);\n });\n\n static configuredLayer = (credentials: ServiceCredential[]) =>\n Layer.succeed(CredentialsService, new ConfiguredCredentialsService(credentials));\n\n static layerConfig = (credentials: { service: string; apiKey: Config.Config<Redacted.Redacted<string>> }[]) =>\n Layer.effect(\n CredentialsService,\n Effect.gen(function* () {\n const serviceCredentials = yield* Effect.forEach(credentials, ({ service, apiKey }) =>\n Effect.gen(function* () {\n return {\n service,\n apiKey: Redacted.value(yield* apiKey),\n };\n }),\n );\n\n return new ConfiguredCredentialsService(serviceCredentials);\n }),\n );\n\n static layerFromDatabase = () =>\n Layer.effect(\n CredentialsService,\n Effect.gen(function* () {\n const dbService = yield* DatabaseService;\n const queryCredentials = async (query: CredentialQuery): Promise<ServiceCredential[]> => {\n const { objects: accessTokens } = await dbService.db.query(Query.type(DataType.AccessToken)).run();\n return accessTokens\n .filter((accessToken) => accessToken.source === query.service)\n .map((accessToken) => ({\n service: accessToken.source,\n apiKey: accessToken.token,\n }));\n };\n return {\n getCredential: async (query) => {\n const credentials = await queryCredentials(query);\n if (credentials.length === 0) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credentials[0];\n },\n queryCredentials: async (query) => {\n return queryCredentials(query);\n },\n };\n }),\n );\n}\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {\n constructor(private readonly credentials: ServiceCredential[] = []) {}\n\n addCredentials(credentials: ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: CredentialQuery): Promise<ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credential;\n }\n}\n\n/**\n * Maps the request to include the API key from the credential.\n */\nexport const withAuthorization = (query: CredentialQuery, kind?: 'Bearer' | 'Basic') =>\n HttpClient.mapRequestEffect(\n Effect.fnUntraced(function* (request) {\n const key = yield* CredentialsService.getApiKey(query).pipe(Effect.map(Redacted.value));\n const authorization = kind ? `${kind} ${key}` : key;\n return HttpClientRequest.setHeader(request, 'Authorization', authorization);\n }),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { AgentStatus } from '@dxos/ai';\nimport { Obj } from '@dxos/echo';\nimport type { ObjectId } from '@dxos/echo/internal';\nimport type { Queue } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Provides a way for compute primitives (functions, workflows, tools)\n * to emit an execution trace as a series of structured ECHO objects.\n */\nexport class TracingService extends Context.Tag('@dxos/functions/TracingService')<\n TracingService,\n {\n /**\n * Gets the parent message ID.\n */\n getTraceContext: () => TracingService.TraceContext;\n\n /**\n * Write an event to the tracing queue.\n * @param event - The event to write. Must be an a typed object.\n */\n write: (event: Obj.Any) => void;\n }\n>() {\n static noop: Context.Tag.Service<TracingService> = { write: () => {}, getTraceContext: () => ({}) };\n\n static layerNoop = Layer.succeed(TracingService, TracingService.noop);\n\n static console: Context.Tag.Service<TracingService> = {\n write: (event) => {\n console.log(event);\n },\n getTraceContext: () => ({}),\n };\n\n static layerConsole = Layer.succeed(TracingService, TracingService.console);\n\n static layerLogInfo = () =>\n Layer.succeed(TracingService, {\n write: (event) => {\n if (Obj.instanceOf(AgentStatus, event)) {\n log.info('status', { message: event.message });\n }\n },\n getTraceContext: () => ({}),\n });\n\n /**\n * Creates a TracingService layer that emits events to the parent tracing service.\n */\n static layerSubframe = (mapContext: (currentContext: TracingService.TraceContext) => TracingService.TraceContext) =>\n Layer.effect(\n TracingService,\n Effect.gen(function* () {\n const tracing = yield* TracingService;\n const context = mapContext(tracing.getTraceContext());\n return {\n write: (event) => tracing.write(event),\n getTraceContext: () => context,\n };\n }),\n );\n\n static layerQueue = (queue: Queue) =>\n Layer.effect(\n TracingService,\n Effect.gen(function* () {\n // TODO(dmaretskyi): Batching.\n return {\n write: (event) => queue.append([event]),\n getTraceContext: () => ({\n debugInfo: {\n queue: queue.dxn.toString(),\n },\n }),\n };\n }),\n );\n\n /**\n * Emit the current human-readable execution status.\n */\n static emitStatus: (\n data: Omit<Obj.MakeProps<typeof AgentStatus>, 'created'>,\n ) => Effect.Effect<void, never, TracingService> = Effect.fnUntraced(function* (data) {\n const tracing = yield* TracingService;\n tracing.write(\n Obj.make(AgentStatus, {\n parentMessage: tracing.getTraceContext().parentMessage,\n toolCallId: tracing.getTraceContext().toolCallId,\n created: new Date().toISOString(),\n ...data,\n }),\n );\n });\n\n static emitConverationMessage: (\n data: Obj.MakeProps<typeof DataType.Message>,\n ) => Effect.Effect<void, never, TracingService> = Effect.fnUntraced(function* (data) {\n const tracing = yield* TracingService;\n tracing.write(\n Obj.make(DataType.Message, {\n parentMessage: tracing.getTraceContext().parentMessage,\n ...data,\n properties: {\n [MESSAGE_PROPERTY_TOOL_CALL_ID]: tracing.getTraceContext().toolCallId,\n ...data.properties,\n },\n }),\n );\n });\n}\n\nexport namespace TracingService {\n export interface TraceContext {\n /**\n * If this thread sprung from a tool call, this is the ID of the message containing the tool call.\n */\n parentMessage?: ObjectId;\n\n /**\n * If the current thread is a byproduct of a tool call, this is the ID of the tool call.\n */\n toolCallId?: string;\n\n debugInfo?: unknown;\n }\n}\n\n/**\n * Goes into {@link DataType.Message['properties']}\n */\nexport const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { LogLevel, log } from '@dxos/log';\n\nimport { TracingService } from './tracing';\n\nexport const ComputeEventPayload = Schema.Union(\n Schema.Struct({\n type: Schema.Literal('begin-compute'),\n nodeId: Schema.String,\n inputs: Schema.Record({ key: Schema.String, value: Schema.Any }),\n }),\n Schema.Struct({\n type: Schema.Literal('end-compute'),\n nodeId: Schema.String,\n outputs: Schema.Record({ key: Schema.String, value: Schema.Any }),\n }),\n Schema.Struct({\n type: Schema.Literal('compute-input'),\n nodeId: Schema.String,\n property: Schema.String,\n value: Schema.Any,\n }),\n Schema.Struct({\n type: Schema.Literal('compute-output'),\n nodeId: Schema.String,\n property: Schema.String,\n value: Schema.Any,\n }),\n Schema.Struct({\n type: Schema.Literal('custom'),\n nodeId: Schema.String,\n event: Schema.Any,\n }),\n);\nexport type ComputeEventPayload = Schema.Schema.Type<typeof ComputeEventPayload>;\n\nexport const ComputeEvent = Schema.Struct({\n payload: ComputeEventPayload,\n}).pipe(Type.Obj({ typename: 'dxos.org/type/ComputeEvent', version: '0.1.0' }));\n\n/**\n * Logs event for the compute workflows.\n */\nexport class ComputeEventLogger extends Context.Tag('@dxos/functions/ComputeEventLogger')<\n ComputeEventLogger,\n { readonly log: (event: ComputeEventPayload) => void; readonly nodeId: string | undefined }\n>() {\n static noop: Context.Tag.Service<ComputeEventLogger> = {\n log: () => {},\n nodeId: undefined,\n };\n\n /**\n * Implements ComputeEventLogger using TracingService.\n */\n static layerFromTracing = Layer.effect(\n ComputeEventLogger,\n Effect.gen(function* () {\n const tracing = yield* TracingService;\n return {\n log: (event: ComputeEventPayload) => {\n tracing.write(Obj.make(ComputeEvent, { payload: event }));\n },\n nodeId: undefined,\n };\n }),\n );\n}\n\nexport const logCustomEvent = (data: any) =>\n Effect.gen(function* () {\n const logger = yield* ComputeEventLogger;\n if (!logger.nodeId) {\n throw new Error('logCustomEvent must be called within a node compute function');\n }\n logger.log({\n type: 'custom',\n nodeId: logger.nodeId,\n event: data,\n });\n });\n\nexport const createDefectLogger = <A, E, R>(): ((self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) =>\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n log.error('unhandled effect error', { error });\n throw error;\n }),\n );\n\nexport const createEventLogger = (\n level: LogLevel,\n message: string = 'event',\n): Context.Tag.Service<ComputeEventLogger> => {\n const logFunction = (\n {\n [LogLevel.WARN]: log.warn,\n [LogLevel.VERBOSE]: log.verbose,\n [LogLevel.DEBUG]: log.debug,\n [LogLevel.INFO]: log.info,\n [LogLevel.ERROR]: log.error,\n } as any\n )[level];\n invariant(logFunction);\n return {\n log: (event: ComputeEventPayload) => {\n logFunction(message, event);\n },\n nodeId: undefined,\n };\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport type { Obj, Relation } from '@dxos/echo';\nimport type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';\nimport type { DXN, QueueSubspaceTag } from '@dxos/keys';\n\n/**\n * Gives access to all queues.\n */\nexport class QueueService extends Context.Tag('@dxos/functions/QueueService')<\n QueueService,\n {\n /**\n * API to access the queues.\n */\n readonly queues: QueueAPI;\n\n /**\n * The queue that is used to store the context of the current research.\n * @deprecated Use `ContextQueueService` instead.\n */\n readonly queue: Queue | undefined;\n }\n>() {\n static notAvailable = Layer.succeed(QueueService, {\n queues: {\n get(_dxn) {\n throw new Error('Queues not available');\n },\n create() {\n throw new Error('Queues not available');\n },\n },\n queue: undefined,\n });\n\n static make = (queues: QueueFactory, queue?: Queue): Context.Tag.Service<QueueService> => {\n return {\n queues,\n queue,\n };\n };\n\n static layer = (queues: QueueFactory, queue?: Queue): Layer.Layer<QueueService> =>\n Layer.succeed(QueueService, QueueService.make(queues, queue));\n\n /**\n * Gets a queue by its DXN.\n */\n static getQueue = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(\n dxn: DXN,\n ): Effect.Effect<Queue<T>, never, QueueService> => QueueService.pipe(Effect.map(({ queues }) => queues.get<T>(dxn)));\n\n /**\n * Creates a new queue.\n */\n static createQueue = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(options?: {\n subspaceTag?: QueueSubspaceTag;\n }): Effect.Effect<Queue<T>, never, QueueService> =>\n QueueService.pipe(Effect.map(({ queues }) => queues.create<T>(options)));\n\n static append = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(\n queue: Queue<T>,\n objects: T[],\n ): Effect.Effect<void> => Effect.promise(() => queue.append(objects));\n}\n\n/**\n * Gives access to a specific queue passed as a context.\n */\nexport class ContextQueueService extends Context.Tag('@dxos/functions/ContextQueueService')<\n ContextQueueService,\n {\n readonly queue: Queue;\n }\n>() {\n static layer = (queue: Queue) => Layer.succeed(ContextQueueService, { queue });\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport type { SpaceId } from '@dxos/keys';\n\nimport { FunctionError } from '../errors';\nimport { getInvocationUrl } from '../url';\n\n/**\n * Allows calling into other functions.\n */\nexport class RemoteFunctionExecutionService extends Context.Tag('@dxos/functions/RemoteFunctionExecutionService')<\n RemoteFunctionExecutionService,\n {\n callFunction<I, O>(deployedFunctionId: string, input: I): Effect.Effect<O>;\n }\n>() {\n /**\n * @param baseUrl URL of the EDGE server.\n * @param spaceId - The space ID to invoke the function in. If not provided, the function will be without space context.\n * @returns\n */\n static fromClient(baseUrl: string, spaceId?: SpaceId): Layer.Layer<RemoteFunctionExecutionService> {\n return Layer.succeed(RemoteFunctionExecutionService, {\n callFunction: <I, O>(deployedFunctionId: string, input: I): Effect.Effect<O> =>\n Effect.gen(function* () {\n const url = getInvocationUrl(deployedFunctionId, baseUrl, { spaceId });\n const result = yield* Effect.promise(() =>\n fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(input),\n }),\n );\n if (result.status >= 300 || result.status < 200) {\n const text = yield* Effect.promise(() => result.text());\n return yield* Effect.die(\n new FunctionError({\n message: 'Failed to invoke function',\n cause: new Error(`HTTP error: ${text}`),\n }),\n );\n }\n const data = (yield* Effect.promise(() => result.json())) as O;\n return data;\n }),\n });\n }\n\n static mock = (): Context.Tag.Service<RemoteFunctionExecutionService> => {\n return {\n callFunction: <I, O>(deployedFunctionId: string, input: I): Effect.Effect<O> =>\n Effect.succeed(input as unknown as O),\n };\n };\n\n static layerMock = Layer.succeed(RemoteFunctionExecutionService, RemoteFunctionExecutionService.mock());\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Layer from 'effect/Layer';\n\nimport { AiService } from '@dxos/ai';\nimport { entries } from '@dxos/util';\n\nimport { ConfiguredCredentialsService, CredentialsService } from './credentials';\nimport { DatabaseService } from './database';\nimport { ComputeEventLogger } from './event-logger';\nimport { QueueService } from './queues';\nimport { RemoteFunctionExecutionService } from './remote-function-execution-service';\nimport { TracingService } from './tracing';\n\n// TODO(dmaretskyi): Refactor this module to only rely on tags and not the human-assigned names.\n\n/**\n * List of all services.\n */\nconst SERVICES = {\n ai: AiService.AiService,\n credentials: CredentialsService,\n database: DatabaseService,\n eventLogger: ComputeEventLogger,\n functionCallService: RemoteFunctionExecutionService,\n queues: QueueService,\n tracing: TracingService,\n} as const satisfies Record<string, Context.TagClass<any, string, any>>;\n\n/**\n * Mapping of service names to their tags.\n */\nexport type ServiceTagRecord = {\n [K in keyof typeof SERVICES]: (typeof SERVICES)[K] extends { new (_: never): infer T } ? T : never;\n};\n\n/**\n * Mapping of service names to their runtime types.\n */\nexport type ServiceRecord = {\n [K in keyof ServiceTagRecord]: Context.Tag.Service<ServiceTagRecord[K]>;\n};\n\n/**\n * Union of all services tags.\n */\nexport type Services = ServiceTagRecord[keyof ServiceTagRecord];\n\nconst SERVICE_MAPPING: Record<string, keyof ServiceRecord> = Object.fromEntries(\n entries(SERVICES).map(([name, tag]) => [tag.key, name]),\n);\n\nexport const SERVICE_TAGS: Context.Tag<any, any>[] = Object.values(SERVICES);\n\nconst DEFAULT_SERVICES: Partial<ServiceRecord> = {\n tracing: TracingService.noop,\n};\n\n/**\n * @deprecated\n */\nexport class ServiceContainer {\n private _services: Partial<ServiceRecord> = { ...DEFAULT_SERVICES };\n\n /**\n * Set services.\n * @param services - Services to set.\n * @returns The container instance.\n */\n setServices(services: Partial<ServiceRecord>): this {\n this._services = { ...this._services, ...services };\n return this;\n }\n\n getService<Id, T>(tag: Context.Tag<Id, T>): T {\n const serviceKey = SERVICE_MAPPING[tag.key];\n const service = serviceKey != null ? this._services[serviceKey] : undefined;\n if (!service) {\n throw new Error(`Service not available: ${tag.key}`);\n }\n\n return service as T;\n }\n\n clone(): ServiceContainer {\n return new ServiceContainer().setServices({ ...this._services });\n }\n\n // TODO(dmaretskyi): `getService` is designed to error at runtime if the service is not available, but Layer forces us to provide all services and makes stubs for the ones that are not available.\n createLayer(): Layer.Layer<Services> {\n const ai =\n this._services.ai != null ? Layer.succeed(AiService.AiService, this._services.ai) : AiService.notAvailable;\n const credentials = Layer.succeed(\n CredentialsService,\n this._services.credentials ?? new ConfiguredCredentialsService(),\n );\n const database =\n this._services.database != null\n ? Layer.succeed(DatabaseService, this._services.database)\n : DatabaseService.notAvailable;\n const queues =\n this._services.queues != null ? Layer.succeed(QueueService, this._services.queues) : QueueService.notAvailable;\n const tracing = Layer.succeed(TracingService, this._services.tracing ?? TracingService.noop);\n const eventLogger = Layer.succeed(ComputeEventLogger, this._services.eventLogger ?? ComputeEventLogger.noop);\n const functionCallService = Layer.succeed(\n RemoteFunctionExecutionService,\n this._services.functionCallService ?? RemoteFunctionExecutionService.mock(),\n );\n\n return Layer.mergeAll(ai, credentials, database, queues, tracing, eventLogger, functionCallService);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,iBAAwC;AAE1C,IAAMC,2BAAN,cAAuCC,UAAUC,OAAO,yBAAyB,uBAAA,EAAA;EACtF,YAAYC,SAAiBC,SAA6C;AACxE,UAAM;MAAEC,SAAS;QAAEF;MAAQ;MAAG,GAAGC;IAAQ,CAAA;EAC3C;AACF;AAEO,IAAME,wBAAN,cAAoCL,UAAUC,OAAO,sBAAsB,oBAAA,EAAA;EAChF,YAAYK,aAAqBH,SAA6C;AAC5E,UAAM;MAAEC,SAAS;QAAEG,UAAUD;MAAY;MAAG,GAAGH;IAAQ,CAAA;EACzD;AACF;AAEO,IAAMK,gBAAN,cAA4BR,UAAUC,OAAO,kBAAkB,2BAAA,EAAA;AAA8B;AAE7F,IAAMQ,4BAAN,cAAwCT,UAAUC,OAAO,2BAA2B,yBAAA,EAAA;AAA4B;;;ACZhH,IAAMS,qBAAqB;AAE3B,IAAMC,4BAA4B;AAEzC,IAAMC,WAAW,CAACC,aAAAA;AAChB,SAAOA,aAAa,YAAYA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D,WAAO;EACT;EAEAC,WAAkBV,KAA4B;AAC5C,UAAMW,aAAajB,gBAAgBM,IAAIC,GAAG;AAC1C,UAAMW,UAAUD,cAAc,OAAO,KAAKJ,UAAUI,UAAAA,IAAcE;AAClE,QAAI,CAACD,SAAS;AACZ,YAAM,IAAIE,MAAM,0BAA0Bd,IAAIC,GAAG,EAAE;IACrD;AAEA,WAAOW;EACT;EAEAG,QAA0B;AACxB,WAAO,IAAIT,kBAAAA,EAAmBE,YAAY;MAAE,GAAG,KAAKD;IAAU,CAAA;EAChE;;EAGAS,cAAqC;AACnC,UAAMpC,KACJ,KAAK2B,UAAU3B,MAAM,OAAaqC,eAAQpC,UAAUA,WAAW,KAAK0B,UAAU3B,EAAE,IAAIC,UAAUqC;AAChG,UAAMpC,cAAoBmC,eACxBlC,oBACA,KAAKwB,UAAUzB,eAAe,IAAIqC,6BAAAA,CAAAA;AAEpC,UAAMnC,WACJ,KAAKuB,UAAUvB,YAAY,OACjBiC,eAAQhC,iBAAiB,KAAKsB,UAAUvB,QAAQ,IACtDC,gBAAgBiC;AACtB,UAAM5B,SACJ,KAAKiB,UAAUjB,UAAU,OAAa2B,eAAQ1B,cAAc,KAAKgB,UAAUjB,MAAM,IAAIC,aAAa2B;AACpG,UAAM1B,UAAgByB,eAAQxB,gBAAgB,KAAKc,UAAUf,WAAWC,eAAeY,IAAI;AAC3F,UAAMnB,cAAoB+B,eAAQ9B,oBAAoB,KAAKoB,UAAUrB,eAAeC,mBAAmBkB,IAAI;AAC3G,UAAMjB,sBAA4B6B,eAChC5B,gCACA,KAAKkB,UAAUnB,uBAAuBC,+BAA+B+B,KAAI,CAAA;AAG3E,WAAaC,gBAASzC,IAAIE,aAAaE,UAAUM,QAAQE,SAASN,aAAaE,mBAAAA;EACjF;AACF;",
|
|
6
|
-
"names": ["BaseError", "ServiceNotAvailableError", "BaseError", "extend", "service", "options", "context", "FunctionNotFoundError", "functionKey", "function", "FunctionError", "TriggerStateNotFoundError", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionIdInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionIdInMetadata", "functionId", "Error", "push", "getInvocationUrl", "edgeUrl", "options", "baseUrl", "URL", "url", "toString", "spaceId", "searchParams", "set", "subjectId", "Context", "Effect", "Layer", "Option", "Obj", "ObjectNotFoundError", "promiseWithCauseCapture", "invariant", "DatabaseService", "Tag", "notAvailable", "succeed", "db", "Error", "make", "layer", "resolve", "dxn", "schema", "gen", "object", "graph", "createRefResolver", "context", "space", "spaceId", "fail", "instanceOf", "load", "fn", "ref", "tryLoad", "loadOption", "pipe", "catchTag", "undefined", "fromNullable", "add", "obj", "map", "remove", "flush", "opts", "flatMap", "getObjectById", "id", "query", "queryOrFilter", "withSpan", "runQuery", "queryResult", "run", "schemaQuery", "schemaRegistry", "runSchemaQuery", "HttpClient", "HttpClientRequest", "Context", "Effect", "Layer", "Redacted", "Query", "DataType", "CredentialsService", "Tag", "getCredential", "query", "gen", "credentials", "promise", "getApiKey", "credential", "apiKey", "Error", "service", "make", "configuredLayer", "succeed", "ConfiguredCredentialsService", "layerConfig", "effect", "serviceCredentials", "forEach", "value", "layerFromDatabase", "dbService", "DatabaseService", "queryCredentials", "objects", "accessTokens", "db", "Query", "type", "DataType", "AccessToken", "run", "filter", "accessToken", "source", "map", "token", "length", "addCredentials", "push", "find", "withAuthorization", "kind", "mapRequestEffect", "fnUntraced", "request", "key", "pipe", "authorization", "setHeader", "Context", "Effect", "Layer", "AgentStatus", "Obj", "log", "DataType", "TracingService", "Tag", "noop", "write", "getTraceContext", "layerNoop", "succeed", "console", "event", "layerConsole", "layerLogInfo", "instanceOf", "info", "message", "layerSubframe", "mapContext", "effect", "gen", "tracing", "context", "layerQueue", "queue", "append", "debugInfo", "dxn", "toString", "emitStatus", "fnUntraced", "data", "make", "parentMessage", "toolCallId", "created", "Date", "toISOString", "emitConverationMessage", "Message", "properties", "MESSAGE_PROPERTY_TOOL_CALL_ID", "Context", "Effect", "Layer", "Schema", "Obj", "Type", "invariant", "LogLevel", "log", "ComputeEventPayload", "Union", "Struct", "type", "Literal", "nodeId", "String", "inputs", "Record", "key", "value", "Any", "outputs", "property", "event", "ComputeEvent", "payload", "pipe", "Type", "Obj", "typename", "version", "ComputeEventLogger", "Tag", "noop", "log", "undefined", "layerFromTracing", "effect", "gen", "tracing", "TracingService", "write", "make", "logCustomEvent", "data", "logger", "Error", "createDefectLogger", "catchAll", "error", "createEventLogger", "level", "message", "logFunction", "LogLevel", "WARN", "warn", "VERBOSE", "verbose", "DEBUG", "debug", "INFO", "info", "ERROR", "invariant", "Context", "Effect", "Layer", "QueueService", "Tag", "notAvailable", "succeed", "queues", "get", "_dxn", "Error", "create", "queue", "undefined", "make", "layer", "getQueue", "dxn", "pipe", "map", "createQueue", "options", "append", "objects", "promise", "ContextQueueService", "Context", "Effect", "Layer", "RemoteFunctionExecutionService", "Tag", "fromClient", "baseUrl", "spaceId", "succeed", "callFunction", "deployedFunctionId", "input", "gen", "url", "getInvocationUrl", "result", "promise", "fetch", "method", "headers", "body", "JSON", "stringify", "status", "text", "die", "FunctionError", "message", "cause", "Error", "data", "json", "mock", "layerMock", "Layer", "AiService", "entries", "SERVICES", "ai", "AiService", "credentials", "CredentialsService", "database", "DatabaseService", "eventLogger", "ComputeEventLogger", "functionCallService", "RemoteFunctionExecutionService", "queues", "QueueService", "tracing", "TracingService", "SERVICE_MAPPING", "Object", "fromEntries", "entries", "map", "name", "tag", "key", "SERVICE_TAGS", "values", "DEFAULT_SERVICES", "noop", "ServiceContainer", "_services", "setServices", "services", "getService", "serviceKey", "service", "undefined", "Error", "clone", "createLayer", "succeed", "notAvailable", "ConfiguredCredentialsService", "mock", "mergeAll"]
|
|
7
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import "../chunk-HSLMI22Q.mjs";
|
|
3
|
-
|
|
4
|
-
// src/edge/functions.ts
|
|
5
|
-
import { createEdgeIdentity } from "@dxos/client/edge";
|
|
6
|
-
import { EdgeHttpClient } from "@dxos/edge-client";
|
|
7
|
-
import { invariant } from "@dxos/invariant";
|
|
8
|
-
import { log } from "@dxos/log";
|
|
9
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions/src/edge/functions.ts";
|
|
10
|
-
var uploadWorkerFunction = async ({ client, version, name, functionId, ownerPublicKey, entryPoint, assets }) => {
|
|
11
|
-
log("uploading function", {
|
|
12
|
-
functionId,
|
|
13
|
-
name,
|
|
14
|
-
version,
|
|
15
|
-
ownerPublicKey
|
|
16
|
-
}, {
|
|
17
|
-
F: __dxlog_file,
|
|
18
|
-
L: 34,
|
|
19
|
-
S: void 0,
|
|
20
|
-
C: (f, a) => f(...a)
|
|
21
|
-
});
|
|
22
|
-
const edgeUrl = client.config.values.runtime?.services?.edge?.url;
|
|
23
|
-
invariant(edgeUrl, "Edge is not configured.", {
|
|
24
|
-
F: __dxlog_file,
|
|
25
|
-
L: 36,
|
|
26
|
-
S: void 0,
|
|
27
|
-
A: [
|
|
28
|
-
"edgeUrl",
|
|
29
|
-
"'Edge is not configured.'"
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
const edgeClient = new EdgeHttpClient(edgeUrl);
|
|
33
|
-
const edgeIdentity = createEdgeIdentity(client);
|
|
34
|
-
edgeClient.setIdentity(edgeIdentity);
|
|
35
|
-
const response = await edgeClient.uploadFunction({
|
|
36
|
-
functionId
|
|
37
|
-
}, {
|
|
38
|
-
name,
|
|
39
|
-
version,
|
|
40
|
-
ownerPublicKey: ownerPublicKey.toHex(),
|
|
41
|
-
entryPoint,
|
|
42
|
-
assets
|
|
43
|
-
});
|
|
44
|
-
log("uploaded", {
|
|
45
|
-
identityKey: edgeIdentity.identityKey,
|
|
46
|
-
functionId,
|
|
47
|
-
name,
|
|
48
|
-
version,
|
|
49
|
-
response
|
|
50
|
-
}, {
|
|
51
|
-
F: __dxlog_file,
|
|
52
|
-
L: 46,
|
|
53
|
-
S: void 0,
|
|
54
|
-
C: (f, a) => f(...a)
|
|
55
|
-
});
|
|
56
|
-
return response;
|
|
57
|
-
};
|
|
58
|
-
var incrementSemverPatch = (version) => {
|
|
59
|
-
const [major, minor, patch] = version.split(".");
|
|
60
|
-
const patchNum = Number(patch);
|
|
61
|
-
invariant(!Number.isNaN(patchNum), `Unexpected function version format: ${version}`, {
|
|
62
|
-
F: __dxlog_file,
|
|
63
|
-
L: 60,
|
|
64
|
-
S: void 0,
|
|
65
|
-
A: [
|
|
66
|
-
"!Number.isNaN(patchNum)",
|
|
67
|
-
"`Unexpected function version format: ${version}`"
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
return [
|
|
71
|
-
major,
|
|
72
|
-
minor,
|
|
73
|
-
String(patchNum + 1)
|
|
74
|
-
].join(".");
|
|
75
|
-
};
|
|
76
|
-
var publicKeyToDid = (key) => {
|
|
77
|
-
return `did:key:${key.toHex()}`;
|
|
78
|
-
};
|
|
79
|
-
export {
|
|
80
|
-
incrementSemverPatch,
|
|
81
|
-
publicKeyToDid,
|
|
82
|
-
uploadWorkerFunction
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/edge/functions.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\n\nimport { type Client } from '@dxos/client';\nimport { createEdgeIdentity } from '@dxos/client/edge';\nimport { EdgeHttpClient } from '@dxos/edge-client';\nimport { invariant } from '@dxos/invariant';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type UploadFunctionResponseBody } from '@dxos/protocols';\n\nexport type UploadWorkerArgs = {\n client: Client;\n version: string;\n name?: string;\n functionId?: string;\n ownerPublicKey: PublicKey;\n entryPoint: string;\n assets: Record<string, Uint8Array>;\n};\n\nexport const uploadWorkerFunction = async ({\n client,\n version,\n name,\n functionId,\n ownerPublicKey,\n entryPoint,\n assets,\n}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {\n log('uploading function', { functionId, name, version, ownerPublicKey });\n const edgeUrl = client.config.values.runtime?.services?.edge?.url;\n invariant(edgeUrl, 'Edge is not configured.');\n const edgeClient = new EdgeHttpClient(edgeUrl);\n const edgeIdentity = createEdgeIdentity(client);\n edgeClient.setIdentity(edgeIdentity);\n const response = await edgeClient.uploadFunction(\n { functionId },\n { name, version, ownerPublicKey: ownerPublicKey.toHex(), entryPoint, assets },\n );\n\n // TODO(burdon): Edge service log.\n log('uploaded', {\n identityKey: edgeIdentity.identityKey,\n functionId,\n name,\n version,\n response,\n });\n\n return response;\n};\n\nexport const incrementSemverPatch = (version: string): string => {\n const [major, minor, patch] = version.split('.');\n const patchNum = Number(patch);\n invariant(!Number.isNaN(patchNum), `Unexpected function version format: ${version}`);\n return [major, minor, String(patchNum + 1)].join('.');\n};\n\n// TODO(burdon): Factor out.\nexport const publicKeyToDid = (key: PublicKey): DID => {\n return `did:key:${key.toHex()}`;\n};\n"],
|
|
5
|
-
"mappings": ";;;;AAOA,SAASA,0BAA0B;AACnC,SAASC,sBAAsB;AAC/B,SAASC,iBAAiB;AAE1B,SAASC,WAAW;;AAab,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,SACAC,MACAC,YACAC,gBACAC,YACAC,OAAM,MACW;AACjBR,MAAI,sBAAsB;IAAEK;IAAYD;IAAMD;IAASG;EAAe,GAAA;;;;;;AACtE,QAAMG,UAAUP,OAAOQ,OAAOC,OAAOC,SAASC,UAAUC,MAAMC;AAC9DhB,YAAUU,SAAS,2BAAA;;;;;;;;;AACnB,QAAMO,aAAa,IAAIlB,eAAeW,OAAAA;AACtC,QAAMQ,eAAepB,mBAAmBK,MAAAA;AACxCc,aAAWE,YAAYD,YAAAA;AACvB,QAAME,WAAW,MAAMH,WAAWI,eAChC;IAAEf;EAAW,GACb;IAAED;IAAMD;IAASG,gBAAgBA,eAAee,MAAK;IAAId;IAAYC;EAAO,CAAA;AAI9ER,MAAI,YAAY;IACdsB,aAAaL,aAAaK;IAC1BjB;IACAD;IACAD;IACAgB;EACF,GAAA;;;;;;AAEA,SAAOA;AACT;AAEO,IAAMI,uBAAuB,CAACpB,YAAAA;AACnC,QAAM,CAACqB,OAAOC,OAAOC,KAAAA,IAASvB,QAAQwB,MAAM,GAAA;AAC5C,QAAMC,WAAWC,OAAOH,KAAAA;AACxB3B,YAAU,CAAC8B,OAAOC,MAAMF,QAAAA,GAAW,uCAAuCzB,OAAAA,IAAS;;;;;;;;;AACnF,SAAO;IAACqB;IAAOC;IAAOM,OAAOH,WAAW,CAAA;IAAII,KAAK,GAAA;AACnD;AAGO,IAAMC,iBAAiB,CAACC,QAAAA;AAC7B,SAAO,WAAWA,IAAIb,MAAK,CAAA;AAC7B;",
|
|
6
|
-
"names": ["createEdgeIdentity", "EdgeHttpClient", "invariant", "log", "uploadWorkerFunction", "client", "version", "name", "functionId", "ownerPublicKey", "entryPoint", "assets", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "setIdentity", "response", "uploadFunction", "toHex", "identityKey", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid", "key"]
|
|
7
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ConfiguredCredentialsService,
|
|
4
|
-
DatabaseService,
|
|
5
|
-
QueueService,
|
|
6
|
-
ServiceContainer,
|
|
7
|
-
createEventLogger
|
|
8
|
-
} from "../chunk-P3IATZMZ.mjs";
|
|
9
|
-
import "../chunk-HSLMI22Q.mjs";
|
|
10
|
-
|
|
11
|
-
// src/testing/services.ts
|
|
12
|
-
import { assertArgument } from "@dxos/invariant";
|
|
13
|
-
|
|
14
|
-
// src/testing/logger.ts
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import { LogLevel } from "@dxos/log";
|
|
17
|
-
var noopLogger = {
|
|
18
|
-
log: () => Effect.succeed(void 0),
|
|
19
|
-
nodeId: void 0
|
|
20
|
-
};
|
|
21
|
-
var consoleLogger = createEventLogger(LogLevel.INFO);
|
|
22
|
-
|
|
23
|
-
// src/testing/services.ts
|
|
24
|
-
var createTestServices = ({ ai, credentials, db, logging, queues, space, tracing } = {}) => {
|
|
25
|
-
assertArgument(!(!!space && (!!db || !!queues)), "space", "space can be provided only if db and queues are not");
|
|
26
|
-
return new ServiceContainer().setServices({
|
|
27
|
-
// ai: createAiService(ai),
|
|
28
|
-
credentials: createCredentialsService(credentials),
|
|
29
|
-
database: space || db ? DatabaseService.make(space?.db || db) : void 0,
|
|
30
|
-
eventLogger: logging?.logger ?? logging?.enabled ? consoleLogger : noopLogger,
|
|
31
|
-
queues: space || queues ? QueueService.make(space?.queues || queues, void 0) : void 0,
|
|
32
|
-
tracing: tracing?.service
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var createCredentialsService = (credentials) => {
|
|
36
|
-
if (credentials?.services) {
|
|
37
|
-
return new ConfiguredCredentialsService(credentials.services);
|
|
38
|
-
}
|
|
39
|
-
if (credentials?.service) {
|
|
40
|
-
return credentials.service;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// src/testing/layer.ts
|
|
45
|
-
import * as Context from "effect/Context";
|
|
46
|
-
import * as Effect2 from "effect/Effect";
|
|
47
|
-
import * as Layer from "effect/Layer";
|
|
48
|
-
import { EchoTestBuilder } from "@dxos/echo-db/testing";
|
|
49
|
-
import { acquireReleaseResource } from "@dxos/effect";
|
|
50
|
-
import { PublicKey } from "@dxos/keys";
|
|
51
|
-
import { createTestLevel } from "@dxos/kv-store/testing";
|
|
52
|
-
import { log } from "@dxos/log";
|
|
53
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions/src/testing/layer.ts";
|
|
54
|
-
var testBuilder = acquireReleaseResource(() => new EchoTestBuilder());
|
|
55
|
-
var testStoragePath = ({ name = PublicKey.random().toHex() }) => {
|
|
56
|
-
return `/tmp/dxos-${name}`;
|
|
57
|
-
};
|
|
58
|
-
var TestDatabaseLayer = ({ indexing, types, spaceKey, storagePath, onInit } = {}) => Layer.scopedContext(Effect2.gen(function* () {
|
|
59
|
-
const builder = yield* testBuilder;
|
|
60
|
-
let kv;
|
|
61
|
-
if (storagePath) {
|
|
62
|
-
kv = createTestLevel(storagePath);
|
|
63
|
-
yield* Effect2.promise(() => kv.open());
|
|
64
|
-
}
|
|
65
|
-
const peer = yield* Effect2.promise(() => builder.createPeer({
|
|
66
|
-
indexing,
|
|
67
|
-
types,
|
|
68
|
-
kv
|
|
69
|
-
}));
|
|
70
|
-
let db;
|
|
71
|
-
let queues;
|
|
72
|
-
if (storagePath) {
|
|
73
|
-
const testMetadata = yield* Effect2.promise(async () => {
|
|
74
|
-
try {
|
|
75
|
-
return await kv.get("test-metadata", {
|
|
76
|
-
valueEncoding: "json"
|
|
77
|
-
});
|
|
78
|
-
} catch (e) {
|
|
79
|
-
if (e.code === "LEVEL_NOT_FOUND") {
|
|
80
|
-
return void 0;
|
|
81
|
-
}
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
log("starting persistant test db", {
|
|
86
|
-
storagePath,
|
|
87
|
-
testMetadata
|
|
88
|
-
}, {
|
|
89
|
-
F: __dxlog_file,
|
|
90
|
-
L: 63,
|
|
91
|
-
S: this,
|
|
92
|
-
C: (f, a) => f(...a)
|
|
93
|
-
});
|
|
94
|
-
if (!testMetadata) {
|
|
95
|
-
const key = spaceKey ?? PublicKey.random();
|
|
96
|
-
db = yield* Effect2.promise(() => peer.createDatabase(key));
|
|
97
|
-
queues = peer.client.constructQueueFactory(db.spaceId);
|
|
98
|
-
yield* Effect2.promise(() => kv.put("test-metadata", {
|
|
99
|
-
key: key.toHex(),
|
|
100
|
-
rootUrl: db.rootUrl
|
|
101
|
-
}, {
|
|
102
|
-
valueEncoding: "json"
|
|
103
|
-
}));
|
|
104
|
-
if (onInit) {
|
|
105
|
-
yield* onInit().pipe(Effect2.provideService(DatabaseService, DatabaseService.make(db)), Effect2.provideService(QueueService, QueueService.make(queues, void 0)));
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
const key = PublicKey.from(testMetadata.key);
|
|
109
|
-
const rootUrl = testMetadata.rootUrl;
|
|
110
|
-
db = yield* Effect2.promise(() => peer.openDatabase(key, rootUrl));
|
|
111
|
-
queues = peer.client.constructQueueFactory(db.spaceId);
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
db = yield* Effect2.promise(() => peer.createDatabase(spaceKey));
|
|
115
|
-
queues = peer.client.constructQueueFactory(db.spaceId);
|
|
116
|
-
if (onInit) {
|
|
117
|
-
yield* onInit().pipe(Effect2.provideService(DatabaseService, DatabaseService.make(db)), Effect2.provideService(QueueService, QueueService.make(queues, void 0)));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
yield* Effect2.addFinalizer(() => Effect2.promise(async () => {
|
|
121
|
-
if (kv) {
|
|
122
|
-
await kv.close();
|
|
123
|
-
}
|
|
124
|
-
}));
|
|
125
|
-
return Context.mergeAll(Context.make(DatabaseService, DatabaseService.make(db)), Context.make(QueueService, QueueService.make(queues, void 0)));
|
|
126
|
-
}));
|
|
127
|
-
export {
|
|
128
|
-
TestDatabaseLayer,
|
|
129
|
-
createTestServices,
|
|
130
|
-
testStoragePath
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/services.ts", "../../../../src/testing/logger.ts", "../../../../src/testing/layer.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\n\nimport type { Space } from '@dxos/client/echo';\nimport type { EchoDatabase, QueueFactory } from '@dxos/echo-db';\nimport { assertArgument } from '@dxos/invariant';\n\nimport {\n type ComputeEventLogger,\n ConfiguredCredentialsService,\n type CredentialsService,\n DatabaseService,\n QueueService,\n ServiceContainer,\n type ServiceCredential,\n type TracingService,\n} from '../services';\n\nimport { consoleLogger, noopLogger } from './logger';\n\n// TODO(burdon): Factor out.\nexport type OneOf<T> = {\n [K in keyof T]: { [P in K]: T[P] } & { [P in Exclude<keyof T, K>]?: never };\n}[keyof T];\n\nexport type AiServiceProvider = 'dev' | 'edge' | 'ollama' | 'lmstudio';\n\nexport type TestServiceOptions = {\n /**\n * AI service configuration.\n */\n ai?: any;\n\n /**\n * Credentials service configuration.\n */\n credentials?: OneOf<{\n /**\n * Predefined credentials list.\n */\n services?: ServiceCredential[];\n\n /**\n * Custom credentials service.\n */\n service?: Context.Tag.Service<CredentialsService>;\n }>;\n\n /**\n * Database configuration.\n */\n db?: EchoDatabase;\n\n /**\n * Gets database and queue services from the space.\n * Exclusive with: `db`, `queues`\n */\n space?: Space;\n\n /**\n * Logging configuration.\n */\n logging?: {\n enabled?: boolean;\n logger?: Context.Tag.Service<ComputeEventLogger>;\n };\n\n /**\n * Queue service configuration.\n */\n queues?: QueueFactory;\n\n tracing?: {\n service?: Context.Tag.Service<TracingService>;\n };\n};\n\n/**\n * @deprecated\n */\nexport const createTestServices = ({\n ai,\n credentials,\n db,\n logging,\n queues,\n space,\n tracing,\n}: TestServiceOptions = {}): ServiceContainer => {\n assertArgument(!(!!space && (!!db || !!queues)), 'space', 'space can be provided only if db and queues are not');\n\n return new ServiceContainer().setServices({\n // ai: createAiService(ai),\n credentials: createCredentialsService(credentials),\n database: space || db ? DatabaseService.make(space?.db || db!) : undefined,\n eventLogger: (logging?.logger ?? logging?.enabled) ? consoleLogger : noopLogger,\n queues: space || queues ? QueueService.make(space?.queues || queues!, undefined) : undefined,\n tracing: tracing?.service,\n });\n};\n\nconst createCredentialsService = (\n credentials: TestServiceOptions['credentials'] | undefined,\n): Context.Tag.Service<CredentialsService> | undefined => {\n if (credentials?.services) {\n return new ConfiguredCredentialsService(credentials.services);\n }\n\n if (credentials?.service) {\n return credentials.service;\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nimport { LogLevel } from '@dxos/log';\n\nimport { type ComputeEventLogger, createEventLogger } from '../services';\n\nexport const noopLogger: Context.Tag.Service<ComputeEventLogger> = {\n log: () => Effect.succeed(undefined),\n nodeId: undefined,\n};\n\nexport const consoleLogger: Context.Tag.Service<ComputeEventLogger> = createEventLogger(LogLevel.INFO);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport type * as Schema from 'effect/Schema';\n\nimport type { EchoDatabaseImpl, QueueFactory } from '@dxos/echo-db';\nimport { EchoTestBuilder } from '@dxos/echo-db/testing';\nimport type { EchoHostIndexingConfig } from '@dxos/echo-pipeline';\nimport { acquireReleaseResource } from '@dxos/effect';\nimport { PublicKey } from '@dxos/keys';\nimport type { LevelDB } from '@dxos/kv-store';\nimport { createTestLevel } from '@dxos/kv-store/testing';\nimport { log } from '@dxos/log';\n\nimport { DatabaseService, QueueService } from '../services';\n\nconst testBuilder = acquireReleaseResource(() => new EchoTestBuilder());\n\nexport const testStoragePath = ({ name = PublicKey.random().toHex() }: { name?: string }) => {\n return `/tmp/dxos-${name}`;\n};\n\nexport type TestDatabaseOptions = {\n indexing?: Partial<EchoHostIndexingConfig>;\n types?: Schema.Schema.AnyNoContext[];\n spaceKey?: PublicKey;\n storagePath?: string;\n onInit?: () => Effect.Effect<void, never, DatabaseService | QueueService>;\n};\n\nexport const TestDatabaseLayer = ({ indexing, types, spaceKey, storagePath, onInit }: TestDatabaseOptions = {}) =>\n Layer.scopedContext(\n Effect.gen(function* () {\n const builder = yield* testBuilder;\n\n let kv: LevelDB | undefined;\n if (storagePath) {\n kv = createTestLevel(storagePath);\n yield* Effect.promise(() => kv!.open());\n // const keyCount = yield* Effect.promise(async () => (await kv!.iterator({ values: false }).all()).length);\n // log.info('opened test db', { storagePath, keyCount });\n }\n const peer = yield* Effect.promise(() => builder.createPeer({ indexing, types, kv }));\n\n let db: EchoDatabaseImpl | undefined;\n let queues: QueueFactory | undefined;\n\n if (storagePath) {\n const testMetadata = yield* Effect.promise(async () => {\n try {\n return await kv!.get('test-metadata', { valueEncoding: 'json' });\n } catch (e) {\n if ((e as any).code === 'LEVEL_NOT_FOUND') {\n return undefined;\n }\n throw e;\n }\n });\n log('starting persistant test db', { storagePath, testMetadata });\n if (!testMetadata) {\n const key = spaceKey ?? PublicKey.random();\n db = yield* Effect.promise(() => peer.createDatabase(key));\n queues = peer.client.constructQueueFactory(db.spaceId);\n\n yield* Effect.promise(() =>\n kv!.put('test-metadata', { key: key.toHex(), rootUrl: db!.rootUrl }, { valueEncoding: 'json' }),\n );\n\n if (onInit) {\n yield* onInit().pipe(\n Effect.provideService(DatabaseService, DatabaseService.make(db)),\n Effect.provideService(QueueService, QueueService.make(queues, undefined)),\n );\n }\n } else {\n const key = PublicKey.from((testMetadata as any).key);\n const rootUrl = (testMetadata as any).rootUrl;\n db = yield* Effect.promise(() => peer.openDatabase(key, rootUrl));\n queues = peer.client.constructQueueFactory(db.spaceId);\n }\n } else {\n db = yield* Effect.promise(() => peer.createDatabase(spaceKey));\n queues = peer.client.constructQueueFactory(db.spaceId);\n if (onInit) {\n yield* onInit().pipe(\n Effect.provideService(DatabaseService, DatabaseService.make(db)),\n Effect.provideService(QueueService, QueueService.make(queues, undefined)),\n );\n }\n }\n\n yield* Effect.addFinalizer(() =>\n Effect.promise(async () => {\n if (kv) {\n // {\n // const keyCount = (await kv.iterator({ values: false }).all()).length;\n // log.info('closing persistant test db', { storagePath, keyCount });\n // }\n\n await kv.close();\n }\n }),\n );\n\n return Context.mergeAll(\n Context.make(DatabaseService, DatabaseService.make(db)),\n Context.make(QueueService, QueueService.make(queues, undefined)),\n );\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAQA,SAASA,sBAAsB;;;ACH/B,YAAYC,YAAY;AAExB,SAASC,gBAAgB;AAIlB,IAAMC,aAAsD;EACjEC,KAAK,MAAaC,eAAQC,MAAAA;EAC1BC,QAAQD;AACV;AAEO,IAAME,gBAAyDC,kBAAkBC,SAASC,IAAI;;;ADmE9F,IAAMC,qBAAqB,CAAC,EACjCC,IACAC,aACAC,IACAC,SACAC,QACAC,OACAC,QAAO,IACe,CAAC,MAAC;AACxBC,iBAAe,EAAE,CAAC,CAACF,UAAU,CAAC,CAACH,MAAM,CAAC,CAACE,UAAU,SAAS,qDAAA;AAE1D,SAAO,IAAII,iBAAAA,EAAmBC,YAAY;;IAExCR,aAAaS,yBAAyBT,WAAAA;IACtCU,UAAUN,SAASH,KAAKU,gBAAgBC,KAAKR,OAAOH,MAAMA,EAAAA,IAAOY;IACjEC,aAAcZ,SAASa,UAAUb,SAASc,UAAWC,gBAAgBC;IACrEf,QAAQC,SAASD,SAASgB,aAAaP,KAAKR,OAAOD,UAAUA,QAASU,MAAAA,IAAaA;IACnFR,SAASA,SAASe;EACpB,CAAA;AACF;AAEA,IAAMX,2BAA2B,CAC/BT,gBAAAA;AAEA,MAAIA,aAAaqB,UAAU;AACzB,WAAO,IAAIC,6BAA6BtB,YAAYqB,QAAQ;EAC9D;AAEA,MAAIrB,aAAaoB,SAAS;AACxB,WAAOpB,YAAYoB;EACrB;AACF;;;AE9GA,YAAYG,aAAa;AACzB,YAAYC,aAAY;AACxB,YAAYC,WAAW;AAIvB,SAASC,uBAAuB;AAEhC,SAASC,8BAA8B;AACvC,SAASC,iBAAiB;AAE1B,SAASC,uBAAuB;AAChC,SAASC,WAAW;;AAIpB,IAAMC,cAAcC,uBAAuB,MAAM,IAAIC,gBAAAA,CAAAA;A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AeG,cAAcA,aAAaD,KAAKlB,QAAQM,MAAAA,CAAAA,CAAAA;MAElE;IACF,OAAO;AACL,YAAME,MAAM3B,UAAUuC,KAAMnB,aAAqBO,GAAG;AACpD,YAAMM,UAAWb,aAAqBa;AACtCf,WAAK,OAAcJ,gBAAQ,MAAME,KAAKwB,aAAab,KAAKM,OAAAA,CAAAA;AACxDd,eAASH,KAAKa,OAAOC,sBAAsBZ,GAAGa,OAAO;IACvD;EACF,OAAO;AACLb,SAAK,OAAcJ,gBAAQ,MAAME,KAAKY,eAAetB,QAAAA,CAAAA;AACrDa,aAASH,KAAKa,OAAOC,sBAAsBZ,GAAGa,OAAO;AACrD,QAAIvB,QAAQ;AACV,aAAOA,OAAAA,EAAS0B,KACPC,uBAAeC,iBAAiBA,gBAAgBC,KAAKnB,EAAAA,CAAAA,GACrDiB,uBAAeG,cAAcA,aAAaD,KAAKlB,QAAQM,MAAAA,CAAAA,CAAAA;IAElE;EACF;AAEA,SAAcgB,qBAAa,MAClB3B,gBAAQ,YAAA;AACb,QAAIF,IAAI;AAMN,YAAMA,GAAG8B,MAAK;IAChB;EACF,CAAA,CAAA;AAGF,SAAeC,iBACLN,aAAKD,iBAAiBA,gBAAgBC,KAAKnB,EAAAA,CAAAA,GAC3CmB,aAAKC,cAAcA,aAAaD,KAAKlB,QAAQM,MAAAA,CAAAA,CAAAA;AAEzD,CAAA,CAAA;",
|
|
6
|
-
"names": ["assertArgument", "Effect", "LogLevel", "noopLogger", "log", "succeed", "undefined", "nodeId", "consoleLogger", "createEventLogger", "LogLevel", "INFO", "createTestServices", "ai", "credentials", "db", "logging", "queues", "space", "tracing", "assertArgument", "ServiceContainer", "setServices", "createCredentialsService", "database", "DatabaseService", "make", "undefined", "eventLogger", "logger", "enabled", "consoleLogger", "noopLogger", "QueueService", "service", "services", "ConfiguredCredentialsService", "Context", "Effect", "Layer", "EchoTestBuilder", "acquireReleaseResource", "PublicKey", "createTestLevel", "log", "testBuilder", "acquireReleaseResource", "EchoTestBuilder", "testStoragePath", "name", "PublicKey", "random", "toHex", "TestDatabaseLayer", "indexing", "types", "spaceKey", "storagePath", "onInit", "scopedContext", "gen", "builder", "kv", "createTestLevel", "promise", "open", "peer", "createPeer", "db", "queues", "testMetadata", "get", "valueEncoding", "e", "code", "undefined", "log", "key", "createDatabase", "client", "constructQueueFactory", "spaceId", "put", "rootUrl", "pipe", "provideService", "DatabaseService", "make", "QueueService", "from", "openDatabase", "addFinalizer", "close", "mergeAll"]
|
|
7
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type BuildOptions, type BuildResult } from 'esbuild-wasm';
|
|
2
|
-
export type Import = {
|
|
3
|
-
moduleUrl: string;
|
|
4
|
-
defaultImport: boolean;
|
|
5
|
-
namedImports: string[];
|
|
6
|
-
};
|
|
7
|
-
export type BundleOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* Source code to bundle.
|
|
10
|
-
*/
|
|
11
|
-
source: string;
|
|
12
|
-
};
|
|
13
|
-
export type BundleResult = {
|
|
14
|
-
timestamp: number;
|
|
15
|
-
sourceHash: Buffer;
|
|
16
|
-
error: unknown;
|
|
17
|
-
} | {
|
|
18
|
-
timestamp: number;
|
|
19
|
-
sourceHash: Buffer;
|
|
20
|
-
imports: Import[];
|
|
21
|
-
entryPoint: string;
|
|
22
|
-
asset: Uint8Array;
|
|
23
|
-
bundle: string;
|
|
24
|
-
};
|
|
25
|
-
export type BundlerOptions = {
|
|
26
|
-
platform: BuildOptions['platform'];
|
|
27
|
-
sandboxedModules: string[];
|
|
28
|
-
remoteModules: Record<string, string>;
|
|
29
|
-
};
|
|
30
|
-
export declare const initializeBundler: (options: {
|
|
31
|
-
wasmUrl: string;
|
|
32
|
-
}) => Promise<void>;
|
|
33
|
-
/**
|
|
34
|
-
* ESBuild bundler.
|
|
35
|
-
*/
|
|
36
|
-
export declare class Bundler {
|
|
37
|
-
private readonly _options;
|
|
38
|
-
constructor(_options: BundlerOptions);
|
|
39
|
-
bundle({ source }: BundleOptions): Promise<BundleResult>;
|
|
40
|
-
analyzeImports(result: BuildResult): Import[];
|
|
41
|
-
analyzeSourceFileImports(code: string): {
|
|
42
|
-
defaultImportName: string;
|
|
43
|
-
namedImports: string[];
|
|
44
|
-
wildcardImportName: string;
|
|
45
|
-
moduleIdentifier: string;
|
|
46
|
-
quotes: string;
|
|
47
|
-
}[];
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=bundler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAA+C,MAAM,cAAc,CAAC;AAOhH,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;CAChB,GACD;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACnC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAU,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,kBAInE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc;IAE/C,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAyF9D,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE;IA0B7C,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG;QACtC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,gBAAgB,EAAE,MAAM,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC;KAChB,EAAE;CAaJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.test.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bundler/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.test.d.ts","sourceRoot":"","sources":["../../../../src/e2e/deploy.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type DID } from 'iso-did/types';
|
|
2
|
-
import { type Client } from '@dxos/client';
|
|
3
|
-
import { type PublicKey } from '@dxos/keys';
|
|
4
|
-
import { type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
5
|
-
export type UploadWorkerArgs = {
|
|
6
|
-
client: Client;
|
|
7
|
-
version: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
functionId?: string;
|
|
10
|
-
ownerPublicKey: PublicKey;
|
|
11
|
-
entryPoint: string;
|
|
12
|
-
assets: Record<string, Uint8Array>;
|
|
13
|
-
};
|
|
14
|
-
export declare const uploadWorkerFunction: ({ client, version, name, functionId, ownerPublicKey, entryPoint, assets, }: UploadWorkerArgs) => Promise<UploadFunctionResponseBody>;
|
|
15
|
-
export declare const incrementSemverPatch: (version: string) => string;
|
|
16
|
-
export declare const publicKeyToDid: (key: PublicKey) => DID;
|
|
17
|
-
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../src/edge/functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,SAAS,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,4EAQxC,gBAAgB,KAAG,OAAO,CAAC,0BAA0B,CAsBvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,MAKtD,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,KAAK,SAAS,KAAG,GAE/C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/edge/index.ts"],"names":[],"mappings":"AAQA,cAAc,aAAa,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FunctionDefinition } from '../handler';
|
|
2
|
-
import type { ServiceContainer } from '../services';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use `FunctionInvocationService`
|
|
5
|
-
*/
|
|
6
|
-
export declare class FunctionExecutor {
|
|
7
|
-
private readonly _services;
|
|
8
|
-
constructor(_services: ServiceContainer);
|
|
9
|
-
/**
|
|
10
|
-
* Invoke function.
|
|
11
|
-
*/
|
|
12
|
-
invoke<F extends FunctionDefinition<any, any>>(functionDef: F, input: F extends FunctionDefinition<infer I, infer _O> ? I : never): Promise<F extends FunctionDefinition<infer _I, infer O> ? O : never>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../../src/executor/executor.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAmB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IAExD;;OAEG;IAEG,MAAM,CAAC,CAAC,SAAS,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,EACjD,WAAW,EAAE,CAAC,EACd,KAAK,EAAE,CAAC,SAAS,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,GACjE,OAAO,CAAC,CAAC,SAAS,kBAAkB,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CA+BxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/executor/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type * as Context from 'effect/Context';
|
|
2
|
-
import * as Effect from 'effect/Effect';
|
|
3
|
-
import * as Schema from 'effect/Schema';
|
|
4
|
-
import { type HasId } from '@dxos/echo/internal';
|
|
5
|
-
import { type EchoDatabase } from '@dxos/echo-db';
|
|
6
|
-
import { type DXN, type SpaceId } from '@dxos/keys';
|
|
7
|
-
import { type QueryResult } from '@dxos/protocols';
|
|
8
|
-
import { type Services } from './services';
|
|
9
|
-
import { Function } from './types';
|
|
10
|
-
/**
|
|
11
|
-
* Function handler.
|
|
12
|
-
*/
|
|
13
|
-
export type FunctionHandler<TData = {}, TOutput = any> = (params: {
|
|
14
|
-
/**
|
|
15
|
-
* Services and context available to the function.
|
|
16
|
-
*/
|
|
17
|
-
context: FunctionContext;
|
|
18
|
-
/**
|
|
19
|
-
* Data passed as the input to the function.
|
|
20
|
-
* Must match the function's input schema.
|
|
21
|
-
* This will be the payload from the trigger or other data passed into the function in a workflow.
|
|
22
|
-
*/
|
|
23
|
-
data: TData;
|
|
24
|
-
}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any, Services>;
|
|
25
|
-
/**
|
|
26
|
-
* Function context.
|
|
27
|
-
*/
|
|
28
|
-
export interface FunctionContext {
|
|
29
|
-
/**
|
|
30
|
-
* Space from which the function was invoked.
|
|
31
|
-
*/
|
|
32
|
-
space: SpaceAPI | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Resolves a service available to the function.
|
|
35
|
-
* @throws if the service is not available.
|
|
36
|
-
*/
|
|
37
|
-
getService: <T extends Context.Tag<any, any>>(tag: T) => Context.Tag.Service<T>;
|
|
38
|
-
getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;
|
|
39
|
-
}
|
|
40
|
-
export interface FunctionContextAi {
|
|
41
|
-
run(model: string, inputs: any, options?: any): Promise<any>;
|
|
42
|
-
}
|
|
43
|
-
export interface QueuesAPI {
|
|
44
|
-
queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;
|
|
45
|
-
insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Space interface available to functions.
|
|
49
|
-
*/
|
|
50
|
-
export interface SpaceAPI {
|
|
51
|
-
get id(): SpaceId;
|
|
52
|
-
get db(): EchoDatabase;
|
|
53
|
-
get queues(): QueuesAPI;
|
|
54
|
-
}
|
|
55
|
-
declare const typeId: unique symbol;
|
|
56
|
-
export type FunctionDefinition<T = any, O = any> = {
|
|
57
|
-
[typeId]: true;
|
|
58
|
-
key: string;
|
|
59
|
-
name: string;
|
|
60
|
-
description?: string;
|
|
61
|
-
inputSchema: Schema.Schema<T, any>;
|
|
62
|
-
outputSchema?: Schema.Schema<O, any>;
|
|
63
|
-
handler: FunctionHandler<T, O>;
|
|
64
|
-
meta?: {
|
|
65
|
-
/**
|
|
66
|
-
* Tools that are projected from functions have this annotation.
|
|
67
|
-
*
|
|
68
|
-
* deployedFunctionId:
|
|
69
|
-
* - Backend deployment ID assigned by the EDGE function service (typically a UUID).
|
|
70
|
-
* - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.
|
|
71
|
-
* - Persisted on the corresponding ECHO `Function.Function` object's metadata under the
|
|
72
|
-
* `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.
|
|
73
|
-
*/
|
|
74
|
-
deployedFunctionId?: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
export type FunctionProps<T, O> = {
|
|
78
|
-
key: string;
|
|
79
|
-
name: string;
|
|
80
|
-
description?: string;
|
|
81
|
-
inputSchema: Schema.Schema<T, any>;
|
|
82
|
-
outputSchema?: Schema.Schema<O, any>;
|
|
83
|
-
handler: FunctionHandler<T, O>;
|
|
84
|
-
};
|
|
85
|
-
export declare const defineFunction: {
|
|
86
|
-
<I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O>;
|
|
87
|
-
};
|
|
88
|
-
export declare const FunctionDefinition: {
|
|
89
|
-
make: <I, O>(params: FunctionProps<I, O>) => FunctionDefinition<I, O>;
|
|
90
|
-
isFunction: (value: unknown) => value is FunctionDefinition.Any;
|
|
91
|
-
serialize: (functionDef: FunctionDefinition.Any) => Function.Function;
|
|
92
|
-
deserialize: (functionObj: Function.Function) => FunctionDefinition.Any;
|
|
93
|
-
};
|
|
94
|
-
export declare namespace FunctionDefinition {
|
|
95
|
-
type Any = FunctionDefinition<any, any>;
|
|
96
|
-
type Input<T extends FunctionDefinition> = T extends FunctionDefinition<infer I, any> ? I : never;
|
|
97
|
-
type Output<T extends FunctionDefinition> = T extends FunctionDefinition<any, infer O> ? O : never;
|
|
98
|
-
}
|
|
99
|
-
export declare const serializeFunction: (functionDef: FunctionDefinition<any, any>) => Function.Function;
|
|
100
|
-
export declare const deserializeFunction: (functionObj: Function.Function) => FunctionDefinition<unknown, unknown>;
|
|
101
|
-
export {};
|
|
102
|
-
//# sourceMappingURL=handler.d.ts.map
|