@geonosis/policy 2.13.0 → 3.1.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/conformance.cjs +169 -0
  3. package/dist/conformance.d.cts +35 -0
  4. package/dist/conformance.d.ts +35 -0
  5. package/dist/conformance.js +129 -0
  6. package/dist/define.cjs +118 -0
  7. package/dist/define.d.cts +34 -0
  8. package/dist/define.d.ts +34 -0
  9. package/dist/define.js +85 -0
  10. package/dist/drizzle/index.cjs +37 -32
  11. package/dist/drizzle/index.d.cts +20 -23
  12. package/dist/drizzle/index.d.ts +20 -23
  13. package/dist/drizzle/index.js +2 -5
  14. package/dist/index.cjs +79 -856
  15. package/dist/index.d.cts +19 -428
  16. package/dist/index.d.ts +19 -428
  17. package/dist/index.js +35 -797
  18. package/dist/journal-events.cjs +68 -0
  19. package/dist/journal-events.d.cts +26 -0
  20. package/dist/journal-events.d.ts +26 -0
  21. package/dist/journal-events.js +28 -0
  22. package/dist/lattice.cjs +150 -0
  23. package/dist/lattice.d.cts +48 -0
  24. package/dist/lattice.d.ts +48 -0
  25. package/dist/lattice.js +110 -0
  26. package/dist/learning.cjs +246 -0
  27. package/dist/learning.d.cts +121 -0
  28. package/dist/learning.d.ts +121 -0
  29. package/dist/learning.js +206 -0
  30. package/dist/markdown.cjs +118 -0
  31. package/dist/markdown.d.cts +35 -0
  32. package/dist/markdown.d.ts +35 -0
  33. package/dist/markdown.js +78 -0
  34. package/dist/medusa/index.cjs +39 -36
  35. package/dist/medusa/index.d.cts +14 -16
  36. package/dist/medusa/index.d.ts +14 -16
  37. package/dist/medusa/index.js +4 -9
  38. package/dist/permissions/index.cjs +49 -40
  39. package/dist/permissions/index.d.cts +18 -20
  40. package/dist/permissions/index.d.ts +18 -20
  41. package/dist/permissions/index.js +15 -25
  42. package/dist/read.cjs +111 -0
  43. package/dist/read.d.cts +51 -0
  44. package/dist/read.d.ts +51 -0
  45. package/dist/read.js +71 -0
  46. package/dist/rows.cjs +54 -0
  47. package/dist/rows.d.cts +11 -0
  48. package/dist/rows.d.ts +11 -0
  49. package/dist/{chunk-JICJ4XEX.js → rows.js} +0 -3
  50. package/dist/seed.cjs +53 -0
  51. package/dist/seed.d.cts +18 -0
  52. package/dist/seed.d.ts +18 -0
  53. package/dist/seed.js +13 -0
  54. package/dist/threshold.cjs +73 -0
  55. package/dist/threshold.d.cts +45 -0
  56. package/dist/threshold.d.ts +45 -0
  57. package/dist/threshold.js +33 -0
  58. package/dist/types.cjs +47 -0
  59. package/dist/{types-C-Q3r-In.d.cts → types.d.cts} +21 -23
  60. package/dist/{types-C-Q3r-In.d.ts → types.d.ts} +21 -23
  61. package/dist/types.js +7 -0
  62. package/package.json +3 -3
@@ -1,45 +1,50 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
11
13
  if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
15
20
  }
16
- return to;
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
17
37
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
38
 
20
39
  // src/drizzle/index.ts
