@svadmin/surface 0.8.19 → 0.9.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 (191) hide show
  1. package/README.md +70 -38
  2. package/STYLING.md +31 -0
  3. package/compatibility.json +23 -2
  4. package/dist/agent-contract.d.ts +37 -0
  5. package/dist/agent-contract.js +203 -0
  6. package/dist/agent.d.ts +38 -7
  7. package/dist/agent.js +98 -59
  8. package/dist/binding.d.ts +2 -0
  9. package/dist/binding.js +7 -1
  10. package/dist/builtin-definitions.d.ts +6 -0
  11. package/dist/builtin-definitions.js +40 -0
  12. package/dist/builtin-schemas.d.ts +25 -0
  13. package/dist/builtin-schemas.js +13 -0
  14. package/dist/catalog.d.ts +4 -61
  15. package/dist/catalog.js +20 -44
  16. package/dist/components/MetricWidget.svelte +12 -8
  17. package/dist/components/ResourceFormBody.svelte +97 -0
  18. package/dist/components/ResourceFormBody.svelte.d.ts +13 -0
  19. package/dist/components/ResourceFormWidget.svelte +19 -0
  20. package/dist/components/ResourceFormWidget.svelte.d.ts +4 -0
  21. package/dist/components/ResourceTableWidget.svelte +14 -12
  22. package/dist/components/SurfaceEditPreview.svelte +107 -0
  23. package/dist/components/SurfaceEditPreview.svelte.d.ts +20 -0
  24. package/dist/components/SurfaceRenderer.svelte +120 -163
  25. package/dist/components/SurfaceRenderer.svelte.d.ts +4 -0
  26. package/dist/components/SurfaceWorkflowProvider.svelte +22 -0
  27. package/dist/components/SurfaceWorkflowProvider.svelte.d.ts +17 -0
  28. package/dist/components/SvarGridWidget.svelte +47 -0
  29. package/dist/components/SvarGridWidget.svelte.d.ts +4 -0
  30. package/dist/components/SvarSurfaceProvider.svelte +12 -0
  31. package/dist/components/SvarSurfaceProvider.svelte.d.ts +11 -0
  32. package/dist/edits.d.ts +57 -0
  33. package/dist/edits.js +166 -0
  34. package/dist/index.d.ts +8 -2
  35. package/dist/index.js +5 -1
  36. package/dist/interactive.d.ts +6 -0
  37. package/dist/interactive.js +15 -0
  38. package/dist/openui.d.ts +64 -0
  39. package/dist/openui.js +168 -0
  40. package/dist/schema.d.ts +108 -0
  41. package/dist/schema.js +73 -0
  42. package/dist/server-sqlite.d.ts +1 -0
  43. package/dist/server-sqlite.js +2 -0
  44. package/dist/server.d.ts +4 -0
  45. package/dist/server.js +4 -0
  46. package/dist/source-cache.d.ts +30 -0
  47. package/dist/source-cache.js +135 -0
  48. package/dist/styled-system/css/conditions.js +36 -0
  49. package/dist/styled-system/css/css.d.ts +22 -0
  50. package/dist/styled-system/css/css.js +45 -0
  51. package/dist/styled-system/css/cva.d.ts +6 -0
  52. package/dist/styled-system/css/cva.js +87 -0
  53. package/dist/styled-system/css/cx.d.ts +5 -0
  54. package/dist/styled-system/css/cx.js +15 -0
  55. package/dist/styled-system/css/index.d.ts +5 -0
  56. package/dist/styled-system/css/index.js +4 -0
  57. package/dist/styled-system/css/sva.d.ts +4 -0
  58. package/dist/styled-system/css/sva.js +46 -0
  59. package/dist/styled-system/design-contract.d.ts +13 -0
  60. package/dist/styled-system/design-contract.js +11 -0
  61. package/dist/styled-system/helpers.js +316 -0
  62. package/dist/styled-system/patterns/aspect-ratio.d.ts +20 -0
  63. package/dist/styled-system/patterns/aspect-ratio.js +38 -0
  64. package/dist/styled-system/patterns/bleed.d.ts +21 -0
  65. package/dist/styled-system/patterns/bleed.js +24 -0
  66. package/dist/styled-system/patterns/box.d.ts +20 -0
  67. package/dist/styled-system/patterns/box.js +15 -0
  68. package/dist/styled-system/patterns/center.d.ts +20 -0
  69. package/dist/styled-system/patterns/center.js +21 -0
  70. package/dist/styled-system/patterns/circle.d.ts +20 -0
  71. package/dist/styled-system/patterns/circle.js +25 -0
  72. package/dist/styled-system/patterns/container.d.ts +20 -0
  73. package/dist/styled-system/patterns/container.js +21 -0
  74. package/dist/styled-system/patterns/cq.d.ts +21 -0
  75. package/dist/styled-system/patterns/cq.js +21 -0
  76. package/dist/styled-system/patterns/divider.d.ts +22 -0
  77. package/dist/styled-system/patterns/divider.js +25 -0
  78. package/dist/styled-system/patterns/flex.d.ts +26 -0
  79. package/dist/styled-system/patterns/flex.js +26 -0
  80. package/dist/styled-system/patterns/float.d.ts +23 -0
  81. package/dist/styled-system/patterns/float.js +52 -0
  82. package/dist/styled-system/patterns/grid-item.d.ts +25 -0
  83. package/dist/styled-system/patterns/grid-item.js +25 -0
  84. package/dist/styled-system/patterns/grid.d.ts +24 -0
  85. package/dist/styled-system/patterns/grid.js +27 -0
  86. package/dist/styled-system/patterns/hstack.d.ts +21 -0
  87. package/dist/styled-system/patterns/hstack.js +24 -0
  88. package/dist/styled-system/patterns/index.d.ts +21 -0
  89. package/dist/styled-system/patterns/index.js +20 -0
  90. package/dist/styled-system/patterns/link-overlay.d.ts +20 -0
  91. package/dist/styled-system/patterns/link-overlay.js +24 -0
  92. package/dist/styled-system/patterns/spacer.d.ts +20 -0
  93. package/dist/styled-system/patterns/spacer.js +25 -0
  94. package/dist/styled-system/patterns/square.d.ts +20 -0
  95. package/dist/styled-system/patterns/square.js +24 -0
  96. package/dist/styled-system/patterns/stack.d.ts +23 -0
  97. package/dist/styled-system/patterns/stack.js +24 -0
  98. package/dist/styled-system/patterns/visually-hidden.d.ts +20 -0
  99. package/dist/styled-system/patterns/visually-hidden.js +18 -0
  100. package/dist/styled-system/patterns/vstack.d.ts +21 -0
  101. package/dist/styled-system/patterns/vstack.js +24 -0
  102. package/dist/styled-system/patterns/wrap.d.ts +24 -0
  103. package/dist/styled-system/patterns/wrap.js +25 -0
  104. package/dist/styled-system/recipes/content-header.d.ts +31 -0
  105. package/dist/styled-system/recipes/content-header.js +65 -0
  106. package/dist/styled-system/recipes/content-page.d.ts +34 -0
  107. package/dist/styled-system/recipes/content-page.js +43 -0
  108. package/dist/styled-system/recipes/create-recipe.js +82 -0
  109. package/dist/styled-system/recipes/index.d.ts +17 -0
  110. package/dist/styled-system/recipes/index.js +16 -0
  111. package/dist/styled-system/recipes/metric-block.d.ts +34 -0
  112. package/dist/styled-system/recipes/metric-block.js +76 -0
  113. package/dist/styled-system/recipes/product-list.d.ts +31 -0
  114. package/dist/styled-system/recipes/product-list.js +73 -0
  115. package/dist/styled-system/recipes/product-section.d.ts +31 -0
  116. package/dist/styled-system/recipes/product-section.js +49 -0
  117. package/dist/styled-system/recipes/product-settings-row.d.ts +34 -0
  118. package/dist/styled-system/recipes/product-settings-row.js +58 -0
  119. package/dist/styled-system/recipes/product-settings.d.ts +31 -0
  120. package/dist/styled-system/recipes/product-settings.js +57 -0
  121. package/dist/styled-system/recipes/product-status.d.ts +34 -0
  122. package/dist/styled-system/recipes/product-status.js +45 -0
  123. package/dist/styled-system/recipes/product-toolbar.d.ts +31 -0
  124. package/dist/styled-system/recipes/product-toolbar.js +41 -0
  125. package/dist/styled-system/recipes/product-workspace.d.ts +34 -0
  126. package/dist/styled-system/recipes/product-workspace.js +58 -0
  127. package/dist/styled-system/recipes/surface-metric.d.ts +38 -0
  128. package/dist/styled-system/recipes/surface-metric.js +63 -0
  129. package/dist/styled-system/recipes/surface-table.d.ts +34 -0
  130. package/dist/styled-system/recipes/surface-table.js +62 -0
  131. package/dist/styled-system/recipes/ui-badge.d.ts +31 -0
  132. package/dist/styled-system/recipes/ui-badge.js +38 -0
  133. package/dist/styled-system/recipes/ui-button.d.ts +32 -0
  134. package/dist/styled-system/recipes/ui-button.js +43 -0
  135. package/dist/styled-system/recipes/ui-input.d.ts +31 -0
  136. package/dist/styled-system/recipes/ui-input.js +49 -0
  137. package/dist/styled-system/recipes/ui-textarea.d.ts +31 -0
  138. package/dist/styled-system/recipes/ui-textarea.js +24 -0
  139. package/dist/styled-system/styles.css +1257 -0
  140. package/dist/styled-system/tokens/index.d.ts +9 -0
  141. package/dist/styled-system/tokens/index.js +268 -0
  142. package/dist/styled-system/tokens/tokens.d.ts +36 -0
  143. package/dist/styled-system/types/composition.d.ts +227 -0
  144. package/dist/styled-system/types/conditions.d.ts +236 -0
  145. package/dist/styled-system/types/csstype.d.ts +22570 -0
  146. package/dist/styled-system/types/index.d.ts +6 -0
  147. package/dist/styled-system/types/parts.d.ts +8 -0
  148. package/dist/styled-system/types/pattern.d.ts +78 -0
  149. package/dist/styled-system/types/prop-type.d.ts +223 -0
  150. package/dist/styled-system/types/recipe.d.ts +181 -0
  151. package/dist/styled-system/types/selectors.d.ts +59 -0
  152. package/dist/styled-system/types/static-css.d.ts +56 -0
  153. package/dist/styled-system/types/style-props.d.ts +8088 -0
  154. package/dist/styled-system/types/system-types.d.ts +151 -0
  155. package/dist/styles/editor.css +124 -0
  156. package/dist/styles/editor.generated.d.ts +8 -0
  157. package/dist/styles/editor.generated.js +9 -0
  158. package/dist/styles.css +1262 -0
  159. package/dist/svar-catalog.d.ts +3 -0
  160. package/dist/svar-catalog.js +7 -0
  161. package/dist/svar-context.d.ts +9 -0
  162. package/dist/svar-context.js +1 -0
  163. package/dist/svar-schema.d.ts +21 -0
  164. package/dist/svar-schema.js +36 -0
  165. package/dist/svar.d.ts +4 -0
  166. package/dist/svar.js +3 -0
  167. package/dist/svelte.d.ts +4 -2
  168. package/dist/svelte.js +2 -1
  169. package/dist/types.d.ts +4 -0
  170. package/dist/validation.js +2 -102
  171. package/dist/wire.d.ts +13 -0
  172. package/dist/wire.js +30 -0
  173. package/dist/workflows/action-contracts.d.ts +7 -0
  174. package/dist/workflows/action-contracts.js +54 -0
  175. package/dist/workflows/catalog.d.ts +20 -0
  176. package/dist/workflows/catalog.js +50 -0
  177. package/dist/workflows/client.d.ts +45 -0
  178. package/dist/workflows/client.js +125 -0
  179. package/dist/workflows/context.d.ts +9 -0
  180. package/dist/workflows/context.js +5 -0
  181. package/dist/workflows/openui-guard.d.ts +19 -0
  182. package/dist/workflows/openui-guard.js +209 -0
  183. package/dist/workflows/service.d.ts +58 -0
  184. package/dist/workflows/service.js +296 -0
  185. package/dist/workflows/sqlite-store.d.ts +20 -0
  186. package/dist/workflows/sqlite-store.js +91 -0
  187. package/dist/workflows/types.d.ts +103 -0
  188. package/dist/workflows/types.js +8 -0
  189. package/dist/workflows.d.ts +5 -0
  190. package/dist/workflows.js +4 -0
  191. package/package.json +52 -8
