@party-stack/ontology-devtools 0.6.2 → 0.7.0

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 (130) hide show
  1. package/README.md +195 -0
  2. package/lib/DisclosureSummary.d.ts +7 -0
  3. package/lib/DisclosureSummary.d.ts.map +1 -0
  4. package/lib/DisclosureSummary.js +20 -0
  5. package/lib/DisclosureSummary.js.map +1 -0
  6. package/lib/NativeQueryCode.d.ts +7 -0
  7. package/lib/NativeQueryCode.d.ts.map +1 -0
  8. package/lib/NativeQueryCode.js +35 -0
  9. package/lib/NativeQueryCode.js.map +1 -0
  10. package/lib/OntologyDevtools.d.ts +11 -50
  11. package/lib/OntologyDevtools.d.ts.map +1 -1
  12. package/lib/OntologyDevtools.js +310 -626
  13. package/lib/OntologyDevtools.js.map +1 -1
  14. package/lib/OntologyIcons.d.ts +14 -0
  15. package/lib/OntologyIcons.d.ts.map +1 -0
  16. package/lib/OntologyIcons.js +22 -0
  17. package/lib/OntologyIcons.js.map +1 -0
  18. package/lib/PanelBoundary.d.ts +10 -0
  19. package/lib/PanelBoundary.d.ts.map +1 -0
  20. package/lib/PanelBoundary.js +67 -0
  21. package/lib/PanelBoundary.js.map +1 -0
  22. package/lib/Pinned.d.ts +14 -0
  23. package/lib/Pinned.d.ts.map +1 -0
  24. package/lib/Pinned.js +142 -0
  25. package/lib/Pinned.js.map +1 -0
  26. package/lib/PinnedFamily.d.ts +13 -0
  27. package/lib/PinnedFamily.d.ts.map +1 -0
  28. package/lib/PinnedFamily.js +105 -0
  29. package/lib/PinnedFamily.js.map +1 -0
  30. package/lib/Queries.d.ts +12 -0
  31. package/lib/Queries.d.ts.map +1 -0
  32. package/lib/Queries.js +147 -0
  33. package/lib/Queries.js.map +1 -0
  34. package/lib/QueryOwners.d.ts +7 -0
  35. package/lib/QueryOwners.d.ts.map +1 -0
  36. package/lib/QueryOwners.js +46 -0
  37. package/lib/QueryOwners.js.map +1 -0
  38. package/lib/QueryPills.d.ts +17 -0
  39. package/lib/QueryPills.d.ts.map +1 -0
  40. package/lib/QueryPills.js +37 -0
  41. package/lib/QueryPills.js.map +1 -0
  42. package/lib/QueryPushdown.d.ts +26 -0
  43. package/lib/QueryPushdown.d.ts.map +1 -0
  44. package/lib/QueryPushdown.js +380 -0
  45. package/lib/QueryPushdown.js.map +1 -0
  46. package/lib/QueryTokens.d.ts +25 -0
  47. package/lib/QueryTokens.d.ts.map +1 -0
  48. package/lib/QueryTokens.js +49 -0
  49. package/lib/QueryTokens.js.map +1 -0
  50. package/lib/QueryView.d.ts +37 -0
  51. package/lib/QueryView.d.ts.map +1 -0
  52. package/lib/QueryView.js +547 -0
  53. package/lib/QueryView.js.map +1 -0
  54. package/lib/SchemaView.d.ts +8 -0
  55. package/lib/SchemaView.d.ts.map +1 -0
  56. package/lib/SchemaView.js +213 -0
  57. package/lib/SchemaView.js.map +1 -0
  58. package/lib/Storage.d.ts +17 -0
  59. package/lib/Storage.d.ts.map +1 -0
  60. package/lib/Storage.js +205 -0
  61. package/lib/Storage.js.map +1 -0
  62. package/lib/Tracing.d.ts +7 -0
  63. package/lib/Tracing.d.ts.map +1 -0
  64. package/lib/Tracing.js +344 -0
  65. package/lib/Tracing.js.map +1 -0
  66. package/lib/attribution/Highlight.d.ts +9 -0
  67. package/lib/attribution/Highlight.d.ts.map +1 -0
  68. package/lib/attribution/Highlight.js +73 -0
  69. package/lib/attribution/Highlight.js.map +1 -0
  70. package/lib/attribution/index.d.ts +12 -0
  71. package/lib/attribution/index.d.ts.map +1 -0
  72. package/lib/attribution/index.js +31 -0
  73. package/lib/attribution/index.js.map +1 -0
  74. package/lib/attribution/registry.d.ts +16 -0
  75. package/lib/attribution/registry.d.ts.map +1 -0
  76. package/lib/attribution/registry.js +31 -0
  77. package/lib/attribution/registry.js.map +1 -0
  78. package/lib/attribution/tanstack.d.ts +11 -0
  79. package/lib/attribution/tanstack.d.ts.map +1 -0
  80. package/lib/attribution/tanstack.js +81 -0
  81. package/lib/attribution/tanstack.js.map +1 -0
  82. package/lib/chrome.d.ts +9 -0
  83. package/lib/chrome.d.ts.map +1 -0
  84. package/lib/chrome.js +41 -0
  85. package/lib/chrome.js.map +1 -0
  86. package/lib/diagnostics.d.ts +15 -0
  87. package/lib/diagnostics.d.ts.map +1 -0
  88. package/lib/diagnostics.js +31 -0
  89. package/lib/diagnostics.js.map +1 -0
  90. package/lib/index.d.ts +4 -2
  91. package/lib/index.js +3 -1
  92. package/lib/plugin.d.ts +11 -0
  93. package/lib/plugin.d.ts.map +1 -0
  94. package/lib/plugin.js +62 -0
  95. package/lib/plugin.js.map +1 -0
  96. package/lib/queryIR.d.ts +9 -0
  97. package/lib/queryIR.d.ts.map +1 -0
  98. package/lib/queryIR.js +69 -0
  99. package/lib/queryIR.js.map +1 -0
  100. package/lib/replicationActivity.d.ts +52 -0
  101. package/lib/replicationActivity.d.ts.map +1 -0
  102. package/lib/replicationActivity.js +54 -0
  103. package/lib/replicationActivity.js.map +1 -0
  104. package/lib/schemaLayout.d.ts +35 -0
  105. package/lib/schemaLayout.d.ts.map +1 -0
  106. package/lib/schemaLayout.js +75 -0
  107. package/lib/schemaLayout.js.map +1 -0
  108. package/lib/styles.js +6 -0
  109. package/lib/styles.js.map +1 -0
  110. package/lib/traceTimeline.d.ts +15 -0
  111. package/lib/traceTimeline.d.ts.map +1 -0
  112. package/lib/traceTimeline.js +36 -0
  113. package/lib/traceTimeline.js.map +1 -0
  114. package/lib/traceWaterfall.d.ts +25 -0
  115. package/lib/traceWaterfall.d.ts.map +1 -0
  116. package/lib/traceWaterfall.js +70 -0
  117. package/lib/traceWaterfall.js.map +1 -0
  118. package/lib/typeDisplayName.d.ts +5 -0
  119. package/lib/typeDisplayName.d.ts.map +1 -0
  120. package/lib/typeDisplayName.js +28 -0
  121. package/lib/typeDisplayName.js.map +1 -0
  122. package/lib/types.d.ts +17 -0
  123. package/lib/types.d.ts.map +1 -0
  124. package/lib/types.js +1 -0
  125. package/lib/vite/index.d.ts +18 -0
  126. package/lib/vite/index.d.ts.map +1 -0
  127. package/lib/vite/index.js +148 -0
  128. package/lib/vite/index.js.map +1 -0
  129. package/package.json +25 -8
  130. package/lib/styles.css +0 -2
