@coffer-org/plugin-documents 1.1.0 → 1.2.2

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/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  declare const _default: import("@coffer-org/sdk/plugin").PluginManifest;
2
2
  export default _default;
3
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineVault } from '@coffer-org/sdk/vault';
2
2
  import { definePlugin } from '@coffer-org/sdk/plugin';
3
- import personal_document from './personal_document/index.js';
4
- import personIdentity from './person_identity/index.js';
3
+ import personal_document from "./personal_document/index.js";
4
+ import personIdentity from "./person_identity/index.js";
5
5
  export default definePlugin({
6
6
  id: 'documents',
7
7
  version: '1.0.0',
@@ -14,4 +14,3 @@ export default definePlugin({
14
14
  ],
15
15
  extends_: [personIdentity],
16
16
  });
17
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  declare const _default: import("@coffer-org/sdk/extend").ExtendDef;
2
2
  export default _default;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,3 @@
1
- /**
2
- * Extend: канон ідентичності людини (не прив'язано до фізичного документа).
3
- * Прив'язується до people/person. На відміну від personal_document (дані,
4
- * розпізнані з конкретного фізичного документа) — це канонічні значення.
5
- */
6
1
  import { defineExtend } from '@coffer-org/sdk/extend';
7
2
  import { field } from '@coffer-org/sdk/fields';
8
3
  export default defineExtend({
@@ -10,21 +5,18 @@ export default defineExtend({
10
5
  label: 'documents.person_identity.label',
11
6
  icon: 'lucide:globe',
12
7
  attachTo: [{ vault: 'people', module: 'person' }],
13
- claude: `Канон ідентичності людини (не прив'язано до фізичного документа).
14
- nationality — ISO alpha-2. variants — ім'я/прізвище мовами (field.group multiple: lang+name+surname).`,
8
+ claude: `Canonical person identity (not tied to a physical document).
9
+ nationality — ISO alpha-2. variants — given/family name per language (field.group multiple: lang+name+surname).`,
15
10
  fields: [
16
11
  field.select({ key: 'nationality', label: 'documents.person_identity.fields.nationality', options: 'countries' }),
17
- field.group({
12
+ field.keyed({
18
13
  key: 'variants',
19
14
  label: 'documents.person_identity.fields.variants',
20
- multiple: true,
21
- unique: ['lang'],
15
+ by: field.select({ key: 'lang', label: 'documents.person_identity.variants.lang', options: 'languages' }),
22
16
  fields: [
23
- field.select({ key: 'lang', label: 'documents.person_identity.variants.lang', options: 'languages' }),
24
17
  field.string({ key: 'name', label: 'documents.person_identity.variants.name' }),
25
18
  field.string({ key: 'surname', label: 'documents.person_identity.variants.surname' }),
26
19
  ],
27
20
  }),
28
21
  ],
29
22
  });
30
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  declare const _default: import("@coffer-org/sdk/module").ModuleDef;
2
2
  export default _default;
3
- //# sourceMappingURL=index.d.ts.map
@@ -11,9 +11,9 @@ export default defineModule({
11
11
  fields: [
12
12
  field.title({ key: 'name', label: 'core.fields.name' }),
13
13
  field.image({ key: 'logo', label: 'documents.personal_document.fields.logo' }),
14
- field.text({ key: 'description', label: 'documents.personal_document.fields.description', max: 1000 }),
15
- field.string({ key: 'surname', label: 'documents.personal_document.fields.surname', config: { max: 100 } }),
16
- field.string({ key: 'given_names', label: 'documents.personal_document.fields.given_names', config: { max: 200 } }),
14
+ field.text({ key: 'description', label: 'documents.personal_document.fields.description', rules: { max: 1000 } }),
15
+ field.string({ key: 'surname', label: 'documents.personal_document.fields.surname', rules: { max: 100 } }),
16
+ field.string({ key: 'given_names', label: 'documents.personal_document.fields.given_names', rules: { max: 200 } }),
17
17
  field.select({
18
18
  key: 'sex',
19
19
  label: 'documents.personal_document.fields.sex',
@@ -24,27 +24,20 @@ export default defineModule({
24
24
  }),
25
25
  field.date({ key: 'birth_date', label: 'documents.personal_document.fields.birth_date' }),
26
26
  field.select({ key: 'nationality', label: 'documents.personal_document.fields.nationality', options: 'countries' }),
27
- field.string({ key: 'number', label: 'documents.personal_document.fields.number', config: { max: 50 } }),
28
- field.string({ key: 'record_no', label: 'documents.personal_document.fields.record_no', config: { max: 50 } }),
27
+ field.string({ key: 'number', label: 'documents.personal_document.fields.number', rules: { max: 50 } }),
28
+ field.string({ key: 'record_no', label: 'documents.personal_document.fields.record_no', rules: { max: 50 } }),
29
29
  field.date({ key: 'issued', label: 'documents.personal_document.fields.issued' }),
30
- field.date({ key: 'expires', label: 'documents.personal_document.fields.expires' }),
31
- field.string({ key: 'authority', label: 'documents.personal_document.fields.authority', config: { max: 200 } }),
32
- field.select({
33
- key: 'country_code',
34
- label: 'documents.personal_document.fields.country_code',
35
- options: 'countries',
36
- }),
37
- field.string({ key: 'storage', label: 'documents.personal_document.fields.storage', config: { max: 200 } }),
38
- field.string({ key: 'mrz', label: 'documents.personal_document.fields.mrz', config: { max: 200 } }),
39
- field.int({ key: 'remind_days', label: 'documents.personal_document.fields.remind_days', config: { min: 0 } }),
30
+ field.reminder({ key: 'expires', label: 'documents.personal_document.fields.expires', rules: { lead: 60 } }),
31
+ field.string({ key: 'authority', label: 'documents.personal_document.fields.authority', rules: { max: 200 } }),
32
+ field.relation({ key: 'storage', label: 'documents.personal_document.fields.storage', options: { vault: 'things', module: 'storage_location' } }),
33
+ field.string({ key: 'mrz', label: 'documents.personal_document.fields.mrz', rules: { max: 200 } }),
40
34
  field.relation({
41
35
  key: 'owner',
42
36
  label: 'documents.personal_document.fields.owner',
43
- vault: 'people',
44
- module: 'person',
37
+ options: { vault: 'people', module: 'person' },
45
38
  }),
46
39
  field.image({ key: 'photos', label: 'documents.personal_document.fields.photos', multiple: true }),
47
- field.text({ key: 'notes', label: 'documents.personal_document.fields.notes', max: 1000 }),
40
+ field.text({ key: 'notes', label: 'documents.personal_document.fields.notes', rules: { max: 1000 } }),
48
41
  field.select({
49
42
  key: 'type',
50
43
  label: 'core.fields.type',
@@ -63,4 +56,3 @@ export default defineModule({
63
56
  field.tags({ key: 'tags', label: 'documents.personal_document.fields.tags' }),
64
57
  ],
65
58
  });
66
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import type { PluginHooks } from '@coffer-org/server/plugin-hooks';
2
+ export declare const serverHooks: PluginHooks;
@@ -0,0 +1,90 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { localPost } from '@coffer-org/server/local-api';
3
+ import { seedAsset } from '@coffer-org/server/uploads';
4
+ const asset = (rel) => fileURLToPath(new URL(`../../seed/assets/${rel}`, import.meta.url));
5
+ export const serverHooks = {
6
+ migrations: [
7
+ {
8
+ version: 1,
9
+ up: async ({ table }) => {
10
+ await table('documents__personal_document').changeType('storage', 'text', {
11
+ transform: (old) => {
12
+ if (old)
13
+ console.warn(`[documents migration] storage reset: ${String(old)}`);
14
+ return null;
15
+ },
16
+ });
17
+ },
18
+ },
19
+ ],
20
+ seed: [
21
+ {
22
+ name: 'demo-documents',
23
+ run: async () => {
24
+ const logo = seedAsset(asset('document.svg'));
25
+ await localPost('documents', 'personal_document', {
26
+ name: 'Passport',
27
+ type: 'P',
28
+ logo,
29
+ surname: 'Johnson',
30
+ given_names: 'Emma',
31
+ sex: 'F',
32
+ birth_date: '1990-04-17',
33
+ nationality: 'US',
34
+ number: 'FA123456',
35
+ record_no: '19900417-12345',
36
+ issued: '2018-05-20',
37
+ expires: '2028-05-20',
38
+ authority: '8025',
39
+ mrz: 'P<USAJOHNSON<<EMMA<<<<<<<<<<<<<<<<<<<<<<<<<<\nFA1234567USA9004173F2805201<<<<<<<<<<<<<<00',
40
+ notes: 'Biometric international passport. Keep in the safe.',
41
+ photos: [logo],
42
+ tags: ['passport', 'personal'],
43
+ });
44
+ await localPost('documents', 'personal_document', {
45
+ name: 'ID card',
46
+ type: 'ID',
47
+ logo,
48
+ surname: 'Miller',
49
+ given_names: 'James',
50
+ sex: 'M',
51
+ birth_date: '1985-11-02',
52
+ nationality: 'US',
53
+ number: '001234567',
54
+ record_no: '19851102-67890',
55
+ issued: '2019-02-14',
56
+ expires: '2029-02-14',
57
+ authority: '4641',
58
+ mrz: 'IDUSA0012345677<<<<<<<<<<<<<<<\n8511020M2902145USA<<<<<<<<<<<4',
59
+ notes: 'National ID card. Linked to the record in the demographic registry.',
60
+ photos: [logo],
61
+ tags: ['id', 'personal'],
62
+ });
63
+ await localPost('documents', 'personal_document', {
64
+ name: "Driver's license",
65
+ type: 'DL',
66
+ logo,
67
+ surname: 'Davis',
68
+ given_names: 'Olivia',
69
+ sex: 'F',
70
+ birth_date: '1978-07-29',
71
+ nationality: 'US',
72
+ number: 'ABC123456',
73
+ record_no: '19780729-11223',
74
+ issued: '2021-09-01',
75
+ expires: '2031-09-01',
76
+ authority: 'DMV 8041',
77
+ mrz: '',
78
+ notes: 'Categories B, C. Duplicate obtained after a replacement.',
79
+ photos: [logo],
80
+ tags: ['auto', 'personal'],
81
+ });
82
+ },
83
+ },
84
+ ],
85
+ agent: {
86
+ instructions: 'Vault documents — personal documents (personal_document): type, number, issued/expires (ISO), ' +
87
+ 'authority, owner (relation to people). Expiring documents — count by expires.' +
88
+ ' When a document is reissued — update number/issued/expires via update_record.',
89
+ },
90
+ };
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@coffer-org/plugin-documents",
3
- "version": "1.1.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
+ "engines": {
6
+ "node": ">=24"
7
+ },
5
8
  "files": [
6
- "dist"
9
+ "dist",
10
+ "seed"
7
11
  ],
8
12
  "exports": {
9
13
  ".": {
10
14
  "types": "./dist/index.d.ts",
11
15
  "default": "./dist/index.js"
16
+ },
17
+ "./runtime": {
18
+ "types": "./dist/runtime/index.d.ts",
19
+ "default": "./dist/runtime/index.js"
12
20
  }
13
21
  },
14
22
  "scripts": {
@@ -17,6 +25,7 @@
17
25
  "postpack": "node ../../scripts/swap-exports.mjs src"
18
26
  },
19
27
  "dependencies": {
20
- "@coffer-org/sdk": "^1.1.0"
28
+ "@coffer-org/sdk": "^1.2.2",
29
+ "@coffer-org/server": "^1.2.2"
21
30
  }
22
31
  }
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" fill="none">
2
+ <rect x="12" y="6" width="40" height="52" rx="4" fill="#0ea5e9"/>
3
+ <rect x="20" y="16" width="24" height="6" rx="2" fill="#e0f2fe"/>
4
+ <rect x="20" y="28" width="24" height="4" rx="2" fill="#bae6fd"/>
5
+ <rect x="20" y="38" width="18" height="4" rx="2" fill="#bae6fd"/>
6
+ <rect x="20" y="46" width="14" height="4" rx="2" fill="#bae6fd"/>
7
+ </svg>
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,wBAWG"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,cAAc,MAAM,4BAA4B,CAAC;AAExD,eAAe,YAAY,CAAC;IAC1B,EAAE,EAAE,WAAW;IACf,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;YAC9F,OAAO,EAAE,CAAC,iBAAiB,CAAC;SAC7B;KACF;IACD,QAAQ,EAAE,CAAC,cAAc,CAAC;CAC3B,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/person_identity/index.ts"],"names":[],"mappings":";AAQA,wBAqBG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/person_identity/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,eAAe,YAAY,CAAC;IAC1B,EAAE,EAAE,iBAAiB;IACrB,KAAK,EAAE,iCAAiC;IACxC,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACjD,MAAM,EAAE;sGAC4F;IACpG,MAAM,EAAE;QACN,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,8CAA8C,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QACjH,KAAK,CAAC,KAAK,CAAC;YACV,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,2CAA2C;YAClD,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,MAAM,EAAE;gBACN,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,yCAAyC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;gBACrG,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;gBAC/E,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,4CAA4C,EAAE,CAAC;aACtF;SACF,CAAC;KACH;CACF,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/personal_document/index.ts"],"names":[],"mappings":";AAGA,wBA8DG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/personal_document/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CA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