@@ -0,0 +1,103 @@
1
+ import type { TSchema } from '@sinclair/typebox';
2
+ import type { JsonObject, JsonValue, SurfaceCatalog, SurfacePolicy, SurfaceSpec } from '../types.js';
3
+ /** Identity comes from authenticated server middleware, never from model JSON. */
4
+ export interface SurfaceWorkflowContext {
5
+ readonly tenantId: string;
6
+ readonly actorId: string;
7
+ }
8
+ export type SurfaceApprovalPolicy = 'confirm' | 'four-eyes';
9
+ export type SurfaceActionPhase = 'propose' | 'approve' | 'reject' | 'execute' | 'read';
10
+ export interface SurfaceActionDescriptor {
11
+ readonly id: string;
12
+ readonly version: string;
13
+ readonly label: string;
14
+ readonly inputSchema: TSchema;
15
+ readonly approval: SurfaceApprovalPolicy;
16
+ }
17
+ export interface SurfaceRegisteredAction extends SurfaceActionDescriptor {
18
+ readonly validateInput: (value: unknown) => boolean;
19
+ readonly authorize: (request: {
20
+ context: SurfaceWorkflowContext;
21
+ phase: SurfaceActionPhase;
22
+ args: JsonObject;
23
+ requesterId: string;
24
+ }) => boolean | Promise<boolean>;
25
+ /** Reauthorize in the business backend too. Forward idempotencyKey to it.
26
+ * The workflow cannot promise exactly-once effects across an external service.
27
+ */
28
+ readonly execute: (request: {
29
+ context: SurfaceWorkflowContext;
30
+ args: JsonObject;
31
+ idempotencyKey: string;
32
+ }) => JsonValue | Promise<JsonValue>;
33
+ }
34
+ export interface SurfaceStoredRevision {
35
+ readonly tenantId: string;
36
+ readonly surfaceId: string;
37
+ readonly revision: number;
38
+ readonly spec: SurfaceSpec;
39
+ readonly actorId: string;
40
+ readonly createdAt: number;
41
+ }
42
+ export type SurfaceActionStatus = 'pending' | 'approved' | 'executing' | 'succeeded' | 'indeterminate' | 'rejected';
43
+ export interface SurfaceActionProposal {
44
+ readonly id: string;
45
+ readonly tenantId: string;
46
+ readonly requesterId: string;
47
+ readonly requestKey: string;
48
+ readonly surfaceId: string;
49
+ readonly surfaceRevision: number;
50
+ readonly actionId: string;
51
+ readonly actionVersion: string;
52
+ readonly actionLabel: string;
53
+ readonly args: JsonObject;
54
+ readonly digest: string;
55
+ readonly approval: SurfaceApprovalPolicy;
56
+ readonly status: SurfaceActionStatus;
57
+ readonly createdAt: number;
58
+ readonly expiresAt: number;
59
+ readonly approvedBy?: string;
60
+ readonly result?: JsonValue;
61
+ }
62
+ export interface SurfaceWorkflowAuditEvent {
63
+ readonly sequence?: number;
64
+ readonly tenantId: string;
65
+ readonly surfaceId: string;
66
+ readonly proposalId?: string;
67
+ readonly actorId: string;
68
+ readonly event: string;
69
+ readonly at: number;
70
+ readonly metadata: JsonObject;
71
+ }
72
+ export interface SurfaceWorkflowTransaction {
73
+ getRevision(tenantId: string, surfaceId: string, revision?: number): SurfaceStoredRevision | undefined;
74
+ putRevision(revision: SurfaceStoredRevision): void;
75
+ getProposal(tenantId: string, id: string): SurfaceActionProposal | undefined;
76
+ findRequest(tenantId: string, requesterId: string, requestKey: string): SurfaceActionProposal | undefined;
77
+ putProposal(proposal: SurfaceActionProposal): void;
78
+ audit(event: SurfaceWorkflowAuditEvent): void;
79
+ }
80
+ export interface SurfaceWorkflowStore extends SurfaceWorkflowTransaction {
81
+ /** Synchronous atomic transaction. Must roll back on exceptions; no await. */
82
+ transaction<T>(work: (tx: SurfaceWorkflowTransaction) => T): T;
83
+ listAudit(tenantId: string, surfaceId: string, after: number, limit: number): readonly SurfaceWorkflowAuditEvent[];
84
+ }
85
+ export interface SurfaceWorkflowAccess {
86
+ readonly catalog: SurfaceCatalog;
87
+ readonly policy: SurfacePolicy;
88
+ }
89
+ export interface SurfaceWorkflowOptions {
90
+ readonly store: SurfaceWorkflowStore;
91
+ readonly actions: readonly SurfaceRegisteredAction[];
92
+ readonly authorizeSurface: (request: {
93
+ context: SurfaceWorkflowContext;
94
+ operation: 'read' | 'save' | 'audit';
95
+ surfaceId: string;
96
+ }) => SurfaceWorkflowAccess | null | Promise<SurfaceWorkflowAccess | null>;
97
+ readonly now?: () => number;
98
+ readonly proposalLifetimeMs?: number;
99
+ }
100
+ export declare class SurfaceWorkflowError extends Error {
101
+ readonly code: 'denied' | 'invalid_input' | 'conflict' | 'not_found' | 'expired' | 'invalid_state' | 'indeterminate';
102
+ constructor(code: 'denied' | 'invalid_input' | 'conflict' | 'not_found' | 'expired' | 'invalid_state' | 'indeterminate', message?: string);
103
+ }
@@ -0,0 +1,8 @@
1
+ export class SurfaceWorkflowError extends Error {
2
+ code;
3
+ constructor(code, message = code) {
4
+ super(message);
5
+ this.code = code;
6
+ this.name = 'SurfaceWorkflowError';
7
+ }
8
+ }
@@ -0,0 +1,5 @@
1
+ export { createInteractiveSurfaceDefinitions, withSurfaceAppearance, surfaceAppearanceSchema } from './workflows/catalog.js';
2
+ export { createSurfaceFormController } from './workflows/client.js';
3
+ export type { SurfaceWorkflowTransport, SurfaceWorkflowClientScope, SurfaceWorkflowClientState } from './workflows/client.js';
4
+ export type { SurfaceActionDescriptor, SurfaceActionProposal, SurfaceApprovalPolicy } from './workflows/types.js';
5
+ export { defaultSurfaceDefinitions, styledSurfaceDefinitions } from './builtin-definitions.js';
@@ -0,0 +1,4 @@
1
+ // DOM-free contracts: no server implementation or Svelte components in this entry.
2
+ export { createInteractiveSurfaceDefinitions, withSurfaceAppearance, surfaceAppearanceSchema } from './workflows/catalog.js';
3
+ export { createSurfaceFormController } from './workflows/client.js';
4
+ export { defaultSurfaceDefinitions, styledSurfaceDefinitions } from './builtin-definitions.js';
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@svadmin/surface",
3
- "version": "0.8.19",
3
+ "version": "0.9.0",
4
4
  "description": "Validated declarative surfaces for svadmin dashboards",
