@dxos/functions 0.7.4 → 0.7.5-labs.071a3e2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/lib/browser/{chunk-Y2OPAP26.mjs → chunk-FTGUA7ZJ.mjs} +2 -2
  2. package/dist/lib/browser/chunk-R4ERZ4GX.mjs +162 -0
  3. package/dist/lib/browser/chunk-R4ERZ4GX.mjs.map +7 -0
  4. package/dist/lib/browser/chunk-XRCXIG74.mjs +12 -0
  5. package/dist/lib/browser/chunk-YJEIETRB.mjs +128 -0
  6. package/dist/lib/browser/chunk-YJEIETRB.mjs.map +7 -0
  7. package/dist/lib/browser/edge/index.mjs +21 -0
  8. package/dist/lib/browser/index.mjs +27 -6
  9. package/dist/lib/browser/index.mjs.map +2 -2
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/testing/index.mjs +5 -3
  12. package/dist/lib/browser/testing/index.mjs.map +1 -1
  13. package/dist/lib/browser/{types.mjs → types/index.mjs} +7 -2
  14. package/dist/lib/browser/types/index.mjs.map +7 -0
  15. package/dist/lib/node/chunk-4WNFTPH7.cjs +188 -0
  16. package/dist/lib/node/chunk-4WNFTPH7.cjs.map +7 -0
  17. package/dist/lib/node/chunk-JEQ2X3Z6.cjs +34 -0
  18. package/dist/lib/node/chunk-JEQ2X3Z6.cjs.map +7 -0
  19. package/dist/lib/node/chunk-MZMHE4DC.cjs +154 -0
  20. package/dist/lib/node/chunk-MZMHE4DC.cjs.map +7 -0
  21. package/dist/lib/node/{chunk-CCULBUSE.cjs → chunk-NC6L7H5C.cjs} +15 -15
  22. package/dist/lib/node/edge/index.cjs +42 -0
  23. package/dist/lib/node/edge/index.cjs.map +7 -0
  24. package/dist/lib/node/index.cjs +38 -18
  25. package/dist/lib/node/index.cjs.map +2 -2
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/testing/index.cjs +11 -10
  28. package/dist/lib/node/testing/index.cjs.map +1 -1
  29. package/dist/lib/node/{types.cjs → types/index.cjs} +14 -9
  30. package/dist/lib/node/types/index.cjs.map +7 -0
  31. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs +12 -0
  32. package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-GGGGWYP6.mjs → chunk-FK2RGYVS.mjs} +2 -2
  34. package/dist/lib/node-esm/chunk-T2KBXTMR.mjs +128 -0
  35. package/dist/lib/node-esm/chunk-T2KBXTMR.mjs.map +7 -0
  36. package/dist/lib/node-esm/chunk-UOQLFLOW.mjs +162 -0
  37. package/dist/lib/node-esm/chunk-UOQLFLOW.mjs.map +7 -0
  38. package/dist/lib/node-esm/edge/index.mjs +21 -0
  39. package/dist/lib/node-esm/edge/index.mjs.map +7 -0
  40. package/dist/lib/node-esm/index.mjs +27 -6
  41. package/dist/lib/node-esm/index.mjs.map +2 -2
  42. package/dist/lib/node-esm/meta.json +1 -1
  43. package/dist/lib/node-esm/testing/index.mjs +5 -3
  44. package/dist/lib/node-esm/testing/index.mjs.map +1 -1
  45. package/dist/lib/node-esm/{types.mjs → types/index.mjs} +7 -2
  46. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  47. package/dist/types/src/edge/functions.d.ts +25 -0
  48. package/dist/types/src/edge/functions.d.ts.map +1 -0
  49. package/dist/types/src/edge/index.d.ts +2 -0
  50. package/dist/types/src/edge/index.d.ts.map +1 -0
  51. package/dist/types/src/handler.d.ts.map +1 -1
  52. package/dist/types/src/index.d.ts +1 -0
  53. package/dist/types/src/index.d.ts.map +1 -1
  54. package/dist/types/src/testing/types.d.ts +3 -5
  55. package/dist/types/src/testing/types.d.ts.map +1 -1
  56. package/dist/types/src/translations.d.ts +9 -0
  57. package/dist/types/src/translations.d.ts.map +1 -0
  58. package/dist/types/src/types/index.d.ts +3 -0
  59. package/dist/types/src/types/index.d.ts.map +1 -0
  60. package/dist/types/src/types/schema.d.ts +57 -0
  61. package/dist/types/src/types/schema.d.ts.map +1 -0
  62. package/dist/types/src/{types.d.ts → types/types.d.ts} +76 -75
  63. package/dist/types/src/types/types.d.ts.map +1 -0
  64. package/dist/types/tsconfig.tsbuildinfo +1 -0
  65. package/package.json +27 -20
  66. package/src/edge/functions.ts +120 -0
  67. package/src/edge/index.ts +5 -0
  68. package/src/handler.ts +1 -0
  69. package/src/index.ts +1 -0
  70. package/src/translations.ts +15 -0
  71. package/src/trigger/trigger-registry.test.ts +3 -1
  72. package/src/types/index.ts +6 -0
  73. package/src/types/schema.ts +46 -0
  74. package/src/{types.ts → types/types.ts} +8 -0
  75. package/dist/lib/browser/chunk-N5D5R4Q4.mjs +0 -129
  76. package/dist/lib/browser/chunk-N5D5R4Q4.mjs.map +0 -7
  77. package/dist/lib/node/chunk-JMJCJ3SA.cjs +0 -156
  78. package/dist/lib/node/chunk-JMJCJ3SA.cjs.map +0 -7
  79. package/dist/lib/node/types.cjs.map +0 -7
  80. package/dist/lib/node-esm/chunk-2NACE6MJ.mjs +0 -129
  81. package/dist/lib/node-esm/chunk-2NACE6MJ.mjs.map +0 -7
  82. package/dist/types/src/types.d.ts.map +0 -1
  83. /package/dist/lib/browser/{chunk-Y2OPAP26.mjs.map → chunk-FTGUA7ZJ.mjs.map} +0 -0
  84. /package/dist/lib/browser/{types.mjs.map → chunk-XRCXIG74.mjs.map} +0 -0
  85. /package/dist/lib/{node-esm/types.mjs.map → browser/edge/index.mjs.map} +0 -0
  86. /package/dist/lib/node/{chunk-CCULBUSE.cjs.map → chunk-NC6L7H5C.cjs.map} +0 -0
  87. /package/dist/lib/node-esm/{chunk-GGGGWYP6.mjs.map → chunk-FK2RGYVS.mjs.map} +0 -0
@@ -37,8 +37,9 @@ __export(testing_exports, {
37
37
  triggerWebhook: () => triggerWebhook
38
38
  });
39
39
  module.exports = __toCommonJS(testing_exports);
40
- var import_chunk_CCULBUSE = require("../chunk-CCULBUSE.cjs");
41
- var import_chunk_JMJCJ3SA = require("../chunk-JMJCJ3SA.cjs");
40
+ var import_chunk_NC6L7H5C = require("../chunk-NC6L7H5C.cjs");
41
+ var import_chunk_4WNFTPH7 = require("../chunk-4WNFTPH7.cjs");
42
+ var import_chunk_JEQ2X3Z6 = require("../chunk-JEQ2X3Z6.cjs");
42
43
  var import_get_port_please = require("get-port-please");
43
44
  var import_node_path = __toESM(require("node:path"));
