@coffer-org/plugin-documents 1.3.1 → 1.4.1

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 { defineVault } from '@coffer-org/sdk/vault';
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
- vaults: [
9
+ libraries: [
10
10
  {
11
- meta: defineVault({ id: 'documents', label: 'documents.vault.label', icon: 'lucide:id-card' }),
12
- modules: [personal_document],
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: [{ vault: 'people', module: 'person' }],
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/module").ModuleDef;
1
+ declare const _default: import("@coffer-org/sdk/shelf").ShelfDef;
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
- import { defineModule } from '@coffer-org/sdk/module';
1
+ import { defineShelf } from '@coffer-org/sdk/shelf';
2
2
  import { field } from '@coffer-org/sdk/fields';
3
- export default defineModule({
4
- module: 'personal_document',
5
- vault: 'documents',
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: { vault: 'things', module: 'storage_location' } }),
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: { vault: 'people', module: 'person' },
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 } }),
@@ -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 = (rel) => fileURLToPath(new URL(`../../seed/assets/${rel}`, import.meta.url));
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: 'Vault documents — personal documents (personal_document): type, number, issued/expires (ISO), ' +
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/vault.ts
25
- function defineVault(v) {
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) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
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 modules, only for the core account
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
  */
@@ -4606,6 +4609,25 @@ function internalApiToken(o) {
4606
4609
  ]
4607
4610
  });
4608
4611
  }
4612
+ /**
4613
+ * Internal "connected apps" list — the OAuth clients (claude.ai & co) the user
4614
+ * has authorized for MCP access. Same "internal" caveat and custom-renderer
4615
+ * trick as internalApiToken(): read-only rows + a revoke action, never part of
4616
+ * the parent form's save.
4617
+ */
4618
+ function internalOauthGrants(o) {
4619
+ return group({
4620
+ key: o.key,
4621
+ label: o.label ?? o.key,
4622
+ multiple: true,
4623
+ view: { kind: "internalOauthGrants" },
4624
+ fields: [
4625
+ string({ key: "clientName" }),
4626
+ string({ key: "createdAt" }),
4627
+ string({ key: "lastUsedAt" })
4628
+ ]
4629
+ });
4630
+ }
4609
4631
  var SLUG_RE = /^[a-z0-9-]+$/;
