@dxos/functions-testing 0.8.4-main.422d1c7879 → 0.8.4-main.51f1e5ca51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -4
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/functions/fib.d.ts.map +1 -1
- package/dist/types/src/functions/forex-effect.d.ts.map +1 -1
- package/dist/types/src/functions/query.d.ts.map +1 -1
- package/dist/types/src/functions/reply.d.ts.map +1 -1
- package/dist/types/src/functions/sleep.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/cpu-limit.test.ts +5 -5
- package/src/functions/definitions.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/index.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/index.ts":{"bytes":332,"imports":[],"format":"esm"},"src/testing/util.ts":{"bytes":16019,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime/edge","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime/native","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true}],"format":"esm"},"src/testing/index.ts":{"bytes":368,"imports":[{"path":"src/testing/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/index.mjs":{"imports":[],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":127},"dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7522},"dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime/edge","kind":"import-statement","external":true},{"path":"@dxos/functions-runtime/native","kind":"import-statement","external":true},{"path":"@dxos/operation","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true}],"exports":["deployFunction","observeInvocations","setup","sync","writeBundle"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/util.ts":{"bytesInOutput":3931},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":4165}}}
|
|
@@ -52,10 +52,7 @@ var deployFunction = async (space, functionsServiceClient, entryPoint, runtime)
|
|
|
52
52
|
entryPoint,
|
|
53
53
|
verbose: true
|
|
54
54
|
});
|
|
55
|
-
const func = await functionsServiceClient.deploy(Context.default(void 0, {
|
|
56
|
-
F: __dxlog_file,
|
|
57
|
-
L: 62
|
|
58
|
-
}), {
|
|
55
|
+
const func = await functionsServiceClient.deploy(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 54 }), {
|
|
59
56
|
version: "0.0.1",
|
|
60
57
|
ownerPublicKey: space.key,
|
|
61
58
|
entryPoint: artifact.entryPoint,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/testing/util.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport fs from 'node:fs';\n\nimport { sleep } from '@dxos/async';\nimport { Client, type Config } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { Context } from '@dxos/context';\nimport { Feed, Obj } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { InvocationTraceEndEvent, InvocationTraceStartEvent } from '@dxos/functions-runtime';\nimport { FunctionsServiceClient } from '@dxos/functions-runtime/edge';\nimport { bundleFunction } from '@dxos/functions-runtime/native';\nimport type { BundleResult } from '@dxos/functions-runtime/native';\nimport { Operation } from '@dxos/operation';\nimport { ErrorCodec, type FunctionRuntimeKind } from '@dxos/protocols';\nimport { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';\n\nexport const writeBundle = (path: string, bundle: BundleResult) => {\n fs.mkdirSync(path, { recursive: true });\n Object.entries(bundle.assets).forEach(([name, content]) => {\n fs.writeFileSync(path + '/' + name, content);\n });\n};\n\nexport const setup = async (config: Config) => {\n const client = await new Client({\n config,\n types: [Operation.PersistentOperation, Trigger.Trigger],\n }).initialize();\n await client.halo.createIdentity();\n\n const space = await client.spaces.create();\n await space.waitUntilReady();\n await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);\n\n const functionsServiceClient = FunctionsServiceClient.fromClient(client);\n\n return { client, space, functionsServiceClient };\n};\n\nexport const sync = async (space: Space) => {\n await space.db.flush();\n await space.internal.syncToEdge({\n onProgress: (state) =>\n console.log(state ? `${state.unsyncedDocumentCount} documents syncing...` : 'connecting to edge...'),\n });\n};\n\nexport const deployFunction = async (\n space: Space,\n functionsServiceClient: FunctionsServiceClient,\n entryPoint: string,\n runtime: FunctionRuntimeKind,\n): Promise<Operation.PersistentOperation> => {\n const artifact = await bundleFunction({\n entryPoint,\n verbose: true,\n });\n const func = await functionsServiceClient.deploy(Context.default(), {\n version: '0.0.1',\n ownerPublicKey: space.key,\n entryPoint: artifact.entryPoint,\n assets: artifact.assets,\n runtime,\n });\n space.db.add(func);\n\n return func;\n};\n\nexport const observeInvocations = async (space: Space, maxCount: number | null) => {\n let initialCount = null;\n const invocationData = new Map<\n string,\n {\n count: number;\n begin: InvocationTraceStartEvent;\n end?: InvocationTraceEndEvent;\n }\n >();\n let count = 0;\n while (true) {\n try {\n const traceFeed = space.properties.invocationTraceFeed?.target;\n const traceQueueDxn = traceFeed ? Feed.getQueueDxn(traceFeed) : undefined;\n const invocations = traceQueueDxn ? ((await space.queues.get(traceQueueDxn).queryObjects()) ?? []) : [];\n\n for (const invocation of invocations) {\n if (Obj.instanceOf(InvocationTraceStartEvent, invocation)) {\n if (invocationData.has(invocation.invocationId)) {\n continue;\n }\n invocationData.set(invocation.invocationId, {\n count: count++,\n begin: invocation,\n });\n console.log(\n `${count.toString().padStart(3, ' ')}: BEGIN ${invocation.runtime ?? '(unknown runtime)'} ${JSON.stringify(invocation.input)}`,\n );\n } else if (Obj.instanceOf(InvocationTraceEndEvent, invocation)) {\n const data = invocationData.get(invocation.invocationId);\n if (!data || !!data.end) {\n continue;\n }\n data.end = invocation;\n\n const outcome = data.end.outcome;\n console.log(\n `${data.count.toString().padStart(3, ' ')}: END outcome=${outcome} duration=${data.end.timestamp - data.begin.timestamp}`,\n );\n if (outcome === 'failure' && data.end.error) {\n console.error(ErrorCodec.decode(data.end.error));\n }\n }\n }\n if (initialCount === null) {\n initialCount = invocations.length;\n }\n\n if (maxCount !== null && invocationData.size >= maxCount + initialCount) {\n break;\n }\n } catch (err) {\n console.error(err);\n }\n await sleep(1_000);\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,OAAOA,QAAQ;AAEf,SAASC,aAAa;AACtB,SAASC,cAA2B;AAEpC,SAASC,eAAe;AACxB,SAASC,MAAMC,WAAW;AAC1B,SAASC,eAAe;AACxB,SAASC,yBAAyBC,iCAAiC;AACnE,SAASC,8BAA8B;AACvC,SAASC,sBAAsB;AAE/B,SAASC,iBAAiB;AAC1B,SAASC,kBAA4C;AACrD,SAASC,8BAA8B
|
|
6
|
-
"names": ["fs", "sleep", "Client", "Context", "Feed", "Obj", "Trigger", "InvocationTraceEndEvent", "InvocationTraceStartEvent", "FunctionsServiceClient", "bundleFunction", "Operation", "ErrorCodec", "EdgeReplicationSetting", "writeBundle", "
|
|
5
|
+
"mappings": ";;;AAIA,OAAOA,QAAQ;AAEf,SAASC,aAAa;AACtB,SAASC,cAA2B;AAEpC,SAASC,eAAe;AACxB,SAASC,MAAMC,WAAW;AAC1B,SAASC,eAAe;AACxB,SAASC,yBAAyBC,iCAAiC;AACnE,SAASC,8BAA8B;AACvC,SAASC,sBAAsB;AAE/B,SAASC,iBAAiB;AAC1B,SAASC,kBAA4C;AACrD,SAASC,8BAA8B;AAEvC,IAAA,eAAaC;IACUC,cAAW,CAAA,MAAA,WAAA;AAAK,KAAA,UAAA,MAAA;IACrCC,WAAeC;;AAEf,SAAA,QAAA,OAAA,MAAA,EAAA,QAAA,CAAA,CAAA,MAAA,OAAA,MAAA;AACA,OAAA,cAAA,OAAA,MAAA,MAAA,OAAA;EAEF,CAAA;;IAEIC,QAAAA,OAAAA,WAAAA;QACAC,SAAO,MAAA,IAAA,OAAA;;WAAgCb;MAAgB,UAAA;MACtDc,QAAU;IACb;EAEA,CAAA,EAAA,WAAc;AACd,QAAMC,OAAMC,KAAAA,eAAc;AAC1B,QAAMD,QAAME,MAAQ,OAACC,OAAAA,OAAAA;AAErB,QAAMC,MAAAA,eAAAA;AAEN,QAAA,MAAO,SAAA,6BAAA,uBAAA,OAAA;QAAEC,yBAAAA,uBAAAA,WAAAA,MAAAA;SAAQL;IAAOI;IAAuB;IAC/C;EAEF;;AAEE,IAAMJ,OAAME,OAASI,UAAU;QAC7BC,MAAAA,GAAAA,MAAaC;AAEf,QAAA,MAAA,SAAA,WAAA;IACA,YAAA,CAAA,UAAA,QAAA,IAAA,QAAA,GAAA,MAAA,qBAAA,0BAAA,uBAAA;EAEF,CAAA;;IAOIC,iBAAAA,OAA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A,IAAA,YAAA,KAAA,MAAA,SAAA,EAAA;AAChD,cAAA,YAAA,aAAA,KAAA,IAAA,OAAA;AACF,oBAAA,MAAA,WAAA,OAAA,KAAA,IAAA,KAAA,CAAA;UACF;QACIC;;AAEJ,UAAA,iBAAA,MAAA;AAEIC,uBAAa,YAAQf;;AAEzB,UAAA,aAAA,QAAA,eAAA,QAAA,WAAA,cAAA;AACA;MACAQ;IACF,SAAA,KAAA;AACA,cAAY,MAAA,GAAA;IACd;AACA,UAAA,MAAA,GAAA;;;",
|
|
6
|
+
"names": ["fs", "sleep", "Client", "Context", "Feed", "Obj", "Trigger", "InvocationTraceEndEvent", "InvocationTraceStartEvent", "FunctionsServiceClient", "bundleFunction", "Operation", "ErrorCodec", "EdgeReplicationSetting", "writeBundle", "recursive", "Object", "bundle", "config", "types", "initialize", "space", "waitUntilReady", "internal", "setEdgeReplicationPreference", "functionsServiceClient", "client", "syncToEdge", "onProgress", "state", "entryPoint", "verbose", "ownerPublicKey", "assets", "artifact", "runtime", "invocationData", "Map", "count", "invocations", "traceQueueDxn", "get", "invocation", "instanceOf", "console", "data", "invocationId", "end", "outcome", "error", "initialCount", "maxCount"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fib.d.ts","sourceRoot":"","sources":["../../../../src/functions/fib.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"fib.d.ts","sourceRoot":"","sources":["../../../../src/functions/fib.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forex-effect.d.ts","sourceRoot":"","sources":["../../../../src/functions/forex-effect.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"forex-effect.d.ts","sourceRoot":"","sources":["../../../../src/functions/forex-effect.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/functions/query.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAA8B,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../src/functions/query.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAA8B,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/functions/reply.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/functions/reply.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/functions/sleep.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/functions/sleep.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGvE,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGvE,eAAO,MAAM,WAAW,SAAU,MAAM,UAAU,YAAY,SAK7D,CAAC;AAEF,eAAO,MAAM,KAAK,WAAkB,MAAM;;;;EAczC,CAAC;AAEF,eAAO,MAAM,IAAI,UAAiB,KAAK,kBAMtC,CAAC;AAEF,eAAO,MAAM,cAAc,UAClB,KAAK,0BACY,sBAAsB,cAClC,MAAM,WACT,mBAAmB,KAC3B,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAevC,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAiB,KAAK,YAAY,MAAM,GAAG,IAAI,kBAyD7E,CAAC"}
|