@stonecrop/stonecrop 0.4.36 → 0.5.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 (81) hide show
  1. package/README.md +92 -3
  2. package/dist/src/composable.d.ts +74 -8
  3. package/dist/src/composable.d.ts.map +1 -1
  4. package/dist/src/composable.js +348 -0
  5. package/dist/src/composables/operation-log.d.ts +136 -0
  6. package/dist/src/composables/operation-log.d.ts.map +1 -0
  7. package/dist/src/composables/operation-log.js +221 -0
  8. package/dist/src/doctype.d.ts +9 -1
  9. package/dist/src/doctype.d.ts.map +1 -1
  10. package/dist/{doctype.js → src/doctype.js} +9 -3
  11. package/dist/src/exceptions.d.ts +2 -3
  12. package/dist/src/exceptions.d.ts.map +1 -1
  13. package/dist/{exceptions.js → src/exceptions.js} +5 -11
  14. package/dist/src/field-triggers.d.ts +178 -0
  15. package/dist/src/field-triggers.d.ts.map +1 -0
  16. package/dist/src/field-triggers.js +564 -0
  17. package/dist/src/index.d.ts +12 -4
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +18 -0
  20. package/dist/src/plugins/index.d.ts +11 -13
  21. package/dist/src/plugins/index.d.ts.map +1 -1
  22. package/dist/src/plugins/index.js +90 -0
  23. package/dist/src/registry.d.ts +9 -3
  24. package/dist/src/registry.d.ts.map +1 -1
  25. package/dist/{registry.js → src/registry.js} +14 -1
  26. package/dist/src/stonecrop.d.ts +350 -114
  27. package/dist/src/stonecrop.d.ts.map +1 -1
  28. package/dist/src/stonecrop.js +251 -0
  29. package/dist/src/stores/hst.d.ts +157 -0
  30. package/dist/src/stores/hst.d.ts.map +1 -0
  31. package/dist/src/stores/hst.js +483 -0
  32. package/dist/src/stores/index.d.ts +5 -1
  33. package/dist/src/stores/index.d.ts.map +1 -1
  34. package/dist/{stores → src/stores}/index.js +4 -1
  35. package/dist/src/stores/operation-log.d.ts +268 -0
  36. package/dist/src/stores/operation-log.d.ts.map +1 -0
  37. package/dist/src/stores/operation-log.js +571 -0
  38. package/dist/src/types/field-triggers.d.ts +186 -0
  39. package/dist/src/types/field-triggers.d.ts.map +1 -0
  40. package/dist/src/types/field-triggers.js +4 -0
  41. package/dist/src/types/index.d.ts +13 -2
  42. package/dist/src/types/index.d.ts.map +1 -1
  43. package/dist/src/types/index.js +4 -0
  44. package/dist/src/types/operation-log.d.ts +165 -0
  45. package/dist/src/types/operation-log.d.ts.map +1 -0
  46. package/dist/src/types/registry.d.ts +11 -0
  47. package/dist/src/types/registry.d.ts.map +1 -0
  48. package/dist/src/types/registry.js +0 -0
  49. package/dist/stonecrop.d.ts +1555 -159
  50. package/dist/stonecrop.js +1974 -7035
  51. package/dist/stonecrop.js.map +1 -1
  52. package/dist/stonecrop.umd.cjs +4 -8
  53. package/dist/stonecrop.umd.cjs.map +1 -1
  54. package/dist/tests/setup.d.ts +5 -0
  55. package/dist/tests/setup.d.ts.map +1 -0
  56. package/dist/tests/setup.js +15 -0
  57. package/package.json +18 -16
  58. package/src/composable.ts +481 -33
  59. package/src/composables/operation-log.ts +254 -0
  60. package/src/doctype.ts +9 -3
  61. package/src/exceptions.ts +5 -12
  62. package/src/field-triggers.ts +671 -0
  63. package/src/index.ts +50 -4
  64. package/src/plugins/index.ts +70 -22
  65. package/src/registry.ts +18 -3
  66. package/src/stonecrop.ts +246 -151
  67. package/src/stores/hst.ts +703 -0
  68. package/src/stores/index.ts +6 -1
  69. package/src/stores/operation-log.ts +671 -0
  70. package/src/types/field-triggers.ts +201 -0
  71. package/src/types/index.ts +17 -6
  72. package/src/types/operation-log.ts +205 -0
  73. package/src/types/registry.ts +10 -0
  74. package/dist/composable.js +0 -51
  75. package/dist/index.js +0 -6
  76. package/dist/plugins/index.js +0 -49
  77. package/dist/src/stores/data.d.ts +0 -11
  78. package/dist/src/stores/data.d.ts.map +0 -1
  79. package/dist/stores/data.js +0 -7
  80. package/src/stores/data.ts +0 -8
  81. /package/dist/{types/index.js → src/types/operation-log.js} +0 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Field-level action trigger system types
