@shing.wong/sure-factor 0.2.1 → 0.3.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/README.md CHANGED
@@ -79,6 +79,17 @@ const output = generateForTier(schema, { tier: 'production', component: 'form' }
79
79
  2. **Match** — Match each column to catalog type definitions using name patterns + data type rules → `TypeMatchResult` with confidence scoring
80
80
  3. **Generate** — Produce tier-aware output: routes, templates, i18n, sanitization pipeline, validation rules, theme CSS, and sure-state stores
81
81
 
82
+ ## Installation
83
+
84
+ ```bash
85
+ npm install @shing.wong/sure-factor
86
+ ```
87
+
88
+ No peer dependencies. `pg` and `prettier` are regular dependencies, so live
89
+ schema introspection and code formatting work without extra setup.
90
+
91
+ Requires Node >= 20.
92
+
82
93
  ## Quick Start
83
94
 
84
95
  ```ts
@@ -29,8 +29,6 @@ behavior:
29
29
  successChime: false
30
30
  voiceHelp: false
31
31
  autoFocus: true
32
- scripts:
33
- - auth-handler.js
34
32
  cssClasses:
35
33
  form: sure-auth__form
36
34
  header: sure-auth__header
@@ -45,9 +45,7 @@ behavior:
45
45
  autoFocus: true
46
46
  confirmBeforeCancel: true
47
47
  scripts:
48
- - audio-feedback.js
49
48
  - voice-help.js
50
- - notification-handler.js
51
49
  cssClasses:
52
50
  form: sure-crud
53
51
  field: sure-crud__field
@@ -40,9 +40,7 @@ behavior:
40
40
  autoFocus: false
41
41
  confirmBeforeCancel: false
42
42
  scripts:
43
- - audio-feedback.js
44
43
  - voice-help.js
45
- - notification-handler.js
46
44
  cssClasses:
47
45
  form: sure-table
48
46
  field: sure-table__cell
@@ -50,5 +48,8 @@ cssClasses:
50
48
  error: sure-table__error
51
49
  help: sure-table__help
52
50
  label: sure-table__header
51
+ row: sure-table__row
52
+ cell: sure-table__cell
53
+ header: sure-table__header
53
54
  example:
54
55
  usage: Generate a sortable patient list table with columns for name, DOB, last visit, status, and assigned provider
@@ -35,8 +35,6 @@ behavior:
35
35
  successChime: false
36
36
  voiceHelp: false
37
37
  autoFocus: true
38
- scripts:
39
- - dialog-handler.js
40
38
  cssClasses:
41
39
  overlay: sure-dialog-overlay
42
40
  dialog: sure-dialog
@@ -37,9 +37,7 @@ behavior:
37
37
  autoFocus: true
38
38
  confirmBeforeCancel: true
39
39
  scripts:
40
- - audio-feedback.js
41
40
  - voice-help.js
42
- - notification-handler.js
43
41
  cssClasses:
44
42
  form: sure-modal__form
45
43
  field: sure-modal__field
@@ -33,9 +33,8 @@ behavior:
33
33
  autoFocus: true
34
34
  confirmBeforeCancel: false
35
35
  scripts:
36
- - audio-feedback.js
36
+ - error-bell.js
37
37
  - voice-help.js
38
- - notification-handler.js
39
38
  cssClasses:
40
39
  form: sure-form
41
40
  field: sure-form__field
@@ -43,5 +42,9 @@ cssClasses:
43
42
  error: sure-form__error
44
43
  help: sure-form__help
45
44
  label: sure-form__label
45
+ title: sure-form__title
46
+ actions: sure-form__actions
47
+ submit: btn-primary
48
+ cancel: btn-secondary
46
49
  example:
47
50
  usage: Generate a patient intake form with name, email, diagnosis, and ZIP code fields
@@ -17,8 +17,6 @@ behavior:
17
17
  errorBell: false
18
18
  successChime: false
19
19
  voiceHelp: false
20
- scripts:
21
- - markdown-renderer.js
22
20
  cssClasses:
23
21
  root: sure-markdown
24
22
  code: sure-markdown code
@@ -36,9 +36,7 @@ behavior:
36
36
  autoFocus: true
37
37
  confirmBeforeCancel: false
38
38
  scripts:
39
- - audio-feedback.js
40
39
  - voice-help.js
41
- - notification-handler.js
42
40
  cssClasses:
43
41
  form: sure-search
44
42
  field: sure-search__input
@@ -23,8 +23,6 @@ behavior:
23
23
  audio:
24
24
  errorBell: false
25
25
  successChime: false
26
- scripts:
27
- - session-handler.js
28
26
  cssClasses:
29
27
  list: sure-session-list
30
28
  item: sure-session-item
@@ -0,0 +1,55 @@
1
+ import type { SchemaInfo } from './introspect.js';
2
+ import type { CatalogComponent } from './types.js';
3
+ import type { GenerationTier } from './generate.js';
4
+ export interface ClientGenerateOptions {
5
+ tier: GenerationTier;
6
+ component: string;
7
+ /** Component export name, e.g. `UserCreateForm`. */
8
+ exportName: string;
9
+ }
10
+ export interface ClientFieldSpec {
11
+ name: string;
12
+ label: string;
13
+ help: string;
14
+ required: boolean;
15
+ control: 'text' | 'password' | 'select' | 'textarea';
16
+ type: string;
17
+ readOnly: boolean;
18
+ secret: boolean;
19
+ json: boolean;
20
+ validation: {
21
+ regex: string | null;
22
+ minLength: number | null;
23
+ maxLength: number | null;
24
+ };
25
+ hints: {
26
+ placeholder?: string;
27
+ help?: string;
28
+ error?: {
29
+ required?: string;
30
+ format?: string;
31
+ tooShort?: string;
32
+ tooLong?: string;
33
+ };
34
+ };
35
+ sanitize: string[];
36
+ source: {
37
+ table: string;
38
+ column: string;
39
+ } | null;
40
+ }
41
+ export interface ClientComponentOutput {
42
+ /** The ES module source. Parses and runs with no dependencies. */
43
+ module: string;
44
+ /** The field specs, so a server can serialise them straight to the client. */
45
+ fields: ClientFieldSpec[];
46
+ cssClasses: Record<string, string>;
47
+ }
48
+ /**
49
+ * Derive the field specs the client renderer consumes. Keyed by table+column
50
+ * for the same reason as the server target: a bare column name collides across
51
+ * tables and silently drops validation.
52
+ */
53
+ export declare function buildClientFields(schema: SchemaInfo, options: ClientGenerateOptions, component: CatalogComponent): ClientFieldSpec[];
54
+ export declare function generateClientComponent(schema: SchemaInfo, options: ClientGenerateOptions): ClientComponentOutput;
55
+ //# sourceMappingURL=generate-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-client.d.ts","sourceRoot":"","sources":["../src/generate-client.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAI/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAA;IACpB,SAAS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