@things-factory/biz-base 10.1.228 → 10.1.232
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-server/index.d.ts +1 -0
- package/dist-server/index.js +1 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/company/company-mutation.d.ts +14 -0
- package/dist-server/service/company/company-mutation.js +62 -2
- package/dist-server/service/company/company-mutation.js.map +1 -1
- package/dist-server/service/company/company-query.d.ts +3 -1
- package/dist-server/service/company/company-query.js +15 -8
- package/dist-server/service/company/company-query.js.map +1 -1
- package/dist-server/service/company/company-seal-reader.d.ts +6 -0
- package/dist-server/service/company/company-seal-reader.js +16 -0
- package/dist-server/service/company/company-seal-reader.js.map +1 -0
- package/dist-server/service/company/company-types.d.ts +3 -0
- package/dist-server/service/company/company-types.js +12 -0
- package/dist-server/service/company/company-types.js.map +1 -1
- package/dist-server/service/company/company.d.ts +3 -0
- package/dist-server/service/company/company.js +26 -6
- package/dist-server/service/company/company.js.map +1 -1
- package/dist-server/service/company/our-company.d.ts +44 -0
- package/dist-server/service/company/our-company.js +55 -0
- package/dist-server/service/company/our-company.js.map +1 -0
- package/dist-server/service/index.d.ts +2 -1
- package/dist-server/service/index.js +4 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/tests/our-company.test.mjs +75 -0
- package/translations/en.json +3 -1
- package/translations/es.json +3 -1
- package/translations/ja.json +3 -1
- package/translations/ko.json +3 -1
- package/translations/ms.json +3 -1
- package/translations/zh.json +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/biz-base",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.232",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"test": "npm run build && node --test tests/*.test.mjs tests/*.test.cjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@things-factory/attachment-base": "^10.1.
|
|
45
|
-
"@things-factory/auth-base": "^10.1.
|
|
44
|
+
"@things-factory/attachment-base": "^10.1.232",
|
|
45
|
+
"@things-factory/auth-base": "^10.1.232"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "9307e1db833f13018e3f0ca9b1050f947cbefd68"
|
|
48
48
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { test, before, after } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
import { readFileSync } from 'node:fs'
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* 「우리 회사」 (ADR-0176 decision 4): a domain's own company row - made on its first save, kept under `company`, its seal
|
|
8
|
+
* an attachment only its keepers open, and printed with the domain's name until a name is kept. An in-memory SQLite
|
|
9
|
+
* source; no application database is opened.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const require = createRequire(import.meta.url)
|
|
13
|
+
const { DataSource } = require('typeorm')
|
|
14
|
+
const shell = require('@things-factory/shell')
|
|
15
|
+
const auth = require('@things-factory/auth-base')
|
|
16
|
+
const attachment = require('@things-factory/attachment-base')
|
|
17
|
+
const biz = require('../dist-server/index.js')
|
|
18
|
+
const { companySealReader } = require('../dist-server/service/company/company-seal-reader.js')
|
|
19
|
+
|
|
20
|
+
let db, domain, other, user
|
|
21
|
+
before(async () => {
|
|
22
|
+
db = await new DataSource({
|
|
23
|
+
type: 'sqlite',
|
|
24
|
+
database: ':memory:',
|
|
25
|
+
synchronize: true,
|
|
26
|
+
entities: [...new Set([...shell.entities, ...auth.entities, ...attachment.entities, ...biz.entities])],
|
|
27
|
+
namingStrategy: new shell.NamingStrategy()
|
|
28
|
+
}).initialize()
|
|
29
|
+
domain = await db.getRepository(shell.Domain).save({ name: 'hatiolab', subdomain: 'our-one', description: '(주)하티오랩' })
|
|
30
|
+
other = await db.getRepository(shell.Domain).save({ name: 'other', subdomain: 'our-two' })
|
|
31
|
+
user = await db.getRepository(auth.User).save({ name: 'admin', email: 'admin@example.test', status: 'activated', domains: [domain] })
|
|
32
|
+
})
|
|
33
|
+
after(async () => {
|
|
34
|
+
await db?.destroy()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const save = (patch, into = domain) => db.transaction(tx => biz.saveOurCompany(patch, into, user, tx))
|
|
38
|
+
|
|
39
|
+
test('★ a domain with no company row prints its own name, and nothing else', async () => {
|
|
40
|
+
assert.equal(await biz.ourCompanyOf(domain, db), null)
|
|
41
|
+
const printed = await biz.printedCompanyOf(domain, { manager: db })
|
|
42
|
+
assert.deepEqual(printed, { name: '(주)하티오랩', representative: '', brn: '', corporateRegistrationNumber: '', address: '', phone: '' })
|
|
43
|
+
assert.equal((await biz.printedCompanyOf(other, { manager: db })).name, 'other')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('★ the first save makes the row, later saves change it - one row a domain, its words trimmed', async () => {
|
|
47
|
+
await assert.rejects(save({ representative: '홍길동' }), /a company needs a name/)
|
|
48
|
+
const made = await save({ name: ' 주식회사 하티오랩 ', representative: '홍길동', brn: '123-45-67890', corporateRegistrationNumber: '110111-1234567', address: '서울', phone: '02-000-0000' })
|
|
49
|
+
const changed = await save({ representative: '김대표', status: 'X' })
|
|
50
|
+
assert.equal(changed.id, made.id)
|
|
51
|
+
assert.equal((await db.getRepository(biz.Company).find({ where: { domain: { id: domain.id } } })).length, 1)
|
|
52
|
+
const printed = await biz.printedCompanyOf(domain, { manager: db })
|
|
53
|
+
assert.deepEqual(printed, { name: '주식회사 하티오랩', representative: '김대표', brn: '123-45-67890', corporateRegistrationNumber: '110111-1234567', address: '서울', phone: '02-000-0000' })
|
|
54
|
+
assert.equal((await biz.ourCompanyOf(domain, db)).status, null, 'a save keeps only the words of 「우리 회사」')
|
|
55
|
+
assert.equal(await biz.ourCompanyOf(other, db), null, "another domain's company is its own")
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('★ without a seal a print carries none; the seal opens by its path only for whoever keeps the company', async () => {
|
|
59
|
+
assert.equal((await biz.printedCompanyOf(domain, { seal: true, manager: db })).seal, undefined)
|
|
60
|
+
const asked = []
|
|
61
|
+
const check = async (privilege, ...rest) => (asked.push(privilege), privilege.category === 'company' && privilege.privilege === 'mutation' && rest[0] === 'keeper')
|
|
62
|
+
assert.equal(await companySealReader({}, { state: { user: 'keeper' } }, check), true)
|
|
63
|
+
assert.equal(await companySealReader({}, { state: { user: 'clerk' } }, check), false)
|
|
64
|
+
assert.deepEqual(asked[0], { category: 'company', privilege: 'mutation', owner: true })
|
|
65
|
+
assert.equal(attachment.attachmentReaderOf(biz.COMPANY_SEAL_REF_TYPE) !== undefined, true, 'its reader is registered')
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('★ keeping 「우리 회사」 is audited by the company it names, and needs company:mutation', () => {
|
|
69
|
+
const text = readFileSync(new URL('../server/service/company/company-mutation.ts', import.meta.url), 'utf8')
|
|
70
|
+
for (const door of ['saveCompany', 'attachCompanySeal']) {
|
|
71
|
+
const above = text.split(`async ${door}(`)[0].split('\n').slice(-6).join('\n')
|
|
72
|
+
assert.match(above, /@privilege\(category: "company", privilege: "mutation"/, door)
|
|
73
|
+
assert.match(above, /@auditTarget\(kind: "Company"/, door)
|
|
74
|
+
}
|
|
75
|
+
})
|
package/translations/en.json
CHANGED
|
@@ -21,5 +21,7 @@
|
|
|
21
21
|
"task.biz-base.counterparty-keeping.name": "Keeping counterparties",
|
|
22
22
|
"task.biz-base.counterparty-keeping.description": "Reads and changes counterparties whole - address, representative, notes and their accounts' full numbers.",
|
|
23
23
|
"task.biz-base.company-keeping.name": "Keeping our company and sites",
|
|
24
|
-
"task.biz-base.company-keeping.description": "Reads and changes our company, its business sites and the business options."
|
|
24
|
+
"task.biz-base.company-keeping.description": "Reads and changes our company, its business sites and the business options.",
|
|
25
|
+
"error.company-not-found": "Save the company first",
|
|
26
|
+
"error.company-name-required": "A company needs a name"
|
|
25
27
|
}
|
package/translations/es.json
CHANGED
|
@@ -21,5 +21,7 @@
|
|
|
21
21
|
"task.biz-base.counterparty-keeping.name": "Mantener contrapartes",
|
|
22
22
|
"task.biz-base.counterparty-keeping.description": "Lee y modifica las contrapartes completas: dirección, representante, notas y números de cuenta completos.",
|
|
23
23
|
"task.biz-base.company-keeping.name": "Mantener la empresa y sus sedes",
|
|
24
|
-
"task.biz-base.company-keeping.description": "Lee y modifica nuestra empresa, sus sedes y las opciones de negocio."
|
|
24
|
+
"task.biz-base.company-keeping.description": "Lee y modifica nuestra empresa, sus sedes y las opciones de negocio.",
|
|
25
|
+
"error.company-not-found": "Guarde primero la empresa",
|
|
26
|
+
"error.company-name-required": "La empresa necesita un nombre"
|
|
25
27
|
}
|
package/translations/ja.json
CHANGED
|
@@ -17,5 +17,7 @@
|
|
|
17
17
|
"task.biz-base.counterparty-keeping.name": "取引先の管理",
|
|
18
18
|
"task.biz-base.counterparty-keeping.description": "取引先のすべての項目(住所・代表者・メモ・口座番号全体)を読み、変更する。",
|
|
19
19
|
"task.biz-base.company-keeping.name": "会社・事業所の管理",
|
|
20
|
-
"task.biz-base.company-keeping.description": "自社・事業所・事業オプションを読み、変更する。"
|
|
20
|
+
"task.biz-base.company-keeping.description": "自社・事業所・事業オプションを読み、変更する。",
|
|
21
|
+
"error.company-not-found": "先に会社情報を保存してください",
|
|
22
|
+
"error.company-name-required": "商号を入力してください"
|
|
21
23
|
}
|
package/translations/ko.json
CHANGED
|
@@ -21,5 +21,7 @@
|
|
|
21
21
|
"task.biz-base.counterparty-keeping.name": "거래처 관리",
|
|
22
22
|
"task.biz-base.counterparty-keeping.description": "거래처의 주소·대표자·메모·계좌번호 전체를 포함한 모든 항목을 조회하고 수정합니다.",
|
|
23
23
|
"task.biz-base.company-keeping.name": "회사·사업장 관리",
|
|
24
|
-
"task.biz-base.company-keeping.description": "우리 회사·사업장·사업 옵션을 읽고 바꾼다."
|
|
24
|
+
"task.biz-base.company-keeping.description": "우리 회사·사업장·사업 옵션을 읽고 바꾼다.",
|
|
25
|
+
"error.company-not-found": "회사 정보를 먼저 저장하세요",
|
|
26
|
+
"error.company-name-required": "상호를 적어 주세요"
|
|
25
27
|
}
|
package/translations/ms.json
CHANGED
|
@@ -17,5 +17,7 @@
|
|
|
17
17
|
"task.biz-base.counterparty-keeping.name": "Menyelenggara rakan niaga",
|
|
18
18
|
"task.biz-base.counterparty-keeping.description": "Membaca dan mengubah rakan niaga sepenuhnya: alamat, wakil, nota dan nombor akaun penuh.",
|
|
19
19
|
"task.biz-base.company-keeping.name": "Menyelenggara syarikat dan tapak",
|
|
20
|
-
"task.biz-base.company-keeping.description": "Membaca dan mengubah syarikat kita, tapak perniagaannya dan pilihan perniagaan."
|
|
20
|
+
"task.biz-base.company-keeping.description": "Membaca dan mengubah syarikat kita, tapak perniagaannya dan pilihan perniagaan.",
|
|
21
|
+
"error.company-not-found": "Simpan syarikat dahulu",
|
|
22
|
+
"error.company-name-required": "Syarikat memerlukan nama"
|
|
21
23
|
}
|
package/translations/zh.json
CHANGED
|
@@ -17,5 +17,7 @@
|
|
|
17
17
|
"task.biz-base.counterparty-keeping.name": "管理往来单位",
|
|
18
18
|
"task.biz-base.counterparty-keeping.description": "读取并修改往来单位的全部字段(地址、代表人、备注、完整账号)。",
|
|
19
19
|
"task.biz-base.company-keeping.name": "管理公司与营业场所",
|
|
20
|
-
"task.biz-base.company-keeping.description": "读取并修改本公司、营业场所和业务选项。"
|
|
20
|
+
"task.biz-base.company-keeping.description": "读取并修改本公司、营业场所和业务选项。",
|
|
21
|
+
"error.company-not-found": "请先保存公司信息",
|
|
22
|
+
"error.company-name-required": "请填写公司名称"
|
|
21
23
|
}
|