@softwareproduction/nuxt-introspection-forms 0.1.0 → 0.2.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.
- package/README.md +19 -0
- package/dist/module.d.mts +5 -15
- package/dist/module.d.ts +5 -15
- package/dist/module.json +1 -1
- package/dist/module.mjs +20 -24
- package/dist/runtime/plugins/dryv.js +6 -0
- package/package.json +2 -2
- package/dist/runtime/plugins/introspection-forms.client.js +0 -11
- /package/dist/runtime/plugins/{introspection-forms.client.d.ts → dryv.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -297,6 +297,11 @@ async function submit() {
|
|
|
297
297
|
|
|
298
298
|
The component internally creates a Dryv validation session when rules are provided and exposes the `validate` function via `v-model:validate`. Validation errors appear inline beneath each field automatically.
|
|
299
299
|
|
|
300
|
+
Requirements:
|
|
301
|
+
|
|
302
|
+
- Install `@softwareproduction/dryvue` (≥ 2.1). With the default `dryv: 'auto'` this module then provides `useDryv` to `<IntrospectionForm>`; passing rules without it throws instead of silently skipping validation.
|
|
303
|
+
- The Dryv Vue plugin must also be installed so validators are reactive — add [`@softwareproduction/nuxt-dryv`](https://www.npmjs.com/package/@softwareproduction/nuxt-dryv) to `modules` (or `app.use(Dryv)` from `@softwareproduction/dryvue` in a plugin). Without it, messages only appear after the next re-render.
|
|
304
|
+
|
|
300
305
|
## Advanced Configuration
|
|
301
306
|
|
|
302
307
|
### Multiple Form Configs (Spread Pattern)
|
|
@@ -342,3 +347,17 @@ const form = useIntrospectionForm({
|
|
|
342
347
|
## License
|
|
343
348
|
|
|
344
349
|
MIT
|
|
350
|
+
|
|
351
|
+
## 0.2.0 (breaking)
|
|
352
|
+
|
|
353
|
+
- Components resolve from `@softwareproduction/introspection-forms/components/*.vue` (SFCs now shipped in dist + transpiled for SSR).
|
|
354
|
+
- The module `defaults` option was removed. Register defaults/translate in your own plugin:
|
|
355
|
+
```ts
|
|
356
|
+
// plugins/forms.ts
|
|
357
|
+
import { IntrospectionFormsPlugin } from '@softwareproduction/introspection-forms/plugin'
|
|
358
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
359
|
+
nuxtApp.vueApp.use(IntrospectionFormsPlugin, {defaults: {/* component mapping */}, translate})
|
|
360
|
+
})
|
|
361
|
+
```
|
|
362
|
+
- Validation: `@softwareproduction/dryvue` is wired via injection (`dryv: 'auto' | true | false`, default 'auto'). `dryv: true` without the package installed fails the build.
|
|
363
|
+
- `IntrospectionForm` storage defaults to `'session'` — pass `storage="none"` for personal data.
|
package/dist/module.d.mts
CHANGED
|
@@ -7,22 +7,12 @@ interface ModuleOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
generatedPath?: string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Provide `useDryv` from `@softwareproduction/dryvue` to IntrospectionForm
|
|
11
|
+
* for validation. 'auto' enables it when the package is resolvable;
|
|
12
|
+
* `true` requires it (build fails otherwise); `false` disables it.
|
|
13
|
+
* @default 'auto'
|
|
12
14
|
*/
|
|
13
|
-
|
|
14
|
-
/** Map field TypeScript types (string, number, boolean, enum) to component configs. */
|
|
15
|
-
byFieldType?: Record<string, unknown>;
|
|
16
|
-
/** Map original GraphQL types (DateTime, etc.) to component configs. */
|
|
17
|
-
byOriginalType?: Record<string, unknown>;
|
|
18
|
-
/** Match field names by regex to component configs. */
|
|
19
|
-
byFieldName?: {
|
|
20
|
-
regexp: RegExp;
|
|
21
|
-
config: unknown;
|
|
22
|
-
}[];
|
|
23
|
-
/** Filter enum values by original type name. */
|
|
24
|
-
enumFilters?: Record<string, (values: string[]) => string[]>;
|
|
25
|
-
};
|
|
15
|
+
dryv?: boolean | 'auto';
|
|
26
16
|
}
|
|
27
17
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
28
18
|
|
package/dist/module.d.ts
CHANGED
|
@@ -7,22 +7,12 @@ interface ModuleOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
generatedPath?: string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Provide `useDryv` from `@softwareproduction/dryvue` to IntrospectionForm
|
|
11
|
+
* for validation. 'auto' enables it when the package is resolvable;
|
|
12
|
+
* `true` requires it (build fails otherwise); `false` disables it.
|
|
13
|
+
* @default 'auto'
|
|
12
14
|
*/
|
|
13
|
-
|
|
14
|
-
/** Map field TypeScript types (string, number, boolean, enum) to component configs. */
|
|
15
|
-
byFieldType?: Record<string, unknown>;
|
|
16
|
-
/** Map original GraphQL types (DateTime, etc.) to component configs. */
|
|
17
|
-
byOriginalType?: Record<string, unknown>;
|
|
18
|
-
/** Match field names by regex to component configs. */
|
|
19
|
-
byFieldName?: {
|
|
20
|
-
regexp: RegExp;
|
|
21
|
-
config: unknown;
|
|
22
|
-
}[];
|
|
23
|
-
/** Filter enum values by original type name. */
|
|
24
|
-
enumFilters?: Record<string, (values: string[]) => string[]>;
|
|
25
|
-
};
|
|
15
|
+
dryv?: boolean | 'auto';
|
|
26
16
|
}
|
|
27
17
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
28
18
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addComponent, addImportsDir, addPlugin } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponent, addImportsDir, tryResolveModule, addPlugin } from '@nuxt/kit';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
|
|
4
4
|
const module = defineNuxtModule({
|
|
@@ -10,39 +10,35 @@ const module = defineNuxtModule({
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
defaults: {
|
|
13
|
-
generatedPath: "types/generated/introspection"
|
|
13
|
+
generatedPath: "types/generated/introspection",
|
|
14
|
+
dryv: "auto"
|
|
14
15
|
},
|
|
15
|
-
setup(options, nuxt) {
|
|
16
|
+
async setup(options, nuxt) {
|
|
16
17
|
const resolver = createResolver(import.meta.url);
|
|
18
|
+
nuxt.options.build.transpile.push("@softwareproduction/introspection-forms");
|
|
17
19
|
addComponent({
|
|
18
20
|
name: "IntrospectionForm",
|
|
19
|
-
filePath: "@softwareproduction/introspection-forms"
|
|
20
|
-
export: "IntrospectionForm"
|
|
21
|
+
filePath: "@softwareproduction/introspection-forms/components/IntrospectionForm.vue"
|
|
21
22
|
});
|
|
22
23
|
addComponent({
|
|
23
24
|
name: "IntrospectionField",
|
|
24
|
-
filePath: "@softwareproduction/introspection-forms"
|
|
25
|
-
export: "IntrospectionField"
|
|
25
|
+
filePath: "@softwareproduction/introspection-forms/components/IntrospectionField.vue"
|
|
26
26
|
});
|
|
27
27
|
nuxt.options.alias["#introspection-types"] = join(nuxt.options.rootDir, options.generatedPath);
|
|
28
|
-
nuxt.options.alias["#introspection-forms"] = "@softwareproduction/introspection-forms";
|
|
29
28
|
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
nuxt.options.appConfig.introspectionForms = {
|
|
44
|
-
hasDefaults: !!options.defaults
|
|
45
|
-
};
|
|
29
|
+
const dryvRequested = options.dryv === true || options.dryv === "auto";
|
|
30
|
+
const dryvPath = await tryResolveModule("@softwareproduction/dryvue", nuxt.options.modulesDir);
|
|
31
|
+
if (options.dryv === true && !dryvPath) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"introspectionForms.dryv is enabled but @softwareproduction/dryvue is not installed. Run `yarn add @softwareproduction/dryvue` (peer, >=2.1.0)."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (dryvRequested && dryvPath) {
|
|
37
|
+
addPlugin({
|
|
38
|
+
src: resolver.resolve("./runtime/plugins/dryv"),
|
|
39
|
+
mode: "all"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
46
42
|
}
|
|
47
43
|
});
|
|
48
44
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
2
|
+
import { useDryv } from "@softwareproduction/dryvue";
|
|
3
|
+
import { INTROSPECTION_FORMS_USE_DRYV_KEY } from "@softwareproduction/introspection-forms/plugin";
|
|
4
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
|
+
nuxtApp.vueApp.provide(INTROSPECTION_FORMS_USE_DRYV_KEY, useDryv);
|
|
6
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softwareproduction/nuxt-introspection-forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Nuxt module for introspection-forms — schema-driven form generation from GraphQL",
|
|
5
5
|
"author": "Munir Husseini (https://github.com/mhusseini)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@nuxt/kit": "^3.16.0",
|
|
31
|
-
"@softwareproduction/introspection-forms": "0.
|
|
31
|
+
"@softwareproduction/introspection-forms": "0.2.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"nuxt": "^3.16.0 || ^4.0.0",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineNuxtPlugin } from "#app";
|
|
2
|
-
import { INTROSPECTION_FORMS_KEY } from "@softwareproduction/introspection-forms";
|
|
3
|
-
export default defineNuxtPlugin({
|
|
4
|
-
name: "introspection-forms",
|
|
5
|
-
setup(nuxtApp) {
|
|
6
|
-
const existingDefaults = nuxtApp.$introspectionForms;
|
|
7
|
-
if (existingDefaults) {
|
|
8
|
-
nuxtApp.vueApp.provide(INTROSPECTION_FORMS_KEY, existingDefaults);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
});
|
|
File without changes
|