@fabricorg/experiments 0.5.2 → 0.6.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/dist/bin/fx.cjs +7129 -4910
- package/dist/bin/fx.cjs.map +1 -1
- package/dist/bin/fx.js +94 -13
- package/dist/bin/fx.js.map +1 -1
- package/dist/{chunk-CZAJ7SGJ.js → chunk-VXVHYHGH.js} +2250 -110
- package/dist/chunk-VXVHYHGH.js.map +1 -0
- package/dist/index.cjs +2251 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -5
- package/dist/index.d.ts +115 -5
- package/dist/index.js +1 -1
- package/package.json +9 -16
- package/dist/chunk-CZAJ7SGJ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ExperimentModule } from '@fabricorg/experiments-module';
|
|
2
2
|
import { LocalWarehouse } from '@fabricorg/experiments-warehouse';
|
|
3
3
|
import { ExperimentSpec } from '@fabricorg/experiments-domain';
|
|
4
|
+
import { LoadedExperimentSpec } from '@fabricorg/experiments-yaml';
|
|
5
|
+
export { LoadedExperimentSpec } from '@fabricorg/experiments-yaml';
|
|
6
|
+
import { LakebaseControlClient, createWorkspaceContext, EphemeralLakebaseBranch } from '@fabricorg/databricks-testkit';
|
|
4
7
|
|
|
5
8
|
interface Workspace {
|
|
6
9
|
root: string;
|
|
@@ -13,10 +16,6 @@ interface Workspace {
|
|
|
13
16
|
}
|
|
14
17
|
declare function loadWorkspace(cwd?: string): Promise<Workspace>;
|
|
15
18
|
|
|
16
|
-
interface LoadedExperimentSpec {
|
|
17
|
-
path: string;
|
|
18
|
-
spec: ExperimentSpec;
|
|
19
|
-
}
|
|
20
19
|
declare function loadExperimentDir(dir: string): Promise<LoadedExperimentSpec[]>;
|
|
21
20
|
declare function loadExperimentFile(path: string): Promise<ExperimentSpec>;
|
|
22
21
|
|
|
@@ -91,6 +90,19 @@ interface PublishOptions {
|
|
|
91
90
|
/** Bearer token for the remote /admin/publish endpoint. */
|
|
92
91
|
adminToken?: string;
|
|
93
92
|
keyId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Self-host static export. When set, writes the signed manifest + the
|
|
95
|
+
* tag-loader IIFE bundle into the directory:
|
|
96
|
+
*
|
|
97
|
+
* <dir>/manifest.json
|
|
98
|
+
* <dir>/experiments.tag.global.js
|
|
99
|
+
* <dir>/experiments.tag.global.js.map
|
|
100
|
+
*
|
|
101
|
+
* Upload the directory to S3, R2, GCS, or any static host. The marketing
|
|
102
|
+
* site loads the bundle and points `__FX__.manifestUrl` at the manifest.
|
|
103
|
+
* No manifest-worker required.
|
|
104
|
+
*/
|
|
105
|
+
staticDir?: string;
|
|
94
106
|
}
|
|
95
107
|
/**
|
|
96
108
|
* `fx publish` — sign the current manifest with the dev keypair (auto-generated
|
|
@@ -99,4 +111,102 @@ interface PublishOptions {
|
|
|
99
111
|
*/
|
|
100
112
|
declare function cmdPublish(options?: PublishOptions): Promise<number>;
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Mojito → Fabric Experiments importer.
|
|
116
|
+
*
|
|
117
|
+
* Walks a directory of Mojito waves (each a folder containing `config.yml`
|
|
118
|
+
* plus optional `1.js`, `1.css`, `trigger.js`, `shared.js`, `shared.css`)
|
|
119
|
+
* and emits one Fabric YAML per wave into the output directory.
|
|
120
|
+
*
|
|
121
|
+
* Coverage is best-effort:
|
|
122
|
+
* - YAML structure: id, name, sampleRate, divertTo, manualExposure → 1:1
|
|
123
|
+
* - Variants: each Mojito recipe → Fabric variant with the recipe `js`/`css` copied verbatim
|
|
124
|
+
* - Trigger: emitted as `{ kind: 'auto' }` with the original `trigger.js` body kept
|
|
125
|
+
* inline as a comment header on the variant — the host runtime will not call it,
|
|
126
|
+
* so unconverted constructs are flagged in the conversion report.
|
|
127
|
+
* - DOM ops: not auto-converted — Mojito triggers can be arbitrary code. Importer
|
|
128
|
+
* leaves the JS in place and prints a TODO line per file.
|
|
129
|
+
*/
|
|
130
|
+
interface ImportMojitoOptions {
|
|
131
|
+
/** Output directory for Fabric YAML. Default: `<input>/converted/`. */
|
|
132
|
+
outputDir?: string;
|
|
133
|
+
/** Tenant scope written into emitted spec. Used only as a comment header. */
|
|
134
|
+
tenantId?: string;
|
|
135
|
+
}
|
|
136
|
+
declare function cmdImportMojito(inputDir: string, options?: ImportMojitoOptions): Promise<number>;
|
|
137
|
+
|
|
138
|
+
interface PreviewOptions {
|
|
139
|
+
variantKey: string;
|
|
140
|
+
tenantId?: string;
|
|
141
|
+
ttlSeconds?: number;
|
|
142
|
+
/** Optional base URL for the hosted API. When set, uses the hosted signing endpoint. */
|
|
143
|
+
apiUrl?: string;
|
|
144
|
+
/** Bearer API key for the hosted endpoint. */
|
|
145
|
+
apiKey?: string;
|
|
146
|
+
/** Optional preview origin to embed in the printed URL. */
|
|
147
|
+
origin?: string;
|
|
148
|
+
/** Force local mode even if apiUrl is set. */
|
|
149
|
+
local?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Mints a signed preview token for an experiment + variant. Two modes:
|
|
153
|
+
*
|
|
154
|
+
* 1. Hosted (`--api-url + --api-key`): POST /v1/orgs/<tenant>/preview/sign
|
|
155
|
+
* and receives an EdDSA token verified by public JWKS.
|
|
156
|
+
* 2. Local (default): generates / reuses a per-workspace HS256 secret in
|
|
157
|
+
* `.fx/preview-secret` and signs locally. Useful for `fx dev`.
|
|
158
|
+
*
|
|
159
|
+
* Prints the token, the constructed URL (when --origin is given), and the
|
|
160
|
+
* expiry. Secrets and tokens are bearer credentials — never logged elsewhere.
|
|
161
|
+
*/
|
|
162
|
+
declare function cmdPreview(experimentId: string, options: PreviewOptions): Promise<number>;
|
|
163
|
+
|
|
164
|
+
interface PushOptions {
|
|
165
|
+
apiUrl?: string;
|
|
166
|
+
apiKey?: string;
|
|
167
|
+
tenantId?: string;
|
|
168
|
+
ownerId?: string;
|
|
169
|
+
approverId?: string;
|
|
170
|
+
dryRun?: boolean;
|
|
171
|
+
allowDeletes?: boolean;
|
|
172
|
+
publish?: boolean;
|
|
173
|
+
}
|
|
174
|
+
declare function cmdPush(dir: string, options?: PushOptions): Promise<number>;
|
|
175
|
+
|
|
176
|
+
declare function cmdInitDatabricksTests(directory?: string, options?: {
|
|
177
|
+
force?: boolean;
|
|
178
|
+
}): Promise<number>;
|
|
179
|
+
|
|
180
|
+
interface TestEnvironment {
|
|
181
|
+
name: string;
|
|
182
|
+
catalog: string;
|
|
183
|
+
schema: string;
|
|
184
|
+
principal?: string;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
expiresAt: string;
|
|
187
|
+
lakebase?: EphemeralLakebaseBranch;
|
|
188
|
+
}
|
|
189
|
+
interface TestEnvOptions {
|
|
190
|
+
name?: string;
|
|
191
|
+
catalog?: string;
|
|
192
|
+
principal?: string;
|
|
193
|
+
grantCatalog?: boolean;
|
|
194
|
+
seedDir?: string;
|
|
195
|
+
ttl?: string;
|
|
196
|
+
lakebaseBranch?: boolean;
|
|
197
|
+
lakebaseProject?: string;
|
|
198
|
+
lakebaseClient?: LakebaseControlClient;
|
|
199
|
+
remote?: boolean;
|
|
200
|
+
statePath?: string;
|
|
201
|
+
env?: Record<string, string | undefined>;
|
|
202
|
+
contextFactory?: typeof createWorkspaceContext;
|
|
203
|
+
now?: () => Date;
|
|
204
|
+
}
|
|
205
|
+
declare function cmdTestEnv(action: string, options?: TestEnvOptions): Promise<number>;
|
|
206
|
+
declare function createTestEnvironment(options: TestEnvOptions): Promise<TestEnvironment>;
|
|
207
|
+
declare function destroyTestEnvironment(options: TestEnvOptions): Promise<void>;
|
|
208
|
+
declare function listTestEnvironments(options?: TestEnvOptions): Promise<TestEnvironment[]>;
|
|
209
|
+
declare function reapTestEnvironments(options?: TestEnvOptions): Promise<string[]>;
|
|
210
|
+
declare function discoverRemoteEnvironments(options?: TestEnvOptions): Promise<TestEnvironment[]>;
|
|
211
|
+
|
|
212
|
+
export { type Workspace, cmdApply, cmdDev, cmdImportMojito, cmdInitDatabricksTests, cmdKill, cmdPlan, cmdPreview, cmdPublish, cmdPush, cmdReport, cmdTestEnv, cmdValidate, createTestEnvironment, destroyTestEnvironment, discoverRemoteEnvironments, listTestEnvironments, loadExperimentDir, loadExperimentFile, loadWorkspace, reapTestEnvironments };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ExperimentModule } from '@fabricorg/experiments-module';
|
|
2
2
|
import { LocalWarehouse } from '@fabricorg/experiments-warehouse';
|
|
3
3
|
import { ExperimentSpec } from '@fabricorg/experiments-domain';
|
|
4
|
+
import { LoadedExperimentSpec } from '@fabricorg/experiments-yaml';
|
|
5
|
+
export { LoadedExperimentSpec } from '@fabricorg/experiments-yaml';
|
|
6
|
+
import { LakebaseControlClient, createWorkspaceContext, EphemeralLakebaseBranch } from '@fabricorg/databricks-testkit';
|
|
4
7
|
|
|
5
8
|
interface Workspace {
|
|
6
9
|
root: string;
|
|
@@ -13,10 +16,6 @@ interface Workspace {
|
|
|
13
16
|
}
|
|
14
17
|
declare function loadWorkspace(cwd?: string): Promise<Workspace>;
|
|
15
18
|
|
|
16
|
-
interface LoadedExperimentSpec {
|
|
17
|
-
path: string;
|
|
18
|
-
spec: ExperimentSpec;
|
|
19
|
-
}
|
|
20
19
|
declare function loadExperimentDir(dir: string): Promise<LoadedExperimentSpec[]>;
|
|
21
20
|
declare function loadExperimentFile(path: string): Promise<ExperimentSpec>;
|
|
22
21
|
|
|
@@ -91,6 +90,19 @@ interface PublishOptions {
|
|
|
91
90
|
/** Bearer token for the remote /admin/publish endpoint. */
|
|
92
91
|
adminToken?: string;
|
|
93
92
|
keyId?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Self-host static export. When set, writes the signed manifest + the
|
|
95
|
+
* tag-loader IIFE bundle into the directory:
|
|
96
|
+
*
|
|
97
|
+
* <dir>/manifest.json
|
|
98
|
+
* <dir>/experiments.tag.global.js
|
|
99
|
+
* <dir>/experiments.tag.global.js.map
|
|
100
|
+
*
|
|
101
|
+
* Upload the directory to S3, R2, GCS, or any static host. The marketing
|
|
102
|
+
* site loads the bundle and points `__FX__.manifestUrl` at the manifest.
|
|
103
|
+
* No manifest-worker required.
|
|
104
|
+
*/
|
|
105
|
+
staticDir?: string;
|
|
94
106
|
}
|
|
95
107
|
/**
|
|
96
108
|
* `fx publish` — sign the current manifest with the dev keypair (auto-generated
|
|
@@ -99,4 +111,102 @@ interface PublishOptions {
|
|
|
99
111
|
*/
|
|
100
112
|
declare function cmdPublish(options?: PublishOptions): Promise<number>;
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Mojito → Fabric Experiments importer.
|
|
116
|
+
*
|
|
117
|
+
* Walks a directory of Mojito waves (each a folder containing `config.yml`
|
|
118
|
+
* plus optional `1.js`, `1.css`, `trigger.js`, `shared.js`, `shared.css`)
|
|
119
|
+
* and emits one Fabric YAML per wave into the output directory.
|
|
120
|
+
*
|
|
121
|
+
* Coverage is best-effort:
|
|
122
|
+
* - YAML structure: id, name, sampleRate, divertTo, manualExposure → 1:1
|
|
123
|
+
* - Variants: each Mojito recipe → Fabric variant with the recipe `js`/`css` copied verbatim
|
|
124
|
+
* - Trigger: emitted as `{ kind: 'auto' }` with the original `trigger.js` body kept
|
|
125
|
+
* inline as a comment header on the variant — the host runtime will not call it,
|
|
126
|
+
* so unconverted constructs are flagged in the conversion report.
|
|
127
|
+
* - DOM ops: not auto-converted — Mojito triggers can be arbitrary code. Importer
|
|
128
|
+
* leaves the JS in place and prints a TODO line per file.
|
|
129
|
+
*/
|
|
130
|
+
interface ImportMojitoOptions {
|
|
131
|
+
/** Output directory for Fabric YAML. Default: `<input>/converted/`. */
|
|
132
|
+
outputDir?: string;
|
|
133
|
+
/** Tenant scope written into emitted spec. Used only as a comment header. */
|
|
134
|
+
tenantId?: string;
|
|
135
|
+
}
|
|
136
|
+
declare function cmdImportMojito(inputDir: string, options?: ImportMojitoOptions): Promise<number>;
|
|
137
|
+
|
|
138
|
+
interface PreviewOptions {
|
|
139
|
+
variantKey: string;
|
|
140
|
+
tenantId?: string;
|
|
141
|
+
ttlSeconds?: number;
|
|
142
|
+
/** Optional base URL for the hosted API. When set, uses the hosted signing endpoint. */
|
|
143
|
+
apiUrl?: string;
|
|
144
|
+
/** Bearer API key for the hosted endpoint. */
|
|
145
|
+
apiKey?: string;
|
|
146
|
+
/** Optional preview origin to embed in the printed URL. */
|
|
147
|
+
origin?: string;
|
|
148
|
+
/** Force local mode even if apiUrl is set. */
|
|
149
|
+
local?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Mints a signed preview token for an experiment + variant. Two modes:
|
|
153
|
+
*
|
|
154
|
+
* 1. Hosted (`--api-url + --api-key`): POST /v1/orgs/<tenant>/preview/sign
|
|
155
|
+
* and receives an EdDSA token verified by public JWKS.
|
|
156
|
+
* 2. Local (default): generates / reuses a per-workspace HS256 secret in
|
|
157
|
+
* `.fx/preview-secret` and signs locally. Useful for `fx dev`.
|
|
158
|
+
*
|
|
159
|
+
* Prints the token, the constructed URL (when --origin is given), and the
|
|
160
|
+
* expiry. Secrets and tokens are bearer credentials — never logged elsewhere.
|
|
161
|
+
*/
|
|
162
|
+
declare function cmdPreview(experimentId: string, options: PreviewOptions): Promise<number>;
|
|
163
|
+
|
|
164
|
+
interface PushOptions {
|
|
165
|
+
apiUrl?: string;
|
|
166
|
+
apiKey?: string;
|
|
167
|
+
tenantId?: string;
|
|
168
|
+
ownerId?: string;
|
|
169
|
+
approverId?: string;
|
|
170
|
+
dryRun?: boolean;
|
|
171
|
+
allowDeletes?: boolean;
|
|
172
|
+
publish?: boolean;
|
|
173
|
+
}
|
|
174
|
+
declare function cmdPush(dir: string, options?: PushOptions): Promise<number>;
|
|
175
|
+
|
|
176
|
+
declare function cmdInitDatabricksTests(directory?: string, options?: {
|
|
177
|
+
force?: boolean;
|
|
178
|
+
}): Promise<number>;
|
|
179
|
+
|
|
180
|
+
interface TestEnvironment {
|
|
181
|
+
name: string;
|
|
182
|
+
catalog: string;
|
|
183
|
+
schema: string;
|
|
184
|
+
principal?: string;
|
|
185
|
+
createdAt: string;
|
|
186
|
+
expiresAt: string;
|
|
187
|
+
lakebase?: EphemeralLakebaseBranch;
|
|
188
|
+
}
|
|
189
|
+
interface TestEnvOptions {
|
|
190
|
+
name?: string;
|
|
191
|
+
catalog?: string;
|
|
192
|
+
principal?: string;
|
|
193
|
+
grantCatalog?: boolean;
|
|
194
|
+
seedDir?: string;
|
|
195
|
+
ttl?: string;
|
|
196
|
+
lakebaseBranch?: boolean;
|
|
197
|
+
lakebaseProject?: string;
|
|
198
|
+
lakebaseClient?: LakebaseControlClient;
|
|
199
|
+
remote?: boolean;
|
|
200
|
+
statePath?: string;
|
|
201
|
+
env?: Record<string, string | undefined>;
|
|
202
|
+
contextFactory?: typeof createWorkspaceContext;
|
|
203
|
+
now?: () => Date;
|
|
204
|
+
}
|
|
205
|
+
declare function cmdTestEnv(action: string, options?: TestEnvOptions): Promise<number>;
|
|
206
|
+
declare function createTestEnvironment(options: TestEnvOptions): Promise<TestEnvironment>;
|
|
207
|
+
declare function destroyTestEnvironment(options: TestEnvOptions): Promise<void>;
|
|
208
|
+
declare function listTestEnvironments(options?: TestEnvOptions): Promise<TestEnvironment[]>;
|
|
209
|
+
declare function reapTestEnvironments(options?: TestEnvOptions): Promise<string[]>;
|
|
210
|
+
declare function discoverRemoteEnvironments(options?: TestEnvOptions): Promise<TestEnvironment[]>;
|
|
211
|
+
|
|
212
|
+
export { type Workspace, cmdApply, cmdDev, cmdImportMojito, cmdInitDatabricksTests, cmdKill, cmdPlan, cmdPreview, cmdPublish, cmdPush, cmdReport, cmdTestEnv, cmdValidate, createTestEnvironment, destroyTestEnvironment, discoverRemoteEnvironments, listTestEnvironments, loadExperimentDir, loadExperimentFile, loadWorkspace, reapTestEnvironments };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { cmdApply, cmdDev, cmdKill, cmdPlan, cmdPublish, cmdReport, cmdValidate, loadExperimentDir, loadExperimentFile, loadWorkspace } from './chunk-
|
|
1
|
+
export { cmdApply, cmdDev, cmdImportMojito, cmdInitDatabricksTests, cmdKill, cmdPlan, cmdPreview, cmdPublish, cmdPush, cmdReport, cmdTestEnv, cmdValidate, createTestEnvironment, destroyTestEnvironment, discoverRemoteEnvironments, listTestEnvironments, loadExperimentDir, loadExperimentFile, loadWorkspace, reapTestEnvironments } from './chunk-VXVHYHGH.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/experiments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Fabric Experiments CLI (fx) — validate, plan, apply, run, publish, report, and kill governed A/B tests locally.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"ab-testing",
|
|
7
|
-
"experimentation",
|
|
8
|
-
"feature-flags",
|
|
9
|
-
"growth",
|
|
10
|
-
"fabric",
|
|
11
|
-
"cli",
|
|
12
|
-
"fx"
|
|
13
|
-
],
|
|
5
|
+
"keywords": ["ab-testing", "experimentation", "feature-flags", "growth", "fabric", "cli", "fx"],
|
|
14
6
|
"license": "MIT",
|
|
15
7
|
"author": "Fabric",
|
|
16
8
|
"homepage": "https://experiments.fabric.pro",
|
|
@@ -50,22 +42,23 @@
|
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
},
|
|
53
|
-
"files": [
|
|
54
|
-
"dist",
|
|
55
|
-
"README.md",
|
|
56
|
-
"LICENSE"
|
|
57
|
-
],
|
|
45
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
58
46
|
"scripts": {
|
|
59
47
|
"build": "tsup",
|
|
60
48
|
"type-check": "tsc --noEmit",
|
|
61
|
-
"test": "vitest run
|
|
49
|
+
"test": "vitest run",
|
|
62
50
|
"clean": "rm -rf dist",
|
|
63
51
|
"prepublishOnly": "pnpm clean && pnpm build && pnpm test"
|
|
64
52
|
},
|
|
65
53
|
"dependencies": {
|
|
54
|
+
"@fabricorg/databricks-testkit": "workspace:*",
|
|
55
|
+
"@fabricorg/experiments-web": "workspace:*",
|
|
56
|
+
"@fabricorg/experiments-yaml": "workspace:*",
|
|
66
57
|
"yaml": "^2.6.1"
|
|
67
58
|
},
|
|
68
59
|
"devDependencies": {
|
|
60
|
+
"@fabricorg/experiments-api-client": "workspace:*",
|
|
61
|
+
"@fabricorg/experiments-api-protocol": "workspace:*",
|
|
69
62
|
"@fabricorg/experiments-domain": "workspace:*",
|
|
70
63
|
"@fabricorg/experiments-manifest-signing": "workspace:*",
|
|
71
64
|
"@fabricorg/experiments-module": "workspace:*",
|