3
+ * @public
4
+ */
5
+ import { HSTNode } from '../stores/hst';
6
+ /**
7
+ * Context provided to action functions when field changes occur
8
+ * @public
9
+ */
10
+ export interface FieldChangeContext {
11
+ /** The HST path that was changed */
12
+ path: string;
13
+ /** The field name (last segment of path) */
14
+ fieldname: string;
15
+ /** Value before the change */
16
+ beforeValue: any;
17
+ /** Value after the change */
18
+ afterValue: any;
19
+ /** The operation type */
20
+ operation: 'set' | 'delete' | 'patch';
21
+ /** The doctype of the record being changed */
22
+ doctype: string;
23
+ /** The record ID if applicable */
24
+ recordId?: string;
25
+ /** Timestamp of the change */
26
+ timestamp: Date;
27
+ /** Reference to the HST store for state access (optional) */
28
+ store?: HSTNode;
29
+ }
30
+ /**
31
+ * Context provided to XState transition action functions
32
+ * Extends FieldChangeContext with FSM-specific data
33
+ * @public
34
+ */
35
+ export interface TransitionChangeContext extends FieldChangeContext {
36
+ /** The XState transition name that triggered this action */
37
+ transition: string;
38
+ /** Current workflow state before transition */
39
+ currentState?: string;
40
+ /** Target workflow state after transition */
41
+ targetState?: string;
42
+ /** Additional FSM context data */
43
+ fsmContext?: Record<string, any>;
44
+ }
45
+ /**
46
+ * Action function that can be triggered by field changes
47
+ * @public
48
+ */
49
+ export type FieldActionFunction = (context: FieldChangeContext) => void | Promise<void>;
50
+ /**
51
+ * Action function for XState transition triggers
52
+ * Receives enhanced context with FSM state information
53
+ * @public
54
+ */
55
+ export type TransitionActionFunction = (context: TransitionChangeContext) => void | Promise<void>;
56
+ /**
57
+ * String reference to a globally registered action function or inline function
58
+ * @public
59
+ */
60
+ export type FieldActionString = string;
61
+ /**
62
+ * Supported action types for field triggers
63
+ * @public
64
+ */
65
+ export type FieldAction = FieldActionFunction | FieldActionString;
66
+ /**
67
+ * Supported action types for XState transitions
68
+ * Can be either a transition-specific function or a string reference
69
+ * @public
70
+ */
71
+ export type TransitionAction = TransitionActionFunction | FieldActionString;
72
+ /**
73
+ * Configuration for a single field trigger
74
+ * @public
75
+ */
76
+ export interface FieldTriggerConfig {
77
+ /** Array of actions to execute when this field changes */
78
+ actions: FieldAction[];
79
+ /** Optional condition function to determine if actions should run */
80
+ condition?: (context: FieldChangeContext) => boolean | Promise<boolean>;
81
+ /** Whether to run actions before or after the value is set (default: 'after') */
82
+ timing?: 'before' | 'after';
83
+ /** Whether to stop execution on first error (default: true) */
84
+ stopOnError?: boolean;
85
+ /** Maximum execution time in milliseconds before timeout */
86
+ timeout?: number;
87
+ /** Whether to enable automatic rollback for this field trigger (overrides global setting) */
88
+ enableRollback?: boolean;
89
+ }
90
+ /**
91
+ * Map of field paths to trigger configurations
92
+ * Supports wildcard patterns like 'emailAddress.*.is_primary'
93
+ * @public
94
+ */
95
+ export type FieldTriggerMap = Record<string, FieldTriggerConfig | FieldAction[]>;
96
+ /**
97
+ * Registry for storing global action functions
98
+ * @public
99
+ */
100
+ export interface ActionRegistry {
101
+ /** Register a global action function */
102
+ register(name: string, fn: FieldActionFunction): void;
103
+ /** Get a registered action function */
104
+ get(name: string): FieldActionFunction | undefined;
105
+ /** Check if an action is registered */
106
+ has(name: string): boolean;
107
+ /** Unregister an action function */
108
+ unregister(name: string): void;
109
+ /** Get all registered action names */
110
+ list(): string[];
111
+ }
112
+ /**
113
+ * Result of executing a field action
114
+ * @public
115
+ */
116
+ export interface ActionExecutionResult {
117
+ /** Whether the action executed successfully */
118
+ success: boolean;
119
+ /** Error if execution failed */
120
+ error?: Error;
121
+ /** Execution time in milliseconds */
122
+ executionTime: number;
123
+ /** The action that was executed */
124
+ action: FieldAction;
125
+ }
126
+ /**
127
+ * Result of executing an XState transition action
128
+ * @public
129
+ */
130
+ export interface TransitionExecutionResult {
131
+ /** Whether the action executed successfully */
132
+ success: boolean;
133
+ /** Error if execution failed */
134
+ error?: Error;
135
+ /** Execution time in milliseconds */
136
+ executionTime: number;
137
+ /** The action that was executed */
138
+ action: TransitionAction;
139
+ /** The transition name that was executed */
140
+ transition: string;
141
+ }
142
+ /**
143
+ * Result of executing all actions for a field change
144
+ * @public
145
+ */
146
+ export interface FieldTriggerExecutionResult {
147
+ /** The path that triggered the actions */
148
+ path: string;
149
+ /** Results for each action that was executed */
150
+ actionResults: ActionExecutionResult[];
151
+ /** Total execution time for all actions */
152
+ totalExecutionTime: number;
153
+ /** Whether all actions succeeded */
154
+ allSucceeded: boolean;
155
+ /** Whether execution was stopped due to an error */
156
+ stoppedOnError: boolean;
157
+ /** Whether a rollback was performed */
158
+ rolledBack: boolean;
159
+ /** The snapshot that was captured before execution */
160
+ snapshot?: any;
161
+ }
162
+ /**
163
+ * Options for the field trigger system
164
+ * @public
165
+ */
166
+ export interface FieldTriggerOptions {
167
+ /** Default timeout for action execution in milliseconds */
168
+ defaultTimeout?: number;
169
+ /** Whether to log trigger executions for debugging */
170
+ debug?: boolean;
171
+ /** Custom error handler for action failures */
172
+ errorHandler?: (error: Error, context: FieldChangeContext, action: FieldAction) => void;
173
+ /** Whether to enable automatic rollback on failure (default: true) */
174
+ enableRollback?: boolean;
175
+ }
176
+ /**
177
+ * Pattern matching result for wildcard paths
178
+ * @internal
179
+ */
180
+ export interface _PathMatchResult {
181
+ /** Whether the path matches the pattern */
182
+ matches: boolean;
183
+ /** Captured wildcard values */
184
+ captures: Record<string, string>;
185
+ }
186
+ //# sourceMappingURL=field-triggers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-triggers.d.ts","sourceRoot":"","sources":["../../../src/types/field-triggers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,8BAA8B;IAC9B,WAAW,EAAE,GAAG,CAAA;IAChB,6BAA6B;IAC7B,UAAU,EAAE,GAAG,CAAA;IACf,y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;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC3C,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,aAAa,EAAE,qBAAqB,EAAE,CAAA;IACtC,2CAA2C;IAC3C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,oCAAoC;IACpC,YAAY,EAAE,OAAO,CAAA;IACrB,oDAAoD;IACpD,cAAc,EAAE,OAAO,CAAA;IACvB,uCAAuC;IACvC,UAAU,EAAE,OAAO,CAAA;IACnB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,GAAG,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,+CAA+C;IAC/C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACvF,sEAAsE;IACtE,cAAc,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC,2CAA2C;IAC3C,OAAO,EAAE,OAAO,CAAA;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Field-level action trigger system types
3
+ * @public
4
+ */
@@ -3,7 +3,10 @@ import { List, Map } from 'immutable';
3
3
  import type { Component } from 'vue';
