@ductape/sdk 0.1.133 → 0.1.135
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/api/services/productsApi.service.js +0 -2
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/functions/functions.runtime.d.ts +6 -1
- package/dist/functions/functions.runtime.js +79 -48
- package/dist/functions/functions.runtime.js.map +1 -1
- package/dist/functions/types.d.ts +24 -1
- package/dist/functions/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/processor/services/processor.service.js +7 -0
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/products/services/products.service.d.ts +5 -0
- package/dist/products/services/products.service.js +73 -35
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -470,6 +470,11 @@ export default class ProductsBuilderService implements IProductsBuilderService {
|
|
|
470
470
|
private validateAppData;
|
|
471
471
|
private validateVariablesSchema;
|
|
472
472
|
private validateVariablesValues;
|
|
473
|
+
/**
|
|
474
|
+
* base_url placeholders ({{key}} / :key) are syntactically required for the URL to resolve
|
|
475
|
+
* to something requestable — unlike custom app variables, there is no "optional" case here.
|
|
476
|
+
*/
|
|
477
|
+
private validateBaseUrlVariablesRequired;
|
|
473
478
|
private validateAppEnvs;
|
|
474
479
|
private validateAppAuth;
|
|
475
480
|
createAppAccessTag(app_tag: string, known_app_id?: string): Promise<IAppAccess>;
|
|
@@ -144,9 +144,10 @@ class ProductsBuilderService {
|
|
|
144
144
|
}
|
|
145
145
|
const event = version.actions.find((act) => act.tag === action);
|
|
146
146
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
147
|
+
var _a, _b, _c;
|
|
147
148
|
const exists = await this.fetchEnv(env.slug);
|
|
148
149
|
if (!exists) {
|
|
149
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
150
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
150
151
|
}
|
|
151
152
|
await this.validateActionDataInput({ input: env.input }, event, env.input, 0, 0);
|
|
152
153
|
env.input = (0, processor_utils_1.encrypt)(JSON.stringify(env.input), this.product.private_key);
|
|
@@ -203,9 +204,10 @@ class ProductsBuilderService {
|
|
|
203
204
|
// 4. Validate and process envs
|
|
204
205
|
if (data.envs) {
|
|
205
206
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
207
|
+
var _a, _b, _c;
|
|
206
208
|
const exists = await this.fetchEnv(env.slug);
|
|
207
209
|
if (!exists) {
|
|
208
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
210
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
209
211
|
}
|
|
210
212
|
// Validate input if present
|
|
211
213
|
if (env.input) {
|
|
@@ -345,7 +347,7 @@ class ProductsBuilderService {
|
|
|
345
347
|
* Every environment carries an explicit payload, including `{}` for actions with no inputs.
|
|
346
348
|
*/
|
|
347
349
|
async validateAppHealthcheckSchema(schema) {
|
|
348
|
-
var _a, _b, _c, _d;
|
|
350
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
349
351
|
const probe = schema.probe;
|
|
350
352
|
const probeType = (_a = probe === null || probe === void 0 ? void 0 : probe.type) !== null && _a !== void 0 ? _a : ((probe === null || probe === void 0 ? void 0 : probe.app) || schema.app ? 'app' : undefined);
|
|
351
353
|
if (probeType !== 'app')
|
|
@@ -372,9 +374,9 @@ class ProductsBuilderService {
|
|
|
372
374
|
}
|
|
373
375
|
for (const env of schema.envs || []) {
|
|
374
376
|
if (!(await this.fetchEnv(env.slug))) {
|
|
375
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
377
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_f = (_e = (_d = this.product) === null || _d === void 0 ? void 0 : _d.tag) !== null && _e !== void 0 ? _e : this.product_id) !== null && _f !== void 0 ? _f : 'unknown'}"`);
|
|
376
378
|
}
|
|
377
|
-
const payload = (
|
|
379
|
+
const payload = (_g = env.input) !== null && _g !== void 0 ? _g : probe === null || probe === void 0 ? void 0 : probe.input;
|
|
378
380
|
if (payload == null) {
|
|
379
381
|
throw new Error(`App healthcheck "${schema.tag}" requires an input payload for env ${env.slug}; use {} when the action has no inputs`);
|
|
380
382
|
}
|
|
@@ -1489,9 +1491,7 @@ class ProductsBuilderService {
|
|
|
1489
1491
|
return components;
|
|
1490
1492
|
}
|
|
1491
1493
|
async fetchEnv(slug, refresh = false) {
|
|
1492
|
-
console.log("CHAMO!!!!", { slug, refresh });
|
|
1493
1494
|
if (!refresh && this.product_id && this.envCache.has(slug)) {
|
|
1494
|
-
console.log("CHAMO!!!!", { cached: this.envCache.get(slug) });
|
|
1495
1495
|
return this.envCache.get(slug);
|
|
1496
1496
|
}
|
|
1497
1497
|
const component = await this.productApi.fetchProductComponentByTag(this.product_id, 'env', slug, this.getUserAccess());
|
|
@@ -1521,7 +1521,7 @@ class ProductsBuilderService {
|
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
1523
|
async createMessageBroker(data, throwErrorIfExists = false) {
|
|
1524
|
-
var _a;
|
|
1524
|
+
var _a, _b, _c, _d;
|
|
1525
1525
|
const logPrefix = '[MessageBroker:Create]';
|
|
1526
1526
|
console.log(`${logPrefix} Starting creation for broker: ${data.tag}`);
|
|
1527
1527
|
console.log(`${logPrefix} Broker name: ${data.name}`);
|
|
@@ -1544,7 +1544,7 @@ class ProductsBuilderService {
|
|
|
1544
1544
|
const exists = await this.fetchEnv(env.slug);
|
|
1545
1545
|
if (!exists) {
|
|
1546
1546
|
console.error(`${logPrefix} Env ${env.slug} does not exist`);
|
|
1547
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
1547
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_d = (_c = (_b = this.product) === null || _b === void 0 ? void 0 : _b.tag) !== null && _c !== void 0 ? _c : this.product_id) !== null && _d !== void 0 ? _d : 'unknown'}"`);
|
|
1548
1548
|
}
|
|
1549
1549
|
console.log(`${logPrefix} Env ${env.slug} exists, verified`);
|
|
1550
1550
|
const isProvisioning = env.provisionStatus === 'provisioning';
|
|
@@ -1591,7 +1591,7 @@ class ProductsBuilderService {
|
|
|
1591
1591
|
}
|
|
1592
1592
|
}
|
|
1593
1593
|
async updateMessageBroker(tag, data) {
|
|
1594
|
-
var _a, _b;
|
|
1594
|
+
var _a, _b, _c, _d, _e;
|
|
1595
1595
|
const logPrefix = '[MessageBroker:Update]';
|
|
1596
1596
|
console.log(`${logPrefix} Starting update for broker: ${tag}`);
|
|
1597
1597
|
console.log(`${logPrefix} New tag (if changed): ${data.tag || 'unchanged'}`);
|
|
@@ -1631,7 +1631,7 @@ class ProductsBuilderService {
|
|
|
1631
1631
|
const exists = await this.fetchEnv(env.slug);
|
|
1632
1632
|
if (!exists) {
|
|
1633
1633
|
console.error(`${logPrefix} Env ${env.slug} does not exist`);
|
|
1634
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
1634
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_e = (_d = (_c = this.product) === null || _c === void 0 ? void 0 : _c.tag) !== null && _d !== void 0 ? _d : this.product_id) !== null && _e !== void 0 ? _e : 'unknown'}"`);
|
|
1635
1635
|
}
|
|
1636
1636
|
console.log(`${logPrefix} Env ${env.slug} exists, verified`);
|
|
1637
1637
|
if (env.config) {
|
|
@@ -1787,6 +1787,7 @@ class ProductsBuilderService {
|
|
|
1787
1787
|
}
|
|
1788
1788
|
}
|
|
1789
1789
|
async createStorage(data, throwErrorIfExists = false) {
|
|
1790
|
+
var _a, _b, _c;
|
|
1790
1791
|
if (!(await this.fetchStorage(data.tag))) {
|
|
1791
1792
|
const auth = this.getUserAccess();
|
|
1792
1793
|
const cloudApi = new cloudApi_service_1.CloudApiService(this.env_type);
|
|
@@ -1797,7 +1798,7 @@ class ProductsBuilderService {
|
|
|
1797
1798
|
for (const env of data.envs) {
|
|
1798
1799
|
const exists = await this.fetchEnv(env.slug);
|
|
1799
1800
|
if (!exists) {
|
|
1800
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
1801
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
1801
1802
|
}
|
|
1802
1803
|
if (env.type === productsBuilder_types_1.StorageProviders.GCP) {
|
|
1803
1804
|
// @ts-ignore
|
|
@@ -1848,9 +1849,10 @@ class ProductsBuilderService {
|
|
|
1848
1849
|
await create_productStorage_validator_1.UpdateProductStorageSchema.validateAsync(data);
|
|
1849
1850
|
if (data.envs && data.envs.length > 0) {
|
|
1850
1851
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
1852
|
+
var _a, _b, _c;
|
|
1851
1853
|
const exists = await this.fetchEnv(env.slug);
|
|
1852
1854
|
if (!exists) {
|
|
1853
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
1855
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
1854
1856
|
}
|
|
1855
1857
|
if (env.type === productsBuilder_types_1.StorageProviders.GCP) {
|
|
1856
1858
|
// @ts-ignore
|
|
@@ -1949,7 +1951,7 @@ class ProductsBuilderService {
|
|
|
1949
1951
|
* @param throwErrorIfExists Whether to throw error if vector config already exists
|
|
1950
1952
|
*/
|
|
1951
1953
|
async createVector(data, throwErrorIfExists = false) {
|
|
1952
|
-
var _a, _b, _c, _d;
|
|
1954
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1953
1955
|
console.log('[ProductsService.createVector] Starting vector creation:', {
|
|
1954
1956
|
tag: data.tag,
|
|
1955
1957
|
name: data.name,
|
|
@@ -1974,7 +1976,7 @@ class ProductsBuilderService {
|
|
|
1974
1976
|
});
|
|
1975
1977
|
const exists = await this.fetchEnv(env.slug, true);
|
|
1976
1978
|
if (!exists) {
|
|
1977
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
1979
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_e = (_d = (_c = this.product) === null || _c === void 0 ? void 0 : _c.tag) !== null && _d !== void 0 ? _d : this.product_id) !== null && _e !== void 0 ? _e : 'unknown'}"`);
|
|
1978
1980
|
}
|
|
1979
1981
|
if (env.apiKey) {
|
|
1980
1982
|
console.log('[ProductsService.createVector] Converting API key to secret for env:', env.slug);
|
|
@@ -1982,7 +1984,7 @@ class ProductsBuilderService {
|
|
|
1982
1984
|
env.apiKey = await this.storeVectorApiKeyAsSecret(env.apiKey, data.tag, env.slug);
|
|
1983
1985
|
console.log('[ProductsService.createVector] API key after secret conversion:', {
|
|
1984
1986
|
wasConverted: originalApiKey !== env.apiKey,
|
|
1985
|
-
isSecretRef: (
|
|
1987
|
+
isSecretRef: (_f = env.apiKey) === null || _f === void 0 ? void 0 : _f.startsWith('$Secret{'),
|
|
1986
1988
|
});
|
|
1987
1989
|
env.apiKey = (0, processor_utils_1.encrypt)(env.apiKey, this.product.private_key);
|
|
1988
1990
|
console.log('[ProductsService.createVector] API key encrypted');
|
|
@@ -1994,7 +1996,7 @@ class ProductsBuilderService {
|
|
|
1994
1996
|
env.endpoint = await this.storeVectorEndpointAsSecret(env.endpoint, data.tag, env.slug);
|
|
1995
1997
|
console.log('[ProductsService.createVector] Endpoint after secret conversion:', {
|
|
1996
1998
|
wasConverted: originalEndpoint !== env.endpoint,
|
|
1997
|
-
isSecretRef: (
|
|
1999
|
+
isSecretRef: (_g = env.endpoint) === null || _g === void 0 ? void 0 : _g.startsWith('$Secret{'),
|
|
1998
2000
|
});
|
|
1999
2001
|
env.endpoint = (0, processor_utils_1.encrypt)(env.endpoint, this.product.private_key);
|
|
2000
2002
|
console.log('[ProductsService.createVector] Endpoint encrypted');
|
|
@@ -2056,7 +2058,7 @@ class ProductsBuilderService {
|
|
|
2056
2058
|
const cloudApi = new cloudApi_service_1.CloudApiService(this.env_type);
|
|
2057
2059
|
const productTag = this.product.tag;
|
|
2058
2060
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
2059
|
-
var _a, _b;
|
|
2061
|
+
var _a, _b, _c, _d, _e;
|
|
2060
2062
|
const materialized = await (0, cloud_vector_link_util_1.materializeCloudLinkedVectorEnv)(env, {
|
|
2061
2063
|
cloudApi,
|
|
2062
2064
|
auth,
|
|
@@ -2070,7 +2072,7 @@ class ProductsBuilderService {
|
|
|
2070
2072
|
});
|
|
2071
2073
|
const exists = await this.fetchEnv(materialized.slug);
|
|
2072
2074
|
if (!exists) {
|
|
2073
|
-
throw new Error(`Env ${materialized.slug} does not exist`);
|
|
2075
|
+
throw new Error(`Env "${materialized.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
2074
2076
|
}
|
|
2075
2077
|
// Store API key as secret and encrypt
|
|
2076
2078
|
if (materialized.apiKey) {
|
|
@@ -2079,7 +2081,7 @@ class ProductsBuilderService {
|
|
|
2079
2081
|
materialized.apiKey = await this.storeVectorApiKeyAsSecret(materialized.apiKey, data.tag || tag, materialized.slug);
|
|
2080
2082
|
console.log('[ProductsService.updateVector] API key after secret conversion:', {
|
|
2081
2083
|
wasConverted: originalApiKey !== materialized.apiKey,
|
|
2082
|
-
isSecretRef: (
|
|
2084
|
+
isSecretRef: (_d = materialized.apiKey) === null || _d === void 0 ? void 0 : _d.startsWith('$Secret{'),
|
|
2083
2085
|
});
|
|
2084
2086
|
materialized.apiKey = (0, processor_utils_1.encrypt)(materialized.apiKey, this.product.private_key);
|
|
2085
2087
|
console.log('[ProductsService.updateVector] API key encrypted');
|
|
@@ -2091,7 +2093,7 @@ class ProductsBuilderService {
|
|
|
2091
2093
|
materialized.endpoint = await this.storeVectorEndpointAsSecret(materialized.endpoint, data.tag || tag, materialized.slug);
|
|
2092
2094
|
console.log('[ProductsService.updateVector] Endpoint after secret conversion:', {
|
|
2093
2095
|
wasConverted: originalEndpoint !== materialized.endpoint,
|
|
2094
|
-
isSecretRef: (
|
|
2096
|
+
isSecretRef: (_e = materialized.endpoint) === null || _e === void 0 ? void 0 : _e.startsWith('$Secret{'),
|
|
2095
2097
|
});
|
|
2096
2098
|
materialized.endpoint = (0, processor_utils_1.encrypt)(materialized.endpoint, this.product.private_key);
|
|
2097
2099
|
console.log('[ProductsService.updateVector] Endpoint encrypted');
|
|
@@ -2343,6 +2345,7 @@ class ProductsBuilderService {
|
|
|
2343
2345
|
* @param throwErrorIfExists Whether to throw an error if agent already exists
|
|
2344
2346
|
*/
|
|
2345
2347
|
async createAgent(data, throwErrorIfExists = false) {
|
|
2348
|
+
var _a, _b, _c;
|
|
2346
2349
|
if (!(await this.fetchAgent(data.tag))) {
|
|
2347
2350
|
await validators_1.CreateProductAgentSchema.validateAsync(data);
|
|
2348
2351
|
// Validate envs if provided
|
|
@@ -2350,7 +2353,7 @@ class ProductsBuilderService {
|
|
|
2350
2353
|
for (const env of data.envs) {
|
|
2351
2354
|
const exists = await this.fetchEnv(env.slug);
|
|
2352
2355
|
if (!exists) {
|
|
2353
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
2356
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
2354
2357
|
}
|
|
2355
2358
|
}
|
|
2356
2359
|
}
|
|
@@ -2382,6 +2385,7 @@ class ProductsBuilderService {
|
|
|
2382
2385
|
* @param data Updated agent configuration
|
|
2383
2386
|
*/
|
|
2384
2387
|
async updateAgent(tag, data) {
|
|
2388
|
+
var _a, _b, _c;
|
|
2385
2389
|
try {
|
|
2386
2390
|
const agent = await this.fetchAgent(tag);
|
|
2387
2391
|
if (!agent) {
|
|
@@ -2397,7 +2401,7 @@ class ProductsBuilderService {
|
|
|
2397
2401
|
for (const env of data.envs) {
|
|
2398
2402
|
const exists = await this.fetchEnv(env.slug);
|
|
2399
2403
|
if (!exists) {
|
|
2400
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
2404
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
2401
2405
|
}
|
|
2402
2406
|
}
|
|
2403
2407
|
const overwrite = [];
|
|
@@ -2473,13 +2477,14 @@ class ProductsBuilderService {
|
|
|
2473
2477
|
* @param throwErrorIfExists Whether to throw error if model already exists
|
|
2474
2478
|
*/
|
|
2475
2479
|
async createModel(data, throwErrorIfExists = false) {
|
|
2480
|
+
var _a, _b, _c;
|
|
2476
2481
|
if (!(await this.fetchModel(data.tag))) {
|
|
2477
2482
|
await validators_1.CreateProductModelSchema.validateAsync(data);
|
|
2478
2483
|
const processedEnvs = [];
|
|
2479
2484
|
for (const env of data.envs) {
|
|
2480
2485
|
const exists = await this.fetchEnv(env.slug);
|
|
2481
2486
|
if (!exists) {
|
|
2482
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
2487
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
2483
2488
|
}
|
|
2484
2489
|
// Store API key as secret and encrypt
|
|
2485
2490
|
if (env.apiKey) {
|
|
@@ -2521,9 +2526,10 @@ class ProductsBuilderService {
|
|
|
2521
2526
|
}
|
|
2522
2527
|
if (data.envs) {
|
|
2523
2528
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
2529
|
+
var _a, _b, _c;
|
|
2524
2530
|
const exists = await this.fetchEnv(env.slug);
|
|
2525
2531
|
if (!exists) {
|
|
2526
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
2532
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
2527
2533
|
}
|
|
2528
2534
|
// Store API key as secret and encrypt
|
|
2529
2535
|
if (env.apiKey) {
|
|
@@ -2635,6 +2641,25 @@ class ProductsBuilderService {
|
|
|
2635
2641
|
this.inputsService.validateFeatureInputData(find, data);
|
|
2636
2642
|
});
|
|
2637
2643
|
}
|
|
2644
|
+
/**
|
|
2645
|
+
* base_url placeholders ({{key}} / :key) are syntactically required for the URL to resolve
|
|
2646
|
+
* to something requestable — unlike custom app variables, there is no "optional" case here.
|
|
2647
|
+
*/
|
|
2648
|
+
validateBaseUrlVariablesRequired(variables, baseUrlVariableKeys) {
|
|
2649
|
+
if (!(baseUrlVariableKeys === null || baseUrlVariableKeys === void 0 ? void 0 : baseUrlVariableKeys.length))
|
|
2650
|
+
return;
|
|
2651
|
+
const provided = new Map((variables !== null && variables !== void 0 ? variables : []).map((v) => [v.key, v.value]));
|
|
2652
|
+
const missing = baseUrlVariableKeys
|
|
2653
|
+
.map((v) => v.key)
|
|
2654
|
+
.filter((key) => {
|
|
2655
|
+
const value = provided.get(key);
|
|
2656
|
+
return value === undefined || value === null || String(value).trim() === '';
|
|
2657
|
+
});
|
|
2658
|
+
if (missing.length) {
|
|
2659
|
+
throw new Error(`base_url for app environment requires a value for: ${missing.join(', ')}. ` +
|
|
2660
|
+
`Provide them via envs[].variables when connecting/updating the app.`);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2638
2663
|
validateAppEnvs(envs, version) {
|
|
2639
2664
|
const { envs: appEnvs } = version;
|
|
2640
2665
|
return envs.map((env) => {
|
|
@@ -2647,6 +2672,7 @@ class ProductsBuilderService {
|
|
|
2647
2672
|
// const updates = this.validateAppAuth(auth, version);
|
|
2648
2673
|
this.validateVariablesSchema(env.variables, version.variables, appEnv.base_url_variables);
|
|
2649
2674
|
this.validateVariablesValues(env.variables, version.variables);
|
|
2675
|
+
this.validateBaseUrlVariablesRequired(env.variables, appEnv.base_url_variables);
|
|
2650
2676
|
/*if (updates && updates.data) {
|
|
2651
2677
|
env.auth.data = updates.data;
|
|
2652
2678
|
}
|
|
@@ -2891,6 +2917,7 @@ class ProductsBuilderService {
|
|
|
2891
2917
|
}
|
|
2892
2918
|
}
|
|
2893
2919
|
async updateApp(access_tag, data) {
|
|
2920
|
+
var _a, _b, _c, _d;
|
|
2894
2921
|
try {
|
|
2895
2922
|
const app = await this.fetchApp(access_tag);
|
|
2896
2923
|
if (!app) {
|
|
@@ -2907,6 +2934,13 @@ class ProductsBuilderService {
|
|
|
2907
2934
|
/*if (data.access_tag && this.fetchApp(data.access_tag)) {
|
|
2908
2935
|
throw new Error(`access_tag ${access_tag} is in use`); // TODO: also check on the backend
|
|
2909
2936
|
}*/
|
|
2937
|
+
if ((_a = data.envs) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2938
|
+
const thirdPartyApp = await this.fetchThirdPartyAppByAccessTag(access_tag);
|
|
2939
|
+
const version = (_c = (_b = thirdPartyApp === null || thirdPartyApp === void 0 ? void 0 : thirdPartyApp.versions) === null || _b === void 0 ? void 0 : _b.find((v) => v.tag === thirdPartyApp.version)) !== null && _c !== void 0 ? _c : (_d = thirdPartyApp === null || thirdPartyApp === void 0 ? void 0 : thirdPartyApp.versions) === null || _d === void 0 ? void 0 : _d[0];
|
|
2940
|
+
if (version) {
|
|
2941
|
+
data.envs = this.validateAppEnvs(data.envs, version);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2910
2944
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({ _id }, data), { access_tag, component: enums_1.ProductComponents.APP, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
2911
2945
|
}
|
|
2912
2946
|
catch (e) {
|
|
@@ -4174,6 +4208,7 @@ class ProductsBuilderService {
|
|
|
4174
4208
|
return action;
|
|
4175
4209
|
}
|
|
4176
4210
|
async createDatabase(data, throwErrorIfExists = false) {
|
|
4211
|
+
var _a, _b, _c;
|
|
4177
4212
|
try {
|
|
4178
4213
|
if (!(await this.fetchDatabase(data.tag))) {
|
|
4179
4214
|
const auth = this.getUserAccess();
|
|
@@ -4188,7 +4223,7 @@ class ProductsBuilderService {
|
|
|
4188
4223
|
for (const env of data.envs) {
|
|
4189
4224
|
const exists = await this.fetchEnv(env.slug);
|
|
4190
4225
|
if (!exists) {
|
|
4191
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
4226
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
4192
4227
|
}
|
|
4193
4228
|
if (env.connection_url) {
|
|
4194
4229
|
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
@@ -4237,9 +4272,10 @@ class ProductsBuilderService {
|
|
|
4237
4272
|
await validators_1.UpdateProductDatabaseSchema.validateAsync(data);
|
|
4238
4273
|
if (data.envs && data.envs.length > 0) {
|
|
4239
4274
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
4275
|
+
var _a, _b, _c;
|
|
4240
4276
|
const exists = await this.fetchEnv(env.slug);
|
|
4241
4277
|
if (!exists) {
|
|
4242
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
4278
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
4243
4279
|
}
|
|
4244
4280
|
if (env.connection_url) {
|
|
4245
4281
|
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
@@ -4340,7 +4376,7 @@ class ProductsBuilderService {
|
|
|
4340
4376
|
}
|
|
4341
4377
|
// GRAPH CRUD METHODS
|
|
4342
4378
|
async createGraph(data, throwErrorIfExists = false) {
|
|
4343
|
-
var _a, _b, _c;
|
|
4379
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4344
4380
|
console.log('[ProductsService.createGraph] Starting graph creation:', {
|
|
4345
4381
|
tag: data.tag,
|
|
4346
4382
|
name: data.name,
|
|
@@ -4367,7 +4403,7 @@ class ProductsBuilderService {
|
|
|
4367
4403
|
});
|
|
4368
4404
|
const exists = await this.fetchEnv(env.slug);
|
|
4369
4405
|
if (!exists) {
|
|
4370
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
4406
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_e = (_d = (_c = this.product) === null || _c === void 0 ? void 0 : _c.tag) !== null && _d !== void 0 ? _d : this.product_id) !== null && _e !== void 0 ? _e : 'unknown'}"`);
|
|
4371
4407
|
}
|
|
4372
4408
|
if (env.connection_url) {
|
|
4373
4409
|
console.log('[ProductsService.createGraph] Converting connection URL to secret for env:', env.slug);
|
|
@@ -4375,7 +4411,7 @@ class ProductsBuilderService {
|
|
|
4375
4411
|
env.connection_url = await this.storeGraphConnectionUrlAsSecret(env.connection_url, data.tag, env.slug);
|
|
4376
4412
|
console.log('[ProductsService.createGraph] Connection URL after secret conversion:', {
|
|
4377
4413
|
wasConverted: originalUrl !== env.connection_url,
|
|
4378
|
-
isSecretRef: (
|
|
4414
|
+
isSecretRef: (_f = env.connection_url) === null || _f === void 0 ? void 0 : _f.startsWith('$Secret{'),
|
|
4379
4415
|
});
|
|
4380
4416
|
env.connection_url = (0, processor_utils_1.encrypt)(env.connection_url, this.product.private_key);
|
|
4381
4417
|
console.log('[ProductsService.createGraph] Connection URL encrypted');
|
|
@@ -4444,7 +4480,7 @@ class ProductsBuilderService {
|
|
|
4444
4480
|
const cloudApi = new cloudApi_service_1.CloudApiService(this.env_type);
|
|
4445
4481
|
const productTag = this.product.tag;
|
|
4446
4482
|
data.envs = await Promise.all(data.envs.map(async (env) => {
|
|
4447
|
-
var _a;
|
|
4483
|
+
var _a, _b, _c, _d;
|
|
4448
4484
|
const materialized = await (0, cloud_graph_link_util_1.materializeCloudLinkedGraphEnv)(env, {
|
|
4449
4485
|
cloudApi,
|
|
4450
4486
|
auth,
|
|
@@ -4459,7 +4495,7 @@ class ProductsBuilderService {
|
|
|
4459
4495
|
});
|
|
4460
4496
|
const exists = await this.fetchEnv(materialized.slug);
|
|
4461
4497
|
if (!exists) {
|
|
4462
|
-
throw new Error(`Env ${materialized.slug} does not exist`);
|
|
4498
|
+
throw new Error(`Env "${materialized.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
4463
4499
|
}
|
|
4464
4500
|
if (materialized.connection_url) {
|
|
4465
4501
|
// Store connection URL as secret
|
|
@@ -4468,7 +4504,7 @@ class ProductsBuilderService {
|
|
|
4468
4504
|
materialized.connection_url = await this.storeGraphConnectionUrlAsSecret(materialized.connection_url, data.tag || tag, materialized.slug);
|
|
4469
4505
|
console.log('[ProductsService.updateGraph] Connection URL after secret conversion:', {
|
|
4470
4506
|
wasConverted: originalUrl !== materialized.connection_url,
|
|
4471
|
-
isSecretRef: (
|
|
4507
|
+
isSecretRef: (_d = materialized.connection_url) === null || _d === void 0 ? void 0 : _d.startsWith('$Secret{'),
|
|
4472
4508
|
});
|
|
4473
4509
|
materialized.connection_url = (0, processor_utils_1.encrypt)(materialized.connection_url, this.product.private_key);
|
|
4474
4510
|
console.log('[ProductsService.updateGraph] Connection URL encrypted');
|
|
@@ -5124,6 +5160,7 @@ class ProductsBuilderService {
|
|
|
5124
5160
|
}
|
|
5125
5161
|
// ==================== WORKFLOW CRUD METHODS ====================
|
|
5126
5162
|
async createFeature(data, throwErrorIfExists = false) {
|
|
5163
|
+
var _a, _b, _c;
|
|
5127
5164
|
try {
|
|
5128
5165
|
const productId = this.requireProductId(`createFeature("${data.tag || ''}")`);
|
|
5129
5166
|
const existing = await this.fetchFeature(data.tag);
|
|
@@ -5137,7 +5174,7 @@ class ProductsBuilderService {
|
|
|
5137
5174
|
for (const env of data.envs) {
|
|
5138
5175
|
const exists = await this.fetchEnv(env.slug);
|
|
5139
5176
|
if (!exists) {
|
|
5140
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
5177
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
5141
5178
|
}
|
|
5142
5179
|
}
|
|
5143
5180
|
}
|
|
@@ -5195,6 +5232,7 @@ class ProductsBuilderService {
|
|
|
5195
5232
|
}
|
|
5196
5233
|
}
|
|
5197
5234
|
async updateFeature(tag, data) {
|
|
5235
|
+
var _a, _b, _c;
|
|
5198
5236
|
try {
|
|
5199
5237
|
const feature = await this.fetchFeature(tag);
|
|
5200
5238
|
if (!feature) {
|
|
@@ -5209,7 +5247,7 @@ class ProductsBuilderService {
|
|
|
5209
5247
|
for (const env of data.envs) {
|
|
5210
5248
|
const exists = await this.fetchEnv(env.slug);
|
|
5211
5249
|
if (!exists) {
|
|
5212
|
-
throw new Error(`Env ${env.slug} does not exist`);
|
|
5250
|
+
throw new Error(`Env "${env.slug}" does not exist on product "${(_c = (_b = (_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) !== null && _b !== void 0 ? _b : this.product_id) !== null && _c !== void 0 ? _c : 'unknown'}"`);
|
|
5213
5251
|
}
|
|
5214
5252
|
}
|
|
5215
5253
|
}
|