@inixiative/json-rules 3.0.0 → 3.1.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 +41 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1130,6 +1130,47 @@ const projection = projectLens(narrowing, { sourceValues: [values] });
|
|
|
1130
1130
|
Options never offer a value the lens disallows: `projectLens` drops fetched values outside a
|
|
1131
1131
|
field's allowed set.
|
|
1132
1132
|
|
|
1133
|
+
#### Two kinds of source
|
|
1134
|
+
|
|
1135
|
+
A source declared down a relation path offers the rows **reachable** from there: every grant above
|
|
1136
|
+
it is carried down, so a Tag source under `User.tagAttachments.tag` offers the tags a live
|
|
1137
|
+
attachment of an in-tenant user points at. When a field should offer every row the lens lets its
|
|
1138
|
+
model show — linked or not, what a rule may *name* — point the path source at the model's own
|
|
1139
|
+
source:
|
|
1140
|
+
|
|
1141
|
+
```ts
|
|
1142
|
+
root: {
|
|
1143
|
+
where: { field: 'orgId', operator: Operator.equals, bind: 'orgId' },
|
|
1144
|
+
relations: {
|
|
1145
|
+
tagAttachments: {
|
|
1146
|
+
where: { field: 'deletedAt', operator: Operator.isEmpty },
|
|
1147
|
+
relations: { tag: { sources: { id: { from: 'mapDefaults' } } } }, // the model's own source
|
|
1148
|
+
},
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
mapDefaults: {
|
|
1152
|
+
app: {
|
|
1153
|
+
models: {
|
|
1154
|
+
Tag: {
|
|
1155
|
+
where: { field: 'deletedAt', operator: Operator.isEmpty },
|
|
1156
|
+
sources: {
|
|
1157
|
+
id: { where: { field: 'ownerId', operator: Operator.equals, bind: 'orgId' }, label: 'name' },
|
|
1158
|
+
},
|
|
1159
|
+
},
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
},
|
|
1163
|
+
```
|
|
1164
|
+
|
|
1165
|
+
`from: 'mapDefaults'` resolves where it sits — `mapDefaults[<this path's map>].models[<this path's
|
|
1166
|
+
model>].sources[<field>]` — and takes that source's eligibility (tenancy included), label and
|
|
1167
|
+
axes; its own `where`, and child layers, only narrow it. Nothing is carried from the path above.
|
|
1168
|
+
A pointer whose model declares no source fails `validateNarrowing` (`invalid_source`) and throws
|
|
1169
|
+
from `projectLens` / `toSourceQueries`. Across a bridge it is how a picker gets options at all: the
|
|
1170
|
+
model source compiles against the far map alone, with that map's own tenancy, where a path source
|
|
1171
|
+
offers nothing. `materializeSources` refuses a pointer — a fetched collection can't hold unlinked
|
|
1172
|
+
rows; query it with `toSourceQueries` and `materializeSourceQuery`.
|
|
1173
|
+
|
|
1133
1174
|
### Evaluating Across Bridges
|
|
1134
1175
|
|
|
1135
1176
|
`path:` refs (used for value comparisons) walk via the same dotted-path mechanism as `field:`. Bridge keys (`'salesforce:Contact'`) are just plain object properties, so `path: 'salesforce:Contact.industry'` works in both `field:` (left side) and `path:` (right side) positions.
|