@fabricorg/databricks-bdd 0.3.1 → 0.4.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.
- package/README.md +56 -5
- package/dist/actions-CuXXKUqe.d.ts +92 -0
- package/dist/actions-CxfxhBZh.d.cts +92 -0
- package/dist/actions.cjs +14 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +6 -0
- package/dist/actions.d.ts +6 -0
- package/dist/actions.js +3 -0
- package/dist/actions.js.map +1 -0
- package/dist/cardinality.cjs +24 -0
- package/dist/cardinality.cjs.map +1 -0
- package/dist/cardinality.d.cts +19 -0
- package/dist/cardinality.d.ts +19 -0
- package/dist/cardinality.js +3 -0
- package/dist/cardinality.js.map +1 -0
- package/dist/{chunk-FNTI2VUP.js → chunk-3XDMBHFP.js} +117 -4
- package/dist/chunk-3XDMBHFP.js.map +1 -0
- package/dist/chunk-6JC65RH2.js +11 -0
- package/dist/chunk-6JC65RH2.js.map +1 -0
- package/dist/chunk-HTKRJLVX.js +70 -0
- package/dist/chunk-HTKRJLVX.js.map +1 -0
- package/dist/chunk-K5LJ7WSW.js +22 -0
- package/dist/chunk-K5LJ7WSW.js.map +1 -0
- package/dist/chunk-SZL3KWW7.js +62 -0
- package/dist/chunk-SZL3KWW7.js.map +1 -0
- package/dist/fixtures.cjs +65 -0
- package/dist/fixtures.cjs.map +1 -0
- package/dist/fixtures.d.cts +34 -0
- package/dist/fixtures.d.ts +34 -0
- package/dist/fixtures.js +3 -0
- package/dist/fixtures.js.map +1 -0
- package/dist/index.cjs +277 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -55
- package/dist/index.d.ts +24 -55
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/scoped-state.cjs +74 -0
- package/dist/scoped-state.cjs.map +1 -0
- package/dist/scoped-state.d.cts +30 -0
- package/dist/scoped-state.d.ts +30 -0
- package/dist/scoped-state.js +3 -0
- package/dist/scoped-state.js.map +1 -0
- package/dist/steps.cjs +254 -2
- package/dist/steps.cjs.map +1 -1
- package/dist/steps.js +15 -4
- package/dist/steps.js.map +1 -1
- package/package.json +41 -1
- package/dist/chunk-FNTI2VUP.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions.ts"],"names":[],"mappings":";AAeO,SAAS,aACd,MAAA,EAC8B;AAC9B,EAAA,OAAO,MAAA;AACT;AAGA,eAAsB,SAAA,CACpB,KAAA,EACA,MAAA,EAAA,GACG,IAAA,EACuB;AAC1B,EAAA,OAAQ,MAAM,MAAA,CAAO,KAAA,EAAO,GAAG,IAAI,CAAA;AACrC","file":"chunk-6JC65RH2.js","sourcesContent":["import type { DatabricksWorld } from './world.js';\n\n/**\n * A reusable, typed scenario action.\n *\n * Behave suites sometimes compose behavior with `context.execute_steps()`. In\n * TypeScript, composing ordinary functions preserves type checking, stack\n * traces, and direct unit-testability without reparsing Gherkin at runtime.\n */\nexport type ScenarioAction<Args extends readonly unknown[] = readonly unknown[], Result = void> = (\n world: DatabricksWorld,\n ...args: Args\n) => Result | Promise<Result>;\n\n/** Preserve inference while declaring a reusable scenario action. */\nexport function defineAction<Args extends readonly unknown[], Result>(\n action: ScenarioAction<Args, Result>,\n): ScenarioAction<Args, Result> {\n return action;\n}\n\n/** Execute a typed action against the current scenario World. */\nexport async function runAction<Args extends readonly unknown[], Result>(\n world: DatabricksWorld,\n action: ScenarioAction<Args, Result>,\n ...args: Args\n): Promise<Awaited<Result>> {\n return (await action(world, ...args)) as Awaited<Result>;\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/scoped-state.ts
|
|
2
|
+
var SharedStateRegistry = class {
|
|
3
|
+
runValues = /* @__PURE__ */ new Map();
|
|
4
|
+
featureValues = /* @__PURE__ */ new Map();
|
|
5
|
+
run() {
|
|
6
|
+
return this.runValues;
|
|
7
|
+
}
|
|
8
|
+
feature(featureUri) {
|
|
9
|
+
if (!featureUri) throw new Error("Feature state requires a feature URI");
|
|
10
|
+
let values = this.featureValues.get(featureUri);
|
|
11
|
+
if (!values) {
|
|
12
|
+
values = /* @__PURE__ */ new Map();
|
|
13
|
+
this.featureValues.set(featureUri, values);
|
|
14
|
+
}
|
|
15
|
+
return values;
|
|
16
|
+
}
|
|
17
|
+
clear() {
|
|
18
|
+
this.runValues.clear();
|
|
19
|
+
this.featureValues.clear();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var ScopedState = class {
|
|
23
|
+
constructor(runValues, featureValues) {
|
|
24
|
+
this.runValues = runValues;
|
|
25
|
+
this.featureValues = featureValues;
|
|
26
|
+
}
|
|
27
|
+
runValues;
|
|
28
|
+
featureValues;
|
|
29
|
+
scenarioValues = /* @__PURE__ */ new Map();
|
|
30
|
+
set(scope, key, value) {
|
|
31
|
+
this.values(scope).set(validateKey(key), value);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
get(key) {
|
|
35
|
+
const validKey = validateKey(key);
|
|
36
|
+
if (this.scenarioValues.has(validKey)) return this.scenarioValues.get(validKey);
|
|
37
|
+
if (this.featureValues.has(validKey)) return this.featureValues.get(validKey);
|
|
38
|
+
return this.runValues.get(validKey);
|
|
39
|
+
}
|
|
40
|
+
require(key) {
|
|
41
|
+
const value = this.get(key);
|
|
42
|
+
if (value === void 0) throw new Error(`Required BDD state '${key}' is not set`);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
has(key) {
|
|
46
|
+
const validKey = validateKey(key);
|
|
47
|
+
return this.scenarioValues.has(validKey) || this.featureValues.has(validKey) || this.runValues.has(validKey);
|
|
48
|
+
}
|
|
49
|
+
delete(scope, key) {
|
|
50
|
+
return this.values(scope).delete(validateKey(key));
|
|
51
|
+
}
|
|
52
|
+
clearScenario() {
|
|
53
|
+
this.scenarioValues.clear();
|
|
54
|
+
}
|
|
55
|
+
values(scope) {
|
|
56
|
+
if (scope === "run") return this.runValues;
|
|
57
|
+
if (scope === "feature") return this.featureValues;
|
|
58
|
+
return this.scenarioValues;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function validateKey(key) {
|
|
62
|
+
const trimmed = key.trim();
|
|
63
|
+
if (!trimmed) throw new Error("BDD state key must not be empty");
|
|
64
|
+
return trimmed;
|
|
65
|
+
}
|
|
66
|
+
var sharedState = new SharedStateRegistry();
|
|
67
|
+
|
|
68
|
+
export { ScopedState, SharedStateRegistry, sharedState };
|
|
69
|
+
//# sourceMappingURL=chunk-HTKRJLVX.js.map
|
|
70
|
+
//# sourceMappingURL=chunk-HTKRJLVX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scoped-state.ts"],"names":[],"mappings":";AAQO,IAAM,sBAAN,MAA0B;AAAA,EACd,SAAA,uBAA6B,GAAA,EAAI;AAAA,EACjC,aAAA,uBAAoB,GAAA,EAAyB;AAAA,EAE9D,GAAA,GAAmB;AACjB,IAAA,OAAO,IAAA,CAAK,SAAA;AAAA,EACd;AAAA,EAEA,QAAQ,UAAA,EAAiC;AACvC,IAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,MAAM,sCAAsC,CAAA;AACvE,IAAA,IAAI,MAAA,GAAS,IAAA,CAAK,aAAA,CAAc,GAAA,CAAI,UAAU,CAAA;AAC9C,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAA,uBAAa,GAAA,EAAI;AACjB,MAAA,IAAA,CAAK,aAAA,CAAc,GAAA,CAAI,UAAA,EAAY,MAAM,CAAA;AAAA,IAC3C;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,UAAU,KAAA,EAAM;AACrB,IAAA,IAAA,CAAK,cAAc,KAAA,EAAM;AAAA,EAC3B;AACF;AAGO,IAAM,cAAN,MAAkB;AAAA,EAGvB,WAAA,CACmB,WACA,aAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,SAAA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B;AAAA,EAEA,MAAA,CAAO,OAAmB,GAAA,EAAsB;AAC9C,IAAA,OAAO,KAAK,MAAA,CAAO,KAAK,EAAE,MAAA,CAAO,WAAA,CAAY,GAAG,CAAC,CAAA;AAAA,EACnD;AAAA,EAEA,aAAA,GAAsB;AACpB,IAAA,IAAA,CAAK,eAAe,KAAA,EAAM;AAAA,EAC5B;AAAA,EAEQ,OAAO,KAAA,EAAgC;AAC7C,IAAA,IAAI,KAAA,KAAU,KAAA,EAAO,OAAO,IAAA,CAAK,SAAA;AACjC,IAAA,IAAI,KAAA,KAAU,SAAA,EAAW,OAAO,IAAA,CAAK,aAAA;AACrC,IAAA,OAAO,IAAA,CAAK,cAAA;AAAA,EACd;AACF;AAEA,SAAS,YAAY,GAAA,EAAqB;AACxC,EAAA,MAAM,OAAA,GAAU,IAAI,IAAA,EAAK;AACzB,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,iCAAiC,CAAA;AAC/D,EAAA,OAAO,OAAA;AACT;AAEO,IAAM,WAAA,GAAc,IAAI,mBAAA","file":"chunk-HTKRJLVX.js","sourcesContent":["export type StateScope = 'run' | 'feature' | 'scenario';\n\ntype StateValues = Map<string, unknown>;\n\n/**\n * Process-local state backing Behave-style run and feature context layers.\n * Scenario values stay on the scenario World and are never shared.\n */\nexport class SharedStateRegistry {\n private readonly runValues: StateValues = new Map();\n private readonly featureValues = new Map<string, StateValues>();\n\n run(): StateValues {\n return this.runValues;\n }\n\n feature(featureUri: string): StateValues {\n if (!featureUri) throw new Error('Feature state requires a feature URI');\n let values = this.featureValues.get(featureUri);\n if (!values) {\n values = new Map();\n this.featureValues.set(featureUri, values);\n }\n return values;\n }\n\n clear(): void {\n this.runValues.clear();\n this.featureValues.clear();\n }\n}\n\n/** Layered state lookup: scenario overrides feature, which overrides run. */\nexport class ScopedState {\n private readonly scenarioValues: StateValues = new Map();\n\n constructor(\n private readonly runValues: StateValues,\n private readonly featureValues: StateValues,\n ) {}\n\n set<T>(scope: StateScope, key: string, value: T): T {\n this.values(scope).set(validateKey(key), value);\n return value;\n }\n\n get<T>(key: string): T | undefined {\n const validKey = validateKey(key);\n if (this.scenarioValues.has(validKey)) return this.scenarioValues.get(validKey) as T;\n if (this.featureValues.has(validKey)) return this.featureValues.get(validKey) as T;\n return this.runValues.get(validKey) as T | undefined;\n }\n\n require<T>(key: string): T {\n const value = this.get<T>(key);\n if (value === undefined) throw new Error(`Required BDD state '${key}' is not set`);\n return value;\n }\n\n has(key: string): boolean {\n const validKey = validateKey(key);\n return (\n this.scenarioValues.has(validKey) ||\n this.featureValues.has(validKey) ||\n this.runValues.has(validKey)\n );\n }\n\n delete(scope: StateScope, key: string): boolean {\n return this.values(scope).delete(validateKey(key));\n }\n\n clearScenario(): void {\n this.scenarioValues.clear();\n }\n\n private values(scope: StateScope): StateValues {\n if (scope === 'run') return this.runValues;\n if (scope === 'feature') return this.featureValues;\n return this.scenarioValues;\n }\n}\n\nfunction validateKey(key: string): string {\n const trimmed = key.trim();\n if (!trimmed) throw new Error('BDD state key must not be empty');\n return trimmed;\n}\n\nexport const sharedState = new SharedStateRegistry();\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/cardinality.ts
|
|
2
|
+
function parseCardinalityField(value, cardinality, transform, options = {}) {
|
|
3
|
+
const fieldName = options.fieldName ?? "field";
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
const items = trimmed ? trimmed.split(options.separator ?? /\s*,\s*/).map((item) => item.trim()) : [];
|
|
6
|
+
if (items.some((item) => !item)) {
|
|
7
|
+
throw new Error(`${fieldName} contains an empty value`);
|
|
8
|
+
}
|
|
9
|
+
if (cardinality === "?" && items.length > 1) {
|
|
10
|
+
throw new Error(`${fieldName} expects zero or one value, received ${items.length}`);
|
|
11
|
+
}
|
|
12
|
+
if (cardinality === "+" && items.length === 0) {
|
|
13
|
+
throw new Error(`${fieldName} expects one or more values`);
|
|
14
|
+
}
|
|
15
|
+
const parsed = items.map(transform);
|
|
16
|
+
if (cardinality === "?") return parsed[0];
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { parseCardinalityField };
|
|
21
|
+
//# sourceMappingURL=chunk-K5LJ7WSW.js.map
|
|
22
|
+
//# sourceMappingURL=chunk-K5LJ7WSW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cardinality.ts"],"names":[],"mappings":";AAmBO,SAAS,sBACd,KAAA,EACA,WAAA,EACA,SAAA,EACA,OAAA,GAA8B,EAAC,EACN;AACzB,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,OAAA;AACvC,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAC3B,EAAA,MAAM,KAAA,GAAQ,OAAA,GACV,OAAA,CAAQ,KAAA,CAAM,QAAQ,SAAA,IAAa,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,IAAA,KAAS,IAAA,CAAK,IAAA,EAAM,IACvE,EAAC;AACL,EAAA,IAAI,MAAM,IAAA,CAAK,CAAC,IAAA,KAAS,CAAC,IAAI,CAAA,EAAG;AAC/B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,wBAAA,CAA0B,CAAA;AAAA,EACxD;AAEA,EAAA,IAAI,WAAA,KAAgB,GAAA,IAAO,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG;AAC3C,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,qCAAA,EAAwC,KAAA,CAAM,MAAM,CAAA,CAAE,CAAA;AAAA,EACpF;AACA,EAAA,IAAI,WAAA,KAAgB,GAAA,IAAO,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG;AAC7C,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,2BAAA,CAA6B,CAAA;AAAA,EAC3D;AAEA,EAAA,MAAM,MAAA,GAAS,KAAA,CAAM,GAAA,CAAI,SAAS,CAAA;AAClC,EAAA,IAAI,WAAA,KAAgB,GAAA,EAAK,OAAO,MAAA,CAAO,CAAC,CAAA;AACxC,EAAA,OAAO,MAAA;AACT","file":"chunk-K5LJ7WSW.js","sourcesContent":["/** Cardinalities supported by Behave's cfparse fields. */\nexport type FieldCardinality = '?' | '*' | '+';\n\nexport interface CardinalityOptions {\n /** Delimiter between values. Defaults to a comma with optional whitespace. */\n separator?: string | RegExp;\n /** Human-readable field name used in validation errors. */\n fieldName?: string;\n}\n\nexport type CardinalityResult<T, C extends FieldCardinality> = C extends '?' ? T | undefined : T[];\n\n/**\n * Parse a Cucumber string parameter with cfparse-compatible cardinality.\n *\n * Use `?` for zero-or-one, `*` for zero-or-more, and `+` for one-or-more.\n * This keeps the capability in TypeScript while allowing standard Cucumber\n * Expressions and readable comma-separated parameters.\n */\nexport function parseCardinalityField<T, C extends FieldCardinality>(\n value: string,\n cardinality: C,\n transform: (item: string, index: number) => T,\n options: CardinalityOptions = {},\n): CardinalityResult<T, C> {\n const fieldName = options.fieldName ?? 'field';\n const trimmed = value.trim();\n const items = trimmed\n ? trimmed.split(options.separator ?? /\\s*,\\s*/).map((item) => item.trim())\n : [];\n if (items.some((item) => !item)) {\n throw new Error(`${fieldName} contains an empty value`);\n }\n\n if (cardinality === '?' && items.length > 1) {\n throw new Error(`${fieldName} expects zero or one value, received ${items.length}`);\n }\n if (cardinality === '+' && items.length === 0) {\n throw new Error(`${fieldName} expects one or more values`);\n }\n\n const parsed = items.map(transform);\n if (cardinality === '?') return parsed[0] as CardinalityResult<T, C>;\n return parsed as CardinalityResult<T, C>;\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/fixtures.ts
|
|
2
|
+
function isFixtureResult(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "value") && typeof value.cleanup === "function";
|
|
4
|
+
}
|
|
5
|
+
var SharedFixtureRegistry = class {
|
|
6
|
+
runEntries = /* @__PURE__ */ new Map();
|
|
7
|
+
featureEntries = /* @__PURE__ */ new Map();
|
|
8
|
+
cleanupOrder = [];
|
|
9
|
+
runFixture(key, setup) {
|
|
10
|
+
return this.resolve(this.runEntries, key, setup);
|
|
11
|
+
}
|
|
12
|
+
featureFixture(featureUri, key, setup) {
|
|
13
|
+
if (!featureUri) throw new Error("featureFixture requires a feature URI");
|
|
14
|
+
let feature = this.featureEntries.get(featureUri);
|
|
15
|
+
if (!feature) {
|
|
16
|
+
feature = /* @__PURE__ */ new Map();
|
|
17
|
+
this.featureEntries.set(featureUri, feature);
|
|
18
|
+
}
|
|
19
|
+
return this.resolve(feature, key, setup);
|
|
20
|
+
}
|
|
21
|
+
resolve(entries, key, setup) {
|
|
22
|
+
if (!key.trim()) throw new Error("Fixture key must not be empty");
|
|
23
|
+
const existing = entries.get(key);
|
|
24
|
+
if (existing) return existing.value;
|
|
25
|
+
const entry = {
|
|
26
|
+
value: Promise.resolve().then(setup).then((result) => {
|
|
27
|
+
if (isFixtureResult(result)) {
|
|
28
|
+
entry.cleanup = result.cleanup;
|
|
29
|
+
return result.value;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}).catch((error) => {
|
|
33
|
+
entries.delete(key);
|
|
34
|
+
const index = this.cleanupOrder.indexOf(entry);
|
|
35
|
+
if (index >= 0) this.cleanupOrder.splice(index, 1);
|
|
36
|
+
throw error;
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
entries.set(key, entry);
|
|
40
|
+
this.cleanupOrder.push(entry);
|
|
41
|
+
return entry.value;
|
|
42
|
+
}
|
|
43
|
+
async dispose() {
|
|
44
|
+
const errors = [];
|
|
45
|
+
for (const entry of this.cleanupOrder.splice(0).reverse()) {
|
|
46
|
+
try {
|
|
47
|
+
await entry.value.catch(() => void 0);
|
|
48
|
+
await entry.cleanup?.();
|
|
49
|
+
} catch (error) {
|
|
50
|
+
errors.push(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.runEntries.clear();
|
|
54
|
+
this.featureEntries.clear();
|
|
55
|
+
if (errors.length > 0) throw new AggregateError(errors, "Shared fixture cleanup failed");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var sharedFixtures = new SharedFixtureRegistry();
|
|
59
|
+
|
|
60
|
+
export { SharedFixtureRegistry, sharedFixtures };
|
|
61
|
+
//# sourceMappingURL=chunk-SZL3KWW7.js.map
|
|
62
|
+
//# sourceMappingURL=chunk-SZL3KWW7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixtures.ts"],"names":[],"mappings":";AA2BA,SAAS,gBAAmB,KAAA,EAG1B;AACA,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,KAAA,EAAO,OAAO,CAAA,IACnD,OAAQ,MAAgC,OAAA,KAAY,UAAA;AAExD;AAEO,IAAM,wBAAN,MAA4B;AAAA,EAChB,UAAA,uBAAiB,GAAA,EAA0B;AAAA,EAC3C,cAAA,uBAAqB,GAAA,EAAuC;AAAA,EAC5D,eAA+B,EAAC;AAAA,EAEjD,UAAA,CAAc,KAAa,KAAA,EAAoC;AAC7D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,UAAA,EAAY,KAAK,KAAK,CAAA;AAAA,EACjD;AAAA,EAEA,cAAA,CAAkB,UAAA,EAAoB,GAAA,EAAa,KAAA,EAAoC;AACrF,IAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,MAAM,uCAAuC,CAAA;AACxE,IAAA,IAAI,OAAA,GAAU,IAAA,CAAK,cAAA,CAAe,GAAA,CAAI,UAAU,CAAA;AAChD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,OAAA,uBAAc,GAAA,EAAI;AAClB,MAAA,IAAA,CAAK,cAAA,CAAe,GAAA,CAAI,UAAA,EAAY,OAAO,CAAA;AAAA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,MAAW,SAAS,IAAA,CAAK,YAAA,CAAa,OAAO,CAAC,CAAA,CAAE,SAAQ,EAAG;AACzD,MAAA,IAAI;AAEF,QAAA,MAAM,KAAA,CAAM,KAAA,CAAM,KAAA,CAAM,MAAM,KAAA,CAAS,CAAA;AACvC,QAAA,MAAM,MAAM,OAAA,IAAU;AAAA,MACxB,SAAS,KAAA,EAAO;AACd,QAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,MACnB;AAAA,IACF;AACA,IAAA,IAAA,CAAK,WAAW,KAAA,EAAM;AACtB,IAAA,IAAA,CAAK,eAAe,KAAA,EAAM;AAC1B,IAAA,IAAI,OAAO,MAAA,GAAS,CAAA,QAAS,IAAI,cAAA,CAAe,QAAQ,+BAA+B,CAAA;AAAA,EACzF;AACF;AAEO,IAAM,cAAA,GAAiB,IAAI,qBAAA","file":"chunk-SZL3KWW7.js","sourcesContent":["/**\n * Behave-style shared fixtures for expensive Databricks resources.\n *\n * Cucumber Worlds are scenario-scoped. These registries provide the two\n * broader scopes users commonly need when migrating Behave suites:\n *\n * - runFixture: setup once for the entire Cucumber run;\n * - featureFixture: setup once per feature URI.\n *\n * Both scopes are drained by the package AfterAll hook. Deferring feature\n * cleanup until AfterAll is intentional: cucumber-js may interleave scenarios\n * and does not expose an after-feature hook. The resource is still isolated by\n * feature URI and is never reused by another feature.\n */\n\nexport type FixtureCleanup = () => void | Promise<void>;\nexport type FixtureSetup<T> = () =>\n | T\n | Promise<T>\n | { value: T; cleanup: FixtureCleanup }\n | Promise<{ value: T; cleanup: FixtureCleanup }>;\n\ninterface FixtureEntry<T = unknown> {\n value: Promise<T>;\n cleanup?: FixtureCleanup;\n}\n\nfunction isFixtureResult<T>(value: T | { value: T; cleanup: FixtureCleanup }): value is {\n value: T;\n cleanup: FixtureCleanup;\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.hasOwnProperty.call(value, 'value') &&\n typeof (value as { cleanup?: unknown }).cleanup === 'function'\n );\n}\n\nexport class SharedFixtureRegistry {\n private readonly runEntries = new Map<string, FixtureEntry>();\n private readonly featureEntries = new Map<string, Map<string, FixtureEntry>>();\n private readonly cleanupOrder: FixtureEntry[] = [];\n\n runFixture<T>(key: string, setup: FixtureSetup<T>): Promise<T> {\n return this.resolve(this.runEntries, key, setup);\n }\n\n featureFixture<T>(featureUri: string, key: string, setup: FixtureSetup<T>): Promise<T> {\n if (!featureUri) throw new Error('featureFixture requires a feature URI');\n let feature = this.featureEntries.get(featureUri);\n if (!feature) {\n feature = new Map();\n this.featureEntries.set(featureUri, feature);\n }\n return this.resolve(feature, key, setup);\n }\n\n private resolve<T>(entries: Map<string, FixtureEntry>, key: string, setup: FixtureSetup<T>) {\n if (!key.trim()) throw new Error('Fixture key must not be empty');\n const existing = entries.get(key);\n if (existing) return existing.value as Promise<T>;\n\n const entry: FixtureEntry<T> = {\n value: Promise.resolve()\n .then(setup)\n .then((result) => {\n if (isFixtureResult(result)) {\n entry.cleanup = result.cleanup;\n return result.value;\n }\n return result;\n })\n .catch((error) => {\n entries.delete(key);\n const index = this.cleanupOrder.indexOf(entry);\n if (index >= 0) this.cleanupOrder.splice(index, 1);\n throw error;\n }),\n };\n entries.set(key, entry);\n this.cleanupOrder.push(entry);\n return entry.value;\n }\n\n async dispose(): Promise<void> {\n const errors: unknown[] = [];\n for (const entry of this.cleanupOrder.splice(0).reverse()) {\n try {\n // Ensure setup has settled before attempting its cleanup.\n await entry.value.catch(() => undefined);\n await entry.cleanup?.();\n } catch (error) {\n errors.push(error);\n }\n }\n this.runEntries.clear();\n this.featureEntries.clear();\n if (errors.length > 0) throw new AggregateError(errors, 'Shared fixture cleanup failed');\n }\n}\n\nexport const sharedFixtures = new SharedFixtureRegistry();\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/fixtures.ts
|
|
4
|
+
function isFixtureResult(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "value") && typeof value.cleanup === "function";
|
|
6
|
+
}
|
|
7
|
+
var SharedFixtureRegistry = class {
|
|
8
|
+
runEntries = /* @__PURE__ */ new Map();
|
|
9
|
+
featureEntries = /* @__PURE__ */ new Map();
|
|
10
|
+
cleanupOrder = [];
|
|
11
|
+
runFixture(key, setup) {
|
|
12
|
+
return this.resolve(this.runEntries, key, setup);
|
|
13
|
+
}
|
|
14
|
+
featureFixture(featureUri, key, setup) {
|
|
15
|
+
if (!featureUri) throw new Error("featureFixture requires a feature URI");
|
|
16
|
+
let feature = this.featureEntries.get(featureUri);
|
|
17
|
+
if (!feature) {
|
|
18
|
+
feature = /* @__PURE__ */ new Map();
|
|
19
|
+
this.featureEntries.set(featureUri, feature);
|
|
20
|
+
}
|
|
21
|
+
return this.resolve(feature, key, setup);
|
|
22
|
+
}
|
|
23
|
+
resolve(entries, key, setup) {
|
|
24
|
+
if (!key.trim()) throw new Error("Fixture key must not be empty");
|
|
25
|
+
const existing = entries.get(key);
|
|
26
|
+
if (existing) return existing.value;
|
|
27
|
+
const entry = {
|
|
28
|
+
value: Promise.resolve().then(setup).then((result) => {
|
|
29
|
+
if (isFixtureResult(result)) {
|
|
30
|
+
entry.cleanup = result.cleanup;
|
|
31
|
+
return result.value;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}).catch((error) => {
|
|
35
|
+
entries.delete(key);
|
|
36
|
+
const index = this.cleanupOrder.indexOf(entry);
|
|
37
|
+
if (index >= 0) this.cleanupOrder.splice(index, 1);
|
|
38
|
+
throw error;
|
|
39
|
+
})
|
|
40
|
+
};
|
|
41
|
+
entries.set(key, entry);
|
|
42
|
+
this.cleanupOrder.push(entry);
|
|
43
|
+
return entry.value;
|
|
44
|
+
}
|
|
45
|
+
async dispose() {
|
|
46
|
+
const errors = [];
|
|
47
|
+
for (const entry of this.cleanupOrder.splice(0).reverse()) {
|
|
48
|
+
try {
|
|
49
|
+
await entry.value.catch(() => void 0);
|
|
50
|
+
await entry.cleanup?.();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
errors.push(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.runEntries.clear();
|
|
56
|
+
this.featureEntries.clear();
|
|
57
|
+
if (errors.length > 0) throw new AggregateError(errors, "Shared fixture cleanup failed");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var sharedFixtures = new SharedFixtureRegistry();
|
|
61
|
+
|
|
62
|
+
exports.SharedFixtureRegistry = SharedFixtureRegistry;
|
|
63
|
+
exports.sharedFixtures = sharedFixtures;
|
|
64
|
+
//# sourceMappingURL=fixtures.cjs.map
|
|
65
|
+
//# sourceMappingURL=fixtures.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixtures.ts"],"names":[],"mappings":";;;AA2BA,SAAS,gBAAmB,KAAA,EAG1B;AACA,EAAA,OACE,OAAO,KAAA,KAAU,QAAA,IACjB,KAAA,KAAU,QACV,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,KAAA,EAAO,OAAO,CAAA,IACnD,OAAQ,MAAgC,OAAA,KAAY,UAAA;AAExD;AAEO,IAAM,wBAAN,MAA4B;AAAA,EAChB,UAAA,uBAAiB,GAAA,EAA0B;AAAA,EAC3C,cAAA,uBAAqB,GAAA,EAAuC;AAAA,EAC5D,eAA+B,EAAC;AAAA,EAEjD,UAAA,CAAc,KAAa,KAAA,EAAoC;AAC7D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,UAAA,EAAY,KAAK,KAAK,CAAA;AAAA,EACjD;AAAA,EAEA,cAAA,CAAkB,UAAA,EAAoB,GAAA,EAAa,KAAA,EAAoC;AACrF,IAAA,IAAI,CAAC,UAAA,EAAY,MAAM,IAAI,MAAM,uCAAuC,CAAA;AACxE,IAAA,IAAI,OAAA,GAAU,IAAA,CAAK,cAAA,CAAe,GAAA,CAAI,UAAU,CAAA;AAChD,IAAA,IAAI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AA;AAC5B,IAAA,OAAO,KAAA,CAAM,KAAA;AAAA,EACf;AAAA,EAEA,MAAM,OAAA,GAAyB;AAC7B,IAAA,MAAM,SAAoB,EAAC;AAC3B,IAAA,KAAA,MAAW,SAAS,IAAA,CAAK,YAAA,CAAa,OAAO,CAAC,CAAA,CAAE,SAAQ,EAAG;AACzD,MAAA,IAAI;AAEF,QAAA,MAAM,KAAA,CAAM,KAAA,CAAM,KAAA,CAAM,MAAM,KAAA,CAAS,CAAA;AACvC,QAAA,MAAM,MAAM,OAAA,IAAU;AAAA,MACxB,SAAS,KAAA,EAAO;AACd,QAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,MACnB;AAAA,IACF;AACA,IAAA,IAAA,CAAK,WAAW,KAAA,EAAM;AACtB,IAAA,IAAA,CAAK,eAAe,KAAA,EAAM;AAC1B,IAAA,IAAI,OAAO,MAAA,GAAS,CAAA,QAAS,IAAI,cAAA,CAAe,QAAQ,+BAA+B,CAAA;AAAA,EACzF;AACF;AAEO,IAAM,cAAA,GAAiB,IAAI,qBAAA","file":"fixtures.cjs","sourcesContent":["/**\n * Behave-style shared fixtures for expensive Databricks resources.\n *\n * Cucumber Worlds are scenario-scoped. These registries provide the two\n * broader scopes users commonly need when migrating Behave suites:\n *\n * - runFixture: setup once for the entire Cucumber run;\n * - featureFixture: setup once per feature URI.\n *\n * Both scopes are drained by the package AfterAll hook. Deferring feature\n * cleanup until AfterAll is intentional: cucumber-js may interleave scenarios\n * and does not expose an after-feature hook. The resource is still isolated by\n * feature URI and is never reused by another feature.\n */\n\nexport type FixtureCleanup = () => void | Promise<void>;\nexport type FixtureSetup<T> = () =>\n | T\n | Promise<T>\n | { value: T; cleanup: FixtureCleanup }\n | Promise<{ value: T; cleanup: FixtureCleanup }>;\n\ninterface FixtureEntry<T = unknown> {\n value: Promise<T>;\n cleanup?: FixtureCleanup;\n}\n\nfunction isFixtureResult<T>(value: T | { value: T; cleanup: FixtureCleanup }): value is {\n value: T;\n cleanup: FixtureCleanup;\n} {\n return (\n typeof value === 'object' &&\n value !== null &&\n Object.prototype.hasOwnProperty.call(value, 'value') &&\n typeof (value as { cleanup?: unknown }).cleanup === 'function'\n );\n}\n\nexport class SharedFixtureRegistry {\n private readonly runEntries = new Map<string, FixtureEntry>();\n private readonly featureEntries = new Map<string, Map<string, FixtureEntry>>();\n private readonly cleanupOrder: FixtureEntry[] = [];\n\n runFixture<T>(key: string, setup: FixtureSetup<T>): Promise<T> {\n return this.resolve(this.runEntries, key, setup);\n }\n\n featureFixture<T>(featureUri: string, key: string, setup: FixtureSetup<T>): Promise<T> {\n if (!featureUri) throw new Error('featureFixture requires a feature URI');\n let feature = this.featureEntries.get(featureUri);\n if (!feature) {\n feature = new Map();\n this.featureEntries.set(featureUri, feature);\n }\n return this.resolve(feature, key, setup);\n }\n\n private resolve<T>(entries: Map<string, FixtureEntry>, key: string, setup: FixtureSetup<T>) {\n if (!key.trim()) throw new Error('Fixture key must not be empty');\n const existing = entries.get(key);\n if (existing) return existing.value as Promise<T>;\n\n const entry: FixtureEntry<T> = {\n value: Promise.resolve()\n .then(setup)\n .then((result) => {\n if (isFixtureResult(result)) {\n entry.cleanup = result.cleanup;\n return result.value;\n }\n return result;\n })\n .catch((error) => {\n entries.delete(key);\n const index = this.cleanupOrder.indexOf(entry);\n if (index >= 0) this.cleanupOrder.splice(index, 1);\n throw error;\n }),\n };\n entries.set(key, entry);\n this.cleanupOrder.push(entry);\n return entry.value;\n }\n\n async dispose(): Promise<void> {\n const errors: unknown[] = [];\n for (const entry of this.cleanupOrder.splice(0).reverse()) {\n try {\n // Ensure setup has settled before attempting its cleanup.\n await entry.value.catch(() => undefined);\n await entry.cleanup?.();\n } catch (error) {\n errors.push(error);\n }\n }\n this.runEntries.clear();\n this.featureEntries.clear();\n if (errors.length > 0) throw new AggregateError(errors, 'Shared fixture cleanup failed');\n }\n}\n\nexport const sharedFixtures = new SharedFixtureRegistry();\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behave-style shared fixtures for expensive Databricks resources.
|
|
3
|
+
*
|
|
4
|
+
* Cucumber Worlds are scenario-scoped. These registries provide the two
|
|
5
|
+
* broader scopes users commonly need when migrating Behave suites:
|
|
6
|
+
*
|
|
7
|
+
* - runFixture: setup once for the entire Cucumber run;
|
|
8
|
+
* - featureFixture: setup once per feature URI.
|
|
9
|
+
*
|
|
10
|
+
* Both scopes are drained by the package AfterAll hook. Deferring feature
|
|
11
|
+
* cleanup until AfterAll is intentional: cucumber-js may interleave scenarios
|
|
12
|
+
* and does not expose an after-feature hook. The resource is still isolated by
|
|
13
|
+
* feature URI and is never reused by another feature.
|
|
14
|
+
*/
|
|
15
|
+
type FixtureCleanup = () => void | Promise<void>;
|
|
16
|
+
type FixtureSetup<T> = () => T | Promise<T> | {
|
|
17
|
+
value: T;
|
|
18
|
+
cleanup: FixtureCleanup;
|
|
19
|
+
} | Promise<{
|
|
20
|
+
value: T;
|
|
21
|
+
cleanup: FixtureCleanup;
|
|
22
|
+
}>;
|
|
23
|
+
declare class SharedFixtureRegistry {
|
|
24
|
+
private readonly runEntries;
|
|
25
|
+
private readonly featureEntries;
|
|
26
|
+
private readonly cleanupOrder;
|
|
27
|
+
runFixture<T>(key: string, setup: FixtureSetup<T>): Promise<T>;
|
|
28
|
+
featureFixture<T>(featureUri: string, key: string, setup: FixtureSetup<T>): Promise<T>;
|
|
29
|
+
private resolve;
|
|
30
|
+
dispose(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
declare const sharedFixtures: SharedFixtureRegistry;
|
|
33
|
+
|
|
34
|
+
export { type FixtureCleanup, type FixtureSetup, SharedFixtureRegistry, sharedFixtures };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behave-style shared fixtures for expensive Databricks resources.
|
|
3
|
+
*
|
|
4
|
+
* Cucumber Worlds are scenario-scoped. These registries provide the two
|
|
5
|
+
* broader scopes users commonly need when migrating Behave suites:
|
|
6
|
+
*
|
|
7
|
+
* - runFixture: setup once for the entire Cucumber run;
|
|
8
|
+
* - featureFixture: setup once per feature URI.
|
|
9
|
+
*
|
|
10
|
+
* Both scopes are drained by the package AfterAll hook. Deferring feature
|
|
11
|
+
* cleanup until AfterAll is intentional: cucumber-js may interleave scenarios
|
|
12
|
+
* and does not expose an after-feature hook. The resource is still isolated by
|
|
13
|
+
* feature URI and is never reused by another feature.
|
|
14
|
+
*/
|
|
15
|
+
type FixtureCleanup = () => void | Promise<void>;
|
|
16
|
+
type FixtureSetup<T> = () => T | Promise<T> | {
|
|
17
|
+
value: T;
|
|
18
|
+
cleanup: FixtureCleanup;
|
|
19
|
+
} | Promise<{
|
|
20
|
+
value: T;
|
|
21
|
+
cleanup: FixtureCleanup;
|
|
22
|
+
}>;
|
|
23
|
+
declare class SharedFixtureRegistry {
|
|
24
|
+
private readonly runEntries;
|
|
25
|
+
private readonly featureEntries;
|
|
26
|
+
private readonly cleanupOrder;
|
|
27
|
+
runFixture<T>(key: string, setup: FixtureSetup<T>): Promise<T>;
|
|
28
|
+
featureFixture<T>(featureUri: string, key: string, setup: FixtureSetup<T>): Promise<T>;
|
|
29
|
+
private resolve;
|
|
30
|
+
dispose(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
declare const sharedFixtures: SharedFixtureRegistry;
|
|
33
|
+
|
|
34
|
+
export { type FixtureCleanup, type FixtureSetup, SharedFixtureRegistry, sharedFixtures };
|
package/dist/fixtures.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"fixtures.js"}
|