@intentius/chant-lexicon-cedar 0.44.8

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 (265) hide show
  1. package/README.md +190 -0
  2. package/dist/avp/ambient.d.ts +54 -0
  3. package/dist/avp/ambient.d.ts.map +1 -0
  4. package/dist/avp/client.d.ts +127 -0
  5. package/dist/avp/client.d.ts.map +1 -0
  6. package/dist/avp/describe-resources.d.ts +42 -0
  7. package/dist/avp/describe-resources.d.ts.map +1 -0
  8. package/dist/avp/embed.d.ts +120 -0
  9. package/dist/avp/embed.d.ts.map +1 -0
  10. package/dist/avp/live-export.d.ts +94 -0
  11. package/dist/avp/live-export.d.ts.map +1 -0
  12. package/dist/avp/ownership.d.ts +97 -0
  13. package/dist/avp/ownership.d.ts.map +1 -0
  14. package/dist/avp/statement.d.ts +22 -0
  15. package/dist/avp/statement.d.ts.map +1 -0
  16. package/dist/avp/store.d.ts +82 -0
  17. package/dist/avp/store.d.ts.map +1 -0
  18. package/dist/avp/testdata/mock-transport.d.ts +55 -0
  19. package/dist/avp/testdata/mock-transport.d.ts.map +1 -0
  20. package/dist/codegen/docs-cli.d.ts +3 -0
  21. package/dist/codegen/docs-cli.d.ts.map +1 -0
  22. package/dist/codegen/docs.d.ts +26 -0
  23. package/dist/codegen/docs.d.ts.map +1 -0
  24. package/dist/codegen/emit.d.ts +85 -0
  25. package/dist/codegen/emit.d.ts.map +1 -0
  26. package/dist/codegen/generate-cli.d.ts +3 -0
  27. package/dist/codegen/generate-cli.d.ts.map +1 -0
  28. package/dist/codegen/generate.d.ts +37 -0
  29. package/dist/codegen/generate.d.ts.map +1 -0
  30. package/dist/codegen/naming.d.ts +48 -0
  31. package/dist/codegen/naming.d.ts.map +1 -0
  32. package/dist/codegen/package.d.ts +10 -0
  33. package/dist/codegen/package.d.ts.map +1 -0
  34. package/dist/composites/deny-by-default-set.d.ts +58 -0
  35. package/dist/composites/deny-by-default-set.d.ts.map +1 -0
  36. package/dist/composites/index.d.ts +12 -0
  37. package/dist/composites/index.d.ts.map +1 -0
  38. package/dist/composites/owner-can-manage.d.ts +48 -0
  39. package/dist/composites/owner-can-manage.d.ts.map +1 -0
  40. package/dist/config.d.ts +102 -0
  41. package/dist/config.d.ts.map +1 -0
  42. package/dist/coverage.d.ts +59 -0
  43. package/dist/coverage.d.ts.map +1 -0
  44. package/dist/detect.d.ts +18 -0
  45. package/dist/detect.d.ts.map +1 -0
  46. package/dist/generated/index.d.ts +251 -0
  47. package/dist/generated/index.d.ts.map +1 -0
  48. package/dist/generated/runtime.d.ts +2 -0
  49. package/dist/generated/runtime.d.ts.map +1 -0
  50. package/dist/import/adapter.d.ts +21 -0
  51. package/dist/import/adapter.d.ts.map +1 -0
  52. package/dist/import/clause-text.d.ts +38 -0
  53. package/dist/import/clause-text.d.ts.map +1 -0
  54. package/dist/import/generator.d.ts +53 -0
  55. package/dist/import/generator.d.ts.map +1 -0
  56. package/dist/import/parser.d.ts +57 -0
  57. package/dist/import/parser.d.ts.map +1 -0
  58. package/dist/index.d.ts +34 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/init-templates.d.ts +32 -0
  61. package/dist/init-templates.d.ts.map +1 -0
  62. package/dist/integrity.json +22 -0
  63. package/dist/lint/audit-catalog.d.ts +29 -0
  64. package/dist/lint/audit-catalog.d.ts.map +1 -0
  65. package/dist/lint/post-synth/cedar-helpers.d.ts +97 -0
  66. package/dist/lint/post-synth/cedar-helpers.d.ts.map +1 -0
  67. package/dist/lint/post-synth/cedc010.d.ts +17 -0
  68. package/dist/lint/post-synth/cedc010.d.ts.map +1 -0
  69. package/dist/lint/post-synth/cedc011.d.ts +17 -0
  70. package/dist/lint/post-synth/cedc011.d.ts.map +1 -0
  71. package/dist/lint/post-synth/cedc012.d.ts +21 -0
  72. package/dist/lint/post-synth/cedc012.d.ts.map +1 -0
  73. package/dist/lint/post-synth/cedc013.d.ts +20 -0
  74. package/dist/lint/post-synth/cedc013.d.ts.map +1 -0
  75. package/dist/lint/post-synth/cedc014.d.ts +19 -0
  76. package/dist/lint/post-synth/cedc014.d.ts.map +1 -0
  77. package/dist/lint/post-synth/cede010.d.ts +34 -0
  78. package/dist/lint/post-synth/cede010.d.ts.map +1 -0
  79. package/dist/lint/post-synth/cede011.d.ts +22 -0
  80. package/dist/lint/post-synth/cede011.d.ts.map +1 -0
  81. package/dist/lint/post-synth/ceds010.d.ts +24 -0
  82. package/dist/lint/post-synth/ceds010.d.ts.map +1 -0
  83. package/dist/lint/post-synth/ceds011.d.ts +19 -0
  84. package/dist/lint/post-synth/ceds011.d.ts.map +1 -0
  85. package/dist/lint/post-synth/ceds012.d.ts +17 -0
  86. package/dist/lint/post-synth/ceds012.d.ts.map +1 -0
  87. package/dist/lint/post-synth/index.d.ts +3 -0
  88. package/dist/lint/post-synth/index.d.ts.map +1 -0
  89. package/dist/lint/post-synth/wasm-helpers.d.ts +108 -0
  90. package/dist/lint/post-synth/wasm-helpers.d.ts.map +1 -0
  91. package/dist/lint/rules/index.d.ts +10 -0
  92. package/dist/lint/rules/index.d.ts.map +1 -0
  93. package/dist/lint/rules/policy-shape.d.ts +31 -0
  94. package/dist/lint/rules/policy-shape.d.ts.map +1 -0
  95. package/dist/lsp/completions.d.ts +24 -0
  96. package/dist/lsp/completions.d.ts.map +1 -0
  97. package/dist/lsp/hover.d.ts +11 -0
  98. package/dist/lsp/hover.d.ts.map +1 -0
  99. package/dist/lsp/registry.d.ts +45 -0
  100. package/dist/lsp/registry.d.ts.map +1 -0
  101. package/dist/manifest.json +8 -0
  102. package/dist/mcp/index.d.ts +34 -0
  103. package/dist/mcp/index.d.ts.map +1 -0
  104. package/dist/mcp/policy-coverage.d.ts +81 -0
  105. package/dist/mcp/policy-coverage.d.ts.map +1 -0
  106. package/dist/meta.json +699 -0
  107. package/dist/okf/index.md +37 -0
  108. package/dist/okf/rules/CEDC001.md +11 -0
  109. package/dist/okf/rules/CEDC010.md +11 -0
  110. package/dist/okf/rules/CEDC011.md +15 -0
  111. package/dist/okf/rules/CEDC012.md +11 -0
  112. package/dist/okf/rules/CEDC013.md +15 -0
  113. package/dist/okf/rules/CEDC014.md +15 -0
  114. package/dist/okf/rules/CEDE010.md +15 -0
  115. package/dist/okf/rules/CEDE011.md +15 -0
  116. package/dist/okf/rules/CEDS010.md +15 -0
  117. package/dist/okf/rules/CEDS011.md +11 -0
  118. package/dist/okf/rules/CEDS012.md +15 -0
  119. package/dist/okf/types/AdminAction.md +14 -0
  120. package/dist/okf/types/Application.md +14 -0
  121. package/dist/okf/types/ApproveAction.md +13 -0
  122. package/dist/okf/types/CommentAction.md +14 -0
  123. package/dist/okf/types/CreateAction.md +14 -0
  124. package/dist/okf/types/DeleteAction.md +14 -0
  125. package/dist/okf/types/Document.md +18 -0
  126. package/dist/okf/types/Folder.md +15 -0
  127. package/dist/okf/types/Group.md +14 -0
  128. package/dist/okf/types/ListAction.md +14 -0
  129. package/dist/okf/types/Policy.md +29 -0
  130. package/dist/okf/types/ReadAction.md +14 -0
  131. package/dist/okf/types/ServiceAccount.md +15 -0
  132. package/dist/okf/types/ShareAction.md +14 -0
  133. package/dist/okf/types/Team.md +14 -0
  134. package/dist/okf/types/User.md +18 -0
  135. package/dist/okf/types/WriteAction.md +14 -0
  136. package/dist/package-cli.d.ts +3 -0
  137. package/dist/package-cli.d.ts.map +1 -0
  138. package/dist/plugin.d.ts +8 -0
  139. package/dist/plugin.d.ts.map +1 -0
  140. package/dist/rules/cedar-helpers.ts +209 -0
  141. package/dist/rules/cedc010.ts +80 -0
  142. package/dist/rules/cedc011.ts +47 -0
  143. package/dist/rules/cedc012.ts +64 -0
  144. package/dist/rules/cedc013.ts +68 -0
  145. package/dist/rules/cedc014.ts +73 -0
  146. package/dist/rules/cede010.ts +89 -0
  147. package/dist/rules/cede011.ts +58 -0
  148. package/dist/rules/ceds010.ts +57 -0
  149. package/dist/rules/ceds011.ts +42 -0
  150. package/dist/rules/ceds012.ts +50 -0
  151. package/dist/rules/policy-shape.ts +148 -0
  152. package/dist/rules/wasm-helpers.ts +315 -0
  153. package/dist/serializer.d.ts +138 -0
  154. package/dist/serializer.d.ts.map +1 -0
  155. package/dist/spec/fetch.d.ts +71 -0
  156. package/dist/spec/fetch.d.ts.map +1 -0
  157. package/dist/spec/parse.d.ts +113 -0
  158. package/dist/spec/parse.d.ts.map +1 -0
  159. package/dist/spec/pin.d.ts +116 -0
  160. package/dist/spec/pin.d.ts.map +1 -0
  161. package/dist/spec/pinned-names.json +18 -0
  162. package/dist/spec/wasm.d.ts +143 -0
  163. package/dist/spec/wasm.d.ts.map +1 -0
  164. package/dist/types/index.d.ts +219 -0
  165. package/dist/validate-cli.d.ts +3 -0
  166. package/dist/validate-cli.d.ts.map +1 -0
  167. package/dist/validate.d.ts +25 -0
  168. package/dist/validate.d.ts.map +1 -0
  169. package/package.json +75 -0
  170. package/src/avp/OWNERSHIP.md +125 -0
  171. package/src/avp/ambient.test.ts +113 -0
  172. package/src/avp/ambient.ts +124 -0
  173. package/src/avp/client.ts +310 -0
  174. package/src/avp/describe-resources.test.ts +316 -0
  175. package/src/avp/describe-resources.ts +215 -0
  176. package/src/avp/embed.test.ts +114 -0
  177. package/src/avp/embed.ts +190 -0
  178. package/src/avp/live-export.test.ts +232 -0
  179. package/src/avp/live-export.ts +185 -0
  180. package/src/avp/ownership.test.ts +101 -0
  181. package/src/avp/ownership.ts +170 -0
  182. package/src/avp/statement.ts +50 -0
  183. package/src/avp/store.ts +152 -0
  184. package/src/avp/testdata/mock-transport.ts +147 -0
  185. package/src/codegen/docs-cli.ts +7 -0
  186. package/src/codegen/docs.ts +873 -0
  187. package/src/codegen/emit.ts +496 -0
  188. package/src/codegen/generate-cli.ts +18 -0
  189. package/src/codegen/generate.test.ts +128 -0
  190. package/src/codegen/generate.ts +123 -0
  191. package/src/codegen/naming.ts +101 -0
  192. package/src/codegen/package.ts +52 -0
  193. package/src/composites/composites.test.ts +206 -0
  194. package/src/composites/deny-by-default-set.ts +98 -0
  195. package/src/composites/index.ts +13 -0
  196. package/src/composites/owner-can-manage.ts +80 -0
  197. package/src/config-namespace.test.ts +44 -0
  198. package/src/config.test.ts +82 -0
  199. package/src/config.ts +119 -0
  200. package/src/coverage.test.ts +61 -0
  201. package/src/coverage.ts +166 -0
  202. package/src/detect.test.ts +64 -0
  203. package/src/detect.ts +59 -0
  204. package/src/generated/index.d.ts +219 -0
  205. package/src/generated/index.ts +279 -0
  206. package/src/generated/lexicon-cedar.json +699 -0
  207. package/src/generated/runtime.ts +2 -0
  208. package/src/import/adapter.ts +63 -0
  209. package/src/import/clause-text.ts +178 -0
  210. package/src/import/generator.test.ts +133 -0
  211. package/src/import/generator.ts +219 -0
  212. package/src/import/parser.test.ts +265 -0
  213. package/src/import/parser.ts +352 -0
  214. package/src/import/roundtrip.test.ts +127 -0
  215. package/src/import/testdata/full.cedar +36 -0
  216. package/src/import/testdata/full.cedar.json +238 -0
  217. package/src/import/testdata/realistic.cedar +35 -0
  218. package/src/import/testdata/simple.cedar +6 -0
  219. package/src/index.ts +94 -0
  220. package/src/init-templates.test.ts +158 -0
  221. package/src/init-templates.ts +358 -0
  222. package/src/lint/audit-catalog.ts +130 -0
  223. package/src/lint/post-synth/cedar-helpers.ts +209 -0
  224. package/src/lint/post-synth/cedc010.ts +80 -0
  225. package/src/lint/post-synth/cedc011.ts +47 -0
  226. package/src/lint/post-synth/cedc012.ts +64 -0
  227. package/src/lint/post-synth/cedc013.ts +68 -0
  228. package/src/lint/post-synth/cedc014.ts +73 -0
  229. package/src/lint/post-synth/cede010.ts +89 -0
  230. package/src/lint/post-synth/cede011.ts +58 -0
  231. package/src/lint/post-synth/ceds010.ts +57 -0
  232. package/src/lint/post-synth/ceds011.ts +42 -0
  233. package/src/lint/post-synth/ceds012.ts +50 -0
  234. package/src/lint/post-synth/index.ts +25 -0
  235. package/src/lint/post-synth/post-synth.test.ts +474 -0
  236. package/src/lint/post-synth/wasm-helpers.ts +315 -0
  237. package/src/lint/rules/index.ts +12 -0
  238. package/src/lint/rules/policy-shape.test.ts +90 -0
  239. package/src/lint/rules/policy-shape.ts +148 -0
  240. package/src/lsp/completions.test.ts +111 -0
  241. package/src/lsp/completions.ts +55 -0
  242. package/src/lsp/hover.test.ts +82 -0
  243. package/src/lsp/hover.ts +75 -0
  244. package/src/lsp/registry.ts +74 -0
  245. package/src/mcp/index.ts +103 -0
  246. package/src/mcp/policy-coverage.test.ts +176 -0
  247. package/src/mcp/policy-coverage.ts +205 -0
  248. package/src/package-cli.ts +22 -0
  249. package/src/plugin.test.ts +115 -0
  250. package/src/plugin.ts +312 -0
  251. package/src/serializer.test.ts +502 -0
  252. package/src/serializer.ts +335 -0
  253. package/src/skills/chant-cedar-authoring.md +180 -0
  254. package/src/skills/chant-cedar-avp-embedding.md +125 -0
  255. package/src/skills/chant-cedar-meta-policy.md +119 -0
  256. package/src/spec/default-schema.cedarschema +108 -0
  257. package/src/spec/fetch.ts +107 -0
  258. package/src/spec/parse.test.ts +123 -0
  259. package/src/spec/parse.ts +253 -0
  260. package/src/spec/pin.test.ts +88 -0
  261. package/src/spec/pin.ts +243 -0
  262. package/src/spec/pinned-names.json +18 -0
  263. package/src/spec/wasm.ts +283 -0
  264. package/src/validate-cli.ts +8 -0
  265. package/src/validate.ts +85 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * OwnerCanManage — the ownership grant, written once.
