@rippling/rippling-sdk 0.2.0-alpha.36 → 0.2.0-alpha.38

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 (232) hide show
  1. package/client.d.mts +7 -1
  2. package/client.d.mts.map +1 -1
  3. package/client.d.ts +7 -1
  4. package/client.d.ts.map +1 -1
  5. package/client.js +7 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +7 -1
  8. package/client.mjs.map +1 -1
  9. package/examples/manifest/dental-practice-management/dental-practice-management.ts +21 -34
  10. package/examples/manifest/gym-membership-management/gym-membership-management.ts +27 -38
  11. package/examples/manifest/gym-membership-management/manifest.json +1 -1
  12. package/examples/sdui/sdui-crud-todo/sdui-crud-todo.ts +3 -3
  13. package/examples/sdui/sdui-showcase/sdui-showcase.ts +6 -11
  14. package/examples/sdui/sdui-tab-multi-view/sdui-tab-multi-view.ts +14 -24
  15. package/examples/sdui/vote/vote.ts +7 -11
  16. package/internal/utils/log.d.mts.map +1 -1
  17. package/internal/utils/log.d.ts.map +1 -1
  18. package/internal/utils/log.js +2 -0
  19. package/internal/utils/log.js.map +1 -1
  20. package/internal/utils/log.mjs +2 -0
  21. package/internal/utils/log.mjs.map +1 -1
  22. package/lib/manifest/category.d.mts +4 -2
  23. package/lib/manifest/category.d.mts.map +1 -1
  24. package/lib/manifest/category.d.ts +4 -2
  25. package/lib/manifest/category.d.ts.map +1 -1
  26. package/lib/manifest/category.js +2 -2
  27. package/lib/manifest/category.js.map +1 -1
  28. package/lib/manifest/category.mjs +2 -2
  29. package/lib/manifest/category.mjs.map +1 -1
  30. package/lib/manifest/custom-object-field-section.d.mts +4 -0
  31. package/lib/manifest/custom-object-field-section.d.mts.map +1 -1
  32. package/lib/manifest/custom-object-field-section.d.ts +4 -0
  33. package/lib/manifest/custom-object-field-section.d.ts.map +1 -1
  34. package/lib/manifest/custom-object-field-section.js +6 -0
  35. package/lib/manifest/custom-object-field-section.js.map +1 -1
  36. package/lib/manifest/custom-object-field-section.mjs +6 -0
  37. package/lib/manifest/custom-object-field-section.mjs.map +1 -1
  38. package/lib/manifest/custom-object-page-layout.d.mts +23 -13
  39. package/lib/manifest/custom-object-page-layout.d.mts.map +1 -1
  40. package/lib/manifest/custom-object-page-layout.d.ts +23 -13
  41. package/lib/manifest/custom-object-page-layout.d.ts.map +1 -1
  42. package/lib/manifest/custom-object-page-layout.js +122 -9
  43. package/lib/manifest/custom-object-page-layout.js.map +1 -1
  44. package/lib/manifest/custom-object-page-layout.mjs +122 -9
  45. package/lib/manifest/custom-object-page-layout.mjs.map +1 -1
  46. package/lib/manifest/custom-object.d.mts +30 -1
  47. package/lib/manifest/custom-object.d.mts.map +1 -1
  48. package/lib/manifest/custom-object.d.ts +30 -1
  49. package/lib/manifest/custom-object.d.ts.map +1 -1
  50. package/lib/manifest/custom-object.js +15 -1
  51. package/lib/manifest/custom-object.js.map +1 -1
  52. package/lib/manifest/custom-object.mjs +15 -1
  53. package/lib/manifest/custom-object.mjs.map +1 -1
  54. package/lib/manifest/field.d.mts +25 -3
  55. package/lib/manifest/field.d.mts.map +1 -1
  56. package/lib/manifest/field.d.ts +25 -3
  57. package/lib/manifest/field.d.ts.map +1 -1
  58. package/lib/manifest/field.js +28 -2
  59. package/lib/manifest/field.js.map +1 -1
  60. package/lib/manifest/field.mjs +28 -2
  61. package/lib/manifest/field.mjs.map +1 -1
  62. package/lib/manifest/index.d.mts +1 -1
  63. package/lib/manifest/index.d.mts.map +1 -1
  64. package/lib/manifest/index.d.ts +1 -1
  65. package/lib/manifest/index.d.ts.map +1 -1
  66. package/lib/manifest/index.js.map +1 -1
  67. package/lib/manifest/index.mjs.map +1 -1
  68. package/lib/manifest/manifest-builder.d.mts +1 -1
  69. package/lib/manifest/manifest-builder.d.ts +1 -1
  70. package/lib/manifest/manifest-builder.js +1 -1
  71. package/lib/manifest/manifest-builder.mjs +1 -1
  72. package/lib/manifest/manifest-function.d.mts +8 -2
  73. package/lib/manifest/manifest-function.d.mts.map +1 -1
  74. package/lib/manifest/manifest-function.d.ts +8 -2
  75. package/lib/manifest/manifest-function.d.ts.map +1 -1
  76. package/lib/manifest/manifest-function.js +8 -2
  77. package/lib/manifest/manifest-function.js.map +1 -1
  78. package/lib/manifest/manifest-function.mjs +8 -2
  79. package/lib/manifest/manifest-function.mjs.map +1 -1
  80. package/lib/sdui/actions.d.mts.map +1 -1
  81. package/lib/sdui/actions.d.ts.map +1 -1
  82. package/lib/sdui/actions.js +23 -13
  83. package/lib/sdui/actions.js.map +1 -1
  84. package/lib/sdui/actions.mjs +23 -13
  85. package/lib/sdui/actions.mjs.map +1 -1
  86. package/lib/sdui/component.d.mts +28 -11
  87. package/lib/sdui/component.d.mts.map +1 -1
  88. package/lib/sdui/component.d.ts +28 -11
  89. package/lib/sdui/component.d.ts.map +1 -1
  90. package/lib/sdui/component.js +69 -36
  91. package/lib/sdui/component.js.map +1 -1
  92. package/lib/sdui/component.mjs +69 -36
  93. package/lib/sdui/component.mjs.map +1 -1
  94. package/lib/sdui/components.d.mts +1141 -132
  95. package/lib/sdui/components.d.mts.map +1 -1
  96. package/lib/sdui/components.d.ts +1141 -132
  97. package/lib/sdui/components.d.ts.map +1 -1
  98. package/lib/sdui/components.js +834 -206
  99. package/lib/sdui/components.js.map +1 -1
  100. package/lib/sdui/components.mjs +830 -203
  101. package/lib/sdui/components.mjs.map +1 -1
  102. package/lib/sdui/directives.d.mts.map +1 -1
  103. package/lib/sdui/directives.d.ts.map +1 -1
  104. package/lib/sdui/directives.js +4 -1
  105. package/lib/sdui/directives.js.map +1 -1
  106. package/lib/sdui/directives.mjs +4 -1
  107. package/lib/sdui/directives.mjs.map +1 -1
  108. package/lib/sdui/index.d.mts +314 -261
  109. package/lib/sdui/index.d.mts.map +1 -1
  110. package/lib/sdui/index.d.ts +314 -261
  111. package/lib/sdui/index.d.ts.map +1 -1
  112. package/lib/sdui/index.js +255 -204
  113. package/lib/sdui/index.js.map +1 -1
  114. package/lib/sdui/index.mjs +128 -103
  115. package/lib/sdui/index.mjs.map +1 -1
  116. package/lib/sdui/propTypes.d.mts +6330 -0
  117. package/lib/sdui/propTypes.d.mts.map +1 -0
  118. package/lib/sdui/propTypes.d.ts +6330 -0
  119. package/lib/sdui/propTypes.d.ts.map +1 -0
  120. package/lib/sdui/propTypes.js +14 -0
  121. package/lib/sdui/propTypes.js.map +1 -0
  122. package/lib/sdui/propTypes.mjs +13 -0
  123. package/lib/sdui/propTypes.mjs.map +1 -0
  124. package/lib/sdui/render.d.mts +1 -1
  125. package/lib/sdui/render.d.mts.map +1 -1
  126. package/lib/sdui/render.d.ts +1 -1
  127. package/lib/sdui/render.d.ts.map +1 -1
  128. package/lib/sdui/render.js +11 -3
  129. package/lib/sdui/render.js.map +1 -1
  130. package/lib/sdui/render.mjs +11 -3
  131. package/lib/sdui/render.mjs.map +1 -1
  132. package/lib/sdui/state.d.mts.map +1 -1
  133. package/lib/sdui/state.d.ts.map +1 -1
  134. package/lib/sdui/state.js +3 -1
  135. package/lib/sdui/state.js.map +1 -1
  136. package/lib/sdui/state.mjs +3 -1
  137. package/lib/sdui/state.mjs.map +1 -1
  138. package/package.json +1 -1
  139. package/resources/company-legal-entities.d.mts +180 -0
  140. package/resources/company-legal-entities.d.mts.map +1 -0
  141. package/resources/company-legal-entities.d.ts +180 -0
  142. package/resources/company-legal-entities.d.ts.map +1 -0
  143. package/resources/company-legal-entities.js +30 -0
  144. package/resources/company-legal-entities.js.map +1 -0
  145. package/resources/company-legal-entities.mjs +26 -0
  146. package/resources/company-legal-entities.mjs.map +1 -0
  147. package/resources/earning-types.d.mts +1 -6
  148. package/resources/earning-types.d.mts.map +1 -1
  149. package/resources/earning-types.d.ts +1 -6
  150. package/resources/earning-types.d.ts.map +1 -1
  151. package/resources/earning-types.js +1 -1
  152. package/resources/earning-types.mjs +1 -1
  153. package/resources/earnings-inputs.d.mts +1 -1
  154. package/resources/earnings-inputs.d.ts +1 -1
  155. package/resources/earnings-inputs.js +1 -1
  156. package/resources/earnings-inputs.mjs +1 -1
  157. package/resources/index.d.mts +2 -1
  158. package/resources/index.d.mts.map +1 -1
  159. package/resources/index.d.ts +2 -1
  160. package/resources/index.d.ts.map +1 -1
  161. package/resources/index.js +5 -3
  162. package/resources/index.js.map +1 -1
  163. package/resources/index.mjs +2 -1
  164. package/resources/index.mjs.map +1 -1
  165. package/resources/legal-entities.d.mts +1 -1
  166. package/resources/legal-entities.d.mts.map +1 -1
  167. package/resources/legal-entities.d.ts +1 -1
  168. package/resources/legal-entities.d.ts.map +1 -1
  169. package/resources/payroll-runs/index.d.mts +3 -0
  170. package/resources/payroll-runs/index.d.mts.map +1 -0
  171. package/resources/payroll-runs/index.d.ts +3 -0
  172. package/resources/payroll-runs/index.d.ts.map +1 -0
  173. package/resources/payroll-runs/index.js +9 -0
  174. package/resources/payroll-runs/index.js.map +1 -0
  175. package/resources/payroll-runs/index.mjs +4 -0
  176. package/resources/payroll-runs/index.mjs.map +1 -0
  177. package/resources/payroll-runs/payroll-runs.d.mts +199 -0
  178. package/resources/payroll-runs/payroll-runs.d.mts.map +1 -0
  179. package/resources/payroll-runs/payroll-runs.d.ts +199 -0
  180. package/resources/payroll-runs/payroll-runs.d.ts.map +1 -0
  181. package/resources/payroll-runs/payroll-runs.js +40 -0
  182. package/resources/payroll-runs/payroll-runs.js.map +1 -0
  183. package/resources/payroll-runs/payroll-runs.mjs +35 -0
  184. package/resources/payroll-runs/payroll-runs.mjs.map +1 -0
  185. package/resources/payroll-runs/worker-payroll-records.d.mts +200 -0
  186. package/resources/payroll-runs/worker-payroll-records.d.mts.map +1 -0
  187. package/resources/payroll-runs/worker-payroll-records.d.ts +200 -0
  188. package/resources/payroll-runs/worker-payroll-records.d.ts.map +1 -0
  189. package/resources/payroll-runs/worker-payroll-records.js +23 -0
  190. package/resources/payroll-runs/worker-payroll-records.js.map +1 -0
  191. package/resources/payroll-runs/worker-payroll-records.mjs +19 -0
  192. package/resources/payroll-runs/worker-payroll-records.mjs.map +1 -0
  193. package/resources/payroll-runs.d.mts +1 -194
  194. package/resources/payroll-runs.d.mts.map +1 -1
  195. package/resources/payroll-runs.d.ts +1 -194
  196. package/resources/payroll-runs.d.ts.map +1 -1
  197. package/resources/payroll-runs.js +2 -28
  198. package/resources/payroll-runs.js.map +1 -1
  199. package/resources/payroll-runs.mjs +1 -26
  200. package/resources/payroll-runs.mjs.map +1 -1
  201. package/src/client.ts +27 -7
  202. package/src/internal/utils/log.ts +2 -0
  203. package/src/lib/manifest/category.ts +7 -5
  204. package/src/lib/manifest/custom-object-field-section.ts +7 -0
  205. package/src/lib/manifest/custom-object-page-layout.ts +225 -18
  206. package/src/lib/manifest/custom-object.ts +30 -1
  207. package/src/lib/manifest/field.ts +29 -3
  208. package/src/lib/manifest/index.ts +2 -0
  209. package/src/lib/manifest/manifest-builder.ts +1 -1
  210. package/src/lib/manifest/manifest-function.ts +8 -2
  211. package/src/lib/sdui/actions.ts +23 -10
  212. package/src/lib/sdui/component.ts +84 -44
  213. package/src/lib/sdui/components.ts +1627 -212
  214. package/src/lib/sdui/directives.ts +4 -1
  215. package/src/lib/sdui/index.ts +565 -200
  216. package/src/lib/sdui/propTypes.ts +8470 -0
  217. package/src/lib/sdui/render.ts +13 -5
  218. package/src/lib/sdui/state.ts +8 -2
  219. package/src/resources/company-legal-entities.ts +237 -0
  220. package/src/resources/earning-types.ts +1 -7
  221. package/src/resources/earnings-inputs.ts +1 -1
  222. package/src/resources/index.ts +8 -1
  223. package/src/resources/legal-entities.ts +1 -1
  224. package/src/resources/payroll-runs/index.ts +15 -0
  225. package/src/resources/payroll-runs/payroll-runs.ts +270 -0
  226. package/src/resources/payroll-runs/worker-payroll-records.ts +255 -0
  227. package/src/resources/payroll-runs.ts +1 -249
  228. package/src/version.ts +1 -1
  229. package/version.d.mts +1 -1
  230. package/version.d.ts +1 -1
  231. package/version.js +1 -1
  232. package/version.mjs +1 -1