44
45
  var import_async = require("@dxos/async");
@@ -276,11 +277,11 @@ var DevServer = class {
276
277
  C: (f, a) => f(...a)
277
278
  });
278
279
  if (force) {
279
- Object.keys(import_chunk_JMJCJ3SA.__require.cache).filter((key) => key.startsWith(filePath)).forEach((key) => {
280
- delete import_chunk_JMJCJ3SA.__require.cache[key];
280
+ Object.keys(import_chunk_JEQ2X3Z6.__require.cache).filter((key) => key.startsWith(filePath)).forEach((key) => {
281
+ delete import_chunk_JEQ2X3Z6.__require.cache[key];
281
282
  });
282
283
  }
283
- const module2 = (0, import_chunk_JMJCJ3SA.__require)(filePath);
284
+ const module2 = (0, import_chunk_JEQ2X3Z6.__require)(filePath);
284
285
  if (typeof module2.default !== "function") {
285
286
  throw new Error(`Handler must export default function: ${uri}`);
286
287
  }
@@ -571,8 +572,8 @@ var createInitializedClients = async (testBuilder, count = 1, config) => {
571
572
  config,
572
573
  services: testBuilder.createLocalClientServices(),
573
574
  types: [
574
- import_chunk_JMJCJ3SA.FunctionDef,
575
- import_chunk_JMJCJ3SA.FunctionTrigger,
575
+ import_chunk_4WNFTPH7.FunctionDef,
576
+ import_chunk_4WNFTPH7.FunctionTrigger,
576
577
  TestType
577
578
  ]
578
579
  }));
@@ -609,7 +610,7 @@ var createFunctionRuntime = async (testBuilder, pluginInitializer) => {
609
610
  };
