@grasp-labs/ds-microfrontends-integration 0.26.0 → 1.0.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 (47) hide show
  1. package/README.md +1 -1
  2. package/dist/components/index.d.ts +0 -1
  3. package/dist/components/language/translations/en.json.d.ts +9 -1
  4. package/dist/components/language/translations/no.json.d.ts +9 -1
  5. package/dist/components/schemaFields/ArrayField.d.ts +5 -0
  6. package/dist/components/schemaFields/BooleanField.d.ts +5 -0
  7. package/dist/components/schemaFields/ConditionalFields.d.ts +19 -0
  8. package/dist/components/schemaFields/DateField.d.ts +5 -0
  9. package/dist/components/schemaFields/DefaultFieldRenderer.d.ts +6 -0
  10. package/dist/components/schemaFields/DependentFields.d.ts +19 -0
  11. package/dist/components/schemaFields/DictionaryField/DictionaryEntry.d.ts +20 -0
  12. package/dist/components/schemaFields/DictionaryField/DictionaryField.d.ts +14 -0
  13. package/dist/components/schemaFields/DictionaryField/index.d.ts +1 -0
  14. package/dist/components/schemaFields/EnumField.d.ts +5 -0
  15. package/dist/components/schemaFields/FieldError.d.ts +5 -0
  16. package/dist/components/schemaFields/JsonField.d.ts +5 -0
  17. package/dist/components/schemaFields/NumberField.d.ts +5 -0
  18. package/dist/components/schemaFields/SchemaFields.d.ts +6 -0
  19. package/dist/components/schemaFields/SchemaFields.stories.d.ts +3 -5
  20. package/dist/components/schemaFields/TextField.d.ts +5 -0
  21. package/dist/components/schemaFields/TupleField.d.ts +13 -0
  22. package/dist/components/schemaFields/VariantField/VariantField.d.ts +14 -0
  23. package/dist/components/schemaFields/VariantField/index.d.ts +1 -0
  24. package/dist/components/schemaFields/VaultField.d.ts +5 -0
  25. package/dist/components/schemaFields/consts/schemas.d.ts +10 -0
  26. package/dist/components/schemaFields/index.d.ts +1 -0
  27. package/dist/components/schemaFields/shared/EntryValueRenderer.d.ts +16 -0
  28. package/dist/components/schemaFields/shared/dictionaryHandlers.d.ts +5 -0
  29. package/dist/{index-oWl7bj7h.js → index-B6ZY0zb9.js} +8131 -6737
  30. package/dist/{index.esm-fQDYRCEr-Cx-fegXB.js → index.esm-fQDYRCEr-DmkkBbtV.js} +1 -1
  31. package/dist/index.js +49 -39
  32. package/dist/lib/schema/conditional.d.ts +2 -0
  33. package/dist/lib/schema/index.d.ts +2 -1
  34. package/dist/lib/schema/inspector.d.ts +26 -0
  35. package/dist/lib/schema/resolver.d.ts +4 -0
  36. package/dist/lib/schema/schemaResolver/schemaResolver.d.ts +1 -2
  37. package/dist/lib/schema/schemaResolver/utils.d.ts +27 -4
  38. package/dist/lib/schema/types.d.ts +5 -1
  39. package/dist/types/Navigation.d.ts +0 -2
  40. package/dist/types/Schema.d.ts +2 -2
  41. package/dist/types/customErrorHandler.d.ts +13 -3
  42. package/dist/types/index.d.ts +0 -1
  43. package/package.json +7 -5
  44. package/dist/components/user/UserProvider.d.ts +0 -37
  45. package/dist/components/user/UserProvider.stories.d.ts +0 -16
  46. package/dist/components/user/index.d.ts +0 -1
  47. package/dist/types/User.d.ts +0 -5
@@ -1,4 +1,4 @@
1
- import { O as o } from "./index-oWl7bj7h.js";
1
+ import { O as o } from "./index-B6ZY0zb9.js";
2
2
  import { useState as J, useEffect as De, createContext as Zt, useRef as ce, useContext as Gt, useMemo as le, useCallback as Re } from "react";