21
- var drizzle_exports = {};
22
- __export(drizzle_exports, {
40
+ var exports_drizzle = {};
41
+ __export(exports_drizzle, {
23
42
  createDrizzlePolicyAdapter: () => createDrizzlePolicyAdapter,
24
43
  policyJournalColumns: () => policyJournalColumns,
25
44
  policyRuleColumns: () => policyRuleColumns
26
45
  });
27
- module.exports = __toCommonJS(drizzle_exports);
28
-
29
- // src/rows.ts
30
- var toPolicyRule = (row) => ({
31
- constraint: { kind: row.constraint_kind, value: row.constraint_value },
32
- id: row.rule_key,
33
- // Only `false` is worth carrying: `true` is the default a policy declares, and writing it back
34
- // would make a rule that never said anything indistinguishable from one that agreed.
35
- ...row.overridable === false ? { overridable: false } : {},
36
- reason: row.reason,
37
- ...row.scope ? { scope: row.scope } : {},
38
- tier: row.tier
39
- });
40
- var toPolicyRules = (rows) => rows.filter((row) => (row.status ?? "active") === "active").map(toPolicyRule);
41
-
42
- // src/drizzle/index.ts
46
+ module.exports = __toCommonJS(exports_drizzle);
47
+ var import_rows = require("../rows.cjs");
43
48
  var policyRuleColumns = {
44
49
  constraint_kind: "text",
45
50
  constraint_value: "json",
@@ -63,7 +68,7 @@ var attempt = async (what) => {
63
68
  try {
64
69
  return await what();
65
70
  } catch {
66
- return void 0;
71
+ return;
67
72
  }
68
73
  };
69
74
  var toRow = (entry) => ({
@@ -82,5 +87,5 @@ var createDrizzlePolicyAdapter = (options) => ({
82
87
  }
83
88
  } : {},
84
89
  name: "drizzle",
85
- rule: { rules: async () => toPolicyRules(await options.rules({ status: "active" }) ?? []) }
90
+ rule: { rules: async () => import_rows.toPolicyRules(await options.rules({ status: "active" }) ?? []) }
86
91
  });
@@ -1,5 +1,4 @@
1
- import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.cjs';
2
-
1
+ import type { Awaitable, PolicyAdapter, PolicyQuery, PolicyRuleRow } from '../types.cjs';
3
2
  /**
4
3
  * A drizzle table, behind the ports the kernel reads.
5
4
  *
@@ -10,27 +9,27 @@ import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapte
10
9
  * changes no decision.
11
10
  */
12
11
  /** The columns the kernel reads. Declared once, so a table and a mapper cannot drift apart. */
13
- declare const policyRuleColumns: {
14
- readonly constraint_kind: "text";
15
- readonly constraint_value: "json";
16
- readonly overridable: "boolean";
17
- readonly reason: "text";
18
- readonly rule_key: "text";
19
- readonly scope: "json";
20
- readonly status: "text";
21
- readonly tier: "text";
12
+ export declare const policyRuleColumns: {
13
+ readonly constraint_kind: 'text';
14
+ readonly constraint_value: 'json';
15
+ readonly overridable: 'boolean';
16
+ readonly reason: 'text';
17
+ readonly rule_key: 'text';
18
+ readonly scope: 'json';
19
+ readonly status: 'text';
20
+ readonly tier: 'text';
22
21
  };
23
22
  /** The journal's columns. There is no `rejected` one: a rejection is written into `error`. */
24
- declare const policyJournalColumns: {
25
- readonly actor_id: "text";
26
- readonly actor_kind: "text";
27
- readonly error: "text";
28
- readonly event_name: "text";
29
- readonly fell_back_to: "json";
30
- readonly op: "text";
31
- readonly subject: "text";
23
+ export declare const policyJournalColumns: {
24
+ readonly actor_id: 'text';
25
+ readonly actor_kind: 'text';
26
+ readonly error: 'text';
27
+ readonly event_name: 'text';
28
+ readonly fell_back_to: 'json';
29
+ readonly op: 'text';
30
+ readonly subject: 'text';
32
31
  };
33
- type DrizzlePolicyAdapterOptions = {
32
+ export type DrizzlePolicyAdapterOptions = {
34
33
  config?: (kind: string, query: PolicyQuery) => Awaitable<unknown>;
35
34
  /** Absent when the store has no journal table. Half an adapter is honest; a silent drop is not. */
36
35
  journal?: (row: Record<string, unknown>) => Awaitable<unknown>;
@@ -38,6 +37,4 @@ type DrizzlePolicyAdapterOptions = {
38
37
  status: string;
39
38
  }) => Awaitable<readonly PolicyRuleRow[]>;
40
39
  };
41
- declare const createDrizzlePolicyAdapter: (options: DrizzlePolicyAdapterOptions) => PolicyAdapter;
42
-
43
- export { type DrizzlePolicyAdapterOptions, createDrizzlePolicyAdapter, policyJournalColumns, policyRuleColumns };
40
+ export declare const createDrizzlePolicyAdapter: (options: DrizzlePolicyAdapterOptions) => PolicyAdapter;
@@ -1,5 +1,4 @@
1
- import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapter } from '../types-C-Q3r-In.js';
2
-
1
+ import type { Awaitable, PolicyAdapter, PolicyQuery, PolicyRuleRow } from '../types.js';
3
2
  /**
4
3
  * A drizzle table, behind the ports the kernel reads.
5
4
  *
@@ -10,27 +9,27 @@ import { P as PolicyQuery, A as Awaitable, a as PolicyRuleRow, b as PolicyAdapte
10
9
  * changes no decision.
11
10
  */
12
11
  /** The columns the kernel reads. Declared once, so a table and a mapper cannot drift apart. */
13
- declare const policyRuleColumns: {
14
- readonly constraint_kind: "text";
15
- readonly constraint_value: "json";
16
- readonly overridable: "boolean";
17
- readonly reason: "text";
18
- readonly rule_key: "text";
19
- readonly scope: "json";
20
- readonly status: "text";
21
- readonly tier: "text";
12
+ export declare const policyRuleColumns: {
13
+ readonly constraint_kind: 'text';
14
+ readonly constraint_value: 'json';
15
+ readonly overridable: 'boolean';
16
+ readonly reason: 'text';
17
+ readonly rule_key: 'text';
18
+ readonly scope: 'json';
19
+ readonly status: 'text';
20
+ readonly tier: 'text';
22
21
  };
23
22
  /** The journal's columns. There is no `rejected` one: a rejection is written into `error`. */
24
- declare const policyJournalColumns: {
25
- readonly actor_id: "text";
26
- readonly actor_kind: "text";
27
- readonly error: "text";
28
- readonly event_name: "text";
29
- readonly fell_back_to: "json";
30
- readonly op: "text";
31
- readonly subject: "text";
23
+ export declare const policyJournalColumns: {
24
+ readonly actor_id: 'text';
25
+ readonly actor_kind: 'text';
26
+ readonly error: 'text';
27
+ readonly event_name: 'text';
28
+ readonly fell_back_to: 'json';
29
+ readonly op: 'text';
30
+ readonly subject: 'text';
32
31
  };
33
- type DrizzlePolicyAdapterOptions = {
32
+ export type DrizzlePolicyAdapterOptions = {
34
33
  config?: (kind: string, query: PolicyQuery) => Awaitable<unknown>;
35
34
  /** Absent when the store has no journal table. Half an adapter is honest; a silent drop is not. */
36
35
  journal?: (row: Record<string, unknown>) => Awaitable<unknown>;
@@ -38,6 +37,4 @@ type DrizzlePolicyAdapterOptions = {
38
37
  status: string;
39
38
  }) => Awaitable<readonly PolicyRuleRow[]>;
40
39
  };
41
- declare const createDrizzlePolicyAdapter: (options: DrizzlePolicyAdapterOptions) => PolicyAdapter;
42
-
43
- export { type DrizzlePolicyAdapterOptions, createDrizzlePolicyAdapter, policyJournalColumns, policyRuleColumns };
40
+ export declare const createDrizzlePolicyAdapter: (options: DrizzlePolicyAdapterOptions) => PolicyAdapter;
@@ -1,8 +1,5 @@
1
- import {
2
- toPolicyRules
3
- } from "../chunk-JICJ4XEX.js";
4
-
5
1
  // src/drizzle/index.ts
2
+ import { toPolicyRules } from "../rows.js";
6
3
  var policyRuleColumns = {
7
4
  constraint_kind: "text",
8
5
  constraint_value: "json",
@@ -26,7 +23,7 @@ var attempt = async (what) => {
26
23
  try {
27
24
  return await what();
28
25
  } catch {
29
- return void 0;
26
+ return;
30
27
  }
31
28
  };
32
29
  var toRow = (entry) => ({