@pikku/cli 0.12.113 → 0.12.114
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/CHANGELOG.md +29 -0
- package/dist/.pikku/addon/index.d.ts +1 -1
- package/dist/.pikku/addon/index.js +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.js +1 -1
- package/dist/.pikku/agent/index.d.ts +1 -1
- package/dist/.pikku/agent/index.js +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-model-aliases.gen.js +1 -1
- package/dist/.pikku/auth/index.d.ts +1 -1
- package/dist/.pikku/auth/index.js +1 -1
- package/dist/.pikku/auth/pikku-auth-types.gen.d.ts +1 -1
- package/dist/.pikku/auth/pikku-auth-types.gen.js +1 -1
- package/dist/.pikku/channel/index.d.ts +1 -1
- package/dist/.pikku/channel/index.js +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/cli/index.d.ts +1 -1
- package/dist/.pikku/cli/index.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/error/index.d.ts +1 -1
- package/dist/.pikku/error/index.js +1 -1
- package/dist/.pikku/error/pikku-error-types.gen.d.ts +1 -1
- package/dist/.pikku/error/pikku-error-types.gen.js +1 -1
- package/dist/.pikku/function/index.d.ts +1 -1
- package/dist/.pikku/function/index.js +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +3 -3
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- package/dist/.pikku/gateway/index.d.ts +1 -1
- package/dist/.pikku/gateway/index.js +1 -1
- package/dist/.pikku/gateway/pikku-gateway-types.gen.d.ts +1 -1
- package/dist/.pikku/gateway/pikku-gateway-types.gen.js +1 -1
- package/dist/.pikku/http/index.d.ts +1 -1
- package/dist/.pikku/http/index.js +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/mcp/index.d.ts +1 -1
- package/dist/.pikku/mcp/index.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/middleware/index.d.ts +1 -1
- package/dist/.pikku/middleware/index.js +1 -1
- package/dist/.pikku/middleware/pikku-middleware-types.gen.d.ts +1 -1
- package/dist/.pikku/middleware/pikku-middleware-types.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -1
- package/dist/.pikku/queue/index.d.ts +1 -1
- package/dist/.pikku/queue/index.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/scenarios/index.d.ts +1 -1
- package/dist/.pikku/scenarios/index.js +1 -1
- package/dist/.pikku/scenarios/pikku-personas.gen.js +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-types.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.js +1 -1
- package/dist/.pikku/scheduler/index.d.ts +1 -1
- package/dist/.pikku/scheduler/index.js +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +1 -1
- package/dist/.pikku/scopes/index.d.ts +1 -1
- package/dist/.pikku/scopes/index.js +1 -1
- package/dist/.pikku/scopes/pikku-personas.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-roles.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +1 -1
- package/dist/.pikku/secrets/index.d.ts +1 -1
- package/dist/.pikku/secrets/index.js +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/services/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/services/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/setup/index.d.ts +1 -1
- package/dist/.pikku/setup/index.js +1 -1
- package/dist/.pikku/setup/pikku-setup-types.gen.d.ts +1 -1
- package/dist/.pikku/setup/pikku-setup-types.gen.js +1 -1
- package/dist/.pikku/trigger/index.d.ts +1 -1
- package/dist/.pikku/trigger/index.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/index.d.ts +1 -1
- package/dist/.pikku/variables/index.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/index.d.ts +1 -1
- package/dist/.pikku/workflow/index.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/bin/pikku-bin.mjs +2 -2
- package/dist/src/functions/commands/persona-sync.js +3 -6
- package/dist/src/functions/commands/persona.js +3 -6
- package/dist/src/functions/commands/scenario-browser.d.ts +10 -3
- package/dist/src/functions/commands/scenario-browser.js +2 -1
- package/dist/src/functions/commands/scenario.js +4 -7
- package/dist/src/utils/persona-credentials.d.ts +22 -0
- package/dist/src/utils/persona-credentials.js +32 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/surface.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.114
|
|
3
3
|
*/
|
|
4
4
|
import { WorkflowCancelledException } from '@pikku/core/workflow';
|
|
5
5
|
import type { PikkuWorkflowGraphConfig, PikkuWorkflowGraphResult } from '@pikku/core/workflow';
|
package/dist/bin/pikku-bin.mjs
CHANGED
|
@@ -11,8 +11,8 @@ async function checkForUpdate() {
|
|
|
11
11
|
})
|
|
12
12
|
if (!res.ok) return
|
|
13
13
|
const { version: latest } = await res.json()
|
|
14
|
-
if (latest !== '0.12.
|
|
15
|
-
process.stderr.write(`\n Update available 0.12.
|
|
14
|
+
if (latest !== '0.12.114') {
|
|
15
|
+
process.stderr.write(`\n Update available 0.12.114 → ${latest}\n brew upgrade pikku or npm install -g @pikku/cli\n\n`)
|
|
16
16
|
}
|
|
17
17
|
} catch {}
|
|
18
18
|
}
|
|
@@ -2,6 +2,7 @@ import { pikkuSessionlessFunc } from '#pikku/function';
|
|
|
2
2
|
import { createHttpPersonas } from '@pikku/core/persona';
|
|
3
3
|
import { personaEnvironmentRefusal } from '@pikku/core/persona';
|
|
4
4
|
import { resolvePersonas } from '../../utils/resolve-personas.js';
|
|
5
|
+
import { resolvePersonaCredentials } from '../../utils/persona-credentials.js';
|
|
5
6
|
import { resolveEnvironment } from './environment.js';
|
|
6
7
|
import { loadDeclaredRoles, openScopeServiceForRoles } from './roles-shared.js';
|
|
7
8
|
/**
|
|
@@ -88,18 +89,14 @@ export const personaSync = pikkuSessionlessFunc({
|
|
|
88
89
|
logger.info('Re-run without --dry-run to apply.');
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
91
|
-
const
|
|
92
|
-
if (!secret) {
|
|
93
|
-
throw new Error('SCENARIO_ACTOR_SECRET is not set — a persona account cannot be created. ' +
|
|
94
|
-
'Export it in the environment running this command (never put it in pikku.config.json).');
|
|
95
|
-
}
|
|
92
|
+
const credentials = await resolvePersonaCredentials(variables, 'a persona account');
|
|
96
93
|
const declaredRoles = await loadDeclaredRoles(config.rolesMetaJsonFile, logger);
|
|
97
94
|
if (!declaredRoles) {
|
|
98
95
|
throw new Error('role metadata not found');
|
|
99
96
|
}
|
|
100
97
|
const signedIn = createHttpPersonas({
|
|
101
98
|
apiUrl: env.apiUrl,
|
|
102
|
-
|
|
99
|
+
...credentials,
|
|
103
100
|
personas: Object.fromEntries(eligible),
|
|
104
101
|
signInPath: env.signInPath,
|
|
105
102
|
rpcPath: env.rpcPath,
|
|
@@ -5,6 +5,7 @@ import { createHttpPersonas, personaEnvironmentRefusal, roleMismatchMessage, ver
|
|
|
5
5
|
import { personaVirtualUserTarget, runVirtualUser, catalogueClassification, DISPOSITIONS, prepareVirtualUserRun, } from '@pikku/core/virtual-user';
|
|
6
6
|
import { getSingletonServices, setSingletonServices } from '@pikku/core/state';
|
|
7
7
|
import { resolvePersonas } from '../../utils/resolve-personas.js';
|
|
8
|
+
import { resolvePersonaCredentials } from '../../utils/persona-credentials.js';
|
|
8
9
|
import { resolveEnvironment } from './environment.js';
|
|
9
10
|
import { createDevAgentRunner } from './dev-agent-runner.js';
|
|
10
11
|
import { formatVirtualUserReport } from './virtual-user-formatter.js';
|
|
@@ -76,11 +77,7 @@ export const personaRun = pikkuSessionlessFunc({
|
|
|
76
77
|
if (refusal) {
|
|
77
78
|
throw new Error(refusal);
|
|
78
79
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!secret) {
|
|
81
|
-
throw new Error('SCENARIO_ACTOR_SECRET is not set — a virtual user cannot sign in. ' +
|
|
82
|
-
'Export it in the environment running this command (never put it in pikku.config.json).');
|
|
83
|
-
}
|
|
80
|
+
const credentials = await resolvePersonaCredentials(variables, 'a virtual user');
|
|
84
81
|
const resolvedModel = model ?? config.scenarios?.model;
|
|
85
82
|
if (!resolvedModel) {
|
|
86
83
|
throw new Error('No model to think with — pass --model, or set scenarios.model in pikku.config.json.');
|
|
@@ -115,7 +112,7 @@ export const personaRun = pikkuSessionlessFunc({
|
|
|
115
112
|
}
|
|
116
113
|
const signedIn = createHttpPersonas({
|
|
117
114
|
apiUrl: env.apiUrl,
|
|
118
|
-
|
|
115
|
+
...credentials,
|
|
119
116
|
personas,
|
|
120
117
|
signInPath: env.signInPath,
|
|
121
118
|
rpcPath: env.rpcPath,
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { ScenarioArtifact, ScenarioBrowserFailure, ScenarioBrowserProvider } from '@pikku/core/scenario';
|
|
11
11
|
import type { ResolvedPersona } from '@pikku/core/services';
|
|
12
|
+
import type { OperatorSignInOptions } from '@pikku/core/persona';
|
|
12
13
|
/** The default driver, used when a project names no other. */
|
|
13
14
|
export declare const DEFAULT_BROWSER_DRIVER = "@pikku/playwright";
|
|
14
15
|
export interface ScenarioBrowserDriverOptions {
|
|
15
|
-
secret
|
|
16
|
+
/** The actor secret, for a local `pikku dev` target. */
|
|
17
|
+
secret?: string;
|
|
18
|
+
/** Fabric operator credentials, for a deployed target. */
|
|
19
|
+
operator?: OperatorSignInOptions;
|
|
16
20
|
actors: Record<string, ResolvedPersona>;
|
|
17
21
|
signInPath?: string;
|
|
18
22
|
capture?: ScenarioCaptureOptions;
|
|
@@ -68,7 +72,10 @@ export interface ResolveScenarioBrowserProviderOptions {
|
|
|
68
72
|
appUrl?: string;
|
|
69
73
|
/** Base url per app, for a product whose personas sign into more than one. */
|
|
70
74
|
appUrls?: Record<string, string>;
|
|
71
|
-
secret
|
|
75
|
+
/** The actor secret, for a local `pikku dev` target. */
|
|
76
|
+
secret?: string;
|
|
77
|
+
/** Fabric operator credentials, for a deployed target. */
|
|
78
|
+
operator?: OperatorSignInOptions;
|
|
72
79
|
actors: Record<string, ResolvedPersona>;
|
|
73
80
|
signInPath?: string;
|
|
74
81
|
/**
|
|
@@ -96,7 +103,7 @@ export interface ResolveScenarioBrowserProviderOptions {
|
|
|
96
103
|
* because a run against a placeholder URL is worse than one that refuses to
|
|
97
104
|
* start.
|
|
98
105
|
*/
|
|
99
|
-
export declare const resolveScenarioBrowserProvider: ({ environment, apiUrl, appUrl, appUrls, secret, actors, signInPath, capture, browserScenarios, driver, importDriver, }: ResolveScenarioBrowserProviderOptions) => Promise<ScenarioBrowserProvider>;
|
|
106
|
+
export declare const resolveScenarioBrowserProvider: ({ environment, apiUrl, appUrl, appUrls, secret, operator, actors, signInPath, capture, browserScenarios, driver, importDriver, }: ResolveScenarioBrowserProviderOptions) => Promise<ScenarioBrowserProvider>;
|
|
100
107
|
/**
|
|
101
108
|
* The calls the run loop makes, safe against a run with no browser and against
|
|
102
109
|
* a driver that implements none of the optional members.
|
|
@@ -12,7 +12,7 @@ export const DEFAULT_BROWSER_DRIVER = '@pikku/playwright';
|
|
|
12
12
|
* because a run against a placeholder URL is worse than one that refuses to
|
|
13
13
|
* start.
|
|
14
14
|
*/
|
|
15
|
-
export const resolveScenarioBrowserProvider = async ({ environment, apiUrl, appUrl, appUrls, secret, actors, signInPath, capture, browserScenarios, driver = DEFAULT_BROWSER_DRIVER, importDriver = (specifier) => import(specifier), }) => {
|
|
15
|
+
export const resolveScenarioBrowserProvider = async ({ environment, apiUrl, appUrl, appUrls, secret, operator, actors, signInPath, capture, browserScenarios, driver = DEFAULT_BROWSER_DRIVER, importDriver = (specifier) => import(specifier), }) => {
|
|
16
16
|
const module = await importDriver(driver).catch(() => {
|
|
17
17
|
const install = driver === DEFAULT_BROWSER_DRIVER
|
|
18
18
|
? `Run 'yarn add -D ${driver} @playwright/test'`
|
|
@@ -41,6 +41,7 @@ export const resolveScenarioBrowserProvider = async ({ environment, apiUrl, appU
|
|
|
41
41
|
}
|
|
42
42
|
const options = {
|
|
43
43
|
secret,
|
|
44
|
+
operator,
|
|
44
45
|
actors,
|
|
45
46
|
signInPath,
|
|
46
47
|
capture,
|
|
@@ -12,6 +12,7 @@ import { collectScenarioStepProse, scenarioBrowserSteps, scenarioFailureFromStep
|
|
|
12
12
|
import { formatScenarioReport } from './scenario-formatter.js';
|
|
13
13
|
import { resolveScenarioBrowserProvider, scenarioBrowserLifecycle, } from './scenario-browser.js';
|
|
14
14
|
import { resolvePersonas } from '../../utils/resolve-personas.js';
|
|
15
|
+
import { resolvePersonaCredentials } from '../../utils/persona-credentials.js';
|
|
15
16
|
import { spawnDevServer } from '../../server/spawn-dev-server.js';
|
|
16
17
|
import { buildScenarioPlan } from './scenario-plan.js';
|
|
17
18
|
import { resolveEnvironment } from './environment.js';
|
|
@@ -165,18 +166,14 @@ export const scenarioRun = pikkuSessionlessFunc({
|
|
|
165
166
|
process.exitCode = 1;
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
|
-
const
|
|
169
|
-
if (!secret) {
|
|
170
|
-
throw new Error('SCENARIO_ACTOR_SECRET is not set — scenario actors cannot sign in. ' +
|
|
171
|
-
'Export it in the environment running this command (never put it in pikku.config.json).');
|
|
172
|
-
}
|
|
169
|
+
const credentials = await resolvePersonaCredentials(variables, 'scenario actors');
|
|
173
170
|
// Every declared persona, with its address filled in. Resolved once: the
|
|
174
171
|
// HTTP personas and the Playwright provider below must see the same
|
|
175
172
|
// registry, and codegen resolved the same way to type `PersonaName`.
|
|
176
173
|
const scenarioActors = resolvePersonas(state.personas?.definitions ?? [], config.scenarios?.emailDomain);
|
|
177
174
|
const actors = createHttpPersonas({
|
|
178
175
|
apiUrl: env.apiUrl,
|
|
179
|
-
|
|
176
|
+
...credentials,
|
|
180
177
|
personas: scenarioActors,
|
|
181
178
|
signInPath: env.signInPath,
|
|
182
179
|
rpcPath: env.rpcPath,
|
|
@@ -300,7 +297,7 @@ export const scenarioRun = pikkuSessionlessFunc({
|
|
|
300
297
|
apiUrl: env.apiUrl,
|
|
301
298
|
appUrl: env.appUrl,
|
|
302
299
|
appUrls: env.appUrls,
|
|
303
|
-
|
|
300
|
+
...credentials,
|
|
304
301
|
actors: scenarioActors,
|
|
305
302
|
signInPath: env.signInPath,
|
|
306
303
|
capture,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { VariablesService } from '@pikku/core/services';
|
|
2
|
+
import type { HttpPersonasConfig } from '@pikku/core/persona';
|
|
3
|
+
/** A Fabric operator token, which is what a deployed stage accepts. */
|
|
4
|
+
export declare const OPERATOR_TOKEN_VARIABLE = "FABRIC_OPERATOR_TOKEN";
|
|
5
|
+
/** The actor plugin's passwordless secret, which only `pikku dev` serves. */
|
|
6
|
+
export declare const ACTOR_SECRET_VARIABLE = "SCENARIO_ACTOR_SECRET";
|
|
7
|
+
/** Opt in to creating persona accounts the target does not already have. */
|
|
8
|
+
export declare const CREATE_MISSING_VARIABLE = "PIKKU_PERSONA_CREATE_MISSING";
|
|
9
|
+
export type PersonaCredentials = Pick<HttpPersonasConfig, 'secret' | 'operator'>;
|
|
10
|
+
/**
|
|
11
|
+
* How the personas in this run will sign in, decided by which credential the
|
|
12
|
+
* environment actually holds.
|
|
13
|
+
*
|
|
14
|
+
* An operator token wins when both are present. It is the stronger of the two —
|
|
15
|
+
* asymmetric, and it never needs an account the target would not otherwise
|
|
16
|
+
* have — so a run that could use either should not fall back to the weaker one.
|
|
17
|
+
*
|
|
18
|
+
* `what` names the thing that cannot proceed ('scenario actors', 'a virtual
|
|
19
|
+
* user'), because the same missing credential blocks several commands and the
|
|
20
|
+
* message should say which one the operator was running.
|
|
21
|
+
*/
|
|
22
|
+
export declare const resolvePersonaCredentials: (variables: VariablesService, what: string) => Promise<PersonaCredentials>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** A Fabric operator token, which is what a deployed stage accepts. */
|
|
2
|
+
export const OPERATOR_TOKEN_VARIABLE = 'FABRIC_OPERATOR_TOKEN';
|
|
3
|
+
/** The actor plugin's passwordless secret, which only `pikku dev` serves. */
|
|
4
|
+
export const ACTOR_SECRET_VARIABLE = 'SCENARIO_ACTOR_SECRET';
|
|
5
|
+
/** Opt in to creating persona accounts the target does not already have. */
|
|
6
|
+
export const CREATE_MISSING_VARIABLE = 'PIKKU_PERSONA_CREATE_MISSING';
|
|
7
|
+
/**
|
|
8
|
+
* How the personas in this run will sign in, decided by which credential the
|
|
9
|
+
* environment actually holds.
|
|
10
|
+
*
|
|
11
|
+
* An operator token wins when both are present. It is the stronger of the two —
|
|
12
|
+
* asymmetric, and it never needs an account the target would not otherwise
|
|
13
|
+
* have — so a run that could use either should not fall back to the weaker one.
|
|
14
|
+
*
|
|
15
|
+
* `what` names the thing that cannot proceed ('scenario actors', 'a virtual
|
|
16
|
+
* user'), because the same missing credential blocks several commands and the
|
|
17
|
+
* message should say which one the operator was running.
|
|
18
|
+
*/
|
|
19
|
+
export const resolvePersonaCredentials = async (variables, what) => {
|
|
20
|
+
const token = await variables.get(OPERATOR_TOKEN_VARIABLE);
|
|
21
|
+
if (token) {
|
|
22
|
+
const createMissing = (await variables.get(CREATE_MISSING_VARIABLE)) === 'true';
|
|
23
|
+
return { operator: { token, createMissing } };
|
|
24
|
+
}
|
|
25
|
+
const secret = await variables.get(ACTOR_SECRET_VARIABLE);
|
|
26
|
+
if (secret) {
|
|
27
|
+
return { secret };
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Neither ${OPERATOR_TOKEN_VARIABLE} nor ${ACTOR_SECRET_VARIABLE} is set — ${what} cannot sign in. ` +
|
|
30
|
+
`Export ${ACTOR_SECRET_VARIABLE} against a local \`pikku dev\` target, or ` +
|
|
31
|
+
`${OPERATOR_TOKEN_VARIABLE} against a deployed one (never put either in pikku.config.json).`);
|
|
32
|
+
};
|