@contember/binding 1.2.0-alpha.1 → 1.2.0-alpha.11
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/development/accessorPropagation/AccessorProvider.js +10 -2
- package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
- package/dist/development/accessorPropagation/BindingOperationsProvider.js +6 -2
- package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EntityKeyProvider.js +6 -2
- package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
- package/dist/development/accessorPropagation/EnvironmentContext.js +21 -5
- package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
- package/dist/development/accessorPropagation/TreeRootIdProvider.js +6 -2
- package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +57 -13
- package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
- package/dist/development/accessorTree/AccessorTree.js +22 -2
- package/dist/development/accessorTree/AccessorTree.js.map +1 -1
- package/dist/development/accessors/EntityAccessor.js +66 -22
- package/dist/development/accessors/EntityAccessor.js.map +1 -1
- package/dist/development/core/EventManager.js +27 -1
- package/dist/development/core/EventManager.js.map +1 -1
- package/dist/development/core/operations/FieldOperations.js +21 -1
- package/dist/development/core/operations/FieldOperations.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +6 -2
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/coreComponents/Entity.js +6 -2
- package/dist/development/coreComponents/Entity.js.map +1 -1
- package/dist/development/coreComponents/EntityList.js +17 -5
- package/dist/development/coreComponents/EntityList.js.map +1 -1
- package/dist/development/coreComponents/EntityListSubTree.js +17 -5
- package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
- package/dist/development/coreComponents/EntitySubTree.js +33 -9
- package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
- package/dist/development/coreComponents/Field.js +11 -3
- package/dist/development/coreComponents/Field.js.map +1 -1
- package/dist/development/coreComponents/HasMany.js +17 -5
- package/dist/development/coreComponents/HasMany.js.map +1 -1
- package/dist/development/coreComponents/HasOne.js +17 -5
- package/dist/development/coreComponents/HasOne.js.map +1 -1
- package/dist/development/coreComponents/ParentEntity.js +6 -2
- package/dist/development/coreComponents/ParentEntity.js.map +1 -1
- package/dist/development/dao/TreeNodeEnvironmentFactory.js +6 -76
- package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +22 -6
- package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
- package/dist/development/helperComponents/EntityView.js +6 -2
- package/dist/development/helperComponents/EntityView.js.map +1 -1
- package/dist/development/helperComponents/FieldView.js +17 -5
- package/dist/development/helperComponents/FieldView.js.map +1 -1
- package/dist/development/helperComponents/If.js +40 -8
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/StaticRender.js +6 -2
- package/dist/development/helperComponents/StaticRender.js.map +1 -1
- package/dist/development/helperComponents/SugaredField.js +11 -3
- package/dist/development/helperComponents/SugaredField.js.map +1 -1
- package/dist/development/markers/HasManyRelationMarker.js +6 -0
- package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
- package/dist/development/markers/PlaceholderGenerator.js +5 -4
- package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/development/markers/PlaceholderParametersGenerator.js +62 -0
- package/dist/development/markers/PlaceholderParametersGenerator.js.map +1 -0
- package/dist/development/queryLanguage/Parser.js +3 -0
- package/dist/development/queryLanguage/Parser.js.map +1 -1
- package/dist/development/queryLanguage/QueryLanguage.js +3 -0
- package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
- package/dist/development/utils/Hashing.js +2 -56
- package/dist/development/utils/Hashing.js.map +1 -1
- package/dist/development/utils/TreeNodeUtils.js +77 -0
- package/dist/development/utils/TreeNodeUtils.js.map +1 -0
- package/dist/production/accessors/EntityAccessor.js +66 -22
- package/dist/production/accessors/EntityAccessor.js.map +1 -1
- package/dist/production/dao/TreeNodeEnvironmentFactory.js +6 -76
- package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -1
- package/dist/production/markers/PlaceholderGenerator.js +5 -4
- package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
- package/dist/production/markers/PlaceholderParametersGenerator.js +62 -0
- package/dist/production/markers/PlaceholderParametersGenerator.js.map +1 -0
- package/dist/production/utils/Hashing.js +2 -56
- package/dist/production/utils/Hashing.js.map +1 -1
- package/dist/production/utils/TreeNodeUtils.js +77 -0
- package/dist/production/utils/TreeNodeUtils.js.map +1 -0
- package/dist/types/accessors/EntityAccessor.d.ts +9 -4
- package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +0 -8
- package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -1
- package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
- package/dist/types/markers/PlaceholderParametersGenerator.d.ts +9 -0
- package/dist/types/markers/PlaceholderParametersGenerator.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/Hashing.d.ts +1 -7
- package/dist/types/utils/Hashing.d.ts.map +1 -1
- package/dist/types/utils/TreeNodeUtils.d.ts +13 -0
- package/dist/types/utils/TreeNodeUtils.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/accessors/EntityAccessor.ts +96 -28
- package/src/dao/TreeNodeEnvironmentFactory.ts +6 -92
- package/src/markers/PlaceholderGenerator.ts +6 -5
- package/src/markers/PlaceholderParametersGenerator.ts +79 -0
- package/src/utils/Hashing.ts +2 -68
- package/src/utils/TreeNodeUtils.ts +92 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
|
|
3
3
|
import { Component } from "./Component.js";
|
|
4
4
|
import { Entity } from "./Entity.js";
|
|
@@ -9,17 +9,29 @@ import { useEntity } from "../accessorPropagation/useEntity.js";
|
|
|
9
9
|
const HasOne = Component(
|
|
10
10
|
(props) => {
|
|
11
11
|
const entity = useEntity(props);
|
|
12
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ jsxDEV(Entity, { ...props, accessor: entity }, void 0, false, {
|
|
13
|
+
fileName: "/__w/interface/interface/packages/binding/src/coreComponents/HasOne.tsx",
|
|
14
|
+
lineNumber: 24,
|
|
15
|
+
columnNumber: 10
|
|
16
|
+
}, globalThis);
|
|
13
17
|
},
|
|
14
18
|
{
|
|
15
19
|
generateEnvironment: (props, oldEnvironment) => {
|
|
16
20
|
const environment = oldEnvironment.withVariables(props.variables);
|
|
17
21
|
return TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props);
|
|
18
22
|
},
|
|
19
|
-
staticRender: (props) => /* @__PURE__ */
|
|
20
|
-
/* @__PURE__ */
|
|
23
|
+
staticRender: (props) => /* @__PURE__ */ jsxDEV(Entity, { ...props, accessor: void 0, children: [
|
|
24
|
+
/* @__PURE__ */ jsxDEV(Field, { field: PRIMARY_KEY_NAME }, void 0, false, {
|
|
25
|
+
fileName: "/__w/interface/interface/packages/binding/src/coreComponents/HasOne.tsx",
|
|
26
|
+
lineNumber: 33,
|
|
27
|
+
columnNumber: 5
|
|
28
|
+
}, globalThis),
|
|
21
29
|
props.children
|
|
22
|
-
] }
|
|
30
|
+
] }, void 0, true, {
|
|
31
|
+
fileName: "/__w/interface/interface/packages/binding/src/coreComponents/HasOne.tsx",
|
|
32
|
+
lineNumber: 32,
|
|
33
|
+
columnNumber: 4
|
|
34
|
+
}, globalThis),
|
|
23
35
|
generateBranchMarker: (props, fields, environment) => MarkerFactory.createRelativeSingleEntityFields(props, environment, fields)
|
|
24
36
|
},
|
|
25
37
|
"HasOne"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\n/**\n * @group Data binding\n */\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":[],"mappings":";;;;;;;;AAmBO,MAAM,SAAS;AAAA,EACrB,CAAyB,UAAoC;AACtD,UAAA,SAAS,UAAU,KAAK;AAE9B,WAAQ,
|
|
1
|
+
{"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\n/**\n * @group Data binding\n */\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":["this"],"mappings":";;;;;;;;AAmBO,MAAM,SAAS;AAAA,EACrB,CAAyB,UAAoC;AACtD,UAAA,SAAS,UAAU,KAAK;AAE9B,WAAQ,uBAAA,QAAA,EAAQ,GAAG,OAAO,UAAU,OAA7B,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAqC,GAAAA,UAAA;AAAA,EAC7C;AAAA,EACA;AAAA,IACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,2BAA2B,aAAa,KAAK;AAAA,IAChF;AAAA,IACA,cAAc,CACb,UAAA,uBAAC,UAAQ,GAAG,OAAO,UAAU,QAC5B,UAAA;AAAA,MAAC,uBAAA,OAAA,EAAM,OAAO,iBAAd,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAgC,GAAAA,UAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,KAFR,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGA,GAAAA,UAAA;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa,MAAM;AAAA,EAC3E;AAAA,EACA;AACD;"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { Component } from "./Component.js";
|
|
3
3
|
import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
|
|
4
4
|
const ParentEntity = Component(
|
|
5
|
-
(props) => /* @__PURE__ */
|
|
5
|
+
(props) => /* @__PURE__ */ jsxDEV(Fragment, { children: props.children }, void 0, false, {
|
|
6
|
+
fileName: "/__w/interface/interface/packages/binding/src/coreComponents/ParentEntity.tsx",
|
|
7
|
+
lineNumber: 14,
|
|
8
|
+
columnNumber: 11
|
|
9
|
+
}, globalThis),
|
|
6
10
|
{
|
|
7
11
|
generateBranchMarker: (props, fields, environment) => MarkerFactory.createParentEntityMarker(props, fields, environment)
|
|
8
12
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":[],"mappings":";;;AAYO,MAAM,eAAe;AAAA,EAC3B,CAAA,UAAY,
|
|
1
|
+
{"version":3,"file":"ParentEntity.js","sources":["../../../src/coreComponents/ParentEntity.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredParentEntityParameters } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface ParentEntityProps extends SugaredParentEntityParameters {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const ParentEntity = Component<ParentEntityProps>(\n\tprops => <>{props.children}</>,\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createParentEntityMarker(props, fields, environment),\n\t},\n\t'ParentEntity',\n)\n"],"names":["this"],"mappings":";;;AAYO,MAAM,eAAe;AAAA,EAC3B,CAAA,UAAY,uBAAA,UAAA,EAAA,UAAA,MAAM,SAAT,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAkB,GAAAA,UAAA;AAAA,EAC3B;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,yBAAyB,OAAO,QAAQ,WAAW;AAAA,EACnE;AAAA,EACA;AACD;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BindingError } from "../BindingError.js";
|
|
2
1
|
import { whereToFilter } from "@contember/client";
|
|
3
|
-
import
|
|
2
|
+
import { TreeNodeUtils } from "../utils/TreeNodeUtils.js";
|
|
4
3
|
import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
|
|
5
4
|
class TreeNodeEnvironmentFactory {
|
|
6
5
|
static createEnvironmentForEntityListSubtree(environment, sugaredEntityList) {
|
|
@@ -16,7 +15,7 @@ class TreeNodeEnvironmentFactory {
|
|
|
16
15
|
rootWhere = entityList.filter ?? {};
|
|
17
16
|
expectedCardinality = "zero-to-many";
|
|
18
17
|
}
|
|
19
|
-
const entitySchema =
|
|
18
|
+
const entitySchema = TreeNodeUtils.resolveEntity(environment.getSchema(), entityList.entityName, "entity list");
|
|
20
19
|
return environment.withSubTree({
|
|
21
20
|
type: "subtree-entity-list",
|
|
22
21
|
entity: entitySchema,
|
|
@@ -37,7 +36,7 @@ class TreeNodeEnvironmentFactory {
|
|
|
37
36
|
rootWhere = whereToFilter(entity.where);
|
|
38
37
|
expectedCardinality = entity.setOnCreate ? "zero-or-one" : "one";
|
|
39
38
|
}
|
|
40
|
-
const entitySchema =
|
|
39
|
+
const entitySchema = TreeNodeUtils.resolveEntity(environment.getSchema(), entity.entityName, "entity");
|
|
41
40
|
return environment.withSubTree({
|
|
42
41
|
type: "subtree-entity",
|
|
43
42
|
entity: entitySchema,
|
|
@@ -49,7 +48,7 @@ class TreeNodeEnvironmentFactory {
|
|
|
49
48
|
const relativeEntityList = QueryLanguage.desugarRelativeEntityList(sugaredRelativeEntityList, environment);
|
|
50
49
|
const hasOneEnvironment = this.traverseHasOnePath(environment, relativeEntityList.hasOneRelationPath);
|
|
51
50
|
const hasManyField = relativeEntityList.hasManyRelation.field;
|
|
52
|
-
const field =
|
|
51
|
+
const field = TreeNodeUtils.resolveHasManyRelation(hasOneEnvironment, hasManyField);
|
|
53
52
|
const targetEntity = environment.getSchema().getEntity(field.targetEntity);
|
|
54
53
|
return hasOneEnvironment.withSubTreeChild({
|
|
55
54
|
type: "entity-list",
|
|
@@ -64,7 +63,7 @@ class TreeNodeEnvironmentFactory {
|
|
|
64
63
|
static createEnvironmentForField(environment, sugaredRelativeSingleField) {
|
|
65
64
|
const relativeSingleField = QueryLanguage.desugarRelativeSingleField(sugaredRelativeSingleField, environment);
|
|
66
65
|
const hasOneEnvironment = this.traverseHasOnePath(environment, relativeSingleField.hasOneRelationPath);
|
|
67
|
-
const field =
|
|
66
|
+
const field = TreeNodeUtils.resolveColumn(hasOneEnvironment, relativeSingleField.field);
|
|
68
67
|
return hasOneEnvironment.withSubTreeChild({
|
|
69
68
|
type: "column",
|
|
70
69
|
entity: environment.getSubTreeNode().entity,
|
|
@@ -73,7 +72,7 @@ class TreeNodeEnvironmentFactory {
|
|
|
73
72
|
}
|
|
74
73
|
static traverseHasOnePath(environment, hasOneRelationPath) {
|
|
75
74
|
for (const pathItem of hasOneRelationPath) {
|
|
76
|
-
const field =
|
|
75
|
+
const field = TreeNodeUtils.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy);
|
|
77
76
|
const targetEntity = environment.getSchema().getEntity(field.targetEntity);
|
|
78
77
|
environment = environment.withSubTreeChild({
|
|
79
78
|
type: "entity",
|
|
@@ -83,75 +82,6 @@ class TreeNodeEnvironmentFactory {
|
|
|
83
82
|
}
|
|
84
83
|
return environment;
|
|
85
84
|
}
|
|
86
|
-
static resolveHasOneRelation(environment, field, isReduced) {
|
|
87
|
-
if (isReduced) {
|
|
88
|
-
return this.resolveRelation(environment, field, "reduced has-one relation", ["ManyHasMany", "OneHasMany"]);
|
|
89
|
-
}
|
|
90
|
-
return this.resolveRelation(environment, field, "a has-one relation", ["ManyHasOne", "OneHasOne"]);
|
|
91
|
-
}
|
|
92
|
-
static assertHasManyRelation(environment, field) {
|
|
93
|
-
return this.resolveRelation(environment, field, "a has-many relation", ["ManyHasMany", "OneHasMany"]);
|
|
94
|
-
}
|
|
95
|
-
static resolveRelation(environment, field, relationDescription, expectedRelationType) {
|
|
96
|
-
return this.resolveField(environment, field, (field2) => {
|
|
97
|
-
return field2.__typename === "_Relation" && expectedRelationType.includes(field2.type);
|
|
98
|
-
}, relationDescription);
|
|
99
|
-
}
|
|
100
|
-
static resolveEntity(schema, entityName, type) {
|
|
101
|
-
const entity = schema.getEntityOrUndefined(entityName);
|
|
102
|
-
if (!entity) {
|
|
103
|
-
const alternative = this.recommendAlternative(entityName, schema.getEntityNames());
|
|
104
|
-
const didYouMean = alternative ? `Did you mean '${alternative}'?` : "";
|
|
105
|
-
throw new BindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${didYouMean}`);
|
|
106
|
-
}
|
|
107
|
-
return entity;
|
|
108
|
-
}
|
|
109
|
-
static resolveColumn(environment, fieldName) {
|
|
110
|
-
return this.resolveField(environment, fieldName, (field) => field.__typename === "_Column", "an ordinary field");
|
|
111
|
-
}
|
|
112
|
-
static resolveField(environment, fieldName, matcher, expectedDescription) {
|
|
113
|
-
const treeLocation = environment.getSubTreeNode();
|
|
114
|
-
const entity = treeLocation.entity;
|
|
115
|
-
const field = entity.fields.get(fieldName);
|
|
116
|
-
if (!field) {
|
|
117
|
-
const alternative = this.recommendAlternative(
|
|
118
|
-
fieldName,
|
|
119
|
-
Array.from(entity.fields).filter(([, field2]) => matcher(field2)).map(([fieldName2]) => fieldName2)
|
|
120
|
-
);
|
|
121
|
-
const didYouMean = alternative ? `Did you mean '${alternative}'?` : "";
|
|
122
|
-
throw new BindingError(`Field '${fieldName}' doesn't exist on ${this.describeLocation(environment)}. ${didYouMean}`);
|
|
123
|
-
}
|
|
124
|
-
if (!matcher(field)) {
|
|
125
|
-
const actual = field.__typename === "_Column" ? "an ordinary field" : `a ${field.type} relation`;
|
|
126
|
-
throw new BindingError(
|
|
127
|
-
`Invalid field: the name '${field.name}' on ${this.describeLocation(environment)} refers to ${actual} but is being used as a ${expectedDescription}.`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
return field;
|
|
131
|
-
}
|
|
132
|
-
static describeLocation(environment) {
|
|
133
|
-
const path = [];
|
|
134
|
-
const loc = environment.getSubTreeNode();
|
|
135
|
-
for (let env = environment; ; env = env.getParent()) {
|
|
136
|
-
const node = env.getSubTreeNode();
|
|
137
|
-
if (node.type === "subtree-entity" || node.type === "subtree-entity-list") {
|
|
138
|
-
return `entity '${loc.entity.name}' in path '${[node.entity.name, ...path.reverse()].join(".")}'`;
|
|
139
|
-
}
|
|
140
|
-
path.push(node.field.name);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
static recommendAlternative(original, possibleAlternatives) {
|
|
144
|
-
let bestAlternative = void 0;
|
|
145
|
-
let bestAlternativeDistance = Number.MAX_SAFE_INTEGER;
|
|
146
|
-
for (const alternative of possibleAlternatives) {
|
|
147
|
-
const distance = levenshtein(original, alternative);
|
|
148
|
-
if (distance < bestAlternativeDistance) {
|
|
149
|
-
bestAlternative = alternative;
|
|
150
|
-
bestAlternativeDistance = distance;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return bestAlternative;
|
|
154
|
-
}
|
|
155
85
|
}
|
|
156
86
|
export {
|
|
157
87
|
TreeNodeEnvironmentFactory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeEnvironmentFactory.js","sources":["../../../src/dao/TreeNodeEnvironmentFactory.ts"],"sourcesContent":["import { Environment } from './Environment'\nimport {\n\tHasOneRelation,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { QueryLanguage } from '../queryLanguage'\nimport { BindingError } from '../BindingError'\nimport { whereToFilter } from '@contember/client'\nimport { BaseRelation, Schema, SchemaColumn, SchemaEntity, SchemaField, SchemaRelation } from '../core/schema'\nimport levenshtein from 'js-levenshtein'\n\nexport class TreeNodeEnvironmentFactory {\n\n\tpublic static createEnvironmentForEntityListSubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t): Environment {\n\t\tlet entityList\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\tentityList = QueryLanguage.desugarUnconstrainedQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = {} as const\n\t\t\texpectedCardinality = 'zero'\n\n\t\t} else {\n\t\t\tentityList = QueryLanguage.desugarQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = entityList.filter ?? {}\n\t\t\texpectedCardinality = 'zero-to-many'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entityList.entityName, 'entity list')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity-list',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntitySubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t): Environment {\n\t\tlet entity\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\trootWhere = { } as const\n\t\t\texpectedCardinality = 'zero'\n\t\t\tentity = QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(sugaredEntityList, environment)\n\n\t\t} else {\n\t\t\tentity = QueryLanguage.desugarQualifiedSingleEntity(sugaredEntityList, environment, { missingSetOnCreate: 'fill' })\n\t\t\trootWhere = whereToFilter(entity.where)\n\t\t\texpectedCardinality = entity.setOnCreate ? 'zero-or-one' : 'one'\n\t\t}\n\n\t\tconst entitySchema = this.resolveEntity(environment.getSchema(), entity.entityName, 'entity')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality: expectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntityList(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeEntityList: SugaredRelativeEntityList,\n\t): Environment {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(sugaredRelativeEntityList, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeEntityList.hasOneRelationPath)\n\t\tconst hasManyField = relativeEntityList.hasManyRelation.field\n\n\t\tconst field = this.assertHasManyRelation(hasOneEnvironment, hasManyField)\n\n\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'entity-list',\n\t\t\tfield,\n\t\t\tentity: targetEntity,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntity(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleEntity: SugaredRelativeSingleEntity,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(sugaredRelativeSingleEntity, environment)\n\n\t\treturn this.traverseHasOnePath(environment, relativeSingleEntity.hasOneRelationPath)\n\t}\n\n\tpublic static createEnvironmentForField(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleField: SugaredRelativeSingleField,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(sugaredRelativeSingleField, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeSingleField.hasOneRelationPath)\n\n\t\tconst field = this.resolveColumn(hasOneEnvironment, relativeSingleField.field)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'column',\n\t\t\tentity: environment.getSubTreeNode().entity,\n\t\t\tfield,\n\t\t})\n\t}\n\n\tprivate static traverseHasOnePath(\n\t\tenvironment: Environment,\n\t\thasOneRelationPath: HasOneRelation[],\n\t): Environment {\n\t\tfor (const pathItem of hasOneRelationPath) {\n\t\t\tconst field = this.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy)\n\t\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\n\t\t\tenvironment = environment.withSubTreeChild({\n\t\t\t\ttype: 'entity',\n\t\t\t\tfield,\n\t\t\t\tentity: targetEntity,\n\t\t\t})\n\t\t}\n\t\treturn environment\n\t}\n\n\tprivate static resolveHasOneRelation(environment: Environment, field: string, isReduced: boolean): SchemaRelation {\n\t\tif (isReduced) {\n\t\t\treturn this.resolveRelation(environment, field, 'reduced has-one relation', ['ManyHasMany', 'OneHasMany'])\n\t\t}\n\t\treturn this.resolveRelation(environment, field, 'a has-one relation', ['ManyHasOne', 'OneHasOne'])\n\t}\n\n\tprivate static assertHasManyRelation(environment: Environment, field: string): SchemaRelation {\n\t\treturn this.resolveRelation(environment, field, 'a has-many relation', ['ManyHasMany', 'OneHasMany'])\n\t}\n\n\n\tprivate static resolveRelation(environment: Environment, field: string, relationDescription: string, expectedRelationType: BaseRelation['type'][]): SchemaRelation {\n\t\treturn this.resolveField(environment, field, (field): field is SchemaRelation => {\n\t\t\treturn field.__typename === '_Relation' && expectedRelationType.includes(field.type)\n\t\t}, relationDescription)\n\t}\n\n\tprivate static resolveEntity(schema: Schema, entityName: string, type: 'entity' | 'entity list'): SchemaEntity {\n\t\tconst entity = schema.getEntityOrUndefined(entityName)\n\t\tif (!entity) {\n\t\t\tconst alternative = this.recommendAlternative(entityName, schema.getEntityNames())\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Invalid ${type} sub tree: Entity '${entityName}' doesn't exist. ${didYouMean}`)\n\t\t}\n\t\treturn entity\n\t}\n\n\tprivate static resolveColumn(environment: Environment, fieldName: string): SchemaColumn {\n\t\treturn this.resolveField(environment, fieldName, (field): field is SchemaColumn => field.__typename === '_Column', 'an ordinary field')\n\t\t// TODO check that defaultValue matches the type\n\t\t// TODO run custom validators\n\t}\n\n\tprivate static resolveField<T extends SchemaField>(environment: Environment, fieldName: string, matcher: (field: SchemaField) => field is T, expectedDescription: string): T {\n\t\tconst treeLocation = environment.getSubTreeNode()\n\t\tconst entity = treeLocation.entity\n\t\tconst field = entity.fields.get(fieldName)\n\t\tif (!field) {\n\t\t\tconst alternative = this.recommendAlternative(\n\t\t\t\tfieldName,\n\t\t\t\tArray.from(entity.fields)\n\t\t\t\t\t.filter(([, field]) => matcher(field))\n\t\t\t\t\t.map(([fieldName]) => fieldName),\n\t\t\t)\n\t\t\tconst didYouMean = alternative ? `Did you mean '${alternative}'?` : ''\n\t\t\tthrow new BindingError(`Field '${fieldName}' doesn't exist on ${this.describeLocation(environment)}. ${didYouMean}`)\n\t\t}\n\t\tif (!matcher(field)) {\n\t\t\tconst actual = field.__typename === '_Column' ? 'an ordinary field' : `a ${field.type} relation`\n\t\t\tthrow new BindingError(\n\t\t\t\t`Invalid field: the name '${field.name}' on ${this.describeLocation(environment)} ` +\n\t\t\t\t`refers to ${actual} but is being used as a ${expectedDescription}.`,\n\t\t\t)\n\t\t}\n\t\treturn field\n\t}\n\n\tprivate static describeLocation(environment: Environment): string {\n\t\tconst path = []\n\t\tconst loc = environment.getSubTreeNode()\n\t\tfor (let env = environment;; env = env.getParent()) {\n\t\t\tconst node = env.getSubTreeNode()\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn `entity '${loc.entity.name}' in path '${[node.entity.name, ...path.reverse()].join('.')}'`\n\t\t\t}\n\t\t\tpath.push(node.field.name)\n\t\t}\n\t}\n\n\tpublic static recommendAlternative(original: string, possibleAlternatives: Iterable<string>): string | undefined {\n\t\tlet bestAlternative: string | undefined = undefined\n\t\tlet bestAlternativeDistance = Number.MAX_SAFE_INTEGER\n\n\t\tfor (const alternative of possibleAlternatives) {\n\t\t\tconst distance = levenshtein(original, alternative)\n\n\t\t\tif (distance < bestAlternativeDistance) {\n\t\t\t\tbestAlternative = alternative\n\t\t\t\tbestAlternativeDistance = distance\n\t\t\t}\n\t\t}\n\t\treturn bestAlternative\n\t}\n}\n"],"names":["field","fieldName"],"mappings":";;;;AAiBO,MAAM,2BA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AAA,QACT,4BAA4B,MAAM,YAAY,KAAK,iBAAiB,WAAW,eAClE,iCAAiC;AAAA,MAAA;AAAA,IAEhD;AACO,WAAA;AAAA,EACR;AAAA,EAEA,OAAe,iBAAiB,aAAkC;AACjE,UAAM,OAAO,CAAA;AACP,UAAA,MAAM,YAAY;AACxB,aAAS,MAAM,eAAc,MAAM,IAAI,aAAa;AAC7C,YAAA,OAAO,IAAI;AACjB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AAC1E,eAAO,WAAW,IAAI,OAAO,kBAAkB,CAAC,KAAK,OAAO,MAAM,GAAG,KAAK,QAAS,CAAA,EAAE,KAAK,GAAG;AAAA,MAC9F;AACK,WAAA,KAAK,KAAK,MAAM,IAAI;AAAA,IAC1B;AAAA,EACD;AAAA,EAEA,OAAc,qBAAqB,UAAkB,sBAA4D;AAChH,QAAI,kBAAsC;AAC1C,QAAI,0BAA0B,OAAO;AAErC,eAAW,eAAe,sBAAsB;AACzC,YAAA,WAAW,YAAY,UAAU,WAAW;AAElD,UAAI,WAAW,yBAAyB;AACrB,0BAAA;AACQ,kCAAA;AAAA,MAC3B;AAAA,IACD;AACO,WAAA;AAAA,EACR;AACD;"}
|
|
1
|
+
{"version":3,"file":"TreeNodeEnvironmentFactory.js","sources":["../../../src/dao/TreeNodeEnvironmentFactory.ts"],"sourcesContent":["import { Environment } from './Environment'\nimport {\n\tHasOneRelation,\n\tSugaredQualifiedEntityList,\n\tSugaredQualifiedSingleEntity,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleEntity,\n\tSugaredRelativeSingleField,\n\tSugaredUnconstrainedQualifiedEntityList,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n} from '../treeParameters'\nimport { QueryLanguage } from '../queryLanguage'\nimport { whereToFilter } from '@contember/client'\nimport { TreeNodeUtils } from '../utils/TreeNodeUtils'\n\nexport class TreeNodeEnvironmentFactory {\n\n\tpublic static createEnvironmentForEntityListSubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList,\n\t): Environment {\n\t\tlet entityList\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\tentityList = QueryLanguage.desugarUnconstrainedQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = {} as const\n\t\t\texpectedCardinality = 'zero'\n\n\t\t} else {\n\t\t\tentityList = QueryLanguage.desugarQualifiedEntityList(sugaredEntityList, environment)\n\t\t\trootWhere = entityList.filter ?? {}\n\t\t\texpectedCardinality = 'zero-to-many'\n\t\t}\n\n\t\tconst entitySchema = TreeNodeUtils.resolveEntity(environment.getSchema(), entityList.entityName, 'entity list')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity-list',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntitySubtree(\n\t\tenvironment: Environment,\n\t\tsugaredEntityList: SugaredQualifiedSingleEntity | SugaredUnconstrainedQualifiedSingleEntity,\n\t): Environment {\n\t\tlet entity\n\t\tlet rootWhere\n\t\tlet expectedCardinality: Environment.SubTreeNode['expectedCardinality']\n\n\t\tif (sugaredEntityList.isCreating) {\n\t\t\trootWhere = { } as const\n\t\t\texpectedCardinality = 'zero'\n\t\t\tentity = QueryLanguage.desugarUnconstrainedQualifiedSingleEntity(sugaredEntityList, environment)\n\n\t\t} else {\n\t\t\tentity = QueryLanguage.desugarQualifiedSingleEntity(sugaredEntityList, environment, { missingSetOnCreate: 'fill' })\n\t\t\trootWhere = whereToFilter(entity.where)\n\t\t\texpectedCardinality = entity.setOnCreate ? 'zero-or-one' : 'one'\n\t\t}\n\n\t\tconst entitySchema = TreeNodeUtils.resolveEntity(environment.getSchema(), entity.entityName, 'entity')\n\n\t\treturn environment.withSubTree({\n\t\t\ttype: 'subtree-entity',\n\t\t\tentity: entitySchema,\n\t\t\texpectedCardinality: expectedCardinality,\n\t\t\tfilter: rootWhere,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntityList(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeEntityList: SugaredRelativeEntityList,\n\t): Environment {\n\t\tconst relativeEntityList = QueryLanguage.desugarRelativeEntityList(sugaredRelativeEntityList, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeEntityList.hasOneRelationPath)\n\t\tconst hasManyField = relativeEntityList.hasManyRelation.field\n\n\t\tconst field = TreeNodeUtils.resolveHasManyRelation(hasOneEnvironment, hasManyField)\n\n\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'entity-list',\n\t\t\tfield,\n\t\t\tentity: targetEntity,\n\t\t})\n\t}\n\n\tpublic static createEnvironmentForEntity(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleEntity: SugaredRelativeSingleEntity,\n\t) {\n\t\tconst relativeSingleEntity = QueryLanguage.desugarRelativeSingleEntity(sugaredRelativeSingleEntity, environment)\n\n\t\treturn this.traverseHasOnePath(environment, relativeSingleEntity.hasOneRelationPath)\n\t}\n\n\tpublic static createEnvironmentForField(\n\t\tenvironment: Environment,\n\t\tsugaredRelativeSingleField: SugaredRelativeSingleField,\n\t) {\n\t\tconst relativeSingleField = QueryLanguage.desugarRelativeSingleField(sugaredRelativeSingleField, environment)\n\t\tconst hasOneEnvironment = this.traverseHasOnePath(environment, relativeSingleField.hasOneRelationPath)\n\n\t\tconst field = TreeNodeUtils.resolveColumn(hasOneEnvironment, relativeSingleField.field)\n\n\t\treturn hasOneEnvironment.withSubTreeChild({\n\t\t\ttype: 'column',\n\t\t\tentity: environment.getSubTreeNode().entity,\n\t\t\tfield,\n\t\t})\n\t}\n\n\tprivate static traverseHasOnePath(\n\t\tenvironment: Environment,\n\t\thasOneRelationPath: HasOneRelation[],\n\t): Environment {\n\t\tfor (const pathItem of hasOneRelationPath) {\n\t\t\tconst field = TreeNodeUtils.resolveHasOneRelation(environment, pathItem.field, !!pathItem.reducedBy)\n\t\t\tconst targetEntity = environment.getSchema().getEntity(field.targetEntity)\n\n\t\t\tenvironment = environment.withSubTreeChild({\n\t\t\t\ttype: 'entity',\n\t\t\t\tfield,\n\t\t\t\tentity: targetEntity,\n\t\t\t})\n\t\t}\n\t\treturn environment\n\t}\n\n}\n"],"names":[],"mappings":";;;AAeO,MAAM,2BAA2B;AAAA,EAEvC,OAAc,sCACb,aACA,mBACc;AACV,QAAA;AACA,QAAA;AACA,QAAA;AAEJ,QAAI,kBAAkB,YAAY;AACpB,mBAAA,cAAc,wCAAwC,mBAAmB,WAAW;AACjG,kBAAY,CAAA;AACU,4BAAA;AAAA,IAAA,OAEhB;AACO,mBAAA,cAAc,2BAA2B,mBAAmB,WAAW;AACxE,kBAAA,WAAW,UAAU;AACX,4BAAA;AAAA,IACvB;AAEM,UAAA,eAAe,cAAc,cAAc,YAAY,aAAa,WAAW,YAAY,aAAa;AAE9G,WAAO,YAAY,YAAY;AAAA,MAC9B,MAAM;AAAA,MACN,QAAQ;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,IAAA,CACR;AAAA,EACF;AAAA,EAEA,OAAc,kCACb,aACA,mBACc;AACV,QAAA;AACA,QAAA;AACA,QAAA;AAEJ,QAAI,kBAAkB,YAAY;AACjC,kBAAY,CAAA;AACU,4BAAA;AACb,eAAA,cAAc,0CAA0C,mBAAmB,WAAW;AAAA,IAAA,OAEzF;AACN,eAAS,cAAc,6BAA6B,mBAAmB,aAAa,EAAE,oBAAoB,QAAQ;AACtG,kBAAA,cAAc,OAAO,KAAK;AAChB,4BAAA,OAAO,cAAc,gBAAgB;AAAA,IAC5D;AAEM,UAAA,eAAe,cAAc,cAAc,YAAY,aAAa,OAAO,YAAY,QAAQ;AAErG,WAAO,YAAY,YAAY;AAAA,MAC9B,MAAM;AAAA,MACN,QA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;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useState, useCallback, useEffect } from "react";
|
|
3
3
|
import { useConstantValueInvariant } from "@contember/react-utils";
|
|
4
4
|
import { Component } from "../coreComponents/Component.js";
|
|
@@ -41,7 +41,11 @@ const DeferredSubTrees = Component(
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
setLoadState({ name: "loading" });
|
|
44
|
-
const newFragment = /* @__PURE__ */
|
|
44
|
+
const newFragment = /* @__PURE__ */ jsxDEV(OnlyKeepSubTrees, { children: props.children }, void 0, false, {
|
|
45
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
|
|
46
|
+
lineNumber: 66,
|
|
47
|
+
columnNumber: 24
|
|
48
|
+
}, globalThis);
|
|
45
49
|
extendTree(newFragment, { signal, environment }).then((treeRootId) => !signal.aborted && setLoadState({ name: "success", treeRootId })).catch((error) => {
|
|
46
50
|
if (signal.aborted) {
|
|
47
51
|
return;
|
|
@@ -52,16 +56,28 @@ const DeferredSubTrees = Component(
|
|
|
52
56
|
switch (loadState.name) {
|
|
53
57
|
case "initial":
|
|
54
58
|
case "loading":
|
|
55
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: props.fallback }, void 0, false, {
|
|
60
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
|
|
61
|
+
lineNumber: 81,
|
|
62
|
+
columnNumber: 12
|
|
63
|
+
}, globalThis);
|
|
56
64
|
case "success":
|
|
57
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ jsxDEV(TreeRootIdProvider, { treeRootId: loadState.treeRootId, children: props.children }, void 0, false, {
|
|
66
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
|
|
67
|
+
lineNumber: 87,
|
|
68
|
+
columnNumber: 12
|
|
69
|
+
}, globalThis);
|
|
58
70
|
}
|
|
59
71
|
},
|
|
60
72
|
{
|
|
61
|
-
staticRender: (props) => /* @__PURE__ */
|
|
73
|
+
staticRender: (props) => /* @__PURE__ */ jsxDEV(Fragment, { children: [
|
|
62
74
|
props.children,
|
|
63
75
|
props.fallback
|
|
64
|
-
] }
|
|
76
|
+
] }, void 0, true, {
|
|
77
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
|
|
78
|
+
lineNumber: 92,
|
|
79
|
+
columnNumber: 4
|
|
80
|
+
}, globalThis),
|
|
65
81
|
generateBranchMarker: (props, fields, environment) => {
|
|
66
82
|
const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
|
|
67
83
|
fieldsWithHoistablesMarker.subTrees?.clear();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":[],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEA,cAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAc;AACpB,cAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["this"],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,Q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AM;AAAA,IAAA,KAFR,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGA,GAAAA,UAAA;AAAA,IAED,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6B,cAAc,uCAAuC,QAAQ,WAAW;AAM3G,iCAA2B,UAAU;AAE9B,aAAA;AAAA,IACR;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useEntity } from "../accessorPropagation/useEntity.js";
|
|
3
3
|
function EntityView(props) {
|
|
4
4
|
const entity = "field" in props ? useEntity(props.field) : useEntity();
|
|
5
|
-
return /* @__PURE__ */
|
|
5
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: props.render(entity) }, void 0, false, {
|
|
6
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/EntityView.tsx",
|
|
7
|
+
lineNumber: 18,
|
|
8
|
+
columnNumber: 9
|
|
9
|
+
}, this);
|
|
6
10
|
}
|
|
7
11
|
export {
|
|
8
12
|
EntityView
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\n/**\n * @group Data binding\n */\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;AAaO,SAAS,WAAW,OAAwB;AAElD,QAAM,SAAS,WAAW,QAAQ,UAAU,MAAM,KAAK,IAAK;AAE5D,SAAU,
|
|
1
|
+
{"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\n/**\n * @group Data binding\n */\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;AAaO,SAAS,WAAW,OAAwB;AAElD,QAAM,SAAS,WAAW,QAAQ,UAAU,MAAM,KAAK,IAAK;AAE5D,SAAU,uBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,EAAtB,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAwB,GAAA,IAAA;AAChC;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useConstantLengthInvariant, useArrayMapMemo } from "@contember/react-utils";
|
|
3
3
|
import { useCallback, useMemo } from "react";
|
|
4
4
|
import { throwBindingError } from "../BindingError.js";
|
|
@@ -32,14 +32,26 @@ const FieldView = Component(
|
|
|
32
32
|
}
|
|
33
33
|
return render(...accessors);
|
|
34
34
|
}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render]);
|
|
35
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: output }, void 0, false, {
|
|
36
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
|
|
37
|
+
lineNumber: 87,
|
|
38
|
+
columnNumber: 10
|
|
39
|
+
}, globalThis);
|
|
36
40
|
},
|
|
37
41
|
(props) => {
|
|
38
42
|
const fields = "fields" in props && Array.isArray(props.fields) ? props.fields : "field" in props && props.field ? [props.field] : throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`);
|
|
39
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: [
|
|
40
44
|
props.fallbackIfUnpersisted,
|
|
41
|
-
fields.map((field, i) => /* @__PURE__ */
|
|
42
|
-
|
|
45
|
+
fields.map((field, i) => /* @__PURE__ */ jsxDEV(SugaredField, { field }, i, false, {
|
|
46
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
|
|
47
|
+
lineNumber: 100,
|
|
48
|
+
columnNumber: 6
|
|
49
|
+
}, globalThis))
|
|
50
|
+
] }, void 0, true, {
|
|
51
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
|
|
52
|
+
lineNumber: 97,
|
|
53
|
+
columnNumber: 4
|
|
54
|
+
}, globalThis);
|
|
43
55
|
},
|
|
44
56
|
"FieldView"
|
|
45
57
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":[],"mappings":";;;;;;;;AA8CO,MAAM,YAAY;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QAC1B,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAE5F;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAID,UAAM,iBAAiB;AACvB,UAAM,cAAc,eAAe;AAEnC,UAAM,eAAe;AAAA,MACpB,CAAC,QAAc,cAAc,2BAA2B,KAAK,WAAW;AAAA,MACxE,CAAC,WAAW;AAAA,IAAA;AAEP,UAAA,kBAAkB,gBAAgB,QAAQ,YAAY;AAE5D,UAAM,gBAAgB;AAAA,MACrB,CAAC,iBAAsC,eAAe,uBAAuB,YAAY;AAAA,MACzF,CAAC,cAAc;AAAA,IAAA;AAEV,UAAA,YAAY,gBAAgB,iBAAiB,aAAa;AAI1D,UAAA,SAAS,QAAQ,MAAM;AAC5B,UAAI,CAAC,eAAe,kBAAkB,0BAA0B,QAAW;AACnE,eAAA;AAAA,MACR;AACO,aAAA,OAAO,GAAG,SAAS;AAAA,IAAA,GACxB,CAAC,WAAW,eAAe,gBAAgB,uBAAuB,MAAM,CAAC;AAE5E,
|
|
1
|
+
{"version":3,"file":"FieldView.js","sources":["../../../src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: SRSF) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t? [props.field]\n\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":["this"],"mappings":";;;;;;;;AA8CO,MAAM,YAAY;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,Q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GAAAA,UAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { FilterFieldsCollector } from "./helpers/FilterFieldsCollector.js";
|
|
4
4
|
import { FilterEvaluator } from "./helpers/FilterEvaluator.js";
|
|
@@ -9,7 +9,15 @@ import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
|
|
|
9
9
|
import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
|
|
10
10
|
const If = Component(
|
|
11
11
|
(props) => {
|
|
12
|
-
return typeof props.condition !== "function" ? /* @__PURE__ */
|
|
12
|
+
return typeof props.condition !== "function" ? /* @__PURE__ */ jsxDEV(IfFilter, { condition: props.condition, children: props.children }, void 0, false, {
|
|
13
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
14
|
+
lineNumber: 30,
|
|
15
|
+
columnNumber: 6
|
|
16
|
+
}, globalThis) : /* @__PURE__ */ jsxDEV(IfCallback, { condition: props.condition, children: props.children }, void 0, false, {
|
|
17
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
18
|
+
lineNumber: 31,
|
|
19
|
+
columnNumber: 6
|
|
20
|
+
}, globalThis);
|
|
13
21
|
},
|
|
14
22
|
"If"
|
|
15
23
|
);
|
|
@@ -17,10 +25,18 @@ const IfCallback = Component(
|
|
|
17
25
|
({ children, condition }) => {
|
|
18
26
|
const entity = useEntity();
|
|
19
27
|
const evaluated = useMemo(() => condition(entity), [condition, entity]);
|
|
20
|
-
return evaluated ? /* @__PURE__ */
|
|
28
|
+
return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
29
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
30
|
+
lineNumber: 41,
|
|
31
|
+
columnNumber: 22
|
|
32
|
+
}, globalThis) : null;
|
|
21
33
|
},
|
|
22
34
|
({ children }) => {
|
|
23
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
36
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
37
|
+
lineNumber: 44,
|
|
38
|
+
columnNumber: 10
|
|
39
|
+
}, globalThis);
|
|
24
40
|
},
|
|
25
41
|
"IfCallback"
|
|
26
42
|
);
|
|
@@ -33,16 +49,32 @@ const IfFilter = Component(
|
|
|
33
49
|
() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),
|
|
34
50
|
[condition, entity, env, schema]
|
|
35
51
|
);
|
|
36
|
-
return evaluated ? /* @__PURE__ */
|
|
52
|
+
return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
53
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
54
|
+
lineNumber: 60,
|
|
55
|
+
columnNumber: 22
|
|
56
|
+
}, globalThis) : null;
|
|
37
57
|
},
|
|
38
58
|
({ children, condition }, env) => {
|
|
39
59
|
const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
|
|
40
60
|
const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
|
|
41
|
-
const additionalFields = /* @__PURE__ */
|
|
42
|
-
|
|
61
|
+
const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, { field: it }, it, false, {
|
|
62
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
63
|
+
lineNumber: 65,
|
|
64
|
+
columnNumber: 69
|
|
65
|
+
}, globalThis)) }, void 0, false, {
|
|
66
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
67
|
+
lineNumber: 65,
|
|
68
|
+
columnNumber: 28
|
|
69
|
+
}, globalThis);
|
|
70
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: [
|
|
43
71
|
additionalFields,
|
|
44
72
|
children
|
|
45
|
-
] }
|
|
73
|
+
] }, void 0, true, {
|
|
74
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
|
|
75
|
+
lineNumber: 67,
|
|
76
|
+
columnNumber: 10
|
|
77
|
+
}, globalThis);
|
|
46
78
|
},
|
|
47
79
|
"IfFilter"
|
|
48
80
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\n/**\n * @group Logic Components\n */\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":[],"mappings":";;;;;;;;;AA2BO,MAAM,KAAK;AAAA,EAAmB,CAAS,UAAA;
|
|
1
|
+
{"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\n/**\n * @group Logic Components\n */\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":["this"],"mappings":";;;;;;;;;AA2BO,MAAM,KAAK;AAAA,EAAmB,CAAS,UAAA;AACrC,WAAA,OAAO,MAAM,cAAc,aAC/B,uBAAC,YAAS,WAAW,MAAM,WAAY,UAAA,MAAM,SAA7C,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAA,UAAsD,IACrD,uBAAA,YAAA,EAAW,WAAW,MAAM,WAAY,gBAAM,SAA/C,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwD,GAAAA,UAAA;AAAA,EAC5D;AAAA,EACA;AACD;AAEA,MAAM,aAAa;AAAA,EAClB,CAAC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AAA,UAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,UAAA;AAEjG,WACE,uBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,IAAA,KAFK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGP,GAAAA,UAAA;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
2
|
import { Component } from "../coreComponents/Component.js";
|
|
3
3
|
const StaticRender = Component(
|
|
4
4
|
() => null,
|
|
5
|
-
({ children }) => /* @__PURE__ */
|
|
5
|
+
({ children }) => /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
|
|
6
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/StaticRender.tsx",
|
|
7
|
+
lineNumber: 13,
|
|
8
|
+
columnNumber: 20
|
|
9
|
+
}, globalThis),
|
|
6
10
|
"StaticRender"
|
|
7
11
|
);
|
|
8
12
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":[],"mappings":";;AAUO,MAAM,eAAe;AAAA,EAC3B,MAAM;AAAA,EACN,CAAC,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\n/**\n * @group Data binding\n */\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":["this"],"mappings":";;AAUO,MAAM,eAAe;AAAA,EAC3B,MAAM;AAAA,EACN,CAAC,EAAE,SAAS,yCAAS,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAY,GAAAA,UAAA;AAAA,EAC9B;AACD;"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { Component } from "../coreComponents/Component.js";
|
|
3
3
|
import { Field } from "../coreComponents/Field.js";
|
|
4
4
|
const SugaredField = Component((props) => {
|
|
5
5
|
if (typeof props.field === "string") {
|
|
6
|
-
return /* @__PURE__ */
|
|
6
|
+
return /* @__PURE__ */ jsxDEV(Field, { ...props, field: props.field }, void 0, false, {
|
|
7
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/SugaredField.tsx",
|
|
8
|
+
lineNumber: 15,
|
|
9
|
+
columnNumber: 10
|
|
10
|
+
}, globalThis);
|
|
7
11
|
}
|
|
8
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ jsxDEV(Field, { ...props, ...props.field }, void 0, false, {
|
|
13
|
+
fileName: "/__w/interface/interface/packages/binding/src/helperComponents/SugaredField.tsx",
|
|
14
|
+
lineNumber: 17,
|
|
15
|
+
columnNumber: 9
|
|
16
|
+
}, globalThis);
|
|
9
17
|
}, "SugaredField");
|
|
10
18
|
export {
|
|
11
19
|
SugaredField
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\n/**\n * @group Data binding\n */\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;AAYa,MAAA,eAAe,UAAU,CAA4C,UAAwC;AACrH,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC
|
|
1
|
+
{"version":3,"file":"SugaredField.js","sources":["../../../src/helperComponents/SugaredField.tsx"],"sourcesContent":["import { Component, Field, FieldProps } from '../coreComponents'\nimport type { SugaredRelativeSingleField } from '../treeParameters'\nimport { FieldValue } from '../treeParameters'\nimport { ReactElement } from 'react'\n\nexport interface SugaredFieldProps<Persisted extends FieldValue = FieldValue> extends Omit<FieldProps<Persisted>, 'field'> {\n\tfield: string | SugaredRelativeSingleField\n}\n\n/**\n * @group Data binding\n */\nexport const SugaredField = Component(<Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => {\n\tif (typeof props.field === 'string') {\n\t\treturn <Field {...props} field={props.field} />\n\t}\n\treturn <Field {...props} {...props.field} />\n}, 'SugaredField') as <Persisted extends FieldValue = FieldValue>(props: SugaredFieldProps<Persisted>) => ReactElement\n"],"names":["this"],"mappings":";;;AAYa,MAAA,eAAe,UAAU,CAA4C,UAAwC;AACrH,MAAA,OAAO,MAAM,UAAU,UAAU;AACpC,kCAAQ,OAAO,EAAA,GAAG,OAAO,OAAO,MAAM,MAA/B,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAsC,GAAAA,UAAA;AAAA,EAC9C;AACA,gCAAQ,OAAO,EAAA,GAAG,OAAQ,GAAG,MAAM,MAA5B,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAmC,GAAAA,UAAA;AAC3C,GAAG,cAAc;"}
|