@driftfence/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +81 -0
  2. package/README.md +36 -0
  3. package/dist/draft/scenario.d.ts +3 -0
  4. package/dist/draft/scenario.d.ts.map +1 -0
  5. package/dist/draft/scenario.js +207 -0
  6. package/dist/draft/scenario.js.map +1 -0
  7. package/dist/index.d.ts +22 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +38 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/io/config.d.ts +10 -0
  12. package/dist/io/config.d.ts.map +1 -0
  13. package/dist/io/config.js +165 -0
  14. package/dist/io/config.js.map +1 -0
  15. package/dist/io/contracts.d.ts +7 -0
  16. package/dist/io/contracts.d.ts.map +1 -0
  17. package/dist/io/contracts.js +562 -0
  18. package/dist/io/contracts.js.map +1 -0
  19. package/dist/io/files.d.ts +6 -0
  20. package/dist/io/files.d.ts.map +1 -0
  21. package/dist/io/files.js +49 -0
  22. package/dist/io/files.js.map +1 -0
  23. package/dist/io/suppressions.d.ts +16 -0
  24. package/dist/io/suppressions.d.ts.map +1 -0
  25. package/dist/io/suppressions.js +108 -0
  26. package/dist/io/suppressions.js.map +1 -0
  27. package/dist/io/traces.d.ts +3 -0
  28. package/dist/io/traces.d.ts.map +1 -0
  29. package/dist/io/traces.js +40 -0
  30. package/dist/io/traces.js.map +1 -0
  31. package/dist/match/expr.d.ts +3 -0
  32. package/dist/match/expr.d.ts.map +1 -0
  33. package/dist/match/expr.js +43 -0
  34. package/dist/match/expr.js.map +1 -0
  35. package/dist/match/value.d.ts +5 -0
  36. package/dist/match/value.d.ts.map +1 -0
  37. package/dist/match/value.js +127 -0
  38. package/dist/match/value.js.map +1 -0
  39. package/dist/normalize/trace.d.ts +12 -0
  40. package/dist/normalize/trace.d.ts.map +1 -0
  41. package/dist/normalize/trace.js +215 -0
  42. package/dist/normalize/trace.js.map +1 -0
  43. package/dist/query/index.d.ts +4 -0
  44. package/dist/query/index.d.ts.map +1 -0
  45. package/dist/query/index.js +96 -0
  46. package/dist/query/index.js.map +1 -0
  47. package/dist/report/check.d.ts +3 -0
  48. package/dist/report/check.d.ts.map +1 -0
  49. package/dist/report/check.js +347 -0
  50. package/dist/report/check.js.map +1 -0
  51. package/dist/report/render.d.ts +11 -0
  52. package/dist/report/render.d.ts.map +1 -0
  53. package/dist/report/render.js +99 -0
  54. package/dist/report/render.js.map +1 -0
  55. package/dist/schemas/index.d.ts +578 -0
  56. package/dist/schemas/index.d.ts.map +1 -0
  57. package/dist/schemas/index.js +492 -0
  58. package/dist/schemas/index.js.map +1 -0
  59. package/dist/tsconfig.tsbuildinfo +1 -0
  60. package/dist/types.d.ts +402 -0
  61. package/dist/types.d.ts.map +1 -0
  62. package/dist/types.js +3 -0
  63. package/dist/types.js.map +1 -0
  64. package/dist/utils/errors.d.ts +18 -0
  65. package/dist/utils/errors.d.ts.map +1 -0
  66. package/dist/utils/errors.js +34 -0
  67. package/dist/utils/errors.js.map +1 -0
  68. package/dist/utils/json.d.ts +10 -0
  69. package/dist/utils/json.d.ts.map +1 -0
  70. package/dist/utils/json.js +98 -0
  71. package/dist/utils/json.js.map +1 -0
  72. package/dist/utils/order.d.ts +8 -0
  73. package/dist/utils/order.d.ts.map +1 -0
  74. package/dist/utils/order.js +42 -0
  75. package/dist/utils/order.js.map +1 -0
  76. package/dist/utils/path.d.ts +8 -0
  77. package/dist/utils/path.d.ts.map +1 -0
  78. package/dist/utils/path.js +168 -0
  79. package/dist/utils/path.js.map +1 -0
  80. package/dist/verify/invariants.d.ts +3 -0
  81. package/dist/verify/invariants.d.ts.map +1 -0
  82. package/dist/verify/invariants.js +38 -0
  83. package/dist/verify/invariants.js.map +1 -0
  84. package/dist/verify/sequence.d.ts +3 -0
  85. package/dist/verify/sequence.d.ts.map +1 -0
  86. package/dist/verify/sequence.js +151 -0
  87. package/dist/verify/sequence.js.map +1 -0
  88. package/dist/verify/summary.d.ts +8 -0
  89. package/dist/verify/summary.d.ts.map +1 -0
  90. package/dist/verify/summary.js +132 -0
  91. package/dist/verify/summary.js.map +1 -0
  92. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,81 @@