3
3
  const $e = (e, t, n, r, a) => {
4
4
  if (!r) throw new Error(a ?? `Invalid property path: ${t}
package/dist/index.js CHANGED
@@ -1,45 +1,55 @@
1
- import { A as s, B as r, D as l, c as t, E as i, F as u, a as d, G as o, J as n, L as F, N as g, S as c, T as m, d as p, U as v, V, j as h, k as D, h as P, l as S, x as f, z as b, I as x, n as y, o as G, m as T, p as E, y as I, q as L, g as N, H as R, s as A, t as U, v as j, w as B, C, r as H, u as J, b as O, e as k, f as q, i as w } from "./index-oWl7bj7h.js";
1
+ import { A as s, B as t, D as i, c as r, d as l, E as o, F as d, a as u, G as n, J as c, L as F, N as g, S as m, T as p, e as h, V as P, j as D, k as S, h as f, l as v, R as y, X as V, _ as x, n as b, W as T, o as A, p as G, m as L, q as O, K as R, s as E, t as I, U as N, v as C, g as j, w as B, Z as H, x as J, M as W, y as k, z as q, C as w, H as z, P as K, I as M, Q, Y as U, r as X, u as Y, b as Z, f as _, i as $ } from "./index-B6ZY0zb9.js";
2
2
  export {
3
3
  s as ArrayField,
4
- r as BooleanField,
5
- l as DateField,
6
- t as DefaultFieldRenderer,
7
- i as EnumField,
8
- u as FieldError,
9
- d as GroupGuard,
10
- o as GroupsProvider,
11
- n as JsonField,
4
+ t as BooleanField,
5
+ i as DateField,
6
+ r as DefaultFieldRenderer,
7
+ l as DictionaryField,
8
+ o as EnumField,
9
+ d as FieldError,
10
+ u as GroupGuard,
11
+ n as GroupsProvider,
12
+ c as JsonField,
12
13
  F as LanguageProvider,
13
14
  g as NumberField,
14
- c as SchemaFields,
15
- m as TextField,
16
- p as ToastProvider,
17
- v as UserProvider,
18
- V as VaultField,
19
- h as VaultInput,
20
- D as VaultInputField,
21
- P as VaultProvider,
22
- S as VaultSecretDialog,
23
- f as buildDefaultValues,
24
- b as createFieldDescriptor,
15
+ m as SchemaFields,
16
+ p as TextField,
17
+ h as ToastProvider,
18
+ P as VaultField,
19
+ D as VaultInput,
20
+ S as VaultInputField,
21
+ f as VaultProvider,
22
+ v as VaultSecretDialog,
23
+ y as buildDefaultValues,
24
+ V as createFieldDescriptor,
25
25
  x as createRuleHandler,
26
- y as defineNavigation,
27
- G as extractConstraints,
28
- T as extractPaths,
29
- E as getArrayItemsSchema,
30
- I as getDefaultValue,
31
- L as getFieldType,
32
- N as getLanguage,
33
- R as getSchemaResolver,
34
- A as isEnumField,
35
- U as isNullable,
36
- j as isObjectWithoutProperties,
37
- B as isReadOnly,
38
- C as parseSchemaFields,
39
- H as resolveSchema,
40
- J as useGroups,
41
- O as useLanguage,
42
- k as useToast,
43
- q as useUser,
44
- w as useVault
26
+ b as defineNavigation,
27
+ T as evaluateCondition,
28
+ A as extractConstraints,
29
+ G as extractDescription,
30
+ L as extractPaths,
31
+ O as extractPlaceholder,
32
+ R as formatLabel,
33
+ E as getAdditionalPropertiesSchema,
34
+ I as getArrayItemsSchema,
35
+ N as getDefaultValue,
36
+ C as getFieldType,
37
+ j as getLanguage,
38
+ B as getPatternPropertiesSchemas,
39
+ H as getSchemaResolver,
40
+ J as getTupleSchemas,
41
+ W as isAnyOfField,
42
+ k as isDictionary,
43
+ q as isEnumField,
44
+ w as isNullable,
45
+ z as isObjectWithoutProperties,
46
+ K as isOneOfField,
47
+ M as isPatternDictionary,
48
+ Q as isReadOnly,
49
+ U as parseSchemaFields,
50
+ X as resolveSchema,
51
+ Y as useGroups,
52
+ Z as useLanguage,
53
+ _ as useToast,
54
+ $ as useVault
45
55
  };
@@ -0,0 +1,2 @@
1
+ import { Schema } from 'src/types/Schema';
2
+ export declare function evaluateCondition(ifSchema: Schema, values: unknown): boolean;
@@ -1,6 +1,7 @@
1
1
  export type { Constraints, FieldDescriptor, FieldType } from './types';
2
2
  export { resolveSchema } from './resolver';
3
- export { extractConstraints, getArrayItemsSchema, getFieldType, isEnumField, isNullable, isObjectWithoutProperties, isReadOnly, } from './inspector';
3
+ export { extractConstraints, extractDescription, extractPlaceholder, getAdditionalPropertiesSchema, getArrayItemsSchema, getFieldType, getPatternPropertiesSchemas, getTupleSchemas, isDictionary, isEnumField, isNullable, isObjectWithoutProperties, isPatternDictionary, formatLabel, isAnyOfField, isOneOfField, isReadOnly, } from './inspector';
4
4
  export { buildDefaultValues, getDefaultValue } from './defaults';
5
+ export { evaluateCondition } from './conditional';
5
6
  export { createFieldDescriptor, parseSchemaFields } from './descriptor';
6
7
  export { getSchemaResolver, createRuleHandler } from './schemaResolver';
@@ -1,10 +1,36 @@
1
1
  import { Schema } from 'src/types/Schema';
2
2
  import { Constraints, FieldType } from './types';
3
+ /** Returns true if the schema defines a non-empty enum. */
3
4
  export declare function isEnumField(schema: Schema): boolean;
5
+ /** Returns true if the field is read-only (const or readOnly). */
4
6
  export declare function isReadOnly(schema: Schema): boolean;
7
+ /** Returns true if the schema allows null (nullable, type includes "null", or enum contains null). */
5
8
  export declare function isNullable(schema: Schema): boolean;
9
+ /** Returns true for object schemas with no defined properties (dictionary-like). */
6
10
  export declare function isObjectWithoutProperties(schema: Schema): boolean;
11
+ /** Returns true for object schemas with patternProperties and no fixed properties. */
12
+ export declare function isPatternDictionary(schema: Schema): boolean;
13
+ /** Extracts pattern → schema map from patternProperties. Returns null if not a pattern dictionary. */
14
+ export declare function getPatternPropertiesSchemas(schema: Schema): Record<string, Schema> | null;
15
+ /** Returns true for object schemas with additionalProperties schema and no fixed properties. */
16
+ export declare function isDictionary(schema: Schema): boolean;
17
+ /** Returns the additionalProperties schema for dictionary-type schemas. */
18
+ export declare function getAdditionalPropertiesSchema(schema: Schema): Schema | null;
19
+ /** Returns true if the schema has a non-empty oneOf composition. */
20
+ export declare function isOneOfField(schema: Schema): boolean;
21
+ /** Returns true if the schema has a non-empty anyOf composition. */
22
+ export declare function isAnyOfField(schema: Schema): boolean;
23
+ /** Determines the FieldType for a schema (e.g., "string", "enum", "tuple", "dictionary"). */
7
24
  export declare function getFieldType(schema: Schema): FieldType;
25
+ /** Returns per-position schemas from prefixItems or array items. Null if not a tuple. */
26
+ export declare function getTupleSchemas(schema: Schema): Schema[] | null;
27
+ /** Returns the single items schema for homogeneous arrays. Null for tuples or boolean items. */
8
28
  export declare function getArrayItemsSchema(schema: Schema): Schema | null;
29
+ /** Converts a snake_case key to a Title Case label. */
9
30
  export declare function formatLabel(key: string): string;
31
+ /** Extracts validation constraints (min, max, pattern, format, etc.) from a schema. */
10
32
  export declare function extractConstraints(schema: Schema): Constraints;
33
+ /** Returns the schema description if it's a string. */
34
+ export declare function extractDescription(schema: Schema): string | undefined;
35
+ /** Returns the first example value as a placeholder string. */
36
+ export declare function extractPlaceholder(schema: Schema): string | undefined;
@@ -1,2 +1,6 @@
1
1
  import { Schema } from 'src/types/Schema';
2
+ /**
3
+ * Recursively resolves $ref, allOf, oneOf, anyOf, if/then/else, and type-specific
4
+ * sub-schemas. Tracks visited refs to prevent circular resolution.
5
+ */
2
6
  export declare function resolveSchema(schema: Schema, rootSchema: Schema, visited?: Set<string>): Schema;
@@ -1,4 +1,3 @@
1
1
  import { FieldValues, Resolver } from 'react-hook-form';
2
2
  import { CustomErrorHandler } from 'src/types';
3
- import { z } from 'zod';
4
- export declare const getSchemaResolver: <T extends FieldValues = FieldValues>(schema?: z.core.JSONSchema.JSONSchema, errorHandler?: CustomErrorHandler) => Resolver<T> | undefined;
3
+ export declare const getSchemaResolver: <T extends FieldValues = FieldValues>(schema?: object, errorHandler?: CustomErrorHandler) => Resolver<T> | undefined;
@@ -1,10 +1,33 @@
1
1
  import { FieldValues, Path } from 'react-hook-form';
2
- import { CustomErrorHandler, ZodIssue } from 'src/types';
2
+ import { AjvIssue, CustomErrorHandler } from 'src/types';
3
+ /**
4
+ * AJV error keywords that correspond to validation rules.
5
+ * Common keywords: type, required, minLength, maxLength, minimum, maximum,
6
+ * pattern, format, enum, const, if, then, else, anyOf, oneOf, allOf, not
7
+ */
8
+ export type AjvKeyword = AjvIssue["keyword"];
3
9
  export type Rule<TFieldValues extends FieldValues = FieldValues> = {
10
+ /** Field path to match (e.g., "profile.firstName" or "users.0.email") */
4
11
  path?: Path<TFieldValues>;
5
- code?: ZodIssue["code"];
6
- when?: (issue: ZodIssue) => boolean;
7
- message: string | ((issue: ZodIssue) => string);
12
+ /** AJV keyword to match (e.g., "required", "minLength", "format") */
13
+ keyword?: AjvKeyword;
14
+ /** Custom predicate for advanced matching */
15
+ when?: (issue: AjvIssue) => boolean;
16
+ /** Error message - static string or function receiving the issue */
17
+ message: string | ((issue: AjvIssue) => string);
8
18
  };
19
+ /**
20
+ * Gets the full field path from an AJV error.
21
+ * Handles special cases like "required" where the field is in params.
22
+ */
23
+ export declare const getFieldPath: (issue: AjvIssue) => string;
9
24
  export declare const createRuleHandler: <TFieldValues extends FieldValues = FieldValues>(rules: Rule<TFieldValues>[]) => CustomErrorHandler;
10
25
  export declare const convertDatesToStringForValidation: (value: unknown) => unknown;
26
+ /**
27
+ * Sets a nested error on a FieldErrors object.
28
+ * Supports dot notation paths like "address.city" or "users.0.email"
29
+ */
30
+ export declare const setNestedError: (obj: Record<string, unknown>, path: string, error: {
31
+ type: string;
32
+ message: string;
33
+ }) => void;
@@ -1,9 +1,11 @@
1
1
  import { Schema } from 'src/types/Schema';
2
- export declare const FIELD_TYPES: readonly ["string", "number", "integer", "boolean", "object", "object-string", "array", "enum", "const", "null", "unknown"];
2
+ export declare const FIELD_TYPES: readonly ["string", "number", "integer", "boolean", "object", "object-string", "dictionary", "pattern-dictionary", "array", "tuple", "enum", "const", "null", "oneOf", "unknown"];
3
3
  export type FieldType = (typeof FIELD_TYPES)[number];
4
4
  export type Constraints = {
5
5
  minimum?: number;
6
6
  maximum?: number;
7
+ exclusiveMinimum?: number;
8
+ exclusiveMaximum?: number;
7
9
  minLength?: number;
8
10
  maxLength?: number;
9
11
  multipleOf?: number;
@@ -21,6 +23,8 @@ export type FieldDescriptor<TFieldName extends string = string> = {
21
23
  schema: Schema;
22
24
  type: FieldType;
23
25
  label: string;
26
+ description?: string;
27
+ placeholder?: string;
24
28
  isDisabled: boolean;
25
29
  required: boolean;
26
30
  constraints: Constraints;
@@ -13,8 +13,6 @@ export type BaseItem = {
13
13
  /**
14
14
  * Groups required to access this navigation item.
15
15
  * When specified, the item should only be visible to users with all of the listed groups.
16
- * Supports glob patterns with wildcard (*) matching exactly one segment,
17
- * e.g. "service.store.*" matches "service.store.admin" but not "service.store.admin.extra".
18
16
  */
19
17
  requiredGroups?: string[];
20
18
  };
@@ -1,6 +1,6 @@
1
- import { z } from 'zod';
1
+ import { SchemaObject } from 'ajv';
2
2
  /**
3
3
  * JSON Schema type for validation.
4
4
  * Represents a schema for validating objects with unknown properties.
5
5
  */
6
- export type Schema = z.core.JSONSchema.JSONSchema;
6
+ export type Schema = SchemaObject;
@@ -1,3 +1,13 @@
1
- import { default as z } from 'zod';
2
- export type ZodIssue = z.core.$ZodIssue;
3
- export type CustomErrorHandler = (issue: ZodIssue) => string | undefined;
1
+ import { ErrorObject } from 'ajv';
2
+ /**
3
+ * AJV error object with permissive params type to handle all keyword-specific params.
4
+ * Common params include:
5
+ * - required: { missingProperty: string }
6
+ * - minLength/maxLength: { limit: number }
7
+ * - minimum/maximum: { limit: number, comparison: string }
8
+ * - pattern: { pattern: string }
9
+ * - format: { format: string }
10
+ * - enum: { allowedValues: any[] }
11
+ */
12
+ export type AjvIssue = ErrorObject<string, Record<string, unknown>, unknown>;
13
+ export type CustomErrorHandler = (issue: AjvIssue) => string | undefined;
@@ -4,4 +4,3 @@ export * from './Vault';
4
4
  export * from './Groups';
5
5
  export * from './Navigation';
6
6
  export * from './customErrorHandler';
7
- export * from './User';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grasp-labs/ds-microfrontends-integration",
3
- "version": "0.26.0",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -46,12 +46,13 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@module-federation/vite": "^1.0.0",
49
+ "ajv": "^8.17.0",
50
+ "ajv-formats": "^3.0.1",
49
51
  "express": "^5.0.0",
50
52
  "react": "19.2.3",
51
53
  "react-dom": "19.2.3",
52
54
  "react-hook-form": "^7.0.0",
53
- "react-router": "7.12.0",
54
- "zod": "4.2.1"
55
+ "react-router": "7.12.0"
55
56
  },
56
57
  "peerDependenciesMeta": {
57
58
  "express": {
@@ -60,6 +61,8 @@
60
61
  },
61
62
  "devDependencies": {
62
63
  "@eslint/js": "^9.32.0",
64
+ "ajv": "^8.17.1",
65
+ "ajv-formats": "^3.0.1",
63
66
  "@grasp-labs/ds-react-components": "^0.23.0",
64
67
  "@hookform/resolvers": "^5.2.2",
65
68
  "@module-federation/vite": "1.9.4",
@@ -100,7 +103,6 @@
100
103
  "vite": "^7.0.6",
101
104
  "vite-plugin-dts": "^4.5.4",
102
105
  "vite-tsconfig-paths": "^6.0.3",
103
- "vitest": "^4.0.16",
104
- "zod": "4.2.1"
106
+ "vitest": "^4.0.16"
105
107
  }
106
108
  }
@@ -1,37 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { User } from '../../types';
3
- export type UserContextValue = {
4
- user: User | null;
5
- isAuthenticated: boolean;
6
- };
7
- export type UserProviderProps = {
8
- children: ReactNode;
9
- user: User | null;
10
- };
11
- /**
12
- * Provides user context to child components.
13
- *
14
- * @example
15
- * ```tsx
16
- * <UserProvider user={user}>
17
- * <App />
18
- * </UserProvider>
19
- * ```
20
- */
21
- export declare const UserProvider: ({ children, user }: UserProviderProps) => import("react/jsx-runtime").JSX.Element;
22
- /**
23
- * Hook to access user context.
24
- *
25
- * @returns The user context with user data and authentication status.
26
- * @throws Error if used outside of UserProvider.
27
- *
28
- * @example
29
- * ```tsx
30
- * const { user, isAuthenticated } = useUser();
31
- *
32
- * if (isAuthenticated) {
33
- * console.log(user.name);
34
- * }
35
- * ```
36
- */
37
- export declare const useUser: () => UserContextValue;
@@ -1,16 +0,0 @@
1
- import { StoryObj } from '@storybook/react-vite';
2
- declare const meta: {
3
- title: string;
4
- component: ({ children, user }: import('./UserProvider').UserProviderProps) => import("react/jsx-runtime").JSX.Element;
5
- parameters: {
6
- layout: string;
7
- };
8
- tags: string[];
9
- };
10
- export default meta;
11
- type Story = StoryObj<typeof meta>;
12
- export declare const Authenticated: Story;
13
- export declare const Unauthenticated: Story;
14
- export declare const PartialUserData: Story;
15
- export declare const WithCustomFields: Story;
16
- export declare const LogoutTriggersEffect: StoryObj;
@@ -1 +0,0 @@
1
- export * from './UserProvider';
@@ -1,5 +0,0 @@
1
- export type User = {
2
- id?: string;
3
- name?: string;
4
- [key: string]: unknown;
5
- };