@spotto/semantic-query 1.0.70-alpha.41 → 1.0.70-alpha.42
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/dates.d.ts +32 -32
- package/dist/dates.js +104 -104
- package/dist/evaluate.d.ts +35 -35
- package/dist/evaluate.js +587 -587
- package/dist/fixtures.d.ts +277 -277
- package/dist/fixtures.js +175 -175
- package/dist/index.d.ts +33 -33
- package/dist/index.js +49 -49
- package/dist/resolve-name.d.ts +9 -9
- package/dist/resolve-name.js +90 -90
- package/dist/rules-fixtures.d.ts +673 -673
- package/dist/rules-fixtures.js +405 -405
- package/dist/rules.d.ts +180 -180
- package/dist/rules.js +321 -321
- package/dist/suggest.d.ts +12 -12
- package/dist/suggest.js +69 -69
- package/dist/types.d.ts +111 -111
- package/dist/types.js +23 -23
- package/dist/validate.d.ts +33 -33
- package/dist/validate.js +822 -822
- package/package.json +3 -3
package/dist/rules-fixtures.js
CHANGED
|
@@ -1,406 +1,406 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RULE_OPTS = exports.RULE_CALLERS = exports.RULE_CORPUS = exports.RULE_ASSETS = exports.ALBURY_NULL_TOOL = exports.DUBBO_LOGISTICS_POWER_TOOL = exports.ALBURY_OPS_TROLLEY = exports.PERTH_OPS_TOOL = exports.SYDNEY_VEHICLE = exports.SYDNEYSIDE_TOOL = exports.PERTH_TROLLEY = exports.ALBURY_POWER_TOOL = exports.VISITING_TOOL = exports.DUBBO_TROLLEY = exports.SYDNEY_TOOL = exports.RULE_GROUPS = exports.DANGLING_FILTER = exports.EMPTY_RULES = exports.ALL_USERS = exports.TOOL_EDITORS = exports.SERIAL_READERS = exports.OPERATIONS_VIEWERS = exports.SYDNEY_EDITORS = exports.RULE_GROUP_IDS = exports.RULE_SCHEMA = exports.RULE_ACTIONS = exports.RULE_LOCATIONS = exports.RULE_TYPE_PATHS = exports.RULE_TYPES = exports.RULE_FIELD_DEFS = exports.RULE_FIELDS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The rules conformance cast: the groups, assets and callers of the
|
|
6
|
-
* specification's appendix A, plus the cases the appendix leaves to the
|
|
7
|
-
* reader. Shipped on its own entry point (`@spotto/semantic-query/dist/rules-fixtures`)
|
|
8
|
-
* beside the language corpus, for the same reason: the server's compiler spec
|
|
9
|
-
* pins its Mongo against these documents and the client's equivalence test
|
|
10
|
-
* executes its SQL over them, so a scenario means the same thing at every
|
|
11
|
-
* layer.
|
|
12
|
-
*
|
|
13
|
-
* Every document states beside it why it exists. The hand-derived truth
|
|
14
|
-
* table lives in `rules.spec.ts`, so that the oracle is proven by hand once
|
|
15
|
-
* and the back-ends are proven against the oracle.
|
|
16
|
-
*/
|
|
17
|
-
exports.RULE_FIELDS = {
|
|
18
|
-
BATTERY_GOOD: 'eeeeeeeeeeeeeeeeeeeeee01',
|
|
19
|
-
BRAND: 'eeeeeeeeeeeeeeeeeeeeee02',
|
|
20
|
-
COST: 'eeeeeeeeeeeeeeeeeeeeee03',
|
|
21
|
-
SERIAL: 'eeeeeeeeeeeeeeeeeeeeee04',
|
|
22
|
-
BUSINESS_UNIT: 'eeeeeeeeeeeeeeeeeeeeee05',
|
|
23
|
-
/** A CHECKBOXES field, present so the write-time refusal of a multi-select filter has something to refuse. */
|
|
24
|
-
CERTIFICATIONS: 'eeeeeeeeeeeeeeeeeeeeee06',
|
|
25
|
-
};
|
|
26
|
-
exports.RULE_FIELD_DEFS = [
|
|
27
|
-
{ id: exports.RULE_FIELDS.BATTERY_GOOD, name: 'Battery Good', dataType: 'BOOLEAN' },
|
|
28
|
-
{ id: exports.RULE_FIELDS.BRAND, name: 'Brand', dataType: 'STRING' },
|
|
29
|
-
{ id: exports.RULE_FIELDS.COST, name: 'Cost', dataType: 'DECIMAL' },
|
|
30
|
-
{ id: exports.RULE_FIELDS.SERIAL, name: 'Serial Number', dataType: 'STRING' },
|
|
31
|
-
{
|
|
32
|
-
id: exports.RULE_FIELDS.BUSINESS_UNIT,
|
|
33
|
-
name: 'Business Unit',
|
|
34
|
-
dataType: 'STRING',
|
|
35
|
-
inputType: 'DROPDOWN',
|
|
36
|
-
options: ['Operations', 'Logistics', 'Finance'],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: exports.RULE_FIELDS.CERTIFICATIONS,
|
|
40
|
-
name: 'Certifications',
|
|
41
|
-
dataType: 'STRING',
|
|
42
|
-
inputType: 'CHECKBOXES',
|
|
43
|
-
options: ['Electrical', 'Height'],
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
exports.RULE_TYPES = {
|
|
47
|
-
TOOLS: 'dddddddddddddddddddddd01',
|
|
48
|
-
/** Nested under Tools, and carries Business Unit = Operations at the TYPE level. */
|
|
49
|
-
POWER_TOOLS: 'dddddddddddddddddddddd02',
|
|
50
|
-
TROLLEYS: 'dddddddddddddddddddddd03',
|
|
51
|
-
VEHICLES: 'dddddddddddddddddddddd04',
|
|
52
|
-
};
|
|
53
|
-
exports.RULE_TYPE_PATHS = {
|
|
54
|
-
TOOLS: 'Tools|',
|
|
55
|
-
POWER_TOOLS: 'Tools|Power tools|',
|
|
56
|
-
TROLLEYS: 'Trolleys|',
|
|
57
|
-
VEHICLES: 'Vehicles|',
|
|
58
|
-
};
|
|
59
|
-
exports.RULE_LOCATIONS = {
|
|
60
|
-
SYDNEY: 'Eastern|Sydney|',
|
|
61
|
-
SYDNEY_BAY: 'Eastern|Sydney|Bay 1|',
|
|
62
|
-
ALBURY: 'Eastern|Albury|',
|
|
63
|
-
DUBBO: 'Eastern|Dubbo|',
|
|
64
|
-
PERTH: 'Western|Perth|',
|
|
65
|
-
/** The sibling trap: shares the prefix of Sydney up to the pipe. */
|
|
66
|
-
SYDNEYSIDE: 'Eastern|Sydneyside|',
|
|
67
|
-
};
|
|
68
|
-
exports.RULE_ACTIONS = {
|
|
69
|
-
REPORT_DAMAGE: 'cccccccccccccccccccccc01',
|
|
70
|
-
DECOMMISSION: 'cccccccccccccccccccccc02',
|
|
71
|
-
/** Targets locations, so it attaches to no type. */
|
|
72
|
-
AUDIT_LOCATION: 'cccccccccccccccccccccc03',
|
|
73
|
-
};
|
|
74
|
-
exports.RULE_SCHEMA = {
|
|
75
|
-
fields: exports.RULE_FIELD_DEFS.map(({ id, name, dataType, options }) => options ? { id, name, dataType, options } : { id, name, dataType }),
|
|
76
|
-
types: [
|
|
77
|
-
{ id: exports.RULE_TYPES.TOOLS, path: exports.RULE_TYPE_PATHS.TOOLS, typeFieldValuesAll: [] },
|
|
78
|
-
{
|
|
79
|
-
id: exports.RULE_TYPES.POWER_TOOLS,
|
|
80
|
-
path: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
81
|
-
typeFieldValuesAll: [
|
|
82
|
-
{ _id: exports.RULE_FIELDS.BUSINESS_UNIT, name: 'Business Unit', valueString: 'Operations' },
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
{ id: exports.RULE_TYPES.TROLLEYS, path: exports.RULE_TYPE_PATHS.TROLLEYS, typeFieldValuesAll: [] },
|
|
86
|
-
{ id: exports.RULE_TYPES.VEHICLES, path: exports.RULE_TYPE_PATHS.VEHICLES, typeFieldValuesAll: [] },
|
|
87
|
-
],
|
|
88
|
-
};
|
|
89
|
-
// ---------------------------------------------------------------------------
|
|
90
|
-
// Groups: appendix A, plus the shapes the appendix does not show
|
|
91
|
-
// ---------------------------------------------------------------------------
|
|
92
|
-
exports.RULE_GROUP_IDS = {
|
|
93
|
-
SYDNEY_EDITORS: 'bbbbbbbbbbbbbbbbbbbbbb01',
|
|
94
|
-
OPERATIONS_VIEWERS: 'bbbbbbbbbbbbbbbbbbbbbb02',
|
|
95
|
-
SERIAL_READERS: 'bbbbbbbbbbbbbbbbbbbbbb03',
|
|
96
|
-
TOOL_EDITORS: 'bbbbbbbbbbbbbbbbbbbbbb04',
|
|
97
|
-
ALL_USERS: 'bbbbbbbbbbbbbbbbbbbbbb05',
|
|
98
|
-
EMPTY_RULES: 'bbbbbbbbbbbbbbbbbbbbbb06',
|
|
99
|
-
DANGLING_FILTER: 'bbbbbbbbbbbbbbbbbbbbbb07',
|
|
100
|
-
};
|
|
101
|
-
/** EDIT on the Sydney subtree, any type. Battery Good EDIT, Brand VIEW. All actions. */
|
|
102
|
-
exports.SYDNEY_EDITORS = {
|
|
103
|
-
id: exports.RULE_GROUP_IDS.SYDNEY_EDITORS,
|
|
104
|
-
name: 'Sydney editors',
|
|
105
|
-
assetAccessRules: [
|
|
106
|
-
{
|
|
107
|
-
id: 'rule-sydney-editors',
|
|
108
|
-
level: 'EDIT',
|
|
109
|
-
conditions: {
|
|
110
|
-
locations: { mode: 'SELECTED', paths: [exports.RULE_LOCATIONS.SYDNEY] },
|
|
111
|
-
assetTypes: { mode: 'ALL' },
|
|
112
|
-
customFields: [],
|
|
113
|
-
},
|
|
114
|
-
fieldAccess: {
|
|
115
|
-
mode: 'SELECTED',
|
|
116
|
-
fields: [
|
|
117
|
-
{ fieldId: exports.RULE_FIELDS.BATTERY_GOOD, level: 'EDIT' },
|
|
118
|
-
{ fieldId: exports.RULE_FIELDS.BRAND, level: 'VIEW' },
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
actionAccess: { mode: 'ALL' },
|
|
124
|
-
};
|
|
125
|
-
/** VIEW on every asset whose Business Unit is Operations, own or type-level. All fields VIEW. Report damage only. */
|
|
126
|
-
exports.OPERATIONS_VIEWERS = {
|
|
127
|
-
id: exports.RULE_GROUP_IDS.OPERATIONS_VIEWERS,
|
|
128
|
-
name: 'Operations viewers',
|
|
129
|
-
assetAccessRules: [
|
|
130
|
-
{
|
|
131
|
-
id: 'rule-operations-viewers',
|
|
132
|
-
level: 'VIEW',
|
|
133
|
-
conditions: {
|
|
134
|
-
locations: { mode: 'ALL' },
|
|
135
|
-
assetTypes: { mode: 'ALL' },
|
|
136
|
-
customFields: [
|
|
137
|
-
{ fieldId: exports.RULE_FIELDS.BUSINESS_UNIT, operator: 'IN', values: ['Operations'] },
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
fieldAccess: { mode: 'ALL', level: 'VIEW' },
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
actionAccess: { mode: 'SELECTED', actions: [exports.RULE_ACTIONS.REPORT_DAMAGE] },
|
|
144
|
-
};
|
|
145
|
-
/** Rule-less: Serial Number VIEW on anything a member can open. No actions. */
|
|
146
|
-
exports.SERIAL_READERS = {
|
|
147
|
-
id: exports.RULE_GROUP_IDS.SERIAL_READERS,
|
|
148
|
-
name: 'Serial readers',
|
|
149
|
-
assetAccessRules: [
|
|
150
|
-
{
|
|
151
|
-
id: 'rule-serial-readers',
|
|
152
|
-
fieldAccess: { mode: 'SELECTED', fields: [{ fieldId: exports.RULE_FIELDS.SERIAL, level: 'VIEW' }] },
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
actionAccess: { mode: 'SELECTED', actions: [] },
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* EDIT on Tools, subtypes included, at Albury or Perth: two selected paths
|
|
159
|
-
* AND a selected type, so a Perth trolley and a Dubbo tool both miss. All
|
|
160
|
-
* fields EDIT. Decommission only.
|
|
161
|
-
*/
|
|
162
|
-
exports.TOOL_EDITORS = {
|
|
163
|
-
id: exports.RULE_GROUP_IDS.TOOL_EDITORS,
|
|
164
|
-
name: 'Tool editors',
|
|
165
|
-
assetAccessRules: [
|
|
166
|
-
{
|
|
167
|
-
id: 'rule-tool-editors',
|
|
168
|
-
level: 'EDIT',
|
|
169
|
-
conditions: {
|
|
170
|
-
locations: { mode: 'SELECTED', paths: [exports.RULE_LOCATIONS.ALBURY, exports.RULE_LOCATIONS.PERTH] },
|
|
171
|
-
assetTypes: { mode: 'SELECTED', paths: [exports.RULE_TYPE_PATHS.TOOLS] },
|
|
172
|
-
},
|
|
173
|
-
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
actionAccess: { mode: 'SELECTED', actions: [exports.RULE_ACTIONS.DECOMMISSION] },
|
|
177
|
-
};
|
|
178
|
-
/** The bootstrap shape: unlimited at EDIT, every field EDIT, every action. */
|
|
179
|
-
exports.ALL_USERS = {
|
|
180
|
-
id: exports.RULE_GROUP_IDS.ALL_USERS,
|
|
181
|
-
name: 'All users',
|
|
182
|
-
assetAccessRules: [
|
|
183
|
-
{
|
|
184
|
-
id: 'rule-all-users',
|
|
185
|
-
level: 'EDIT',
|
|
186
|
-
conditions: {
|
|
187
|
-
locations: { mode: 'ALL' },
|
|
188
|
-
assetTypes: { mode: 'ALL' },
|
|
189
|
-
customFields: [],
|
|
190
|
-
},
|
|
191
|
-
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
actionAccess: { mode: 'ALL' },
|
|
195
|
-
};
|
|
196
|
-
/** A group with no rule at all: valid for a home layout or an SSO mapping, grants nothing. */
|
|
197
|
-
exports.EMPTY_RULES = {
|
|
198
|
-
id: exports.RULE_GROUP_IDS.EMPTY_RULES,
|
|
199
|
-
name: 'Layout only',
|
|
200
|
-
assetAccessRules: [],
|
|
201
|
-
};
|
|
202
|
-
/** A filter on a field the catalogue does not hold: the rule grants nothing, never everything. */
|
|
203
|
-
exports.DANGLING_FILTER = {
|
|
204
|
-
id: exports.RULE_GROUP_IDS.DANGLING_FILTER,
|
|
205
|
-
name: 'Dangling filter',
|
|
206
|
-
assetAccessRules: [
|
|
207
|
-
{
|
|
208
|
-
id: 'rule-dangling',
|
|
209
|
-
level: 'EDIT',
|
|
210
|
-
conditions: {
|
|
211
|
-
locations: { mode: 'ALL' },
|
|
212
|
-
assetTypes: { mode: 'ALL' },
|
|
213
|
-
customFields: [{ fieldId: 'eeeeeeeeeeeeeeeeeeeeee99', operator: 'IN', values: ['x'] }],
|
|
214
|
-
},
|
|
215
|
-
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
actionAccess: { mode: 'ALL' },
|
|
219
|
-
};
|
|
220
|
-
exports.RULE_GROUPS = {
|
|
221
|
-
SYDNEY_EDITORS: exports.SYDNEY_EDITORS,
|
|
222
|
-
OPERATIONS_VIEWERS: exports.OPERATIONS_VIEWERS,
|
|
223
|
-
SERIAL_READERS: exports.SERIAL_READERS,
|
|
224
|
-
TOOL_EDITORS: exports.TOOL_EDITORS,
|
|
225
|
-
ALL_USERS: exports.ALL_USERS,
|
|
226
|
-
EMPTY_RULES: exports.EMPTY_RULES,
|
|
227
|
-
DANGLING_FILTER: exports.DANGLING_FILTER,
|
|
228
|
-
};
|
|
229
|
-
// ---------------------------------------------------------------------------
|
|
230
|
-
// Assets, in the server's document shape the evaluator reads
|
|
231
|
-
// ---------------------------------------------------------------------------
|
|
232
|
-
const value = (id, name, slot) => (Object.assign({ _id: id, name }, slot));
|
|
233
|
-
/** Appendix asset A: a Sydney tool in Operations, scanned at home. Sydney editors EDIT and Operations viewers VIEW both match. */
|
|
234
|
-
exports.SYDNEY_TOOL = {
|
|
235
|
-
_id: 'ffffffffffffffffffffff01',
|
|
236
|
-
name: 'Sydney tool',
|
|
237
|
-
typeId: exports.RULE_TYPES.TOOLS,
|
|
238
|
-
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
239
|
-
homeLocationPath: exports.RULE_LOCATIONS.SYDNEY,
|
|
240
|
-
state: { locationName: exports.RULE_LOCATIONS.SYDNEY_BAY, locationStatus: 'HOME' },
|
|
241
|
-
fieldValues: [
|
|
242
|
-
value(exports.RULE_FIELDS.BATTERY_GOOD, 'Battery Good', { valueBoolean: true }),
|
|
243
|
-
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Makita' }),
|
|
244
|
-
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 120.5 }),
|
|
245
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-001' }),
|
|
246
|
-
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
247
|
-
],
|
|
248
|
-
};
|
|
249
|
-
/** Appendix asset B: a Dubbo trolley in Logistics. No group matches. */
|
|
250
|
-
exports.DUBBO_TROLLEY = {
|
|
251
|
-
_id: 'ffffffffffffffffffffff02',
|
|
252
|
-
name: 'Dubbo trolley',
|
|
253
|
-
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
254
|
-
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
255
|
-
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
256
|
-
state: { locationName: exports.RULE_LOCATIONS.DUBBO, locationStatus: 'HOME' },
|
|
257
|
-
fieldValues: [
|
|
258
|
-
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Generic' }),
|
|
259
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-002' }),
|
|
260
|
-
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Logistics' }),
|
|
261
|
-
],
|
|
262
|
-
};
|
|
263
|
-
/** Appendix asset C: a tool homed in Dubbo, no business unit, currently scanned in Sydney. Sydney editors match through the current location. */
|
|
264
|
-
exports.VISITING_TOOL = {
|
|
265
|
-
_id: 'ffffffffffffffffffffff03',
|
|
266
|
-
name: 'Visiting tool',
|
|
267
|
-
typeId: exports.RULE_TYPES.TOOLS,
|
|
268
|
-
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
269
|
-
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
270
|
-
state: { locationName: exports.RULE_LOCATIONS.SYDNEY, locationStatus: 'AWAY' },
|
|
271
|
-
fieldValues: [
|
|
272
|
-
value(exports.RULE_FIELDS.BATTERY_GOOD, 'Battery Good', { valueBoolean: false }),
|
|
273
|
-
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Bosch' }),
|
|
274
|
-
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 80 }),
|
|
275
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-003' }),
|
|
276
|
-
],
|
|
277
|
-
};
|
|
278
|
-
/** A power tool at Albury, never scanned, with no business unit of its own: Operations viewers match through the TYPE-level value, Tool editors through Albury and the Tools prefix. */
|
|
279
|
-
exports.ALBURY_POWER_TOOL = {
|
|
280
|
-
_id: 'ffffffffffffffffffffff04',
|
|
281
|
-
name: 'Albury power tool',
|
|
282
|
-
typeId: exports.RULE_TYPES.POWER_TOOLS,
|
|
283
|
-
typePath: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
284
|
-
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
285
|
-
fieldValues: [
|
|
286
|
-
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'DeWalt' }),
|
|
287
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-004' }),
|
|
288
|
-
],
|
|
289
|
-
};
|
|
290
|
-
/** A Perth trolley with nothing set: Tool editors miss on the type, nobody else reaches Perth. */
|
|
291
|
-
exports.PERTH_TROLLEY = {
|
|
292
|
-
_id: 'ffffffffffffffffffffff05',
|
|
293
|
-
name: 'Perth trolley',
|
|
294
|
-
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
295
|
-
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
296
|
-
homeLocationPath: exports.RULE_LOCATIONS.PERTH,
|
|
297
|
-
fieldValues: [],
|
|
298
|
-
};
|
|
299
|
-
/** The sibling trap: homed at Sydneyside, which shares Sydney's prefix up to the pipe. Must stay hidden from Sydney editors. */
|
|
300
|
-
exports.SYDNEYSIDE_TOOL = {
|
|
301
|
-
_id: 'ffffffffffffffffffffff06',
|
|
302
|
-
name: 'Sydneyside tool',
|
|
303
|
-
typeId: exports.RULE_TYPES.TOOLS,
|
|
304
|
-
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
305
|
-
homeLocationPath: exports.RULE_LOCATIONS.SYDNEYSIDE,
|
|
306
|
-
state: { locationName: exports.RULE_LOCATIONS.SYDNEYSIDE, locationStatus: 'HOME' },
|
|
307
|
-
fieldValues: [
|
|
308
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-006' }),
|
|
309
|
-
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Finance' }),
|
|
310
|
-
],
|
|
311
|
-
};
|
|
312
|
-
/** A Sydney vehicle never scanned: Sydney editors match through the home alone. */
|
|
313
|
-
exports.SYDNEY_VEHICLE = {
|
|
314
|
-
_id: 'ffffffffffffffffffffff07',
|
|
315
|
-
name: 'Sydney vehicle',
|
|
316
|
-
typeId: exports.RULE_TYPES.VEHICLES,
|
|
317
|
-
typePath: exports.RULE_TYPE_PATHS.VEHICLES,
|
|
318
|
-
homeLocationPath: exports.RULE_LOCATIONS.SYDNEY,
|
|
319
|
-
fieldValues: [value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-007' })],
|
|
320
|
-
};
|
|
321
|
-
/** A Perth tool in Operations: Operations viewers VIEW and Tool editors EDIT, so EDIT wins. */
|
|
322
|
-
exports.PERTH_OPS_TOOL = {
|
|
323
|
-
_id: 'ffffffffffffffffffffff08',
|
|
324
|
-
name: 'Perth ops tool',
|
|
325
|
-
typeId: exports.RULE_TYPES.TOOLS,
|
|
326
|
-
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
327
|
-
homeLocationPath: exports.RULE_LOCATIONS.PERTH,
|
|
328
|
-
state: { locationName: exports.RULE_LOCATIONS.PERTH, locationStatus: 'HOME' },
|
|
329
|
-
fieldValues: [
|
|
330
|
-
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 300 }),
|
|
331
|
-
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-008' }),
|
|
332
|
-
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
333
|
-
],
|
|
334
|
-
};
|
|
335
|
-
/** An Albury trolley in Operations: Operations viewers alone, so VIEW, and the VIEW cap on every field. */
|
|
336
|
-
exports.ALBURY_OPS_TROLLEY = {
|
|
337
|
-
_id: 'ffffffffffffffffffffff09',
|
|
338
|
-
name: 'Albury ops trolley',
|
|
339
|
-
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
340
|
-
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
341
|
-
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
342
|
-
fieldValues: [
|
|
343
|
-
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Generic' }),
|
|
344
|
-
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 50 }),
|
|
345
|
-
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
346
|
-
],
|
|
347
|
-
};
|
|
348
|
-
/** A Dubbo power tool whose OWN business unit is Logistics while its type says Operations: either value matches, so Operations viewers see it. */
|
|
349
|
-
exports.DUBBO_LOGISTICS_POWER_TOOL = {
|
|
350
|
-
_id: 'ffffffffffffffffffffff10',
|
|
351
|
-
name: 'Dubbo logistics power tool',
|
|
352
|
-
typeId: exports.RULE_TYPES.POWER_TOOLS,
|
|
353
|
-
typePath: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
354
|
-
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
355
|
-
fieldValues: [value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Logistics' })],
|
|
356
|
-
};
|
|
357
|
-
/** An Albury tool whose business unit slot is present but null: unset, so Operations viewers miss, while Tool editors match. */
|
|
358
|
-
exports.ALBURY_NULL_TOOL = {
|
|
359
|
-
_id: 'ffffffffffffffffffffff11',
|
|
360
|
-
name: 'Albury null tool',
|
|
361
|
-
typeId: exports.RULE_TYPES.TOOLS,
|
|
362
|
-
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
363
|
-
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
364
|
-
state: { locationName: exports.RULE_LOCATIONS.ALBURY, locationStatus: 'HOME' },
|
|
365
|
-
fieldValues: [value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: null })],
|
|
366
|
-
};
|
|
367
|
-
exports.RULE_ASSETS = {
|
|
368
|
-
SYDNEY_TOOL: exports.SYDNEY_TOOL,
|
|
369
|
-
DUBBO_TROLLEY: exports.DUBBO_TROLLEY,
|
|
370
|
-
VISITING_TOOL: exports.VISITING_TOOL,
|
|
371
|
-
ALBURY_POWER_TOOL: exports.ALBURY_POWER_TOOL,
|
|
372
|
-
PERTH_TROLLEY: exports.PERTH_TROLLEY,
|
|
373
|
-
SYDNEYSIDE_TOOL: exports.SYDNEYSIDE_TOOL,
|
|
374
|
-
SYDNEY_VEHICLE: exports.SYDNEY_VEHICLE,
|
|
375
|
-
PERTH_OPS_TOOL: exports.PERTH_OPS_TOOL,
|
|
376
|
-
ALBURY_OPS_TROLLEY: exports.ALBURY_OPS_TROLLEY,
|
|
377
|
-
DUBBO_LOGISTICS_POWER_TOOL: exports.DUBBO_LOGISTICS_POWER_TOOL,
|
|
378
|
-
ALBURY_NULL_TOOL: exports.ALBURY_NULL_TOOL,
|
|
379
|
-
};
|
|
380
|
-
exports.RULE_CORPUS = Object.values(exports.RULE_ASSETS);
|
|
381
|
-
// ---------------------------------------------------------------------------
|
|
382
|
-
// Callers: the personas the model distinguishes
|
|
383
|
-
// ---------------------------------------------------------------------------
|
|
384
|
-
const definedCallers = {
|
|
385
|
-
/** The appendix user: a member of all three appendix groups. */
|
|
386
|
-
ALL_THREE: { groups: [exports.SYDNEY_EDITORS, exports.OPERATIONS_VIEWERS, exports.SERIAL_READERS] },
|
|
387
|
-
OPERATIONS_ONLY: { groups: [exports.OPERATIONS_VIEWERS] },
|
|
388
|
-
SERIAL_ONLY: { groups: [exports.SERIAL_READERS] },
|
|
389
|
-
TOOL_EDITORS_ONLY: { groups: [exports.TOOL_EDITORS] },
|
|
390
|
-
NO_GROUP: { groups: [] },
|
|
391
|
-
BOOTSTRAP_ONLY: { groups: [exports.ALL_USERS] },
|
|
392
|
-
/** An Admin: the field and action bypasses, confined to Sydney by their one group. */
|
|
393
|
-
ADMIN: { fieldsAdmin: true, actionsAdmin: true, groups: [exports.SYDNEY_EDITORS] },
|
|
394
|
-
/** A System Admin: exempt from asset rules, with both bypasses, in no group. */
|
|
395
|
-
SYSTEM_ADMIN: { exempt: true, fieldsAdmin: true, actionsAdmin: true, groups: [] },
|
|
396
|
-
/** Exempt without the bypasses: every asset, but only the fields and actions the groups grant. */
|
|
397
|
-
EXEMPT_ONLY: { exempt: true, groups: [exports.OPERATIONS_VIEWERS] },
|
|
398
|
-
/** An API-key request: open on every axis, whatever its user record holds. */
|
|
399
|
-
API_KEY: { open: true, groups: [exports.SERIAL_READERS] },
|
|
400
|
-
LAYOUT_ONLY: { groups: [exports.EMPTY_RULES] },
|
|
401
|
-
DANGLING_ONLY: { groups: [exports.DANGLING_FILTER] },
|
|
402
|
-
};
|
|
403
|
-
exports.RULE_CALLERS = definedCallers;
|
|
404
|
-
/** Frozen clock, as the language corpus has: nothing here is date-sensitive, but the evaluator takes one. */
|
|
405
|
-
exports.RULE_OPTS = { now: new Date('2026-10-15T00:00:00Z'), timeZone: 'Australia/Sydney' };
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULE_OPTS = exports.RULE_CALLERS = exports.RULE_CORPUS = exports.RULE_ASSETS = exports.ALBURY_NULL_TOOL = exports.DUBBO_LOGISTICS_POWER_TOOL = exports.ALBURY_OPS_TROLLEY = exports.PERTH_OPS_TOOL = exports.SYDNEY_VEHICLE = exports.SYDNEYSIDE_TOOL = exports.PERTH_TROLLEY = exports.ALBURY_POWER_TOOL = exports.VISITING_TOOL = exports.DUBBO_TROLLEY = exports.SYDNEY_TOOL = exports.RULE_GROUPS = exports.DANGLING_FILTER = exports.EMPTY_RULES = exports.ALL_USERS = exports.TOOL_EDITORS = exports.SERIAL_READERS = exports.OPERATIONS_VIEWERS = exports.SYDNEY_EDITORS = exports.RULE_GROUP_IDS = exports.RULE_SCHEMA = exports.RULE_ACTIONS = exports.RULE_LOCATIONS = exports.RULE_TYPE_PATHS = exports.RULE_TYPES = exports.RULE_FIELD_DEFS = exports.RULE_FIELDS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The rules conformance cast: the groups, assets and callers of the
|
|
6
|
+
* specification's appendix A, plus the cases the appendix leaves to the
|
|
7
|
+
* reader. Shipped on its own entry point (`@spotto/semantic-query/dist/rules-fixtures`)
|
|
8
|
+
* beside the language corpus, for the same reason: the server's compiler spec
|
|
9
|
+
* pins its Mongo against these documents and the client's equivalence test
|
|
10
|
+
* executes its SQL over them, so a scenario means the same thing at every
|
|
11
|
+
* layer.
|
|
12
|
+
*
|
|
13
|
+
* Every document states beside it why it exists. The hand-derived truth
|
|
14
|
+
* table lives in `rules.spec.ts`, so that the oracle is proven by hand once
|
|
15
|
+
* and the back-ends are proven against the oracle.
|
|
16
|
+
*/
|
|
17
|
+
exports.RULE_FIELDS = {
|
|
18
|
+
BATTERY_GOOD: 'eeeeeeeeeeeeeeeeeeeeee01',
|
|
19
|
+
BRAND: 'eeeeeeeeeeeeeeeeeeeeee02',
|
|
20
|
+
COST: 'eeeeeeeeeeeeeeeeeeeeee03',
|
|
21
|
+
SERIAL: 'eeeeeeeeeeeeeeeeeeeeee04',
|
|
22
|
+
BUSINESS_UNIT: 'eeeeeeeeeeeeeeeeeeeeee05',
|
|
23
|
+
/** A CHECKBOXES field, present so the write-time refusal of a multi-select filter has something to refuse. */
|
|
24
|
+
CERTIFICATIONS: 'eeeeeeeeeeeeeeeeeeeeee06',
|
|
25
|
+
};
|
|
26
|
+
exports.RULE_FIELD_DEFS = [
|
|
27
|
+
{ id: exports.RULE_FIELDS.BATTERY_GOOD, name: 'Battery Good', dataType: 'BOOLEAN' },
|
|
28
|
+
{ id: exports.RULE_FIELDS.BRAND, name: 'Brand', dataType: 'STRING' },
|
|
29
|
+
{ id: exports.RULE_FIELDS.COST, name: 'Cost', dataType: 'DECIMAL' },
|
|
30
|
+
{ id: exports.RULE_FIELDS.SERIAL, name: 'Serial Number', dataType: 'STRING' },
|
|
31
|
+
{
|
|
32
|
+
id: exports.RULE_FIELDS.BUSINESS_UNIT,
|
|
33
|
+
name: 'Business Unit',
|
|
34
|
+
dataType: 'STRING',
|
|
35
|
+
inputType: 'DROPDOWN',
|
|
36
|
+
options: ['Operations', 'Logistics', 'Finance'],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: exports.RULE_FIELDS.CERTIFICATIONS,
|
|
40
|
+
name: 'Certifications',
|
|
41
|
+
dataType: 'STRING',
|
|
42
|
+
inputType: 'CHECKBOXES',
|
|
43
|
+
options: ['Electrical', 'Height'],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
exports.RULE_TYPES = {
|
|
47
|
+
TOOLS: 'dddddddddddddddddddddd01',
|
|
48
|
+
/** Nested under Tools, and carries Business Unit = Operations at the TYPE level. */
|
|
49
|
+
POWER_TOOLS: 'dddddddddddddddddddddd02',
|
|
50
|
+
TROLLEYS: 'dddddddddddddddddddddd03',
|
|
51
|
+
VEHICLES: 'dddddddddddddddddddddd04',
|
|
52
|
+
};
|
|
53
|
+
exports.RULE_TYPE_PATHS = {
|
|
54
|
+
TOOLS: 'Tools|',
|
|
55
|
+
POWER_TOOLS: 'Tools|Power tools|',
|
|
56
|
+
TROLLEYS: 'Trolleys|',
|
|
57
|
+
VEHICLES: 'Vehicles|',
|
|
58
|
+
};
|
|
59
|
+
exports.RULE_LOCATIONS = {
|
|
60
|
+
SYDNEY: 'Eastern|Sydney|',
|
|
61
|
+
SYDNEY_BAY: 'Eastern|Sydney|Bay 1|',
|
|
62
|
+
ALBURY: 'Eastern|Albury|',
|
|
63
|
+
DUBBO: 'Eastern|Dubbo|',
|
|
64
|
+
PERTH: 'Western|Perth|',
|
|
65
|
+
/** The sibling trap: shares the prefix of Sydney up to the pipe. */
|
|
66
|
+
SYDNEYSIDE: 'Eastern|Sydneyside|',
|
|
67
|
+
};
|
|
68
|
+
exports.RULE_ACTIONS = {
|
|
69
|
+
REPORT_DAMAGE: 'cccccccccccccccccccccc01',
|
|
70
|
+
DECOMMISSION: 'cccccccccccccccccccccc02',
|
|
71
|
+
/** Targets locations, so it attaches to no type. */
|
|
72
|
+
AUDIT_LOCATION: 'cccccccccccccccccccccc03',
|
|
73
|
+
};
|
|
74
|
+
exports.RULE_SCHEMA = {
|
|
75
|
+
fields: exports.RULE_FIELD_DEFS.map(({ id, name, dataType, options }) => options ? { id, name, dataType, options } : { id, name, dataType }),
|
|
76
|
+
types: [
|
|
77
|
+
{ id: exports.RULE_TYPES.TOOLS, path: exports.RULE_TYPE_PATHS.TOOLS, typeFieldValuesAll: [] },
|
|
78
|
+
{
|
|
79
|
+
id: exports.RULE_TYPES.POWER_TOOLS,
|
|
80
|
+
path: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
81
|
+
typeFieldValuesAll: [
|
|
82
|
+
{ _id: exports.RULE_FIELDS.BUSINESS_UNIT, name: 'Business Unit', valueString: 'Operations' },
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{ id: exports.RULE_TYPES.TROLLEYS, path: exports.RULE_TYPE_PATHS.TROLLEYS, typeFieldValuesAll: [] },
|
|
86
|
+
{ id: exports.RULE_TYPES.VEHICLES, path: exports.RULE_TYPE_PATHS.VEHICLES, typeFieldValuesAll: [] },
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Groups: appendix A, plus the shapes the appendix does not show
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
exports.RULE_GROUP_IDS = {
|
|
93
|
+
SYDNEY_EDITORS: 'bbbbbbbbbbbbbbbbbbbbbb01',
|
|
94
|
+
OPERATIONS_VIEWERS: 'bbbbbbbbbbbbbbbbbbbbbb02',
|
|
95
|
+
SERIAL_READERS: 'bbbbbbbbbbbbbbbbbbbbbb03',
|
|
96
|
+
TOOL_EDITORS: 'bbbbbbbbbbbbbbbbbbbbbb04',
|
|
97
|
+
ALL_USERS: 'bbbbbbbbbbbbbbbbbbbbbb05',
|
|
98
|
+
EMPTY_RULES: 'bbbbbbbbbbbbbbbbbbbbbb06',
|
|
99
|
+
DANGLING_FILTER: 'bbbbbbbbbbbbbbbbbbbbbb07',
|
|
100
|
+
};
|
|
101
|
+
/** EDIT on the Sydney subtree, any type. Battery Good EDIT, Brand VIEW. All actions. */
|
|
102
|
+
exports.SYDNEY_EDITORS = {
|
|
103
|
+
id: exports.RULE_GROUP_IDS.SYDNEY_EDITORS,
|
|
104
|
+
name: 'Sydney editors',
|
|
105
|
+
assetAccessRules: [
|
|
106
|
+
{
|
|
107
|
+
id: 'rule-sydney-editors',
|
|
108
|
+
level: 'EDIT',
|
|
109
|
+
conditions: {
|
|
110
|
+
locations: { mode: 'SELECTED', paths: [exports.RULE_LOCATIONS.SYDNEY] },
|
|
111
|
+
assetTypes: { mode: 'ALL' },
|
|
112
|
+
customFields: [],
|
|
113
|
+
},
|
|
114
|
+
fieldAccess: {
|
|
115
|
+
mode: 'SELECTED',
|
|
116
|
+
fields: [
|
|
117
|
+
{ fieldId: exports.RULE_FIELDS.BATTERY_GOOD, level: 'EDIT' },
|
|
118
|
+
{ fieldId: exports.RULE_FIELDS.BRAND, level: 'VIEW' },
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
actionAccess: { mode: 'ALL' },
|
|
124
|
+
};
|
|
125
|
+
/** VIEW on every asset whose Business Unit is Operations, own or type-level. All fields VIEW. Report damage only. */
|
|
126
|
+
exports.OPERATIONS_VIEWERS = {
|
|
127
|
+
id: exports.RULE_GROUP_IDS.OPERATIONS_VIEWERS,
|
|
128
|
+
name: 'Operations viewers',
|
|
129
|
+
assetAccessRules: [
|
|
130
|
+
{
|
|
131
|
+
id: 'rule-operations-viewers',
|
|
132
|
+
level: 'VIEW',
|
|
133
|
+
conditions: {
|
|
134
|
+
locations: { mode: 'ALL' },
|
|
135
|
+
assetTypes: { mode: 'ALL' },
|
|
136
|
+
customFields: [
|
|
137
|
+
{ fieldId: exports.RULE_FIELDS.BUSINESS_UNIT, operator: 'IN', values: ['Operations'] },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
fieldAccess: { mode: 'ALL', level: 'VIEW' },
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
actionAccess: { mode: 'SELECTED', actions: [exports.RULE_ACTIONS.REPORT_DAMAGE] },
|
|
144
|
+
};
|
|
145
|
+
/** Rule-less: Serial Number VIEW on anything a member can open. No actions. */
|
|
146
|
+
exports.SERIAL_READERS = {
|
|
147
|
+
id: exports.RULE_GROUP_IDS.SERIAL_READERS,
|
|
148
|
+
name: 'Serial readers',
|
|
149
|
+
assetAccessRules: [
|
|
150
|
+
{
|
|
151
|
+
id: 'rule-serial-readers',
|
|
152
|
+
fieldAccess: { mode: 'SELECTED', fields: [{ fieldId: exports.RULE_FIELDS.SERIAL, level: 'VIEW' }] },
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
actionAccess: { mode: 'SELECTED', actions: [] },
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* EDIT on Tools, subtypes included, at Albury or Perth: two selected paths
|
|
159
|
+
* AND a selected type, so a Perth trolley and a Dubbo tool both miss. All
|
|
160
|
+
* fields EDIT. Decommission only.
|
|
161
|
+
*/
|
|
162
|
+
exports.TOOL_EDITORS = {
|
|
163
|
+
id: exports.RULE_GROUP_IDS.TOOL_EDITORS,
|
|
164
|
+
name: 'Tool editors',
|
|
165
|
+
assetAccessRules: [
|
|
166
|
+
{
|
|
167
|
+
id: 'rule-tool-editors',
|
|
168
|
+
level: 'EDIT',
|
|
169
|
+
conditions: {
|
|
170
|
+
locations: { mode: 'SELECTED', paths: [exports.RULE_LOCATIONS.ALBURY, exports.RULE_LOCATIONS.PERTH] },
|
|
171
|
+
assetTypes: { mode: 'SELECTED', paths: [exports.RULE_TYPE_PATHS.TOOLS] },
|
|
172
|
+
},
|
|
173
|
+
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
actionAccess: { mode: 'SELECTED', actions: [exports.RULE_ACTIONS.DECOMMISSION] },
|
|
177
|
+
};
|
|
178
|
+
/** The bootstrap shape: unlimited at EDIT, every field EDIT, every action. */
|
|
179
|
+
exports.ALL_USERS = {
|
|
180
|
+
id: exports.RULE_GROUP_IDS.ALL_USERS,
|
|
181
|
+
name: 'All users',
|
|
182
|
+
assetAccessRules: [
|
|
183
|
+
{
|
|
184
|
+
id: 'rule-all-users',
|
|
185
|
+
level: 'EDIT',
|
|
186
|
+
conditions: {
|
|
187
|
+
locations: { mode: 'ALL' },
|
|
188
|
+
assetTypes: { mode: 'ALL' },
|
|
189
|
+
customFields: [],
|
|
190
|
+
},
|
|
191
|
+
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
actionAccess: { mode: 'ALL' },
|
|
195
|
+
};
|
|
196
|
+
/** A group with no rule at all: valid for a home layout or an SSO mapping, grants nothing. */
|
|
197
|
+
exports.EMPTY_RULES = {
|
|
198
|
+
id: exports.RULE_GROUP_IDS.EMPTY_RULES,
|
|
199
|
+
name: 'Layout only',
|
|
200
|
+
assetAccessRules: [],
|
|
201
|
+
};
|
|
202
|
+
/** A filter on a field the catalogue does not hold: the rule grants nothing, never everything. */
|
|
203
|
+
exports.DANGLING_FILTER = {
|
|
204
|
+
id: exports.RULE_GROUP_IDS.DANGLING_FILTER,
|
|
205
|
+
name: 'Dangling filter',
|
|
206
|
+
assetAccessRules: [
|
|
207
|
+
{
|
|
208
|
+
id: 'rule-dangling',
|
|
209
|
+
level: 'EDIT',
|
|
210
|
+
conditions: {
|
|
211
|
+
locations: { mode: 'ALL' },
|
|
212
|
+
assetTypes: { mode: 'ALL' },
|
|
213
|
+
customFields: [{ fieldId: 'eeeeeeeeeeeeeeeeeeeeee99', operator: 'IN', values: ['x'] }],
|
|
214
|
+
},
|
|
215
|
+
fieldAccess: { mode: 'ALL', level: 'EDIT' },
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
actionAccess: { mode: 'ALL' },
|
|
219
|
+
};
|
|
220
|
+
exports.RULE_GROUPS = {
|
|
221
|
+
SYDNEY_EDITORS: exports.SYDNEY_EDITORS,
|
|
222
|
+
OPERATIONS_VIEWERS: exports.OPERATIONS_VIEWERS,
|
|
223
|
+
SERIAL_READERS: exports.SERIAL_READERS,
|
|
224
|
+
TOOL_EDITORS: exports.TOOL_EDITORS,
|
|
225
|
+
ALL_USERS: exports.ALL_USERS,
|
|
226
|
+
EMPTY_RULES: exports.EMPTY_RULES,
|
|
227
|
+
DANGLING_FILTER: exports.DANGLING_FILTER,
|
|
228
|
+
};
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
// Assets, in the server's document shape the evaluator reads
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
const value = (id, name, slot) => (Object.assign({ _id: id, name }, slot));
|
|
233
|
+
/** Appendix asset A: a Sydney tool in Operations, scanned at home. Sydney editors EDIT and Operations viewers VIEW both match. */
|
|
234
|
+
exports.SYDNEY_TOOL = {
|
|
235
|
+
_id: 'ffffffffffffffffffffff01',
|
|
236
|
+
name: 'Sydney tool',
|
|
237
|
+
typeId: exports.RULE_TYPES.TOOLS,
|
|
238
|
+
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
239
|
+
homeLocationPath: exports.RULE_LOCATIONS.SYDNEY,
|
|
240
|
+
state: { locationName: exports.RULE_LOCATIONS.SYDNEY_BAY, locationStatus: 'HOME' },
|
|
241
|
+
fieldValues: [
|
|
242
|
+
value(exports.RULE_FIELDS.BATTERY_GOOD, 'Battery Good', { valueBoolean: true }),
|
|
243
|
+
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Makita' }),
|
|
244
|
+
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 120.5 }),
|
|
245
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-001' }),
|
|
246
|
+
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
/** Appendix asset B: a Dubbo trolley in Logistics. No group matches. */
|
|
250
|
+
exports.DUBBO_TROLLEY = {
|
|
251
|
+
_id: 'ffffffffffffffffffffff02',
|
|
252
|
+
name: 'Dubbo trolley',
|
|
253
|
+
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
254
|
+
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
255
|
+
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
256
|
+
state: { locationName: exports.RULE_LOCATIONS.DUBBO, locationStatus: 'HOME' },
|
|
257
|
+
fieldValues: [
|
|
258
|
+
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Generic' }),
|
|
259
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-002' }),
|
|
260
|
+
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Logistics' }),
|
|
261
|
+
],
|
|
262
|
+
};
|
|
263
|
+
/** Appendix asset C: a tool homed in Dubbo, no business unit, currently scanned in Sydney. Sydney editors match through the current location. */
|
|
264
|
+
exports.VISITING_TOOL = {
|
|
265
|
+
_id: 'ffffffffffffffffffffff03',
|
|
266
|
+
name: 'Visiting tool',
|
|
267
|
+
typeId: exports.RULE_TYPES.TOOLS,
|
|
268
|
+
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
269
|
+
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
270
|
+
state: { locationName: exports.RULE_LOCATIONS.SYDNEY, locationStatus: 'AWAY' },
|
|
271
|
+
fieldValues: [
|
|
272
|
+
value(exports.RULE_FIELDS.BATTERY_GOOD, 'Battery Good', { valueBoolean: false }),
|
|
273
|
+
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Bosch' }),
|
|
274
|
+
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 80 }),
|
|
275
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-003' }),
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
/** A power tool at Albury, never scanned, with no business unit of its own: Operations viewers match through the TYPE-level value, Tool editors through Albury and the Tools prefix. */
|
|
279
|
+
exports.ALBURY_POWER_TOOL = {
|
|
280
|
+
_id: 'ffffffffffffffffffffff04',
|
|
281
|
+
name: 'Albury power tool',
|
|
282
|
+
typeId: exports.RULE_TYPES.POWER_TOOLS,
|
|
283
|
+
typePath: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
284
|
+
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
285
|
+
fieldValues: [
|
|
286
|
+
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'DeWalt' }),
|
|
287
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-004' }),
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
/** A Perth trolley with nothing set: Tool editors miss on the type, nobody else reaches Perth. */
|
|
291
|
+
exports.PERTH_TROLLEY = {
|
|
292
|
+
_id: 'ffffffffffffffffffffff05',
|
|
293
|
+
name: 'Perth trolley',
|
|
294
|
+
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
295
|
+
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
296
|
+
homeLocationPath: exports.RULE_LOCATIONS.PERTH,
|
|
297
|
+
fieldValues: [],
|
|
298
|
+
};
|
|
299
|
+
/** The sibling trap: homed at Sydneyside, which shares Sydney's prefix up to the pipe. Must stay hidden from Sydney editors. */
|
|
300
|
+
exports.SYDNEYSIDE_TOOL = {
|
|
301
|
+
_id: 'ffffffffffffffffffffff06',
|
|
302
|
+
name: 'Sydneyside tool',
|
|
303
|
+
typeId: exports.RULE_TYPES.TOOLS,
|
|
304
|
+
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
305
|
+
homeLocationPath: exports.RULE_LOCATIONS.SYDNEYSIDE,
|
|
306
|
+
state: { locationName: exports.RULE_LOCATIONS.SYDNEYSIDE, locationStatus: 'HOME' },
|
|
307
|
+
fieldValues: [
|
|
308
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-006' }),
|
|
309
|
+
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Finance' }),
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
/** A Sydney vehicle never scanned: Sydney editors match through the home alone. */
|
|
313
|
+
exports.SYDNEY_VEHICLE = {
|
|
314
|
+
_id: 'ffffffffffffffffffffff07',
|
|
315
|
+
name: 'Sydney vehicle',
|
|
316
|
+
typeId: exports.RULE_TYPES.VEHICLES,
|
|
317
|
+
typePath: exports.RULE_TYPE_PATHS.VEHICLES,
|
|
318
|
+
homeLocationPath: exports.RULE_LOCATIONS.SYDNEY,
|
|
319
|
+
fieldValues: [value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-007' })],
|
|
320
|
+
};
|
|
321
|
+
/** A Perth tool in Operations: Operations viewers VIEW and Tool editors EDIT, so EDIT wins. */
|
|
322
|
+
exports.PERTH_OPS_TOOL = {
|
|
323
|
+
_id: 'ffffffffffffffffffffff08',
|
|
324
|
+
name: 'Perth ops tool',
|
|
325
|
+
typeId: exports.RULE_TYPES.TOOLS,
|
|
326
|
+
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
327
|
+
homeLocationPath: exports.RULE_LOCATIONS.PERTH,
|
|
328
|
+
state: { locationName: exports.RULE_LOCATIONS.PERTH, locationStatus: 'HOME' },
|
|
329
|
+
fieldValues: [
|
|
330
|
+
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 300 }),
|
|
331
|
+
value(exports.RULE_FIELDS.SERIAL, 'Serial Number', { valueString: 'S-008' }),
|
|
332
|
+
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
/** An Albury trolley in Operations: Operations viewers alone, so VIEW, and the VIEW cap on every field. */
|
|
336
|
+
exports.ALBURY_OPS_TROLLEY = {
|
|
337
|
+
_id: 'ffffffffffffffffffffff09',
|
|
338
|
+
name: 'Albury ops trolley',
|
|
339
|
+
typeId: exports.RULE_TYPES.TROLLEYS,
|
|
340
|
+
typePath: exports.RULE_TYPE_PATHS.TROLLEYS,
|
|
341
|
+
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
342
|
+
fieldValues: [
|
|
343
|
+
value(exports.RULE_FIELDS.BRAND, 'Brand', { valueString: 'Generic' }),
|
|
344
|
+
value(exports.RULE_FIELDS.COST, 'Cost', { valueDecimal: 50 }),
|
|
345
|
+
value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Operations' }),
|
|
346
|
+
],
|
|
347
|
+
};
|
|
348
|
+
/** A Dubbo power tool whose OWN business unit is Logistics while its type says Operations: either value matches, so Operations viewers see it. */
|
|
349
|
+
exports.DUBBO_LOGISTICS_POWER_TOOL = {
|
|
350
|
+
_id: 'ffffffffffffffffffffff10',
|
|
351
|
+
name: 'Dubbo logistics power tool',
|
|
352
|
+
typeId: exports.RULE_TYPES.POWER_TOOLS,
|
|
353
|
+
typePath: exports.RULE_TYPE_PATHS.POWER_TOOLS,
|
|
354
|
+
homeLocationPath: exports.RULE_LOCATIONS.DUBBO,
|
|
355
|
+
fieldValues: [value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: 'Logistics' })],
|
|
356
|
+
};
|
|
357
|
+
/** An Albury tool whose business unit slot is present but null: unset, so Operations viewers miss, while Tool editors match. */
|
|
358
|
+
exports.ALBURY_NULL_TOOL = {
|
|
359
|
+
_id: 'ffffffffffffffffffffff11',
|
|
360
|
+
name: 'Albury null tool',
|
|
361
|
+
typeId: exports.RULE_TYPES.TOOLS,
|
|
362
|
+
typePath: exports.RULE_TYPE_PATHS.TOOLS,
|
|
363
|
+
homeLocationPath: exports.RULE_LOCATIONS.ALBURY,
|
|
364
|
+
state: { locationName: exports.RULE_LOCATIONS.ALBURY, locationStatus: 'HOME' },
|
|
365
|
+
fieldValues: [value(exports.RULE_FIELDS.BUSINESS_UNIT, 'Business Unit', { valueString: null })],
|
|
366
|
+
};
|
|
367
|
+
exports.RULE_ASSETS = {
|
|
368
|
+
SYDNEY_TOOL: exports.SYDNEY_TOOL,
|
|
369
|
+
DUBBO_TROLLEY: exports.DUBBO_TROLLEY,
|
|
370
|
+
VISITING_TOOL: exports.VISITING_TOOL,
|
|
371
|
+
ALBURY_POWER_TOOL: exports.ALBURY_POWER_TOOL,
|
|
372
|
+
PERTH_TROLLEY: exports.PERTH_TROLLEY,
|
|
373
|
+
SYDNEYSIDE_TOOL: exports.SYDNEYSIDE_TOOL,
|
|
374
|
+
SYDNEY_VEHICLE: exports.SYDNEY_VEHICLE,
|
|
375
|
+
PERTH_OPS_TOOL: exports.PERTH_OPS_TOOL,
|
|
376
|
+
ALBURY_OPS_TROLLEY: exports.ALBURY_OPS_TROLLEY,
|
|
377
|
+
DUBBO_LOGISTICS_POWER_TOOL: exports.DUBBO_LOGISTICS_POWER_TOOL,
|
|
378
|
+
ALBURY_NULL_TOOL: exports.ALBURY_NULL_TOOL,
|
|
379
|
+
};
|
|
380
|
+
exports.RULE_CORPUS = Object.values(exports.RULE_ASSETS);
|
|
381
|
+
// ---------------------------------------------------------------------------
|
|
382
|
+
// Callers: the personas the model distinguishes
|
|
383
|
+
// ---------------------------------------------------------------------------
|
|
384
|
+
const definedCallers = {
|
|
385
|
+
/** The appendix user: a member of all three appendix groups. */
|
|
386
|
+
ALL_THREE: { groups: [exports.SYDNEY_EDITORS, exports.OPERATIONS_VIEWERS, exports.SERIAL_READERS] },
|
|
387
|
+
OPERATIONS_ONLY: { groups: [exports.OPERATIONS_VIEWERS] },
|
|
388
|
+
SERIAL_ONLY: { groups: [exports.SERIAL_READERS] },
|
|
389
|
+
TOOL_EDITORS_ONLY: { groups: [exports.TOOL_EDITORS] },
|
|
390
|
+
NO_GROUP: { groups: [] },
|
|
391
|
+
BOOTSTRAP_ONLY: { groups: [exports.ALL_USERS] },
|
|
392
|
+
/** An Admin: the field and action bypasses, confined to Sydney by their one group. */
|
|
393
|
+
ADMIN: { fieldsAdmin: true, actionsAdmin: true, groups: [exports.SYDNEY_EDITORS] },
|
|
394
|
+
/** A System Admin: exempt from asset rules, with both bypasses, in no group. */
|
|
395
|
+
SYSTEM_ADMIN: { exempt: true, fieldsAdmin: true, actionsAdmin: true, groups: [] },
|
|
396
|
+
/** Exempt without the bypasses: every asset, but only the fields and actions the groups grant. */
|
|
397
|
+
EXEMPT_ONLY: { exempt: true, groups: [exports.OPERATIONS_VIEWERS] },
|
|
398
|
+
/** An API-key request: open on every axis, whatever its user record holds. */
|
|
399
|
+
API_KEY: { open: true, groups: [exports.SERIAL_READERS] },
|
|
400
|
+
LAYOUT_ONLY: { groups: [exports.EMPTY_RULES] },
|
|
401
|
+
DANGLING_ONLY: { groups: [exports.DANGLING_FILTER] },
|
|
402
|
+
};
|
|
403
|
+
exports.RULE_CALLERS = definedCallers;
|
|
404
|
+
/** Frozen clock, as the language corpus has: nothing here is date-sensitive, but the evaluator takes one. */
|
|
405
|
+
exports.RULE_OPTS = { now: new Date('2026-10-15T00:00:00Z'), timeZone: 'Australia/Sydney' };
|
|
406
406
|
//# sourceMappingURL=rules-fixtures.js.map
|