@mmapp/react 0.1.0-alpha.1 → 0.1.0-alpha.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/README.md +112 -0
- package/dist/index.d.mts +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.js +70 -3
- package/dist/index.mjs +74 -12
- package/package.json +4 -3
- package/package.json.backup +0 -41
- package/src/Blueprint.ts +0 -216
- package/src/__tests__/Blueprint.test.ts +0 -106
- package/src/__tests__/action-context.test.ts +0 -166
- package/src/__tests__/actionCreators.test.ts +0 -179
- package/src/__tests__/builders.test.ts +0 -336
- package/src/__tests__/defineBlueprint-composition.test.ts +0 -106
- package/src/__tests__/factories.test.ts +0 -229
- package/src/__tests__/loader.test.ts +0 -159
- package/src/__tests__/logger.test.ts +0 -70
- package/src/__tests__/type-inference.test.ts +0 -160
- package/src/__tests__/typed-transitions.test.ts +0 -126
- package/src/__tests__/useModuleConfig.test.ts +0 -61
- package/src/actionCreators.ts +0 -132
- package/src/actions.ts +0 -547
- package/src/atoms/index.ts +0 -600
- package/src/authoring.ts +0 -92
- package/src/browser-player.ts +0 -783
- package/src/builders.ts +0 -1342
- package/src/components/ExperienceWorkflowBridge.tsx +0 -123
- package/src/components/PlayerProvider.tsx +0 -43
- package/src/components/atoms/index.tsx +0 -269
- package/src/components/index.ts +0 -36
- package/src/conditions.ts +0 -692
- package/src/config/defineBlueprint.ts +0 -329
- package/src/config/defineModel.ts +0 -753
- package/src/config/defineWorkspace.ts +0 -24
- package/src/core/WorkflowRuntime.ts +0 -153
- package/src/factories.ts +0 -425
- package/src/grammar/index.ts +0 -173
- package/src/hooks/index.ts +0 -106
- package/src/hooks/useAuth.ts +0 -288
- package/src/hooks/useChannel.ts +0 -304
- package/src/hooks/useComputed.ts +0 -154
- package/src/hooks/useDomainSubscription.ts +0 -110
- package/src/hooks/useDuringAction.ts +0 -99
- package/src/hooks/useExperienceState.ts +0 -59
- package/src/hooks/useExpressionLibrary.ts +0 -129
- package/src/hooks/useForm.ts +0 -352
- package/src/hooks/useGeolocation.ts +0 -207
- package/src/hooks/useMapView.ts +0 -259
- package/src/hooks/useMiddleware.ts +0 -291
- package/src/hooks/useModel.ts +0 -363
- package/src/hooks/useModule.ts +0 -59
- package/src/hooks/useModuleConfig.ts +0 -61
- package/src/hooks/useMutation.ts +0 -237
- package/src/hooks/useNotification.ts +0 -151
- package/src/hooks/useOnChange.ts +0 -30
- package/src/hooks/useOnEnter.ts +0 -59
- package/src/hooks/useOnEvent.ts +0 -37
- package/src/hooks/useOnExit.ts +0 -27
- package/src/hooks/useOnTransition.ts +0 -30
- package/src/hooks/usePackage.ts +0 -128
- package/src/hooks/useParams.ts +0 -33
- package/src/hooks/usePlayer.ts +0 -308
- package/src/hooks/useQuery.ts +0 -184
- package/src/hooks/useRealtimeQuery.ts +0 -222
- package/src/hooks/useRole.ts +0 -191
- package/src/hooks/useRouteParams.ts +0 -100
- package/src/hooks/useRouter.ts +0 -347
- package/src/hooks/useServerAction.ts +0 -178
- package/src/hooks/useServerState.ts +0 -284
- package/src/hooks/useToast.ts +0 -164
- package/src/hooks/useTransition.ts +0 -39
- package/src/hooks/useView.ts +0 -102
- package/src/hooks/useWhileIn.ts +0 -48
- package/src/hooks/useWorkflow.ts +0 -63
- package/src/index.ts +0 -465
- package/src/loader/experience-workflow-loader.ts +0 -192
- package/src/loader/index.ts +0 -6
- package/src/local/LocalEngine.ts +0 -388
- package/src/local/LocalEngineAdapter.ts +0 -175
- package/src/local/LocalEngineContext.ts +0 -30
- package/src/logger.ts +0 -37
- package/src/mixins.ts +0 -1160
- package/src/providers/RuntimeContext.ts +0 -20
- package/src/providers/WorkflowProvider.tsx +0 -28
- package/src/routing/instance-key.ts +0 -107
- package/src/server/transition-context.ts +0 -172
- package/src/testing/index.ts +0 -9
- package/src/testing/useBlueprintTestRunner.ts +0 -91
- package/src/testing/useGraphAnalysis.ts +0 -18
- package/src/testing/useTestRunner.ts +0 -77
- package/src/testing.ts +0 -995
- package/src/types/workflow-inference.ts +0 -158
- package/src/types.ts +0 -114
- package/tsconfig.json +0 -27
- package/vitest.config.ts +0 -8
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type inference utilities for workflow model definitions.
|
|
3
|
-
*
|
|
4
|
-
* These mapped types extract TypeScript types from defineModel() results,
|
|
5
|
-
* enabling typed hooks (useModel, useQuery, useMutation) to provide
|
|
6
|
-
* IntelliSense on field names, state names, and transition names.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import auth from '../models/authentication';
|
|
11
|
-
* type Fields = InferFields<typeof auth>;
|
|
12
|
-
* // { appName: string; layout: string; showSignup: boolean; ... }
|
|
13
|
-
*
|
|
14
|
-
* type Trans = InferTransitions<typeof auth>;
|
|
15
|
-
* // 'login' | 'signup' | 'logout' | 'retry' | ...
|
|
16
|
-
*
|
|
17
|
-
* type States = InferStates<typeof auth>;
|
|
18
|
-
* // 'unauthenticated' | 'authenticating' | 'authenticated' | 'error'
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// =============================================================================
|
|
23
|
-
// Field Type Mapping
|
|
24
|
-
// =============================================================================
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Maps WorkflowFieldDescriptor.type strings to TypeScript types.
|
|
28
|
-
* Covers all built-in field types in the MindMatrix type system.
|
|
29
|
-
*/
|
|
30
|
-
export type FieldTypeMap = {
|
|
31
|
-
// Text types
|
|
32
|
-
string: string;
|
|
33
|
-
text: string;
|
|
34
|
-
rich_text: string;
|
|
35
|
-
email: string;
|
|
36
|
-
url: string;
|
|
37
|
-
phone: string;
|
|
38
|
-
color: string;
|
|
39
|
-
select: string;
|
|
40
|
-
|
|
41
|
-
// Numeric types
|
|
42
|
-
number: number;
|
|
43
|
-
integer: number;
|
|
44
|
-
float: number;
|
|
45
|
-
currency: number;
|
|
46
|
-
percentage: number;
|
|
47
|
-
rating: number;
|
|
48
|
-
duration: number;
|
|
49
|
-
auto_number: number;
|
|
50
|
-
|
|
51
|
-
// Boolean
|
|
52
|
-
boolean: boolean;
|
|
53
|
-
|
|
54
|
-
// Date/Time
|
|
55
|
-
date: string;
|
|
56
|
-
datetime: string;
|
|
57
|
-
time: string;
|
|
58
|
-
created_at: string;
|
|
59
|
-
updated_at: string;
|
|
60
|
-
|
|
61
|
-
// Complex types
|
|
62
|
-
array: unknown[];
|
|
63
|
-
object: Record<string, unknown>;
|
|
64
|
-
json: unknown;
|
|
65
|
-
file: string;
|
|
66
|
-
image: string;
|
|
67
|
-
|
|
68
|
-
// Relation types
|
|
69
|
-
relation: string;
|
|
70
|
-
multi_relation: string[];
|
|
71
|
-
lookup: unknown;
|
|
72
|
-
rollup: unknown;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// =============================================================================
|
|
76
|
-
// Inference Types
|
|
77
|
-
// =============================================================================
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Infer the TypeScript shape of a model's fields.
|
|
81
|
-
*
|
|
82
|
-
* Given a model definition D (from defineModel()), produces an object type
|
|
83
|
-
* where each key is a field name and each value is the corresponding TS type.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const model = defineModel({
|
|
88
|
-
* slug: 'test',
|
|
89
|
-
* fields: {
|
|
90
|
-
* name: { type: 'string', required: true },
|
|
91
|
-
* count: { type: 'number', default: 0 },
|
|
92
|
-
* active: { type: 'boolean', default: true },
|
|
93
|
-
* },
|
|
94
|
-
* states: {}, transitions: {},
|
|
95
|
-
* });
|
|
96
|
-
* type F = InferFields<typeof model>;
|
|
97
|
-
* // { name: string; count: number; active: boolean }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
export type InferFields<D> = D extends { fields: infer F extends Record<string, { type: string }> }
|
|
101
|
-
? {
|
|
102
|
-
[K in keyof F]: F[K] extends { type: infer T extends string }
|
|
103
|
-
? T extends keyof FieldTypeMap
|
|
104
|
-
? FieldTypeMap[T]
|
|
105
|
-
: unknown
|
|
106
|
-
: unknown;
|
|
107
|
-
}
|
|
108
|
-
: Record<string, unknown>;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Infer a union of transition names from a model definition.
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```typescript
|
|
115
|
-
* type T = InferTransitions<typeof authModel>;
|
|
116
|
-
* // 'login' | 'signup' | 'logout' | 'retry'
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export type InferTransitions<D> = D extends { transitions: infer T }
|
|
120
|
-
? Extract<keyof T, string>
|
|
121
|
-
: string;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Infer a union of state names from a model definition.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```typescript
|
|
128
|
-
* type S = InferStates<typeof authModel>;
|
|
129
|
-
* // 'unauthenticated' | 'authenticating' | 'authenticated' | 'error'
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
export type InferStates<D> = D extends { states: infer S }
|
|
133
|
-
? Extract<keyof S, string>
|
|
134
|
-
: string;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Extract the slug literal type from a model definition.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* type Slug = InferSlug<typeof authModel>;
|
|
142
|
-
* // 'mod-authentication'
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export type InferSlug<D> = D extends { slug: infer S extends string } ? S : string;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Infer a union of field names from a model definition.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* type FN = InferFieldNames<typeof authModel>;
|
|
153
|
-
* // 'appName' | 'layout' | 'showSignup' | ...
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
export type InferFieldNames<D> = D extends { fields: infer F }
|
|
157
|
-
? Extract<keyof F, string>
|
|
158
|
-
: string;
|
package/src/types.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Player Web Types — React integration types for the browser-side workflow engine.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type {
|
|
6
|
-
PlayerWorkflowDefinition,
|
|
7
|
-
TransitionResult,
|
|
8
|
-
StateMachineEvent,
|
|
9
|
-
ActionHandlerFn,
|
|
10
|
-
BusEvent,
|
|
11
|
-
EventBus,
|
|
12
|
-
} from '@mindmatrix/player-core';
|
|
13
|
-
|
|
14
|
-
/** Configuration for creating a Player instance */
|
|
15
|
-
export interface PlayerConfig {
|
|
16
|
-
/** Workflow definition to interpret */
|
|
17
|
-
definition: PlayerWorkflowDefinition;
|
|
18
|
-
/** Initial state_data */
|
|
19
|
-
initialData?: Record<string, unknown>;
|
|
20
|
-
/** Custom action handlers to register */
|
|
21
|
-
actionHandlers?: Record<string, ActionHandlerFn>;
|
|
22
|
-
/** Custom expression functions */
|
|
23
|
-
functions?: Array<{ name: string; fn: (...args: unknown[]) => unknown; arity: number }>;
|
|
24
|
-
/** Enable structured logging */
|
|
25
|
-
debug?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Player instance exposed to React components */
|
|
29
|
-
export interface PlayerHandle {
|
|
30
|
-
/** Current state name */
|
|
31
|
-
currentState: string;
|
|
32
|
-
/** Current state_data */
|
|
33
|
-
stateData: Record<string, unknown>;
|
|
34
|
-
/** Current instance status */
|
|
35
|
-
status: 'ACTIVE' | 'COMPLETED' | 'CANCELLED';
|
|
36
|
-
/** Execute a named transition */
|
|
37
|
-
transition: (name: string, data?: Record<string, unknown>) => Promise<TransitionResult>;
|
|
38
|
-
/** Set a field in state_data */
|
|
39
|
-
setField: (field: string, value: unknown) => void;
|
|
40
|
-
/** Set a memory value */
|
|
41
|
-
setMemory: (key: string, value: unknown) => void;
|
|
42
|
-
/** Get available (non-auto) transitions from current state */
|
|
43
|
-
availableTransitions: string[];
|
|
44
|
-
/** Publish an event to the local event bus */
|
|
45
|
-
publishEvent: (topic: string, payload?: Record<string, unknown>) => void;
|
|
46
|
-
/** The underlying event bus instance (for domain subscription wiring) */
|
|
47
|
-
eventBus: EventBus;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Domain event received from WebSocket */
|
|
51
|
-
export interface DomainEvent {
|
|
52
|
-
instance_id: string;
|
|
53
|
-
definition_id?: string;
|
|
54
|
-
definition_slug?: string;
|
|
55
|
-
from_state: string;
|
|
56
|
-
to_state: string;
|
|
57
|
-
transition_name: string;
|
|
58
|
-
trigger?: 'user' | 'auto' | 'resume' | 'system';
|
|
59
|
-
state_data_before?: Record<string, unknown>;
|
|
60
|
-
state_data_after?: Record<string, unknown>;
|
|
61
|
-
changed_fields?: string[];
|
|
62
|
-
entity_type?: string | null;
|
|
63
|
-
entity_id?: string | null;
|
|
64
|
-
blocked?: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Subscription configuration for domain events */
|
|
68
|
-
export interface DomainSubscriptionConfig {
|
|
69
|
-
/** Instance IDs to subscribe to */
|
|
70
|
-
instanceIds?: string[];
|
|
71
|
-
/** Entity scope for room subscription */
|
|
72
|
-
entity?: { type: string; id: string };
|
|
73
|
-
/** Event patterns to match (glob-style) */
|
|
74
|
-
patterns?: string[];
|
|
75
|
-
/** Callback when an event matches */
|
|
76
|
-
onEvent?: (event: BusEvent) => void;
|
|
77
|
-
/** Enable/disable subscription */
|
|
78
|
-
enabled?: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Experience workflow definition — extends player-core definition with view metadata */
|
|
82
|
-
export interface ExperienceWorkflowDefinition extends PlayerWorkflowDefinition {
|
|
83
|
-
/** Experience tree to render in each state */
|
|
84
|
-
state_views?: Record<string, ExperienceViewConfig>;
|
|
85
|
-
/** Global experience configuration */
|
|
86
|
-
experience?: {
|
|
87
|
-
/** Default layout for states without explicit views */
|
|
88
|
-
default_layout?: 'stack' | 'row' | 'grid' | 'tabs';
|
|
89
|
-
/** Theme/branding config */
|
|
90
|
-
theme?: Record<string, unknown>;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** View configuration for a specific state */
|
|
95
|
-
export interface ExperienceViewConfig {
|
|
96
|
-
/** Experience tree (ExperienceNode) to render */
|
|
97
|
-
tree?: Record<string, unknown>;
|
|
98
|
-
/** Experience ID to load from registry */
|
|
99
|
-
experienceId?: string;
|
|
100
|
-
/** Title for the state's view */
|
|
101
|
-
title?: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Logging context for structured warnings */
|
|
105
|
-
export interface PlayerLogEntry {
|
|
106
|
-
level: 'debug' | 'info' | 'warn' | 'error';
|
|
107
|
-
category: 'event_match' | 'action_dispatch' | 'expression' | 'transition' | 'lifecycle';
|
|
108
|
-
message: string;
|
|
109
|
-
data?: Record<string, unknown>;
|
|
110
|
-
timestamp: number;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Player event listener for React components */
|
|
114
|
-
export type PlayerEventListener = (event: StateMachineEvent) => void;
|
package/tsconfig.json
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"lib": ["ES2022", "DOM"],
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"outDir": "./dist",
|
|
17
|
-
"rootDir": "./src",
|
|
18
|
-
"noImplicitAny": true,
|
|
19
|
-
"strictNullChecks": true,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"noImplicitReturns": true,
|
|
23
|
-
"noFallthroughCasesInSwitch": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["src/**/*"],
|
|
26
|
-
"exclude": ["node_modules", "dist", "**/__tests__", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts"]
|
|
27
|
-
}
|