4
4
  import type { Router } from 'vue-router';
5
5
  import type { AnyStateNodeConfig, UnknownMachineConfig } from 'xstate';
6
- import DoctypeMeta from '../doctype';
6
+ import type DoctypeMeta from '../doctype';
7
+ import Registry from '../registry';
8
+ import { Stonecrop } from '../stonecrop';
9
+ import type { RouteContext } from './registry';
7
10
  /**
8
11
  * Immutable Doctype type for Stonecrop instances
9
12
  * @public
@@ -18,6 +21,7 @@ export type ImmutableDoctype = {
18
21
  * @public
19
22
  */
20
23
  export type MutableDoctype = {
24
+ doctype?: string;
21
25
  schema?: SchemaTypes[];
22
26
  workflow?: UnknownMachineConfig | AnyStateNodeConfig;
23
27
  actions?: Record<string, string[]>;
@@ -37,6 +41,13 @@ export type Schema = {
37
41
  export type InstallOptions = {
38
42
  router?: Router;
39
43
  components?: Record<string, Component>;
40
- getMeta?: (doctype?: string) => DoctypeMeta | Promise<DoctypeMeta>;
44
+ getMeta?: (routeContext: RouteContext) => DoctypeMeta | Promise<DoctypeMeta>;
45
+ /** Automatically run initialization callback after app mounting (default: false) */
46
+ autoInitializeRouter?: boolean;
47
+ /** Callback function called after plugin is ready and mounted */
48
+ onRouterInitialized?: (registry: Registry, stonecrop: Stonecrop) => void | Promise<void>;
41
49
  };
50
+ export * from './field-triggers';
51
+ export * from './registry';
52
+ export * from './operation-log';
42
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,WAAW,MAAM,YAAY,CAAA;AAEpC;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAE9B,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IAC7D,QAAQ,CAAC,OAAO,CA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-export types
2
+ export * from './field-triggers';
3
+ export * from './registry';
4
+ export * from './operation-log';
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Type of HST operation
3
+ * @public
4
+ */
5
+ export type HSTOperationType = 'set' | 'delete' | 'batch' | 'transition' | 'action';
6
+ /**
7
+ * Operation source - where the change originated
8
+ * @public
9
+ */
10
+ export type OperationSource = 'user' | 'system' | 'sync' | 'undo' | 'redo';
11
+ /**
12
+ * Complete metadata for an HST mutation
13
+ * Enables time travel, synchronization, and audit trails
14
+ * @public
15
+ */
16
+ export interface HSTOperation {
17
+ /** Unique operation identifier */
18
+ id: string;
19
+ /** Type of operation performed */
20
+ type: HSTOperationType;
21
+ /** Full HST path affected (e.g., "task.123.title") */
22
+ path: string;
23
+ /** Field name extracted from path */
24
+ fieldname: string;
25
+ /** Value before the operation */
26
+ beforeValue: any;
27
+ /** Value after the operation */
28
+ afterValue: any;
29
+ /** Doctype this operation affects */
30
+ doctype: string;
31
+ /** Record ID if applicable */
32
+ recordId?: string;
33
+ /** Timestamp of the operation */
34
+ timestamp: Date;
35
+ /** Source of the operation (defaults to 'user' if not specified) */
36
+ source?: OperationSource;
37
+ /** Whether this operation can be undone */
38
+ reversible: boolean;
39
+ /** Reason if operation is irreversible */
40
+ irreversibleReason?: string;
41
+ /** XState transition name if triggered by FSM */
42
+ transition?: string;
43
+ /** XState current state before transition */
44
+ currentState?: string;
45
+ /** XState target state after transition */
46
+ targetState?: string;
47
+ /** Action name if operation is an action execution (type: 'action') */
48
+ actionName?: string;
49
+ /** Record IDs that the action was executed on */
50
+ actionRecordIds?: string[];
51
+ /** Result or status of the action execution */
52
+ actionResult?: 'success' | 'failure' | 'pending';
53
+ /** Error message if action execution failed */
54
+ actionError?: string;
55
+ /** User or session identifier */
56
+ userId?: string;
57
+ /** Additional metadata for custom use cases */
58
+ metadata?: Record<string, any>;
59
+ /** Parent operation ID for batch operations */
60
+ parentOperationId?: string;
61
+ /** Child operation IDs for batch operations */
62
+ childOperationIds?: string[];
63
+ }
64
+ /**
65
+ * Input type for adding operations
66
+ * Excludes system-generated fields (id, timestamp)
67
+ * @public
68
+ */
69
+ export type HSTOperationInput = Omit<HSTOperation, 'id' | 'timestamp' | 'source'> & {
70
+ source?: OperationSource;
71
+ };
72
+ /**
73
+ * Batch operation wrapper
74
+ * @public
75
+ */
76
+ export interface BatchOperation {
77
+ /** Unique batch identifier */
78
+ id: string;
79
+ /** Operations included in this batch */
80
+ operations: HSTOperation[];
81
+ /** When the batch was created */
82
+ timestamp: Date;
83
+ /** Optional description of what this batch represents */
84
+ description?: string;
85
+ /** Whether the entire batch can be undone */
86
+ reversible: boolean;
87
+ }
88
+ /**
89
+ * Operation log configuration
90
+ * @public
91
+ */
92
+ export interface OperationLogConfig {
93
+ /** Maximum operations to store (default: 100) */
94
+ maxOperations?: number;
95
+ /** Enable cross-tab synchronization (default: true) */
96
+ enableCrossTabSync?: boolean;
97
+ /** Auto-sync interval in milliseconds (default: 30000) */
98
+ autoSyncInterval?: number;
99
+ /** Enable operation persistence to localStorage (default: false) */
100
+ enablePersistence?: boolean;
101
+ /** Persistence key prefix */
102
+ persistenceKeyPrefix?: string;
103
+ /** User identifier for multi-user scenarios */
104
+ userId?: string;
105
+ /** Custom operation filter */
106
+ operationFilter?: (operation: HSTOperation) => boolean;
107
+ }
108
+ /**
109
+ * Undo/Redo state
110
+ * @public
111
+ */
112
+ export interface UndoRedoState {
113
+ /** Can undo */
114
+ canUndo: boolean;
115
+ /** Can redo */
116
+ canRedo: boolean;
117
+ /** Number of operations available for undo */
118
+ undoCount: number;
119
+ /** Number of operations available for redo */
120
+ redoCount: number;
121
+ /** Current operation index */
122
+ currentIndex: number;
123
+ }
124
+ /**
125
+ * Operation log snapshot for debugging
126
+ * @public
127
+ */
128
+ export interface OperationLogSnapshot {
129
+ /** All operations in the log */
130
+ operations: HSTOperation[];
131
+ /** Current operation index in the history */
132
+ currentIndex: number;
133
+ /** Total number of operations */
134
+ totalOperations: number;
135
+ /** Number of operations that can be undone */
136
+ reversibleOperations: number;
137
+ /** Number of operations that cannot be undone */
138
+ irreversibleOperations: number;
139
+ /** Timestamp of the oldest operation */
140
+ oldestOperation?: Date;
141
+ /** Timestamp of the newest operation */
142
+ newestOperation?: Date;
143
+ }
144
+ /**
145
+ * Cross-tab message types
146
+ * @public
147
+ */
148
+ export type CrossTabMessageType = 'operation' | 'undo' | 'redo' | 'sync-request' | 'sync-response';
149
+ /**
150
+ * Cross-tab message payload
151
+ * @public
152
+ */
153
+ export interface CrossTabMessage {
154
+ /** Type of cross-tab message */
155
+ type: CrossTabMessageType;
156
+ /** Single operation for operation/undo/redo messages */
157
+ operation?: HSTOperation;
158
+ /** Multiple operations for sync messages */
159
+ operations?: HSTOperation[];
160
+ /** Identifier of the client/tab sending the message */
161
+ clientId: string;
162
+ /** When the message was sent */
163
+ timestamp: Date;
164
+ }
165
+ //# sourceMappingURL=operation-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-log.d.ts","sourceRoot":"","sources":["../../../src/types/operation-log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAA;AAEnF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE1E;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAA;IAEV,kCAAkC;IAClC,IAAI,EAAE,gBAAgB,CAAA;IAEtB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IAEZ,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;IAEjB,iCAAiC;IACjC,WAAW,EAAE,GAAG,CAAA;IAEhB,gCAAgC;IAChC,UAAU,EAAE,GAAG,CAAA;IAEf,qCAAqC;IACrC,OAAO,EAAE,MAAM,C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AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,eAAe,CAAA;AAElG;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,gCAAgC;IAChC,IAAI,EAAE,mBAAmB,CAAA;IACzB,wDAAwD;IACxD,SAAS,CAAC,EAAE,YAAY,CAAA;IACxB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,YAAY,EAAE,CAAA;IAC3B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAA;IAChB,gCAAgC;IAChC,SAAS,EAAE,IAAI,CAAA;CACf"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Route context passed to getMeta function
3
+ * @public
4
+ */
5
+ export interface RouteContext {
6
+ /** The full route path (e.g., "/todo/1" or "/todo") */
7
+ path: string;
8
+ /** Path segments split by "/" (e.g., ["todo", "1"] or ["todo"]) */
9
+ segments: string[];
10
+ }
11
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/types/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,mEAAmE;IACnE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAClB"}
File without changes