@20baht/validator 0.1.0 → 0.1.1

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/dist/common.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type FieldDescriptor, type FormDefinition, type Locale, type NestedData, type WorkflowDefinition } from '@20baht/engine';
1
+ import { type FieldDescriptor, type FormDefinition, type NestedData, type WorkflowDefinition } from '@20baht/engine';
2
2
  export type SchemaDefinition = FormDefinition | WorkflowDefinition;
3
3
  /** One violation. `ref` is the field key for forms, `form_name.key` for workflows. */
4
4
  export interface ValidationIssue {
@@ -40,13 +40,8 @@ export interface ValidationResult {
40
40
  */
41
41
  data: Record<string, unknown> | NestedData;
42
42
  }
43
- /**
44
- * Run `fn` with the catalog switched to `locale`, restoring the previous
45
- * catalog after. The engine catalog is module-global; validation is fully
46
- * synchronous, so scoping the switch this way is race-free even on a server
47
- * interleaving requests with different locales.
48
- */
49
- export declare function withLocale<T>(locale: Locale | undefined, fn: () => T): T;
43
+ /** `fn` in `locale`'s catalog, the previous one put back after: the engine's, shared with the form session. */
44
+ export { withLocale } from '@20baht/engine';
50
45
  /** Static blocks (`label`, `section`): no value, never in the payload, never validated. */
51
46
  export declare function isStatic(field: FieldDescriptor): boolean;
52
47
  export declare function isWorkflowDefinition(schema: unknown): schema is WorkflowDefinition;
package/dist/common.js CHANGED
@@ -1,22 +1,6 @@
1
- import { getCatalog, setCatalog, setLocale, } from '@20baht/engine';
2
- /**
3
- * Run `fn` with the catalog switched to `locale`, restoring the previous
4
- * catalog after. The engine catalog is module-global; validation is fully
5
- * synchronous, so scoping the switch this way is race-free even on a server
6
- * interleaving requests with different locales.
7
- */
8
- export function withLocale(locale, fn) {
9
- if (locale === undefined)
10
- return fn();
11
- const prev = getCatalog();
12
- setLocale(locale);
13
- try {
14
- return fn();
15
- }
16
- finally {
17
- setCatalog(prev);
18
- }
19
- }
1
+ import {} from '@20baht/engine';
2
+ /** `fn` in `locale`'s catalog, the previous one put back after: the engine's, shared with the form session. */
3
+ export { withLocale } from '@20baht/engine';
20
4
  /** Static blocks (`label`, `section`): no value, never in the payload, never validated. */
21
5
  export function isStatic(field) {
22
6
  return field.type === 'label' || field.type === 'section';
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@20baht/validator",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
+ "engines": {
6
+ "node": ">=20.19.0"
7
+ },
5
8
  "description": "Runtime validation for bahtui form/workflow JSON — the exact engine rules the client runs, on the server.",
6
9
  "license": "MIT",
7
10
  "author": "Nattapong Promthong",