@@ -1,25 +1,38 @@
1
1
  /**
2
2
  * component() — creates a stateful component boundary.
3
3
  *
4
- * Provides ctx.useState (scoped local state) and ctx.useEffect (onMount actions).
5
- * The returned element is automatically wrapped with _LocalStateProvider in the rendered spec.
4
+ * Provides ctx.localState (scoped local state slot) and ctx.onMount (an
5
+ * action that fires once when the component mounts on the client). The
6
+ * runtime handles state setup and mount firing; consumers don't need to
7
+ * know how the wrapping is implemented.
8
+ *
9
+ * NOTE: these are NOT React hooks. The factory runs ONCE at spec-build
10
+ * time, producing a JSON description of the UI. `localState` returns a
11
+ * path-builder proxy (not a [value, setter] tuple); `onMount` registers
12
+ * a JSON action that fires on first client render (not an effect that
13
+ * re-runs).
6
14
  *
7
15
  * Usage:
8
16
  * function MembersGrid(props) {
9
17
  * return component((ctx) => {
10
- * const local = ctx.useState({ data: [], loading: true })
11
- * ctx.useEffect(fetchAction)
12
- * return { element: DataGrid({ ... }), refresh: fetchAction }
18
+ * const local = ctx.localState({ data: [], loading: true })
19
+ * ctx.onMount(fetchAction)
20
+ * return { element: DataGrid({ ... }) }
13
21
  * })
14
22
  * }
15
23
  */