@@ -0,0 +1,81 @@
1
+ import { queryConsumers } from "./registry.js";
2
+ import { demandId } from "../replicationActivity.js";
3
+ import { getCollectionDemands } from "@party-stack/ontology/tanstack";
4
+ //#region src/attribution/tanstack.ts
5
+ /** TanStack DB 1.0 adapter. Private inspection is confined here and fails closed.
6
+ * No subscriptions, sync runs, queries, or row reads are created by inspection.
7
+ */
8
+ function queryGraph(collection) {
9
+ const utils = collection.utils;
10
+ if (!utils) return;
11
+ const key = Object.getOwnPropertySymbols(utils).find((symbol) => symbol.description === "liveQueryInternal");
12
+ if (!key) return;
13
+ const utility = Reflect.get(utils, key);
14
+ if (typeof utility?.getBuilder !== "function") return;
15
+ const graph = utility.getBuilder();
16
+ return typeof graph?.getSourceCollections === "function" && graph.subscriptions && typeof graph.subscriptions === "object" ? graph : void 0;
17
+ }
18
+ function queryDemandGraph(collection) {
19
+ const result = [];
20
+ const seen = /* @__PURE__ */ new Set();
21
+ const visit = (current) => {
22
+ if (seen.has(current)) return;
23
+ seen.add(current);
24
+ const own = (key) => Object.getOwnPropertyDescriptor(current, key)?.value;
25
+ const source = own("source");
26
+ const partition = own("partition");
27
+ if (source && partition && typeof own("groupKey") === "string") {
28
+ const partitionSource = Object.getOwnPropertyDescriptor(partition, "source")?.value;
29
+ const subscription = Object.getOwnPropertyDescriptor(partition, "subscription")?.value;
30
+ if (partitionSource !== source) return;
31
+ for (const demand of getCollectionDemands(source)) if (subscription && demand.subscription === subscription) result.push({
32
+ ...demand,
33
+ collection: source
34
+ });
35
+ visit(source);
36
+ const materialized = own("collection");
37
+ if (materialized) visit(materialized);
38
+ return;
39
+ }
40
+ const graph = queryGraph(current);
41
+ if (!graph) return;
42
+ const subscriptions = new Set(Object.values(graph.subscriptions));
43
+ for (const source of graph.getSourceCollections()) {
44
+ for (const demand of getCollectionDemands(source)) if (demand.subscription && subscriptions.has(demand.subscription)) result.push({
45
+ ...demand,
46
+ collection: source
47
+ });
48
+ visit(source);
49
+ }
50
+ };
51
+ try {
52
+ visit(collection);
53
+ } catch {
54
+ return [];
55
+ }
56
+ return result;
57
+ }
58
+ function demandOwners(demand, sources) {
59
+ const key = demandId(demand);
60
+ const roots = new Set(sources);
61
+ const owners = /* @__PURE__ */ new Map();
62
+ for (const consumer of queryConsumers()) if (queryDemandGraph(consumer.collection).some((request) => roots.has(request.collection) && demandId(request) === key)) owners.set(consumer.owner.id, consumer.owner);
63
+ return [...owners.values()];
64
+ }
65
+ function demandRequests(demand, sources) {
66
+ const key = demandId(demand);
67
+ const roots = new Set(sources);
68
+ const requests = /* @__PURE__ */ new Map();
69
+ for (const consumer of queryConsumers()) for (const request of queryDemandGraph(consumer.collection)) {
70
+ if (!request.requested || !roots.has(request.collection) || demandId(request) !== key) continue;
71
+ try {
72
+ const signature = JSON.stringify(request.requested, (_, value) => typeof value === "bigint" ? `${value}n` : value);
73
+ requests.set(signature, request);
74
+ } catch {}
75
+ }
76
+ return [...requests.values()];
77
+ }
78
+ //#endregion
79
+ export { demandOwners, demandRequests, queryDemandGraph };
80
+
81
+ //# sourceMappingURL=tanstack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tanstack.js","names":[],"sources":["../../src/attribution/tanstack.ts"],"sourcesContent":["import { getCollectionDemands, type CollectionDemandDiagnostic } from \"@party-stack/ontology/tanstack\";\nimport { demandId, type ReplicationDemand } from \"../replicationActivity.js\";\nimport { queryConsumers, type DemandOwner } from \"./registry.js\";\n\ninterface Graph {\n getSourceCollections(): readonly object[];\n readonly subscriptions: Record<string, object>;\n}\n/** TanStack DB 1.0 adapter. Private inspection is confined here and fails closed.\n * No subscriptions, sync runs, queries, or row reads are created by inspection.\n */\nfunction queryGraph(collection: object): Graph | undefined {\n const utils = (collection as { utils?: object }).utils;\n if (!utils) return;\n const key = Object.getOwnPropertySymbols(utils).find(\n (symbol) => symbol.description === \"liveQueryInternal\"\n );\n if (!key) return;\n const utility = Reflect.get(utils, key) as { getBuilder?: () => Graph } | undefined;\n if (typeof utility?.getBuilder !== \"function\") return;\n const graph = utility.getBuilder();\n return typeof graph?.getSourceCollections === \"function\" &&\n graph.subscriptions &&\n typeof graph.subscriptions === \"object\"\n ? graph\n : undefined;\n}\n\nexport function queryDemandGraph(\n collection: object\n): readonly (CollectionDemandDiagnostic & { collection: object })[] {\n const result: (CollectionDemandDiagnostic & { collection: object })[] = [];\n const seen = new Set<object>();\n const visit = (current: object) => {\n if (seen.has(current)) return;\n seen.add(current);\n // A pooled hook result is a lazy Proxy: reading .utils would materialize\n // another query and acquire demand. Inspect its own data descriptors only.\n const own = (key: string) => Object.getOwnPropertyDescriptor(current, key)?.value;\n const source = own(\"source\") as object | undefined;\n const partition = own(\"partition\") as object | undefined;\n if (source && partition && typeof own(\"groupKey\") === \"string\") {\n const partitionSource = Object.getOwnPropertyDescriptor(partition, \"source\")?.value;\n const subscription = Object.getOwnPropertyDescriptor(partition, \"subscription\")?.value;\n if (partitionSource !== source) return;\n for (const demand of getCollectionDemands(source))\n if (subscription && demand.subscription === subscription)\n result.push({ ...demand, collection: source });\n visit(source);\n const materialized = own(\"collection\") as object | undefined;\n if (materialized) visit(materialized);\n return;\n }\n const graph = queryGraph(current);\n if (!graph) return;\n const subscriptions = new Set(Object.values(graph.subscriptions));\n for (const source of graph.getSourceCollections()) {\n for (const demand of getCollectionDemands(source))\n if (demand.subscription && subscriptions.has(demand.subscription))\n result.push({ ...demand, collection: source });\n visit(source);\n }\n };\n try {\n visit(collection);\n } catch {\n return [];\n }\n return result;\n}\n\nexport function demandOwners(\n demand: Pick<ReplicationDemand, \"objectType\" | \"query\">,\n sources: readonly object[]\n): readonly DemandOwner[] {\n const key = demandId(demand);\n const roots = new Set(sources);\n const owners = new Map<string, DemandOwner>();\n for (const consumer of queryConsumers())\n if (\n queryDemandGraph(consumer.collection).some(\n (request) => roots.has(request.collection) && demandId(request) === key\n )\n )\n owners.set(consumer.owner.id, consumer.owner);\n return [...owners.values()];\n}\n\nexport function demandRequests(\n demand: Pick<ReplicationDemand, \"objectType\" | \"query\">,\n sources: readonly object[]\n) {\n const key = demandId(demand);\n const roots = new Set(sources);\n const requests = new Map<string, CollectionDemandDiagnostic>();\n for (const consumer of queryConsumers())\n for (const request of queryDemandGraph(consumer.collection)) {\n if (!request.requested || !roots.has(request.collection) || demandId(request) !== key) continue;\n try {\n const signature = JSON.stringify(request.requested, (_, value: unknown) =>\n typeof value === \"bigint\" ? `${value}n` : value\n );\n requests.set(signature, request);\n } catch {\n /* Nonportable diagnostic values cannot break the inspector. */\n }\n }\n return [...requests.values()];\n}\n"],"mappings":";;;;;;;AAWA,SAAS,WAAW,YAAuC;CACvD,MAAM,QAAS,WAAkC;CACjD,IAAI,CAAC,OAAO;CACZ,MAAM,MAAM,OAAO,sBAAsB,KAAK,CAAC,CAAC,MAC3C,WAAW,OAAO,gBAAgB,mBACvC;CACA,IAAI,CAAC,KAAK;CACV,MAAM,UAAU,QAAQ,IAAI,OAAO,GAAG;CACtC,IAAI,OAAO,SAAS,eAAe,YAAY;CAC/C,MAAM,QAAQ,QAAQ,WAAW;CACjC,OAAO,OAAO,OAAO,yBAAyB,cAC1C,MAAM,iBACN,OAAO,MAAM,kBAAkB,WAC7B,QACA,KAAA;AACV;AAEA,SAAgB,iBACZ,YACgE;CAChE,MAAM,SAAkE,CAAC;CACzE,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,SAAS,YAAoB;EAC/B,IAAI,KAAK,IAAI,OAAO,GAAG;EACvB,KAAK,IAAI,OAAO;EAGhB,MAAM,OAAO,QAAgB,OAAO,yBAAyB,SAAS,GAAG,CAAC,EAAE;EAC5E,MAAM,SAAS,IAAI,QAAQ;EAC3B,MAAM,YAAY,IAAI,WAAW;EACjC,IAAI,UAAU,aAAa,OAAO,IAAI,UAAU,MAAM,UAAU;GAC5D,MAAM,kBAAkB,OAAO,yBAAyB,WAAW,QAAQ,CAAC,EAAE;GAC9E,MAAM,eAAe,OAAO,yBAAyB,WAAW,cAAc,CAAC,EAAE;GACjF,IAAI,oBAAoB,QAAQ;GAChC,KAAK,MAAM,UAAU,qBAAqB,MAAM,GAC5C,IAAI,gBAAgB,OAAO,iBAAiB,cACxC,OAAO,KAAK;IAAE,GAAG;IAAQ,YAAY;GAAO,CAAC;GACrD,MAAM,MAAM;GACZ,MAAM,eAAe,IAAI,YAAY;GACrC,IAAI,cAAc,MAAM,YAAY;GACpC;EACJ;EACA,MAAM,QAAQ,WAAW,OAAO;EAChC,IAAI,CAAC,OAAO;EACZ,MAAM,gBAAgB,IAAI,IAAI,OAAO,OAAO,MAAM,aAAa,CAAC;EAChE,KAAK,MAAM,UAAU,MAAM,qBAAqB,GAAG;GAC/C,KAAK,MAAM,UAAU,qBAAqB,MAAM,GAC5C,IAAI,OAAO,gBAAgB,cAAc,IAAI,OAAO,YAAY,GAC5D,OAAO,KAAK;IAAE,GAAG;IAAQ,YAAY;GAAO,CAAC;GACrD,MAAM,MAAM;EAChB;CACJ;CACA,IAAI;EACA,MAAM,UAAU;CACpB,QAAQ;EACJ,OAAO,CAAC;CACZ;CACA,OAAO;AACX;AAEA,SAAgB,aACZ,QACA,SACsB;CACtB,MAAM,MAAM,SAAS,MAAM;CAC3B,MAAM,QAAQ,IAAI,IAAI,OAAO;CAC7B,MAAM,yBAAS,IAAI,IAAyB;CAC5C,KAAK,MAAM,YAAY,eAAe,GAClC,IACI,iBAAiB,SAAS,UAAU,CAAC,CAAC,MACjC,YAAY,MAAM,IAAI,QAAQ,UAAU,KAAK,SAAS,OAAO,MAAM,GACxE,GAEA,OAAO,IAAI,SAAS,MAAM,IAAI,SAAS,KAAK;CACpD,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;AAC9B;AAEA,SAAgB,eACZ,QACA,SACF;CACE,MAAM,MAAM,SAAS,MAAM;CAC3B,MAAM,QAAQ,IAAI,IAAI,OAAO;CAC7B,MAAM,2BAAW,IAAI,IAAwC;CAC7D,KAAK,MAAM,YAAY,eAAe,GAClC,KAAK,MAAM,WAAW,iBAAiB,SAAS,UAAU,GAAG;EACzD,IAAI,CAAC,QAAQ,aAAa,CAAC,MAAM,IAAI,QAAQ,UAAU,KAAK,SAAS,OAAO,MAAM,KAAK;EACvF,IAAI;GACA,MAAM,YAAY,KAAK,UAAU,QAAQ,YAAY,GAAG,UACpD,OAAO,UAAU,WAAW,GAAG,MAAM,KAAK,KAC9C;GACA,SAAS,IAAI,WAAW,OAAO;EACnC,QAAQ,CAER;CACJ;CACJ,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC;AAChC"}
@@ -0,0 +1,9 @@
1
+ //#region src/chrome.d.ts
2
+ export interface OntologyDevtoolsChromeProps {
3
+ theme: "light" | "dark";
4
+ }
5
+ export declare function OntologyDevtoolsPluginName({ theme }: OntologyDevtoolsChromeProps): import("react").JSX.Element;
6
+ export declare function OntologyDevtoolsTrigger({ theme }: OntologyDevtoolsChromeProps): import("react").JSX.Element;
7
+ export declare function ontologyDevtoolsTrigger(_element: HTMLElement, { theme }: OntologyDevtoolsChromeProps): import("react").JSX.Element;
8
+ //#endregion
9
+ //# sourceMappingURL=chrome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.d.ts","names":[],"sources":["../src/chrome.tsx"],"mappings":";iBAEiB;EACb;;wBAGY,6BAA6B,SAAS,8CAA2B,IAAA;wBAQjE,0BAA0B,SAAS,8CAA2B,IAAA;wBA8B9D,wBAAwB,UAAU,eAAe,SAAS,8CAA2B,IAAA"}
package/lib/chrome.js ADDED
@@ -0,0 +1,41 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { PartyStackLogo, PartyStackLogomark } from "@party-stack/design-system/brand";
3
+ //#region src/chrome.tsx
4
+ function OntologyDevtoolsPluginName({ theme }) {
5
+ return /* @__PURE__ */ jsx("div", {
6
+ style: {
7
+ height: 30,
8
+ width: 120
9
+ },
10
+ children: /* @__PURE__ */ jsx(PartyStackLogo, { theme })
11
+ });
12
+ }
13
+ function OntologyDevtoolsTrigger({ theme }) {
14
+ const dark = theme === "dark";
15
+ return /* @__PURE__ */ jsx("div", {
16
+ "aria-label": "Open Ontology devtools",
17
+ style: {
18
+ alignItems: "center",
19
+ background: dark ? "linear-gradient(145deg, #2d2d31, #171719)" : "linear-gradient(145deg, #fff, #f5f5f4)",
20
+ border: dark ? "1px solid rgba(255,255,255,.16)" : "1px solid rgba(23,23,23,.14)",
21
+ borderRadius: "999px",
22
+ boxSizing: "border-box",
23
+ boxShadow: dark ? "0 10px 30px rgba(0,0,0,.34), 0 0 0 4px rgba(141,120,235,.11)" : "0 10px 28px rgba(28,25,23,.16), 0 0 0 4px rgba(141,120,235,.09)",
24
+ cursor: "pointer",
25
+ display: "flex",
26
+ height: 48,
27
+ justifyContent: "center",
28
+ padding: 8,
29
+ width: 48
30
+ },
31
+ title: "Open Ontology devtools",
32
+ children: /* @__PURE__ */ jsx(PartyStackLogomark, {})
33
+ });
34
+ }
35
+ function ontologyDevtoolsTrigger(_element, { theme }) {
36
+ return /* @__PURE__ */ jsx(OntologyDevtoolsTrigger, { theme });
37
+ }
38
+ //#endregion
39
+ export { OntologyDevtoolsPluginName, OntologyDevtoolsTrigger, ontologyDevtoolsTrigger };
40
+
41
+ //# sourceMappingURL=chrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.js","names":[],"sources":["../src/chrome.tsx"],"sourcesContent":["import { PartyStackLogo, PartyStackLogomark } from \"@party-stack/design-system/brand\";\n\nexport interface OntologyDevtoolsChromeProps {\n theme: \"light\" | \"dark\";\n}\n\nexport function OntologyDevtoolsPluginName({ theme }: OntologyDevtoolsChromeProps) {\n return (\n <div style={{ height: 30, width: 120 }}>\n <PartyStackLogo theme={theme} />\n </div>\n );\n}\n\nexport function OntologyDevtoolsTrigger({ theme }: OntologyDevtoolsChromeProps) {\n const dark = theme === \"dark\";\n return (\n <div\n aria-label=\"Open Ontology devtools\"\n style={{\n alignItems: \"center\",\n background: dark\n ? \"linear-gradient(145deg, #2d2d31, #171719)\"\n : \"linear-gradient(145deg, #fff, #f5f5f4)\",\n border: dark ? \"1px solid rgba(255,255,255,.16)\" : \"1px solid rgba(23,23,23,.14)\",\n borderRadius: \"999px\",\n boxSizing: \"border-box\",\n boxShadow: dark\n ? \"0 10px 30px rgba(0,0,0,.34), 0 0 0 4px rgba(141,120,235,.11)\"\n : \"0 10px 28px rgba(28,25,23,.16), 0 0 0 4px rgba(141,120,235,.09)\",\n cursor: \"pointer\",\n display: \"flex\",\n height: 48,\n justifyContent: \"center\",\n padding: 8,\n width: 48,\n }}\n title=\"Open Ontology devtools\"\n >\n <PartyStackLogomark />\n </div>\n );\n}\n\nexport function ontologyDevtoolsTrigger(_element: HTMLElement, { theme }: OntologyDevtoolsChromeProps) {\n return <OntologyDevtoolsTrigger theme={theme} />;\n}\n"],"mappings":";;;AAMA,SAAgB,2BAA2B,EAAE,SAAsC;CAC/E,OACI,oBAAC,OAAD;EAAK,OAAO;GAAE,QAAQ;GAAI,OAAO;EAAI;EACjC,UAAA,oBAAC,gBAAD,EAAuB,MAAQ,CAAA;CAC9B,CAAA;AAEb;AAEA,SAAgB,wBAAwB,EAAE,SAAsC;CAC5E,MAAM,OAAO,UAAU;CACvB,OACI,oBAAC,OAAD;EACI,cAAW;EACX,OAAO;GACH,YAAY;GACZ,YAAY,OACN,8CACA;GACN,QAAQ,OAAO,oCAAoC;GACnD,cAAc;GACd,WAAW;GACX,WAAW,OACL,iEACA;GACN,QAAQ;GACR,SAAS;GACT,QAAQ;GACR,gBAAgB;GAChB,SAAS;GACT,OAAO;EACX;EACA,OAAM;EAEN,UAAA,oBAAC,oBAAD,CAAqB,CAAA;CACpB,CAAA;AAEb;AAEA,SAAgB,wBAAwB,UAAuB,EAAE,SAAsC;CACnG,OAAO,oBAAC,yBAAD,EAAgC,MAAQ,CAAA;AACnD"}
@@ -0,0 +1,15 @@
1
+ import { LiveOntology } from "@party-stack/ontology";
2
+ //#region src/diagnostics.d.ts
3
+ export type Diagnostics = NonNullable<LiveOntology["diagnostics"]>;
4
+ export type Status = NonNullable<ReturnType<Diagnostics["replica"]["getSnapshot"]>["status"]>;
5
+ export type Demand = Status["demands"][number];
6
+ export type Load = Status["loads"][number];
7
+ export declare function useReplicaStatus(diagnostics?: Diagnostics): ReturnType<Diagnostics["replica"]["getSnapshot"]>;
8
+ export declare function useTraceSpans(store?: LiveOntology["traces"]): readonly import("@party-stack/runtime/tracing").TraceRecord[];
9
+ export declare function diagnosticTargets(diagnostics?: Diagnostics): {
10
+ label: string;
11
+ value: Diagnostics;
12
+ }[];
13
+ export declare const ms: (value: number) => string;
14
+ //#endregion
15
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","names":[],"sources":["../src/diagnostics.ts"],"mappings":";;YAIY,cAAc,YAAY;YAC1B,SAAS,YAAY,WAAW;YAChC,SAAS;YACT,OAAO;wBAMH,iBAAiB,cAAc,cAMtC,WAAW;wBAEJ,cAAc,QAAQ,yEAAsB;wBAG5C,kBAAkB,cAAc;EACpB;EAAe,OAAA;;qBAQ9B,KAAE"}
@@ -0,0 +1,31 @@
1
+ import { useSyncExternalStore } from "react";
2
+ //#region src/diagnostics.ts
3
+ const empty = {};
4
+ const noSnapshot = () => empty;
5
+ const emptySpans = [];
6
+ const noSpans = () => emptySpans;
7
+ const noSubscription = () => () => void 0;
8
+ function useReplicaStatus(diagnostics) {
9
+ const store = diagnostics?.replica;
10
+ return useSyncExternalStore(store?.subscribe ?? noSubscription, store?.getSnapshot ?? noSnapshot, noSnapshot);
11
+ }
12
+ function useTraceSpans(store) {
13
+ return useSyncExternalStore(store?.subscribe ?? noSubscription, store?.getSnapshot ?? noSpans, noSpans);
14
+ }
15
+ function diagnosticTargets(diagnostics) {
16
+ const targets = [];
17
+ for (let node = diagnostics; node; node = node.parent) {
18
+ if (targets.some((target) => target.value === node)) break;
19
+ const label = !targets.length ? "This tab" : node.location ?? node.label ?? "Host";
20
+ targets.push({
21
+ label,
22
+ value: node
23
+ });
24
+ }
25
+ return targets;
26
+ }
27
+ const ms = (value) => value < 1 ? `${(value * 1e3).toFixed(0)} µs` : `${value.toFixed(1)} ms`;
28
+ //#endregion
29
+ export { diagnosticTargets, ms, useReplicaStatus, useTraceSpans };
30
+
31
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","names":[],"sources":["../src/diagnostics.ts"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\nimport type { PerformanceSpan } from \"./traceWaterfall.js\";\nimport type { LiveOntology } from \"@party-stack/ontology\";\n\nexport type Diagnostics = NonNullable<LiveOntology[\"diagnostics\"]>;\nexport type Status = NonNullable<ReturnType<Diagnostics[\"replica\"][\"getSnapshot\"]>[\"status\"]>;\nexport type Demand = Status[\"demands\"][number];\nexport type Load = Status[\"loads\"][number];\nconst empty = {};\nconst noSnapshot = () => empty;\nconst emptySpans: readonly PerformanceSpan[] = [];\nconst noSpans = () => emptySpans;\nconst noSubscription = () => () => undefined;\nexport function useReplicaStatus(diagnostics?: Diagnostics) {\n const store = diagnostics?.replica;\n return useSyncExternalStore(\n store?.subscribe ?? noSubscription,\n store?.getSnapshot ?? noSnapshot,\n noSnapshot\n ) as ReturnType<Diagnostics[\"replica\"][\"getSnapshot\"]>;\n}\nexport function useTraceSpans(store?: LiveOntology[\"traces\"]) {\n return useSyncExternalStore(store?.subscribe ?? noSubscription, store?.getSnapshot ?? noSpans, noSpans);\n}\nexport function diagnosticTargets(diagnostics?: Diagnostics) {\n const targets: { label: string; value: Diagnostics }[] = [];\n for (let node = diagnostics; node; node = node.parent) {\n if (targets.some((target) => target.value === node)) break;\n const label = !targets.length ? \"This tab\" : (node.location ?? node.label ?? \"Host\");\n targets.push({ label, value: node });\n }\n return targets;\n}\nexport const ms = (value: number) =>\n value < 1 ? `${(value * 1000).toFixed(0)} µs` : `${value.toFixed(1)} ms`;\n"],"mappings":";;AAQA,MAAM,QAAQ,CAAC;AACf,MAAM,mBAAmB;AACzB,MAAM,aAAyC,CAAC;AAChD,MAAM,gBAAgB;AACtB,MAAM,6BAA6B,KAAA;AACnC,SAAgB,iBAAiB,aAA2B;CACxD,MAAM,QAAQ,aAAa;CAC3B,OAAO,qBACH,OAAO,aAAa,gBACpB,OAAO,eAAe,YACtB,UACJ;AACJ;AACA,SAAgB,cAAc,OAAgC;CAC1D,OAAO,qBAAqB,OAAO,aAAa,gBAAgB,OAAO,eAAe,SAAS,OAAO;AAC1G;AACA,SAAgB,kBAAkB,aAA2B;CACzD,MAAM,UAAmD,CAAC;CAC1D,KAAK,IAAI,OAAO,aAAa,MAAM,OAAO,KAAK,QAAQ;EACnD,IAAI,QAAQ,MAAM,WAAW,OAAO,UAAU,IAAI,GAAG;EACrD,MAAM,QAAQ,CAAC,QAAQ,SAAS,aAAc,KAAK,YAAY,KAAK,SAAS;EAC7E,QAAQ,KAAK;GAAE;GAAO,OAAO;EAAK,CAAC;CACvC;CACA,OAAO;AACX;AACA,MAAa,MAAM,UACf,QAAQ,IAAI,IAAI,QAAQ,IAAA,CAAM,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,QAAQ,CAAC,EAAE"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- import { OntologyDevtoolsChromeProps, OntologyDevtoolsPanel, OntologyDevtoolsPanelProps, OntologyDevtoolsPluginName, OntologyDevtoolsPluginOptions, OntologyDevtoolsTrigger, createOntologyDevtoolsPlugin, ontologyDevtoolsTrigger } from "./OntologyDevtools.js";
2
- export { type OntologyDevtoolsChromeProps, OntologyDevtoolsPanel, type OntologyDevtoolsPanelProps, OntologyDevtoolsPluginName, type OntologyDevtoolsPluginOptions, OntologyDevtoolsTrigger, createOntologyDevtoolsPlugin, ontologyDevtoolsTrigger };
1
+ import { OntologyDevtoolsPanelProps, OntologyDevtoolsPluginOptions } from "./types.js";
2
+ import { OntologyDevtoolsChromeProps, OntologyDevtoolsPluginName, OntologyDevtoolsTrigger, ontologyDevtoolsTrigger } from "./chrome.js";
3
+ import { OntologyDevtoolsPanel, createOntologyDevtoolsPlugin, preloadOntologyDevtools } from "./plugin.js";
4
+ export { type OntologyDevtoolsChromeProps, OntologyDevtoolsPanel, type OntologyDevtoolsPanelProps, OntologyDevtoolsPluginName, type OntologyDevtoolsPluginOptions, OntologyDevtoolsTrigger, createOntologyDevtoolsPlugin, ontologyDevtoolsTrigger, preloadOntologyDevtools };
package/lib/index.js CHANGED
@@ -1 +1,3 @@
1
- export { OntologyDevtoolsPanel, OntologyDevtoolsPluginName, OntologyDevtoolsTrigger, createOntologyDevtoolsPlugin, ontologyDevtoolsTrigger } from "./OntologyDevtools.js";
1
+ import { OntologyDevtoolsPluginName, OntologyDevtoolsTrigger, ontologyDevtoolsTrigger } from "./chrome.js";
2
+ import { OntologyDevtoolsPanel, createOntologyDevtoolsPlugin, preloadOntologyDevtools } from "./plugin.js";
3
+ export { OntologyDevtoolsPanel, OntologyDevtoolsPluginName, OntologyDevtoolsTrigger, createOntologyDevtoolsPlugin, ontologyDevtoolsTrigger, preloadOntologyDevtools };
@@ -0,0 +1,11 @@
1
+ import { OntologyDevtoolsPanelProps, OntologyDevtoolsPluginOptions } from "./types.js";
2
+ import { OntologyDefinition } from "@party-stack/ontology";
3
+ import { TanStackDevtoolsReactPlugin } from "@tanstack/react-devtools";
4
+ //#region src/plugin.d.ts
5
+ /** Warm optional inspector code after the application's first data is displayed, for offline use. */
6
+ export declare const preloadOntologyDevtools: () => Promise<undefined>;
7
+ /** Loading the shell must not import inspectors, schema layout or collection subscriptions. */
8
+ export declare function OntologyDevtoolsPanel<Ontology extends OntologyDefinition, MetaOntology extends OntologyDefinition = OntologyDefinition>(props: OntologyDevtoolsPanelProps<Ontology, MetaOntology>): import("react").JSX.Element;
9
+ export declare function createOntologyDevtoolsPlugin<Ontology extends OntologyDefinition, MetaOntology extends OntologyDefinition = OntologyDefinition>({ ontology, id, metaOntology, name, defaultOpen }: OntologyDevtoolsPluginOptions<Ontology, MetaOntology>): TanStackDevtoolsReactPlugin;
10
+ //#endregion
11
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;qBAYa,+BAAuB;;wBAiBpB,sBACZ,iBAAiB,oBACjB,qBAAqB,qBAAqB,oBAC5C,OAAO,2BAA2B,UAAU,gCAAa,IAAA;wBAsB3C,6BACZ,iBAAiB,oBACjB,qBAAqB,qBAAqB,sBAE1C,UACA,IACA,cACA,MACA,eACD,8BAA8B,UAAU,gBAAgB"}
package/lib/plugin.js ADDED
@@ -0,0 +1,62 @@
1
+ import { OntologyDevtoolsPluginName } from "./chrome.js";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { Component, Suspense, lazy } from "react";
4
+ import { PartyStackLogomark } from "@party-stack/design-system/brand";
5
+ import { createReactPlugin } from "@tanstack/devtools-utils/react";
6
+ //#region src/plugin.tsx
7
+ const loadPanel = () => import("./OntologyDevtools.js");
8
+ const Panel = lazy(() => loadPanel().then((module) => ({ default: module.OntologyDevtoolsPanel })));
9
+ /** Warm optional inspector code after the application's first data is displayed, for offline use. */
10
+ const preloadOntologyDevtools = () => loadPanel().then(() => void 0);
11
+ var InspectorBoundary = class extends Component {
12
+ state = { failed: false };
13
+ static getDerivedStateFromError() {
14
+ return { failed: true };
15
+ }
16
+ render() {
17
+ return this.state.failed ? /* @__PURE__ */ jsx("p", { children: "The inspector could not load. Reconnect and reload to try again." }) : this.props.children;
18
+ }
19
+ };
20
+ /** Loading the shell must not import inspectors, schema layout or collection subscriptions. */
21
+ function OntologyDevtoolsPanel(props) {
22
+ return /* @__PURE__ */ jsx(InspectorBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
23
+ fallback: /* @__PURE__ */ jsx("div", {
24
+ role: "status",
25
+ "aria-label": "Loading inspector",
26
+ style: {
27
+ height: "100%",
28
+ minHeight: 160,
29
+ display: "grid",
30
+ placeItems: "center"
31
+ },
32
+ children: /* @__PURE__ */ jsx("div", {
33
+ style: {
34
+ width: 44,
35
+ height: 44
36
+ },
37
+ children: /* @__PURE__ */ jsx(PartyStackLogomark, {})
38
+ })
39
+ }),
40
+ children: /* @__PURE__ */ jsx(Panel, { ...props })
41
+ }) });
42
+ }
43
+ function createOntologyDevtoolsPlugin({ ontology, id = "party-stack-ontology", metaOntology, name, defaultOpen }) {
44
+ const [createPlugin] = createReactPlugin({
45
+ id,
46
+ name: "Ontology",
47
+ defaultOpen,
48
+ Component: ({ theme, devtoolsOpen }) => devtoolsOpen ? /* @__PURE__ */ jsx(OntologyDevtoolsPanel, {
49
+ metaOntology,
50
+ ontology,
51
+ theme
52
+ }) : /* @__PURE__ */ jsx(Fragment, {})
53
+ });
54
+ return {
55
+ ...createPlugin(),
56
+ name: name ?? ((_element, { theme }) => /* @__PURE__ */ jsx(OntologyDevtoolsPluginName, { theme }))
57
+ };
58
+ }
59
+ //#endregion
60
+ export { OntologyDevtoolsPanel, createOntologyDevtoolsPlugin, preloadOntologyDevtools };
61
+
62
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":["import { PartyStackLogomark } from \"@party-stack/design-system/brand\";\nimport { createReactPlugin } from \"@tanstack/devtools-utils/react\";\nimport { Component, lazy, Suspense, type ReactNode } from \"react\";\nimport { OntologyDevtoolsPluginName } from \"./chrome.js\";\nimport type { OntologyDevtoolsPanelProps, OntologyDevtoolsPluginOptions } from \"./types.js\";\nimport type { OntologyDefinition } from \"@party-stack/ontology\";\nimport type { TanStackDevtoolsReactPlugin } from \"@tanstack/react-devtools\";\n\nconst loadPanel = () => import(\"./OntologyDevtools.js\");\nconst Panel = lazy(() => loadPanel().then((module) => ({ default: module.OntologyDevtoolsPanel })));\n\n/** Warm optional inspector code after the application's first data is displayed, for offline use. */\nexport const preloadOntologyDevtools = () => loadPanel().then(() => undefined);\n\nclass InspectorBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n static getDerivedStateFromError() {\n return { failed: true };\n }\n render() {\n return this.state.failed ? (\n <p>The inspector could not load. Reconnect and reload to try again.</p>\n ) : (\n this.props.children\n );\n }\n}\n\n/** Loading the shell must not import inspectors, schema layout or collection subscriptions. */\nexport function OntologyDevtoolsPanel<\n Ontology extends OntologyDefinition,\n MetaOntology extends OntologyDefinition = OntologyDefinition,\n>(props: OntologyDevtoolsPanelProps<Ontology, MetaOntology>) {\n return (\n <InspectorBoundary>\n <Suspense\n fallback={\n <div\n role=\"status\"\n aria-label=\"Loading inspector\"\n style={{ height: \"100%\", minHeight: 160, display: \"grid\", placeItems: \"center\" }}\n >\n <div style={{ width: 44, height: 44 }}>\n <PartyStackLogomark />\n </div>\n </div>\n }\n >\n <Panel {...props} />\n </Suspense>\n </InspectorBoundary>\n );\n}\n\nexport function createOntologyDevtoolsPlugin<\n Ontology extends OntologyDefinition,\n MetaOntology extends OntologyDefinition = OntologyDefinition,\n>({\n ontology,\n id = \"party-stack-ontology\",\n metaOntology,\n name,\n defaultOpen,\n}: OntologyDevtoolsPluginOptions<Ontology, MetaOntology>): TanStackDevtoolsReactPlugin {\n const [createPlugin] = createReactPlugin({\n id,\n name: \"Ontology\",\n defaultOpen,\n Component: ({ theme, devtoolsOpen }) =>\n devtoolsOpen ? (\n <OntologyDevtoolsPanel metaOntology={metaOntology} ontology={ontology} theme={theme} />\n ) : (\n <></>\n ),\n });\n return {\n ...createPlugin(),\n name: name ?? ((_element, { theme }) => <OntologyDevtoolsPluginName theme={theme} />),\n };\n}\n"],"mappings":";;;;;;AAQA,MAAM,kBAAkB,OAAO;AAC/B,MAAM,QAAQ,WAAW,UAAU,CAAC,CAAC,MAAM,YAAY,EAAE,SAAS,OAAO,sBAAsB,EAAE,CAAC;;AAGlG,MAAa,gCAAgC,UAAU,CAAC,CAAC,WAAW,KAAA,CAAS;AAE7E,IAAM,oBAAN,cAAgC,UAAwD;CACpF,QAAQ,EAAE,QAAQ,MAAM;CACxB,OAAO,2BAA2B;EAC9B,OAAO,EAAE,QAAQ,KAAK;CAC1B;CACA,SAAS;EACL,OAAO,KAAK,MAAM,SACd,oBAAC,KAAD,EAAA,UAAG,mEAAmE,CAAA,IAEtE,KAAK,MAAM;CAEnB;AACJ;;AAGA,SAAgB,sBAGd,OAA2D;CACzD,OACI,oBAAC,mBAAD,EAAA,UACI,oBAAC,UAAD;EACI,UACI,oBAAC,OAAD;GACI,MAAK;GACL,cAAW;GACX,OAAO;IAAE,QAAQ;IAAQ,WAAW;IAAK,SAAS;IAAQ,YAAY;GAAS;GAE/E,UAAA,oBAAC,OAAD;IAAK,OAAO;KAAE,OAAO;KAAI,QAAQ;IAAG;IAChC,UAAA,oBAAC,oBAAD,CAAqB,CAAA;GACpB,CAAA;EACJ,CAAA;EAGT,UAAA,oBAAC,OAAD,EAAO,GAAI,MAAQ,CAAA;CACb,CAAA,EACK,CAAA;AAE3B;AAEA,SAAgB,6BAGd,EACE,UACA,KAAK,wBACL,cACA,MACA,eACmF;CACnF,MAAM,CAAC,gBAAgB,kBAAkB;EACrC;EACA,MAAM;EACN;EACA,YAAY,EAAE,OAAO,mBACjB,eACI,oBAAC,uBAAD;GAAqC;GAAwB;GAAiB;EAAQ,CAAA,IAEtF,oBAAA,UAAA,CAAI,CAAA;CAEhB,CAAC;CACD,OAAO;EACH,GAAG,aAAa;EAChB,MAAM,UAAU,UAAU,EAAE,YAAY,oBAAC,4BAAD,EAAmC,MAAQ,CAAA;CACvF;AACJ"}
@@ -0,0 +1,9 @@
1
+ import { Demand } from "./diagnostics.js";
2
+ import { Query } from "@party-stack/ontology";
3
+ //#region src/queryIR.d.ts
4
+ type Subset = NonNullable<Demand["query"]>;
5
+ /** One renderer for portable query graphs and the engine's compiled subsets. */
6
+ export declare function subsetQuery(objectType: string, subset?: Subset): Query;
7
+ //#endregion
8
+ export {};
9
+ //# sourceMappingURL=queryIR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryIR.d.ts","names":[],"sources":["../src/queryIR.ts"],"mappings":";;;KAIK,SAAS,YAAY;;wBAuBV,YAAY,oBAAoB,SAAS,SAAS"}
package/lib/queryIR.js ADDED
@@ -0,0 +1,69 @@
1
+ //#region src/queryIR.ts
2
+ const literal = (value) => ({
3
+ kind: "literal",
4
+ value: { value }
5
+ });
6
+ function operand(value) {
7
+ return value !== null && typeof value === "object" && "_tag" in value && value._tag === "Field" ? {
8
+ kind: "getAt",
9
+ value: {
10
+ source: {
11
+ kind: "localReference",
12
+ value: { name: "row" }
13
+ },
14
+ path: [...value.path]
15
+ }
16
+ } : literal(value);
17
+ }
18
+ function predicate(value) {
19
+ if (value.op === "and" || value.op === "or") return {
20
+ kind: value.op,
21
+ value: { expressions: value.predicates.map(predicate) }
22
+ };
23
+ if (value.op === "not") return {
24
+ kind: "not",
25
+ value: { expression: predicate(value.predicate) }
26
+ };
27
+ if (value.op === "in") return {
28
+ kind: "in",
29
+ value: {
30
+ left: operand(value.left),
31
+ right: literal(value.values)
32
+ }
33
+ };
34
+ return {
35
+ kind: value.op,
36
+ value: {
37
+ left: operand(value.left),
38
+ right: operand(value.right)
39
+ }
40
+ };
41
+ }
42
+ /** One renderer for portable query graphs and the engine's compiled subsets. */
43
+ function subsetQuery(objectType, subset) {
44
+ return {
45
+ from: {
46
+ source: { objectType },
47
+ binding: "row"
48
+ },
49
+ where: subset?.where && predicate(subset.where),
50
+ orderBy: subset?.orderBy?.map((order) => ({
51
+ expression: operand(order.field),
52
+ direction: order.direction,
53
+ nulls: order.nulls
54
+ })),
55
+ page: subset && {
56
+ limit: subset.limit,
57
+ offset: subset.offset,
58
+ after: subset.after && {
59
+ key: subset.after.key,
60
+ values: [...subset.after.values]
61
+ }
62
+ },
63
+ select: []
64
+ };
65
+ }
66
+ //#endregion
67
+ export { subsetQuery };
68
+
69
+ //# sourceMappingURL=queryIR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryIR.js","names":[],"sources":["../src/queryIR.ts"],"sourcesContent":["import type { Demand } from \"./diagnostics.js\";\nimport type { QueryOperand } from \"./QueryTokens.js\";\nimport type { Expression, Query } from \"@party-stack/ontology\";\n\ntype Subset = NonNullable<Demand[\"query\"]>;\ntype Predicate = NonNullable<Subset[\"where\"]>;\nconst literal = (value: unknown): Expression => ({ kind: \"literal\", value: { value } });\n\nfunction operand(value: QueryOperand): Expression {\n return value !== null && typeof value === \"object\" && \"_tag\" in value && value._tag === \"Field\"\n ? {\n kind: \"getAt\",\n value: { source: { kind: \"localReference\", value: { name: \"row\" } }, path: [...value.path] },\n }\n : literal(value);\n}\n\nfunction predicate(value: Predicate): Expression {\n if (value.op === \"and\" || value.op === \"or\")\n return { kind: value.op, value: { expressions: value.predicates.map(predicate) } };\n if (value.op === \"not\") return { kind: \"not\", value: { expression: predicate(value.predicate) } };\n if (value.op === \"in\")\n return { kind: \"in\", value: { left: operand(value.left), right: literal(value.values) } };\n return { kind: value.op, value: { left: operand(value.left), right: operand(value.right) } };\n}\n\n/** One renderer for portable query graphs and the engine's compiled subsets. */\nexport function subsetQuery(objectType: string, subset?: Subset): Query {\n return {\n from: { source: { objectType }, binding: \"row\" },\n where: subset?.where && predicate(subset.where),\n orderBy: subset?.orderBy?.map((order) => ({\n expression: operand(order.field),\n direction: order.direction,\n nulls: order.nulls,\n })),\n page: subset && {\n limit: subset.limit,\n offset: subset.offset,\n after: subset.after && { key: subset.after.key, values: [...subset.after.values] },\n },\n select: [],\n };\n}\n"],"mappings":";AAMA,MAAM,WAAW,WAAgC;CAAE,MAAM;CAAW,OAAO,EAAE,MAAM;AAAE;AAErF,SAAS,QAAQ,OAAiC;CAC9C,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,UAAU,SAAS,MAAM,SAAS,UAClF;EACI,MAAM;EACN,OAAO;GAAE,QAAQ;IAAE,MAAM;IAAkB,OAAO,EAAE,MAAM,MAAM;GAAE;GAAG,MAAM,CAAC,GAAG,MAAM,IAAI;EAAE;CAC/F,IACA,QAAQ,KAAK;AACvB;AAEA,SAAS,UAAU,OAA8B;CAC7C,IAAI,MAAM,OAAO,SAAS,MAAM,OAAO,MACnC,OAAO;EAAE,MAAM,MAAM;EAAI,OAAO,EAAE,aAAa,MAAM,WAAW,IAAI,SAAS,EAAE;CAAE;CACrF,IAAI,MAAM,OAAO,OAAO,OAAO;EAAE,MAAM;EAAO,OAAO,EAAE,YAAY,UAAU,MAAM,SAAS,EAAE;CAAE;CAChG,IAAI,MAAM,OAAO,MACb,OAAO;EAAE,MAAM;EAAM,OAAO;GAAE,MAAM,QAAQ,MAAM,IAAI;GAAG,OAAO,QAAQ,MAAM,MAAM;EAAE;CAAE;CAC5F,OAAO;EAAE,MAAM,MAAM;EAAI,OAAO;GAAE,MAAM,QAAQ,MAAM,IAAI;GAAG,OAAO,QAAQ,MAAM,KAAK;EAAE;CAAE;AAC/F;;AAGA,SAAgB,YAAY,YAAoB,QAAwB;CACpE,OAAO;EACH,MAAM;GAAE,QAAQ,EAAE,WAAW;GAAG,SAAS;EAAM;EAC/C,OAAO,QAAQ,SAAS,UAAU,OAAO,KAAK;EAC9C,SAAS,QAAQ,SAAS,KAAK,WAAW;GACtC,YAAY,QAAQ,MAAM,KAAK;GAC/B,WAAW,MAAM;GACjB,OAAO,MAAM;EACjB,EAAE;EACF,MAAM,UAAU;GACZ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO,SAAS;IAAE,KAAK,OAAO,MAAM;IAAK,QAAQ,CAAC,GAAG,OAAO,MAAM,MAAM;GAAE;EACrF;EACA,QAAQ,CAAC;CACb;AACJ"}
@@ -0,0 +1,52 @@
1
+ import { PerformanceSpan } from "./traceWaterfall.js";
2
+ import { LiveOntology } from "@party-stack/ontology";
3
+ //#region src/replicationActivity.d.ts
4
+ type Diagnostics = NonNullable<LiveOntology["diagnostics"]>;
5
+ export type ReplicationStatus = NonNullable<ReturnType<Diagnostics["replica"]["getSnapshot"]>["status"]>;
6
+ export type ReplicationLoad = ReplicationStatus["loads"][number];
7
+ export type ReplicationDemand = ReplicationStatus["demands"][number];
8
+ /** Keep every span for the timeline, filling only requests whose span has left the trace buffer. */
9
+ export declare function diagnosticSpans(spans: readonly PerformanceSpan[], loads: readonly ReplicationLoad[]): readonly PerformanceSpan[];
10
+ export declare const queryText: (value: unknown) => string;
11
+ export declare const demandId: (demand: Pick<ReplicationDemand, "objectType" | "query">) => string;
12
+ export declare function replicationState(status: ReplicationStatus | undefined, error?: string): "Authenticating…" | "Authentication failed" | "Awaiting confirmation" | "Connecting…" | "Idle" | "Monitoring disconnected" | "Offline" | "Outbox paused" | "Sign-in required" | "Signed out" | "Sync failed" | "Syncing";
13
+ /** Exact recorded subset identity only; never attribute a broader/cache-covering load by type alone. */
14
+ export declare function queryLoads(demand: Pick<ReplicationDemand, "objectType" | "query">, loads: readonly ReplicationLoad[]): {
15
+ readonly id: number;
16
+ readonly spanId?: string | undefined;
17
+ readonly traceId?: string | undefined;
18
+ readonly operation: "loadSubset" | "pullChanges";
19
+ readonly reason: "demand" | "journal" | "receipt" | "refresh" | "repair";
20
+ readonly subset?: {
21
+ readonly objectType: string;
22
+ readonly query?: import("@party-stack/ontology-storage").Query | undefined;
23
+ } | undefined;
24
+ readonly startedAt: number;
25
+ readonly finishedAt?: number | undefined;
26
+ readonly outcome: "failure" | "interrupted" | "running" | "success";
27
+ readonly rows?: number | undefined;
28
+ readonly fetchedRows?: number | undefined;
29
+ readonly pushdown?: {
30
+ readonly source: string;
31
+ readonly predicates: readonly {
32
+ readonly path: readonly number[];
33
+ readonly execution: "adapter" | "candidate" | "engine" | "source";
34
+ }[];
35
+ readonly sorting: "adapter" | "engine" | "none" | "source";
36
+ readonly pagination: "adapter" | "engine" | "none" | "source";
37
+ readonly rechecksFilter: boolean;
38
+ readonly native?: {
39
+ readonly language: string;
40
+ readonly text: string;
41
+ } | undefined;
42
+ } | undefined;
43
+ readonly commits?: number | undefined;
44
+ readonly complete?: boolean | undefined;
45
+ readonly error?: {
46
+ readonly kind: string;
47
+ readonly message: string;
48
+ } | undefined;
49
+ }[];
50
+ //#endregion
51
+ export {};
52
+ //# sourceMappingURL=replicationActivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replicationActivity.d.ts","names":[],"sources":["../src/replicationActivity.ts"],"mappings":";;;KAGK,cAAc,YAAY;YACnB,oBAAoB,YAAY,WAAW;YAC3C,kBAAkB;YAClB,oBAAoB;;wBAEhB,gBACZ,gBAAgB,mBAChB,gBAAgB,6BACR;qBA2BC,YAAS;qBAET,WAAQ,QAAY,KAAK;wBAStB,iBAAiB,QAAQ,+BAA+B;;wBAexD,WACZ,QAAQ,KAAK,4CACb,gBAAgB"}
@@ -0,0 +1,54 @@
1
+ //#region src/replicationActivity.ts
2
+ /** Keep every span for the timeline, filling only requests whose span has left the trace buffer. */
3
+ function diagnosticSpans(spans, loads) {
4
+ const retained = new Set(spans.map((span) => `${span.traceId}:${span.id}`));
5
+ return [...spans, ...loads.flatMap((load) => {
6
+ const id = load.spanId ?? `load:${load.id}`;
7
+ const traceId = load.traceId ?? `request:${load.id}`;
8
+ if (retained.has(`${traceId}:${id}`)) return [];
9
+ const attributes = load.subset ? { objectType: load.subset.objectType } : {};
10
+ return [{
11
+ id,
12
+ traceId,
13
+ name: `Replica.upstream.${load.operation}`,
14
+ startedAt: load.startedAt,
15
+ durationMs: load.finishedAt === void 0 ? 0 : Math.max(0, load.finishedAt - load.startedAt),
16
+ outcome: load.outcome,
17
+ ...load.error ? { error: {
18
+ kind: "Error",
19
+ message: load.error.message
20
+ } } : {},
21
+ attributes
22
+ }];
23
+ })];
24
+ }
25
+ const queryText = (value) => JSON.stringify(value ?? {}, (_, item) => typeof item === "bigint" ? `${item}n` : item, 2);
26
+ const demandId = (demand) => JSON.stringify({
27
+ objectType: demand.objectType,
28
+ query: demand.query
29
+ }, (_, value) => {
30
+ if (typeof value === "bigint") return `${value}n`;
31
+ return value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b))) : value;
32
+ });
33
+ function replicationState(status, error) {
34
+ if (error) return "Monitoring disconnected";
35
+ if (!status) return "Connecting…";
36
+ if (status.networkOnline === false) return "Offline";
37
+ if (status.authentication?.status === "needs-auth") return "Sign-in required";
38
+ if (status.authentication?.status === "error") return "Authentication failed";
39
+ if (status.authentication?.status === "inactive") return "Signed out";
40
+ if (status.authentication?.status === "pending") return "Authenticating…";
41
+ if (status.syncing) return "Syncing";
42
+ if (status.lastSync?.outcome === "failure") return "Sync failed";
43
+ if ((status.outbox.blocked ?? 0) > 0) return "Outbox paused";
44
+ return (status.outbox.acknowledged ?? 0) > 0 ? "Awaiting confirmation" : "Idle";
45
+ }
46
+ /** Exact recorded subset identity only; never attribute a broader/cache-covering load by type alone. */
47
+ function queryLoads(demand, loads) {
48
+ const key = demandId(demand);
49
+ return loads.filter((load) => load.operation === "loadSubset" && load.subset && demandId(load.subset) === key);
50
+ }
51
+ //#endregion
52
+ export { demandId, diagnosticSpans, queryLoads, queryText, replicationState };
53
+
54
+ //# sourceMappingURL=replicationActivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replicationActivity.js","names":[],"sources":["../src/replicationActivity.ts"],"sourcesContent":["import type { PerformanceSpan } from \"./traceWaterfall.js\";\nimport type { LiveOntology } from \"@party-stack/ontology\";\n\ntype Diagnostics = NonNullable<LiveOntology[\"diagnostics\"]>;\nexport type ReplicationStatus = NonNullable<ReturnType<Diagnostics[\"replica\"][\"getSnapshot\"]>[\"status\"]>;\nexport type ReplicationLoad = ReplicationStatus[\"loads\"][number];\nexport type ReplicationDemand = ReplicationStatus[\"demands\"][number];\n/** Keep every span for the timeline, filling only requests whose span has left the trace buffer. */\nexport function diagnosticSpans(\n spans: readonly PerformanceSpan[],\n loads: readonly ReplicationLoad[]\n): readonly PerformanceSpan[] {\n const retained = new Set(spans.map((span) => `${span.traceId}:${span.id}`));\n return [\n ...spans,\n ...loads.flatMap((load) => {\n const id = load.spanId ?? `load:${load.id}`;\n const traceId = load.traceId ?? `request:${load.id}`;\n if (retained.has(`${traceId}:${id}`)) return [];\n const attributes: PerformanceSpan[\"attributes\"] = load.subset\n ? { objectType: load.subset.objectType }\n : {};\n return [\n {\n id,\n traceId,\n name: `Replica.upstream.${load.operation}`,\n startedAt: load.startedAt,\n durationMs:\n load.finishedAt === undefined ? 0 : Math.max(0, load.finishedAt - load.startedAt),\n outcome: load.outcome,\n ...(load.error ? { error: { kind: \"Error\" as const, message: load.error.message } } : {}),\n attributes,\n },\n ];\n }),\n ];\n}\nexport const queryText = (value: unknown) =>\n JSON.stringify(value ?? {}, (_, item: unknown) => (typeof item === \"bigint\" ? `${item}n` : item), 2);\nexport const demandId = (demand: Pick<ReplicationDemand, \"objectType\" | \"query\">) =>\n JSON.stringify({ objectType: demand.objectType, query: demand.query }, (_, value: unknown) => {\n if (typeof value === \"bigint\") return `${value}n`;\n // Storage copies and RPC can reorder object keys. Array order (including\n // predicate and ordering precedence) remains significant.\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)))\n : value;\n });\nexport function replicationState(status: ReplicationStatus | undefined, error?: string) {\n if (error) return \"Monitoring disconnected\";\n if (!status) return \"Connecting…\";\n if (status.networkOnline === false) return \"Offline\";\n if (status.authentication?.status === \"needs-auth\") return \"Sign-in required\";\n if (status.authentication?.status === \"error\") return \"Authentication failed\";\n if (status.authentication?.status === \"inactive\") return \"Signed out\";\n if (status.authentication?.status === \"pending\") return \"Authenticating…\";\n if (status.syncing) return \"Syncing\";\n if (status.lastSync?.outcome === \"failure\") return \"Sync failed\";\n if ((status.outbox.blocked ?? 0) > 0) return \"Outbox paused\";\n return (status.outbox.acknowledged ?? 0) > 0 ? \"Awaiting confirmation\" : \"Idle\";\n}\n\n/** Exact recorded subset identity only; never attribute a broader/cache-covering load by type alone. */\nexport function queryLoads(\n demand: Pick<ReplicationDemand, \"objectType\" | \"query\">,\n loads: readonly ReplicationLoad[]\n) {\n const key = demandId(demand);\n return loads.filter(\n (load) => load.operation === \"loadSubset\" && load.subset && demandId(load.subset) === key\n );\n}\n"],"mappings":";;AAQA,SAAgB,gBACZ,OACA,OAC0B;CAC1B,MAAM,WAAW,IAAI,IAAI,MAAM,KAAK,SAAS,GAAG,KAAK,QAAQ,GAAG,KAAK,IAAI,CAAC;CAC1E,OAAO,CACH,GAAG,OACH,GAAG,MAAM,SAAS,SAAS;EACvB,MAAM,KAAK,KAAK,UAAU,QAAQ,KAAK;EACvC,MAAM,UAAU,KAAK,WAAW,WAAW,KAAK;EAChD,IAAI,SAAS,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;EAC9C,MAAM,aAA4C,KAAK,SACjD,EAAE,YAAY,KAAK,OAAO,WAAW,IACrC,CAAC;EACP,OAAO,CACH;GACI;GACA;GACA,MAAM,oBAAoB,KAAK;GAC/B,WAAW,KAAK;GAChB,YACI,KAAK,eAAe,KAAA,IAAY,IAAI,KAAK,IAAI,GAAG,KAAK,aAAa,KAAK,SAAS;GACpF,SAAS,KAAK;GACd,GAAI,KAAK,QAAQ,EAAE,OAAO;IAAE,MAAM;IAAkB,SAAS,KAAK,MAAM;GAAQ,EAAE,IAAI,CAAC;GACvF;EACJ,CACJ;CACJ,CAAC,CACL;AACJ;AACA,MAAa,aAAa,UACtB,KAAK,UAAU,SAAS,CAAC,IAAI,GAAG,SAAmB,OAAO,SAAS,WAAW,GAAG,KAAK,KAAK,MAAO,CAAC;AACvG,MAAa,YAAY,WACrB,KAAK,UAAU;CAAE,YAAY,OAAO;CAAY,OAAO,OAAO;AAAM,IAAI,GAAG,UAAmB;CAC1F,IAAI,OAAO,UAAU,UAAU,OAAO,GAAG,MAAM;CAG/C,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAC3D,OAAO,YAAY,OAAO,QAAQ,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,IAC/E;AACV,CAAC;AACL,SAAgB,iBAAiB,QAAuC,OAAgB;CACpF,IAAI,OAAO,OAAO;CAClB,IAAI,CAAC,QAAQ,OAAO;CACpB,IAAI,OAAO,kBAAkB,OAAO,OAAO;CAC3C,IAAI,OAAO,gBAAgB,WAAW,cAAc,OAAO;CAC3D,IAAI,OAAO,gBAAgB,WAAW,SAAS,OAAO;CACtD,IAAI,OAAO,gBAAgB,WAAW,YAAY,OAAO;CACzD,IAAI,OAAO,gBAAgB,WAAW,WAAW,OAAO;CACxD,IAAI,OAAO,SAAS,OAAO;CAC3B,IAAI,OAAO,UAAU,YAAY,WAAW,OAAO;CACnD,KAAK,OAAO,OAAO,WAAW,KAAK,GAAG,OAAO;CAC7C,QAAQ,OAAO,OAAO,gBAAgB,KAAK,IAAI,0BAA0B;AAC7E;;AAGA,SAAgB,WACZ,QACA,OACF;CACE,MAAM,MAAM,SAAS,MAAM;CAC3B,OAAO,MAAM,QACR,SAAS,KAAK,cAAc,gBAAgB,KAAK,UAAU,SAAS,KAAK,MAAM,MAAM,GAC1F;AACJ"}
@@ -0,0 +1,35 @@
1
+ import { Point } from "@dagrejs/dagre";
2
+ import { ObjectTypeDef, OntologyIR } from "@party-stack/ontology";
3
+ //#region src/schemaLayout.d.ts
4
+ interface SchemaNode {
5
+ objectType: ObjectTypeDef;
6
+ x: number;
7
+ y: number;
8
+ }
9
+ interface SchemaEdge {
10
+ id: string;
11
+ label: string;
12
+ labelWidth: number;
13
+ labelX: number;
14
+ labelY: number;
15
+ points: Point[];
16
+ }
17
+ export declare function schemaLinkLabel(ir: OntologyIR, side: OntologyIR["linkTypes"][number]["source"], cardinality: "one" | "many"): string;
18
+ /** Diagram arrows run from the referenced object to dependents, so many means one-to-many. */
19
+ export declare function schemaRelationship(link: OntologyIR["linkTypes"][number]): {
20
+ id: string;
21
+ source: string;
22
+ target: string;
23
+ cardinality: "many" | "one";
24
+ label: string;
25
+ width: number;
26
+ };
27
+ export declare function layoutSchema(ir: OntologyIR): {
28
+ nodes: SchemaNode[];
29
+ edges: SchemaEdge[];
30
+ width: number;
31
+ height: number;
32
+ };
33
+ //#endregion
34
+ export {};
35
+ //# sourceMappingURL=schemaLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaLayout.d.ts","names":[],"sources":["../src/schemaLayout.ts"],"mappings":";;;UAUU;EACN,YAAY;EACZ;EACA;;UAGM;EACN;EACA;EACA;EACA;EACA;EACA,QAAQ;;wBAUI,gBACZ,IAAI,YACJ,MAAM,2CACN;;wBAYY,mBAAmB,MAAM;;;;;;;;wBAYzB,aAAa,IAAI;EAC7B,OAAO;EACP,OAAO;EACP;EACA"}