@intentius/chant-lexicon-cedar 0.44.8 → 0.44.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/codegen/package.d.ts.map +1 -1
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/dogwood/cli.d.ts +206 -0
- package/dist/dogwood/cli.d.ts.map +1 -0
- package/dist/dogwood/event-schema.d.ts +161 -0
- package/dist/dogwood/event-schema.d.ts.map +1 -0
- package/dist/dogwood/index.d.ts +33 -0
- package/dist/dogwood/index.d.ts.map +1 -0
- package/dist/dogwood/macros.d.ts +96 -0
- package/dist/dogwood/macros.d.ts.map +1 -0
- package/dist/dogwood/policy.d.ts +120 -0
- package/dist/dogwood/policy.d.ts.map +1 -0
- package/dist/dogwood/scan.d.ts +109 -0
- package/dist/dogwood/scan.d.ts.map +1 -0
- package/dist/dogwood/serialize.d.ts +46 -0
- package/dist/dogwood/serialize.d.ts.map +1 -0
- package/dist/dogwood/temporal.d.ts +259 -0
- package/dist/dogwood/temporal.d.ts.map +1 -0
- package/dist/dogwood/upstream.d.ts +41 -0
- package/dist/dogwood/upstream.d.ts.map +1 -0
- package/dist/dogwood/window.d.ts +73 -0
- package/dist/dogwood/window.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +13 -3
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/dogwood-helpers.d.ts +63 -0
- package/dist/lint/post-synth/dogwood-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc010.d.ts +25 -0
- package/dist/lint/post-synth/dwdc010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc011.d.ts +19 -0
- package/dist/lint/post-synth/dwdc011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc012.d.ts +21 -0
- package/dist/lint/post-synth/dwdc012.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde010.d.ts +32 -0
- package/dist/lint/post-synth/dwde010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde011.d.ts +33 -0
- package/dist/lint/post-synth/dwde011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwds010.d.ts +24 -0
- package/dist/lint/post-synth/dwds010.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/okf/index.md +6 -0
- package/dist/okf/rules/DWDC010.md +11 -0
- package/dist/okf/rules/DWDC011.md +11 -0
- package/dist/okf/rules/DWDC012.md +11 -0
- package/dist/okf/rules/DWDE010.md +11 -0
- package/dist/okf/rules/DWDE011.md +11 -0
- package/dist/okf/rules/DWDS010.md +11 -0
- package/dist/policy-text.d.ts +53 -0
- package/dist/policy-text.d.ts.map +1 -0
- package/dist/rules/dogwood-helpers.ts +139 -0
- package/dist/rules/dwdc010.ts +62 -0
- package/dist/rules/dwdc011.ts +61 -0
- package/dist/rules/dwdc012.ts +46 -0
- package/dist/rules/dwde010.ts +130 -0
- package/dist/rules/dwde011.ts +108 -0
- package/dist/rules/dwds010.ts +46 -0
- package/dist/serializer.d.ts +10 -18
- package/dist/serializer.d.ts.map +1 -1
- package/dist/skills/chant-cedar-authoring.md +180 -0
- package/dist/skills/chant-cedar-avp-embedding.md +125 -0
- package/dist/skills/chant-cedar-meta-policy.md +119 -0
- package/package.json +2 -2
- package/src/codegen/package.ts +3 -2
- package/src/config.test.ts +12 -0
- package/src/config.ts +28 -0
- package/src/dogwood/cli.test.ts +392 -0
- package/src/dogwood/cli.ts +545 -0
- package/src/dogwood/event-schema.test.ts +218 -0
- package/src/dogwood/event-schema.ts +318 -0
- package/src/dogwood/index.ts +198 -0
- package/src/dogwood/macros.test.ts +104 -0
- package/src/dogwood/macros.ts +229 -0
- package/src/dogwood/policy.test.ts +94 -0
- package/src/dogwood/policy.ts +141 -0
- package/src/dogwood/scan.ts +287 -0
- package/src/dogwood/serialize.test.ts +331 -0
- package/src/dogwood/serialize.ts +209 -0
- package/src/dogwood/temporal.test.ts +272 -0
- package/src/dogwood/temporal.ts +592 -0
- package/src/dogwood/testdata/custom-kinds.dwschema +17 -0
- package/src/dogwood/testdata/default-macros.dw +23 -0
- package/src/dogwood/testdata/lowered-read-after-login.json +13 -0
- package/src/dogwood/testdata/max-window-raised.dwschema +25 -0
- package/src/dogwood/testdata/pinned.dwschema +31 -0
- package/src/dogwood/testdata/read-after-login.cedarschema +20 -0
- package/src/dogwood/testdata/read-after-login.dw +17 -0
- package/src/dogwood/testdata/temporal-policies.dw +53 -0
- package/src/dogwood/upstream.ts +41 -0
- package/src/dogwood/window.ts +124 -0
- package/src/index.ts +24 -0
- package/src/lint/audit-catalog.ts +56 -0
- package/src/lint/post-synth/dogwood-helpers.ts +139 -0
- package/src/lint/post-synth/dwd-post-synth.test.ts +256 -0
- package/src/lint/post-synth/dwdc010.ts +62 -0
- package/src/lint/post-synth/dwdc011.ts +61 -0
- package/src/lint/post-synth/dwdc012.ts +46 -0
- package/src/lint/post-synth/dwde-post-synth.test.ts +368 -0
- package/src/lint/post-synth/dwde010.ts +130 -0
- package/src/lint/post-synth/dwde011.ts +108 -0
- package/src/lint/post-synth/dwds010.ts +46 -0
- package/src/lint/post-synth/index.ts +12 -0
- package/src/lint/post-synth/post-synth.test.ts +7 -3
- package/src/policy-text.ts +128 -0
- package/src/serializer.ts +71 -109
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dogwood entity model: a temporal policy, an event schema, a macro library.
|
|
3
|
+
*
|
|
4
|
+
* `Dogwood::TemporalPolicy` is `Cedar::Policy` plus the two clause forms
|
|
5
|
+
* upstream's policy grammar adds. Its head — annotations, effect, the three
|
|
6
|
+
* scope positions — is Cedar's, byte for byte, which is why `./serialize.ts`
|
|
7
|
+
* renders it with the cedar serializer's own `renderPolicyHead` rather than a
|
|
8
|
+
* copy of it. Only the `cond` rule differs:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* cond = { cond_kw ~ (extension_marker | guardrails_tag? ~ "{" ~ expr ~ "}") }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* — so a clause is `when { … }`, `when guardrails { … }`, or
|
|
15
|
+
* `when temporal { … }`, and the same three under `unless`. `guardrails` is
|
|
16
|
+
* transparent sugar for a bare Cedar expression (upstream discards the tag
|
|
17
|
+
* during lowering); `temporal { … }` is a genuine sub-language dispatched to a
|
|
18
|
+
* different parser.
|
|
19
|
+
*
|
|
20
|
+
* These are not schema-driven the way `Cedar::Policy`'s generated class is.
|
|
21
|
+
* Codegen's input is the project's `.cedarschema`, which says nothing about
|
|
22
|
+
* event kinds or temporal operators, so the dialect's classes are written here
|
|
23
|
+
* and typed against the builders in `./temporal.ts`.
|
|
24
|
+
*/
|
|
25
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
26
|
+
import type { CedarEffect, CedarScope } from "../serializer.js";
|
|
27
|
+
import type { TemporalCondition } from "./temporal.js";
|
|
28
|
+
import type { EventSchema } from "./event-schema.js";
|
|
29
|
+
import type { MacroDefinition } from "./macros.js";
|
|
30
|
+
/** The lexicon these entities belong to — dogwood is a dialect of cedar, not a lexicon. */
|
|
31
|
+
export declare const DOGWOOD_LEXICON = "cedar";
|
|
32
|
+
/** The `entityType` of a temporal policy. */
|
|
33
|
+
export declare const DOGWOOD_POLICY_TYPE = "Dogwood::TemporalPolicy";
|
|
34
|
+
/** The `entityType` of an event schema. */
|
|
35
|
+
export declare const DOGWOOD_EVENT_SCHEMA_TYPE = "Dogwood::EventSchema";
|
|
36
|
+
/** The `entityType` of a macro library. */
|
|
37
|
+
export declare const DOGWOOD_MACRO_LIBRARY_TYPE = "Dogwood::MacroLibrary";
|
|
38
|
+
/** The `.dw` policy set written beside the cedar outputs. */
|
|
39
|
+
export declare const DOGWOOD_POLICY_FILENAME = "policies.dw";
|
|
40
|
+
/** The `.dwschema` event schema — what `dogwood validate --event-schema` reads. */
|
|
41
|
+
export declare const DOGWOOD_EVENT_SCHEMA_FILENAME = "events.dwschema";
|
|
42
|
+
/** The macro library — what `dogwood validate --macros` reads. */
|
|
43
|
+
export declare const DOGWOOD_MACRO_FILENAME = "macros.dw";
|
|
44
|
+
/**
|
|
45
|
+
* The props of a `Dogwood::TemporalPolicy`.
|
|
46
|
+
*
|
|
47
|
+
* The first six mirror `CedarPolicyProps` exactly. The rest are the dialect's.
|
|
48
|
+
*/
|
|
49
|
+
export interface TemporalPolicyProps {
|
|
50
|
+
/** Defaults to `permit` when omitted. */
|
|
51
|
+
effect?: CedarEffect;
|
|
52
|
+
/** Defaults to unconstrained (`{}`) when omitted. */
|
|
53
|
+
principal?: CedarScope;
|
|
54
|
+
/** Defaults to unconstrained (`{}`) when omitted. */
|
|
55
|
+
action?: CedarScope;
|
|
56
|
+
/** Defaults to unconstrained (`{}`) when omitted. */
|
|
57
|
+
resource?: CedarScope;
|
|
58
|
+
/** Cedar expression strings, each emitted as its own `when { … }` clause. */
|
|
59
|
+
when?: string[];
|
|
60
|
+
/** Cedar expression strings, each emitted as its own `unless { … }` clause. */
|
|
61
|
+
unless?: string[];
|
|
62
|
+
/** Emitted as `@key("value")`; an explicit `id` wins over the logical name. */
|
|
63
|
+
annotations?: Record<string, string>;
|
|
64
|
+
/** Each emitted as its own `when temporal { … }` clause. */
|
|
65
|
+
whenTemporal?: TemporalCondition[];
|
|
66
|
+
/** Each emitted as its own `unless temporal { … }` clause. */
|
|
67
|
+
unlessTemporal?: TemporalCondition[];
|
|
68
|
+
/**
|
|
69
|
+
* Cedar expression strings emitted as `when guardrails { … }`.
|
|
70
|
+
*
|
|
71
|
+
* The tag carries no separate grammar — upstream parses the body as an
|
|
72
|
+
* ordinary Cedar expression and discards the tag when lowering. It marks a
|
|
73
|
+
* clause as a guardrail for a human reader and for whatever reads the source
|
|
74
|
+
* after chant; it does not change what the policy means.
|
|
75
|
+
*/
|
|
76
|
+
whenGuardrails?: string[];
|
|
77
|
+
/** As {@link whenGuardrails}, negated. */
|
|
78
|
+
unlessGuardrails?: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A temporal policy. Declare one per policy, the same way as `Cedar::Policy`:
|
|
82
|
+
*
|
|
83
|
+
* ```ts
|
|
84
|
+
* export const readAfterLogin = new TemporalPolicy({
|
|
85
|
+
* action: { eq: 'Drupe::Action::"Read"' },
|
|
86
|
+
* whenTemporal: [
|
|
87
|
+
* formerly("1h", predicate('Drupe::Action::"Login"', "response", {
|
|
88
|
+
* "input.user": ctx("input.user"),
|
|
89
|
+
* })),
|
|
90
|
+
* ],
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare const TemporalPolicy: new (props: TemporalPolicyProps) => Declarable;
|
|
95
|
+
/** The props of a `Dogwood::EventSchema`. */
|
|
96
|
+
export interface EventSchemaProps {
|
|
97
|
+
/** Built with `eventSchema()` or `defaultEventSchema()`. */
|
|
98
|
+
schema: EventSchema;
|
|
99
|
+
/** Defaults to {@link DOGWOOD_EVENT_SCHEMA_FILENAME}. */
|
|
100
|
+
filename?: string;
|
|
101
|
+
}
|
|
102
|
+
/** The service half of the schema, emitted as `.dwschema` text. */
|
|
103
|
+
export declare const TemporalEventSchema: new (props: EventSchemaProps) => Declarable;
|
|
104
|
+
/** The props of a `Dogwood::MacroLibrary`. */
|
|
105
|
+
export interface MacroLibraryProps {
|
|
106
|
+
macros: MacroDefinition[];
|
|
107
|
+
/** Defaults to {@link DOGWOOD_MACRO_FILENAME}. Ignored when `inline` is set. */
|
|
108
|
+
filename?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Emit the definitions at the top of the policy set instead of into their own
|
|
111
|
+
* file.
|
|
112
|
+
*
|
|
113
|
+
* A policy set's own `def` shadows a same-named library macro, so inlining is
|
|
114
|
+
* how a project stops depending on whoever runs the CLI passing `--macros`.
|
|
115
|
+
*/
|
|
116
|
+
inline?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** A `def cedar` / `def temporal` library, emitted as `.dw` text. */
|
|
119
|
+
export declare const TemporalMacroLibrary: new (props: MacroLibraryProps) => Declarable;
|
|
120
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/dogwood/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,2FAA2F;AAC3F,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAEhE,2CAA2C;AAC3C,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAElE,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,mFAAmF;AACnF,eAAO,MAAM,6BAA6B,oBAAoB,CAAC;AAE/D,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAErC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,8DAA8D;IAC9D,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACrC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,EAA0E,KACnG,KAAK,EAAE,mBAAmB,KACvB,UAAU,CAAC;AAEhB,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,MAAM,EAAE,WAAW,CAAC;IACpB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAgF,KAC9G,KAAK,EAAE,gBAAgB,KACpB,UAAU,CAAC;AAEhB,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,EAAiF,KAChH,KAAK,EAAE,iBAAiB,KACrB,UAAU,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the emitted dogwood artifacts back, for the DWD post-synth checks.
|
|
3
|
+
*
|
|
4
|
+
* The checks judge the *text*, not the in-memory model, for the same reason
|
|
5
|
+
* the CED checks judge `policies.cedar.json`: `chant audit` runs over a
|
|
6
|
+
* checked-in artifact chant did not write, and a wall that only fires on
|
|
7
|
+
* chant's own output is not a wall. It also means the typed builders and the
|
|
8
|
+
* walls are independent — DWDC012 catches a windowless `formerly` even though
|
|
9
|
+
* the builders cannot construct one, because `raw()` and a hand-written `.dw`
|
|
10
|
+
* both can.
|
|
11
|
+
*
|
|
12
|
+
* This is scanning, not parsing. Upstream owns the parser and #1659 owns
|
|
13
|
+
* shelling to it; what is here is the subset of the surface that answers the
|
|
14
|
+
* three questions the walls ask, plus enough comment handling not to be fooled
|
|
15
|
+
* by a commented-out clause.
|
|
16
|
+
*/
|
|
17
|
+
import type { PostSynthContext } from "@intentius/chant/lint/post-synth";
|
|
18
|
+
/** One emitted artifact, with everything needed to name it in a finding. */
|
|
19
|
+
export interface DogwoodArtifact {
|
|
20
|
+
/** The lexicon output it came from. */
|
|
21
|
+
lexicon: string;
|
|
22
|
+
/** The filename, which is what a finding points the reader at. */
|
|
23
|
+
source: string;
|
|
24
|
+
/** The file's text. */
|
|
25
|
+
text: string;
|
|
26
|
+
}
|
|
27
|
+
/** Every `.dw` policy file in the build output. */
|
|
28
|
+
export declare function dogwoodPolicyFiles(ctx: PostSynthContext): DogwoodArtifact[];
|
|
29
|
+
/** Every `.dwschema` event-schema file in the build output. */
|
|
30
|
+
export declare function dogwoodSchemaFiles(ctx: PostSynthContext): DogwoodArtifact[];
|
|
31
|
+
/**
|
|
32
|
+
* Blank out `//` comments, leaving string literals intact.
|
|
33
|
+
*
|
|
34
|
+
* String literals stay because a predicate's action id lives inside one
|
|
35
|
+
* (`Drupe::Action::"Read"`), and blanking those would blind every scan below.
|
|
36
|
+
* The walk is string-aware in the other direction too: a `//` inside a quoted
|
|
37
|
+
* value (a URL, say) is not a comment.
|
|
38
|
+
*
|
|
39
|
+
* Comment bytes become spaces so every offset in the result still lines up
|
|
40
|
+
* with the original file.
|
|
41
|
+
*/
|
|
42
|
+
export declare function blankComments(text: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* The stretches of a `.dw` file that the temporal sub-parser reads: every
|
|
45
|
+
* `temporal { … }` marker body, and every `def temporal … { … }` macro body.
|
|
46
|
+
*
|
|
47
|
+
* Scanning only these is what keeps a Cedar `when { … }` clause from being
|
|
48
|
+
* mistaken for temporal source — `context.retryWindow == 3` should not read as
|
|
49
|
+
* a window, and a Cedar attribute named `since` is not the `since` operator.
|
|
50
|
+
*/
|
|
51
|
+
export declare function temporalRegions(text: string): string[];
|
|
52
|
+
/** One `Ns::Action::"Name"::kind` predicate head found in temporal source. */
|
|
53
|
+
export interface TemporalPredicateRef {
|
|
54
|
+
/** The qualified action, quoted id and all. */
|
|
55
|
+
action: string;
|
|
56
|
+
/** The event kind segment after the quoted id. */
|
|
57
|
+
kind: string;
|
|
58
|
+
}
|
|
59
|
+
/** Every temporal predicate head in a `.dw` file, in source order. */
|
|
60
|
+
export declare function scanPredicates(text: string): TemporalPredicateRef[];
|
|
61
|
+
/** One window literal found in temporal source. */
|
|
62
|
+
export interface WindowRef {
|
|
63
|
+
/** As written: `48h`. */
|
|
64
|
+
text: string;
|
|
65
|
+
seconds: number;
|
|
66
|
+
/** `within` for an operator's window, `argument` for a bare macro-call interval. */
|
|
67
|
+
position: "within" | "argument";
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every window literal in a `.dw` file's temporal source.
|
|
71
|
+
*
|
|
72
|
+
* Both shapes count against `max_window`: a macro-call interval is the window
|
|
73
|
+
* a `within ?w` in the macro body resolves to, so `once(48h, …)` looks back
|
|
74
|
+
* exactly as far as `formerly within 48h` does.
|
|
75
|
+
*/
|
|
76
|
+
export declare function scanWindows(text: string): WindowRef[];
|
|
77
|
+
/**
|
|
78
|
+
* Every `formerly` / `previous` / `since` that is not followed by a `within`.
|
|
79
|
+
*
|
|
80
|
+
* Unrepresentable through the builders — {@link formerly} and its siblings all
|
|
81
|
+
* take the window as an argument — but reachable through `raw()`, through a
|
|
82
|
+
* hand-written `.dw`, and through an audit of a file chant never wrote.
|
|
83
|
+
*/
|
|
84
|
+
export declare function scanWindowlessOperators(text: string): string[];
|
|
85
|
+
/** What a `.dwschema` file says, as far as the walls need to know. */
|
|
86
|
+
export interface EventSchemaFacts {
|
|
87
|
+
/** Every declared event kind. */
|
|
88
|
+
kinds: string[];
|
|
89
|
+
/** The `max_window` directive in seconds, or upstream's 24h default when absent. */
|
|
90
|
+
maxWindowSeconds: number;
|
|
91
|
+
/** As written (`30d`), or undefined when the directive is absent. */
|
|
92
|
+
maxWindowText?: string;
|
|
93
|
+
/** True when at least one field carries a `pin … = …`. */
|
|
94
|
+
hasPin: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Read a `.dwschema` file's declarations. */
|
|
97
|
+
export declare function readEventSchema(text: string): EventSchemaFacts;
|
|
98
|
+
/**
|
|
99
|
+
* The look-back cap in force for a build.
|
|
100
|
+
*
|
|
101
|
+
* With no emitted schema, `ServiceSchema::defaults()` applies and the cap is
|
|
102
|
+
* 24h. With several, the tightest one wins — a window legal under one schema
|
|
103
|
+
* and not another is a window some consumer will reject.
|
|
104
|
+
*/
|
|
105
|
+
export declare function effectiveMaxWindowSeconds(schemas: EventSchemaFacts[]): {
|
|
106
|
+
seconds: number;
|
|
107
|
+
text: string;
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/dogwood/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,GAA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yBAAyB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAaxG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `.dw` serializer leg.
|
|
3
|
+
*
|
|
4
|
+
* Runs inside the cedar serializer, not beside it: `serializeDogwood` is
|
|
5
|
+
* called once the cedar policies have been rendered, and its files land in the
|
|
6
|
+
* same `SerializerResult`. That is the whole point of shipping dogwood as a
|
|
7
|
+
* dialect — a `.dw` file stripped of Cedar semantics is meaningless, and a
|
|
8
|
+
* project's temporal policies and its plain Cedar policies are one policy set
|
|
9
|
+
* with two halves.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here re-implements Cedar rendering. The policy head comes from
|
|
12
|
+
* `../serializer`'s `renderPolicyHead`, the scope forms from its
|
|
13
|
+
* `renderScope`, and the `when`/`unless` bodies from its `conditionStrings`,
|
|
14
|
+
* so a change to how a scope is written moves both outputs at once.
|
|
15
|
+
*/
|
|
16
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
17
|
+
/** Files ending in this carry dogwood policy text. */
|
|
18
|
+
export declare const DOGWOOD_POLICY_SUFFIX = ".dw";
|
|
19
|
+
/** Files ending in this carry an event schema. */
|
|
20
|
+
export declare const DOGWOOD_EVENT_SCHEMA_SUFFIX = ".dwschema";
|
|
21
|
+
/** What the leg produced: files to write, and anything the build should say out loud. */
|
|
22
|
+
export interface DogwoodSerializeResult {
|
|
23
|
+
files: Record<string, string>;
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One policy, in `.dw` surface syntax.
|
|
28
|
+
*
|
|
29
|
+
* Clause order is fixed rather than authored: every `when` form, then every
|
|
30
|
+
* `unless` form. Cedar evaluates a policy's conditions as a conjunction, and
|
|
31
|
+
* so does dogwood, so the order carries no meaning — fixing it means a policy
|
|
32
|
+
* that gains a temporal clause does not reshuffle the ones already there.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderTemporalPolicyText(id: string, props: Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render every dogwood entity in the build.
|
|
37
|
+
*
|
|
38
|
+
* Returns `undefined` when the build holds no temporal policies, event schemas
|
|
39
|
+
* or macro libraries at all — a cedar-only project sees no `.dw` output and no
|
|
40
|
+
* behaviour change.
|
|
41
|
+
*
|
|
42
|
+
* Ids come from `resolvePolicyId`, the same rule `cedarPolicyRecords` uses, so
|
|
43
|
+
* a policy's `@id` does not depend on which leg rendered it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function serializeDogwood(entities: Map<string, Declarable>): DogwoodSerializeResult | undefined;
|
|
46
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/dogwood/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAgB9D,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C,kDAAkD;AAClD,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAUD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAgB3F;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,sBAAsB,GAAG,SAAS,CAgGtG"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed builders for dogwood's temporal sub-language.
|
|
3
|
+
*
|
|
4
|
+
* These target the **parser primitives**, not the named aggregates. The #1657
|
|
5
|
+
* verification (and the correction comment on epic #1646) is explicit about
|
|
6
|
+
* why: `formerly`, `previous`, `since`, `exists`, `tp()`, `count for … where`
|
|
7
|
+
* and `sum … for … where` are the only temporal keywords in upstream's
|
|
8
|
+
* `extension/temporal/grammar.pest`. `count_within`, `sum_within`,
|
|
9
|
+
* `count_distinct_within` and `bind` are macros in `default_macros.dw` — a
|
|
10
|
+
* swappable standard library that a caller passing `--macros` replaces
|
|
11
|
+
* wholesale — and `once` is not even in that library, only in the examples.
|
|
12
|
+
*
|
|
13
|
+
* So the aggregates are expressible here as macro *calls* ({@link call}, and
|
|
14
|
+
* the convenience wrappers in `./macros.ts`), never as first-class operators.
|
|
15
|
+
* A call that resolves to nothing at the other end is a missing macro, which
|
|
16
|
+
* is a comprehensible failure; a first-class builder that silently emits a
|
|
17
|
+
* name the callee's library does not define is not.
|
|
18
|
+
*
|
|
19
|
+
* Everything below renders to the surface syntax the pest grammar accepts.
|
|
20
|
+
* Where the grammar's precedence would bind differently from the tree the
|
|
21
|
+
* author built, the renderer parenthesises — it never relies on the reader
|
|
22
|
+
* knowing that `!` binds tighter than `since`, or that an aggregate's `where`
|
|
23
|
+
* body is greedy.
|
|
24
|
+
*/
|
|
25
|
+
import { type TemporalWindow, type WindowLike, type WindowParam, type WindowValue } from "./window.js";
|
|
26
|
+
/** What the three past-only operators accept: a window, or a macro's `?w`. */
|
|
27
|
+
export type WindowArgument = WindowLike | WindowParam;
|
|
28
|
+
/**
|
|
29
|
+
* A binder position: a plain identifier, or a macro sigil.
|
|
30
|
+
*
|
|
31
|
+
* The sigils are legal only inside a macro body; upstream's well-formedness
|
|
32
|
+
* pass rejects them elsewhere. `./macros.ts` is where they belong, and it is
|
|
33
|
+
* what carries that warning to the author.
|
|
34
|
+
*/
|
|
35
|
+
export declare function binderName(value: string): string;
|
|
36
|
+
/** `(x: T)` — a declaration site in an `exists` or a `for` list. */
|
|
37
|
+
export interface TypedBinder {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
}
|
|
41
|
+
/** `(t: Timepoint)`, `(amount: Long)`, `($t: Timepoint)` inside a macro. */
|
|
42
|
+
export declare function typedBinder(name: string, type: string): TypedBinder;
|
|
43
|
+
/** Anything that renders in term position. */
|
|
44
|
+
export type TemporalTerm = TermText | ArrayTerm | CountTerm | SumTerm | CallNode;
|
|
45
|
+
/** A leaf term already in its surface form (a literal, a path, an entity UID). */
|
|
46
|
+
export interface TermText {
|
|
47
|
+
readonly op: "term";
|
|
48
|
+
readonly text: string;
|
|
49
|
+
}
|
|
50
|
+
/** `[a, b, c]`. */
|
|
51
|
+
export interface ArrayTerm {
|
|
52
|
+
readonly op: "array";
|
|
53
|
+
readonly items: readonly TemporalTerm[];
|
|
54
|
+
}
|
|
55
|
+
/** `count for (t: Timepoint). where φ`. */
|
|
56
|
+
export interface CountTerm {
|
|
57
|
+
readonly op: "count";
|
|
58
|
+
readonly binders: readonly TypedBinder[];
|
|
59
|
+
readonly where: TemporalCondition;
|
|
60
|
+
}
|
|
61
|
+
/** `sum a for (a: Long), (t: Timepoint). where φ`. */
|
|
62
|
+
export interface SumTerm {
|
|
63
|
+
readonly op: "sum";
|
|
64
|
+
readonly over: string;
|
|
65
|
+
readonly binders: readonly TypedBinder[];
|
|
66
|
+
readonly where: TemporalCondition;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What a builder accepts in term position.
|
|
70
|
+
*
|
|
71
|
+
* Numbers and booleans lift to literals because there is only one thing they
|
|
72
|
+
* can mean. A bare `string` deliberately does not: `"alice"` is a Cedar string
|
|
73
|
+
* literal and `alice` is a binder reference, and guessing which one the author
|
|
74
|
+
* meant is how a policy silently stops matching. Say which with {@link str},
|
|
75
|
+
* {@link varRef}, {@link ctx} or {@link entityUid}.
|
|
76
|
+
*/
|
|
77
|
+
export type TermInput = TemporalTerm | number | boolean;
|
|
78
|
+
/** A raw term, emitted verbatim. The escape hatch for a shape not modelled here. */
|
|
79
|
+
export declare function term(text: string): TermText;
|
|
80
|
+
/** A Cedar string literal: `"alice"`. */
|
|
81
|
+
export declare function str(value: string): TermText;
|
|
82
|
+
/** An integer literal. Upstream's grammar admits a leading `-`. */
|
|
83
|
+
export declare function int(value: number): TermText;
|
|
84
|
+
/** `true` / `false`. */
|
|
85
|
+
export declare function bool(value: boolean): TermText;
|
|
86
|
+
/** `decimal("1.50")` — Cedar's decimal constructor, which dogwood admits as a term. */
|
|
87
|
+
export declare function decimalOf(value: string): TermText;
|
|
88
|
+
/** `context.input.user` — a field of the request context record. */
|
|
89
|
+
export declare function ctx(path: string): TermText;
|
|
90
|
+
/** `principal`, `resource`, `principal.dept` — the request scope entities. */
|
|
91
|
+
export declare function scopeRef(root: "principal" | "resource", ...attrs: string[]): TermText;
|
|
92
|
+
/** `Drupe::OAuthUser::"alice"` — an entity UID literal. */
|
|
93
|
+
export declare function entityUid(uid: string): TermText;
|
|
94
|
+
/** A bare binder reference — a `for`-declared variable, or a macro sigil. */
|
|
95
|
+
export declare function varRef(name: string): TermText;
|
|
96
|
+
/** `*` — the grammar's wildcard term. */
|
|
97
|
+
export declare function wildcard(): TermText;
|
|
98
|
+
/** `[a, b]`. */
|
|
99
|
+
export declare function arrayOf(...items: TermInput[]): ArrayTerm;
|
|
100
|
+
/**
|
|
101
|
+
* `count for (t: Timepoint). where φ` — the primitive behind `count_within`.
|
|
102
|
+
*
|
|
103
|
+
* The `for` list is the aggregation domain and is mandatory in the grammar,
|
|
104
|
+
* so it is a required argument here too.
|
|
105
|
+
*/
|
|
106
|
+
export declare function count(binders: TypedBinder[], where: TemporalCondition): CountTerm;
|
|
107
|
+
/** `sum a for (a: Long), (t: Timepoint). where φ` — the primitive behind `sum_within`. */
|
|
108
|
+
export declare function sum(over: string, binders: TypedBinder[], where: TemporalCondition): SumTerm;
|
|
109
|
+
/** Anything that renders in condition position. */
|
|
110
|
+
export type TemporalCondition = PredicateNode | FormerlyNode | PreviousNode | SinceNode | ExistsNode | TpNode | AndNode | NotNode | ComparisonNode | CallNode | SigilCondition | RawCondition;
|
|
111
|
+
/** `Drupe::Action::"Login"::response{ input.user: context.input.user }`. */
|
|
112
|
+
export interface PredicateNode {
|
|
113
|
+
readonly op: "predicate";
|
|
114
|
+
readonly action: string;
|
|
115
|
+
readonly kind: string;
|
|
116
|
+
readonly args: ReadonlyArray<{
|
|
117
|
+
readonly path: string;
|
|
118
|
+
readonly value: TemporalTerm;
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
/** `formerly within 1h φ`. */
|
|
122
|
+
export interface FormerlyNode {
|
|
123
|
+
readonly op: "formerly";
|
|
124
|
+
readonly window: WindowValue;
|
|
125
|
+
readonly body: TemporalCondition;
|
|
126
|
+
}
|
|
127
|
+
/** `previous within 30s φ`. */
|
|
128
|
+
export interface PreviousNode {
|
|
129
|
+
readonly op: "previous";
|
|
130
|
+
readonly window: WindowValue;
|
|
131
|
+
readonly body: TemporalCondition;
|
|
132
|
+
}
|
|
133
|
+
/** `φ since within 1h ψ` — infix, with the window on the operator. */
|
|
134
|
+
export interface SinceNode {
|
|
135
|
+
readonly op: "since";
|
|
136
|
+
readonly left: TemporalCondition;
|
|
137
|
+
readonly window: WindowValue;
|
|
138
|
+
readonly right: TemporalCondition;
|
|
139
|
+
}
|
|
140
|
+
/** `exists (total: Long). φ`. */
|
|
141
|
+
export interface ExistsNode {
|
|
142
|
+
readonly op: "exists";
|
|
143
|
+
readonly binder: TypedBinder;
|
|
144
|
+
readonly body: TemporalCondition;
|
|
145
|
+
}
|
|
146
|
+
/** `tp(t)` — binds the timepoint under evaluation. */
|
|
147
|
+
export interface TpNode {
|
|
148
|
+
readonly op: "tp";
|
|
149
|
+
readonly binder: string;
|
|
150
|
+
}
|
|
151
|
+
/** `φ && ψ`. */
|
|
152
|
+
export interface AndNode {
|
|
153
|
+
readonly op: "and";
|
|
154
|
+
readonly operands: readonly TemporalCondition[];
|
|
155
|
+
}
|
|
156
|
+
/** `!φ`. */
|
|
157
|
+
export interface NotNode {
|
|
158
|
+
readonly op: "not";
|
|
159
|
+
readonly body: TemporalCondition;
|
|
160
|
+
}
|
|
161
|
+
/** `a == b`, `0 < count …`. */
|
|
162
|
+
export interface ComparisonNode {
|
|
163
|
+
readonly op: "compare";
|
|
164
|
+
readonly left: TemporalTerm;
|
|
165
|
+
readonly operator: ComparisonOperator;
|
|
166
|
+
readonly right: TemporalTerm;
|
|
167
|
+
}
|
|
168
|
+
/** The six operators `cmp_op` admits. */
|
|
169
|
+
export type ComparisonOperator = "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
170
|
+
/** A macro invocation — `once(1h, φ)`. Legal in both condition and term position. */
|
|
171
|
+
export interface CallNode {
|
|
172
|
+
readonly op: "call";
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly args: readonly MacroArg[];
|
|
175
|
+
}
|
|
176
|
+
/** `1h` as a macro-call argument — bare, with no `within` keyword. */
|
|
177
|
+
export interface IntervalArg {
|
|
178
|
+
readonly op: "interval";
|
|
179
|
+
readonly window: TemporalWindow;
|
|
180
|
+
}
|
|
181
|
+
/** What a macro call takes: an interval, a condition, or a term. */
|
|
182
|
+
export type MacroArg = IntervalArg | TemporalCondition | TemporalTerm;
|
|
183
|
+
/**
|
|
184
|
+
* Temporal source text emitted verbatim.
|
|
185
|
+
*
|
|
186
|
+
* The one builder that can produce something the walls exist to catch — a
|
|
187
|
+
* `formerly` with no window, an event kind the schema never declared. That is
|
|
188
|
+
* deliberate: an escape hatch nobody can reach makes the walls untestable, and
|
|
189
|
+
* DWDC012 reads the serialized text precisely because this exists.
|
|
190
|
+
*/
|
|
191
|
+
export interface RawCondition {
|
|
192
|
+
readonly op: "raw";
|
|
193
|
+
readonly text: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* `?s` — a macro parameter standing for an entire condition.
|
|
197
|
+
*
|
|
198
|
+
* Its own node rather than a {@link RawCondition} because the grammar treats
|
|
199
|
+
* it as an atom (`refinable = (predicate | sigil_cond) ~ field_block*`), so
|
|
200
|
+
* `formerly within ?w ?s` needs no parentheses where arbitrary raw text would.
|
|
201
|
+
* Build one with `macroCondition()` in `./macros.ts`, which is where the rule
|
|
202
|
+
* that sigils are legal only inside a macro body is documented.
|
|
203
|
+
*/
|
|
204
|
+
export interface SigilCondition {
|
|
205
|
+
readonly op: "sigil";
|
|
206
|
+
readonly param: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* `Ns::Action::"Name"::kind{ field: term, … }`.
|
|
210
|
+
*
|
|
211
|
+
* The event kind is mandatory in the grammar and author-defined in practice —
|
|
212
|
+
* `request`/`response`/`error` are the conventional kinds the default event
|
|
213
|
+
* schema declares, not a fixed set. Which kinds are legal for a given policy
|
|
214
|
+
* set is the emitted `.dwschema`'s business, and DWDC010's.
|
|
215
|
+
*/
|
|
216
|
+
export declare function predicate(action: string, kind: string, args?: Record<string, TermInput>): PredicateNode;
|
|
217
|
+
/** `formerly within <w> φ` — held at some point in the window. */
|
|
218
|
+
export declare function formerly(w: WindowArgument, body: TemporalCondition): FormerlyNode;
|
|
219
|
+
/** `previous within <w> φ` — held at the immediately preceding timepoint in the window. */
|
|
220
|
+
export declare function previous(w: WindowArgument, body: TemporalCondition): PreviousNode;
|
|
221
|
+
/** `φ since within <w> ψ` — φ has held continuously since ψ, inside the window. */
|
|
222
|
+
export declare function since(left: TemporalCondition, w: WindowArgument, right: TemporalCondition): SinceNode;
|
|
223
|
+
/** `exists (name: Type). φ`. */
|
|
224
|
+
export declare function exists(binder: TypedBinder, body: TemporalCondition): ExistsNode;
|
|
225
|
+
/** `tp(t)`. */
|
|
226
|
+
export declare function tp(binder: string): TpNode;
|
|
227
|
+
/** `φ && ψ && …`. A single operand collapses to itself. */
|
|
228
|
+
export declare function and(...operands: TemporalCondition[]): TemporalCondition;
|
|
229
|
+
/** `!φ`. */
|
|
230
|
+
export declare function not(body: TemporalCondition): NotNode;
|
|
231
|
+
/** `a <op> b`. */
|
|
232
|
+
export declare function compare(left: TermInput, operator: ComparisonOperator, right: TermInput): ComparisonNode;
|
|
233
|
+
/**
|
|
234
|
+
* A macro invocation.
|
|
235
|
+
*
|
|
236
|
+
* Nothing here checks that the macro exists: the library is `--macros`, chosen
|
|
237
|
+
* by whoever runs `dogwood validate`, and chant is not that. `./macros.ts`
|
|
238
|
+
* carries typed wrappers for the four the default library ships.
|
|
239
|
+
*/
|
|
240
|
+
export declare function call(name: string, args?: MacroArg[]): CallNode;
|
|
241
|
+
/** `1h` in macro-call argument position — the interval without the `within`. */
|
|
242
|
+
export declare function interval(w: WindowLike): IntervalArg;
|
|
243
|
+
/** Temporal source text, passed through untouched. See {@link RawCondition}. */
|
|
244
|
+
export declare function raw(text: string): RawCondition;
|
|
245
|
+
/** `?s` in condition position. See {@link SigilCondition}. */
|
|
246
|
+
export declare function sigilCondition(param: string): SigilCondition;
|
|
247
|
+
/** Render a term. */
|
|
248
|
+
export declare function renderTerm(t: TemporalTerm): string;
|
|
249
|
+
/** Render a temporal condition to the surface syntax the pest grammar accepts. */
|
|
250
|
+
export declare function renderCondition(node: TemporalCondition): string;
|
|
251
|
+
/**
|
|
252
|
+
* `temporal { … }` — the extension marker.
|
|
253
|
+
*
|
|
254
|
+
* It is a `primary` in the Cedar expression grammar as well as a clause tag,
|
|
255
|
+
* so this is also how a temporal condition is embedded mid-expression:
|
|
256
|
+
* `when { is_small(context.input.shares) && temporal { once(1h, …) } }`.
|
|
257
|
+
*/
|
|
258
|
+
export declare function temporalMarker(condition: TemporalCondition): string;
|
|
259
|
+
//# sourceMappingURL=temporal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/dogwood/temporal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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EAAE,KAAK,EAAE,SAAS,GAAG,cAAc,CAEvG;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,QAAQ,EAAO,GAAG,QAAQ,CAGlE;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,WAAW,CAEnD;AAED,gFAAgF;AAChF,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE9C;AAED,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAG5D;AAYD,qBAAqB;AACrB,wBAAgB,UAAU,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,CAalD;AAiFD,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAwC/D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAEnE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dogwood upstream pin.
|
|
3
|
+
*
|
|
4
|
+
* Not a `upstreamPin` on the plugin: that slot belongs to the cedar grammar
|
|
5
|
+
* (`@cedar-policy/cedar-wasm`, see `../spec/pin.ts`), and self-upgrade tooling
|
|
6
|
+
* bumps exactly one thing per lexicon. Dogwood's pin is a git SHA recorded by
|
|
7
|
+
* #1657, because upstream has no version to key off — zero tags, zero
|
|
8
|
+
* releases, and a workspace version of `1.0.0` that is an Amazon-internal
|
|
9
|
+
* package artifact every future sync will also report.
|
|
10
|
+
*
|
|
11
|
+
* The blob hashes are the narrow content pin the #1657 report recommends. The
|
|
12
|
+
* whole tree hash moves on every sync including docs-only ones, which makes it
|
|
13
|
+
* too noisy to gate on; these seven files are the surface chant actually
|
|
14
|
+
* depends on. The three `.pest` grammars pin the language, `default_macros.dw`
|
|
15
|
+
* pins the standard aggregate library (which is a file a sync can edit and a
|
|
16
|
+
* caller can replace with `--macros`), and the three `dogwood-cli/src` files
|
|
17
|
+
* pin the JSON report structs that are #1659's integration surface.
|
|
18
|
+
*
|
|
19
|
+
* Movement risk is structural, not incidental: content arrives as squashed
|
|
20
|
+
* "Sync from internal source" commits from a publish bot, against a repository
|
|
21
|
+
* nobody outside Amazon can see, with no changelog and no version bump.
|
|
22
|
+
*/
|
|
23
|
+
/** The pinned upstream revision and the files chant's surface is built against. */
|
|
24
|
+
export declare const DOGWOOD_UPSTREAM: {
|
|
25
|
+
readonly owner: "dogwood-policy";
|
|
26
|
+
readonly repo: "dogwood";
|
|
27
|
+
/** Default-branch SHA verified in #1657 (committed 2026-08-06). */
|
|
28
|
+
readonly revision: "5063bcc2d6d6cf5024d1b0498e6cc8ef52cbcf0c";
|
|
29
|
+
readonly license: "Apache-2.0";
|
|
30
|
+
/** Git blob hashes at {@link revision} — the narrow content pin. */
|
|
31
|
+
readonly contents: {
|
|
32
|
+
readonly "dogwood-language/src/parser/grammar.pest": "adb0801303ee1b735585fe22a5d85175ecf6772c";
|
|
33
|
+
readonly "dogwood-language/src/extension/temporal/grammar.pest": "dc31fe1634b5c37173f0a999619e9834069b7a22";
|
|
34
|
+
readonly "dogwood-language/src/event_schema/grammar.pest": "bd3b064447dc0d09cc2f8eb28a7c657e746cc8a2";
|
|
35
|
+
readonly "dogwood-language/configuration/default_macros.dw": "ecd67e5edcd566aa66b05ad51bc472afbaf22a7a";
|
|
36
|
+
readonly "dogwood-cli/src/ops.rs": "2924c7eb0e569a745ff19c2d84cbba782fc56502";
|
|
37
|
+
readonly "dogwood-cli/src/main.rs": "bfd68c9ff05883ed48e5738f658b5925542d817d";
|
|
38
|
+
readonly "dogwood-cli/src/error.rs": "43f12afbbf25ad94e25130c83227eefd86f8d516";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=upstream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../src/dogwood/upstream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,mFAAmF;AACnF,eAAO,MAAM,gBAAgB;;;IAG3B,mEAAmE;;;IAGnE,oEAAoE;;;;;;;;;;CAU5D,CAAC"}
|