3
+ *
4
+ * "The owner of a thing may act on it" is the most-repeated shape in every
5
+ * Cedar policy set, and hand-writing it per entity type is where the two
6
+ * classic mistakes get made: the `when` guard names an attribute the schema
7
+ * spells differently, or the grant is written wide and the scoping clause is
8
+ * forgotten. Cedar itself cannot help — it has no functions, no modules, and
9
+ * templates carry exactly two slots. A TypeScript factory is the only place
10
+ * this abstraction can live.
11
+ *
12
+ * The composite emits a permit whose resource scope is pinned with `is` and
13
+ * whose ownership test is a `when` clause, so both halves arrive together or
14
+ * neither does.
15
+ */
16
+ import type { Declarable } from "@intentius/chant/declarable";
17
+ import type { EntityTypeName, PolicyRef, PolicyScope } from "../generated/index.js";
18
+ export interface OwnerCanManageOpts {
19
+ /** The entity type owners act on, e.g. `"App::Document"`. */
20
+ entityType: EntityTypeName;
21
+ /**
22
+ * Actions the owner is granted. A single action is emitted as `== A`, several
23
+ * as `in [A, …]`, and none leaves the action position unconstrained — which
24
+ * is a wide grant, so it has to be asked for by omitting the field.
25
+ */
26
+ actions?: PolicyRef | PolicyRef[];
27
+ /**
28
+ * The attribute on the resource that holds the owner. Defaults to `owner`,
29
+ * the name the bundled schema and most Cedar examples use.
30
+ */
31
+ ownerAttribute?: string;
32
+ /**
33
+ * Narrow the principal beyond "anyone". A bare entity type string becomes
34
+ * `principal is T`; a full scope is passed through.
35
+ */
36
+ principal?: EntityTypeName | PolicyScope;
37
+ /** Extra `when` clauses, appended after the ownership test. */
38
+ when?: string[];
39
+ /** `unless` clauses. An MFA requirement is the usual one. */
40
+ unless?: string[];
41
+ /** Merged over the generated annotations; an explicit `id` wins. */
42
+ annotations?: Record<string, string>;
43
+ }
44
+ /**
45
+ * One permit: the owner of an `entityType` may take `actions` on it.
46
+ */
47
+ export declare function OwnerCanManage(opts: OwnerCanManageOpts): Declarable;
48
+ //# sourceMappingURL=owner-can-manage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-can-manage.d.ts","sourceRoot":"","sources":["../../src/composites/owner-can-manage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,UAAU,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IACzC,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAeD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,UAAU,CAgBnE"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The `cedar` namespace in `chant.config.ts` (#1344, #1650).
3
+ *
4
+ * ```ts
5
+ * import type { ChantConfig } from "@intentius/chant/config";
6
+ * import "@intentius/chant-lexicon-cedar"; // brings the `cedar` key into ChantConfig
7
+ *
8
+ * export default {
9
+ * lexicons: ["cedar"],
10
+ * cedar: {
11
+ * schema: "authz/app.cedarschema",
12
+ * validation: { mode: "strict", warnings: "warn" },
13
+ * },
14
+ * } satisfies ChantConfig;
15
+ * ```
16
+ *
17
+ * Cedar is the one lexicon whose codegen input is the *project's* file rather
18
+ * than a global upstream (epic #1645), so this namespace is not a convenience —
19
+ * it is where `generate()` is told what to read. A typo in the path is the
20
+ * difference between "your entity types" and "the bundled default schema",
21
+ * which is exactly the kind of silent fallback `z.strictObject` exists to stop
22
+ * one level down.
23
+ */
24
+ import { z } from "zod";
25
+ import type { ChantConfig } from "@intentius/chant/config";
26
+ /**
27
+ * Where `generate()` looks when `cedar.schema` is unset.
28
+ *
29
+ * Relative to the project root (the directory holding `chant.config.ts`).
30
+ */
31
+ export declare const CEDAR_DEFAULT_SCHEMA_PATH = "schema.cedarschema";
32
+ /**
33
+ * `strictObject`, not `object`. Core applies `.strict()` to the top level of a
34
+ * declared namespace itself; `validation` is nested, and is the lexicon's own
35
+ * to close.
36
+ */
37
+ export declare const cedarConfigSchema: z.ZodObject<{
38
+ /**
39
+ * Path to the project's human-readable Cedar schema, relative to the project
40
+ * root. Defaults to {@link CEDAR_DEFAULT_SCHEMA_PATH}; when neither the
41
+ * configured path nor the default exists, generation falls back to the
42
+ * schema bundled at `src/spec/default-schema.cedarschema` so a fresh
43
+ * checkout still produces artifacts.
44
+ */
45
+ schema: z.ZodOptional<z.ZodString>;
46
+ /**
47
+ * Knobs for the `cedar-wasm` validator. `mode` is a single-variant enum on
48
+ * purpose: `ValidationMode` in cedar-wasm 4.12.0 accepts `"strict"` and
49
+ * nothing else, and passing anything further throws (#1648 §5.7).
50
+ */
51
+ validation: z.ZodOptional<z.ZodObject<{
52
+ /** Validator mode. Only `"strict"` exists in this build of cedar-wasm. */
53
+ mode: z.ZodOptional<z.ZodLiteral<"strict">>;
54
+ /**
55
+ * What to do with `validationWarnings` — the validator reports things
56
+ * like "policy is impossible" here, separately from errors.
57
+ */
58
+ warnings: z.ZodOptional<z.ZodEnum<{
59
+ error: "error";
60
+ ignore: "ignore";
61
+ warn: "warn";
62
+ }>>;
63
+ /**
64
+ * Refuse to build when no project schema is found rather than falling
65
+ * back to the bundled default. Off by default so `chant init` works;
66
+ * worth turning on once a project has its own schema, because
67
+ * `checkParseSchema("")` succeeds and an empty schema validates
68
+ * everything clean (#1648 §1).
69
+ */
70
+ requireProjectSchema: z.ZodOptional<z.ZodBoolean>;
71
+ }, z.core.$strict>>;
72
+ }, z.core.$strict>;
73
+ export type CedarConfig = z.infer<typeof cedarConfigSchema>;
74
+ declare module "@intentius/chant/config" {
75
+ interface ChantConfig {
76
+ cedar?: CedarConfig;
77
+ }
78
+ }
79
+ /**
80
+ * Compile-time proof that the augmentation above reaches `ChantConfig` (#1344).
81
+ *
82
+ * Without it this line is `Property 'cedar' does not exist on type
83
+ * 'ChantConfig'`. It lives here rather than in a test because the root tsconfig
84
+ * excludes test files, so a compile-time claim asserted in one is checked by
85
+ * nothing.
86
+ */
87
+ export type CedarConfigNamespace = NonNullable<ChantConfig["cedar"]>;
88
+ /**
89
+ * Read the `cedar` namespace out of the project's config.
90
+ *
91
+ * Searches upward from `startDir`, so `chant generate` finds the config from a
92
+ * subdirectory the same way `chant build` does. A project with no config, or
93
+ * one with no `cedar` key, gets `{}` — the schema resolution order in
94
+ * `spec/fetch.ts` handles that case without needing to know why.
95
+ *
96
+ * Core has already validated the namespace against {@link cedarConfigSchema}
97
+ * by the time this reads it, so the parse here is a type narrowing rather than
98
+ * a second gate; it stays because a caller can point this at a directory core
99
+ * never loaded.
100
+ */
101
+ export declare function loadCedarConfig(startDir: string): Promise<CedarConfig>;
102
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;;;;;OAMG;;IAGH;;;;OAIG;;QAGC,0EAA0E;;QAE1E;;;WAGG;;;;;;QAEH;;;;;;WAMG;;;kBAIP,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,WAAW;QACnB,KAAK,CAAC,EAAE,WAAW,CAAC;KACrB;CACF;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAY5E"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Schema coverage for the cedar lexicon.
3
+ *
4
+ * Core's `computeCoverage` measures CloudFormation-shaped dimensions —
5
+ * property constraints, create-only/write-only lifecycle, return attributes —
6
+ * none of which a Cedar schema has. Reporting 0% across four axes that cannot
7
+ * apply would be worse than reporting nothing, so this asks the question that
8
+ * does mean something here: **is every entity type and every action in the
9
+ * schema reachable from the generated artifacts?**
10
+ *
11
+ * A gap is a real defect, not a nice-to-have. An action with no generated
12
+ * constant is an action a policy can only name as a hand-typed string, which
13
+ * is the exact failure mode the lexicon exists to remove.
14
+ */
15
+ import { type ResolveSchemaOptions } from "./spec/fetch.js";
16
+ export interface CedarCoverageItem {
17
+ /** Fully-qualified declaration name from the schema. */
18
+ name: string;
19
+ kind: "entity" | "action";
20
+ /** True when a registry entry names this declaration. */
21
+ covered: boolean;
22
+ /** True when the record type beside it (attributes / context) is present too. */
23
+ recordCovered: boolean;
24
+ /** Attributes the schema declares for it. */
25
+ attributes: number;
26
+ }
27
+ export interface CedarCoverageReport {
28
+ /** Where the schema came from. */
29
+ schemaPath: string;
30
+ /** True when the bundled default schema was used. */
31
+ isDefaultSchema: boolean;
32
+ entityTypes: number;
33
+ entityTypesCovered: number;
34
+ actions: number;
35
+ actionsCovered: number;
36
+ recordTypes: number;
37
+ recordTypesCovered: number;
38
+ entityPct: number;
39
+ actionPct: number;
40
+ recordPct: number;
41
+ overallPct: number;
42
+ items: CedarCoverageItem[];
43
+ }
44
+ export interface CedarCoverageOptions extends ResolveSchemaOptions {
45
+ /** Directory holding the generated artifacts. Defaults to `<package>/src/generated`. */
46
+ generatedDir?: string;
47
+ verbose?: boolean;
48
+ /** Fail when `overallPct` falls below this. */
49
+ minOverall?: number;
50
+ }
51
+ /** Compute schema coverage against the artifacts already on disk. */
52
+ export declare function computeCedarCoverage(options?: CedarCoverageOptions): CedarCoverageReport;
53
+ /** Human-readable summary. */
54
+ export declare function formatCedarCoverage(report: CedarCoverageReport, verbose?: boolean): string;
55
+ /**
56
+ * Print the report, and throw when it falls below `minOverall`.
57
+ */
58
+ export declare function analyzeCedarCoverage(options?: CedarCoverageOptions): CedarCoverageReport;
59
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,EAAoB,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAG3E,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,aAAa,EAAE,OAAO,CAAC;IACvB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CAsD5F;AAED,8BAA8B;AAC9B,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,OAAO,UAAQ,GAAG,MAAM,CAwBxF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CAS5F"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Edge-safe template detection for cedar (#426, #1653).
3
+ *
4
+ * Two documents belong to this lexicon: the JSON policy-set envelope the
5
+ * serializer writes, and `.cedar` policy text. The first is recognized by its
6
+ * shape and then confirmed by `checkParsePolicySet`; the second only by asking
7
+ * the module to split it.
8
+ *
9
+ * The shape test is strict on purpose. `chant import` walks every loaded
10
+ * plugin's `detectTemplate` in turn, so a lexicon that answers `true` for
11
+ * someone else's JSON steals the file. `staticPolicies`/`templates`/
12
+ * `templateLinks` and nothing else is a document no other lexicon writes, and
13
+ * a policy set with no policies in it is not claimed at all — `{}` parses
14
+ * perfectly well as an empty Cedar policy set, and matching it would swallow
15
+ * every empty JSON object in the repo.
16
+ */
17
+ export declare function detectTemplate(data: unknown): boolean;
18
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuBH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAoBrD"}
@@ -0,0 +1,251 @@
1
+ import type { Declarable } from "@intentius/chant/declarable";
2
+ /**
3
+ * Entity UID of `App::Application`.
4
+ */
5
+ export type ApplicationUid = `App::Application::"${string}"`;
6
+ export interface ApplicationAttributesProps {
7
+ name: string;
8
+ owner: TeamUid;
9
+ }
10
+ /**
11
+ * Entity UID of `App::Document`.
12
+ * Member of: App::Folder.
13
+ */
14
+ export type DocumentUid = `App::Document::"${string}"`;
15
+ export interface DocumentAttributesProps {
16
+ classification: string;
17
+ folder: FolderUid;
18
+ owner: UserUid;
19
+ public: boolean;
20
+ tags: string[];
21
+ title: string;
22
+ }
23
+ /**
24
+ * Entity UID of `App::Folder`.
25
+ */
26
+ export type FolderUid = `App::Folder::"${string}"`;
27
+ export interface FolderAttributesProps {
28
+ name: string;
29
+ owner: UserUid;
30
+ tags: string[];
31
+ }
32
+ /**
33
+ * Entity UID of `App::Group`.
34
+ */
35
+ export type GroupUid = `App::Group::"${string}"`;
36
+ export interface GroupAttributesProps {
37
+ description?: string;
38
+ name: string;
39
+ }
40
+ /**
41
+ * Entity UID of `App::ServiceAccount`.
42
+ * Member of: App::Group.
43
+ */
44
+ export type ServiceAccountUid = `App::ServiceAccount::"${string}"`;
45
+ export interface ServiceAccountAttributesProps {
46
+ name: string;
47
+ owner: UserUid;
48
+ rotatedAt?: string;
49
+ }
50
+ /**
51
+ * Entity UID of `App::Team`.
52
+ * Member of: App::Group.
53
+ */
54
+ export type TeamUid = `App::Team::"${string}"`;
55
+ export interface TeamAttributesProps {
56
+ costCenter?: string;
57
+ name: string;
58
+ }
59
+ /**
60
+ * Entity UID of `App::User`.
61
+ * Member of: App::Group, App::Team.
62
+ */
63
+ export type UserUid = `App::User::"${string}"`;
64
+ export interface UserAttributesProps {
65
+ department: string;
66
+ email: string;
67
+ level: number;
68
+ manager?: UserUid;
69
+ mfaEnabled: boolean;
70
+ roles: string[];
71
+ }
72
+ export interface AdminContextProps {
73
+ breakGlass?: boolean;
74
+ mfa: boolean;
75
+ }
76
+ export interface ApproveContextProps {
77
+ mfa: boolean;
78
+ }
79
+ export interface CommentContextProps {
80
+ mfa: boolean;
81
+ reason?: string;
82
+ }
83
+ export interface CreateContextProps {
84
+ mfa: boolean;
85
+ reason?: string;
86
+ }
87
+ export interface DeleteContextProps {
88
+ approvedBy?: UserUid;
89
+ mfa: boolean;
90
+ }
91
+ export interface ListContextProps {
92
+ mfa: boolean;
93
+ sourceIp?: string;
94
+ }
95
+ export interface ReadContextProps {
96
+ mfa: boolean;
97
+ sourceIp?: string;
98
+ }
99
+ export interface ShareContextProps {
100
+ approvedBy?: UserUid;
101
+ mfa: boolean;
102
+ }
103
+ export interface WriteContextProps {
104
+ mfa: boolean;
105
+ reason?: string;
106
+ }
107
+ /** Every entity type name the schema declares, as Cedar writes it. */
108
+ export type EntityTypeName = "App::Application" | "App::Document" | "App::Folder" | "App::Group" | "App::ServiceAccount" | "App::Team" | "App::User";
109
+ /** Every entity UID the schema can produce. */
110
+ export type EntityUid = ApplicationUid | DocumentUid | FolderUid | GroupUid | ServiceAccountUid | TeamUid | UserUid;
111
+ /** Every action UID the schema declares. */
112
+ export type ActionUid = "App::Action::\"admin\"" | "App::Action::\"approve\"" | "App::Action::\"comment\"" | "App::Action::\"create\"" | "App::Action::\"delete\"" | "App::Action::\"list\"" | "App::Action::\"read\"" | "App::Action::\"share\"" | "App::Action::\"write\"";
113
+ /** Anything a policy scope may name. */
114
+ export type PolicyRef = EntityUid | ActionUid;
115
+ /** A Cedar policy either permits or forbids; there is no third effect. */
116
+ export type PolicyEffect = "permit" | "forbid";
117
+ /**
118
+ * One scope position (`principal`, `action`, `resource`).
119
+ *
120
+ * `{}` is the unconstrained form Cedar writes as a bare variable. The
121
+ * constrained forms mirror the grammar: `== E`, `in E`, `in [E, …]`,
122
+ * `is T`, and `is T in E`.
123
+ */
124
+ export type PolicyScope = Record<string, never> | {
125
+ eq: PolicyRef;
126
+ in?: never;
127
+ is?: never;
128
+ } | {
129
+ in: PolicyRef | PolicyRef[];
130
+ eq?: never;
131
+ is?: never;
132
+ } | {
133
+ is: EntityTypeName;
134
+ in?: PolicyRef | PolicyRef[];
135
+ eq?: never;
136
+ };
137
+ /**
138
+ * The props of a `Cedar::Policy`.
139
+ *
140
+ * `when`/`unless` carry Cedar expression text. They stay strings because
141
+ * Cedar's expression grammar is the policy language itself — typing it in
142
+ * TypeScript is import/reconcile's problem (epic #1645 sub-issue 6), not
143
+ * codegen's.
144
+ */
145
+ export interface PolicyProps {
146
+ /** Defaults to `permit` when omitted. */
147
+ effect?: PolicyEffect;
148
+ principal?: PolicyScope;
149
+ action?: PolicyScope;
150
+ resource?: PolicyScope;
151
+ /** Cedar expression strings, each emitted as its own `when { … }` clause. */
152
+ when?: string[];
153
+ /** Cedar expression strings, each emitted as its own `unless { … }` clause. */
154
+ unless?: string[];
155
+ /** Emitted as `@key("value")`; an explicit `id` wins over the logical name. */
156
+ annotations?: Record<string, string>;
157
+ }
158
+ /**
159
+ * The policy resource. Declare one per policy:
160
+ *
161
+ * ```ts
162
+ * export const allowOwnerRead = new Policy({
163
+ * principal: { is: "App::User" },
164
+ * action: { eq: ReadAction },
165
+ * when: ['resource.owner == principal'],
166
+ * });
167
+ * ```
168
+ */
169
+ export declare const Policy: new (props: PolicyProps) => Declarable;
170
+ export declare const Application: new (props: ApplicationAttributesProps) => Declarable;
171
+ export declare const ApplicationAttributes: new (props: ApplicationAttributesProps) => Declarable;
172
+ export declare const Document: new (props: DocumentAttributesProps) => Declarable;
173
+ export declare const DocumentAttributes: new (props: DocumentAttributesProps) => Declarable;
174
+ export declare const Folder: new (props: FolderAttributesProps) => Declarable;
175
+ export declare const FolderAttributes: new (props: FolderAttributesProps) => Declarable;
176
+ export declare const Group: new (props: GroupAttributesProps) => Declarable;
177
+ export declare const GroupAttributes: new (props: GroupAttributesProps) => Declarable;
178
+ export declare const ServiceAccount: new (props: ServiceAccountAttributesProps) => Declarable;
179
+ export declare const ServiceAccountAttributes: new (props: ServiceAccountAttributesProps) => Declarable;
180
+ export declare const Team: new (props: TeamAttributesProps) => Declarable;
181
+ export declare const TeamAttributes: new (props: TeamAttributesProps) => Declarable;
182
+ export declare const User: new (props: UserAttributesProps) => Declarable;
183
+ export declare const UserAttributes: new (props: UserAttributesProps) => Declarable;
184
+ /**
185
+ * `App::Action::"admin"`.
186
+ * Principals: App::User.
187
+ * Resources: App::Application.
188
+ */
189
+ export declare const AdminAction: "App::Action::\"admin\"";
190
+ export declare const AdminContext: new (props: AdminContextProps) => Declarable;
191
+ /**
192
+ * `App::Action::"approve"`.
193
+ * Principals: App::User.
194
+ * Resources: App::Document.
195
+ */
196
+ export declare const ApproveAction: "App::Action::\"approve\"";
197
+ export declare const ApproveContext: new (props: ApproveContextProps) => Declarable;
198
+ /**
199
+ * `App::Action::"comment"`.
200
+ * Principals: App::User.
201
+ * Resources: App::Document, App::Folder.
202
+ */
203
+ export declare const CommentAction: "App::Action::\"comment\"";
204
+ export declare const CommentContext: new (props: CommentContextProps) => Declarable;
205
+ /**
206
+ * `App::Action::"create"`.
207
+ * Principals: App::User.
208
+ * Resources: App::Document, App::Folder.
209
+ */
210
+ export declare const CreateAction: "App::Action::\"create\"";
211
+ export declare const CreateContext: new (props: CreateContextProps) => Declarable;
212
+ /**
213
+ * `App::Action::"delete"`.
214
+ * Principals: App::User.
215
+ * Resources: App::Document.
216
+ */
217
+ export declare const DeleteAction: "App::Action::\"delete\"";
218
+ export declare const DeleteContext: new (props: DeleteContextProps) => Declarable;
219
+ /**
220
+ * `App::Action::"list"`.
221
+ * Principals: App::ServiceAccount, App::User.
222
+ * Resources: App::Document, App::Folder.
223
+ */
224
+ export declare const ListAction: "App::Action::\"list\"";
225
+ export declare const ListContext: new (props: ListContextProps) => Declarable;
226
+ /**
227
+ * `App::Action::"read"`.
228
+ * Principals: App::ServiceAccount, App::User.
229
+ * Resources: App::Document, App::Folder.
230
+ */
231
+ export declare const ReadAction: "App::Action::\"read\"";
232
+ export declare const ReadContext: new (props: ReadContextProps) => Declarable;
233
+ /**
234
+ * `App::Action::"share"`.
235
+ * Principals: App::User.
236
+ * Resources: App::Document.
237
+ */
238
+ export declare const ShareAction: "App::Action::\"share\"";
239
+ export declare const ShareContext: new (props: ShareContextProps) => Declarable;
240
+ /**
241
+ * `App::Action::"write"`.
242
+ * Principals: App::User.
243
+ * Resources: App::Document, App::Folder.
244
+ */
245
+ export declare const WriteAction: "App::Action::\"write\"";
246
+ export declare const WriteContext: new (props: WriteContextProps) => Declarable;
247
+ /** Every generated action constant, for exhaustive iteration. */
248
+ export declare const ALL_ACTIONS: readonly ActionUid[];
249
+ /** Every entity type name the schema declares. */
250
+ export declare const ALL_ENTITY_TYPES: readonly EntityTypeName[];
251
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,MAAM,GAAG,CAAC;AAE7D,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,MAAM,GAAG,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,iBAAiB,MAAM,GAAG,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,MAAM,GAAG,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,yBAAyB,MAAM,GAAG,CAAC;AAEnE,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAA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AK,UAAU,CAAC;AAC9I;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAG,wBAAiC,CAAC;AAC7D,eAAO,MAAM,YAAY,EAA2E,KAAK,KAAK,EAAE,iBAAiB,KAAK,UAAU,CAAC;AACjJ;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAG,wBAAiC,CAAC;AAC7D,eAAO,MAAM,YAAY,EAA2E,KAAK,KAAK,EAAE,iBAAiB,KAAK,UAAU,CAAC;AAEjJ,iEAAiE;AACjE,eAAO,MAAM,WAAW,EAAE,SAAS,SAAS,EAA8H,CAAC;AAE3K,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAAwH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createProperty, createResource } from "@intentius/chant/runtime";
2
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/generated/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The seam between the cedar-shaped parser/generator above and the core
3
+ * `TemplateParser` / `TypeScriptGenerator` that `chant import` drives.
4
+ *
5
+ * Core's pipeline speaks `TemplateIR` — a flat list of `ResourceIR` with a
6
+ * `type` string it may reorganize into category files. A Cedar policy maps
7
+ * cleanly onto one: the logical id is the policy id, and the type records
8
+ * whether Cedar read it as a static policy or as a template, so the mapping
9
+ * reverses without guessing.
10
+ */
11
+ import type { TemplateIR, TemplateParser } from "@intentius/chant/import/parser";
12
+ import type { GeneratedFile, TypeScriptGenerator } from "@intentius/chant/import/generator";
13
+ /** `TemplateParser` over `.cedar` text and the JSON policy-set envelope. */
14
+ export declare class CedarTemplateParser implements TemplateParser {
15
+ parse(content: string): TemplateIR;
16
+ }
17
+ /** `TypeScriptGenerator` emitting `new Policy({ … })` per imported policy. */
18
+ export declare class CedarTemplateGenerator implements TypeScriptGenerator {
19
+ generate(ir: TemplateIR): GeneratedFile[];
20
+ }
21
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/import/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAc,MAAM,gCAAgC,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AA+B5F,4EAA4E;AAC5E,qBAAa,mBAAoB,YAAW,cAAc;IACxD,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;CAQnC;AAED,8EAA8E;AAC9E,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,aAAa,EAAE;CAK1C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Recover the `when`/`unless` bodies of a policy exactly as they were written.
3
+ *
4
+ * The round-trip this lexicon promises is byte-identical `.cedar` output, and
5
+ * the JSON leg cannot deliver it: an expression that goes to `PolicyJson` and
6
+ * back comes out defensively parenthesized — `resource.owner == principal`
7
+ * returns as `(resource.owner) == principal` — and `formatPolicies` does not
8
+ * undo that. The tree is semantically lossless; the text is not preserved.
9
+ *
10
+ * So when there *is* source text, the condition bodies are lifted out of it
11
+ * verbatim, and the module still decides what they mean: every body this file
12
+ * hands back is re-parsed and compared against the tree `policyToJson` produced
13
+ * for the same clause before the importer trusts it (see `parser.ts`). A
14
+ * mismatch falls back to the rendered form.
15
+ *
16
+ * What is here is a *delimiter scanner*, not a Cedar parser. It knows three
17
+ * things — that a `"` starts a string with backslash escapes, that `//` runs
18
+ * to end of line, and that `@`, `(` and `{` have partners — and it knows the
19
+ * two clause keywords. It has no opinion about expressions, which remains the
20
+ * module's job. Anything it does not recognize returns `null`, and the caller
21
+ * uses the rendered bodies instead.
22
+ */
23
+ /** One `when`/`unless` clause, with its body as the author typed it. */
24
+ export interface SourceClause {
25
+ kind: "when" | "unless";
26
+ /** The text between the braces, trimmed. */
27
+ body: string;
28
+ }
29
+ /**
30
+ * Split one policy's source into its clause bodies.
31
+ *
32
+ * Returns `null` for anything that does not walk cleanly — an unbalanced
33
+ * brace, a keyword that is neither `when` nor `unless`, trailing text after
34
+ * the terminating `;`. `null` is not a diagnosis, only a decision to use the
35
+ * module's rendering instead.
36
+ */
37
+ export declare function extractClauses(policyText: string): SourceClause[] | null;
38
+ //# sourceMappingURL=clause-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clause-text.d.ts","sourceRoot":"","sources":["../../src/import/clause-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAqGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,IAAI,CAwCxE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * TypeScript generator for `chant import`.
3
+ *
4
+ * Turns the parser's IR back into the authoring source it came from: one
5
+ * `import` line, then an `export const … = new Policy({ … })` per policy.
6
+ *
7
+ * `Policy` is the schema-driven class `chant generate` emits, and the scope
8
+ * refs it accepts are string-literal unions — so `action: { eq: 'App::Action::"read"' }`
9
+ * is already checked against the schema by the compiler, and an action the
10
+ * schema never declared is an error at the import site. Where the generated
11
+ * registry is on hand, an action UID is emitted as the generated *constant*
12
+ * (`ReadAction`) instead, which reads better and survives a rename; without a
13
+ * registry the literal is the fallback, and it typechecks just the same.
14
+ */
15
+ import type { CedarPolicyIR } from "./parser.js";
16
+ /** The package this generated source imports from. */
17
+ export declare const CEDAR_PACKAGE = "@intentius/chant-lexicon-cedar";
18
+ export interface CedarGenerateOptions {
19
+ /**
20
+ * `App::Action::"read"` → `ReadAction`, from the generated registry.
21
+ *
22
+ * Empty by default: the generator is a pure function of its IR, and the
23
+ * adapter is what goes looking for a registry to fill this in.
24
+ */
25
+ actionConstants?: Record<string, string>;
26
+ }
27
+ export interface CedarGenerateResult {
28
+ source: string;
29
+ warnings: string[];
30
+ }
31
+ /**
32
+ * A Cedar policy id as a JavaScript identifier.
33
+ *
34
+ * `allow-alice-read` → `allowAliceRead`, `legacy_policy` → `legacyPolicy`,
35
+ * `SOC2-AC-3` → `soc2AC3`. A leading segment that is already mixed case keeps
36
+ * its shape apart from the first letter; one that is all caps is lowered whole,
37
+ * so an id like `SOC2` does not come back as `sOC2`.
38
+ */
39
+ export declare function sanitizeName(id: string): string;
40
+ export declare class CedarGenerator {
41
+ private readonly actionConstants;
42
+ constructor(options?: CedarGenerateOptions);
43
+ generate(entities: CedarPolicyIR[]): CedarGenerateResult;
44
+ }
45
+ /**
46
+ * Read `App::Action::"read"` → `ReadAction` out of the generated registry.
47
+ *
48
+ * Best-effort by design: a project that has not run `chant generate` has no
49
+ * registry, and the generator falls back to emitting UID literals — which the
50
+ * `Policy` class accepts and the compiler still checks.
51
+ */
52
+ export declare function loadActionConstants(packageDir?: string): Record<string, string>;
53
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/import/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,sDAAsD;AACtD,eAAO,MAAM,aAAa,mCAAmC,CAAC;AAK9D,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAgBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAY/C;AA0ED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;gBAE7C,OAAO,GAAE,oBAAyB;IAI9C,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,mBAAmB;CAyBzD;AAYD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB/E"}