@aifabrix/builder 2.47.1 → 2.47.2

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.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Docker build-arg resolution from resolved env and shell overlays.
3
+ *
4
+ * @fileoverview Build-time args for `aifabrix build` / docker build
5
+ * @author AI Fabrix Team
6
+ * @version 1.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const path = require('path');
12
+ const secretsEnvWrite = require('../core/secrets-env-write');
13
+ const { assertMisoControllerNpmSdkDeps } = require('./miso-controller-npm-sdk-guard');
14
+
15
+ const MISO_CONTROLLER_UI_BUILD_ARG_KEYS = [
16
+ 'MISO_RELATIVE_PATH',
17
+ 'MISO_WEB_SERVER_URL',
18
+ 'VITE_BASE_PATH',
19
+ 'KEYCLOAK_SERVER_URL',
20
+ 'KEYCLOAK_REALM',
21
+ 'KEYCLOAK_CLIENT_ID'
22
+ ];
23
+
24
+ /**
25
+ * @param {Object.<string, string>} buildArgs
26
+ * @param {Object.<string, string>} envMap
27
+ */
28
+ function applyMisoControllerUiBuildArgs(buildArgs, envMap) {
29
+ for (const key of MISO_CONTROLLER_UI_BUILD_ARG_KEYS) {
30
+ const value = envMap[key];
31
+ if (typeof value === 'string' && value.trim() && !value.includes('://')) {
32
+ buildArgs[key] = value.trim();
33
+ }
34
+ }
35
+ if (!buildArgs.VITE_BASE_PATH && buildArgs.MISO_RELATIVE_PATH) {
36
+ buildArgs.VITE_BASE_PATH = buildArgs.MISO_RELATIVE_PATH;
37
+ }
38
+ if (!buildArgs.VITE_BASE_PATH && buildArgs.MISO_WEB_SERVER_URL) {
39
+ try {
40
+ const pathname = new URL(buildArgs.MISO_WEB_SERVER_URL).pathname.replace(/\/+$/, '');
41
+ if (pathname && pathname !== '/') {
42
+ buildArgs.VITE_BASE_PATH = pathname;
43
+ }
44
+ } catch {
45
+ // ignore invalid public URL
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Resolve Docker build-args from resolved env map and merged BASH_* secrets.
52
+ *
53
+ * @param {string} appName
54
+ * @param {string} [contextPath] Docker build context (repo root for miso-controller)
55
+ * @returns {Promise<Object.<string, string>>}
56
+ */
57
+ async function resolveDockerBuildArgsForApp(appName, contextPath) {
58
+ const envMap = await secretsEnvWrite.resolveAndGetEnvMap(appName, { environment: 'docker' });
59
+ const { getBashPrefixedProcessEnvOverlay } = require('../utils/bash-secret-env');
60
+ const bashOverlay = await getBashPrefixedProcessEnvOverlay(null, appName);
61
+ const buildArgs = {};
62
+ if (envMap.NPM_TOKEN) buildArgs.NPM_TOKEN = envMap.NPM_TOKEN;
63
+ if (envMap.PYPI_TOKEN) buildArgs.PYPI_TOKEN = envMap.PYPI_TOKEN;
64
+ for (const [k, v] of Object.entries(bashOverlay)) {
65
+ if (v && buildArgs[k] === undefined) buildArgs[k] = v;
66
+ }
67
+ const shellNpm = typeof process.env.NPM_TOKEN === 'string' ? process.env.NPM_TOKEN.trim() : '';
68
+ const shellPypi = typeof process.env.PYPI_TOKEN === 'string' ? process.env.PYPI_TOKEN.trim() : '';
69
+ if (shellNpm) buildArgs.NPM_TOKEN = shellNpm;
70
+ if (shellPypi) buildArgs.PYPI_TOKEN = shellPypi;
71
+ if (appName === 'miso-controller') {
72
+ applyMisoControllerUiBuildArgs(buildArgs, envMap);
73
+ }
74
+ if (appName === 'miso-controller' && contextPath) {
75
+ assertMisoControllerNpmSdkDeps(path.resolve(contextPath));
76
+ }
77
+ return buildArgs;
78
+ }
79
+
80
+ module.exports = {
81
+ resolveDockerBuildArgsForApp,
82
+ applyMisoControllerUiBuildArgs
83
+ };
@@ -35,9 +35,8 @@ const dockerBuild = require('../utils/docker-build');
35
35
  const buildCopy = require('../utils/build-copy');
36
36
  const { resolveBuildDockerTagNames } = require('../utils/build-resolve-image');
37
37
  const buildHelpers = require('../utils/build-helpers');
38
- const secretsEnvWrite = require('../core/secrets-env-write');
39
38
  const { ensureRunSecretsForApp } = require('../app/run-env-compose');
40
- const { assertMisoControllerNpmSdkDeps } = require('./miso-controller-npm-sdk-guard');
39
+ const { resolveDockerBuildArgsForApp } = require('./docker-build-args');
41
40
 
42
41
  /**
43
42
  * Loads application config for an application
@@ -394,33 +393,6 @@ async function handleDockerfileGeneration(appName, params, options, buildHelpers
394
393
  }, generateDockerfile);
395
394
  }
396
395
 
397
- /**
398
- * Resolve Docker build-args from resolved env map and merged BASH_* secrets.
399
- * @param {string} appName
400
- * @param {string} [contextPath] Docker build context (repo root for miso-controller)
401
- * @returns {Promise<Object.<string, string>>}
402
- */
403
- async function resolveDockerBuildArgsForApp(appName, contextPath) {
404
- const envMap = await secretsEnvWrite.resolveAndGetEnvMap(appName, { environment: 'docker' });
405
- const { getBashPrefixedProcessEnvOverlay } = require('../utils/bash-secret-env');
406
- const bashOverlay = await getBashPrefixedProcessEnvOverlay(null, appName);
407
- const buildArgs = {};
408
- if (envMap.NPM_TOKEN) buildArgs.NPM_TOKEN = envMap.NPM_TOKEN;
409
- if (envMap.PYPI_TOKEN) buildArgs.PYPI_TOKEN = envMap.PYPI_TOKEN;
410
- for (const [k, v] of Object.entries(bashOverlay)) {
411
- if (v && buildArgs[k] === undefined) buildArgs[k] = v;
412
- }
413
- // Exported shell tokens win (local dev: export NPM_TOKEN=... before af build / docker build).
414
- const shellNpm = typeof process.env.NPM_TOKEN === 'string' ? process.env.NPM_TOKEN.trim() : '';
415
- const shellPypi = typeof process.env.PYPI_TOKEN === 'string' ? process.env.PYPI_TOKEN.trim() : '';
416
- if (shellNpm) buildArgs.NPM_TOKEN = shellNpm;
417
- if (shellPypi) buildArgs.PYPI_TOKEN = shellPypi;
418
- if (appName === 'miso-controller' && contextPath) {
419
- assertMisoControllerNpmSdkDeps(path.resolve(contextPath));
420
- }
421
- return buildArgs;
422
- }
423
-
424
396
  /**
425
397
  * Standard Docker build path after CLI header is printed (non-external apps).
426
398
  * @param {string} appName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aifabrix/builder",
3
- "version": "2.47.1",
3
+ "version": "2.47.2",
4
4
  "description": "AI Fabrix Local Fabric & Deployment SDK",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
package/.npmrc.token DELETED
@@ -1 +0,0 @@
1
- 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
@@ -1 +0,0 @@
1
- {"apiVersion":"dataplane.aifabrix.ai/v1","kind":"Protection","metadata":{"key":"hubspot-country-sales","displayName":"HubSpot Country Sales Access"},"spec":{"enabled":true,"datasourceKey":"hubspot-companies","mode":"replaceForSource","rules":[{"key":"sales-country-users","principal":{"type":"group","expression":"Sales {{fk.country.metadata.iso3}} Users"},"grants":[{"dimensionKey":"country","valueExpression":"{{fk.country.metadata.iso2}}"}]}]}}
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1 +0,0 @@
1
- {"apiVersion":"dataplane.aifabrix.ai/v1","kind":"Protection","metadata":{"key":"hubspot-country-sales","displayName":"HubSpot Country Sales Access"},"spec":{"enabled":true,"datasourceKey":"hubspot-companies","mode":"replaceForSource","rules":[{"key":"sales-country-users","principal":{"type":"group","expression":"Sales {{fk.country.metadata.iso3}} Users"},"grants":[{"dimensionKey":"country","valueExpression":"{{fk.country.metadata.iso2}}"}]}]}}
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,17 +0,0 @@
1
- apiVersion: dataplane.aifabrix.ai/v1
2
- kind: Protection
3
- metadata:
4
- key: hubspot-country-sales
5
- displayName: HubSpot Country Sales Access
6
- spec:
7
- enabled: true
8
- datasourceKey: hubspot-companies
9
- mode: replaceForSource
10
- rules:
11
- - key: sales-country-users
12
- principal:
13
- type: group
14
- expression: "Sales {{fk.country.metadata.iso3}} Users"
15
- grants:
16
- - dimensionKey: country
17
- valueExpression: "{{fk.country.metadata.iso2}}"
@@ -1,5 +0,0 @@
1
- lint:fix exit=0
2
- lint exit=0
3
- test exit=0
4
- miso typecheck exit=0
5
- miso build exit=0