16
24
 
17
- import type { SpecNode } from './components';
18
25
  import type { ActionBinding } from './actions';
26
+ import type { SpecNode } from './components';
19
27
 
20
28
  let _idCounter = 0;
29
+ // Counter-only IDs (no Date.now()) so the same factory body produces the
30
+ // same paths across runs. The counter is monotonic per process; calling
31
+ // `_resetIdCounter()` (tests only) brings it back to 0 so snapshot tests
32
+ // stay stable.
21
33
  function generateId(): string {
22
- return `auto_${(++_idCounter).toString(36)}_${Date.now().toString(36)}`;
34
+ _idCounter += 1;
35
+ return `auto_${_idCounter.toString(36)}`;
23
36
  }
24
37
 
25
38
  // Reset counter (for testing)
@@ -37,15 +50,25 @@ export interface StateScope {
37
50
  }
38
51
 
39
52
  interface ComponentContext {
40
- /** Declare scoped local state. Returns a proxy for reading/binding. */
41
- useState<T extends Record<string, unknown>>(initial: T): StateScope;
42
- /** Register an action to fire on mount (when element becomes visible). */
43
- useEffect(action: ActionBinding | ActionBinding[]): void;
53
+ /**
54
+ * Declare a scoped local state slot. Returns a path-builder proxy whose
55
+ * property accesses produce `{ $state: '/path' }` references for reading
56
+ * and `.$bind` for two-way binding. Not a React hook — runs once when
57
+ * the factory is invoked, never returns `[value, setter]`.
58
+ */
59
+ localState<T extends Record<string, unknown>>(initial: T): StateScope;
60
+
61
+ /**
62
+ * Register a JSON action to fire once when the component mounts on the
63
+ * client. Not a React effect — does not re-run, has no dependency
64
+ * tracking. Pass an `ActionBinding` (e.g. from `set(...)`, `callFunction(...)`)
65
+ * or an array of them.
66
+ */
67
+ onMount(action: ActionBinding | ActionBinding[]): void;
44
68
  }
