@things-factory/organization 10.1.183 → 10.1.185

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/organization",
3
- "version": "10.1.183",
3
+ "version": "10.1.185",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -41,5 +41,5 @@
41
41
  "@things-factory/contact": "^10.1.183",
42
42
  "@things-factory/shell": "^10.1.179"
43
43
  },
44
- "gitHead": "c36684e0db8353f5f4523ed55111df3154bae19e"
44
+ "gitHead": "3cfe5c959e7e82d772f46fd280037900fa89fcaa"
45
45
  }
@@ -1,18 +1,18 @@
1
1
  import { readFileSync } from 'fs'
2
2
  import { join } from 'path'
3
3
 
4
- import { EMPLOYEE_PRIVATE_FIELDS, privateFieldsOf } from '../server/service/employee/employee-private'
4
+ import { EMPLOYEE_PRIVATE_FIELDS, privateFieldsOf, refusePrivateWrite } from '../server/service/employee/employee-private'
5
5
 
6
6
  /**
7
7
  * An employee's pay account is HR-payroll's (ADR-0139): read under `employee-private`, apart from the roster every
8
- * seat reads, and written only by whoever may change it.
8
+ * seat reads, and written through its own door - a door is what declares the privilege (no directive, no privilege row).
9
9
  */
10
10
  describe("an employee's pay account", () => {
11
11
  it('★ is declared under employee-private on the employee and its history - the declaration, not a resolver', () => {
12
12
  for (const file of ['employee.ts', 'employee-history.ts']) {
13
13
  const source = readFileSync(join(__dirname, '..', 'server', 'service', 'employee', file), 'utf8')
14
14
  for (const field of EMPLOYEE_PRIVATE_FIELDS) {
15
- expect([file, field, new RegExp(`@privilege\\(category: "employee-private", privilege: "query"[^\\n]*\\n @Field\\(\\{ nullable: true \\}\\)\\n ${field}\\?:`).test(source)]).toEqual([file, field, true])
15
+ expect([file, field, new RegExp(`@privilege\\(category: "employee-private", privilege: "query", domainOwnerGranted: false\\)[^\\n]*\\n @Field\\(\\{ nullable: true \\}\\)\\n ${field}\\?:`).test(source)]).toEqual([file, field, true])
16
16
  }
17
17
  }
18
18
  })
@@ -23,4 +23,15 @@ describe("an employee's pay account", () => {
23
23
  expect(privateFieldsOf({ bankName: '' })).toEqual(['bankName'])
24
24
  expect(privateFieldsOf(null)).toEqual([])
25
25
  })
26
+
27
+ it('★ the roster writes refuse it; its own door asks employee-private:mutation', () => {
28
+ expect(() => refusePrivateWrite([{ name: '홍길동' }, { bankAccount: '123' }])).toThrow(/updateEmployeePayAccount/)
29
+ expect(() => refusePrivateWrite([{ name: '홍길동' }])).not.toThrow()
30
+ const source = readFileSync(join(__dirname, '..', 'server', 'service', 'employee', 'employee-mutation.ts'), 'utf8')
31
+ expect(source).toMatch(/@privilege\(category: "employee-private", privilege: "mutation", domainOwnerGranted: false\)[^\n]*\n(?: @[^\n]*\n)* async updateEmployeePayAccount\(/)
32
+ for (const door of ['createEmployee', 'updateEmployee', 'updateMultipleEmployee', 'importEmployees']) {
33
+ const body = source.slice(source.indexOf(`async ${door}(`), source.indexOf(`async ${door}(`) + 600)
34
+ expect([door, /refusePrivateWrite\(/.test(body)]).toEqual([door, true])
35
+ }
36
+ })
26
37
  })