@metaobjectsdev/codegen-ts-react 0.21.4 → 0.21.5
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/form-file.d.ts.map +1 -1
- package/dist/form-file.js +6 -2
- package/dist/form-file.js.map +1 -1
- package/package.json +4 -4
- package/src/form-file.ts +6 -2
package/dist/form-file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-file.d.ts","sourceRoot":"","sources":["../src/form-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAA6B,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"form-file.d.ts","sourceRoot":"","sources":["../src/form-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAA6B,KAAK,gBAAgB,EAAwF,MAAM,4BAA4B,CAAC;AAGpL,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAwChB,gBAAgB,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/form-file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OBJECT_ATTR_DISCRIMINATOR } from "@metaobjectsdev/metadata";
|
|
2
|
-
import { perEntity, entityOutputPath,
|
|
2
|
+
import { perEntity, entityOutputPath, servesWriteApi, isProjection, isTphSubtype, CODEGEN_ATTR_EMIT_FORM } from "@metaobjectsdev/codegen-ts";
|
|
3
3
|
import { renderFormFile } from "./templates/form-file.js";
|
|
4
4
|
/**
|
|
5
5
|
* Forms are opt-in: a user must add `formFile()` to config.generators.
|
|
@@ -30,7 +30,11 @@ export const formFile = function formFile(opts) {
|
|
|
30
30
|
// subtype isn't mistaken for a base); e is already known not to be a subtype.
|
|
31
31
|
if (typeof e.ownAttr(OBJECT_ATTR_DISCRIMINATOR) === "string")
|
|
32
32
|
return false;
|
|
33
|
-
|
|
33
|
+
// A form is a client of a WRITE endpoint. Ask whether one exists, not where the
|
|
34
|
+
// data is stored — see api-surface.ts. `!isProjection` stays explicit here: a
|
|
35
|
+
// read-only view is a UI-tier exclusion (nothing to submit), distinct from
|
|
36
|
+
// whether write endpoints exist at all.
|
|
37
|
+
return servesWriteApi(e) && !isProjection(e);
|
|
34
38
|
},
|
|
35
39
|
generate: perEntity((entity, ctx) => {
|
|
36
40
|
if (!ctx.renderContext) {
|
package/dist/form-file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-file.js","sourceRoot":"","sources":["../src/form-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAyC,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"form-file.js","sourceRoot":"","sources":["../src/form-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAyC,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpL,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAO1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,QAAQ,CAAC,IAAmB;IAC3D,MAAM,UAAU,GAAG,IAAI,EAAE,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,WAAW;QACjB,8DAA8D;QAC9D,oEAAoE;QACpE,qEAAqE;QACrE,4BAA4B;QAC5B,2EA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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/codegen-ts-react",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.5",
|
|
4
4
|
"description": "React codegen for metaobjects — emits <Entity>.form.tsx files using react-hook-form and @metaobjectsdev/react helpers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@metaobjectsdev/metadata": "0.21.
|
|
49
|
-
"@metaobjectsdev/codegen-ts": "0.21.
|
|
48
|
+
"@metaobjectsdev/metadata": "0.21.5",
|
|
49
|
+
"@metaobjectsdev/codegen-ts": "0.21.5",
|
|
50
50
|
"ts-poet": "^6.10.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@biomejs/biome": ">=1.9.0"
|
|
53
|
+
"@biomejs/biome": ">=1.9.0 <3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@biomejs/biome": "^1.9.0",
|
package/src/form-file.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MetaObject } from "@metaobjectsdev/metadata";
|
|
2
2
|
import { OBJECT_ATTR_DISCRIMINATOR } from "@metaobjectsdev/metadata";
|
|
3
|
-
import { perEntity, type Generator, type GeneratorFactory, entityOutputPath,
|
|
3
|
+
import { perEntity, type Generator, type GeneratorFactory, entityOutputPath, servesWriteApi, isProjection, isTphSubtype, CODEGEN_ATTR_EMIT_FORM } from "@metaobjectsdev/codegen-ts";
|
|
4
4
|
import { renderFormFile } from "./templates/form-file.js";
|
|
5
5
|
|
|
6
6
|
export interface FormFileOpts {
|
|
@@ -33,7 +33,11 @@ export const formFile = function formFile(opts?: FormFileOpts): Generator {
|
|
|
33
33
|
// ADR-0039: own — @discriminator identifies a TPH base level (read own so a
|
|
34
34
|
// subtype isn't mistaken for a base); e is already known not to be a subtype.
|
|
35
35
|
if (typeof e.ownAttr(OBJECT_ATTR_DISCRIMINATOR) === "string") return false;
|
|
36
|
-
|
|
36
|
+
// A form is a client of a WRITE endpoint. Ask whether one exists, not where the
|
|
37
|
+
// data is stored — see api-surface.ts. `!isProjection` stays explicit here: a
|
|
38
|
+
// read-only view is a UI-tier exclusion (nothing to submit), distinct from
|
|
39
|
+
// whether write endpoints exist at all.
|
|
40
|
+
return servesWriteApi(e) && !isProjection(e);
|
|
37
41
|
},
|
|
38
42
|
generate: perEntity((entity, ctx) => {
|
|
39
43
|
if (!ctx.renderContext) {
|