@coffer-org/plugin-documents 1.3.1 → 1.4.0
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineLibrary } from '@coffer-org/sdk/library';
|
|
2
2
|
import { definePlugin } from '@coffer-org/sdk/plugin';
|
|
3
3
|
import personal_document from "./personal_document/index.js";
|
|
4
4
|
import personIdentity from "./person_identity/index.js";
|
|
@@ -6,10 +6,10 @@ export default definePlugin({
|
|
|
6
6
|
id: 'documents',
|
|
7
7
|
version: '1.0.0',
|
|
8
8
|
dependsOn: ['people'],
|
|
9
|
-
|
|
9
|
+
libraries: [
|
|
10
10
|
{
|
|
11
|
-
meta:
|
|
12
|
-
|
|
11
|
+
meta: defineLibrary({ id: 'documents', label: 'documents.library.label', icon: 'lucide:id-card', agent: 'Personal documents — IDs, passports, licences (personal_document); tracks expiry.' }),
|
|
12
|
+
shelves: [personal_document],
|
|
13
13
|
},
|
|
14
14
|
],
|
|
15
15
|
extends_: [personIdentity],
|
|
@@ -4,7 +4,7 @@ export default defineExtend({
|
|
|
4
4
|
id: 'person_identity',
|
|
5
5
|
label: 'documents.person_identity.label',
|
|
6
6
|
icon: 'lucide:globe',
|
|
7
|
-
attachTo: [{
|
|
7
|
+
attachTo: [{ library: 'people', shelf: 'person' }],
|
|
8
8
|
claude: `Canonical person identity (not tied to a physical document).
|
|
9
9
|
nationality — ISO alpha-2. variants — given/family name per language (field.group multiple: lang+name+surname).`,
|
|
10
10
|
fields: [
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@coffer-org/sdk/
|
|
1
|
+
declare const _default: import("@coffer-org/sdk/shelf").ShelfDef;
|
|
2
2
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineShelf } from '@coffer-org/sdk/shelf';
|
|
2
2
|
import { field } from '@coffer-org/sdk/fields';
|
|
3
|
-
export default
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default defineShelf({
|
|
4
|
+
shelf: 'personal_document',
|
|
5
|
+
library: 'documents',
|
|
6
6
|
label: 'documents.personal_document.label',
|
|
7
7
|
icon: 'lucide:id-card',
|
|
8
8
|
views: {
|
|
@@ -29,12 +29,12 @@ export default defineModule({
|
|
|
29
29
|
field.date({ key: 'issued', label: 'documents.personal_document.fields.issued' }),
|
|
30
30
|
field.reminder({ key: 'expires', label: 'documents.personal_document.fields.expires', rules: { lead: 60 } }),
|
|
31
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: {
|
|
32
|
+
field.relation({ key: 'storage', label: 'documents.personal_document.fields.storage', options: { library: 'things', shelf: 'storage_location' } }),
|
|
33
33
|
field.string({ key: 'mrz', label: 'documents.personal_document.fields.mrz', rules: { max: 200 } }),
|
|
34
34
|
field.relation({
|
|
35
35
|
key: 'owner',
|
|
36
36
|
label: 'documents.personal_document.fields.owner',
|
|
37
|
-
options: {
|
|
37
|
+
options: { library: 'people', shelf: 'person' },
|
|
38
38
|
}),
|
|
39
39
|
field.image({ key: 'photos', label: 'documents.personal_document.fields.photos', multiple: true }),
|
|
40
40
|
field.text({ key: 'notes', label: 'documents.personal_document.fields.notes', rules: { max: 1000 } }),
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
1
|
import { localPost } from '@coffer-org/server/local-api';
|
|
3
|
-
import { seedAsset } from '@coffer-org/server/uploads';
|
|
2
|
+
import { seedAsset, seedAssetPath } from '@coffer-org/server/uploads';
|
|
4
3
|
import { getLogger } from '@coffer-org/sdk/logger';
|
|
5
4
|
const log = getLogger('documents');
|
|
6
|
-
const asset = (
|
|
5
|
+
const asset = seedAssetPath(import.meta.url);
|
|
7
6
|
export const serverHooks = {
|
|
8
7
|
migrations: [
|
|
9
8
|
{
|
|
@@ -85,8 +84,6 @@ export const serverHooks = {
|
|
|
85
84
|
},
|
|
86
85
|
],
|
|
87
86
|
agent: {
|
|
88
|
-
instructions: '
|
|
89
|
-
'authority, owner (relation to people). Expiring documents — count by expires.' +
|
|
90
|
-
' When a document is reissued — update number/issued/expires via update_record.',
|
|
87
|
+
instructions: 'Expiring documents — count by expires. When a document is reissued — update number/issued/expires via update_record.',
|
|
91
88
|
},
|
|
92
89
|
};
|
package/dist/schema.js
CHANGED
|
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region ../sdk/src/
|
|
25
|
-
function
|
|
24
|
+
//#region ../sdk/src/library.ts
|
|
25
|
+
function defineLibrary(v) {
|
|
26
26
|
return v;
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
@@ -154,7 +154,10 @@ function assignProp(target, prop, value) {
|
|
|
154
154
|
}
|
|
155
155
|
function mergeDefs(...defs) {
|
|
156
156
|
const mergedDescriptors = {};
|
|
157
|
-
for (const def of defs)
|
|
157
|
+
for (const def of defs) {
|
|
158
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
159
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
160
|
+
}
|
|
158
161
|
return Object.defineProperties({}, mergedDescriptors);
|
|
159
162
|
}
|
|
160
163
|
function esc(str) {
|
|
@@ -476,7 +479,7 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
476
479
|
}, ctx);
|
|
477
480
|
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
478
481
|
if (result.issues.length) {
|
|
479
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
482
|
+
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
480
483
|
captureStackTrace(e, _params?.callee);
|
|
481
484
|
throw e;
|
|
482
485
|
}
|
|
@@ -493,7 +496,7 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
493
496
|
}, ctx);
|
|
494
497
|
if (result instanceof Promise) result = await result;
|
|
495
498
|
if (result.issues.length) {
|
|
496
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
499
|
+
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
497
500
|
captureStackTrace(e, params?.callee);
|
|
498
501
|
throw e;
|
|
499
502
|
}
|
|
@@ -1945,7 +1948,7 @@ var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
|
|
|
1945
1948
|
inst._zod.optin = "optional";
|
|
1946
1949
|
inst._zod.optout = "optional";
|
|
1947
1950
|
defineLazy(inst._zod, "values", () => {
|
|
1948
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1951
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1949
1952
|
});
|
|
1950
1953
|
defineLazy(inst._zod, "pattern", () => {
|
|
1951
1954
|
const pattern = def.innerType._zod.pattern;
|
|
@@ -1979,7 +1982,7 @@ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
|
|
|
1979
1982
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1980
1983
|
});
|
|
1981
1984
|
defineLazy(inst._zod, "values", () => {
|
|
1982
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1985
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1983
1986
|
});
|
|
1984
1987
|
inst._zod.parse = (payload, ctx) => {
|
|
1985
1988
|
if (payload.value === null) return payload;
|
|
@@ -4587,7 +4590,7 @@ function password(raw) {
|
|
|
4587
4590
|
* Internal API-token list — keyValue-shaped collection (name + write-only
|
|
4588
4591
|
* token + timestamps), custom renderer (`kind:'internalApiToken'`, own
|
|
4589
4592
|
* create/revoke UI — same trick as url()/perWeekday()). "Internal" = not a
|
|
4590
|
-
* general-purpose field type for plugin
|
|
4593
|
+
* general-purpose field type for plugin shelves, only for the core account
|
|
4591
4594
|
* settings page. `token` is `kind:'password'` so maskSecrets/preserveTree
|
|
4592
4595
|
* already mask/preserve it for free.
|
|
4593
4596
|
*/
|
|
@@ -4686,7 +4689,7 @@ var TEL_RE = /^\+?[\d\s()-]{4,}$/;
|
|
|
4686
4689
|
/** Loose URL: будь-який scheme:// АБО host-з-крапкою (+опц. порт/шлях). Без пробілів. */
|
|
4687
4690
|
var LINK_RE = /^([a-z][a-z0-9+.-]*:\/\/\S+|[\w-]+(\.[\w-]+)+(:\d+)?(\/\S*)?)$/i;
|
|
4688
4691
|
/** CSS named colors (CSS Color Module L4) — для f.colorname. */
|
|
4689
|
-
var CSS_COLOR_NAMES = new Set([
|
|
4692
|
+
var CSS_COLOR_NAMES = /* @__PURE__ */ new Set([
|
|
4690
4693
|
"aliceblue",
|
|
4691
4694
|
"antiquewhite",
|
|
4692
4695
|
"aqua",
|
|
@@ -5147,7 +5150,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5147
5150
|
},
|
|
5148
5151
|
cs: {
|
|
5149
5152
|
name: "Czech",
|
|
5150
|
-
nativeName: "
|
|
5153
|
+
nativeName: "čeština"
|
|
5151
5154
|
},
|
|
5152
5155
|
cu: {
|
|
5153
5156
|
name: "Old Church Slavonic",
|
|
@@ -5611,7 +5614,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5611
5614
|
},
|
|
5612
5615
|
sk: {
|
|
5613
5616
|
name: "Slovak",
|
|
5614
|
-
nativeName: "
|
|
5617
|
+
nativeName: "slovenčtina"
|
|
5615
5618
|
},
|
|
5616
5619
|
sl: {
|
|
5617
5620
|
name: "Slovenian",
|
|
@@ -5992,6 +5995,34 @@ function wrapKey(opts, meta) {
|
|
|
5992
5995
|
noEditControl: true
|
|
5993
5996
|
}
|
|
5994
5997
|
};
|
|
5998
|
+
if (opts.emphasis) m = {
|
|
5999
|
+
...m,
|
|
6000
|
+
hints: {
|
|
6001
|
+
...m.hints,
|
|
6002
|
+
emphasis: opts.emphasis
|
|
6003
|
+
}
|
|
6004
|
+
};
|
|
6005
|
+
if (opts.noLabel) m = {
|
|
6006
|
+
...m,
|
|
6007
|
+
hints: {
|
|
6008
|
+
...m.hints,
|
|
6009
|
+
noLabel: true
|
|
6010
|
+
}
|
|
6011
|
+
};
|
|
6012
|
+
if (opts.role) m = {
|
|
6013
|
+
...m,
|
|
6014
|
+
hints: {
|
|
6015
|
+
...m.hints,
|
|
6016
|
+
role: opts.role
|
|
6017
|
+
}
|
|
6018
|
+
};
|
|
6019
|
+
if (opts.pinned) m = {
|
|
6020
|
+
...m,
|
|
6021
|
+
hints: {
|
|
6022
|
+
...m.hints,
|
|
6023
|
+
pinned: true
|
|
6024
|
+
}
|
|
6025
|
+
};
|
|
5995
6026
|
if (opts.default !== void 0) m = {
|
|
5996
6027
|
...m,
|
|
5997
6028
|
default: opts.default
|
|
@@ -6355,8 +6386,8 @@ function relation(raw) {
|
|
|
6355
6386
|
displayKey: o.displayKey ?? "name"
|
|
6356
6387
|
},
|
|
6357
6388
|
relation: {
|
|
6358
|
-
|
|
6359
|
-
type: raw.options.
|
|
6389
|
+
library: raw.options.library,
|
|
6390
|
+
type: raw.options.shelf
|
|
6360
6391
|
},
|
|
6361
6392
|
...multi && { json: true },
|
|
6362
6393
|
zod: optionalize(s, required)
|
|
@@ -7676,7 +7707,7 @@ var createDefaultQueryTester = function(query, options) {
|
|
|
7676
7707
|
};
|
|
7677
7708
|
createDefaultQueryTester.createEqualsOperation;
|
|
7678
7709
|
//#endregion
|
|
7679
|
-
//#region ../sdk/src/
|
|
7710
|
+
//#region ../sdk/src/shelf.ts
|
|
7680
7711
|
/** Flat [storageKey, FieldMeta] pairs of the parent table's columns.
|
|
7681
7712
|
* layout group → flattened; embedded group → prefix `key__`; collection → skipped. */
|
|
7682
7713
|
function fieldEntries(items) {
|
|
@@ -7689,18 +7720,18 @@ function fieldEntries(items) {
|
|
|
7689
7720
|
}
|
|
7690
7721
|
return out;
|
|
7691
7722
|
}
|
|
7692
|
-
function
|
|
7723
|
+
function defineShelf(m) {
|
|
7693
7724
|
const keys = fieldEntries(m.fields).map(([k]) => k);
|
|
7694
7725
|
const dup = keys.find((k, i) => keys.indexOf(k) !== i);
|
|
7695
|
-
if (dup) throw new Error(`[
|
|
7696
|
-
if (m.standalone !== false && !m.views?.table?.length) console.warn(`[
|
|
7726
|
+
if (dup) throw new Error(`[shelf] ${m.library}/${m.shelf}: duplicate key '${dup}'`);
|
|
7727
|
+
if (m.standalone !== false && !m.views?.table?.length) console.warn(`[shelf] ${m.library}/${m.shelf}: standalone shelf without an explicit views.table`);
|
|
7697
7728
|
return m;
|
|
7698
7729
|
}
|
|
7699
7730
|
//#endregion
|
|
7700
7731
|
//#region src/personal_document/index.ts
|
|
7701
|
-
var personal_document_default =
|
|
7702
|
-
|
|
7703
|
-
|
|
7732
|
+
var personal_document_default = defineShelf({
|
|
7733
|
+
shelf: "personal_document",
|
|
7734
|
+
library: "documents",
|
|
7704
7735
|
label: "documents.personal_document.label",
|
|
7705
7736
|
icon: "lucide:id-card",
|
|
7706
7737
|
views: { table: [
|
|
@@ -7781,8 +7812,8 @@ var personal_document_default = defineModule({
|
|
|
7781
7812
|
key: "storage",
|
|
7782
7813
|
label: "documents.personal_document.fields.storage",
|
|
7783
7814
|
options: {
|
|
7784
|
-
|
|
7785
|
-
|
|
7815
|
+
library: "things",
|
|
7816
|
+
shelf: "storage_location"
|
|
7786
7817
|
}
|
|
7787
7818
|
}),
|
|
7788
7819
|
field.string({
|
|
@@ -7794,8 +7825,8 @@ var personal_document_default = defineModule({
|
|
|
7794
7825
|
key: "owner",
|
|
7795
7826
|
label: "documents.personal_document.fields.owner",
|
|
7796
7827
|
options: {
|
|
7797
|
-
|
|
7798
|
-
|
|
7828
|
+
library: "people",
|
|
7829
|
+
shelf: "person"
|
|
7799
7830
|
}
|
|
7800
7831
|
}),
|
|
7801
7832
|
field.image({
|
|
@@ -7873,8 +7904,8 @@ var person_identity_default = defineExtend({
|
|
|
7873
7904
|
label: "documents.person_identity.label",
|
|
7874
7905
|
icon: "lucide:globe",
|
|
7875
7906
|
attachTo: [{
|
|
7876
|
-
|
|
7877
|
-
|
|
7907
|
+
library: "people",
|
|
7908
|
+
shelf: "person"
|
|
7878
7909
|
}],
|
|
7879
7910
|
claude: `Canonical person identity (not tied to a physical document).
|
|
7880
7911
|
nationality — ISO alpha-2. variants — given/family name per language (field.group multiple: lang+name+surname).`,
|
|
@@ -7905,13 +7936,14 @@ var src_default = definePlugin({
|
|
|
7905
7936
|
id: "documents",
|
|
7906
7937
|
version: "1.0.0",
|
|
7907
7938
|
dependsOn: ["people"],
|
|
7908
|
-
|
|
7909
|
-
meta:
|
|
7939
|
+
libraries: [{
|
|
7940
|
+
meta: defineLibrary({
|
|
7910
7941
|
id: "documents",
|
|
7911
|
-
label: "documents.
|
|
7912
|
-
icon: "lucide:id-card"
|
|
7942
|
+
label: "documents.library.label",
|
|
7943
|
+
icon: "lucide:id-card",
|
|
7944
|
+
agent: "Personal documents — IDs, passports, licences (personal_document); tracks expiry."
|
|
7913
7945
|
}),
|
|
7914
|
-
|
|
7946
|
+
shelves: [personal_document_default]
|
|
7915
7947
|
}],
|
|
7916
7948
|
extends_: [person_identity_default]
|
|
7917
7949
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffer-org/plugin-documents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"postpack": "node ../../scripts/swap-exports.mjs src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@coffer-org/sdk": "^1.
|
|
29
|
-
"@coffer-org/server": "^1.
|
|
28
|
+
"@coffer-org/sdk": "^1.5.0",
|
|
29
|
+
"@coffer-org/server": "^1.8.0"
|
|
30
30
|
},
|
|
31
31
|
"coffer": {
|
|
32
32
|
"schema": "dist/schema.js"
|