1
+ Business Source License 1.1
2
+
3
+ Licensor: Austin Young
4
+
5
+ Licensed Work: DriftFence
6
+
7
+ Additional Use Grant: None
8
+
9
+ Change Date: 2030-03-16
10
+
11
+ Change License: GPL Version 2.0 or later
12
+
13
+ For each version of the Licensed Work released under this License, the Change
14
+ Date is the earlier of the date above or the fourth anniversary of the first
15
+ publicly available distribution of that version.
16
+
17
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
18
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative
23
+ works, redistribute, and make non-production use of the Licensed Work. The
24
+ Licensor may make an Additional Use Grant, above, permitting limited production
25
+ use.
26
+
27
+ Effective on the Change Date, or the fourth anniversary of the first publicly
28
+ available distribution of a specific version of the Licensed Work under this
29
+ License, whichever comes first, the Licensor hereby grants you rights under the
30
+ terms of the Change License, and the rights granted in the paragraph above
31
+ terminate.
32
+
33
+ If your use of the Licensed Work does not comply with the requirements
34
+ currently in effect as described in this License, you must purchase a
35
+ commercial license from the Licensor, its affiliated entities, or authorized
36
+ resellers, or you must refrain from using the Licensed Work.
37
+
38
+ All copies of the original and modified Licensed Work, and derivative works of
39
+ the Licensed Work, are subject to this License. This License applies separately
40
+ for each version of the Licensed Work and the Change Date may vary for each
41
+ version of the Licensed Work released by Licensor.
42
+
43
+ You must conspicuously display this License on each original or modified copy
44
+ of the Licensed Work. If you receive the Licensed Work in original or modified
45
+ form from a third party, the terms and conditions set forth in this License
46
+ apply to your use of that work.
47
+
48
+ Any use of the Licensed Work in violation of this License will automatically
49
+ terminate your rights under this License for the current and all other versions
50
+ of the Licensed Work.
51
+
52
+ This License does not grant you any right in any trademark or logo of Licensor
53
+ or its affiliates (provided that you may use a trademark or logo of Licensor as
54
+ expressly required by this License).
55
+
56
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
57
+ "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS
58
+ OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY,
59
+ FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
60
+
61
+ MariaDB hereby grants you permission to use this License's text to license your
62
+ works, and to refer to it using the trademark "Business Source License", as
63
+ long as you comply with the Covenants of Licensor below.
64
+
65
+ Covenants of Licensor
66
+
67
+ In consideration of the right to use this License's text and the "Business
68
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
69
+ other recipients of the licensed work to be provided by Licensor:
70
+
71
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
72
+ or a license that is compatible with GPL Version 2.0 or a later version,
73
+ where "compatible" means that software provided under the Change License can
74
+ be included in a program with software provided under GPL Version 2.0 or a
75
+ later version. Licensor may specify additional Change Licenses without
76
+ limitation.
77
+ 2. To either: (a) specify an additional grant of rights to use that does not
78
+ impose any additional restriction on the right granted in this License, as
79
+ the Additional Use Grant; or (b) insert the text "None".
80
+ 3. To specify a Change Date.
81
+ 4. Not to modify this License in any other way.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @driftfence/core
2
+
3
+ Core schemas, loaders, normalization, matching, checking, querying, and report rendering for DriftFence.
4
+
5
+ Install:
6
+
7
+ ```bash
8
+ npm install @driftfence/core
9
+ ```
10
+
11
+ Minimum Node version:
12
+
13
+ - `>=20.19.0`
14
+
15
+ Usage:
16
+
17
+ ```js
18
+ const { getSchemaJson } = require("@driftfence/core");
19
+
20
+ console.log(getSchemaJson("config").properties.schemaVersion.const);
21
+ ```
22
+
23
+ See the root docs and adoption guide:
24
+
25
+ - [DriftFence README](https://github.com/austindyoung/DriftFenceV2#readme)
26
+
27
+ Licensing:
28
+
29
+ - published for public installation and evaluation under `BUSL-1.1`
30
+ - production use before the change date requires a commercial license
31
+ - see [LICENSE](https://github.com/austindyoung/DriftFenceV2/blob/main/LICENSE), [Terms](https://www.driftfence.dev/terms.html), and [Pricing](https://www.driftfence.dev/pricing.html)
32
+
33
+ Repository and issues:
34
+
35
+ - [Repository](https://github.com/austindyoung/DriftFenceV2)
36
+ - [Issues](https://github.com/austindyoung/DriftFenceV2/issues)
@@ -0,0 +1,3 @@
1
+ import type { ContractScenario, TraceFile } from "../types";
2
+ export declare function draftScenarioFromTrace(trace: TraceFile, precision: "summary" | "sequence"): ContractScenario;
3
+ //# sourceMappingURL=scenario.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../../src/draft/scenario.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,SAAS,EAEV,MAAM,UAAU,CAAC;AAkLlB,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,SAAS,GAAG,UAAU,GAChC,gBAAgB,CAqJlB"}
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.draftScenarioFromTrace = draftScenarioFromTrace;
4
+ const json_1 = require("../utils/json");
5
+ function collectNodePaths(value, basePath = "") {
6
+ const paths = basePath ? [{ path: basePath, value }] : [{ path: "", value }];
7
+ if (value === null || typeof value !== "object") {
8
+ return paths;
9
+ }
10
+ if (Array.isArray(value)) {
11
+ return [
12
+ ...paths,
13
+ ...value.flatMap((item, index) => collectNodePaths(item, `${basePath}[${index}]`))
14
+ ];
15
+ }
16
+ return [
17
+ ...paths,
18
+ ...Object.entries(value).flatMap(([key, child]) => collectNodePaths(child, basePath ? `${basePath}.${key}` : key))
19
+ ];
20
+ }
21
+ function bindingName(stepId, sourceRoot, sourcePath) {
22
+ const normalizedPath = sourcePath
23
+ .replace(/[.[\]]+/g, "_")
24
+ .replace(/^_+|_+$/g, "");
25
+ return normalizedPath.length > 0
26
+ ? `${stepId}_${sourceRoot}_${normalizedPath}`
27
+ : `${stepId}_${sourceRoot}`;
28
+ }
29
+ function buildReference(value, input, stateBefore, previousStepCandidates) {
30
+ const inputMatches = collectNodePaths(input)
31
+ .filter((candidate) => (0, json_1.deepEqual)(candidate.value, value))
32
+ .map((candidate) => candidate.path)
33
+ .filter((candidate) => candidate.length > 0 || (0, json_1.deepEqual)(input, value));
34
+ if (inputMatches.length === 1) {
35
+ return {
36
+ matcher: {
37
+ $from: inputMatches[0] === "" ? "input" : `input.${inputMatches[0]}`
38
+ }
39
+ };
40
+ }
41
+ const stateBeforeMatches = collectNodePaths(stateBefore)
42
+ .filter((candidate) => (0, json_1.deepEqual)(candidate.value, value))
43
+ .map((candidate) => candidate.path)
44
+ .filter((candidate) => candidate.length > 0 || (0, json_1.deepEqual)(stateBefore, value));
45
+ if (stateBeforeMatches.length === 1) {
46
+ return {
47
+ matcher: {
48
+ $from: stateBeforeMatches[0] === ""
49
+ ? "stateBefore"
50
+ : `stateBefore.${stateBeforeMatches[0]}`
51
+ }
52
+ };
53
+ }
54
+ const variableMatches = previousStepCandidates.filter((candidate) => (0, json_1.deepEqual)(candidate.value, value));
55
+ if (variableMatches.length === 1) {
56
+ return { bindTarget: variableMatches[0] };
57
+ }
58
+ return {};
59
+ }
60
+ function generalizeValue(value, input, stateBefore, previousStepCandidates) {
61
+ const reference = buildReference(value, input, stateBefore, previousStepCandidates);
62
+ if (reference.matcher !== undefined) {
63
+ return reference.matcher;
64
+ }
65
+ if (reference.bindTarget) {
66
+ const bindTarget = reference.bindTarget;
67
+ bindTarget.step.bind ??= {};
68
+ const name = bindingName(bindTarget.step.stepId, bindTarget.sourceRoot, bindTarget.sourcePath);
69
+ bindTarget.step.bind[name] =
70
+ bindTarget.sourcePath.length > 0
71
+ ? `${bindTarget.sourceRoot}.${bindTarget.sourcePath}`
72
+ : bindTarget.sourceRoot;
73
+ return { $from: `vars.${name}` };
74
+ }
75
+ if (value === null || typeof value !== "object") {
76
+ return value;
77
+ }
78
+ if (Array.isArray(value)) {
79
+ return value.map((item) => generalizeValue(item, input, stateBefore, previousStepCandidates));
80
+ }
81
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [
82
+ key,
83
+ generalizeValue(child, input, stateBefore, previousStepCandidates)
84
+ ]));
85
+ }
86
+ function collectStepCandidates(step, call) {
87
+ if (step.kind === "effect" && call.kind === "effect") {
88
+ return [
89
+ ...collectNodePaths(call.args).map((candidate) => ({
90
+ step,
91
+ sourceRoot: "args",
92
+ sourcePath: candidate.path,
93
+ value: candidate.value
94
+ })),
95
+ ...collectNodePaths(call.result).map((candidate) => ({
96
+ step,
97
+ sourceRoot: "result",
98
+ sourcePath: candidate.path,
99
+ value: candidate.value
100
+ }))
101
+ ];
102
+ }
103
+ if (step.kind === "emit" && call.kind === "emit") {
104
+ return collectNodePaths(call.payload).map((candidate) => ({
105
+ step,
106
+ sourceRoot: "payload",
107
+ sourcePath: candidate.path,
108
+ value: candidate.value
109
+ }));
110
+ }
111
+ return [];
112
+ }
113
+ function draftScenarioFromTrace(trace, precision) {
114
+ const summaryEffects = Array.from(new Set(trace.calls
115
+ .filter((call) => call.kind === "effect")
116
+ .map((call) => call.name))).sort((left, right) => left.localeCompare(right));
117
+ const summaryEmits = Array.from(new Set(trace.calls
118
+ .filter((call) => call.kind === "emit")
119
+ .map((call) => call.event))).sort((left, right) => left.localeCompare(right));
120
+ const previousStepCandidates = [];
121
+ const steps = [];
122
+ if (precision === "sequence") {
123
+ trace.calls.forEach((call, index) => {
124
+ const stepId = `s${index + 1}`;
125
+ const step = call.kind === "effect"
126
+ ? {
127
+ stepId,
128
+ kind: "effect",
129
+ name: call.name,
130
+ ...(call.args !== undefined
131
+ ? {
132
+ args: generalizeValue(call.args, trace.input, trace.stateBefore, previousStepCandidates)
133
+ }
134
+ : {}),
135
+ ...(call.result !== undefined
136
+ ? {
137
+ result: generalizeValue(call.result, trace.input, trace.stateBefore, previousStepCandidates)
138
+ }
139
+ : {})
140
+ }
141
+ : {
142
+ stepId,
143
+ kind: "emit",
144
+ event: call.event,
145
+ ...(call.payload !== undefined
146
+ ? {
147
+ payload: generalizeValue(call.payload, trace.input, trace.stateBefore, previousStepCandidates)
148
+ }
149
+ : {})
150
+ };
151
+ steps.push(step);
152
+ previousStepCandidates.push(...collectStepCandidates(step, call));
153
+ });
154
+ }
155
+ const sequenceLevel = steps.some((step) => step.bind && Object.keys(step.bind).length > 0)
156
+ ? 1
157
+ : 0;
158
+ return {
159
+ id: trace.scenarioId,
160
+ lifecycle: {
161
+ state: "inferred"
162
+ },
163
+ precision,
164
+ expect: {
165
+ summary: {
166
+ ...(summaryEffects.length > 0 ? { effects: summaryEffects } : {}),
167
+ ...(summaryEmits.length > 0 ? { emits: summaryEmits } : {})
168
+ },
169
+ ...(precision === "sequence"
170
+ ? {
171
+ sequence: {
172
+ level: sequenceLevel,
173
+ steps
174
+ }
175
+ }
176
+ : {}),
177
+ ...(trace.output !== undefined
178
+ ? {
179
+ output: generalizeValue(trace.output, trace.input, trace.stateBefore, previousStepCandidates)
180
+ }
181
+ : {}),
182
+ ...(trace.error === null || trace.error === undefined
183
+ ? { error: { none: true } }
184
+ : {
185
+ error: {
186
+ code: generalizeValue(trace.error.code, trace.input, trace.stateBefore, previousStepCandidates),
187
+ ...(trace.error.message !== undefined
188
+ ? {
189
+ message: generalizeValue(trace.error.message, trace.input, trace.stateBefore, previousStepCandidates)
190
+ }
191
+ : {}),
192
+ ...(trace.error.data !== undefined
193
+ ? {
194
+ data: generalizeValue(trace.error.data, trace.input, trace.stateBefore, previousStepCandidates)
195
+ }
196
+ : {})
197
+ }
198
+ }),
199
+ ...(trace.stateAfter !== undefined
200
+ ? {
201
+ stateAfter: generalizeValue(trace.stateAfter, trace.input, trace.stateBefore, previousStepCandidates)
202
+ }
203
+ : {})
204
+ }
205
+ };
206
+ }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IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;gBACnD,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;gBAC3B,CAAC,CAAC;oBACE,KAAK,EAAE;wBACL,IAAI,EAAE,eAAe,CACnB,KAAK,CAAC,KAAK,CAAC,IAAI,EAChB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,sBAAsB,CACvB;wBACD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS;4BACnC,CAAC,CAAC;gCACE,OAAO,EAAE,eAAe,CACtB,KAAK,CAAC,KAAK,CAAC,OAAO,EACnB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,sBAAsB,CACvB;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC;wBACP,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;4BAChC,CAAC,CAAC;gCACE,IAAI,EAAE,eAAe,CACnB,KAAK,CAAC,KAAK,CAAC,IAAI,EAChB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,sBAAsB,CACvB;6BACF;4BACH,CAAC,CAAC,EAAE,CAAC;qBACR;iBACF,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;gBAChC,CAAC,CAAC;oBACE,UAAU,EAAE,eAAe,CACzB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,sBAAsB,CACvB;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACkB,CAAC;AACxB,CAAC"}
@@ -0,0 +1,22 @@
1
+ export * from "./draft/scenario";
2
+ export * from "./io/config";
3
+ export * from "./io/contracts";
4
+ export * from "./io/files";
5
+ export * from "./io/suppressions";
6
+ export * from "./io/traces";
7
+ export * from "./match/expr";
8
+ export * from "./match/value";
9
+ export * from "./normalize/trace";
10
+ export * from "./query";
11
+ export * from "./report/check";
12
+ export * from "./report/render";
13
+ export * from "./schemas";
14
+ export * from "./types";
15
+ export * from "./utils/errors";
16
+ export * from "./utils/json";
17
+ export * from "./utils/order";
18
+ export * from "./utils/path";
19
+ export * from "./verify/invariants";
20
+ export * from "./verify/sequence";
21
+ export * from "./verify/summary";
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./draft/scenario"), exports);
18
+ __exportStar(require("./io/config"), exports);
19
+ __exportStar(require("./io/contracts"), exports);
20
+ __exportStar(require("./io/files"), exports);
21
+ __exportStar(require("./io/suppressions"), exports);
22
+ __exportStar(require("./io/traces"), exports);
23
+ __exportStar(require("./match/expr"), exports);
24
+ __exportStar(require("./match/value"), exports);
25
+ __exportStar(require("./normalize/trace"), exports);
26
+ __exportStar(require("./query"), exports);
27
+ __exportStar(require("./report/check"), exports);
28
+ __exportStar(require("./report/render"), exports);
29
+ __exportStar(require("./schemas"), exports);
30
+ __exportStar(require("./types"), exports);
31
+ __exportStar(require("./utils/errors"), exports);
32
+ __exportStar(require("./utils/json"), exports);
33
+ __exportStar(require("./utils/order"), exports);
34
+ __exportStar(require("./utils/path"), exports);
35
+ __exportStar(require("./verify/invariants"), exports);
36
+ __exportStar(require("./verify/sequence"), exports);
37
+ __exportStar(require("./verify/summary"), exports);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,8CAA4B;AAC5B,iDAA+B;AAC/B,6CAA2B;AAC3B,oDAAkC;AAClC,8CAA4B;AAC5B,+CAA6B;AAC7B,gDAA8B;AAC9B,oDAAkC;AAClC,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC;AAChC,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B;AAC/B,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B;AAC7B,sDAAoC;AACpC,oDAAkC;AAClC,mDAAiC"}
@@ -0,0 +1,10 @@
1
+ import type { DriftFenceConfig, ResolvedDriftFenceConfig } from "../types";
2
+ export declare const DEFAULT_CONFIG: ResolvedDriftFenceConfig;
3
+ export declare function resolveConfig(raw: DriftFenceConfig, options?: {
4
+ rootDir?: string;
5
+ configPath?: string;
6
+ }): ResolvedDriftFenceConfig;
7
+ export declare function loadConfig(configPath?: string): Promise<ResolvedDriftFenceConfig>;
8
+ export declare function createDefaultConfig(owners?: string[]): DriftFenceConfig;
9
+ export declare function renderConfigYaml(config: DriftFenceConfig): string;
10
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/io/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAK3E,eAAO,MAAM,cAAc,EAAE,wBAuC5B,CAAC;AAiCF,wBAAgB,aAAa,CAC3B,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD,wBAAwB,CAmG1B;AAED,wBAAsB,UAAU,CAC9B,UAAU,SAAsD,GAC/D,OAAO,CAAC,wBAAwB,CAAC,CAanC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAiBvE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAKjE"}
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_CONFIG = void 0;
7
+ exports.resolveConfig = resolveConfig;
8
+ exports.loadConfig = loadConfig;
9
+ exports.createDefaultConfig = createDefaultConfig;
10
+ exports.renderConfigYaml = renderConfigYaml;
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const yaml_1 = require("yaml");
13
+ const schemas_1 = require("../schemas");
14
+ const errors_1 = require("../utils/errors");
15
+ const json_1 = require("../utils/json");
16
+ const files_1 = require("./files");
17
+ exports.DEFAULT_CONFIG = {
18
+ schemaVersion: "driftfence-config/v2",
19
+ rootDir: "",
20
+ configPath: "",
21
+ mode: "observe",
22
+ defaults: {
23
+ owners: ["@team-owning-the-workflow"]
24
+ },
25
+ paths: {
26
+ contracts: ".driftfence/contracts",
27
+ proposals: ".driftfence/proposals",
28
+ traces: ".driftfence/traces",
29
+ reports: ".driftfence/reports",
30
+ suppressions: ".driftfence/suppressions.yaml"
31
+ },
32
+ normalization: {
33
+ redactPaths: [],
34
+ ignorePaths: [],
35
+ zeroPaths: [],
36
+ sortArrayPaths: []
37
+ },
38
+ aliases: {
39
+ effects: {},
40
+ emits: {}
41
+ },
42
+ check: {
43
+ failOn: {
44
+ violating: true,
45
+ wideningRequest: true,
46
+ missingTrace: true,
47
+ narrowing: false,
48
+ orphanTrace: false
49
+ },
50
+ maxInlineScenarios: 10
51
+ },
52
+ github: {
53
+ postComment: true,
54
+ commentMarker: "<!-- driftfence -->"
55
+ }
56
+ };
57
+ function validateAliasMap(map, kind) {
58
+ const resolved = {};
59
+ const resolveAlias = (name, seen) => {
60
+ const next = map[name];
61
+ if (next === undefined) {
62
+ return name;
63
+ }
64
+ if (seen.includes(name)) {
65
+ throw new errors_1.DriftFenceError(`Alias cycle detected in ${kind}: ${[...seen, name].join(" -> ")}`, errors_1.EXIT_CODES.CONFIG_ERROR);
66
+ }
67
+ return resolveAlias(next, [...seen, name]);
68
+ };
69
+ for (const key of Object.keys(map).sort((left, right) => left.localeCompare(right))) {
70
+ resolved[key] = resolveAlias(key, []);
71
+ }
72
+ return resolved;
73
+ }
74
+ function resolveConfig(raw, options) {
75
+ const rootDir = options?.rootDir ?? process.cwd();
76
+ const configPath = options?.configPath ?? node_path_1.default.join(rootDir, ".driftfence/config.yaml");
77
+ const parsed = schemas_1.configSchema.safeParse(raw);
78
+ if (!parsed.success) {
79
+ throw new errors_1.DriftFenceError(`Invalid DriftFence config: ${parsed.error.message}`, errors_1.EXIT_CODES.CONFIG_ERROR);
80
+ }
81
+ return {
82
+ schemaVersion: "driftfence-config/v2",
83
+ rootDir,
84
+ configPath,
85
+ mode: parsed.data.mode ?? exports.DEFAULT_CONFIG.mode,
86
+ defaults: {
87
+ owners: (0, json_1.sortUniqueStrings)(parsed.data.defaults?.owners ?? exports.DEFAULT_CONFIG.defaults.owners) ?? []
88
+ },
89
+ paths: {
90
+ contracts: node_path_1.default.resolve(rootDir, parsed.data.paths?.contracts ?? exports.DEFAULT_CONFIG.paths.contracts),
91
+ proposals: node_path_1.default.resolve(rootDir, parsed.data.paths?.proposals ?? exports.DEFAULT_CONFIG.paths.proposals),
92
+ traces: node_path_1.default.resolve(rootDir, parsed.data.paths?.traces ?? exports.DEFAULT_CONFIG.paths.traces),
93
+ reports: node_path_1.default.resolve(rootDir, parsed.data.paths?.reports ?? exports.DEFAULT_CONFIG.paths.reports),
94
+ suppressions: node_path_1.default.resolve(rootDir, parsed.data.paths?.suppressions ?? exports.DEFAULT_CONFIG.paths.suppressions)
95
+ },
96
+ normalization: {
97
+ redactPaths: parsed.data.normalization?.redactPaths ??
98
+ exports.DEFAULT_CONFIG.normalization.redactPaths,
99
+ ignorePaths: parsed.data.normalization?.ignorePaths ??
100
+ exports.DEFAULT_CONFIG.normalization.ignorePaths,
101
+ zeroPaths: parsed.data.normalization?.zeroPaths ??
102
+ exports.DEFAULT_CONFIG.normalization.zeroPaths,
103
+ sortArrayPaths: parsed.data.normalization?.sortArrayPaths ??
104
+ exports.DEFAULT_CONFIG.normalization.sortArrayPaths
105
+ },
106
+ aliases: {
107
+ effects: validateAliasMap(parsed.data.aliases?.effects ?? exports.DEFAULT_CONFIG.aliases.effects, "effects"),
108
+ emits: validateAliasMap(parsed.data.aliases?.emits ?? exports.DEFAULT_CONFIG.aliases.emits, "emits")
109
+ },
110
+ check: {
111
+ failOn: {
112
+ violating: parsed.data.check?.failOn?.violating ??
113
+ exports.DEFAULT_CONFIG.check.failOn.violating,
114
+ wideningRequest: parsed.data.check?.failOn?.wideningRequest ??
115
+ exports.DEFAULT_CONFIG.check.failOn.wideningRequest,
116
+ missingTrace: parsed.data.check?.failOn?.missingTrace ??
117
+ exports.DEFAULT_CONFIG.check.failOn.missingTrace,
118
+ narrowing: parsed.data.check?.failOn?.narrowing ??
119
+ exports.DEFAULT_CONFIG.check.failOn.narrowing,
120
+ orphanTrace: parsed.data.check?.failOn?.orphanTrace ??
121
+ exports.DEFAULT_CONFIG.check.failOn.orphanTrace
122
+ },
123
+ maxInlineScenarios: parsed.data.check?.maxInlineScenarios ??
124
+ exports.DEFAULT_CONFIG.check.maxInlineScenarios
125
+ },
126
+ github: {
127
+ postComment: parsed.data.github?.postComment ?? exports.DEFAULT_CONFIG.github.postComment,
128
+ commentMarker: parsed.data.github?.commentMarker ?? exports.DEFAULT_CONFIG.github.commentMarker
129
+ }
130
+ };
131
+ }
132
+ async function loadConfig(configPath = node_path_1.default.join(process.cwd(), ".driftfence/config.yaml")) {
133
+ if (!(await (0, files_1.pathExists)(configPath))) {
134
+ throw new errors_1.DriftFenceError(`DriftFence config not found: ${configPath}`, errors_1.EXIT_CODES.CONFIG_ERROR);
135
+ }
136
+ const raw = (0, yaml_1.parse)(await (0, files_1.readUtf8File)(configPath));
137
+ return resolveConfig(raw, {
138
+ rootDir: process.cwd(),
139
+ configPath: node_path_1.default.resolve(configPath)
140
+ });
141
+ }
142
+ function createDefaultConfig(owners) {
143
+ return {
144
+ schemaVersion: "driftfence-config/v2",
145
+ mode: "observe",
146
+ defaults: {
147
+ owners: owners && owners.length > 0 ? owners : exports.DEFAULT_CONFIG.defaults.owners
148
+ },
149
+ paths: { ...exports.DEFAULT_CONFIG.paths },
150
+ normalization: { ...exports.DEFAULT_CONFIG.normalization },
151
+ aliases: { effects: {}, emits: {} },
152
+ check: {
153
+ failOn: { ...exports.DEFAULT_CONFIG.check.failOn },
154
+ maxInlineScenarios: exports.DEFAULT_CONFIG.check.maxInlineScenarios
155
+ },
156
+ github: { ...exports.DEFAULT_CONFIG.github }
157
+ };
158
+ }
159
+ function renderConfigYaml(config) {
160
+ return (0, yaml_1.stringify)(config, {
161
+ aliasDuplicateObjects: false,
162
+ lineWidth: 0
163
+ });
164
+ }
165
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/io/config.ts"],"names":[],"mappings":";;;;;;AAiFA,sCAsGC;AAED,gCAeC;AAED,kDAiBC;AAED,4CAKC;AAlOD,0DAA6B;AAC7B,+BAAsE;AAEtE,wCAA0C;AAE1C,4CAA8D;AAC9D,wCAAkD;AAClD,mCAAmD;AAEtC,QAAA,cAAc,GAA6B;IACtD,aAAa,EAAE,sBAAsB;IACrC,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC,2BAA2B,CAAC;KACtC;IACD,KAAK,EAAE;QACL,SAAS,EAAE,uBAAuB;QAClC,SAAS,EAAE,uBAAuB;QAClC,MAAM,EAAE,oBAAoB;QAC5B,OAAO,EAAE,qBAAqB;QAC9B,YAAY,EAAE,+BAA+B;KAC9C;IACD,aAAa,EAAE;QACb,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,EAAE;KACnB;IACD,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;KACV;IACD,KAAK,EAAE;QACL,MAAM,EAAE;YACN,SAAS,EAAE,IAAI;YACf,eAAe,EAAE,IAAI;YACrB,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,KAAK;YAChB,WAAW,EAAE,KAAK;SACnB;QACD,kBAAkB,EAAE,EAAE;KACvB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,IAAI;QACjB,a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AQ,CAAC,MAAM;SACxE;QACD,KAAK,EAAE,EAAE,GAAG,sBAAc,CAAC,KAAK,EAAE;QAClC,aAAa,EAAE,EAAE,GAAG,sBAAc,CAAC,aAAa,EAAE;QAClD,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QACnC,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,GAAG,sBAAc,CAAC,KAAK,CAAC,MAAM,EAAE;YAC1C,kBAAkB,EAAE,sBAAc,CAAC,KAAK,CAAC,kBAAkB;SAC5D;QACD,MAAM,EAAE,EAAE,GAAG,sBAAc,CAAC,MAAM,EAAE;KACrC,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAAwB;IACvD,OAAO,IAAA,gBAAa,EAAC,MAAM,EAAE;QAC3B,qBAAqB,EAAE,KAAK;QAC5B,SAAS,EAAE,CAAC;KACb,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { LoadedContractFile, WorkflowContractFile } from "../types";
2
+ export declare function canonicalizeContractFile(contract: WorkflowContractFile): WorkflowContractFile;
3
+ export declare function loadContracts(baseDir: string, containerKind: "approved" | "proposal"): Promise<LoadedContractFile[]>;
4
+ export declare function renderContractYaml(contract: WorkflowContractFile): string;
5
+ export declare function writeContractFile(baseDir: string, contract: WorkflowContractFile): Promise<string>;
6
+ export declare function contractFilePath(baseDir: string, contractId: string): string;
7
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/io/contracts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,kBAAkB,EAKlB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AA0rBlB,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,oBAAoB,GAC7B,oBAAoB,CA+CtB;AAiED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,UAAU,GAAG,UAAU,GACrC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA2B/B;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAKzE;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5E"}