45
69
 
46
70
  interface ComponentResult {
47
71
  element: SpecNode;
48
- [key: string]: any; // exposed actions like refresh, reset, etc.
49
72
  }
50
73
 
51
74
  function createScopeProxy(basePath: string): StateScope {
@@ -65,58 +88,75 @@ function createScopeProxy(basePath: string): StateScope {
65
88
  }
66
89
 
67
90
  export function component(factory: (ctx: ComponentContext) => ComponentResult): ComponentResult {
68
- let localState: { path: string; initial: unknown } | null = null;
69
- let mountAction: ActionBinding | ActionBinding[] | null = null;
91
+ const states: { path: string; initial: unknown }[] = [];
92
+ const mountActions: (ActionBinding | ActionBinding[])[] = [];
70
93
 
71
94
  const ctx: ComponentContext = {
72
- useState<T extends Record<string, unknown>>(initial: T): StateScope {
95
+ localState<T extends Record<string, unknown>>(initial: T): StateScope {
73
96
  const path = `/${generateId()}`;
74
- localState = { path, initial };
97
+ states.push({ path, initial });
75
98
  return createScopeProxy(path);
76
99
  },
77
- useEffect(action: ActionBinding | ActionBinding[]) {
78
- mountAction = action;
100
+ onMount(action: ActionBinding | ActionBinding[]) {
101
+ mountActions.push(action);
79
102
  },
80
103
  };
81
104
 
82
105
  const result = factory(ctx);
83
106
 
84
- // Capture state after factory execution (TS can't track closure mutations)
85
- const capturedState = localState as { path: string; initial: unknown } | null;
86
- const capturedMount = mountAction;
87
-
88
- // If no local state and no effects, return as-is
89
- if (!capturedState && !capturedMount) {
107
+ // No state, no effects return as-is.
108
+ if (states.length === 0 && mountActions.length === 0) {
90
109
  return result;
91
110
  }
92
111
 
93
- // Wrap element with _LocalStateProvider
94
- const providerProps: Record<string, unknown> = {};
95
- if (capturedState) {
96
- providerProps['statePath'] = capturedState.path;
97
- providerProps['initialValue'] = capturedState.initial;
98
- }
99
- if (capturedMount) {
100
- providerProps['onMountAction'] = capturedMount;
112
+ // Collapse zero/one/many mount actions for the single onMountAction slot
113
+ // on the innermost wrapper.
114
+ let combinedMount: ActionBinding | ActionBinding[] | undefined;
115
+ if (mountActions.length === 1) {
116
+ combinedMount = mountActions[0];
117
+ } else if (mountActions.length > 1) {
118
+ combinedMount = mountActions.flatMap((a) => (Array.isArray(a) ? a : [a]));
101
119
  }
102
120
 
103
- const wrapper: SpecNode = {
104
- type: '_LocalStateProvider',
105
- props: providerProps,
106
- children: [result.element],
107
- };
121
+ let wrapped: SpecNode = result.element;
108
122
 
109
- // Attach the local state to the spec's state tree
110
- // The render() function will collect this via a special marker
111
- if (capturedState) {
112
- (wrapper as any)._localStateRegistration = {
113
- path: capturedState.path,
114
- initial: capturedState.initial,
123
+ if (states.length === 0) {
124
+ // Mount-only: a single state-provider wrapper carries onMountAction.
125
+ wrapped = {
126
+ type: '_LocalStateProvider',
127
+ props: combinedMount ? { onMountAction: combinedMount } : {},
128
+ children: [wrapped],
115
129
  };
130
+ } else {
131
+ // One state-provider wrapper per localState() call, nested
132
+ // innermost-first. Mount actions attach to the innermost wrapper so
133
+ // every state slot is initialized before any action fires.
134
+ for (let i = states.length - 1; i >= 0; i--) {
135
+ const state = states[i];
136
+ if (state) {
137
+ const isInnermost = i === states.length - 1;
138
+ const props: Record<string, unknown> = {
139
+ statePath: state.path,
140
+ initialValue: state.initial,
141
+ ...(isInnermost && combinedMount ? { onMountAction: combinedMount } : {}),
142
+ };
143
+ const wrapper: SpecNode = {
144
+ type: '_LocalStateProvider',
145
+ props,
146
+ children: [wrapped],
147
+ };
148
+ // render() picks up this marker to populate spec.state.
149
+ (wrapper as any)._localStateRegistration = {
150
+ path: state.path,
151
+ initial: state.initial,
152
+ };
153
+ wrapped = wrapper;
154
+ }
155
+ }
116
156
  }
117
157
 
118
158
  return {
119
159
  ...result,
120
- element: wrapper,
160
+ element: wrapped,
121
161
  };
122
162
  }