@myko/core 4.3.0 → 4.4.0-canary.2

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/index.ts ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @myko/core - Myko client and generated types
3
+ *
4
+ * Browser-compatible WebSocket client with RxJS Observables,
5
+ * plus Rust-generated type bindings.
6
+ */
7
+
8
+ import type { ID, MEvent, WrappedItem, ItemStub, LogLevel } from './generated'
9
+
10
+ // Re-export all Rust-generated types from ./generated
11
+ // This includes the ID type alias (ID = string)
12
+ export * from './generated'
13
+
14
+ // Explicitly re-export type-only exports that don't come through `export *`
15
+ export type { LogLevel }
16
+
17
+ /**
18
+ * Get the item type name from an entity type or query class.
19
+ *
20
+ * For query/report/command classes: Returns the static queryItemType, reportId, or commandId
21
+ * For entity types in the new Rust system: Use the literal type name string instead
22
+ *
23
+ * @example
24
+ * // Old style (decorator-based):
25
+ * getItemName(Scene) // This won't work with Rust-generated types
26
+ *
27
+ * // New style - use literal strings:
28
+ * 'Scene'
29
+ *
30
+ * // Or use query's static property:
31
+ * GetScenesByIds.queryItemType // 'Scene'
32
+ */
33
+ export function getItemName(
34
+ item: { queryItemType?: string; name?: string } | string,
35
+ ): string {
36
+ if (typeof item === 'string') return item
37
+ if ('queryItemType' in item && item.queryItemType) return item.queryItemType
38
+ if ('name' in item && item.name) return item.name
39
+ throw new Error(
40
+ `Cannot get item name from ${item}. Use literal string like 'Scene' instead.`,
41
+ )
42
+ }
43
+
44
+ /**
45
+ * Compatibility alias for MWrappedItem.
46
+ * In the new system, use WrappedItem from ./generated.
47
+ */
48
+ export type MWrappedItem<T = unknown> = WrappedItem
49
+
50
+ /**
51
+ * Compatibility alias for MItemStub.
52
+ * In the new system, use ItemStub from ./generated.
53
+ */
54
+ export type MItemStub = ItemStub
55
+
56
+ /**
57
+ * Log levels ordered by severity (most severe first).
58
+ * Used for filtering and comparing log levels.
59
+ */
60
+ export const LOG_RANK = [
61
+ 'ERROR',
62
+ 'WARN',
63
+ 'INFO',
64
+ 'DEBUG',
65
+ 'VERBOSE',
66
+ ] as const
67
+
68
+ /**
69
+ * GetEventLog is now ServerEventLog in the Rust system.
70
+ * @deprecated Use ServerEventLog from ./generated instead
71
+ */
72
+ // Note: ServerEventLog is re-exported from ./generated via export * above
73
+
74
+ // Export the client
75
+ export {
76
+ ConnectionStatus,
77
+ MykoClient,
78
+ MykoProtocol,
79
+ type ClientStats,
80
+ type Command,
81
+ type CommandResult,
82
+ type MykoError,
83
+ type MykoErrorEvent,
84
+ type Query,
85
+ type QueryDiff,
86
+ type QueryItem,
87
+ type QueryWatchOptions,
88
+ type QueryWindow,
89
+ type QueryWindowInfo,
90
+ type QueryResult,
91
+ type View,
92
+ type ViewItem,
93
+ type ViewResult,
94
+ type Report,
95
+ type ReportResult,
96
+ } from './client.js'
97
+
98
+ // ─────────────────────────────────────────────────────────────────────────────
99
+ // Legacy stubs (not yet in Rust)
100
+ // ─────────────────────────────────────────────────────────────────────────────
101
+
102
+ /**
103
+ * Container for an event with associated metadata.
104
+ * @deprecated Will be generated from Rust
105
+ */
106
+ export type EventContainer = {
107
+ id: ID
108
+ event: MEvent
109
+ }
110
+
111
+ /**
112
+ * Query that returns events for a specific entity.
113
+ * @deprecated TODO: Implement in Rust server
114
+ */
115
+ export class EventsForEntity {
116
+ static readonly queryId = 'EventsForEntity'
117
+ readonly queryId = 'EventsForEntity'
118
+ static readonly queryItemType = 'EventContainer'
119
+ readonly queryItemType = 'EventContainer'
120
+ readonly query: { entityId: string; start?: string; end?: string }
121
+
122
+ /** Phantom type marker for result inference */
123
+ readonly $res!: () => EventContainer[]
124
+
125
+ constructor(entityId: string, start?: string, end?: string) {
126
+ this.query = { entityId, start, end }
127
+ }
128
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "outDir": "./dist",
9
+ "rootDir": "./src",
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }