@lunora/runtime 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (40) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +17 -0
  3. package/dist/index.d.mts +3393 -1170
  4. package/dist/index.d.ts +3393 -1170
  5. package/dist/index.mjs +1 -14
  6. package/dist/packem_shared/DEFAULT_LOG_COLUMNS-B0imn1l0.mjs +1 -0
  7. package/dist/packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-CsNnfJzB.mjs +1 -0
  8. package/dist/packem_shared/HEALTH_PATH-BEE0A_lZ.mjs +1 -0
  9. package/dist/packem_shared/LOG_ARCHIVE_NOT_CONFIGURED-CDpi4yFD.mjs +1 -0
  10. package/dist/packem_shared/LOG_ARCHIVE_PATH-DGsEec3K.mjs +1 -0
  11. package/dist/packem_shared/LunoraError-ByasbDmd.mjs +1 -0
  12. package/dist/packem_shared/NOOP_EXECUTION_CONTEXT-YmXqH-jH.mjs +1 -0
  13. package/dist/packem_shared/analyticsEngineSink-CUWYuLHs.mjs +1 -0
  14. package/dist/packem_shared/applyJurisdiction-uRQLx282.mjs +1 -0
  15. package/dist/packem_shared/argsFromQuery-0KrWTkNx.mjs +1 -0
  16. package/dist/packem_shared/composeIdentityResolvers-DwE0Jbww.mjs +1 -0
  17. package/dist/packem_shared/composeWorker-IO6LYYK2.mjs +6 -0
  18. package/dist/packem_shared/createCrossShardRelationCapabilities-CMWiFA5s.mjs +1 -0
  19. package/dist/packem_shared/createKvCursorStore-C24tEuYk.mjs +3 -0
  20. package/dist/packem_shared/createQueryCoordinator-DqrEvhPD.mjs +1 -0
  21. package/dist/packem_shared/createShardClient-62qcYKGl.mjs +1 -0
  22. package/dist/packem_shared/decorateResponse-DBIWsRSZ.mjs +1 -0
  23. package/dist/packem_shared/emitLogEvent-BcdChmSV.mjs +1 -0
  24. package/dist/packem_shared/memoizeIdentity-CZGtDc4H.mjs +1 -0
  25. package/dist/packem_shared/method-guard-BbuR0VfS.mjs +1 -0
  26. package/dist/packem_shared/observability-DYnm-d4g.mjs +1 -0
  27. package/dist/packem_shared/otlp-resource-B-ByO9qo.mjs +1 -0
  28. package/dist/packem_shared/pipeline-log-reader-DU_CCGDA.mjs +1 -0
  29. package/dist/packem_shared/toAirbyteMessages-DBTuFjb5.mjs +1 -0
  30. package/package.json +6 -2
  31. package/dist/packem_shared/DEFAULT_REGISTRY_CACHE_TTL_MS-ocax8v0n.mjs +0 -78
  32. package/dist/packem_shared/LunoraError-CL0aOtpo.mjs +0 -46
  33. package/dist/packem_shared/analyticsEngineSink-DqEvrQs0.mjs +0 -141
  34. package/dist/packem_shared/applyJurisdiction-BkZtTkct.mjs +0 -20
  35. package/dist/packem_shared/composeWorker-Dxt4Mo0R.mjs +0 -2506
  36. package/dist/packem_shared/createCrossShardRelationCapabilities-C0KOf7er.mjs +0 -61
  37. package/dist/packem_shared/createQueryCoordinator-Cbds9cUI.mjs +0 -838
  38. package/dist/packem_shared/decorateResponse-DbISh_Wi.mjs +0 -233
  39. package/dist/packem_shared/emitLogEvent-pEdtqAK8.mjs +0 -20
  40. package/dist/packem_shared/toAirbyteMessages-DrHdplb4.mjs +0 -39
@@ -1,61 +0,0 @@
1
- const RPC_ENDPOINT = "/_lunora/rpc";
2
- const buildIdentityHeaders = (options) => {
3
- const headers = { "content-type": "application/json" };
4
- if (options.userId !== void 0 && options.userId.length > 0) {
5
- headers["x-lunora-userid"] = options.userId;
6
- }
7
- if (options.identity !== void 0) {
8
- headers["x-lunora-identity"] = JSON.stringify(options.identity);
9
- }
10
- return headers;
11
- };
12
- const fanOutRelation = async (options, body, label) => {
13
- const doFetch = options.fetch ?? globalThis.fetch;
14
- const response = await doFetch(
15
- new Request(`${options.origin}${RPC_ENDPOINT}`, {
16
- body: JSON.stringify(body),
17
- headers: buildIdentityHeaders(options),
18
- method: "POST"
19
- })
20
- );
21
- if (!response.ok) {
22
- throw new Error(`cross-shard relation ${label} failed: worker returned ${String(response.status)}`);
23
- }
24
- const result = await response.json();
25
- if (typeof result.failed === "number" && result.failed > 0) {
26
- const reached = (typeof result.ok === "number" ? result.ok : 0) + result.failed;
27
- throw new Error(
28
- `cross-shard relation ${label} failed on ${String(result.failed)} of ${String(reached)} shard(s) — refusing to return a partial result`
29
- );
30
- }
31
- return result.data;
32
- };
33
- const createCrossShardRelationCapabilities = (options) => {
34
- const crossShardReader = async (table, args) => {
35
- const data = await fanOutRelation(
36
- options,
37
- {
38
- args: { orderBy: args?.orderBy, table, where: args?.where, with: args?.with },
39
- fanOut: { merge: { kind: "concat" }, table },
40
- functionPath: "__lunora_relation__:read"
41
- },
42
- "read"
43
- );
44
- return { continueCursor: null, isDone: true, page: Array.isArray(data) ? data : [] };
45
- };
46
- const crossShardCounter = async (table, where) => {
47
- const data = await fanOutRelation(
48
- options,
49
- {
50
- args: { table, where },
51
- fanOut: { merge: { kind: "sum" }, table },
52
- functionPath: "__lunora_relation__:count"
53
- },
54
- "count"
55
- );
56
- return typeof data === "number" ? data : 0;
57
- };
58
- return { crossShardCounter, crossShardReader };
59
- };
60
-
61
- export { createCrossShardRelationCapabilities };