@meistrari/tela-cli 1.9.4 → 1.9.5
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/commands/ingredients.js +1 -1
- package/dist/index.js +27 -16
- package/dist/session.d.ts +1 -1
- package/dist/session.js +21 -9
- package/package.json +1 -1
|
@@ -138,7 +138,7 @@ async function callIngredientApi(args, _options, io) {
|
|
|
138
138
|
const { client, baseUrl } = await (0, session_1.loadPantryForContext)(targetSession.resolved);
|
|
139
139
|
const ingredient = (0, tela_pantry_1.assertIngredientType)(await (0, tela_pantry_1.fetchServiceIngredient)(client, slug, baseUrl), 'api');
|
|
140
140
|
const { inventory } = await (0, tela_local_config_1.loadInventory)((0, tela_local_config_1.getTelaLocalPaths)().inventoryFile);
|
|
141
|
-
const environment = (0, tela_pantry_1.resolveServiceEnvironment)(ingredient, inventory.services.environmentDefaults, flags.serviceEnv);
|
|
141
|
+
const environment = (0, tela_pantry_1.resolveServiceEnvironment)(ingredient, inventory.services.environmentDefaults, flags.serviceEnv, targetSession.resolved.context.environmentId);
|
|
142
142
|
if (!environment) {
|
|
143
143
|
return usageError(`Ingredient '${slug}' has no environments configured.`, io);
|
|
144
144
|
}
|
package/dist/index.js
CHANGED
|
@@ -62061,7 +62061,7 @@ var require_environments = __commonJS({
|
|
|
62061
62061
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
62062
62062
|
exports2.resolveServiceEnvironment = resolveServiceEnvironment2;
|
|
62063
62063
|
var FALLBACK_ORDER = ["tooling", "production", "staging", "development"];
|
|
62064
|
-
function resolveServiceEnvironment2(ingredient, environmentDefaults, override) {
|
|
62064
|
+
function resolveServiceEnvironment2(ingredient, environmentDefaults, override, preferred) {
|
|
62065
62065
|
const environments = ingredient.environments;
|
|
62066
62066
|
if (override) {
|
|
62067
62067
|
const found = environments.find((environment) => environment.slug === override);
|
|
@@ -62081,8 +62081,9 @@ var require_environments = __commonJS({
|
|
|
62081
62081
|
if (found)
|
|
62082
62082
|
return found;
|
|
62083
62083
|
}
|
|
62084
|
-
|
|
62085
|
-
|
|
62084
|
+
const order = preferred ? [preferred] : FALLBACK_ORDER;
|
|
62085
|
+
for (const slug of order) {
|
|
62086
|
+
const found = environments.find((environment) => environment.slug === slug);
|
|
62086
62087
|
if (found)
|
|
62087
62088
|
return found;
|
|
62088
62089
|
}
|
|
@@ -388063,6 +388064,7 @@ function terminalWidth(target) {
|
|
|
388063
388064
|
// src/session.ts
|
|
388064
388065
|
var import_tela_local_config6 = __toESM(require_dist());
|
|
388065
388066
|
var import_tela_pantry = __toESM(require_dist2());
|
|
388067
|
+
var PANTRY_ENVIRONMENT_ID = "production";
|
|
388066
388068
|
var ENV_ACCESS_TOKEN_REF = {
|
|
388067
388069
|
provider: "env",
|
|
388068
388070
|
service: "env",
|
|
@@ -388079,7 +388081,7 @@ async function loadPantry(flags) {
|
|
|
388079
388081
|
}
|
|
388080
388082
|
async function loadPantryForContext(resolved, config2) {
|
|
388081
388083
|
const loadedConfig = config2 ?? await (0, import_tela_local_config6.loadConfig)();
|
|
388082
|
-
const baseUrl = resolvePantryBaseUrl(
|
|
388084
|
+
const baseUrl = resolvePantryBaseUrl(loadedConfig);
|
|
388083
388085
|
const credential = await loadPantryCredential(loadedConfig, resolved);
|
|
388084
388086
|
return { client: (0, import_tela_pantry.createPantryClient)(baseUrl, credential), baseUrl };
|
|
388085
388087
|
}
|
|
@@ -388096,7 +388098,7 @@ async function loadPantryCredential(config2, selected) {
|
|
|
388096
388098
|
return credential;
|
|
388097
388099
|
}
|
|
388098
388100
|
throw new Error(
|
|
388099
|
-
`Pantry discovery requires a user-session access token for Tela environment '${
|
|
388101
|
+
`Pantry discovery requires a user-session access token for Tela environment '${PANTRY_ENVIRONMENT_ID}'. Run \`tela auth login --environment ${PANTRY_ENVIRONMENT_ID}\` or set TELA_ACCESS_TOKEN.`
|
|
388100
388102
|
);
|
|
388101
388103
|
}
|
|
388102
388104
|
function pantryCredentialCandidates(config2, selected) {
|
|
@@ -388106,19 +388108,19 @@ function pantryCredentialCandidates(config2, selected) {
|
|
|
388106
388108
|
if (!contextId || seen.has(contextId))
|
|
388107
388109
|
return;
|
|
388108
388110
|
const context = config2.contexts[contextId];
|
|
388109
|
-
if (!context || context.environmentId !==
|
|
388111
|
+
if (!context || context.environmentId !== PANTRY_ENVIRONMENT_ID)
|
|
388110
388112
|
return;
|
|
388111
388113
|
if (context.credentialRef.kind !== "user-session")
|
|
388112
388114
|
return;
|
|
388113
|
-
const
|
|
388114
|
-
if (!
|
|
388115
|
+
const environment2 = config2.environments[context.environmentId];
|
|
388116
|
+
if (!environment2)
|
|
388115
388117
|
return;
|
|
388116
388118
|
seen.add(contextId);
|
|
388117
388119
|
candidates.push({
|
|
388118
388120
|
resolved: {
|
|
388119
388121
|
id: contextId,
|
|
388120
388122
|
context,
|
|
388121
|
-
environment
|
|
388123
|
+
environment: environment2
|
|
388122
388124
|
},
|
|
388123
388125
|
credentialRef: context.credentialRef
|
|
388124
388126
|
});
|
|
@@ -388128,7 +388130,17 @@ function pantryCredentialCandidates(config2, selected) {
|
|
|
388128
388130
|
addContext(config2.activeContextId);
|
|
388129
388131
|
for (const contextId of Object.keys(config2.contexts))
|
|
388130
388132
|
addContext(contextId);
|
|
388131
|
-
|
|
388133
|
+
const environment = config2.environments[PANTRY_ENVIRONMENT_ID];
|
|
388134
|
+
if (environment) {
|
|
388135
|
+
candidates.push({
|
|
388136
|
+
resolved: {
|
|
388137
|
+
...selected,
|
|
388138
|
+
context: { ...selected.context, environmentId: PANTRY_ENVIRONMENT_ID },
|
|
388139
|
+
environment
|
|
388140
|
+
},
|
|
388141
|
+
credentialRef: ENV_ACCESS_TOKEN_REF
|
|
388142
|
+
});
|
|
388143
|
+
}
|
|
388132
388144
|
return candidates;
|
|
388133
388145
|
}
|
|
388134
388146
|
async function loadSession(contextId, environmentId) {
|
|
@@ -388147,13 +388159,11 @@ async function loadSession(contextId, environmentId) {
|
|
|
388147
388159
|
refreshed: credential !== originalCredential
|
|
388148
388160
|
};
|
|
388149
388161
|
}
|
|
388150
|
-
function resolvePantryBaseUrl(
|
|
388151
|
-
const baseUrl =
|
|
388162
|
+
function resolvePantryBaseUrl(config2) {
|
|
388163
|
+
const baseUrl = config2.environments[PANTRY_ENVIRONMENT_ID]?.services.pantry;
|
|
388152
388164
|
if (baseUrl)
|
|
388153
388165
|
return baseUrl;
|
|
388154
|
-
throw new Error(
|
|
388155
|
-
`Tela environment '${resolved.context.environmentId}' does not configure a Pantry service URL. Select a context whose environment defines services.pantry.`
|
|
388156
|
-
);
|
|
388166
|
+
throw new Error(`Tela environment '${PANTRY_ENVIRONMENT_ID}' does not configure a Pantry service URL (services.pantry).`);
|
|
388157
388167
|
}
|
|
388158
388168
|
|
|
388159
388169
|
// src/commands/ingredients.ts
|
|
@@ -388275,7 +388285,8 @@ async function callIngredientApi(args, _options, io) {
|
|
|
388275
388285
|
const environment = (0, import_tela_pantry2.resolveServiceEnvironment)(
|
|
388276
388286
|
ingredient,
|
|
388277
388287
|
inventory.services.environmentDefaults,
|
|
388278
|
-
flags.serviceEnv
|
|
388288
|
+
flags.serviceEnv,
|
|
388289
|
+
targetSession.resolved.context.environmentId
|
|
388279
388290
|
);
|
|
388280
388291
|
if (!environment) {
|
|
388281
388292
|
return usageError(`Ingredient '${slug}' has no environments configured.`, io);
|
package/dist/session.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ export type PantrySession = {
|
|
|
25
25
|
export declare function loadPantry(flags: CatalogFlags): Promise<PantrySession>;
|
|
26
26
|
export declare function loadPantryForContext(resolved: ResolvedContext, config?: TelaLocalConfig): Promise<PantrySession>;
|
|
27
27
|
export declare function loadSession(contextId?: string, environmentId?: string): Promise<Session>;
|
|
28
|
-
export declare function resolvePantryBaseUrl(
|
|
28
|
+
export declare function resolvePantryBaseUrl(config: TelaLocalConfig): string;
|
package/dist/session.js
CHANGED
|
@@ -8,6 +8,9 @@ const refresh_session_1 = require("./refresh-session");
|
|
|
8
8
|
const tela_local_config_1 = require("@meistrari/tela-local-config");
|
|
9
9
|
const tela_pantry_1 = require("@meistrari/tela-pantry");
|
|
10
10
|
const credentials_1 = require("./credentials");
|
|
11
|
+
// Pantry only runs in Production. Other environments still pick the credential
|
|
12
|
+
// and service environment a command targets, never where the catalog lives.
|
|
13
|
+
const PANTRY_ENVIRONMENT_ID = 'production';
|
|
11
14
|
const ENV_ACCESS_TOKEN_REF = {
|
|
12
15
|
provider: 'env',
|
|
13
16
|
service: 'env',
|
|
@@ -31,7 +34,7 @@ async function loadPantry(flags) {
|
|
|
31
34
|
}
|
|
32
35
|
async function loadPantryForContext(resolved, config) {
|
|
33
36
|
const loadedConfig = config ?? await (0, tela_local_config_1.loadConfig)();
|
|
34
|
-
const baseUrl = resolvePantryBaseUrl(
|
|
37
|
+
const baseUrl = resolvePantryBaseUrl(loadedConfig);
|
|
35
38
|
const credential = await loadPantryCredential(loadedConfig, resolved);
|
|
36
39
|
return { client: (0, tela_pantry_1.createPantryClient)(baseUrl, credential), baseUrl };
|
|
37
40
|
}
|
|
@@ -49,8 +52,8 @@ async function loadPantryCredential(config, selected) {
|
|
|
49
52
|
if (credential.accessToken)
|
|
50
53
|
return credential;
|
|
51
54
|
}
|
|
52
|
-
throw new Error(`Pantry discovery requires a user-session access token for Tela environment '${
|
|
53
|
-
+
|
|
55
|
+
throw new Error(`Pantry discovery requires a user-session access token for Tela environment '${PANTRY_ENVIRONMENT_ID}'. `
|
|
56
|
+
+ `Run \`tela auth login --environment ${PANTRY_ENVIRONMENT_ID}\` or set TELA_ACCESS_TOKEN.`);
|
|
54
57
|
}
|
|
55
58
|
function pantryCredentialCandidates(config, selected) {
|
|
56
59
|
const candidates = [];
|
|
@@ -59,7 +62,7 @@ function pantryCredentialCandidates(config, selected) {
|
|
|
59
62
|
if (!contextId || seen.has(contextId))
|
|
60
63
|
return;
|
|
61
64
|
const context = config.contexts[contextId];
|
|
62
|
-
if (!context || context.environmentId !==
|
|
65
|
+
if (!context || context.environmentId !== PANTRY_ENVIRONMENT_ID)
|
|
63
66
|
return;
|
|
64
67
|
if (context.credentialRef.kind !== 'user-session')
|
|
65
68
|
return;
|
|
@@ -81,7 +84,17 @@ function pantryCredentialCandidates(config, selected) {
|
|
|
81
84
|
addContext(config.activeContextId);
|
|
82
85
|
for (const contextId of Object.keys(config.contexts))
|
|
83
86
|
addContext(contextId);
|
|
84
|
-
|
|
87
|
+
const environment = config.environments[PANTRY_ENVIRONMENT_ID];
|
|
88
|
+
if (environment) {
|
|
89
|
+
candidates.push({
|
|
90
|
+
resolved: {
|
|
91
|
+
...selected,
|
|
92
|
+
context: { ...selected.context, environmentId: PANTRY_ENVIRONMENT_ID },
|
|
93
|
+
environment,
|
|
94
|
+
},
|
|
95
|
+
credentialRef: ENV_ACCESS_TOKEN_REF,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
85
98
|
return candidates;
|
|
86
99
|
}
|
|
87
100
|
async function loadSession(contextId, environmentId) {
|
|
@@ -102,10 +115,9 @@ async function loadSession(contextId, environmentId) {
|
|
|
102
115
|
refreshed: credential !== originalCredential,
|
|
103
116
|
};
|
|
104
117
|
}
|
|
105
|
-
function resolvePantryBaseUrl(
|
|
106
|
-
const baseUrl =
|
|
118
|
+
function resolvePantryBaseUrl(config) {
|
|
119
|
+
const baseUrl = config.environments[PANTRY_ENVIRONMENT_ID]?.services.pantry;
|
|
107
120
|
if (baseUrl)
|
|
108
121
|
return baseUrl;
|
|
109
|
-
throw new Error(`Tela environment '${
|
|
110
|
-
+ 'Select a context whose environment defines services.pantry.');
|
|
122
|
+
throw new Error(`Tela environment '${PANTRY_ENVIRONMENT_ID}' does not configure a Pantry service URL (services.pantry).`);
|
|
111
123
|
}
|