@dxos/edge-compute 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +105 -0
- package/dist/lib/neutral/bundler/index.mjs +213 -0
- package/dist/lib/neutral/bundler/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RN6KVGN4.mjs +63 -0
- package/dist/lib/neutral/chunk-RN6KVGN4.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +343 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/native/index.mjs +186 -0
- package/dist/lib/neutral/native/index.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +41 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/EdgeOperationInvoker.d.ts +21 -0
- package/dist/types/src/EdgeOperationInvoker.d.ts.map +1 -0
- package/dist/types/src/EdgeProcessManager.d.ts +14 -0
- package/dist/types/src/EdgeProcessManager.d.ts.map +1 -0
- package/dist/types/src/EdgeTriggerManager.d.ts +14 -0
- package/dist/types/src/EdgeTriggerManager.d.ts.map +1 -0
- package/dist/types/src/FunctionsServiceClient.d.ts +65 -0
- package/dist/types/src/FunctionsServiceClient.d.ts.map +1 -0
- package/dist/types/src/bundler/bundler.d.ts +38 -0
- package/dist/types/src/bundler/bundler.d.ts.map +1 -0
- package/dist/types/src/bundler/bundler.test.d.ts +2 -0
- package/dist/types/src/bundler/bundler.test.d.ts.map +1 -0
- package/dist/types/src/bundler/index.d.ts +2 -0
- package/dist/types/src/bundler/index.d.ts.map +1 -0
- package/dist/types/src/bundler/plugins/embedded-vendored-packages.d.ts +3 -0
- package/dist/types/src/bundler/plugins/embedded-vendored-packages.d.ts.map +1 -0
- package/dist/types/src/bundler/plugins/http-plugin-esbuild.d.ts +34 -0
- package/dist/types/src/bundler/plugins/http-plugin-esbuild.d.ts.map +1 -0
- package/dist/types/src/bundler/plugins/index.d.ts +4 -0
- package/dist/types/src/bundler/plugins/index.d.ts.map +1 -0
- package/dist/types/src/bundler/plugins/r2-vendored-packages.d.ts +5 -0
- package/dist/types/src/bundler/plugins/r2-vendored-packages.d.ts.map +1 -0
- package/dist/types/src/edge-client.d.ts +39 -0
- package/dist/types/src/edge-client.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/native/bundler.d.ts +15 -0
- package/dist/types/src/native/bundler.d.ts.map +1 -0
- package/dist/types/src/native/index.d.ts +2 -0
- package/dist/types/src/native/index.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/logger.d.ts +4 -0
- package/dist/types/src/testing/logger.d.ts.map +1 -0
- package/dist/types/src/testing/services.d.ts +53 -0
- package/dist/types/src/testing/services.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +95 -0
- package/src/EdgeOperationInvoker.ts +65 -0
- package/src/EdgeProcessManager.ts +47 -0
- package/src/EdgeTriggerManager.ts +70 -0
- package/src/FunctionsServiceClient.ts +189 -0
- package/src/bundler/bundler.test.ts +108 -0
- package/src/bundler/bundler.ts +232 -0
- package/src/bundler/index.ts +5 -0
- package/src/bundler/plugins/embedded-vendored-packages.ts +39 -0
- package/src/bundler/plugins/http-plugin-esbuild.ts +77 -0
- package/src/bundler/plugins/index.ts +7 -0
- package/src/bundler/plugins/r2-vendored-packages.ts +35 -0
- package/src/edge-client.ts +156 -0
- package/src/index.ts +9 -0
- package/src/native/bundler.ts +231 -0
- package/src/native/index.ts +5 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/logger.ts +14 -0
- package/src/testing/services.ts +95 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/native/bundler.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport * as Array from 'effect/Array';\nimport * as Function from 'effect/Function';\nimport * as Order from 'effect/Order';\nimport * as Record from 'effect/Record';\nimport { type Message, build } from 'esbuild';\nimport { statSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport * as fs from 'node:fs/promises';\nimport { basename, dirname, join, relative, resolve } from 'node:path';\n\nimport { BaseError } from '@dxos/errors';\nimport { PublicKey } from '@dxos/keys';\nimport { Unit, trim } from '@dxos/util';\n\nimport { httpPlugin } from '../bundler/plugins/http-plugin-esbuild';\n\ntype BundleOptions = {\n entryPoint: string;\n verbose?: boolean;\n};\n\nexport type BundleResult = {\n entryPoint: string;\n assets: Record<string, Uint8Array>;\n};\n\n/**\n * Bundles a function.\n * Pulls in node_modules and wasm files.\n */\nexport const bundleFunction = async (options: BundleOptions): Promise<BundleResult> => {\n const outdir = `/tmp/dxos-functions-bundle-${new Date().toISOString()}-${PublicKey.random().toHex()}`;\n const gitDir = findGitDir(dirname(options.entryPoint));\n\n const result = await build({\n entryPoints: {\n // Gets mapped to `index.js` by esbuild.\n index: 'dxos:entrypoint',\n },\n bundle: true,\n format: 'esm',\n platform: 'browser',\n conditions: ['workerd', 'worker', 'browser'],\n outdir,\n metafile: true,\n treeShaking: true,\n sourcemap: true,\n splitting: true,\n logOverride: {\n 'ignored-bare-import': 'silent',\n },\n loader: {\n '.wasm': 'copy',\n },\n external: ['node:*', 'cloudflare:workers', 'functions-service:user-script'],\n plugins: [\n httpPlugin,\n {\n name: 'entrypoint',\n setup: (build) => {\n build.onResolve({ filter: /^dxos:entrypoint$/ }, () => ({\n path: 'dxos:entrypoint',\n namespace: 'dxos:entrypoint',\n }));\n build.onLoad({ filter: /^dxos:entrypoint$/, namespace: 'dxos:entrypoint' }, () => ({\n contents: trim`\n export default {\n fetch: async (...args) => {\n const { wrapFunctionHandler } = await import('@dxos/compute-runtime');\n const { wrapHandlerForCloudflare, setupFunctionsLogger } = await import('@dxos/functions-runtime-cloudflare');\n const { default: handler } = await import('${options.entryPoint}');\n\n setupFunctionsLogger();\n\n //\n // Wrapper to make the function cloudflare-compatible.\n //\n return wrapHandlerForCloudflare(wrapFunctionHandler(handler))(...args);\n },\n };\n `,\n resolveDir: new URL('.', import.meta.url).pathname,\n }));\n },\n },\n {\n name: 'metafile',\n setup: (build) => {\n build.onEnd(async (result) => {\n await writeFile(\n join(build.initialOptions.outdir!, 'metafile.json'),\n JSON.stringify(result.metafile, null, 2),\n );\n await writeFile(\n join(build.initialOptions.outdir!, 'manifest.json'),\n JSON.stringify(\n {\n files: Object.keys(result.metafile!.outputs).map((path) => ({\n name: relative(build.initialOptions.outdir!, path),\n })),\n },\n null,\n 2,\n ),\n );\n });\n },\n },\n ],\n });\n\n if (result.errors.length > 0) {\n throw new BundleCreationError(result.errors);\n }\n\n const assetPaths = Object.keys(result.metafile!.outputs).map((path) => relative(outdir, path));\n const assets = Function.pipe(\n await Promise.all(assetPaths.map((path) => fs.readFile(join(outdir, path)))),\n Array.zipWith(assetPaths, (content, path) => [path, content] as const),\n Record.fromEntries,\n );\n\n if (options.verbose) {\n console.log('Function compiled');\n console.log('Metafile path:', `${outdir}/metafile.json`);\n console.log('Assets:\\n');\n console.log(\n Object.entries(result.metafile!.outputs)\n .sort((a, b) => b[1].bytes - a[1].bytes)\n .map(\n ([path, desc]) =>\n `${formatBytes(desc.bytes).padEnd(10)} - ${relative(outdir, path)} ${basename(path) === 'index.js' ? ' (entry point)' : ''}`,\n )\n .join('\\n'),\n );\n\n const filesInOutput = Function.pipe(\n result.metafile.outputs,\n Record.values,\n Array.flatMap((_) => Record.toEntries(_.inputs)),\n );\n\n const moduleInOutput = Function.pipe(\n result.metafile.inputs,\n Record.values,\n Array.flatMap((_) => _.imports),\n Array.filter((_) => !!_.original?.match(/^@[a-zA-Z]+/)),\n Array.filter((_) => !!filesInOutput.find(([name]) => name === _.path)),\n Array.map((_) => _.original!),\n Array.dedupe,\n Array.sort(Order.string),\n );\n console.log(`Modules in output:\\n${moduleInOutput.map((_) => ` - ${_}`).join('\\n')}`);\n }\n\n for (const path of Object.keys(assets)) {\n if (path.endsWith('.map')) {\n const content = assets[path];\n const map = JSON.parse(new TextDecoder().decode(content));\n const processedMap = postprocessSourceMap(map, outdir, gitDir);\n assets[path] = Buffer.from(JSON.stringify(processedMap));\n }\n }\n\n // Must match esbuild entry point.\n return { entryPoint: 'index.js', assets };\n};\n\nclass BundleCreationError extends BaseError.extend('BundleCreationError', 'Bundle creation failed') {\n constructor(errors: Message[]) {\n super({ context: { errors } });\n }\n}\n\nconst formatBytes = (bytes: number) => {\n if (bytes < Unit.Kilobyte(1).unit.quotient) {\n return Unit.Byte(bytes).toString();\n }\n if (bytes < Unit.Megabyte(1).unit.quotient) {\n return Unit.Kilobyte(bytes).toString();\n }\n if (bytes < Unit.Gigabyte(1).unit.quotient) {\n return Unit.Megabyte(bytes).toString();\n }\n return Unit.Gigabyte(bytes).toString();\n};\n\nconst findGitDir = (startPath: string): string | null => {\n let current = startPath;\n while (current !== '/') {\n const gitPath = join(current, '.git');\n try {\n if (statSync(gitPath).isDirectory()) {\n return gitPath;\n }\n } catch {\n // ignore\n }\n current = dirname(current);\n }\n return null;\n};\n\n/**\n * Adjust source paths to be relative to the repo root.\n */\nconst postprocessSourceMap = (map: any, outDir: string, gitDir: string | null) => {\n if (!gitDir) {\n return map;\n }\n\n // Update source paths to be relative to the output directory\n if (map.sources && Array.isArray(map.sources)) {\n map.sources = map.sources.map((source: string) => {\n const resolved = resolve(outDir, source);\n if (resolved.startsWith(dirname(gitDir))) {\n const rel = relative(dirname(gitDir), resolved);\n return rel;\n }\n return source;\n });\n }\n\n return map;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAMA,YAAYA,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,WAAW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A,QAAQ6B,KAAKC,SAAS,CAAA,EAAGC,KAAKC,UAAU;AAC1C,WAAOH,KAAKI,KAAKjC,KAAAA,EAAOkC,SAAQ;EAClC;AACA,MAAIlC,QAAQ6B,KAAKM,SAAS,CAAA,EAAGJ,KAAKC,UAAU;AAC1C,WAAOH,KAAKC,SAAS9B,KAAAA,EAAOkC,SAAQ;EACtC;AACA,MAAIlC,QAAQ6B,KAAKO,SAAS,CAAA,EAAGL,KAAKC,UAAU;AAC1C,WAAOH,KAAKM,SAASnC,KAAAA,EAAOkC,SAAQ;EACtC;AACA,SAAOL,KAAKO,SAASpC,KAAAA,EAAOkC,SAAQ;AACtC;AAEA,IAAMlG,aAAa,CAACqG,cAAAA;AAClB,MAAIC,UAAUD;AACd,SAAOC,YAAY,KAAK;AACtB,UAAMC,UAAUpE,KAAKmE,SAAS,MAAA;AAC9B,QAAI;AACF,UAAIE,SAASD,OAAAA,EAASE,YAAW,GAAI;AACnC,eAAOF;MACT;IACF,QAAQ;IAER;AACAD,cAAUrG,QAAQqG,OAAAA;EACpB;AACA,SAAO;AACT;AAKA,IAAMf,uBAAuB,CAAC5C,MAAU+D,QAAgB3G,WAAAA;AACtD,MAAI,CAACA,QAAQ;AACX,WAAO4C;EACT;AAGA,MAAIA,KAAIgE,WAAiBC,cAAQjE,KAAIgE,OAAO,GAAG;AAC7ChE,IAAAA,KAAIgE,UAAUhE,KAAIgE,QAAQhE,IAAI,CAACkE,WAAAA;AAC7B,YAAMC,WAAWC,QAAQL,QAAQG,MAAAA;AACjC,UAAIC,SAASE,WAAW/G,QAAQF,MAAAA,CAAAA,GAAU;AACxC,cAAMkH,MAAMrE,SAAS3C,QAAQF,MAAAA,GAAS+G,QAAAA;AACtC,eAAOG;MACT;AACA,aAAOJ;IACT,CAAA;EACF;AAEA,SAAOlE;AACT;",
|
|
6
|
+
"names": ["Array", "Function", "Order", "Record", "build", "statSync", "writeFile", "fs", "basename", "dirname", "join", "relative", "resolve", "BaseError", "PublicKey", "Unit", "trim", "bundleFunction", "options", "outdir", "Date", "toISOString", "PublicKey", "random", "toHex", "gitDir", "findGitDir", "dirname", "entryPoint", "result", "build", "entryPoints", "index", "bundle", "format", "platform", "conditions", "metafile", "treeShaking", "sourcemap", "splitting", "logOverride", "loader", "external", "plugins", "httpPlugin", "name", "setup", "onResolve", "filter", "path", "namespace", "onLoad", "contents", "trim", "resolveDir", "URL", "url", "pathname", "onEnd", "writeFile", "join", "initialOptions", "JSON", "stringify", "files", "Object", "keys", "outputs", "map", "relative", "errors", "length", "BundleCreationError", "assetPaths", "assets", "pipe", "Promise", "all", "readFile", "zipWith", "content", "fromEntries", "verbose", "console", "log", "entries", "sort", "a", "b", "bytes", "desc", "formatBytes", "padEnd", "basename", "filesInOutput", "values", "flatMap", "_", "toEntries", "inputs", "moduleInOutput", "imports", "original", "match", "find", "dedupe", "string", "endsWith", "parse", "TextDecoder", "decode", "processedMap", "postprocessSourceMap", "Buffer", "from", "BaseError", "extend", "context", "Unit", "Kilobyte", "unit", "quotient", "Byte", "toString", "Megabyte", "Gigabyte", "startPath", "current", "gitPath", "statSync", "isDirectory", "outDir", "sources", "isArray", "source", "resolved", "resolve", "startsWith", "rel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/testing/services.ts
|
|
4
|
+
import { ConfiguredCredentialsService } from "@dxos/compute-runtime";
|
|
5
|
+
import { ServiceContainer } from "@dxos/compute-runtime";
|
|
6
|
+
import { Database } from "@dxos/echo";
|
|
7
|
+
import { assertArgument } from "@dxos/invariant";
|
|
8
|
+
|
|
9
|
+
// src/testing/logger.ts
|
|
10
|
+
import { Trace } from "@dxos/compute";
|
|
11
|
+
import { log } from "@dxos/log";
|
|
12
|
+
var __dxlog_file = "/Users/dmaretskyi/Code/dxos/dxos/packages/core/compute/edge-compute/src/testing/logger.ts";
|
|
13
|
+
var noopTraceWriter = Trace.noopWriter;
|
|
14
|
+
var consoleTraceWriter = {
|
|
15
|
+
write: (event, payload) => {
|
|
16
|
+
log.info(event.key, payload, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 9, S: void 0 });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/testing/services.ts
|
|
21
|
+
var createTestServices = ({ ai, credentials, db, logging, space } = {}) => {
|
|
22
|
+
assertArgument(!(!!space && !!db), "space", "space can be provided only if db is not");
|
|
23
|
+
return new ServiceContainer().setServices({
|
|
24
|
+
// ai: createAiService(ai),
|
|
25
|
+
credentials: createCredentialsService(credentials),
|
|
26
|
+
database: space || db ? Database.makeService(space?.db || db) : void 0,
|
|
27
|
+
trace: logging?.trace ?? (logging?.enabled ? consoleTraceWriter : noopTraceWriter)
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var createCredentialsService = (credentials) => {
|
|
31
|
+
if (credentials?.services) {
|
|
32
|
+
return new ConfiguredCredentialsService(credentials.services);
|
|
33
|
+
}
|
|
34
|
+
if (credentials?.service) {
|
|
35
|
+
return credentials.service;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
createTestServices
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/testing/services.ts", "../../../../src/testing/logger.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 Credential, type Trace } from '@dxos/compute';\nimport { ConfiguredCredentialsService } from '@dxos/compute-runtime';\nimport { ServiceContainer } from '@dxos/compute-runtime';\nimport { Database } from '@dxos/echo';\nimport { type EchoDatabase } from '@dxos/echo-client';\nimport { assertArgument } from '@dxos/invariant';\n\nimport { consoleTraceWriter, noopTraceWriter } 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?: Credential.ServiceCredential[];\n\n /**\n * Custom credentials service.\n */\n service?: Context.Tag.Service<Credential.CredentialsService>;\n }>;\n\n /**\n * Database configuration.\n */\n db?: EchoDatabase;\n\n /**\n * Gets database service from the space.\n * Exclusive with: `db`\n */\n space?: Space;\n\n /**\n * Trace writer configuration.\n */\n logging?: {\n enabled?: boolean;\n trace?: Context.Tag.Service<Trace.TraceService>;\n };\n};\n\n/**\n * @deprecated\n */\nexport const createTestServices = ({\n ai,\n credentials,\n db,\n logging,\n space,\n}: TestServiceOptions = {}): ServiceContainer => {\n assertArgument(!(!!space && !!db), 'space', 'space can be provided only if db is not');\n\n return new ServiceContainer().setServices({\n // ai: createAiService(ai),\n credentials: createCredentialsService(credentials),\n database: space || db ? Database.makeService(space?.db || db!) : undefined,\n trace: logging?.trace ?? (logging?.enabled ? consoleTraceWriter : noopTraceWriter),\n });\n};\n\nconst createCredentialsService = (\n credentials: TestServiceOptions['credentials'] | undefined,\n): Context.Tag.Service<Credential.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 { Trace } from '@dxos/compute';\nimport { log } from '@dxos/log';\n\nexport const noopTraceWriter: Trace.TraceWriter = Trace.noopWriter;\n\nexport const consoleTraceWriter: Trace.TraceWriter = {\n write: (event, payload) => {\n log.info(event.key, payload as object);\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;AAQA,SAASA,oCAAoC;AAC7C,SAASC,wBAAwB;AACjC,SAASC,gBAAgB;AAEzB,SAASC,sBAAsB;;;ACR/B,SAASC,aAAa;AACtB,SAASC,WAAW;AAEpB,IAAA,eAAaC;AAGXC,IAAQC,kBAAOC,MAAAA;IACTC,qBAAgBD;EACtB,OAAA,CAAA,OAAA,YAAA;AACA,QAAA,KAAA,MAAA,KAAA,SAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,GAAA,GAAA,OAAA,CAAA;;;;;ADsDK,IAAME,qBAAqB,CAAC,EACjCC,IACAC,aACAC,IACAC,SACAC,MAAK,IACiB,CAAC,MAAC;AACxBC,iBAAe,EAAE,CAAC,CAACD,SAAS,CAAC,CAACF,KAAK,SAAS,yCAAA;AAE5C,SAAO,IAAII,iBAAAA,EAAmBC,YAAY;;IAExCN,aAAaO,yBAAyBP,WAAAA;IACtCQ,UAAUL,SAASF,KAAKQ,SAASC,YAAYP,OAAOF,MAAMA,EAAAA,IAAOU;IACjEC,OAAOV,SAASU,UAAUV,SAASW,UAAUC,qBAAqBC;EACpE,CAAA;AACF;AAEA,IAAMR,2BAA2B,CAC/BP,gBAAAA;AAEA,MAAIA,aAAagB,UAAU;AACzB,WAAO,IAAIC,6BAA6BjB,YAAYgB,QAAQ;EAC9D;AAEA,MAAIhB,aAAakB,SAAS;AACxB,WAAOlB,YAAYkB;EACrB;AACF;",
|
|
6
|
+
"names": ["ConfiguredCredentialsService", "ServiceContainer", "Database", "assertArgument", "Trace", "log", "noopTraceWriter", "write", "event", "payload", "info", "createTestServices", "ai", "credentials", "db", "logging", "space", "assertArgument", "ServiceContainer", "setServices", "createCredentialsService", "database", "Database", "makeService", "undefined", "trace", "enabled", "consoleTraceWriter", "noopTraceWriter", "services", "ConfiguredCredentialsService", "service"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Layer from 'effect/Layer';
|
|
2
|
+
import { type Client, ClientService } from '@dxos/client';
|
|
3
|
+
import { RemoteOperationInvoker } from '@dxos/compute-runtime';
|
|
4
|
+
import { type SpaceId } from '@dxos/keys';
|
|
5
|
+
import { createEdgeClient } from './edge-client';
|
|
6
|
+
type EdgeClient = ReturnType<typeof createEdgeClient>;
|
|
7
|
+
/**
|
|
8
|
+
* For tests: provide a pre-built edge client.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fromEdgeClient: (edgeClient: EdgeClient, spaceId?: SpaceId) => Layer.Layer<RemoteOperationInvoker.Service>;
|
|
11
|
+
/**
|
|
12
|
+
* Build from a `Client`, deferring edge-client creation until first invoke
|
|
13
|
+
* (identity may be absent at boot).
|
|
14
|
+
*/
|
|
15
|
+
export declare const fromClient: (client: Client, spaceId?: SpaceId) => Layer.Layer<RemoteOperationInvoker.Service>;
|
|
16
|
+
/**
|
|
17
|
+
* Build from the ambient `ClientService`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const layer: (spaceId?: SpaceId) => Layer.Layer<RemoteOperationInvoker.Service, never, ClientService>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=EdgeOperationInvoker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeOperationInvoker.d.ts","sourceRoot":"","sources":["../../../src/EdgeOperationInvoker.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAYtD;;GAEG;AACH,eAAO,MAAM,cAAc,eACb,UAAU,YACZ,OAAO,KAChB,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAI1C,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,MAAM,YAAY,OAAO,KAAG,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAMxG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,aAAc,OAAO,KAAG,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,CAQvG,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Registry } from '@effect-atom/atom';
|
|
2
|
+
import * as Layer from 'effect/Layer';
|
|
3
|
+
import { type Client } from '@dxos/client';
|
|
4
|
+
import { RemoteProcessManager } from '@dxos/compute-runtime';
|
|
5
|
+
/**
|
|
6
|
+
* Build from a `Client`. Currently ignores the client until an EDGE
|
|
7
|
+
* process-tree endpoint exists.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fromClient: (_client: Client) => Layer.Layer<RemoteProcessManager.Service, never, Registry.AtomRegistry>;
|
|
10
|
+
/**
|
|
11
|
+
* Empty EDGE process manager (no endpoint yet).
|
|
12
|
+
*/
|
|
13
|
+
export declare const layer: Layer.Layer<RemoteProcessManager.Service, never, Registry.AtomRegistry>;
|
|
14
|
+
//# sourceMappingURL=EdgeProcessManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeProcessManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeProcessManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAwB7D;;;GAGG;AACH,eAAO,MAAM,UAAU,YAAa,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAC3G,CAAC;AAET;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAU,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Registry } from '@effect-atom/atom';
|
|
2
|
+
import * as Layer from 'effect/Layer';
|
|
3
|
+
import { type Client, ClientService } from '@dxos/client';
|
|
4
|
+
import { RemoteTriggerManager } from '@dxos/compute-runtime';
|
|
5
|
+
import { type SpaceId } from '@dxos/keys';
|
|
6
|
+
/**
|
|
7
|
+
* Build from a `Client`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fromClient: (_client: Client, spaceId?: SpaceId) => Layer.Layer<RemoteTriggerManager.Service, never, Registry.AtomRegistry>;
|
|
10
|
+
/**
|
|
11
|
+
* Build from the ambient `ClientService`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const layer: (spaceId?: SpaceId) => Layer.Layer<RemoteTriggerManager.Service, never, Registry.AtomRegistry | ClientService>;
|
|
14
|
+
//# sourceMappingURL=EdgeTriggerManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeTriggerManager.d.ts","sourceRoot":"","sources":["../../../src/EdgeTriggerManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAQ,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,MAAM,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AA8B1C;;GAEG;AACH,eAAO,MAAM,UAAU,YACZ,MAAM,YACL,OAAO,KAChB,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAkB,CAAC;AAE5F;;GAEG;AACH,eAAO,MAAM,KAAK,aACN,OAAO,KAChB,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,GAAG,aAAa,CAatF,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Client } from '@dxos/client';
|
|
2
|
+
import { Operation } from '@dxos/compute';
|
|
3
|
+
import { type Context } from '@dxos/context';
|
|
4
|
+
import { type EdgeHttpClient, type TriggersDispatcherStatus } from '@dxos/edge-client';
|
|
5
|
+
import { type EntityId, type SpaceId } from '@dxos/keys';
|
|
6
|
+
import { type FunctionRuntimeKind, type SerializedError } from '@dxos/protocols';
|
|
7
|
+
export type InvokeResult = {
|
|
8
|
+
_kind: 'success';
|
|
9
|
+
/**
|
|
10
|
+
* The output of the function.
|
|
11
|
+
*/
|
|
12
|
+
result: unknown;
|
|
13
|
+
} | {
|
|
14
|
+
_kind: 'error';
|
|
15
|
+
error: SerializedError;
|
|
16
|
+
};
|
|
17
|
+
export type FunctionDeployOptions = {
|
|
18
|
+
name?: string;
|
|
19
|
+
version: string;
|
|
20
|
+
/** Service-side function id in case this function is a re-upload of a previous version. */
|
|
21
|
+
functionId?: string;
|
|
22
|
+
/** Owner identity DID (`did:halo:…`). Must equal the authenticated presenter DID. */
|
|
23
|
+
ownerUri: string;
|
|
24
|
+
runtime?: FunctionRuntimeKind;
|
|
25
|
+
/** Path of the entry point file in the assets table. */
|
|
26
|
+
entryPoint: string;
|
|
27
|
+
assets: {
|
|
28
|
+
[path: string]: Uint8Array;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type FunctionInvokeOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Space in which the function is invoked.
|
|
34
|
+
* Binds the Database.Service injected into the function to this space.
|
|
35
|
+
* Without this, the function will not have access to any database.
|
|
36
|
+
*/
|
|
37
|
+
spaceId?: SpaceId;
|
|
38
|
+
/**
|
|
39
|
+
* CPU time limit in milliseconds.
|
|
40
|
+
* See Cloudflare docs for details.
|
|
41
|
+
*/
|
|
42
|
+
cpuTimeLimit?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum number of subrequests.
|
|
45
|
+
* See Cloudflare docs for details.
|
|
46
|
+
*/
|
|
47
|
+
subrequestsLimit?: number;
|
|
48
|
+
};
|
|
49
|
+
export declare class FunctionsServiceClient {
|
|
50
|
+
#private;
|
|
51
|
+
static fromClient(client: Client): FunctionsServiceClient;
|
|
52
|
+
constructor(edgeClient: EdgeHttpClient);
|
|
53
|
+
/**
|
|
54
|
+
* Deploys a function to the EDGE service.
|
|
55
|
+
*/
|
|
56
|
+
deploy(ctx: Context, request: FunctionDeployOptions): Promise<Operation.PersistentOperation>;
|
|
57
|
+
/**
|
|
58
|
+
* Queries the EDGE service for deployed functions.
|
|
59
|
+
*/
|
|
60
|
+
query(ctx: Context): Promise<Operation.PersistentOperation[]>;
|
|
61
|
+
invoke(ctx: Context, func: Operation.PersistentOperation, input: unknown, options?: FunctionInvokeOptions): Promise<any>;
|
|
62
|
+
forceRunCronTrigger(ctx: Context, spaceId: SpaceId, triggerId: EntityId): Promise<InvokeResult>;
|
|
63
|
+
getTriggersDispatcherStatus(ctx: Context, spaceId: SpaceId): Promise<TriggersDispatcherStatus>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=FunctionsServiceClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionsServiceClient.d.ts","sourceRoot":"","sources":["../../../src/FunctionsServiceClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAiB,SAAS,EAAE,MAAM,eAAe,CAAC;AAGzD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,K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AAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC,CA0BlE;IAEK,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,gBAqB9G;IAEK,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAEpG;IAEK,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEnG;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type Import = {
|
|
2
|
+
moduleUrl: string;
|
|
3
|
+
defaultImport: boolean;
|
|
4
|
+
namedImports: string[];
|
|
5
|
+
};
|
|
6
|
+
export type BundleOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Source code to bundle.
|
|
9
|
+
*/
|
|
10
|
+
source: string;
|
|
11
|
+
};
|
|
12
|
+
export type BundleResult = {
|
|
13
|
+
timestamp: number;
|
|
14
|
+
sourceHash: Buffer;
|
|
15
|
+
error: unknown;
|
|
16
|
+
} | {
|
|
17
|
+
timestamp: number;
|
|
18
|
+
sourceHash: Buffer;
|
|
19
|
+
imports: Import[];
|
|
20
|
+
entryPoint: string;
|
|
21
|
+
assets: Record<string, Uint8Array>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Initializes the bundler.
|
|
25
|
+
* Must be called before using the bundler in browser.
|
|
26
|
+
*/
|
|
27
|
+
export declare const initializeBundler: (options: {
|
|
28
|
+
wasmUrl: string;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* ESBuild bundler implemented as a function (parity with native bundler API style).
|
|
32
|
+
* Bundles source code directly, does not really on filesystem or Node APIs.
|
|
33
|
+
*
|
|
34
|
+
* This is browser friendly version of the bundler, but it could also be used in Node environment.
|
|
35
|
+
* `initializeBundler` should be called before using it in browser, not required in Node.
|
|
36
|
+
*/
|
|
37
|
+
export declare const bundleFunction: ({ source }: BundleOptions) => Promise<BundleResult>;
|
|
38
|
+
//# sourceMappingURL=bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.ts"],"names":[],"mappings":"AAaA,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,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC,CAAC;AAGN;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YAAmB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,kBAInE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,eAAsB,aAAa,KAAG,OAAO,CAAC,YAAY,CA2HpF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.test.d.ts","sourceRoot":"","sources":["../../../../src/bundler/bundler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bundler/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedded-vendored-packages.d.ts","sourceRoot":"","sources":["../../../../../src/bundler/plugins/embedded-vendored-packages.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,eAAO,MAAM,8BAA8B,QAAO,MA6BhD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Plugin } from 'esbuild';
|
|
2
|
+
import { BaseError } from '@dxos/errors';
|
|
3
|
+
declare const HttpPluginError_base: {
|
|
4
|
+
new (options?: import("@dxos/errors").BaseErrorOptions): {
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
stack?: string;
|
|
7
|
+
name: "HttpPluginError";
|
|
8
|
+
context: Record<string, unknown>;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
readonly _tag: "HttpPluginError";
|
|
11
|
+
};
|
|
12
|
+
isError(error: unknown): error is Error;
|
|
13
|
+
name: "HttpPluginError";
|
|
14
|
+
is(error: unknown): error is BaseError;
|
|
15
|
+
wrap(options?: Omit<import("@dxos/errors").BaseErrorOptions, 'cause'> & {
|
|
16
|
+
ifTypeDiffers?: boolean;
|
|
17
|
+
}): (error: unknown) => {
|
|
18
|
+
cause?: unknown;
|
|
19
|
+
stack?: string;
|
|
20
|
+
name: "HttpPluginError";
|
|
21
|
+
context: Record<string, unknown>;
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly _tag: "HttpPluginError";
|
|
24
|
+
};
|
|
25
|
+
extend<Name extends string = string>(name: Name, message?: string): any;
|
|
26
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
27
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
28
|
+
stackTraceLimit: number;
|
|
29
|
+
};
|
|
30
|
+
export declare class HttpPluginError extends HttpPluginError_base {
|
|
31
|
+
}
|
|
32
|
+
export declare const httpPlugin: Plugin;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=http-plugin-esbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-plugin-esbuild.d.ts","sourceRoot":"","sources":["../../../../../src/bundler/plugins/http-plugin-esbuild.ts"],"names":[],"mappings":"AAUA,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKzC,qBAAa,eAAgB,SAAQ,oBAAmC;CAAG;AAU3E,eAAO,MAAM,UAAU,EAAE,MAgDxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/bundler/plugins/index.ts"],"names":[],"mappings":"AAIA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"r2-vendored-packages.d.ts","sourceRoot":"","sources":["../../../../../src/bundler/plugins/r2-vendored-packages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAe3C,eAAO,MAAM,wBAAwB,aAA8C;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,KAAQ,MAezG,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type DID } from 'iso-did/types';
|
|
2
|
+
import { type Client } from '@dxos/client';
|
|
3
|
+
import { Operation } from '@dxos/compute';
|
|
4
|
+
import { Context } from '@dxos/context';
|
|
5
|
+
import { EdgeHttpClient } from '@dxos/edge-client';
|
|
6
|
+
import { type PublicKey, type SpaceId } from '@dxos/keys';
|
|
7
|
+
import { type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
8
|
+
/** @deprecated Use {@link FunctionsServiceClient} instead. */
|
|
9
|
+
export type UploadWorkerArgs = {
|
|
10
|
+
client: Client;
|
|
11
|
+
version: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
functionId?: string;
|
|
14
|
+
/** Owner identity DID (`did:halo:…`). */
|
|
15
|
+
ownerUri: string;
|
|
16
|
+
entryPoint: string;
|
|
17
|
+
assets: Record<string, Uint8Array>;
|
|
18
|
+
};
|
|
19
|
+
/** @deprecated Migrate to `client.edge`. */
|
|
20
|
+
export declare const createEdgeClient: (client: Client) => EdgeHttpClient;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use {@link FunctionsServiceClient} instead.
|
|
23
|
+
*/
|
|
24
|
+
export declare const uploadWorkerFunction: (ctx: Context, { client, version, name, functionId, ownerUri, entryPoint, assets }: UploadWorkerArgs) => Promise<UploadFunctionResponseBody>;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use {@link FunctionsServiceClient} instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getDeployedFunctions: (ctx: Context, client: Client, dedupe?: boolean) => Promise<Operation.PersistentOperation[]>;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use {@link FunctionsServiceClient} instead.
|
|
31
|
+
*/
|
|
32
|
+
export declare const invokeFunction: (ctx: Context, edgeClient: EdgeHttpClient, fn: Operation.PersistentOperation, input: unknown, { spaceId, cpuTimeLimit, subrequestsLimit, }?: {
|
|
33
|
+
spaceId?: SpaceId;
|
|
34
|
+
cpuTimeLimit?: number;
|
|
35
|
+
subrequestsLimit?: number;
|
|
36
|
+
}) => Promise<any>;
|
|
37
|
+
export declare const incrementSemverPatch: (version: string) => string;
|
|
38
|
+
export declare const publicKeyToDid: (key: PublicKey) => DID;
|
|
39
|
+
//# sourceMappingURL=edge-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-client.d.ts","sourceRoot":"","sources":["../../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IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAa3E,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,MAAM,KAAG,MAKtD,CAAC;AAGF,eAAO,MAAM,cAAc,QAAS,SAAS,KAAG,GAE/C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './edge-client';
|
|
2
|
+
export * as EdgeOperationInvoker from './EdgeOperationInvoker';
|
|
3
|
+
export * as EdgeProcessManager from './EdgeProcessManager';
|
|
4
|
+
export * as EdgeTriggerManager from './EdgeTriggerManager';
|
|
5
|
+
export * from './FunctionsServiceClient';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type BundleOptions = {
|
|
2
|
+
entryPoint: string;
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type BundleResult = {
|
|
6
|
+
entryPoint: string;
|
|
7
|
+
assets: Record<string, Uint8Array>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Bundles a function.
|
|
11
|
+
* Pulls in node_modules and wasm files.
|
|
12
|
+
*/
|
|
13
|
+
export declare const bundleFunction: (options: BundleOptions) => Promise<BundleResult>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../src/native/bundler.ts"],"names":[],"mappings":"AAsBA,KAAK,aAAa,GAAG;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAmB,aAAa,KAAG,OAAO,CAAC,YAAY,CAwIjF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/native/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/testing/logger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,WAA8B,CAAC;AAEnE,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,WAItC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type * as Context from 'effect/Context';
|
|
2
|
+
import type { Space } from '@dxos/client/echo';
|
|
3
|
+
import { type Credential, type Trace } from '@dxos/compute';
|
|
4
|
+
import { ServiceContainer } from '@dxos/compute-runtime';
|
|
5
|
+
import { type EchoDatabase } from '@dxos/echo-client';
|
|
6
|
+
export type OneOf<T> = {
|
|
7
|
+
[K in keyof T]: {
|
|
8
|
+
[P in K]: T[P];
|
|
9
|
+
} & {
|
|
10
|
+
[P in Exclude<keyof T, K>]?: never;
|
|
11
|
+
};
|
|
12
|
+
}[keyof T];
|
|
13
|
+
export type AiServiceProvider = 'dev' | 'edge' | 'ollama' | 'lmstudio';
|
|
14
|
+
export type TestServiceOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* AI service configuration.
|
|
17
|
+
*/
|
|
18
|
+
ai?: any;
|
|
19
|
+
/**
|
|
20
|
+
* Credentials service configuration.
|
|
21
|
+
*/
|
|
22
|
+
credentials?: OneOf<{
|
|
23
|
+
/**
|
|
24
|
+
* Predefined credentials list.
|
|
25
|
+
*/
|
|
26
|
+
services?: Credential.ServiceCredential[];
|
|
27
|
+
/**
|
|
28
|
+
* Custom credentials service.
|
|
29
|
+
*/
|
|
30
|
+
service?: Context.Tag.Service<Credential.CredentialsService>;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Database configuration.
|
|
34
|
+
*/
|
|
35
|
+
db?: EchoDatabase;
|
|
36
|
+
/**
|
|
37
|
+
* Gets database service from the space.
|
|
38
|
+
* Exclusive with: `db`
|
|
39
|
+
*/
|
|
40
|
+
space?: Space;
|
|
41
|
+
/**
|
|
42
|
+
* Trace writer configuration.
|
|
43
|
+
*/
|
|
44
|
+
logging?: {
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
trace?: Context.Tag.Service<Trace.TraceService>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated
|
|
51
|
+
*/
|
|
52
|
+
export declare const createTestServices: ({ ai, credentials, db, logging, space, }?: TestServiceOptions) => ServiceContainer;
|
|
53
|
+
//# sourceMappingURL=services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../../../src/testing/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,KAAK,EAA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