5
5
  "type": "module",
6
- "sideEffects": false,
6
+ "sideEffects": [
7
+ "./dist/styles.css",
8
+ "./dist/styles/editor.css"
9
+ ],
7
10
  "files": [
8
11
  "dist",
9
12
  "README.md",
10
13
  "compatibility.json",
11
14
  "!dist/**/*.test.*",
12
- "!dist/**/*.spec.*"
15
+ "!dist/**/*.test-*",
16
+ "!dist/**/*.spec.*",
17
+ "!dist/**/*.spec-*",
18
+ "STYLING.md"
13
19
  ],
14
20
  "main": "dist/index.js",
15
21
  "types": "dist/index.d.ts",
@@ -22,28 +28,66 @@
22
28
  "types": "./dist/svelte.d.ts",
23
29
  "svelte": "./dist/svelte.js",
24
30
  "default": "./dist/svelte.js"
31
+ },
32
+ "./styles.css": {
33
+ "style": "./dist/styles.css",
34
+ "default": "./dist/styles.css"
35
+ },
36
+ "./editor.css": {
37
+ "style": "./dist/styles/editor.css",
38
+ "default": "./dist/styles/editor.css"
39
+ },
40
+ "./svar": {
41
+ "types": "./dist/svar.d.ts",
42
+ "svelte": "./dist/svar.js",
43
+ "default": "./dist/svar.js"
44
+ },
45
+ "./workflows": {
46
+ "types": "./dist/workflows.d.ts",
47
+ "default": "./dist/workflows.js"
48
+ },
49
+ "./interactive": {
50
+ "types": "./dist/interactive.d.ts",
51
+ "svelte": "./dist/interactive.js",
52
+ "default": "./dist/interactive.js"
53
+ },
54
+ "./openui": {
55
+ "types": "./dist/openui.d.ts",
56
+ "default": "./dist/openui.js"
57
+ },
58
+ "./server": {
59
+ "types": "./dist/server.d.ts",
60
+ "node": "./dist/server.js"
61
+ },
62
+ "./server/sqlite": {
63
+ "types": "./dist/server-sqlite.d.ts",
64
+ "node": "./dist/server-sqlite.js"
25
65
  }