4610
4632
  function slug(raw) {
4611
4633
  const o = normalizeOpts(raw);
@@ -4686,7 +4708,7 @@ var TEL_RE = /^\+?[\d\s()-]{4,}$/;
4686
4708
  /** Loose URL: будь-який scheme:// АБО host-з-крапкою (+опц. порт/шлях). Без пробілів. */
4687
4709
  var LINK_RE = /^([a-z][a-z0-9+.-]*:\/\/\S+|[\w-]+(\.[\w-]+)+(:\d+)?(\/\S*)?)$/i;
4688
4710
  /** CSS named colors (CSS Color Module L4) — для f.colorname. */
4689
- var CSS_COLOR_NAMES = new Set([
4711
+ var CSS_COLOR_NAMES = /* @__PURE__ */ new Set([
4690
4712
  "aliceblue",
4691
4713
  "antiquewhite",
4692
4714
  "aqua",
@@ -5035,7 +5057,8 @@ var presets = {
5035
5057
  weight,
5036
5058
  dimensions,
5037
5059
  country,
5038
- internalApiToken
5060
+ internalApiToken,
5061
+ internalOauthGrants
5039
5062
  };
5040
5063
  //#endregion
5041
5064
  //#region ../../node_modules/iso-639-1/src/data.js
@@ -5147,7 +5170,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5147
5170
  },
5148
5171
  cs: {
5149
5172
  name: "Czech",
5150
- nativeName: "Čeština"
5173
+ nativeName: "čeština"
5151
5174
  },
5152
5175
  cu: {
5153
5176
  name: "Old Church Slavonic",
@@ -5611,7 +5634,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5611
5634
  },
5612
5635
  sk: {
5613
5636
  name: "Slovak",
5614
- nativeName: "Slovenčina"
5637
+ nativeName: "slovenčtina"
5615
5638
  },
5616
5639
  sl: {
5617
5640
  name: "Slovenian",
@@ -5992,6 +6015,34 @@ function wrapKey(opts, meta) {
5992
6015
  noEditControl: true
5993
6016
  }
5994
6017
  };
6018
+ if (opts.emphasis) m = {
6019
+ ...m,
6020
+ hints: {
6021
+ ...m.hints,
6022
+ emphasis: opts.emphasis
6023
+ }
6024
+ };
6025
+ if (opts.noLabel) m = {
6026
+ ...m,
6027
+ hints: {
6028
+ ...m.hints,
6029
+ noLabel: true
6030
+ }
6031
+ };
6032
+ if (opts.role) m = {
6033
+ ...m,
6034
+ hints: {
6035
+ ...m.hints,
6036
+ role: opts.role
6037
+ }
6038
+ };
6039
+ if (opts.pinned) m = {
6040
+ ...m,
6041
+ hints: {
6042
+ ...m.hints,
6043
+ pinned: true
6044
+ }
6045
+ };
5995
6046
  if (opts.default !== void 0) m = {
5996
6047
  ...m,
5997
6048
  default: opts.default
@@ -6355,8 +6406,8 @@ function relation(raw) {
6355
6406
  displayKey: o.displayKey ?? "name"
6356
6407
  },
6357
6408
  relation: {
6358
- vault: raw.options.vault,
6359
- type: raw.options.module
6409
+ library: raw.options.library,
6410
+ type: raw.options.shelf
6360
6411
  },
6361
6412
  ...multi && { json: true },
6362
6413
  zod: optionalize(s, required)
@@ -7676,7 +7727,7 @@ var createDefaultQueryTester = function(query, options) {
7676
7727
  };
7677
7728
  createDefaultQueryTester.createEqualsOperation;
7678
7729
  //#endregion
7679
- //#region ../sdk/src/module.ts
7730
+ //#region ../sdk/src/shelf.ts
7680
7731
  /** Flat [storageKey, FieldMeta] pairs of the parent table's columns.
7681
7732
  * layout group → flattened; embedded group → prefix `key__`; collection → skipped. */
7682
7733
  function fieldEntries(items) {
@@ -7689,18 +7740,18 @@ function fieldEntries(items) {
7689
7740
  }
7690
7741
  return out;
7691
7742
  }
7692
- function defineModule(m) {
7743
+ function defineShelf(m) {
7693
7744
  const keys = fieldEntries(m.fields).map(([k]) => k);
7694
7745
  const dup = keys.find((k, i) => keys.indexOf(k) !== i);
7695
- if (dup) throw new Error(`[module] ${m.vault}/${m.module}: duplicate key '${dup}'`);
7696
- if (m.standalone !== false && !m.views?.table?.length) console.warn(`[module] ${m.vault}/${m.module}: standalone module without an explicit views.table`);
7746
+ if (dup) throw new Error(`[shelf] ${m.library}/${m.shelf}: duplicate key '${dup}'`);
7747
+ if (m.standalone !== false && !m.views?.table?.length) console.warn(`[shelf] ${m.library}/${m.shelf}: standalone shelf without an explicit views.table`);
7697
7748
  return m;
7698
7749
  }
7699
7750
  //#endregion
7700
7751
  //#region src/personal_document/index.ts
7701
- var personal_document_default = defineModule({
7702
- module: "personal_document",
7703
- vault: "documents",
7752
+ var personal_document_default = defineShelf({
7753
+ shelf: "personal_document",
7754
+ library: "documents",
7704
7755
  label: "documents.personal_document.label",
7705
7756
  icon: "lucide:id-card",
7706
7757
  views: { table: [
@@ -7781,8 +7832,8 @@ var personal_document_default = defineModule({
7781
7832
  key: "storage",
7782
7833
  label: "documents.personal_document.fields.storage",
7783
7834
  options: {
7784
- vault: "things",
7785
- module: "storage_location"
7835
+ library: "things",
7836
+ shelf: "storage_location"
7786
7837
  }
7787
7838
  }),
7788
7839
  field.string({
@@ -7794,8 +7845,8 @@ var personal_document_default = defineModule({
7794
7845
  key: "owner",
7795
7846
  label: "documents.personal_document.fields.owner",
7796
7847
  options: {
7797
- vault: "people",
7798
- module: "person"
7848
+ library: "people",
7849
+ shelf: "person"
7799
7850
  }
7800
7851
  }),
7801
7852
  field.image({
@@ -7873,8 +7924,8 @@ var person_identity_default = defineExtend({
7873
7924
  label: "documents.person_identity.label",
7874
7925
  icon: "lucide:globe",
7875
7926
  attachTo: [{
7876
- vault: "people",
7877
- module: "person"
7927
+ library: "people",
7928
+ shelf: "person"
7878
7929
  }],
7879
7930
  claude: `Canonical person identity (not tied to a physical document).
7880
7931
  nationality — ISO alpha-2. variants — given/family name per language (field.group multiple: lang+name+surname).`,
@@ -7905,13 +7956,14 @@ var src_default = definePlugin({
7905
7956
  id: "documents",
7906
7957
  version: "1.0.0",
7907
7958
  dependsOn: ["people"],
7908
- vaults: [{
7909
- meta: defineVault({
7959
+ libraries: [{
7960
+ meta: defineLibrary({
7910
7961
  id: "documents",
7911
- label: "documents.vault.label",
7912
- icon: "lucide:id-card"
7962
+ label: "documents.library.label",
7963
+ icon: "lucide:id-card",
7964
+ agent: "Personal documents — IDs, passports, licences (personal_document); tracks expiry."
7913
7965
  }),
7914
- modules: [personal_document_default]
7966
+ shelves: [personal_document_default]
7915
7967
  }],
7916
7968
  extends_: [person_identity_default]
7917
7969
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffer-org/plugin-documents",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -25,8 +25,9 @@
25
25
  "postpack": "node ../../scripts/swap-exports.mjs src"
26
26
  },
27
27
  "dependencies": {
28
- "@coffer-org/sdk": "^1.4.0",
29
- "@coffer-org/server": "^1.4.0"
28
+ "@coffer-org/plugin-people": "^1.4.0",
29
+ "@coffer-org/sdk": "^1.5.0",
30
+ "@coffer-org/server": "^1.8.0"
30
31
  },
31
32
  "coffer": {
32
33
  "schema": "dist/schema.js"