@myko/ui-svelte 4.4.0 → 4.4.3
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/{src/lib → dist}/components/ConnectionStats.svelte +8 -22
- package/dist/components/ConnectionStats.svelte.d.ts +10 -0
- package/dist/components/EntityDiffBadge.svelte +10 -0
- package/dist/components/EntityDiffBadge.svelte.d.ts +7 -0
- package/{src/lib → dist}/components/EntityDiffFields.svelte +27 -49
- package/dist/components/EntityDiffFields.svelte.d.ts +11 -0
- package/{src/lib → dist}/components/EntityDiffNode.svelte +25 -43
- package/dist/components/EntityDiffNode.svelte.d.ts +14 -0
- package/{src/lib → dist}/components/EntityDiffTree.svelte +150 -200
- package/dist/components/EntityDiffTree.svelte.d.ts +21 -0
- package/dist/components/Logs.svelte +30 -0
- package/dist/components/Logs.svelte.d.ts +7 -0
- package/dist/components/Query.svelte +21 -0
- package/dist/components/Query.svelte.d.ts +35 -0
- package/dist/components/Report.svelte +13 -0
- package/dist/components/Report.svelte.d.ts +32 -0
- package/dist/components/Search.svelte +46 -0
- package/dist/components/Search.svelte.d.ts +56 -0
- package/dist/components/ServerView.svelte +76 -0
- package/dist/components/ServerView.svelte.d.ts +8 -0
- package/dist/components/state/resolutions.d.ts +11 -0
- package/dist/components/state/resolutions.js +129 -0
- package/dist/components/state/viewstate.svelte.d.ts +60 -0
- package/dist/components/state/viewstate.svelte.js +259 -0
- package/dist/components/state/windback.svelte.d.ts +16 -0
- package/dist/components/state/windback.svelte.js +65 -0
- package/dist/components/transactions/EntityHistory.svelte +135 -0
- package/dist/components/transactions/EntityHistory.svelte.d.ts +10 -0
- package/{src/lib → dist}/components/transactions/TimeStrip.svelte +18 -25
- package/dist/components/transactions/TimeStrip.svelte.d.ts +3 -0
- package/dist/components/transactions/TransactionDetails.svelte +24 -0
- package/dist/components/transactions/TransactionDetails.svelte.d.ts +7 -0
- package/{src/lib → dist}/components/transactions/TransactionEvent.svelte +20 -32
- package/dist/components/transactions/TransactionEvent.svelte.d.ts +7 -0
- package/{src/lib → dist}/components/transactions/TransactionEventGroup.svelte +8 -13
- package/dist/components/transactions/TransactionEventGroup.svelte.d.ts +8 -0
- package/dist/components/transactions/Transactions.svelte +94 -0
- package/dist/components/transactions/Transactions.svelte.d.ts +8 -0
- package/{src/lib → dist}/components/transactions/TransactonView.svelte +3 -7
- package/dist/components/transactions/TransactonView.svelte.d.ts +7 -0
- package/{src/lib → dist}/components/windback/WindbackFrame.svelte +3 -6
- package/dist/components/windback/WindbackFrame.svelte.d.ts +7 -0
- package/dist/components/windback/index.js +1 -0
- package/dist/index.d.ts +18 -0
- package/{src/lib/index.ts → dist/index.js} +2 -15
- package/dist/services/svelte-client.svelte.d.ts +278 -0
- package/dist/services/svelte-client.svelte.js +678 -0
- package/dist/utils/entity-apply.d.ts +17 -0
- package/dist/utils/entity-apply.js +35 -0
- package/dist/utils/entity-diff.d.ts +40 -0
- package/dist/utils/entity-diff.js +57 -0
- package/dist/utils/entity-tree.d.ts +24 -0
- package/dist/utils/entity-tree.js +111 -0
- package/package.json +13 -9
- package/.prettierignore +0 -4
- package/.prettierrc +0 -15
- package/src/app.d.ts +0 -13
- package/src/app.html +0 -12
- package/src/lib/components/EntityDiffBadge.svelte +0 -18
- package/src/lib/components/Logs.svelte +0 -37
- package/src/lib/components/Query.svelte +0 -34
- package/src/lib/components/Report.svelte +0 -25
- package/src/lib/components/Search.svelte +0 -85
- package/src/lib/components/ServerView.svelte +0 -95
- package/src/lib/components/state/resolutions.ts +0 -137
- package/src/lib/components/state/viewstate.svelte.ts +0 -375
- package/src/lib/components/state/windback.svelte.ts +0 -88
- package/src/lib/components/transactions/EntityHistory.svelte +0 -173
- package/src/lib/components/transactions/TransactionDetails.svelte +0 -26
- package/src/lib/components/transactions/Transactions.svelte +0 -111
- package/src/lib/services/svelte-client.svelte.ts +0 -863
- package/src/lib/utils/entity-apply.ts +0 -47
- package/src/lib/utils/entity-diff.ts +0 -105
- package/src/lib/utils/entity-tree.ts +0 -130
- package/src/routes/+page.svelte +0 -3
- package/static/favicon.png +0 -0
- package/svelte.config.js +0 -18
- package/tsconfig.json +0 -13
- package/vite.config.ts +0 -6
- /package/{src/lib/components/windback/index.ts → dist/components/windback/index.d.ts} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ExportedEntity, DiffStatus, FieldDiff } from './entity-diff.js';
|
|
2
|
-
|
|
3
|
-
export interface ApplyPlan {
|
|
4
|
-
toSet: ExportedEntity[]; // Added + modified, parents first
|
|
5
|
-
toDel: ExportedEntity[]; // Shallowest removed entities only
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Compute the minimal SET/DEL operations to apply an import.
|
|
10
|
-
*
|
|
11
|
-
* @param diffs - Flat diff map from diffEntityLists()
|
|
12
|
-
* @param allFkFields - All FK field names used in BelongsTo relationships (for cascade detection)
|
|
13
|
-
* @param excluded - Optional set of "Type:id" keys to skip (user chose to keep current version)
|
|
14
|
-
*/
|
|
15
|
-
export function computeApplyPlan(
|
|
16
|
-
diffs: Map<string, { status: DiffStatus; fields?: FieldDiff[]; entity: ExportedEntity }>,
|
|
17
|
-
allFkFields: string[],
|
|
18
|
-
excluded?: Set<string>,
|
|
19
|
-
): ApplyPlan {
|
|
20
|
-
const toSet: ExportedEntity[] = [];
|
|
21
|
-
const allRemoved = new Map<string, ExportedEntity>();
|
|
22
|
-
|
|
23
|
-
for (const [key, diff] of diffs) {
|
|
24
|
-
if (excluded?.has(key)) continue;
|
|
25
|
-
if (diff.status === 'added' || diff.status === 'modified') {
|
|
26
|
-
toSet.push(diff.entity);
|
|
27
|
-
} else if (diff.status === 'removed') {
|
|
28
|
-
allRemoved.set(diff.entity.data.id as string, diff.entity);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Filter removed to shallowest only — if a removed entity's parent is also
|
|
33
|
-
// removed, skip it (the cascade will handle it)
|
|
34
|
-
const removedIds = new Set(allRemoved.keys());
|
|
35
|
-
const toDel: ExportedEntity[] = [];
|
|
36
|
-
for (const [_id, entity] of allRemoved) {
|
|
37
|
-
const hasRemovedParent = allFkFields.some((fk) => {
|
|
38
|
-
const parentId = entity.data[fk] as string | undefined;
|
|
39
|
-
return parentId && removedIds.has(parentId);
|
|
40
|
-
});
|
|
41
|
-
if (!hasRemovedParent) {
|
|
42
|
-
toDel.push(entity);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return { toSet, toDel };
|
|
47
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/** Diff status for an entity or field. */
|
|
2
|
-
export type DiffStatus = 'added' | 'removed' | 'modified' | 'unchanged';
|
|
3
|
-
|
|
4
|
-
/** Field-level diff for a modified entity. */
|
|
5
|
-
export interface FieldDiff {
|
|
6
|
-
field: string;
|
|
7
|
-
oldValue?: unknown;
|
|
8
|
-
newValue?: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** Entity-level diff node with children for tree display. */
|
|
12
|
-
export interface EntityDiff {
|
|
13
|
-
type: string;
|
|
14
|
-
id: string;
|
|
15
|
-
status: DiffStatus;
|
|
16
|
-
/** Display label (entity name or id). */
|
|
17
|
-
name?: string;
|
|
18
|
-
/** Field-level changes — only populated for 'modified' status. */
|
|
19
|
-
fields?: FieldDiff[];
|
|
20
|
-
/** The current (server) entity data — only populated for 'modified' status. */
|
|
21
|
-
currentData?: Record<string, unknown>;
|
|
22
|
-
/** The incoming entity data — only populated for 'modified' status. */
|
|
23
|
-
incomingData?: Record<string, unknown>;
|
|
24
|
-
children: EntityDiff[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** A single exported entity from an EntityTreeExport. */
|
|
28
|
-
export interface ExportedEntity {
|
|
29
|
-
entityType: string;
|
|
30
|
-
data: Record<string, unknown>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Compare two flat entity lists and produce field-level diffs.
|
|
35
|
-
*
|
|
36
|
-
* @param current - Entities currently on the server
|
|
37
|
-
* @param incoming - Entities from the import source (file or snapshot)
|
|
38
|
-
* @returns Map of "type:id" -> { status, fields }
|
|
39
|
-
*/
|
|
40
|
-
export function diffEntityLists(
|
|
41
|
-
current: ExportedEntity[],
|
|
42
|
-
incoming: ExportedEntity[],
|
|
43
|
-
): Map<string, { status: DiffStatus; fields?: FieldDiff[]; entity: ExportedEntity }> {
|
|
44
|
-
const currentMap = new Map<string, ExportedEntity>();
|
|
45
|
-
for (const e of current) {
|
|
46
|
-
currentMap.set(`${e.entityType}:${e.data.id}`, e);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const incomingMap = new Map<string, ExportedEntity>();
|
|
50
|
-
for (const e of incoming) {
|
|
51
|
-
incomingMap.set(`${e.entityType}:${e.data.id}`, e);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const result = new Map<
|
|
55
|
-
string,
|
|
56
|
-
{ status: DiffStatus; fields?: FieldDiff[]; entity: ExportedEntity; currentEntity?: ExportedEntity }
|
|
57
|
-
>();
|
|
58
|
-
|
|
59
|
-
// Check incoming entities against current
|
|
60
|
-
for (const [key, inc] of incomingMap) {
|
|
61
|
-
const cur = currentMap.get(key);
|
|
62
|
-
if (!cur) {
|
|
63
|
-
result.set(key, { status: 'added', entity: inc });
|
|
64
|
-
} else {
|
|
65
|
-
const fields = diffFields(cur.data, inc.data);
|
|
66
|
-
if (fields.length > 0) {
|
|
67
|
-
result.set(key, { status: 'modified', fields, entity: inc, currentEntity: cur });
|
|
68
|
-
} else {
|
|
69
|
-
result.set(key, { status: 'unchanged', entity: inc });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Check for removed entities (in current but not in incoming)
|
|
75
|
-
for (const [key, cur] of currentMap) {
|
|
76
|
-
if (!incomingMap.has(key)) {
|
|
77
|
-
result.set(key, { status: 'removed', entity: cur });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Compare two entity data objects field-by-field. */
|
|
85
|
-
function diffFields(
|
|
86
|
-
oldData: Record<string, unknown>,
|
|
87
|
-
newData: Record<string, unknown>,
|
|
88
|
-
): FieldDiff[] {
|
|
89
|
-
const diffs: FieldDiff[] = [];
|
|
90
|
-
const allKeys = new Set([...Object.keys(oldData), ...Object.keys(newData)]);
|
|
91
|
-
|
|
92
|
-
for (const key of allKeys) {
|
|
93
|
-
// Skip hash — it's derived and always changes when fields change
|
|
94
|
-
if (key === 'hash') continue;
|
|
95
|
-
|
|
96
|
-
const oldVal = oldData[key];
|
|
97
|
-
const newVal = newData[key];
|
|
98
|
-
|
|
99
|
-
if (JSON.stringify(oldVal) !== JSON.stringify(newVal)) {
|
|
100
|
-
diffs.push({ field: key, oldValue: oldVal, newValue: newVal });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return diffs;
|
|
105
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { EntityDiff, ExportedEntity, DiffStatus, FieldDiff } from './entity-diff.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Maps child entity type to its parent FK field names (camelCase).
|
|
5
|
-
* Provided by the consuming application — generated from Rust relationship registrations.
|
|
6
|
-
*/
|
|
7
|
-
export type ParentFkFields = Record<string, string[]>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Extract a display name from entity data.
|
|
11
|
-
* Tries 'name' field first, falls back to 'id'.
|
|
12
|
-
*/
|
|
13
|
-
function entityName(data: Record<string, unknown>): string {
|
|
14
|
-
return (data.name as string) ?? (data.id as string) ?? 'unknown';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Build an EntityDiff tree from a flat diff map.
|
|
19
|
-
*
|
|
20
|
-
* Entities with known parent FK fields are placed under their parent.
|
|
21
|
-
* Entities without a parent mapping (or whose parent isn't in the diff)
|
|
22
|
-
* are placed as direct children of the root so they remain visible.
|
|
23
|
-
*
|
|
24
|
-
* @param rootType - The root entity type
|
|
25
|
-
* @param rootId - The root entity ID
|
|
26
|
-
* @param diffs - Flat diff map from diffEntityLists()
|
|
27
|
-
* @returns Root EntityDiff node with nested children
|
|
28
|
-
*/
|
|
29
|
-
export function buildDiffTree(
|
|
30
|
-
rootType: string,
|
|
31
|
-
rootId: string,
|
|
32
|
-
diffs: Map<string, { status: DiffStatus; fields?: FieldDiff[]; entity: ExportedEntity; currentEntity?: ExportedEntity }>,
|
|
33
|
-
parentFkFields: ParentFkFields,
|
|
34
|
-
): EntityDiff {
|
|
35
|
-
// Build flat EntityDiff nodes and index by ID for parent lookup
|
|
36
|
-
const allNodes = new Map<string, EntityDiff>();
|
|
37
|
-
const idToKey = new Map<string, string>();
|
|
38
|
-
const childrenByParent = new Map<string, EntityDiff[]>();
|
|
39
|
-
const placed = new Set<string>();
|
|
40
|
-
|
|
41
|
-
for (const [key, diff] of diffs) {
|
|
42
|
-
const [type, id] = key.split(':');
|
|
43
|
-
const node: EntityDiff = {
|
|
44
|
-
type,
|
|
45
|
-
id,
|
|
46
|
-
status: diff.status,
|
|
47
|
-
name: entityName(diff.entity.data),
|
|
48
|
-
fields: diff.fields,
|
|
49
|
-
currentData: diff.currentEntity?.data ?? (diff.status === 'removed' ? diff.entity.data : undefined),
|
|
50
|
-
incomingData: diff.status === 'added' || diff.status === 'modified' ? diff.entity.data : undefined,
|
|
51
|
-
children: [],
|
|
52
|
-
};
|
|
53
|
-
allNodes.set(key, node);
|
|
54
|
-
idToKey.set(id, key);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Build parent-child relationships
|
|
58
|
-
for (const [key, diff] of diffs) {
|
|
59
|
-
const [type] = key.split(':');
|
|
60
|
-
const fkFields = parentFkFields[type];
|
|
61
|
-
if (fkFields) {
|
|
62
|
-
let foundParent = false;
|
|
63
|
-
for (const fkField of fkFields) {
|
|
64
|
-
const parentId = diff.entity.data[fkField] as string | undefined;
|
|
65
|
-
if (parentId) {
|
|
66
|
-
const parentKey = idToKey.get(parentId);
|
|
67
|
-
if (parentKey) {
|
|
68
|
-
if (!childrenByParent.has(parentKey)) {
|
|
69
|
-
childrenByParent.set(parentKey, []);
|
|
70
|
-
}
|
|
71
|
-
childrenByParent.get(parentKey)!.push(allNodes.get(key)!);
|
|
72
|
-
placed.add(key);
|
|
73
|
-
foundParent = true;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Get or create root node
|
|
82
|
-
const rootKey = `${rootType}:${rootId}`;
|
|
83
|
-
const rootNode = allNodes.get(rootKey) ?? {
|
|
84
|
-
type: rootType,
|
|
85
|
-
id: rootId,
|
|
86
|
-
status: 'unchanged' as DiffStatus,
|
|
87
|
-
name: rootId,
|
|
88
|
-
children: [],
|
|
89
|
-
};
|
|
90
|
-
placed.add(rootKey);
|
|
91
|
-
|
|
92
|
-
// Attach children from FK relationships
|
|
93
|
-
for (const [key, node] of allNodes) {
|
|
94
|
-
node.children = childrenByParent.get(key) ?? [];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Orphaned entities (not the root, not placed under any parent) become root children
|
|
98
|
-
for (const [key, node] of allNodes) {
|
|
99
|
-
if (!placed.has(key)) {
|
|
100
|
-
rootNode.children.push(node);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Deduplicate all children arrays — entities reachable via multiple FK paths
|
|
105
|
-
// (e.g., BindingNodeConnection with both start_node_id and end_node_id) could
|
|
106
|
-
// appear more than once
|
|
107
|
-
for (const node of allNodes.values()) {
|
|
108
|
-
if (node.children.length > 0) {
|
|
109
|
-
const seen = new Set<string>();
|
|
110
|
-
node.children = node.children.filter((c) => {
|
|
111
|
-
const k = `${c.type}:${c.id}`;
|
|
112
|
-
if (seen.has(k)) return false;
|
|
113
|
-
seen.add(k);
|
|
114
|
-
return true;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Also dedup root if it was created fresh (not from allNodes)
|
|
119
|
-
if (rootNode.children.length > 0) {
|
|
120
|
-
const seen = new Set<string>();
|
|
121
|
-
rootNode.children = rootNode.children.filter((c) => {
|
|
122
|
-
const k = `${c.type}:${c.id}`;
|
|
123
|
-
if (seen.has(k)) return false;
|
|
124
|
-
seen.add(k);
|
|
125
|
-
return true;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return rootNode;
|
|
130
|
-
}
|
package/src/routes/+page.svelte
DELETED
package/static/favicon.png
DELETED
|
Binary file
|
package/svelte.config.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import adapter from '@sveltejs/adapter-auto';
|
|
2
|
-
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
3
|
-
|
|
4
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
5
|
-
const config = {
|
|
6
|
-
// Consult https://svelte.dev/docs/kit/integrations
|
|
7
|
-
// for more information about preprocessors
|
|
8
|
-
preprocess: vitePreprocess({script: true}),
|
|
9
|
-
|
|
10
|
-
kit: {
|
|
11
|
-
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
12
|
-
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
13
|
-
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
14
|
-
adapter: adapter()
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default config;
|
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./.svelte-kit/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"checkJs": true,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"resolveJsonModule": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"strict": true
|
|
12
|
-
}
|
|
13
|
-
}
|
package/vite.config.ts
DELETED
|
File without changes
|