@spotto/semantic-query 1.0.70-alpha.34 → 1.0.70-alpha.36

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.
@@ -0,0 +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' };
406
+ //# sourceMappingURL=rules-fixtures.js.map
@@ -0,0 +1 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;IAC9E,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,sBAAc,CAAC,EAAE;IACjD,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,mBAAW,CAAC,EAAE;IACtC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,uBAAe,CAAC,EAAE;CAC7C,CAAA;AAIY,QAAA,YAAY,GAAwC,cAAc,CAAA;AAE/E,6GAA6G;AAChG,QAAA,SAAS,GAAG,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,sBAAsB,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,180 @@
1
+ import { ActionAccess, AssetAccessLevel, AssetAccessRule, AssetRuleConditions, FieldAccess, PermissionGrantLevel, SemanticQuery } from '@spotto/contract';
2
+ import { SemanticAccountSchema, SemanticCompileOptions, SemanticFieldDef } from './types';
3
+ /**
4
+ * The group permission model as pure functions, called by the API and by the
5
+ * client so that neither holds an opinion of its own about who sees what.
6
+ *
7
+ * Specification: business_unit_access/group_permission_spec_v31.md, section 4.
8
+ * The section numbers beside each function are its. Nothing here reads a
9
+ * database or a store: the caller hands in the groups, an asset document in
10
+ * the server's shape (the client maps through `toEvaluableAsset` first, as it
11
+ * does for every semantic query) and the catalogue the evaluator already
12
+ * takes.
13
+ *
14
+ * The one rule everything below rests on: a group only ever grants. Removing a
15
+ * member, a grant or a group never widens what anyone sees, and adding one
16
+ * never narrows what anyone else has.
17
+ */
18
+ declare type AssetDocument = Record<string, any>;
19
+ /** A group as the model sees it: its rule and its action access, nothing else. */
20
+ export interface AccessGroup {
21
+ id: string;
22
+ name?: string;
23
+ assetAccessRules: AssetAccessRule[];
24
+ actionAccess?: ActionAccess;
25
+ }
26
+ /**
27
+ * The caller, as resolved by whoever holds the session: the server from the
28
+ * request, the client from the current user record.
29
+ */
30
+ export interface AccessCaller {
31
+ /**
32
+ * The model does not apply on either axis: the toggle is off, the request
33
+ * carried an API key, or the caller acts across organisations. Every answer
34
+ * is open.
35
+ */
36
+ open?: boolean;
37
+ /** The role carries the exemption literal: asset rules do not apply. Field and action access still follow the groups. */
38
+ exempt?: boolean;
39
+ /** The role carries `fields:admin`: every custom field, at the asset's level. */
40
+ fieldsAdmin?: boolean;
41
+ /** The role carries `actions:admin`: every action. */
42
+ actionsAdmin?: boolean;
43
+ groups: ReadonlyArray<AccessGroup>;
44
+ }
45
+ declare type ConditionedRule = AssetAccessRule & {
46
+ conditions: AssetRuleConditions;
47
+ };
48
+ declare type FieldCatalogue = ReadonlyArray<Pick<SemanticFieldDef, 'id' | 'name'>>;
49
+ /** The less permissive of two levels. */
50
+ export declare function lowerLevel(a: PermissionGrantLevel, b: PermissionGrantLevel): PermissionGrantLevel;
51
+ /** The more permissive of two levels. */
52
+ export declare function higherLevel(a: PermissionGrantLevel, b: PermissionGrantLevel): PermissionGrantLevel;
53
+ /** The group's rule: one per group in this release. */
54
+ export declare function ruleOf(group: AccessGroup): AssetAccessRule | undefined;
55
+ export declare function ruleHasConditions(rule: AssetAccessRule): rule is ConditionedRule;
56
+ /** A conditions rule's level. The validator requires it; a stored rule without one reads as VIEW, the narrower answer. */
57
+ export declare function ruleLevel(rule: AssetAccessRule): AssetAccessLevel;
58
+ /**
59
+ * Unlimited: conditions present, locations and asset types both at ALL and no
60
+ * custom-field filter. Such a rule grants every asset. A rule-less group is
61
+ * not unlimited, because it grants no assets at all. Section 2.
62
+ */
63
+ export declare function ruleIsUnlimited(rule: AssetAccessRule): boolean;
64
+ /**
65
+ * A path with its trailing pipe. The validators store the canonical form; this
66
+ * guards a document written before them, exactly as the old scope resolver
67
+ * did at match time.
68
+ */
69
+ export declare function canonicalAccessPath(path: string): string;
70
+ /**
71
+ * Section 4.1: a rule's conditions as a semantic query.
72
+ *
73
+ * locations SELECTED -> or[ per path: homeLocation subtree, location subtree ]
74
+ * assetTypes SELECTED -> or[ per path: assetType subtree ]
75
+ * each filter -> or[ per value: customField eq value ]
76
+ * rule -> and of every present dimension (the query's top level)
77
+ *
78
+ * Every condition kind here already exists in the evaluator and in both
79
+ * compilers, so the translation adds no form to any of them. The language
80
+ * keys a custom field by name, so the field id is resolved through the
81
+ * catalogue the caller already holds.
82
+ *
83
+ * Returns undefined when the rule contributes nothing: it has no conditions
84
+ * (a rule-less group), a SELECTED dimension names no path, or a filter names
85
+ * a field the catalogue lacks or no value. The propagation rules keep the
86
+ * last two from being stored; if one is met anyway the rule grants nothing
87
+ * rather than everything.
88
+ */
89
+ export declare function ruleToQuery(rule: AssetAccessRule, fields: FieldCatalogue): SemanticQuery | undefined;
90
+ /**
91
+ * What a list surface applies. `unfiltered` for the open callers, the exempt
92
+ * role and a caller with an unlimited rule. `none` for a caller whose groups
93
+ * carry no rule with conditions, who sees nothing. Otherwise the OR of the
94
+ * rule queries, with a flag saying whether it reads custom fields, which is
95
+ * what decides the type join on the server and the catalogue load on the
96
+ * client.
97
+ */
98
+ export declare type ScopeQuery = {
99
+ kind: 'unfiltered';
100
+ } | {
101
+ kind: 'none';
102
+ } | {
103
+ kind: 'query';
104
+ query: SemanticQuery;
105
+ usesCustomFields: boolean;
106
+ };
107
+ export declare function scopeQueryFor(caller: AccessCaller, fields: FieldCatalogue): ScopeQuery;
108
+ /** The union of the location dimensions, which the location list, its map and the child lists follow. */
109
+ export declare type LocationUnion = {
110
+ all: true;
111
+ } | {
112
+ all: false;
113
+ paths: string[];
114
+ };
115
+ export declare function locationUnionFor(caller: AccessCaller): LocationUnion;
116
+ /**
117
+ * Section 2, location limit: not open or exempt, and no conditions group with
118
+ * locations at ALL. A caller in no group has one, since their union is empty.
119
+ */
120
+ export declare function hasLocationLimit(caller: AccessCaller): boolean;
121
+ /**
122
+ * Section 2, unconfined: open or exempt, or a member of a group whose rule is
123
+ * unlimited. Only unconfined callers administer groups and memberships.
124
+ */
125
+ export declare function isUnconfined(caller: AccessCaller): boolean;
126
+ /** The answers the detail and edit pages, the CSV cells and the warnings need for one asset. */
127
+ export interface AssetAccess {
128
+ visible: boolean;
129
+ editable: boolean;
130
+ /** EDIT, VIEW or NONE. An asset at NONE still opens by scan, link, kit or history. */
131
+ level: PermissionGrantLevel;
132
+ /** The caller's groups with conditions whose rule matches the asset. */
133
+ matching: AccessGroup[];
134
+ /** Section 4.4, for one custom field. */
135
+ fieldLevel(fieldId: string): PermissionGrantLevel;
136
+ }
137
+ /** The asset level over the groups that match it. */
138
+ export declare function assetLevelFor(caller: AccessCaller, matching: AccessGroup[]): PermissionGrantLevel;
139
+ /** What a field access grants on one field: `ALL` its level, `SELECTED` the entry's level or NONE. */
140
+ export declare function fieldGrantLevel(fieldAccess: FieldAccess, fieldId: string): PermissionGrantLevel;
141
+ /**
142
+ * Section 4.4. The cap is the asset level, or VIEW when that is NONE, since
143
+ * any asset can be opened. Open callers and the field-admin bypass get the
144
+ * cap. Otherwise each group contributes: a matching conditions group its
145
+ * grant capped at its rule's level, a rule-less group its grant capped at the
146
+ * cap, and the most permissive contribution wins.
147
+ */
148
+ export declare function fieldLevelFor(caller: AccessCaller, matching: AccessGroup[], assetLevel: PermissionGrantLevel, fieldId: string): PermissionGrantLevel;
149
+ /**
150
+ * Whether the caller can see the field on SOME asset: the test for a column
151
+ * or a picker entry (section 6.1 `canViewFieldAnywhere`, section 5.4 for the
152
+ * CSV columns). Open callers and the field-admin bypass see every column.
153
+ */
154
+ export declare function canViewFieldAnywhere(caller: AccessCaller, fieldId: string): boolean;
155
+ /**
156
+ * The evaluator prepared once for a caller: one predicate per conditions
157
+ * group, built against the catalogue, then applied to any number of assets.
158
+ * The CSV export and the client's lists go through this; a single detail page
159
+ * may call `accessFor` directly.
160
+ */
161
+ export interface PreparedAccess {
162
+ scope: ScopeQuery;
163
+ locationUnion: LocationUnion;
164
+ unconfined: boolean;
165
+ accessFor(asset: AssetDocument): AssetAccess;
166
+ }
167
+ export declare function prepareAccess(caller: AccessCaller, schema: SemanticAccountSchema, opts?: SemanticCompileOptions): PreparedAccess;
168
+ /** One asset, one answer. Prefer `prepareAccess` when evaluating many. */
169
+ export declare function accessFor(caller: AccessCaller, asset: AssetDocument, schema: SemanticAccountSchema, opts?: SemanticCompileOptions): AssetAccess;
170
+ export declare function groupGrantsAction(group: AccessGroup, actionId: string): boolean;
171
+ /** Whether every action is usable: the open callers, the action-admin bypass, or an All actions group. */
172
+ export declare function grantsEveryAction(caller: AccessCaller): boolean;
173
+ export declare function canUseAction(caller: AccessCaller, actionId: string): boolean;
174
+ /**
175
+ * The complete list the current user record carries, in the order of the
176
+ * organisation's actions, so a Selected id that no longer exists never
177
+ * appears.
178
+ */
179
+ export declare function usableActionIds(caller: AccessCaller, organisationActionIds: ReadonlyArray<string>): string[];
180
+ export {};