@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,138 @@
1
+ /**
2
+ * Cedar lexicon serializer.
3
+ *
4
+ * Emits two views of the same policy set:
5
+ *
6
+ * - `.cedar` policy text — the primary output, and the surface every Cedar
7
+ * evaluator reads (AVP, cedar-agent, an embedded `cedar-wasm`).
8
+ * - the Cedar JSON policy format — a second file, written alongside, and the
9
+ * parse source for import (#1653). It is produced by handing the emitted
10
+ * `.cedar` text back to `cedar-wasm`, so what lands on disk is whatever
11
+ * Cedar itself says that text means. Deriving it from the in-memory model
12
+ * instead is what shipped first, and it wrote `when` bodies as
13
+ * `{ "__expr": "<text>" }` — a key Cedar's JSON grammar does not have, which
14
+ * every Cedar tool rejects with `unknown variant '__expr'`.
15
+ *
16
+ * The entity model this serializer reads is hand-shaped for now: one
17
+ * `Cedar::Policy` entity type whose `props` carry an effect, three scope
18
+ * constraints, and optional `when`/`unless` guards. Schema-driven codegen
19
+ * (#1650) generates typed classes onto exactly this shape, so nothing here
20
+ * changes when it lands — the guards become typed expressions rather than
21
+ * the opaque Cedar-expression strings they are today.
22
+ */
23
+ import type { Declarable } from "@intentius/chant/declarable";
24
+ import type { Serializer } from "@intentius/chant/serializer";
25
+ import { type PolicyJson } from "./spec/wasm.js";
26
+ /** The `entityType` this serializer reads. */
27
+ export declare const CEDAR_POLICY_TYPE = "Cedar::Policy";
28
+ /** Filename of the JSON policy-set companion to the primary `.cedar` output. */
29
+ export declare const CEDAR_JSON_FILENAME = "policies.cedar.json";
30
+ /** A Cedar policy either permits or forbids; there is no third effect. */
31
+ export type CedarEffect = "permit" | "forbid";
32
+ /**
33
+ * One scope position (`principal`, `action`, `resource`).
34
+ *
35
+ * `{}` is "any" — the unconstrained form Cedar writes as a bare variable.
36
+ * The constrained forms mirror the grammar: `== E`, `in E`, `in [E, …]`,
37
+ * `is T`, and `is T in E`.
38
+ */
39
+ export type CedarScope = Record<string, never> | {
40
+ eq: string;
41
+ in?: never;
42
+ is?: never;
43
+ } | {
44
+ in: string | string[];
45
+ eq?: never;
46
+ is?: never;
47
+ } | {
48
+ is: string;
49
+ in?: string | string[];
50
+ eq?: never;
51
+ };
52
+ /** The `props` of a `Cedar::Policy` entity. */
53
+ export interface CedarPolicyProps {
54
+ /** Defaults to `permit` when omitted. */
55
+ effect?: CedarEffect;
56
+ /** Defaults to unconstrained (`{}`) when omitted. */
57
+ principal?: CedarScope;
58
+ /** Defaults to unconstrained (`{}`) when omitted. */
59
+ action?: CedarScope;
60
+ /** Defaults to unconstrained (`{}`) when omitted. */
61
+ resource?: CedarScope;
62
+ /** Cedar expression strings, each emitted as its own `when { … }` clause. */
63
+ when?: string[];
64
+ /** Cedar expression strings, each emitted as its own `unless { … }` clause. */
65
+ unless?: string[];
66
+ /**
67
+ * Emitted as `@key("value")` above the policy. An explicit `id` wins over
68
+ * the one derived from the logical name.
69
+ */
70
+ annotations?: Record<string, string>;
71
+ }
72
+ /** Escape a string for a double-quoted Cedar literal. */
73
+ export declare function escapeCedarString(value: string): string;
74
+ /**
75
+ * Derive a policy id from a logical name: `allowAdminRead` → `allow-admin-read`.
76
+ * Cedar ids are free-form strings; kebab-case keeps them readable in the
77
+ * `@id` annotation and stable across a rename-free refactor.
78
+ */
79
+ export declare function policyIdFromLogicalName(name: string): string;
80
+ /**
81
+ * One policy, as `.cedar` text.
82
+ *
83
+ * Exported because the AVP embedding (#1652) needs exactly this string and
84
+ * nothing else — `AWS::VerifiedPermissions::Policy` carries its policy as
85
+ * `Definition.Static.Statement`, a single Cedar policy rather than a set. Two
86
+ * renderers would be two dialects; there is one.
87
+ */
88
+ export declare function renderPolicyText(id: string, props: Record<string, unknown>): string;
89
+ /** The JSON policy-set envelope, exactly as `cedar-wasm` accepts it. */
90
+ export interface CedarPolicySetJSON {
91
+ staticPolicies: Record<string, PolicyJson>;
92
+ templates: Record<string, PolicyJson>;
93
+ templateLinks: unknown[];
94
+ }
95
+ /**
96
+ * Build the JSON companion from the emitted `.cedar` text.
97
+ *
98
+ * Two things fall out of going through the module rather than around it. The
99
+ * condition bodies become real expression trees, which is the whole reason the
100
+ * file is worth writing; and a policy carrying a `?principal`/`?resource` slot
101
+ * lands under `templates` rather than `staticPolicies`, because Cedar — not
102
+ * this serializer — is what decides which one it is.
103
+ *
104
+ * Ids come from each policy's own `@id`, not from the emission order, so the
105
+ * keys here cannot drift from the annotations in the text beside them.
106
+ */
107
+ export declare function policySetJSON(text: string): {
108
+ doc?: CedarPolicySetJSON;
109
+ error?: string;
110
+ };
111
+ /** One declared policy, resolved: its chant name, its Cedar id, and its walked props. */
112
+ export interface CedarPolicyRecord {
113
+ /** The chant entity name — the export name on the `*.ts` file. */
114
+ name: string;
115
+ /** The Cedar policy id, as it appears in `@id(…)`. */
116
+ id: string;
117
+ /** Props with references resolved, ready for either renderer. */
118
+ props: Record<string, unknown>;
119
+ }
120
+ /**
121
+ * The Cedar id for a policy: an explicit `annotations.id` when the author gave
122
+ * one, else derived from the logical name.
123
+ *
124
+ * This is the only rule that links a chant entity to a policy in a live AVP
125
+ * store (#1652) — the observation resolves the same id from the same props and
126
+ * matches it against the `@id` annotation the statement carries. Two copies of
127
+ * this rule would be a mapping that drifts silently, so there is one.
128
+ */
129
+ export declare function resolvePolicyId(logicalName: string, props: Record<string, unknown>): string;
130
+ /**
131
+ * Every `Cedar::Policy` in a build, with references walked and ids resolved.
132
+ *
133
+ * The serializer's own first pass, exported so the AVP embedding (#1652)
134
+ * renders from the same model rather than re-deriving it.
135
+ */
136
+ export declare function cedarPolicyRecords(entities: Map<string, Declarable>): CedarPolicyRecord[];
137
+ export declare const cedarSerializer: Serializer;
138
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,6BAA6B,CAAC;AAGhF,OAAO,EAAgD,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAI5F,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACrB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAA;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AED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,kBAAkB,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CA4BxF;AAID,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAK3F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,iBAAiB,EAAE,CAiBzF;AAID,eAAO,MAAM,eAAe,EAAE,UAgC7B,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * "Fetch" the Cedar schema — which for this lexicon means reading a file.
3
+ *
4
+ * Every other lexicon downloads one global upstream spec. Cedar's interesting
5
+ * spec is the *project's* schema (epic #1645), so there is nothing to fetch,
6
+ * nothing to cache, and no network at all. What replaces it is a small
7
+ * resolution order:
8
+ *
9
+ * 1. `cedar.schema` from the project's `chant.config.ts`
10
+ * 2. `schema.cedarschema` in the project root
11
+ * 3. the schema bundled at `./default-schema.cedarschema`
12
+ *
13
+ * Step 3 is the one that needs defending. Without it `generate()` has nothing
14
+ * to read in a checkout that has not written a schema yet — which is every
15
+ * fresh clone, `just check-lexicons`, and this lexicon's own examples — and a
16
+ * lexicon whose generate step only works after the user does something is a
17
+ * lexicon whose generate step is never gated. The default is a real
18
+ * application-authorization schema, not a stub, so the surface it produces is
19
+ * worth exercising.
20
+ *
21
+ * `requireProjectSchema` turns step 3 off for projects that have moved past it.
22
+ */
23
+ /** Filename the bundled fallback schema ships under. */
24
+ export declare const DEFAULT_SCHEMA_FILENAME = "default-schema.cedarschema";
25
+ /** Map key used for the single schema entry, so `parseSchema` can tell them apart. */
26
+ export declare const DEFAULT_SCHEMA_KEY = "<bundled-default>";
27
+ /** Absolute path to the schema bundled with this package. */
28
+ export declare function defaultSchemaPath(): string;
29
+ export interface SchemaSource {
30
+ /** Absolute path the text came from. */
31
+ path: string;
32
+ /** The `.cedarschema` text. */
33
+ text: string;
34
+ /** True when the bundled fallback was used rather than a project schema. */
35
+ isDefault: boolean;
36
+ }
37
+ export interface ResolveSchemaOptions {
38
+ /** Project root to resolve a relative `cedar.schema` against. Defaults to `process.cwd()`. */
39
+ projectRoot?: string;
40
+ /** Already-loaded `cedar` config namespace, if the caller has one. */
41
+ config?: {
42
+ schema?: string;
43
+ validation?: {
44
+ requireProjectSchema?: boolean;
45
+ };
46
+ };
47
+ }
48
+ /**
49
+ * Resolve which schema `generate()` should read, without loading it.
50
+ *
51
+ * Separated from {@link fetchSchemas} so tests and `coverage()` can ask the
52
+ * question without reading the file.
53
+ */
54
+ export declare function resolveSchemaPath(options?: ResolveSchemaOptions): {
55
+ path: string;
56
+ isDefault: boolean;
57
+ };
58
+ /** Read the resolved schema. */
59
+ export declare function readSchemaSource(options?: ResolveSchemaOptions): SchemaSource;
60
+ /**
61
+ * The `fetchSchemas` callback for `generatePipeline`.
62
+ *
63
+ * Keyed by `<bundled-default>` or by the project schema's absolute path, which
64
+ * is how `parseSchema` knows whether the content pin applies.
65
+ */
66
+ export declare function fetchSchemas(options?: {
67
+ force?: boolean;
68
+ projectRoot?: string;
69
+ config?: ResolveSchemaOptions["config"];
70
+ }): Promise<Map<string, Buffer>>;
71
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/spec/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,wDAAwD;AACxD,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;AAEpE,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAItD,6DAA6D;AAC7D,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,8FAA8F;IAC9F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE;YAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;CAC/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,oBAAyB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAoB1G;AAED,gCAAgC;AAChC,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,oBAAyB,GAAG,YAAY,CAGjF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAK/B"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Turn a `.cedarschema` into the flat declaration list the emitters read.
3
+ *
4
+ * The canonical input is the human-readable syntax and the canonical
5
+ * intermediate is `schemaToJsonWithResolvedTypes`' output (#1648 §4). That
6
+ * choice buys one thing that matters here: `schemaToJson` emits
7
+ * `{type:"EntityOrCommon", name}` for every named type, which cannot
8
+ * distinguish an entity reference from a primitive from a common-type alias,
9
+ * so an emitter reading it would have to re-implement Cedar's own name
10
+ * resolution. The resolved form hands back `{type:"Entity", name:"App::User"}`
11
+ * for references and bare primitives for the rest.
12
+ *
13
+ * What it does *not* resolve is common types in attribute position: those come
14
+ * back as a bare qualified name (`{type:"App::TagSet"}`) with the definition
15
+ * still in `commonTypes`. {@link resolveTypeRef} closes that last hop, so
16
+ * nothing downstream ever sees an alias.
17
+ *
18
+ * One declaration per entity type and one per action, each carrying its own
19
+ * fully-qualified `typeName` — which is what lets `NamingStrategy` contest
20
+ * short names across namespaces the same way it does for every other lexicon.
21
+ */
22
+ import type { ParsedResult } from "@intentius/chant/codegen/generate";
23
+ import { type ResolvedSchemaJson, type ResolvedType } from "./wasm.js";
24
+ /** A Cedar type, with common-type aliases already collapsed. */
25
+ export type CedarTypeRef = {
26
+ kind: "primitive";
27
+ cedar: "String" | "Long" | "Bool";
28
+ ts: "string" | "number" | "boolean";
29
+ } | {
30
+ kind: "entity";
31
+ entityType: string;
32
+ } | {
33
+ kind: "set";
34
+ element: CedarTypeRef;
35
+ } | {
36
+ kind: "record";
37
+ attributes: CedarAttribute[];
38
+ }
39
+ /** `ipaddr`, `decimal`, `datetime`, `duration` — carried as strings in TS. */
40
+ | {
41
+ kind: "extension";
42
+ name: string;
43
+ }
44
+ /** An enumerated entity type, or anything the resolver left unrecognized. */
45
+ | {
46
+ kind: "opaque";
47
+ name: string;
48
+ };
49
+ export interface CedarAttribute {
50
+ name: string;
51
+ required: boolean;
52
+ type: CedarTypeRef;
53
+ }
54
+ interface CedarDeclBase extends ParsedResult {
55
+ /** Fully-qualified: `App::User`, or `App::Action::"read"`. */
56
+ typeName: string;
57
+ /** Namespace the declaration lives in; `""` for the empty namespace. */
58
+ namespace: string;
59
+ propertyTypes: Array<{
60
+ name: string;
61
+ }>;
62
+ enums: unknown[];
63
+ }
64
+ export interface CedarEntityDecl extends CedarDeclBase {
65
+ kind: "entity";
66
+ /** Unqualified name as written in the schema. */
67
+ shortName: string;
68
+ /** Fully-qualified parents from `in [...]`. */
69
+ memberOfTypes: string[];
70
+ attributes: CedarAttribute[];
71
+ /** Present for an enumerated entity (`entity Env enum ["prod","dev"]`). */
72
+ enumValues?: string[];
73
+ }
74
+ export interface CedarActionDecl extends CedarDeclBase {
75
+ kind: "action";
76
+ /** The action id as written (`read`). */
77
+ actionId: string;
78
+ principalTypes: string[];
79
+ resourceTypes: string[];
80
+ context: CedarAttribute[];
81
+ }
82
+ export type CedarDecl = CedarEntityDecl | CedarActionDecl;
83
+ export interface ParsedSchema {
84
+ decls: CedarDecl[];
85
+ /** The resolved JSON, kept for the content pin and for coverage reporting. */
86
+ resolved: ResolvedSchemaJson;
87
+ }
88
+ /**
89
+ * Parse a `.cedarschema` into declarations plus the resolved JSON it came from.
90
+ *
91
+ * Throws with the wasm's own message on a schema that does not parse — which
92
+ * is the right failure for a project schema that is malformed, and reads far
93
+ * better than the alternative, since Cedar's parse errors carry `did you mean`
94
+ * suggestions.
95
+ */
96
+ export declare function parseCedarSchema(schemaText: string): ParsedSchema;
97
+ /**
98
+ * `parseSchema` for `generatePipeline`. One buffer in, many declarations out.
99
+ */
100
+ export declare function parseSchema(_typeName: string, data: Buffer): CedarDecl[];
101
+ /** `App` + `User` → `App::User`; the empty namespace yields the bare name. */
102
+ export declare function qualify(namespace: string, shortName: string): string;
103
+ /** The entity UID form an action is referenced by in a policy. */
104
+ export declare function actionUid(namespace: string, actionId: string): string;
105
+ /**
106
+ * Collapse one resolved type node, following common-type aliases.
107
+ *
108
+ * `seen` guards a schema whose common types reference each other — Cedar
109
+ * rejects true cycles, but a malformed one should not spin here.
110
+ */
111
+ export declare function resolveTypeRef(node: ResolvedType, commonTypes: Record<string, ResolvedType>, namespace: string, seen?: ReadonlySet<string>): CedarTypeRef;
112
+ export {};
113
+ //# sourceMappingUR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AAC,MAAM,CAAa,GACpC,YAAY,CA4Cd"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * What this lexicon pins, and why it pins two different things (#1650, #1390).
3
+ *
4
+ * ## The version pin
5
+ *
6
+ * `@cedar-policy/cedar-wasm` and the Cedar *language* move independently: the
7
+ * package is 4.12.0, the grammar it implements is 4.5 (#1648 §0). A package
8
+ * bump that leaves the language at 4.5 cannot change what parses, so the
9
+ * language version is the value worth asserting at generation time and the
10
+ * package version is the one `upstreamPin` bumps. Both are recorded.
11
+ *
12
+ * The runtime assert is chant #1390's spirit applied to a dependency rather
13
+ * than to a downloaded spec: generation refuses when the installed package
14
+ * implements a different language version than the one whose resolved output
15
+ * produced the committed artifacts. Releases are roughly monthly, so this will
16
+ * fire — and when it does, the answer is to look at the new resolved JSON, not
17
+ * to publish types generated from a grammar nobody checked.
18
+ *
19
+ * ## The content pin
20
+ *
21
+ * The bundled default schema (`default-schema.cedarschema`) is what generation
22
+ * reads in this repo and in a fresh checkout, so it decides the published
23
+ * surface. There is no upstream URL to pin, so the pin is over content: a
24
+ * sha256 over the *resolved* JSON — the thing the emitters actually read —
25
+ * plus the covered entity-type and action names committed beside it.
26
+ *
27
+ * Resolved-JSON serialization is byte-deterministic (Rust `BTreeMap` ordering,
28
+ * 1 distinct serialization over 25 runs, #1648 §5.2), so the digest is stable.
29
+ * It moves when the default schema is edited, and — the case the pin exists for
30
+ * — when a cedar-wasm upgrade resolves the same schema differently. Both change
31
+ * the generated types, and neither is visible in a diff otherwise, because
32
+ * `src/generated/` is not committed.
33
+ *
34
+ * A user's own project schema is not pinned. It is their input, they own its
35
+ * churn, and refusing to generate because they edited their own schema would be
36
+ * absurd.
37
+ */
38
+ /** The pinned `@cedar-policy/cedar-wasm` version — what `upstreamPin` bumps. */
39
+ export declare const CEDAR_WASM_VERSION = "4.12.0";
40
+ /** The Cedar *language* version that package implements (`getCedarLangVersion()`). */
41
+ export declare const CEDAR_LANG_VERSION = "4.5";
42
+ /** Env var that proceeds past a language-version mismatch for one run. */
43
+ export declare const ACCEPT_LANG_ENV = "CHANT_ACCEPT_CEDAR_LANG";
44
+ /** Env var that accepts a moved default-schema digest, printing the new pin. */
45
+ export declare const ACCEPT_SCHEMA_ENV = "CHANT_ACCEPT_CEDAR_SCHEMA";
46
+ /**
47
+ * The entity types and action UIDs the pinned default schema resolved to.
48
+ *
49
+ * Committed beside the digest for the same reason aws commits its type names:
50
+ * without the list, accepting a new pin is one opaque hash replacing another,
51
+ * and the generated artifacts cannot stand in because they are gitignored.
52
+ */
53
+ export declare const PINNED_SCHEMA_NAMES: readonly string[];
54
+ export interface SchemaPin {
55
+ /** `sha256:…` over the resolved schema JSON. */
56
+ readonly digest: string;
57
+ /** How many entity types and actions the pinned schema declared. */
58
+ readonly declarations: number;
59
+ /** ISO date the pin was accepted, so a diff reads as a decision. */
60
+ readonly accepted: string;
61
+ }
62
+ /**
63
+ * The accepted default schema.
64
+ *
65
+ * To move it: run generation, read the refusal, confirm the delta is one you
66
+ * want, and paste the printed block here in its own commit.
67
+ */
68
+ export declare const CEDAR_SCHEMA_PIN: SchemaPin;
69
+ /**
70
+ * Digest the resolved schema JSON.
71
+ *
72
+ * Hashes the canonical serialization the wasm produced, not the authored
73
+ * `.cedarschema` text: reformatting a schema, or reordering its entity types,
74
+ * changes the text and not one byte of what the emitters read.
75
+ */
76
+ export declare function resolvedSchemaDigest(resolved: unknown): string;
77
+ /** What moved between the pinned schema and the one just resolved. */
78
+ export interface SchemaDrift {
79
+ digest: string;
80
+ declarations: number;
81
+ added: string[];
82
+ removed: string[];
83
+ }
84
+ /** Compare a freshly resolved schema against a pin. `null` when it matches. */
85
+ export declare function schemaDrift(resolved: unknown, names: readonly string[], pinnedNamesList?: readonly string[], pin?: SchemaPin): SchemaDrift | null;
86
+ /** The report a mismatch produces. */
87
+ export declare function schemaDriftMessage(drift: SchemaDrift, pin?: SchemaPin): string;
88
+ /**
89
+ * Refuse a default schema whose resolved JSON does not match the pin.
90
+ *
91
+ * Unlike aws, this one refuses on any digest move rather than only on a
92
+ * declaration-set change. It can afford to: the input is a file in this repo
93
+ * and a dependency at a pinned version, neither of which changes under the
94
+ * build's feet the way a republished CloudFormation archive does.
95
+ */
96
+ export declare function assertPinnedSchema(resolved: unknown, names: readonly string[], options?: {
97
+ pin?: SchemaPin;
98
+ pinnedNames?: readonly string[];
99
+ env?: NodeJS.ProcessEnv;
100
+ warn?: (message: string) => void;
101
+ }): void;
102
+ /**
103
+ * Refuse to generate against a Cedar language version other than the pinned one.
104
+ *
105
+ * chant #1390's rule, one level up the supply chain: a lexicon does not emit
106
+ * types derived from a grammar nobody chose. `getCedarLangVersion()` is the
107
+ * right probe because it is the number that decides what parses — the package
108
+ * version moves monthly and mostly does not.
109
+ */
110
+ export declare function assertPinnedLangVersion(options?: {
111
+ actual?: string;
112
+ expected?: string;
113
+ env?: NodeJS.ProcessEnv;
114
+ warn?: (message: string) => void;
115
+ }): void;
116
+ //# sourceMappingURL=pin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/spec/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAA4B,CAAC;AAE9E,MAAM,WAAW,SAAS;IACxB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,QAA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C7B,GACL,IAAI,CAyBN"}
@@ -0,0 +1,18 @@
1
+ [
2
+ "App::Action::\"admin\"",
3
+ "App::Action::\"approve\"",
4
+ "App::Action::\"comment\"",
5
+ "App::Action::\"create\"",
6
+ "App::Action::\"delete\"",
7
+ "App::Action::\"list\"",
8
+ "App::Action::\"read\"",
9
+ "App::Action::\"share\"",
10
+ "App::Action::\"write\"",
11
+ "App::Application",
12
+ "App::Document",
13
+ "App::Folder",
14
+ "App::Group",
15
+ "App::ServiceAccount",
16
+ "App::Team",
17
+ "App::User"
18
+ ]
@@ -0,0 +1,143 @@
1
+ /**
2
+ * The one place `@cedar-policy/cedar-wasm` is called from.
3
+ *
4
+ * Three findings from the 4.12.0 verification (#1648) are encoded here rather
5
+ * than left to each caller to remember:
6
+ *
7
+ * 1. **Only the `/nodejs` flavor.** The root ESM build imports the `.wasm` as
8
+ * an ES module, which Bun cannot start (`wasm.__wbindgen_start is not a
9
+ * function`) and Node only supports behind an experimental warning printed
10
+ * on every run. `/nodejs` loads the binary with `readFileSync` and works
11
+ * under node CJS, node ESM, vitest and bun alike.
12
+ *
13
+ * 2. **`schemaToJsonWithResolvedTypes` takes a string and means it.** A JS
14
+ * object traps the wasm with `memory access out of bounds` — not a failure
15
+ * answer, a memory fault. The `typeof === "string"` guard below is the
16
+ * difference between a readable error and a trap.
17
+ *
18
+ * 3. **The `Answer` union is not the whole error channel.** Malformed input
19
+ * throws a bare serde `Error` from inside the wasm instead of returning
20
+ * `{type:"failure"}`, and the `line 1 column N` in those messages refers to
21
+ * the internal call struct, not to anything the user wrote. Both channels
22
+ * are normalized into one result type here.
23
+ */
24
+ import type * as CedarWasm from "@cedar-policy/cedar-wasm/nodejs";
25
+ /** A namespace body in the resolved schema JSON. */
26
+ export interface ResolvedNamespace {
27
+ commonTypes?: Record<string, ResolvedType>;
28
+ entityTypes?: Record<string, ResolvedEntityType>;
29
+ actions?: Record<string, ResolvedAction>;
30
+ annotations?: Record<string, string>;
31
+ }
32
+ export interface ResolvedEntityType {
33
+ memberOfTypes?: string[];
34
+ shape?: ResolvedType;
35
+ tags?: ResolvedType;
36
+ enum?: string[];
37
+ annotations?: Record<string, string>;
38
+ }
39
+ export interface ResolvedAction {
40
+ memberOf?: Array<{
41
+ id: string;
42
+ type?: string;
43
+ }>;
44
+ appliesTo?: {
45
+ principalTypes?: string[];
46
+ resourceTypes?: string[];
47
+ context?: ResolvedType;
48
+ };
49
+ annotations?: Record<string, string>;
50
+ }
51
+ /**
52
+ * A type in the *resolved* schema JSON.
53
+ *
54
+ * `schemaToJson` emits `{type:"EntityOrCommon", name}` for every named type,
55
+ * which cannot tell an entity reference from a primitive from a common-type
56
+ * alias. `schemaToJsonWithResolvedTypes` collapses that to `{type:"Entity"}`
57
+ * for entity references and to the primitive name otherwise — except for
58
+ * common types, which stay as a bare qualified `{type:"App::TagSet"}` and are
59
+ * resolved against `commonTypes` by the emitter.
60
+ */
61
+ export interface ResolvedType {
62
+ type: string;
63
+ name?: string;
64
+ element?: ResolvedType;
65
+ attributes?: Record<string, ResolvedType>;
66
+ required?: boolean;
67
+ enum?: string[];
68
+ }
69
+ /** The `SchemaJson` shape, keyed by namespace (`""` is the empty namespace). */
70
+ export type ResolvedSchemaJson = Record<string, ResolvedNamespace>;
71
+ export type WasmResult<T> = {
72
+ ok: true;
73
+ value: T;
74
+ } | {
75
+ ok: false;
76
+ error: string;
77
+ };
78
+ /** The Cedar *language* version this build of the package implements. */
79
+ export declare function langVersion(): string;
80
+ /** The `@cedar-policy/cedar-wasm` package version. */
81
+ export declare function packageVersion(): string;
82
+ /**
83
+ * Resolve a human-readable `.cedarschema` into fully-qualified schema JSON.
84
+ *
85
+ * Returns a result rather than throwing so a bad project schema reads as a
86
+ * message about the project schema, not as a stack trace out of a wasm module.
87
+ */
88
+ export declare function resolveSchema(schemaText: unknown): WasmResult<ResolvedSchemaJson>;
89
+ /** One Cedar policy in Cedar's own JSON policy format. */
90
+ export type PolicyJson = CedarWasm.PolicyJson;
91
+ /** The two halves `policySetTextToParts` splits a `.cedar` document into. */
92
+ export interface PolicySetParts {
93
+ /** Verbatim source text of each static policy, in source order. */
94
+ policies: string[];
95
+ /** Verbatim source text of each template, in source order. */
96
+ templates: string[];
97
+ }
98
+ /**
99
+ * Split a `.cedar` document into its policies and its templates.
100
+ *
101
+ * The strings that come back are the **verbatim source** of each policy —
102
+ * annotations, line breaks and all — in source order, which is what lets the
103
+ * importer recover a condition body exactly as it was written rather than as
104
+ * the JSON leg would re-render it. Comments are dropped: they are not part of
105
+ * any grammar the module round-trips.
106
+ */
107
+ export declare function splitPolicySet(text: unknown): WasmResult<PolicySetParts>;
108
+ /** Convert one *static* policy (text or JSON) into Cedar's JSON policy format. */
109
+ export declare function policyToJson(policy: string | PolicyJson): WasmResult<PolicyJson>;
110
+ /**
111
+ * Convert one *template* (text or JSON) into Cedar's JSON policy format.
112
+ *
113
+ * A policy carrying `?principal`/`?resource` is a template, and `policyToJson`
114
+ * refuses it outright ("expected a static policy, got a template containing
115
+ * the slot ?resource") — the two entry points are not interchangeable.
116
+ */
117
+ export declare function templateToJson(template: string | PolicyJson): WasmResult<PolicyJson>;
118
+ /**
119
+ * Render one policy's JSON back to Cedar text.
120
+ *
121
+ * Only ever used to recover an *expression* body that has no source text to
122
+ * quote — an imported JSON policy set. The output is single-line and defensively
123
+ * parenthesized (`((context.mfa) == true)`), and `formatPolicies` does not undo
124
+ * that, so it is never the source of a human-facing `.cedar` artifact: those are
125
+ * laid out by the serializer.
126
+ */
127
+ export declare function policyToText(policy: PolicyJson): WasmResult<string>;
128
+ /**
129
+ * Does this value parse as a Cedar policy set?
130
+ *
131
+ * `checkParsePolicySet` throws — rather than answering `failure` — for a
132
+ * document carrying keys it does not know, which is precisely the shape a
133
+ * foreign lexicon's JSON has, so the throw is a match rejection here.
134
+ */
135
+ export declare function parsesAsPolicySet(value: unknown): boolean;
136
+ /**
137
+ * Flatten a `DetailedError[]` into one line.
138
+ *
139
+ * `code`, `url` and `severity` are `null` on every error this package emits
140
+ * (#1648 §5.6), so only `message` and `help` carry anything.
141
+ */
142
+ export declare function formatWasmErrors(errors: unknown): string;
143
+ //# sourceMappingURL=wasm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/spec/wasm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,KAAK,SAAS,MAAM,iCAAiC,CAAC;AAwBlE,oDAAoD;AACpD,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE;QACV,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,EAAE,YAAY,CAAC;KACxB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;C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