@dxos/functions-testing 0.8.4-main.6fa680abb7 → 0.8.4-main.8360d9e660
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/index.ts":{"bytes":414,"imports":[],"format":"esm"},"src/testing/util.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/index.ts":{"bytes":414,"imports":[],"format":"esm"},"src/testing/util.ts":{"bytes":15204,"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/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","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/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":458,"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":8204},"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/echo","kind":"import-statement","external":true},{"path":"@dxos/functions","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/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":3597},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":3831}}}
|
|
@@ -40,9 +40,7 @@ var setup = async (config) => {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
var sync = async (space) => {
|
|
43
|
-
await space.db.flush(
|
|
44
|
-
indexes: true
|
|
45
|
-
});
|
|
43
|
+
await space.db.flush();
|
|
46
44
|
await space.internal.syncToEdge({
|
|
47
45
|
onProgress: (state) => console.log(state ? `${state.unsyncedDocumentCount} documents syncing...` : "connecting to edge...")
|
|
48
46
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/testing/util.ts"],
|
|
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 { Filter, Obj, Query } from '@dxos/echo';\nimport { Function } from '@dxos/functions';\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 { 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: [Function.Function, 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(
|
|
5
|
-
"mappings": ";;;AAIA,OAAOA,QAAQ;AAEf,SAASC,aAAa;AACtB,SAASC,cAA2B;AAEpC,SAASC,QAAQC,KAAKC,aAAa;AACnC,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,yBAAyBC,iCAAiC;AACnE,SAASC,8BAA8B;AACvC,SAASC,sBAAsB;AAE/B,SAASC,kBAA4C;AACrD,SAASC,8BAA8B;AAEhC,IAAMC,cAAc,CAACC,MAAcC,WAAAA;AACxCC,KAAGC,UAAUH,MAAM;IAAEI,WAAW;EAAK,CAAA;AACrCC,SAAOC,QAAQL,OAAOM,MAAM,EAAEC,QAAQ,CAAC,CAACC,MAAMC,OAAAA,MAAQ;AACpDR,OAAGS,cAAcX,OAAO,MAAMS,MAAMC,OAAAA;EACtC,CAAA;AACF;AAEO,IAAME,QAAQ,OAAOC,WAAAA;AAC1B,QAAMC,SAAS,MAAM,IAAIC,OAAO;IAC9BF;IACAG,OAAO;MAACC,SAASA;MAAUC,QAAQA;;EACrC,CAAA,EAAGC,WAAU;AACb,QAAML,OAAOM,KAAKC,eAAc;AAEhC,QAAMC,QAAQ,MAAMR,OAAOS,OAAOC,OAAM;AACxC,QAAMF,MAAMG,eAAc;AAC1B,QAAMH,MAAMI,SAASC,6BAA6BC,uBAAuBC,OAAO;AAEhF,QAAMC,yBAAyBC,uBAAuBC,WAAWlB,MAAAA;AAEjE,SAAO;IAAEA;IAAQQ;IAAOQ;EAAuB;AACjD;AAEO,IAAMG,OAAO,OAAOX,UAAAA;AACzB,QAAMA,MAAMY,GAAGC,
|
|
6
|
-
"names": ["fs", "sleep", "Client", "Filter", "Obj", "Query", "Function", "Trigger", "InvocationTraceEndEvent", "InvocationTraceStartEvent", "FunctionsServiceClient", "bundleFunction", "ErrorCodec", "EdgeReplicationSetting", "writeBundle", "path", "bundle", "fs", "mkdirSync", "recursive", "Object", "entries", "assets", "forEach", "name", "content", "writeFileSync", "setup", "config", "client", "Client", "types", "Function", "Trigger", "initialize", "halo", "createIdentity", "space", "spaces", "create", "waitUntilReady", "internal", "setEdgeReplicationPreference", "EdgeReplicationSetting", "ENABLED", "functionsServiceClient", "FunctionsServiceClient", "fromClient", "sync", "db", "flush", "
|
|
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 { Filter, Obj, Query } from '@dxos/echo';\nimport { Function } from '@dxos/functions';\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 { 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: [Function.Function, 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) => {\n const artifact = await bundleFunction({\n entryPoint,\n verbose: true,\n });\n const func = await functionsServiceClient.deploy({\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 invocations =\n (await space.properties.invocationTraceQueue?.target!.query(Query.select(Filter.everything())).run()) ?? [];\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,QAAQC,KAAKC,aAAa;AACnC,SAASC,gBAAgB;AACzB,SAASC,eAAe;AACxB,SAASC,yBAAyBC,iCAAiC;AACnE,SAASC,8BAA8B;AACvC,SAASC,sBAAsB;AAE/B,SAASC,kBAA4C;AACrD,SAASC,8BAA8B;AAEhC,IAAMC,cAAc,CAACC,MAAcC,WAAAA;AACxCC,KAAGC,UAAUH,MAAM;IAAEI,WAAW;EAAK,CAAA;AACrCC,SAAOC,QAAQL,OAAOM,MAAM,EAAEC,QAAQ,CAAC,CAACC,MAAMC,OAAAA,MAAQ;AACpDR,OAAGS,cAAcX,OAAO,MAAMS,MAAMC,OAAAA;EACtC,CAAA;AACF;AAEO,IAAME,QAAQ,OAAOC,WAAAA;AAC1B,QAAMC,SAAS,MAAM,IAAIC,OAAO;IAC9BF;IACAG,OAAO;MAACC,SAASA;MAAUC,QAAQA;;EACrC,CAAA,EAAGC,WAAU;AACb,QAAML,OAAOM,KAAKC,eAAc;AAEhC,QAAMC,QAAQ,MAAMR,OAAOS,OAAOC,OAAM;AACxC,QAAMF,MAAMG,eAAc;AAC1B,QAAMH,MAAMI,SAASC,6BAA6BC,uBAAuBC,OAAO;AAEhF,QAAMC,yBAAyBC,uBAAuBC,WAAWlB,MAAAA;AAEjE,SAAO;IAAEA;IAAQQ;IAAOQ;EAAuB;AACjD;AAEO,IAAMG,OAAO,OAAOX,UAAAA;AACzB,QAAMA,MAAMY,GAAGC,MAAK;AACpB,QAAMb,MAAMI,SAASU,WAAW;IAC9BC,YAAY,CAACC,UACXC,QAAQC,IAAIF,QAAQ,GAAGA,MAAMG,qBAAqB,0BAA0B,uBAAA;EAChF,CAAA;AAC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G4C,KAAKzB,MAAMmB,SAAQ,EAAGC,SAAS,GAAG,GAAA,CAAA,iBAAqBQ,OAAAA,aAAoBH,KAAKE,IAAIE,YAAYJ,KAAKP,MAAMW,SAAS,EAAE;AAE3H,cAAID,YAAY,aAAaH,KAAKE,IAAIG,OAAO;AAC3ClD,oBAAQkD,MAAMC,WAAWC,OAAOP,KAAKE,IAAIG,KAAK,CAAA;UAChD;QACF;MACF;AACA,UAAIjC,iBAAiB,MAAM;AACzBA,uBAAeI,YAAYgC;MAC7B;AAEA,UAAIrC,aAAa,QAAQE,eAAeoC,QAAQtC,WAAWC,cAAc;AACvE;MACF;IACF,SAASsC,KAAK;AACZvD,cAAQkD,MAAMK,GAAAA;IAChB;AACA,UAAMC,MAAM,GAAA;EACd;AACF;",
|
|
6
|
+
"names": ["fs", "sleep", "Client", "Filter", "Obj", "Query", "Function", "Trigger", "InvocationTraceEndEvent", "InvocationTraceStartEvent", "FunctionsServiceClient", "bundleFunction", "ErrorCodec", "EdgeReplicationSetting", "writeBundle", "path", "bundle", "fs", "mkdirSync", "recursive", "Object", "entries", "assets", "forEach", "name", "content", "writeFileSync", "setup", "config", "client", "Client", "types", "Function", "Trigger", "initialize", "halo", "createIdentity", "space", "spaces", "create", "waitUntilReady", "internal", "setEdgeReplicationPreference", "EdgeReplicationSetting", "ENABLED", "functionsServiceClient", "FunctionsServiceClient", "fromClient", "sync", "db", "flush", "syncToEdge", "onProgress", "state", "console", "log", "unsyncedDocumentCount", "deployFunction", "entryPoint", "runtime", "artifact", "bundleFunction", "verbose", "func", "deploy", "version", "ownerPublicKey", "key", "add", "observeInvocations", "maxCount", "initialCount", "invocationData", "Map", "count", "invocations", "properties", "invocationTraceQueue", "target", "query", "Query", "select", "Filter", "everything", "run", "invocation", "Obj", "instanceOf", "InvocationTraceStartEvent", "has", "invocationId", "set", "begin", "toString", "padStart", "JSON", "stringify", "input", "InvocationTraceEndEvent", "data", "get", "end", "outcome", "timestamp", "error", "ErrorCodec", "decode", "length", "size", "err", "sleep"]
|
|
7
7
|
}
|