@dxos/functions 0.5.3-main.2ad0afc → 0.5.3-main.2c59258

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 (55) hide show
  1. package/dist/lib/browser/index.mjs +299 -280
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +303 -286
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/types/src/index.d.ts +1 -1
  8. package/dist/types/src/index.d.ts.map +1 -1
  9. package/dist/types/src/{function → registry}/function-registry.d.ts +4 -4
  10. package/dist/types/src/registry/function-registry.d.ts.map +1 -0
  11. package/dist/types/src/registry/function-registry.test.d.ts.map +1 -0
  12. package/dist/types/src/registry/index.d.ts.map +1 -0
  13. package/dist/types/src/runtime/dev-server.d.ts +1 -1
  14. package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
  15. package/dist/types/src/runtime/scheduler.d.ts +1 -2
  16. package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
  17. package/dist/types/src/trigger/trigger-registry.d.ts.map +1 -1
  18. package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +1 -1
  19. package/dist/types/src/types.d.ts +19 -33
  20. package/dist/types/src/types.d.ts.map +1 -1
  21. package/package.json +18 -31
  22. package/schema/functions.json +9 -18
  23. package/src/index.ts +1 -1
  24. package/src/{function → registry}/function-registry.test.ts +10 -10
  25. package/src/{function → registry}/function-registry.ts +24 -30
  26. package/src/runtime/dev-server.test.ts +2 -2
  27. package/src/runtime/dev-server.ts +6 -5
  28. package/src/runtime/scheduler.test.ts +1 -1
  29. package/src/runtime/scheduler.ts +8 -16
  30. package/src/testing/functions-integration.test.ts +1 -1
  31. package/src/testing/setup.ts +1 -1
  32. package/src/trigger/trigger-registry.test.ts +34 -60
  33. package/src/trigger/trigger-registry.ts +5 -18
  34. package/src/trigger/type/subscription-trigger.ts +10 -17
  35. package/src/types.ts +10 -12
  36. package/dist/lib/browser/chunk-366QG6IX.mjs +0 -81
  37. package/dist/lib/browser/chunk-366QG6IX.mjs.map +0 -7
  38. package/dist/lib/browser/types.mjs +0 -12
  39. package/dist/lib/browser/types.mjs.map +0 -7
  40. package/dist/lib/node/chunk-3VSJ57ZZ.cjs +0 -97
  41. package/dist/lib/node/chunk-3VSJ57ZZ.cjs.map +0 -7
  42. package/dist/lib/node/types.cjs +0 -33
  43. package/dist/lib/node/types.cjs.map +0 -7
  44. package/dist/types/src/function/function-registry.d.ts.map +0 -1
  45. package/dist/types/src/function/function-registry.test.d.ts.map +0 -1
  46. package/dist/types/src/function/index.d.ts.map +0 -1
  47. package/dist/types/src/util.d.ts +0 -15
  48. package/dist/types/src/util.d.ts.map +0 -1
  49. package/dist/types/src/util.test.d.ts +0 -2
  50. package/dist/types/src/util.test.d.ts.map +0 -1
  51. package/src/util.test.ts +0 -43
  52. package/src/util.ts +0 -48
  53. /package/dist/types/src/{function → registry}/function-registry.test.d.ts +0 -0
  54. /package/dist/types/src/{function → registry}/index.d.ts +0 -0
  55. /package/src/{function → registry}/index.ts +0 -0
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var types_exports = {};
20
- __export(types_exports, {
21
- FunctionDef: () => import_chunk_3VSJ57ZZ.FunctionDef,
22
- FunctionManifestSchema: () => import_chunk_3VSJ57ZZ.FunctionManifestSchema,
23
- FunctionTrigger: () => import_chunk_3VSJ57ZZ.FunctionTrigger
24
- });
25
- module.exports = __toCommonJS(types_exports);
26
- var import_chunk_3VSJ57ZZ = require("./chunk-3VSJ57ZZ.cjs");
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- FunctionDef,
30
- FunctionManifestSchema,
31
- FunctionTrigger
32
- });
33
- //# sourceMappingURL=types.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["types.cjs"],
4
- "sourcesContent": ["import {\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger\n} from \"./chunk-3VSJ57ZZ.cjs\";\nexport {\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger\n};\n//# sourceMappingURL=types.cjs.map\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAIO;",
6
- "names": []
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"function-registry.d.ts","sourceRoot":"","sources":["../../../../src/function/function-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,QAAQ;IAKhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4D;IAEhG,SAAgB,UAAU,kCAAyC;gBAEtC,OAAO,EAAE,MAAM;IAIrC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,EAAE;IAIhD;;;OAGG;IACU,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;cAiBnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAgCtB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"function-registry.test.d.ts","sourceRoot":"","sources":["../../../../src/function/function-registry.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/function/index.ts"],"names":[],"mappings":"AAIA,cAAc,qBAAqB,CAAC"}
@@ -1,15 +0,0 @@
1
- export type Comparator<A, B = A> = (a: A, b: B) => boolean;
2
- export type DiffResult<A, B = A> = {
3
- added: B[];
4
- updated: A[];
5
- removed: A[];
6
- };
7
- /**
8
- *
9
- * @param previous
10
- * @param next
11
- * @param comparator
12
- */
13
- export declare const diff: <A, B = A>(previous: readonly A[], next: readonly B[], comparator: Comparator<A, B>) => DiffResult<A, B>;
14
- export declare const intersection: <A, B = A>(a: A[], b: B[], comparator: Comparator<A, B>) => A[];
15
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AAE3D,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI;IACjC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,OAAO,EAAE,CAAC,EAAE,CAAC;CACd,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,IAAI,0GAwBhB,CAAC;AAGF,eAAO,MAAM,YAAY,iEACuC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=util.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.test.d.ts","sourceRoot":"","sources":["../../../src/util.test.ts"],"names":[],"mappings":""}
package/src/util.test.ts DELETED
@@ -1,43 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { expect } from 'chai';
6
-
7
- import { describe, test } from '@dxos/test';
8
-
9
- import { diff, intersection } from './util';
10
-
11
- describe('diff', () => {
12
- test('returns the difference between two sets', () => {
13
- {
14
- const { added, updated, removed } = diff<number>([], [], (a, b) => a === b);
15
- expect(added).to.deep.eq([]);
16
- expect(updated).to.deep.eq([]);
17
- expect(removed).to.deep.eq([]);
18
- }
19
- {
20
- const previous = [1, 2, 3];
21
- const next = [2, 3, 4];
22
- const { added, updated, removed } = diff(previous, next, (a, b) => a === b);
23
- expect(added).to.deep.eq([4]);
24
- expect(updated).to.deep.eq([2, 3]);
25
- expect(removed).to.deep.eq([1]);
26
- }
27
- {
28
- const previous = [{ x: 1 }, { x: 2 }, { x: 3 }];
29
- const next = [{ x: 2 }, { x: 3 }, { x: 4 }];
30
- const { added, updated, removed } = diff(previous, next, (a, b) => a.x === b.x);
31
- expect(added).to.deep.eq([{ x: 4 }]);
32
- expect(updated).to.deep.eq([{ x: 2 }, { x: 3 }]);
33
- expect(removed).to.deep.eq([{ x: 1 }]);
34
- }
35
- });
36
-
37
- test('intersection', () => {
38
- expect(intersection([1, 2, 3], [2, 3, 4], (a, b) => a === b)).to.deep.eq([2, 3]);
39
- expect(
40
- intersection([{ x: 1 }, { x: 2 }, { x: 3 }], [{ x: 2 }, { x: 3 }, { x: 4 }], (a, b) => a.x === b.x),
41
- ).to.deep.eq([{ x: 2 }, { x: 3 }]);
42
- });
43
- });
package/src/util.ts DELETED
@@ -1,48 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export type Comparator<A, B = A> = (a: A, b: B) => boolean;
6
-
7
- export type DiffResult<A, B = A> = {
8
- added: B[];
9
- updated: A[];
10
- removed: A[];
11
- };
12
-
13
- /**
14
- *
15
- * @param previous
16
- * @param next
17
- * @param comparator
18
- */
19
- // TODO(burdon): Factor out.
20
- export const diff = <A, B = A>(
21
- previous: readonly A[],
22
- next: readonly B[],
23
- comparator: Comparator<A, B>,
24
- ): DiffResult<A, B> => {
25
- const remaining = [...previous];
26
- const result: DiffResult<A, B> = {
27
- added: [],
28
- updated: [],
29
- removed: remaining,
30
- };
31
-
32
- // TODO(burdon): Mark and sweep.
33
- for (const object of next) {
34
- const index = remaining.findIndex((item) => comparator(item, object));
35
- if (index === -1) {
36
- result.added.push(object);
37
- } else {
38
- result.updated.push(remaining[index]);
39
- remaining.splice(index, 1);
40
- }
41
- }
42
-
43
- return result;
44
- };
45
-
46
- // TODO(burdon): Factor out.
47
- export const intersection = <A, B = A>(a: A[], b: B[], comparator: Comparator<A, B>): A[] =>
48
- a.filter((a) => b.find((b) => comparator(a, b)) !== undefined);
File without changes