26
66
  },
27
67
  "peerDependencies": {
28
- "@svadmin/core": ">=0.34.2 <0.53.0",
29
- "@svadmin/ui": ">=0.40.6 <0.73.0",
68
+ "@svadmin/core": ">=0.34.2 <0.54.0",
69
+ "@svadmin/ui": ">=0.40.6 <0.74.0",
30
70
  "svelte": "^5.56.8"
31
71
  },
32
72
  "dependencies": {
33
73
  "@sinclair/typebox": "^0.34.52"
34
74
  },
35
75
  "devDependencies": {
76
+ "@pandacss/dev": "1.12.1",
36
77
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
37
78
  "@testing-library/dom": "^10.4.1",
38
79
  "@testing-library/svelte": "^5.4.2",
39
80
  "@testing-library/user-event": "^14.6.6",
40
81
  "happy-dom": "^20.11.12",
82
+ "postcss": "^8.5.26",
41
83
  "vitest": "^4.1.11"
42
84
  },
43
85
  "scripts": {
44
- "build": "node ../../node_modules/@sveltejs/package/svelte-package.js -i src -o dist",
45
- "check": "svelte-check --tsgo-experimental-api --tsconfig ./tsconfig.json --threshold error",
46
- "test": "vitest run --config ./vitest.config.ts"
86
+ "build": "node scripts/build-editor-styles.mjs && node scripts/prepare-design.mjs && node ../../node_modules/@sveltejs/package/svelte-package.js -i src -o dist",
87
+ "check": "svelte-check --tsgo-experimental-api --tsconfig ./tsconfig.check.json --threshold error",
88
+ "test": "vitest run --config ./vitest.config.ts",
89
+ "styles:build": "node scripts/build-editor-styles.mjs",
90
+ "styles:check": "node scripts/build-editor-styles.mjs --check"
47
91
  },
48
92
  "license": "MIT",
49
93
  "publishConfig": {