610
611
  var startFunctionsHost = async (testBuilder, pluginInitializer, options) => {
611
612
  const functionRuntime = await createFunctionRuntime(testBuilder, pluginInitializer);
612
- const functionsRegistry = new import_chunk_CCULBUSE.FunctionRegistry(functionRuntime);
613
+ const functionsRegistry = new import_chunk_NC6L7H5C.FunctionRegistry(functionRuntime);
613
614
  const devServer = await startDevServer(testBuilder, functionRuntime, functionsRegistry, options);
614
615
  const scheduler = await startScheduler(testBuilder, functionRuntime, devServer, functionsRegistry);
615
616
  return {
@@ -623,7 +624,7 @@ var startFunctionsHost = async (testBuilder, pluginInitializer, options) => {
623
624
  };
624
625
  };
625
626
  var startScheduler = async (testBuilder, client, devServer, functionRegistry) => {
626
- const triggerRegistry = new import_chunk_CCULBUSE.TriggerRegistry(client);
627
+ const triggerRegistry = new import_chunk_NC6L7H5C.TriggerRegistry(client);
627
628
  const scheduler = new Scheduler(functionRegistry, triggerRegistry, {
628
629
  endpoint: devServer.endpoint
629
630
  });
@@ -643,7 +644,7 @@ var startDevServer = async (testBuilder, client, functionRegistry, options) => {
643
644
  };
644
645
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/functions/src/testing/util.ts";
645
646
  var triggerWebhook = async (space, uri) => {
646
- const trigger = (await space.db.query(import_echo2.Filter.schema(import_chunk_JMJCJ3SA.FunctionTrigger, (trigger2) => trigger2.function === uri)).run()).objects[0];
647
+ const trigger = (await space.db.query(import_echo2.Filter.schema(import_chunk_4WNFTPH7.FunctionTrigger, (trigger2) => trigger2.function === uri)).run()).objects[0];
647
648
  (0, import_invariant2.invariant)(trigger.spec?.type === "webhook", void 0, {
648
649
  F: __dxlog_file3,
649
650
  L: 17,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/testing/setup.ts", "../../../../src/testing/types.ts", "../../../../src/runtime/dev-server.ts", "../../../../src/runtime/scheduler.ts", "../../../../src/testing/util.ts", "../../../../src/testing/manifest.ts"],
4
4
  "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { getRandomPort } from 'get-port-please';\nimport path from 'node:path';\n\nimport { waitForCondition } from '@dxos/async';\nimport { Client, Config } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { type TestBuilder } from '@dxos/client/testing';\nimport { range } from '@dxos/util';\n\nimport { TestType } from './types';\nimport { FunctionRegistry } from '../function';\nimport { DevServer, type DevServerOptions, Scheduler } from '../runtime';\nimport { TriggerRegistry } from '../trigger';\nimport { FunctionDef, FunctionTrigger } from '../types';\n\nexport type FunctionsPluginInitializer = (client: Client) => Promise<{ close: () => Promise<void> }>;\n\n// TODO(burdon): Extend/wrap TestBuilder.\n\nexport const createInitializedClients = async (testBuilder: TestBuilder, count: number = 1, config?: Config) => {\n const clients = range(count).map(\n () =>\n new Client({\n config,\n services: testBuilder.createLocalClientServices(),\n types: [FunctionDef, FunctionTrigger, TestType],\n }),\n );\n\n testBuilder.ctx.onDispose(() => Promise.all(clients.map((client) => client.destroy())));\n return Promise.all(\n clients.map(async (client, index) => {\n await client.initialize();\n await client.halo.createIdentity({ displayName: `Peer ${index}` });\n await client.spaces.waitUntilReady();\n return client;\n }),\n );\n};\n\nexport const createFunctionRuntime = async (\n testBuilder: TestBuilder,\n pluginInitializer: FunctionsPluginInitializer,\n): Promise<Client> => {\n const functionsPort = await getRandomPort('127.0.0.1');\n const config = new Config({\n runtime: {\n agent: {\n plugins: [{ id: 'dxos.org/agent/plugin/functions', config: { port: functionsPort } }],\n },\n },\n });\n\n const [client] = await createInitializedClients(testBuilder, 1, config);\n const plugin = await pluginInitializer(client);\n testBuilder.ctx.onDispose(() => plugin.close());\n return client;\n};\n\nexport const startFunctionsHost = async (\n testBuilder: TestBuilder,\n pluginInitializer: FunctionsPluginInitializer,\n options?: DevServerOptions,\n) => {\n const functionRuntime = await createFunctionRuntime(testBuilder, pluginInitializer);\n const functionsRegistry = new FunctionRegistry(functionRuntime);\n const devServer = await startDevServer(testBuilder, functionRuntime, functionsRegistry, options);\n const scheduler = await startScheduler(testBuilder, functionRuntime, devServer, functionsRegistry);\n return {\n scheduler,\n client: functionRuntime,\n waitForActiveTriggers: async (space: Space) => {\n await waitForCondition({ condition: () => scheduler.triggers.getActiveTriggers(space).length > 0 });\n },\n };\n};\n\nconst startScheduler = async (\n testBuilder: TestBuilder,\n client: Client,\n devServer: DevServer,\n functionRegistry: FunctionRegistry,\n) => {\n const triggerRegistry = new TriggerRegistry(client);\n const scheduler = new Scheduler(functionRegistry, triggerRegistry, { endpoint: devServer.endpoint });\n await scheduler.start();\n testBuilder.ctx.onDispose(() => scheduler.stop());\n return scheduler;\n};\n\nconst startDevServer = async (\n testBuilder: TestBuilder,\n client: Client,\n functionRegistry: FunctionRegistry,\n options?: { baseDir?: string },\n) => {\n const server = new DevServer(client, functionRegistry, {\n baseDir: path.join(__dirname, '../testing'),\n port: await getRandomPort('127.0.0.1'),\n ...options,\n });\n await server.start();\n testBuilder.ctx.onDispose(() => server.stop());\n return server;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\nexport class TestType extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({\n title: S.String,\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport express from 'express';\nimport { getPort } from 'get-port-please';\nimport type http from 'http';\nimport { join } from 'node:path';\n\nimport { asyncTimeout, Event, Trigger } from '@dxos/async';\nimport { type Client } from '@dxos/client';\nimport { Context } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FunctionRegistry } from '../function';\nimport { type FunctionContext, type FunctionEvent, type FunctionHandler, type FunctionResponse } from '../handler';\nimport { type FunctionDef } from '../types';\n\nconst FN_TIMEOUT = 20_000;\n\nexport type DevServerOptions = {\n baseDir: string;\n port?: number;\n reload?: boolean;\n dataDir?: string;\n};\n\n/**\n * Functions dev server provides a local HTTP server for loading and invoking functions.\n * Functions are executed in the context of an authenticated client.\n */\nexport class DevServer {\n private _ctx = createContext();\n\n // Function handlers indexed by name (URL path).\n private readonly _handlers: Record<string, { def: FunctionDef; handler: FunctionHandler<any> }> = {};\n\n private _server?: http.Server;\n private _port?: number;\n private _functionServiceRegistration?: string;\n private _proxy?: string;\n private _seq = 0;\n\n public readonly update = new Event<number>();\n\n constructor(\n private readonly _client: Client,\n private readonly _functionsRegistry: FunctionRegistry,\n private readonly _options: DevServerOptions,\n ) {}\n\n get stats() {\n return {\n seq: this._seq,\n };\n }\n\n get endpoint() {\n invariant(this._port);\n return `http://localhost:${this._port}`;\n }\n\n get proxy() {\n return this._proxy;\n }\n\n get functions() {\n return Object.values(this._handlers);\n }\n\n async start() {\n invariant(!this._server);\n log.info('starting...');\n this._ctx = createContext();\n\n // TODO(burdon): Change to hono.\n const app = express();\n app.use(express.json());\n\n app.post('/:path', async (req, res) => {\n const { path } = req.params;\n try {\n log.info('calling', { path });\n if (this._options.reload) {\n const { def } = this._handlers['/' + path];\n await this._load(def, true);\n }\n\n // TODO(burdon): Get function context.\n res.statusCode = await asyncTimeout(this.invoke('/' + path, req.body), FN_TIMEOUT);\n res.end();\n } catch (err: any) {\n log.catch(err);\n res.statusCode = 500;\n res.end();\n }\n });\n\n this._port = this._options.port ?? (await getPort({ host: 'localhost', port: 7200, portRange: [7200, 7299] }));\n this._server = app.listen(this._port);\n\n try {\n // Register functions.\n const { registrationId, endpoint } = await this._client.services.services.FunctionRegistryService!.register({\n endpoint: this.endpoint,\n });\n\n log.info('registered', { endpoint });\n this._proxy = endpoint;\n this._functionServiceRegistration = registrationId;\n\n // Open after registration, so that it can be updated with the list of function definitions.\n await this._handleNewFunctions(this._functionsRegistry.getUniqueByUri());\n this._ctx.onDispose(this._functionsRegistry.registered.on(({ added }) => this._handleNewFunctions(added)));\n } catch (err: any) {\n await this.stop();\n throw new Error('FunctionRegistryService not available (check plugin is configured).');\n }\n\n log.info('started', { port: this._port });\n }\n\n async stop() {\n if (!this._server) {\n return;\n }\n\n log.info('stopping...');\n await this._ctx.dispose();\n\n const trigger = new Trigger();\n this._server.close(async () => {\n log.info('server stopped');\n try {\n if (this._functionServiceRegistration) {\n invariant(this._client.services.services.FunctionRegistryService);\n await this._client.services.services.FunctionRegistryService.unregister({\n registrationId: this._functionServiceRegistration,\n });\n\n log.info('unregistered', { registrationId: this._functionServiceRegistration });\n this._functionServiceRegistration = undefined;\n this._proxy = undefined;\n }\n\n trigger.wake();\n } catch (err) {\n trigger.throw(err as Error);\n }\n });\n\n await trigger.wait();\n this._port = undefined;\n this._server = undefined;\n log.info('stopped');\n }\n\n private async _handleNewFunctions(newFunctions: FunctionDef[]) {\n newFunctions.forEach((def) => this._load(def));\n await this._safeUpdateRegistration();\n log('new functions loaded', { newFunctions });\n }\n\n /**\n * Load function.\n */\n private async _load(def: FunctionDef, force?: boolean | undefined) {\n const { uri, route, handler } = def;\n const filePath = join(this._options.baseDir, handler);\n log.info('loading', { uri, force });\n\n // Remove from cache.\n if (force) {\n Object.keys(require.cache)\n .filter((key) => key.startsWith(filePath))\n .forEach((key) => {\n delete require.cache[key];\n });\n }\n\n // TODO(burdon): Import types.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const module = require(filePath);\n if (typeof module.default !== 'function') {\n throw new Error(`Handler must export default function: ${uri}`);\n }\n\n this._handlers[route] = { def, handler: module.default };\n }\n\n private async _safeUpdateRegistration(): Promise<void> {\n invariant(this._functionServiceRegistration);\n try {\n await this._client.services.services.FunctionRegistryService!.updateRegistration({\n registrationId: this._functionServiceRegistration,\n functions: this.functions.map(({ def: { id, route } }) => ({ id, route })),\n });\n } catch (err) {\n log.catch(err);\n }\n }\n\n /**\n * Invoke function.\n */\n public async invoke(path: string, data: any): Promise<number> {\n const seq = ++this._seq;\n const now = Date.now();\n\n log.info('req', { seq, path });\n const statusCode = await this._invoke(path, { data });\n\n log.info('res', { seq, path, statusCode, duration: Date.now() - now });\n this.update.emit(statusCode);\n return statusCode;\n }\n\n private async _invoke(path: string, event: FunctionEvent) {\n const { handler } = this._handlers[path] ?? {};\n invariant(handler, `invalid path: ${path}`);\n const context: FunctionContext = {\n client: this._client,\n dataDir: this._options.dataDir,\n } as any;\n\n let statusCode = 200;\n const response: FunctionResponse = {\n status: (code: number) => {\n statusCode = code;\n return response;\n },\n };\n\n await handler({ context, event, response });\n return statusCode;\n }\n}\n\nconst createContext = () => new Context({ name: 'DevServer' });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport path from 'node:path';\n\nimport { Mutex } from '@dxos/async';\nimport { loadObjectReferences, type Space } from '@dxos/client/echo';\nimport { Context } from '@dxos/context';\nimport { Reference } from '@dxos/echo-protocol';\nimport { log } from '@dxos/log';\n\nimport { type FunctionRegistry } from '../function';\nimport { type FunctionEventMeta } from '../handler';\nimport { type TriggerCallback, type TriggerRegistry } from '../trigger';\nimport { type FunctionDef, type FunctionManifest, type FunctionTrigger } from '../types';\n\nexport type Callback = (data: any) => Promise<void | number>;\n\nexport type SchedulerOptions = {\n endpoint?: string;\n callback?: Callback;\n};\n\n/**\n * The scheduler triggers function execution based on various trigger configurations.\n * Functions are scheduled within the context of a specific space.\n */\nexport class Scheduler {\n private _ctx = createContext();\n\n private readonly _functionUriToCallMutex = new Map<string, Mutex>();\n\n constructor(\n public readonly functions: FunctionRegistry,\n public readonly triggers: TriggerRegistry,\n private readonly _options: SchedulerOptions = {},\n ) {\n this.functions.registered.on(async ({ space, added }) => {\n await this._safeActivateTriggers(space, this.triggers.getInactiveTriggers(space), added);\n });\n this.triggers.registered.on(async ({ space, triggers }) => {\n await this._safeActivateTriggers(space, triggers, this.functions.getFunctions(space));\n });\n }\n\n async start() {\n await this._ctx.dispose();\n this._ctx = createContext();\n await this.functions.open(this._ctx);\n await this.triggers.open(this._ctx);\n }\n\n async stop() {\n await this._ctx.dispose();\n await this.functions.close();\n await this.triggers.close();\n }\n\n // TODO(burdon): Remove and update registries directly?\n public async register(space: Space, manifest: FunctionManifest) {\n await this.functions.register(space, manifest.functions);\n await this.triggers.register(space, manifest);\n }\n\n private async _safeActivateTriggers(\n space: Space,\n triggers: FunctionTrigger[],\n functions: FunctionDef[],\n ): Promise<void> {\n const mountTasks = triggers.map((trigger) => {\n return this.activate(space, functions, trigger);\n });\n\n await Promise.all(mountTasks).catch(log.catch);\n }\n\n /**\n * Activate trigger.\n */\n // TODO(burdon): How are triggers deactivated?\n private async activate(space: Space, functions: FunctionDef[], trigger: FunctionTrigger) {\n const definition = functions.find((def) => def.uri === trigger.function);\n if (!definition) {\n log.info('function is not found for trigger', { trigger });\n return;\n }\n\n const execFunction: TriggerCallback = async (args) => {\n const mutex = this._functionUriToCallMutex.get(definition.uri) ?? new Mutex();\n this._functionUriToCallMutex.set(definition.uri, mutex);\n\n log.info('function triggered, waiting for mutex', { uri: definition.uri });\n return mutex.executeSynchronized(async () => {\n log.info('mutex acquired', { uri: definition.uri });\n\n // Load potential references in meta properties to serialize.\n await loadObjectReferences(trigger, (t) => Object.values(t.meta ?? {}));\n const meta: FunctionTrigger['meta'] = {};\n for (const [key, value] of Object.entries(trigger.meta ?? {})) {\n if (value instanceof Reference) {\n const object = await space.db.query({ id: value.objectId }).first();\n if (object) {\n meta[key] = object;\n }\n } else {\n meta[key] = value;\n }\n }\n\n return this._execFunction(definition, trigger, {\n meta,\n data: { ...args, spaceKey: space.key },\n });\n });\n };\n\n await this.triggers.activate(space, trigger, execFunction);\n log('activated trigger', { space: space.key, trigger });\n }\n\n /**\n * Invoke function RPC.\n */\n private async _execFunction<TData, TMeta>(\n def: FunctionDef,\n trigger: FunctionTrigger,\n { meta, data }: { meta?: TMeta; data: TData },\n ): Promise<number> {\n let status = 0;\n try {\n // TODO(burdon): Pass in Space key (common context)?\n const payload = Object.assign({}, meta && ({ meta } satisfies FunctionEventMeta<TMeta>), data);\n\n const { endpoint, callback } = this._options;\n if (endpoint) {\n // TODO(burdon): Move out of scheduler (generalize as callback).\n const url = path.join(endpoint, def.route);\n log.info('exec', { function: def.uri, url, triggerType: trigger.spec?.type });\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n status = response.status;\n } else if (callback) {\n log.info('exec', { function: def.uri });\n status = (await callback(payload)) ?? 200;\n }\n\n // Check errors.\n if (status && status >= 400) {\n throw new Error(`Response: ${status}`);\n }\n\n // const result = await response.json();\n log.info('done', { function: def.uri, status });\n } catch (err: any) {\n log.error('error', { function: def.uri, error: err.message });\n status = 500;\n }\n\n return status;\n }\n}\n\nconst createContext = () => new Context({ name: 'FunctionScheduler' });\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Client } from '@dxos/client';\nimport { Filter, type Space } from '@dxos/client/echo';\nimport { performInvitation } from '@dxos/client/testing';\nimport { invariant } from '@dxos/invariant';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\n\nimport { FunctionTrigger } from '../types';\n\nexport const triggerWebhook = async (space: Space, uri: string) => {\n const trigger = (\n await space.db.query(Filter.schema(FunctionTrigger, (trigger: FunctionTrigger) => trigger.function === uri)).run()\n ).objects[0];\n invariant(trigger.spec?.type === 'webhook');\n void fetch(`http://localhost:${trigger.spec.port}`);\n};\n\nexport const inviteMember = async (host: Space, guest: Client) => {\n const [{ invitation: hostInvitation }] = await Promise.all(performInvitation({ host, guest: guest.spaces }));\n if (hostInvitation?.state !== Invitation.State.SUCCESS) {\n throw new Error(`Expected ${hostInvitation?.state} to be ${Invitation.State.SUCCESS}.`);\n }\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { FunctionManifest } from '../types';\n\nexport const testFunctionManifest: FunctionManifest = {\n functions: [\n {\n uri: 'example.com/function/test',\n route: 'test',\n handler: 'test',\n },\n ],\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,6BAA8B;AAC9B,uBAAiB;AAEjB,mBAAiC;AACjC,oBAA+B;AAG/B,kBAAsB;ACPtB,yBAA+B;ACA/B,qBAAoB;AACpB,IAAAA,0BAAwB;AAExB,IAAAC,oBAAqB;AAErB,IAAAC,gBAA6C;AAE7C,qBAAwB;AACxB,uBAA0B;AAC1B,iBAAoB;ACTpB,IAAAD,oBAAiB;AAEjB,IAAAC,gBAAsB;AACtB,kBAAiD;AACjD,IAAAC,kBAAwB;AACxB,2BAA0B;AA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B,CAACzG,aAA6BA,SAAQ4D,aAAahD,GAAAA,CAAAA,EAAMsI,IAAG,GAChHC,QAAQ,CAAA;AACVpM,wBAAAA,WAAUiD,QAAQsF,MAAMC,SAAS,WAAA,QAAA;;;;;;;;;AACjC,OAAKC,MAAM,oBAAoBxF,QAAQsF,KAAKzG,IAAI,EAAE;AACpD;AAEO,IAAMuK,eAAe,OAAOrK,MAAasK,UAAAA;AAC9C,QAAM,CAAC,EAAEC,YAAYC,eAAc,CAAE,IAAI,MAAM/F,QAAQC,QAAI+F,kCAAkB;IAAEzK;IAAMsK,OAAOA,MAAMpC;EAAO,CAAA,CAAA;AACzG,MAAIsC,gBAAgBE,UAAUC,2BAAWC,MAAMC,SAAS;AACtD,UAAM,IAAI9J,MAAM,YAAYyJ,gBAAgBE,KAAAA,UAAeC,2BAAWC,MAAMC,OAAO,GAAG;EACxF;AACF;ACnBO,IAAMC,uBAAyC;EACpD1M,WAAW;IACT;MACEyD,KAAK;MACLC,OAAO;MACPC,SAAS;IACX;;AAEJ;",
6
6
  "names": ["import_get_port_please", "import_node_path", "import_async", "import_context", "import_log", "import_echo", "import_invariant", "TestType", "TypedObject", "typename", "version", "title", "S", "String", "FN_TIMEOUT", "DevServer", "constructor", "_client", "_functionsRegistry", "_options", "_ctx", "createContext", "_handlers", "_seq", "update", "Event", "stats", "seq", "endpoint", "invariant", "_port", "proxy", "_proxy", "functions", "Object", "values", "start", "_server", "log", "info", "app", "express", "use", "json", "post", "req", "res", "path", "params", "reload", "def", "_load", "statusCode", "asyncTimeout", "invoke", "body", "end", "err", "catch", "port", "getPort", "host", "portRange", "listen", "registrationId", "services", "FunctionRegistryService", "register", "_functionServiceRegistration", "_handleNewFunctions", "getUniqueByUri", "onDispose", "registered", "on", "added", "stop", "Error", "dispose", "trigger", "Trigger", "close", "unregister", "undefined", "wake", "throw", "wait", "newFunctions", "forEach", "_safeUpdateRegistration", "force", "uri", "route", "handler", "filePath", "join", "baseDir", "keys", "require", "cache", "filter", "key", "startsWith", "module", "default", "updateRegistration", "map", "id", "data", "now", "Date", "_invoke", "duration", "emit", "event", "context", "client", "dataDir", "response", "status", "code", "Context", "name", "Scheduler", "triggers", "_functionUriToCallMutex", "Map", "space", "_safeActivateTriggers", "getInactiveTriggers", "getFunctions", "open", "manifest", "mountTasks", "activate", "Promise", "all", "definition", "find", "function", "execFunction", "args", "mutex", "get", "Mutex", "set", "executeSynchronized", "loadObjectReferences", "t", "meta", "value", "entries", "Reference", "object", "db", "query", "objectId", "first", "_execFunction", "spaceKey", "payload", "assign", "callback", "url", "triggerType", "spec", "type", "fetch", "method", "headers", "JSON", "stringify", "error", "message", "createInitializedClients", "testBuilder", "count", "config", "clients", "range", "Client", "createLocalClientServices", "types", "FunctionDef", "FunctionTrigger", "ctx", "destroy", "index", "initialize", "halo", "createIdentity", "displayName", "spaces", "waitUntilReady", "createFunctionRuntime", "pluginInitializer", "functionsPort", "getRandomPort", "Config", "runtime", "agent", "plugins", "plugin", "startFunctionsHost", "options", "functionRuntime", "functionsRegistry", "FunctionRegistry", "devServer", "startDevServer", "scheduler", "startScheduler", "waitForActiveTriggers", "waitForCondition", "condition", "getActiveTriggers", "length", "functionRegistry", "triggerRegistry", "TriggerRegistry", "server", "__dirname", "triggerWebhook", "Filter", "schema", "run", "objects", "inviteMember", "guest", "invitation", "hostInvitation", "performInvitation", "state", "Invitation", "State", "SUCCESS", "testFunctionManifest"]
7
7
  }
@@ -18,16 +18,19 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
- FUNCTION_TYPES: () => import_chunk_JMJCJ3SA.FUNCTION_TYPES,
22
- FunctionDef: () => import_chunk_JMJCJ3SA.FunctionDef,
23
- FunctionManifestSchema: () => import_chunk_JMJCJ3SA.FunctionManifestSchema,
24
- FunctionTrigger: () => import_chunk_JMJCJ3SA.FunctionTrigger,
25
- FunctionTriggerSchema: () => import_chunk_JMJCJ3SA.FunctionTriggerSchema,
26
- TriggerKind: () => import_chunk_JMJCJ3SA.TriggerKind,
27
- TriggerSchema: () => import_chunk_JMJCJ3SA.TriggerSchema
21
+ FUNCTION_TYPES: () => import_chunk_4WNFTPH7.FUNCTION_TYPES,
22
+ FunctionDef: () => import_chunk_4WNFTPH7.FunctionDef,
23
+ FunctionManifestSchema: () => import_chunk_4WNFTPH7.FunctionManifestSchema,
24
+ FunctionTrigger: () => import_chunk_4WNFTPH7.FunctionTrigger,
25
+ FunctionTriggerSchema: () => import_chunk_4WNFTPH7.FunctionTriggerSchema,
26
+ FunctionType: () => import_chunk_4WNFTPH7.FunctionType,
27
+ ScriptType: () => import_chunk_4WNFTPH7.ScriptType,
28
+ TriggerKind: () => import_chunk_4WNFTPH7.TriggerKind,
29
+ TriggerSchema: () => import_chunk_4WNFTPH7.TriggerSchema
28
30
  });
29
31
  module.exports = __toCommonJS(types_exports);
30
- var import_chunk_JMJCJ3SA = require("./chunk-JMJCJ3SA.cjs");
32
+ var import_chunk_4WNFTPH7 = require("../chunk-4WNFTPH7.cjs");
33
+ var import_chunk_JEQ2X3Z6 = require("../chunk-JEQ2X3Z6.cjs");
31
34
  // Annotate the CommonJS export names for ESM import in node:
32
35
  0 && (module.exports = {
33
36
  FUNCTION_TYPES,
@@ -35,7 +38,9 @@ var import_chunk_JMJCJ3SA = require("./chunk-JMJCJ3SA.cjs");
35
38
  FunctionManifestSchema,
36
39
  FunctionTrigger,
37
40
  FunctionTriggerSchema,
41
+ FunctionType,
42
+ ScriptType,
38
43
  TriggerKind,
39
44
  TriggerSchema
40
45
  });
41
- //# sourceMappingURL=types.cjs.map
46
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.cjs"],
4
+ "sourcesContent": ["import {\n FUNCTION_TYPES,\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger,\n FunctionTriggerSchema,\n FunctionType,\n ScriptType,\n TriggerKind,\n TriggerSchema\n} from \"../chunk-4WNFTPH7.cjs\";\nimport \"../chunk-JEQ2X3Z6.cjs\";\nexport {\n FUNCTION_TYPES,\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger,\n FunctionTriggerSchema,\n FunctionType,\n ScriptType,\n TriggerKind,\n TriggerSchema\n};\n//# sourceMappingURL=index.cjs.map\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAUO;AACP,4BAAO;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ export {
10
+ __require
11
+ };
12
+ //# sourceMappingURL=chunk-DHGBFXSZ.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
2
2
  import {
3
3
  FunctionDef,
4
4
  FunctionTrigger
5
- } from "./chunk-2NACE6MJ.mjs";
5
+ } from "./chunk-UOQLFLOW.mjs";
6
6
 
7
7
  // packages/core/functions/src/function/function-registry.ts
8
8
  import { Event } from "@dxos/async";
@@ -477,4 +477,4 @@ export {
477
477
  createTimerTrigger,
478
478
  TriggerRegistry
479
479
  };
480
- //# sourceMappingURL=chunk-GGGGWYP6.mjs.map
480
+ //# sourceMappingURL=chunk-FK2RGYVS.mjs.map
@@ -0,0 +1,128 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/core/functions/src/edge/functions.ts
4
+ import { EdgeHttpClient } from "@dxos/edge-client";
5
+ import { invariant } from "@dxos/invariant";
6
+ import { log } from "@dxos/log";
7
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/edge/functions.ts";
8
+ var FUNCTIONS_META_KEY = "dxos.org/service/function";
9
+ var FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
10
+ var uploadWorkerFunction = async ({ client, name, version, source, spaceId, functionId }) => {
11
+ const edgeUrl = client.config.values.runtime?.services?.edge?.url;
12
+ invariant(edgeUrl, "Edge is not configured.", {
13
+ F: __dxlog_file,
14
+ L: 38,
15
+ S: void 0,
16
+ A: [
17
+ "edgeUrl",
18
+ "'Edge is not configured.'"
19
+ ]
20
+ });
21
+ const edgeClient = new EdgeHttpClient(edgeUrl);
22
+ const edgeIdentity = createEdgeIdentity(client);
23
+ edgeClient.setIdentity(edgeIdentity);
24
+ const response = await edgeClient.uploadFunction({
25
+ spaceId,
26
+ functionId
27
+ }, {
28
+ name,
29
+ version,
30
+ script: source
31
+ });
32
+ log("Uploaded", {
33
+ functionId,
34
+ source,
35
+ name,
36
+ identityKey: edgeIdentity.identityKey,
37
+ response
38
+ }, {
39
+ F: __dxlog_file,
40
+ L: 44,
41
+ S: void 0,
42
+ C: (f, a) => f(...a)
43
+ });
44
+ return response;
45
+ };
46
+ var getUserFunctionUrlInMetadata = (meta) => {
47
+ return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
48
+ };
49
+ var setUserFunctionUrlInMetadata = (meta, functionUrl) => {
50
+ const key = meta.keys.find((key2) => key2.source === FUNCTIONS_META_KEY);
51
+ if (key) {
52
+ if (key.id !== functionUrl) {
53
+ throw new Error("Metadata mismatch");
54
+ }
55
+ } else {
56
+ meta.keys.push({
57
+ source: FUNCTIONS_META_KEY,
58
+ id: functionUrl
59
+ });
60
+ }
61
+ };
62
+ var getInvocationUrl = (functionUrl, edgeUrl, options = {}) => {
63
+ const baseUrl = new URL("functions/", edgeUrl);
64
+ const relativeUrl = functionUrl.replace(/^\//, "");
65
+ const url = new URL(`./${relativeUrl}`, baseUrl.toString());
66
+ options.spaceId && url.searchParams.set("spaceId", options.spaceId);
67
+ options.subjectId && url.searchParams.set("subjectId", options.subjectId);
68
+ url.protocol = isSecure(url.protocol) ? "https" : "http";
69
+ return url.toString();
70
+ };
71
+ var isSecure = (protocol) => {
72
+ return protocol === "https:" || protocol === "wss:";
73
+ };
74
+ var createEdgeIdentity = (client) => {
75
+ const identity = client.halo.identity.get();
76
+ const device = client.halo.device;
77
+ if (!identity || !device) {
78
+ throw new Error("Identity not available");
79
+ }
80
+ return {
81
+ identityKey: identity.identityKey.toHex(),
82
+ peerKey: device.deviceKey.toHex(),
83
+ presentCredentials: async ({ challenge }) => {
84
+ const identityService = client.services.services.IdentityService;
85
+ const authCredential = await identityService.createAuthCredential();
86
+ return identityService.signPresentation({
87
+ presentation: {
88
+ credentials: [
89
+ authCredential
90
+ ]
91
+ },
92
+ nonce: challenge
93
+ });
94
+ }
95
+ };
96
+ };
97
+ var incrementSemverPatch = (version) => {
98
+ const [major, minor, patch] = version.split(".");
99
+ const patchNum = Number(patch);
100
+ invariant(!Number.isNaN(patchNum), "Unexpected function version format.", {
101
+ F: __dxlog_file,
102
+ L: 109,
103
+ S: void 0,
104
+ A: [
105
+ "!Number.isNaN(patchNum)",
106
+ "'Unexpected function version format.'"
107
+ ]
108
+ });
109
+ return [
110
+ major,
111
+ minor,
112
+ String(patchNum + 1)
113
+ ].join(".");
114
+ };
115
+ var publicKeyToDid = (key) => {
116
+ return `did:key:${key.toHex()}`;
117
+ };
118
+
119
+ export {
120
+ FUNCTIONS_PRESET_META_KEY,
121
+ uploadWorkerFunction,
122
+ getUserFunctionUrlInMetadata,
123
+ setUserFunctionUrlInMetadata,
124
+ getInvocationUrl,
125
+ incrementSemverPatch,
126
+ publicKeyToDid
127
+ };
128
+ //# sourceMappingURL=chunk-T2KBXTMR.mjs.map
@@ -0,0 +1,7 @@
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 { type ObjectMeta } from '@dxos/echo-schema';\nimport { EdgeHttpClient, type EdgeIdentity } from '@dxos/edge-client';\nimport { invariant } from '@dxos/invariant';\nimport type { PublicKey, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type UploadFunctionResponseBody } from '@dxos/protocols';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nexport type UploadWorkerArgs = {\n client: Client;\n name?: string;\n source: string;\n version: string;\n functionId?: string;\n spaceId: SpaceId;\n};\n\nexport const uploadWorkerFunction = async ({\n client,\n name,\n version,\n source,\n spaceId,\n functionId,\n}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {\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({ spaceId, functionId }, { name, version, script: source });\n\n log('Uploaded', {\n functionId,\n source,\n name,\n identityKey: edgeIdentity.identityKey,\n response,\n });\n\n return response;\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\nexport const getInvocationUrl = (functionUrl: 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 relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, 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\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\nconst createEdgeIdentity = (client: Client): EdgeIdentity => {\n const identity = client.halo.identity.get();\n const device = client.halo.device;\n if (!identity || !device) {\n throw new Error('Identity not available');\n }\n return {\n identityKey: identity.identityKey.toHex(),\n peerKey: device.deviceKey.toHex(),\n presentCredentials: async ({ challenge }) => {\n const identityService = client.services.services.IdentityService!;\n const authCredential = await identityService.createAuthCredential();\n return identityService.signPresentation({\n presentation: { credentials: [authCredential] },\n nonce: challenge,\n });\n },\n };\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.');\n return [major, minor, String(patchNum + 1)].join('.');\n};\n\nexport const publicKeyToDid = (key: PublicKey): DID => {\n return `did:key:${key.toHex()}`;\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
5
+ "mappings": ";;;AAQA,SAASA,sBAAyC;AAClD,SAASC,iBAAiB;AAE1B,SAASC,WAAW;;AAIpB,IAAMC,qBAAqB;AAEpB,IAAMC,4BAA4B;AAWlC,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,MACAC,SACAC,QACAC,SACAC,WAAU,MACO;AACjB,QAAMC,UAAUN,OAAOO,OAAOC,OAAOC,SAASC,UAAUC,MAAMC;AAC9DjB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AAO7B,IAAIyB,SAAQ;AACrB;AAEA,IAAMK,WAAW,CAACD,aAAAA;AAChB,SAAOA,aAAa,YAAYA,aAAa;AAC/C;AAEA,IAAM1B,qBAAqB,CAACf,WAAAA;AAC1B,QAAM2C,WAAW3C,OAAO4C,KAAKD,SAASE,IAAG;AACzC,QAAMC,SAAS9C,OAAO4C,KAAKE;AAC3B,MAAI,CAACH,YAAY,CAACG,QAAQ;AACxB,UAAM,IAAIjB,MAAM,wBAAA;EAClB;AACA,SAAO;IACLT,aAAauB,SAASvB,YAAY2B,MAAK;IACvCC,SAASF,OAAOG,UAAUF,MAAK;IAC/BG,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,YAAMC,kBAAkBpD,OAAOU,SAASA,SAAS2C;AACjD,YAAMC,iBAAiB,MAAMF,gBAAgBG,qBAAoB;AACjE,aAAOH,gBAAgBI,iBAAiB;QACtCC,cAAc;UAAEC,aAAa;YAACJ;;QAAgB;QAC9CK,OAAOR;MACT,CAAA;IACF;EACF;AACF;AAEO,IAAMS,uBAAuB,CAAC1D,YAAAA;AACnC,QAAM,CAAC2D,OAAOC,OAAOC,KAAAA,IAAS7D,QAAQ8D,MAAM,GAAA;AAC5C,QAAMC,WAAWC,OAAOH,KAAAA;AACxBpE,YAAU,CAACuE,OAAOC,MAAMF,QAAAA,GAAW,uCAAA;;;;;;;;;AACnC,SAAO;IAACJ;IAAOC;IAAOM,OAAOH,WAAW,CAAA;IAAII,KAAK,GAAA;AACnD;AAEO,IAAMC,iBAAiB,CAAC7C,QAAAA;AAC7B,SAAO,WAAWA,IAAIsB,MAAK,CAAA;AAC7B;",
6
+ "names": ["EdgeHttpClient", "invariant", "log", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "identityKey", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "toString", "searchParams", "set", "subjectId", "protocol", "isSecure", "identity", "halo", "get", "device", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid"]
7
+ }
@@ -0,0 +1,162 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/core/functions/src/types/schema.ts
4
+ import { JsonSchemaType, Ref, S, TypedObject } from "@dxos/echo-schema";
5
+ import { TextType } from "@dxos/schema";
6
+ var ScriptType = class extends TypedObject({
7
+ typename: "dxos.org/type/Script",
8
+ version: "0.1.0"
9
+ })({
10
+ // TODO(burdon): Change to URI?
11
+ name: S.optional(S.String),
12
+ description: S.optional(S.String),
13
+ // TODO(burdon): Change to hash of deployed content.
14
+ // Whether source has changed since last deploy.
15
+ changed: S.optional(S.Boolean),
16
+ source: Ref(TextType)
17
+ }) {
18
+ };
19
+ var FunctionType = class extends TypedObject({
20
+ typename: "dxos.org/type/Function",
21
+ version: "0.1.0"
22
+ })({
23
+ // TODO(burdon): Rename to id/uri?
24
+ name: S.NonEmptyString,
25
+ version: S.String,
26
+ description: S.optional(S.String),
27
+ // Reference to a source script if it exists within ECHO.
28
+ // TODO(burdon): Don't ref ScriptType directly (core).
29
+ source: S.optional(Ref(ScriptType)),
30
+ inputSchema: S.optional(JsonSchemaType),
31
+ // Local binding to a function name.
32
+ binding: S.optional(S.String)
33
+ }) {
34
+ };
35
+
36
+ // packages/core/functions/src/types/types.ts
37
+ import { AST, OptionsAnnotationId, RawObject, S as S2, TypedObject as TypedObject2 } from "@dxos/echo-schema";
38
+ var TriggerKind;
39
+ (function(TriggerKind2) {
40
+ TriggerKind2["Timer"] = "timer";
41
+ TriggerKind2["Webhook"] = "webhook";
42
+ TriggerKind2["Subscription"] = "subscription";
43
+ TriggerKind2["Email"] = "email";
44
+ })(TriggerKind || (TriggerKind = {}));
45
+ var typeLiteralAnnotations = {
46
+ [AST.TitleAnnotationId]: "Type"
47
+ };
48
+ var TimerTriggerSchema = S2.Struct({
49
+ type: S2.Literal("timer").annotations(typeLiteralAnnotations),
50
+ cron: S2.String.annotations({
51
+ [AST.TitleAnnotationId]: "Cron",
52
+ [AST.ExamplesAnnotationId]: [
53
+ "0 0 * * *"
54
+ ]
55
+ })
56
+ }).pipe(S2.mutable);
57
+ var EmailTriggerSchema = S2.Struct({
58
+ type: S2.Literal("email").annotations(typeLiteralAnnotations)
59
+ }).pipe(S2.mutable);
60
+ var WebhookTriggerSchema = S2.Struct({
61
+ type: S2.Literal("webhook").annotations(typeLiteralAnnotations),
62
+ method: S2.optional(S2.String.annotations({
63
+ [AST.TitleAnnotationId]: "Method",
64
+ [OptionsAnnotationId]: [
65
+ "GET",
66
+ "POST"
67
+ ]
68
+ })),
69
+ port: S2.optional(S2.Number.annotations({
70
+ [AST.TitleAnnotationId]: "Port"
71
+ }))
72
+ }).pipe(S2.mutable);
73
+ var QuerySchema = S2.Struct({
74
+ type: S2.optional(S2.String.annotations({
75
+ [AST.TitleAnnotationId]: "Type"
76
+ })),
77
+ props: S2.optional(S2.Record({
78
+ key: S2.String,
79
+ value: S2.Any
80
+ }))
81
+ }).annotations({
82
+ [AST.TitleAnnotationId]: "Query"
83
+ });
84
+ var SubscriptionTriggerSchema = S2.Struct({
85
+ type: S2.Literal("subscription").annotations(typeLiteralAnnotations),
86
+ // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.
87
+ filter: QuerySchema,
88
+ options: S2.optional(S2.Struct({
89
+ // Watch changes to object (not just creation).
90
+ deep: S2.optional(S2.Boolean.annotations({
91
+ [AST.TitleAnnotationId]: "Nested"
92
+ })),
93
+ // Debounce changes (delay in ms).
94
+ delay: S2.optional(S2.Number.annotations({
95
+ [AST.TitleAnnotationId]: "Delay"
96
+ }))
97
+ }).annotations({
98
+ [AST.TitleAnnotationId]: "Options"
99
+ }))
100
+ }).pipe(S2.mutable);
101
+ var TriggerSchema = S2.Union(
102
+ //
103
+ TimerTriggerSchema,
104
+ WebhookTriggerSchema,
105
+ SubscriptionTriggerSchema,
106
+ EmailTriggerSchema
107
+ ).annotations({
108
+ [AST.TitleAnnotationId]: "Trigger"
109
+ });
110
+ var FunctionTriggerSchema = S2.Struct({
111
+ // TODO(burdon): What type does this reference.
112
+ function: S2.optional(S2.String.annotations({
113
+ [AST.TitleAnnotationId]: "Function"
114
+ })),
115
+ enabled: S2.optional(S2.Boolean.annotations({
116
+ [AST.TitleAnnotationId]: "Enabled"
117
+ })),
118
+ // TODO(burdon): Flatten entire schema.
119
+ spec: S2.optional(TriggerSchema),
120
+ // TODO(burdon): Get meta from function.
121
+ // The `meta` property is merged into the event data passed to the function.
122
+ meta: S2.optional(S2.mutable(S2.Record({
123
+ key: S2.String,
124
+ value: S2.Any
125
+ })))
126
+ });
127
+ var FunctionTrigger = class extends TypedObject2({
128
+ typename: "dxos.org/type/FunctionTrigger",
129
+ version: "0.1.0"
130
+ })(FunctionTriggerSchema.fields) {
131
+ };
132
+ var FunctionDef = class extends TypedObject2({
133
+ typename: "dxos.org/type/FunctionDef",
134
+ version: "0.1.0"
135
+ })({
136
+ uri: S2.String,
137
+ description: S2.optional(S2.String),
138
+ route: S2.String,
139
+ handler: S2.String
140
+ }) {
141
+ };
142
+ var FunctionManifestSchema = S2.Struct({
143
+ functions: S2.optional(S2.mutable(S2.Array(RawObject(FunctionDef)))),
144
+ triggers: S2.optional(S2.mutable(S2.Array(RawObject(FunctionTrigger))))
145
+ });
146
+ var FUNCTION_TYPES = [
147
+ FunctionDef,
148
+ FunctionTrigger
149
+ ];
150
+
151
+ export {
152
+ ScriptType,
153
+ FunctionType,
154
+ TriggerKind,
155
+ TriggerSchema,
156
+ FunctionTriggerSchema,
157
+ FunctionTrigger,
158
+ FunctionDef,
159
+ FunctionManifestSchema,
160
+ FUNCTION_TYPES
161
+ };
162
+ //# sourceMappingURL=chunk-UOQLFLOW.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport class ScriptType extends TypedObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n})({\n // TODO(burdon): Change to URI?\n name: S.optional(S.String),\n description: S.optional(S.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: S.optional(S.Boolean),\n source: Ref(TextType),\n}) {}\n\n/**\n * Function deployment.\n */\n// TODO(burdon): Move to core/functions.\nexport class FunctionType extends TypedObject({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n})({\n // TODO(burdon): Rename to id/uri?\n name: S.NonEmptyString,\n version: S.String,\n\n description: S.optional(S.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: S.optional(Ref(ScriptType)),\n\n inputSchema: S.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: S.optional(S.String),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { AST, OptionsAnnotationId, RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n Email = 'email',\n}\n\n// TODO(burdon): Rename prop kind.\nconst typeLiteralAnnotations = { [AST.TitleAnnotationId]: 'Type' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Timer).annotations(typeLiteralAnnotations),\n cron: S.String.annotations({\n [AST.TitleAnnotationId]: 'Cron',\n [AST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(S.mutable);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst EmailTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Email).annotations(typeLiteralAnnotations),\n}).pipe(S.mutable);\n\nexport type EmailTrigger = S.Schema.Type<typeof EmailTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Webhook).annotations(typeLiteralAnnotations),\n method: S.optional(\n S.String.annotations({\n [AST.TitleAnnotationId]: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: S.optional(\n S.Number.annotations({\n [AST.TitleAnnotationId]: 'Port',\n }),\n ),\n}).pipe(S.mutable);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = S.Struct({\n type: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Type' })),\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n}).annotations({ [AST.TitleAnnotationId]: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Subscription).annotations(typeLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number.annotations({ [AST.TitleAnnotationId]: 'Delay' })),\n }).annotations({ [AST.TitleAnnotationId]: 'Options' }),\n ),\n}).pipe(S.mutable);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = S.Union(\n //\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n).annotations({\n [AST.TitleAnnotationId]: 'Trigger',\n});\n\nexport type TriggerType = S.Schema.Type<typeof TriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport const FunctionTriggerSchema = S.Struct({\n // TODO(burdon): What type does this reference.\n function: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Function' })),\n\n enabled: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Enabled' })),\n\n // TODO(burdon): Flatten entire schema.\n spec: S.optional(TriggerSchema),\n\n // TODO(burdon): Get meta from function.\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n});\n\nexport type FunctionTriggerType = S.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})(FunctionTriggerSchema.fields) {}\n\n/**\n * Function definition.\n * @deprecated (Use dxos.org/type/Function)\n */\n// TODO(burdon): Reconcile with FunctionType.\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.String,\n description: S.optional(S.String),\n route: S.String,\n handler: S.String,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.Struct({\n functions: S.optional(S.mutable(S.Array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.Array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionDef, FunctionTrigger];\n"],
5
+ "mappings": ";;;AAIA,SAASA,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Ab;AAAAA,EACAN,YAAY;EACZ,CAACP,IAAIC,iBAAiB,GAAG;AAC3B,CAAA;AAOO,IAAMiC,wBAAwB/B,GAAEC,OAAO;;EAE5C+B,UAAUhC,GAAEa,SAASb,GAAEM,OAAOF,YAAY;IAAE,CAACP,IAAIC,iBAAiB,GAAG;EAAW,CAAA,CAAA;EAEhFmC,SAASjC,GAAEa,SAASb,GAAE2B,QAAQvB,YAAY;IAAE,CAACP,IAAIC,iBAAiB,GAAG;EAAU,CAAA,CAAA;;EAG/EoC,MAAMlC,GAAEa,SAASgB,aAAAA;;;EAIjBM,MAAMnC,GAAEa,SAASb,GAAES,QAAQT,GAAEmB,OAAO;IAAEC,KAAKpB,GAAEM;IAAQe,OAAOrB,GAAEsB;EAAI,CAAA,CAAA,CAAA;AACpE,CAAA;AAOO,IAAMc,kBAAN,cAA8BC,aAAY;EAC/CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGR,sBAAsBS,MAAM,EAAA;AAAG;AAO3B,IAAMC,cAAN,cAA0BJ,aAAY;EAC3CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDG,KAAK1C,GAAEM;EACPqC,aAAa3C,GAAEa,SAASb,GAAEM,MAAM;EAChCsC,OAAO5C,GAAEM;EACTuC,SAAS7C,GAAEM;AACb,CAAA,EAAA;AAAI;AAKG,IAAMwC,yBAAyB9C,GAAEC,OAAO;EAC7C8C,WAAW/C,GAAEa,SAASb,GAAES,QAAQT,GAAEgD,MAAMC,UAAUR,WAAAA,CAAAA,CAAAA,CAAAA;EAClDS,UAAUlD,GAAEa,SAASb,GAAES,QAAQT,GAAEgD,MAAMC,UAAUb,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;AAIO,IAAMe,iBAAiB;EAACV;EAAaL;;",
6
+ "names": ["JsonSchemaType", "Ref", "S", "TypedObject", "TextType", "ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "TextType", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "binding", "AST", "OptionsAnnotationId", "RawObject", "S", "TypedObject", "TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "S", "Struct", "type", "Literal", "annotations", "cron", "String", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "WebhookTriggerSchema", "method", "optional", "OptionsAnnotationId", "port", "Number", "QuerySchema", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "Boolean", "delay", "TriggerSchema", "Union", "FunctionTriggerSchema", "function", "enabled", "spec", "meta", "FunctionTrigger", "TypedObject", "typename", "version", "fields", "FunctionDef", "uri", "description", "route", "handler", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES"]
7
+ }
@@ -0,0 +1,21 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ FUNCTIONS_PRESET_META_KEY,
4
+ getInvocationUrl,
5
+ getUserFunctionUrlInMetadata,
6
+ incrementSemverPatch,
7
+ publicKeyToDid,
8
+ setUserFunctionUrlInMetadata,
9
+ uploadWorkerFunction
10
+ } from "../chunk-T2KBXTMR.mjs";
11
+ import "../chunk-DHGBFXSZ.mjs";
12
+ export {
13
+ FUNCTIONS_PRESET_META_KEY,
14
+ getInvocationUrl,
15
+ getUserFunctionUrlInMetadata,
16
+ incrementSemverPatch,
17
+ publicKeyToDid,
18
+ setUserFunctionUrlInMetadata,
19
+ uploadWorkerFunction
20
+ };
21
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }