@aj-archipelago/cortex 1.3.62 ā 1.3.63
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/.github/workflows/cortex-file-handler-test.yml +61 -0
- package/README.md +31 -7
- package/config/default.example.json +15 -0
- package/config.js +133 -12
- package/helper-apps/cortex-autogen2/DigiCertGlobalRootCA.crt.pem +22 -0
- package/helper-apps/cortex-autogen2/Dockerfile +31 -0
- package/helper-apps/cortex-autogen2/Dockerfile.worker +41 -0
- package/helper-apps/cortex-autogen2/README.md +183 -0
- package/helper-apps/cortex-autogen2/__init__.py +1 -0
- package/helper-apps/cortex-autogen2/agents.py +131 -0
- package/helper-apps/cortex-autogen2/docker-compose.yml +20 -0
- package/helper-apps/cortex-autogen2/function_app.py +55 -0
- package/helper-apps/cortex-autogen2/host.json +15 -0
- package/helper-apps/cortex-autogen2/main.py +126 -0
- package/helper-apps/cortex-autogen2/poetry.lock +3652 -0
- package/helper-apps/cortex-autogen2/pyproject.toml +36 -0
- package/helper-apps/cortex-autogen2/requirements.txt +20 -0
- package/helper-apps/cortex-autogen2/send_task.py +105 -0
- package/helper-apps/cortex-autogen2/services/__init__.py +1 -0
- package/helper-apps/cortex-autogen2/services/azure_queue.py +85 -0
- package/helper-apps/cortex-autogen2/services/redis_publisher.py +153 -0
- package/helper-apps/cortex-autogen2/task_processor.py +488 -0
- package/helper-apps/cortex-autogen2/tools/__init__.py +24 -0
- package/helper-apps/cortex-autogen2/tools/azure_blob_tools.py +175 -0
- package/helper-apps/cortex-autogen2/tools/azure_foundry_agents.py +601 -0
- package/helper-apps/cortex-autogen2/tools/coding_tools.py +72 -0
- package/helper-apps/cortex-autogen2/tools/download_tools.py +48 -0
- package/helper-apps/cortex-autogen2/tools/file_tools.py +545 -0
- package/helper-apps/cortex-autogen2/tools/search_tools.py +646 -0
- package/helper-apps/cortex-azure-cleaner/README.md +36 -0
- package/helper-apps/cortex-file-converter/README.md +93 -0
- package/helper-apps/cortex-file-converter/key_to_pdf.py +104 -0
- package/helper-apps/cortex-file-converter/list_blob_extensions.py +89 -0
- package/helper-apps/cortex-file-converter/process_azure_keynotes.py +181 -0
- package/helper-apps/cortex-file-converter/requirements.txt +1 -0
- package/helper-apps/cortex-file-handler/.env.test.azure.ci +7 -0
- package/helper-apps/cortex-file-handler/.env.test.azure.sample +1 -1
- package/helper-apps/cortex-file-handler/.env.test.gcs.ci +10 -0
- package/helper-apps/cortex-file-handler/.env.test.gcs.sample +2 -2
- package/helper-apps/cortex-file-handler/INTERFACE.md +41 -0
- package/helper-apps/cortex-file-handler/package.json +1 -1
- package/helper-apps/cortex-file-handler/scripts/setup-azure-container.js +41 -17
- package/helper-apps/cortex-file-handler/scripts/setup-test-containers.js +30 -15
- package/helper-apps/cortex-file-handler/scripts/test-azure.sh +32 -6
- package/helper-apps/cortex-file-handler/scripts/test-gcs.sh +24 -2
- package/helper-apps/cortex-file-handler/scripts/validate-env.js +128 -0
- package/helper-apps/cortex-file-handler/src/blobHandler.js +161 -51
- package/helper-apps/cortex-file-handler/src/constants.js +3 -0
- package/helper-apps/cortex-file-handler/src/fileChunker.js +10 -8
- package/helper-apps/cortex-file-handler/src/index.js +116 -9
- package/helper-apps/cortex-file-handler/src/redis.js +61 -1
- package/helper-apps/cortex-file-handler/src/services/ConversionService.js +11 -8
- package/helper-apps/cortex-file-handler/src/services/FileConversionService.js +2 -2
- package/helper-apps/cortex-file-handler/src/services/storage/AzureStorageProvider.js +88 -6
- package/helper-apps/cortex-file-handler/src/services/storage/GCSStorageProvider.js +58 -0
- package/helper-apps/cortex-file-handler/src/services/storage/StorageFactory.js +25 -5
- package/helper-apps/cortex-file-handler/src/services/storage/StorageProvider.js +9 -0
- package/helper-apps/cortex-file-handler/src/services/storage/StorageService.js +120 -16
- package/helper-apps/cortex-file-handler/src/start.js +27 -17
- package/helper-apps/cortex-file-handler/tests/FileConversionService.test.js +52 -1
- package/helper-apps/cortex-file-handler/tests/blobHandler.test.js +40 -0
- package/helper-apps/cortex-file-handler/tests/checkHashShortLived.test.js +553 -0
- package/helper-apps/cortex-file-handler/tests/cleanup.test.js +46 -52
- package/helper-apps/cortex-file-handler/tests/containerConversionFlow.test.js +451 -0
- package/helper-apps/cortex-file-handler/tests/containerNameParsing.test.js +229 -0
- package/helper-apps/cortex-file-handler/tests/containerParameterFlow.test.js +392 -0
- package/helper-apps/cortex-file-handler/tests/conversionResilience.test.js +7 -2
- package/helper-apps/cortex-file-handler/tests/deleteOperations.test.js +348 -0
- package/helper-apps/cortex-file-handler/tests/fileChunker.test.js +23 -2
- package/helper-apps/cortex-file-handler/tests/fileUpload.test.js +11 -5
- package/helper-apps/cortex-file-handler/tests/getOperations.test.js +58 -24
- package/helper-apps/cortex-file-handler/tests/postOperations.test.js +11 -4
- package/helper-apps/cortex-file-handler/tests/shortLivedUrlConversion.test.js +225 -0
- package/helper-apps/cortex-file-handler/tests/start.test.js +8 -12
- package/helper-apps/cortex-file-handler/tests/storage/StorageFactory.test.js +80 -0
- package/helper-apps/cortex-file-handler/tests/storage/StorageService.test.js +388 -22
- package/helper-apps/cortex-file-handler/tests/testUtils.helper.js +74 -0
- package/lib/cortexResponse.js +153 -0
- package/lib/entityConstants.js +21 -3
- package/lib/logger.js +21 -4
- package/lib/pathwayTools.js +28 -9
- package/lib/util.js +49 -0
- package/package.json +1 -1
- package/pathways/basePathway.js +1 -0
- package/pathways/bing_afagent.js +54 -1
- package/pathways/call_tools.js +2 -3
- package/pathways/chat_jarvis.js +1 -1
- package/pathways/google_cse.js +27 -0
- package/pathways/grok_live_search.js +18 -0
- package/pathways/system/entity/memory/sys_memory_lookup_required.js +1 -0
- package/pathways/system/entity/memory/sys_memory_required.js +1 -0
- package/pathways/system/entity/memory/sys_search_memory.js +1 -0
- package/pathways/system/entity/sys_entity_agent.js +56 -4
- package/pathways/system/entity/sys_generator_quick.js +1 -0
- package/pathways/system/entity/tools/sys_tool_bing_search_afagent.js +26 -0
- package/pathways/system/entity/tools/sys_tool_google_search.js +141 -0
- package/pathways/system/entity/tools/sys_tool_grok_x_search.js +237 -0
- package/pathways/system/entity/tools/sys_tool_image.js +1 -1
- package/pathways/system/rest_streaming/sys_claude_37_sonnet.js +21 -0
- package/pathways/system/rest_streaming/sys_claude_41_opus.js +21 -0
- package/pathways/system/rest_streaming/sys_claude_4_sonnet.js +21 -0
- package/pathways/system/rest_streaming/sys_google_gemini_25_flash.js +25 -0
- package/pathways/system/rest_streaming/{sys_google_gemini_chat.js ā sys_google_gemini_25_pro.js} +6 -4
- package/pathways/system/rest_streaming/sys_grok_4.js +23 -0
- package/pathways/system/rest_streaming/sys_grok_4_fast_non_reasoning.js +23 -0
- package/pathways/system/rest_streaming/sys_grok_4_fast_reasoning.js +23 -0
- package/pathways/system/rest_streaming/sys_openai_chat.js +3 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41.js +22 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41_mini.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt41_nano.js +21 -0
- package/pathways/system/rest_streaming/{sys_claude_35_sonnet.js ā sys_openai_chat_gpt4_omni.js} +6 -4
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_omni_mini.js +21 -0
- package/pathways/system/rest_streaming/{sys_claude_3_haiku.js ā sys_openai_chat_gpt5.js} +7 -5
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_chat.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_mini.js +21 -0
- package/pathways/system/rest_streaming/sys_openai_chat_gpt5_nano.js +21 -0
- package/pathways/system/rest_streaming/{sys_openai_chat_o1.js ā sys_openai_chat_o3.js} +6 -3
- package/pathways/system/rest_streaming/sys_openai_chat_o3_mini.js +3 -0
- package/pathways/system/workspaces/run_workspace_prompt.js +99 -0
- package/pathways/vision.js +1 -1
- package/server/graphql.js +1 -1
- package/server/modelExecutor.js +8 -0
- package/server/pathwayResolver.js +166 -16
- package/server/pathwayResponseParser.js +16 -8
- package/server/plugins/azureFoundryAgentsPlugin.js +1 -1
- package/server/plugins/claude3VertexPlugin.js +193 -45
- package/server/plugins/gemini15ChatPlugin.js +21 -0
- package/server/plugins/gemini15VisionPlugin.js +360 -0
- package/server/plugins/googleCsePlugin.js +94 -0
- package/server/plugins/grokVisionPlugin.js +365 -0
- package/server/plugins/modelPlugin.js +3 -1
- package/server/plugins/openAiChatPlugin.js +106 -13
- package/server/plugins/openAiVisionPlugin.js +42 -30
- package/server/resolver.js +28 -4
- package/server/rest.js +270 -53
- package/server/typeDef.js +1 -0
- package/tests/{mocks.js ā helpers/mocks.js} +5 -2
- package/tests/{server.js ā helpers/server.js} +2 -2
- package/tests/helpers/sseAssert.js +23 -0
- package/tests/helpers/sseClient.js +73 -0
- package/tests/helpers/subscriptionAssert.js +11 -0
- package/tests/helpers/subscriptions.js +113 -0
- package/tests/{sublong.srt ā integration/features/translate/sublong.srt} +4543 -4543
- package/tests/integration/features/translate/translate_chunking_stream.test.js +100 -0
- package/tests/{translate_srt.test.js ā integration/features/translate/translate_srt.test.js} +2 -2
- package/tests/integration/graphql/async/stream/agentic.test.js +477 -0
- package/tests/integration/graphql/async/stream/subscription_streaming.test.js +62 -0
- package/tests/integration/graphql/async/stream/sys_entity_start_streaming.test.js +71 -0
- package/tests/integration/graphql/async/stream/vendors/claude_streaming.test.js +56 -0
- package/tests/integration/graphql/async/stream/vendors/gemini_streaming.test.js +66 -0
- package/tests/integration/graphql/async/stream/vendors/grok_streaming.test.js +56 -0
- package/tests/integration/graphql/async/stream/vendors/openai_streaming.test.js +72 -0
- package/tests/integration/graphql/features/google/sysToolGoogleSearch.test.js +96 -0
- package/tests/integration/graphql/features/grok/grok.test.js +688 -0
- package/tests/integration/graphql/features/grok/grok_x_search_tool.test.js +354 -0
- package/tests/{main.test.js ā integration/graphql/features/main.test.js} +1 -1
- package/tests/{call_tools.test.js ā integration/graphql/features/tools/call_tools.test.js} +2 -2
- package/tests/{vision.test.js ā integration/graphql/features/vision/vision.test.js} +1 -1
- package/tests/integration/graphql/subscriptions/connection.test.js +26 -0
- package/tests/{openai_api.test.js ā integration/rest/oai/openai_api.test.js} +63 -238
- package/tests/integration/rest/oai/tool_calling_api.test.js +343 -0
- package/tests/integration/rest/oai/tool_calling_streaming.test.js +85 -0
- package/tests/integration/rest/vendors/claude_streaming.test.js +47 -0
- package/tests/integration/rest/vendors/claude_tool_calling_streaming.test.js +75 -0
- package/tests/integration/rest/vendors/gemini_streaming.test.js +47 -0
- package/tests/integration/rest/vendors/gemini_tool_calling_streaming.test.js +75 -0
- package/tests/integration/rest/vendors/grok_streaming.test.js +55 -0
- package/tests/integration/rest/vendors/grok_tool_calling_streaming.test.js +75 -0
- package/tests/{azureAuthTokenHelper.test.js ā unit/core/azureAuthTokenHelper.test.js} +1 -1
- package/tests/{chunkfunction.test.js ā unit/core/chunkfunction.test.js} +2 -2
- package/tests/{config.test.js ā unit/core/config.test.js} +3 -3
- package/tests/{encodeCache.test.js ā unit/core/encodeCache.test.js} +1 -1
- package/tests/{fastLruCache.test.js ā unit/core/fastLruCache.test.js} +1 -1
- package/tests/{handleBars.test.js ā unit/core/handleBars.test.js} +1 -1
- package/tests/{memoryfunction.test.js ā unit/core/memoryfunction.test.js} +2 -2
- package/tests/unit/core/mergeResolver.test.js +952 -0
- package/tests/{parser.test.js ā unit/core/parser.test.js} +3 -3
- package/tests/unit/core/pathwayResolver.test.js +187 -0
- package/tests/{requestMonitor.test.js ā unit/core/requestMonitor.test.js} +1 -1
- package/tests/{requestMonitorDurationEstimator.test.js ā unit/core/requestMonitorDurationEstimator.test.js} +1 -1
- package/tests/{truncateMessages.test.js ā unit/core/truncateMessages.test.js} +3 -3
- package/tests/{util.test.js ā unit/core/util.test.js} +1 -1
- package/tests/{apptekTranslatePlugin.test.js ā unit/plugins/apptekTranslatePlugin.test.js} +3 -3
- package/tests/{azureFoundryAgents.test.js ā unit/plugins/azureFoundryAgents.test.js} +136 -1
- package/tests/{claude3VertexPlugin.test.js ā unit/plugins/claude3VertexPlugin.test.js} +32 -10
- package/tests/{claude3VertexToolConversion.test.js ā unit/plugins/claude3VertexToolConversion.test.js} +3 -3
- package/tests/unit/plugins/googleCsePlugin.test.js +111 -0
- package/tests/unit/plugins/grokVisionPlugin.test.js +1392 -0
- package/tests/{modelPlugin.test.js ā unit/plugins/modelPlugin.test.js} +3 -3
- package/tests/{multimodal_conversion.test.js ā unit/plugins/multimodal_conversion.test.js} +4 -4
- package/tests/{openAiChatPlugin.test.js ā unit/plugins/openAiChatPlugin.test.js} +13 -4
- package/tests/{openAiToolPlugin.test.js ā unit/plugins/openAiToolPlugin.test.js} +35 -27
- package/tests/{tokenHandlingTests.test.js ā unit/plugins/tokenHandlingTests.test.js} +5 -5
- package/tests/{translate_apptek.test.js ā unit/plugins/translate_apptek.test.js} +3 -3
- package/tests/{streaming.test.js ā unit/plugins.streaming/plugin_stream_events.test.js} +19 -58
- package/helper-apps/mogrt-handler/tests/test-files/test.gif +0 -1
- package/helper-apps/mogrt-handler/tests/test-files/test.mogrt +0 -1
- package/helper-apps/mogrt-handler/tests/test-files/test.mp4 +0 -1
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4.js +0 -19
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_32.js +0 -19
- package/pathways/system/rest_streaming/sys_openai_chat_gpt4_turbo.js +0 -19
- package/pathways/system/workspaces/run_claude35_sonnet.js +0 -21
- package/pathways/system/workspaces/run_claude3_haiku.js +0 -20
- package/pathways/system/workspaces/run_gpt35turbo.js +0 -20
- package/pathways/system/workspaces/run_gpt4.js +0 -20
- package/pathways/system/workspaces/run_gpt4_32.js +0 -20
- package/tests/agentic.test.js +0 -256
- package/tests/pathwayResolver.test.js +0 -78
- package/tests/subscription.test.js +0 -387
- /package/tests/{subchunk.srt ā integration/features/translate/subchunk.srt} +0 -0
- /package/tests/{subhorizontal.srt ā integration/features/translate/subhorizontal.srt} +0 -0
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import { BlobServiceClient } from "@azure/storage-blob";
|
|
2
2
|
import { Storage } from "@google-cloud/storage";
|
|
3
3
|
|
|
4
|
-
async function
|
|
4
|
+
async function createAzureContainers() {
|
|
5
5
|
try {
|
|
6
6
|
const blobServiceClient = BlobServiceClient.fromConnectionString(
|
|
7
7
|
"UseDevelopmentStorage=true",
|
|
8
8
|
);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
console.log(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
|
|
10
|
+
// Get container names from environment variable
|
|
11
|
+
const containerStr = process.env.AZURE_STORAGE_CONTAINER_NAME || "default,test-container,test1,test2,test3,container1,container2,container3";
|
|
12
|
+
const containerNames = containerStr.split(',').map(name => name.trim()).filter(name => name.length > 0);
|
|
13
|
+
|
|
14
|
+
console.log(`Creating Azure containers: ${containerNames.join(', ')}`);
|
|
15
|
+
|
|
16
|
+
for (const containerName of containerNames) {
|
|
17
|
+
try {
|
|
18
|
+
const containerClient = blobServiceClient.getContainerClient(containerName);
|
|
19
|
+
await containerClient.create();
|
|
20
|
+
console.log(`ā Created container: ${containerName}`);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// Ignore if container already exists
|
|
23
|
+
if (error.statusCode === 409) {
|
|
24
|
+
console.log(`ā Container already exists: ${containerName}`);
|
|
25
|
+
} else {
|
|
26
|
+
console.error(`Error creating container ${containerName}:`, error);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
22
30
|
}
|
|
31
|
+
|
|
32
|
+
console.log("All Azure containers created successfully");
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error("Error creating Azure containers:", error);
|
|
35
|
+
process.exit(1);
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
|
|
@@ -30,6 +43,8 @@ async function createGCSBucket() {
|
|
|
30
43
|
apiEndpoint: "http://localhost:4443",
|
|
31
44
|
});
|
|
32
45
|
|
|
46
|
+
storage.baseUrl = "http://localhost:4443/storage/v1";
|
|
47
|
+
|
|
33
48
|
console.log("Creating GCS bucket...");
|
|
34
49
|
await storage.createBucket("cortextempfiles");
|
|
35
50
|
console.log("GCS bucket created successfully");
|
|
@@ -45,7 +60,7 @@ async function createGCSBucket() {
|
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
async function setup() {
|
|
48
|
-
await
|
|
63
|
+
await createAzureContainers();
|
|
49
64
|
await createGCSBucket();
|
|
50
65
|
}
|
|
51
66
|
|
|
@@ -1,24 +1,50 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# Validate environment variables first - fail fast if missing
|
|
4
|
+
echo "š Validating environment configuration..."
|
|
5
|
+
DOTENV_CONFIG_PATH=.env.test.azure NODE_ENV=test node -r dotenv/config scripts/validate-env.js
|
|
6
|
+
if [ $? -ne 0 ]; then
|
|
7
|
+
echo "ā Environment validation failed. Exiting."
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
3
11
|
# Create temp directory for Azurite
|
|
4
12
|
AZURITE_DIR="/tmp/azurite-test"
|
|
5
13
|
mkdir -p $AZURITE_DIR
|
|
6
14
|
|
|
7
15
|
# Start Azurite in background
|
|
8
|
-
echo "Starting Azurite..."
|
|
16
|
+
echo "š Starting Azurite..."
|
|
9
17
|
azurite --silent --skipApiVersionCheck --location $AZURITE_DIR &
|
|
10
18
|
AZURITE_PID=$!
|
|
11
19
|
|
|
12
|
-
# Wait for Azurite to start
|
|
13
|
-
|
|
20
|
+
# Wait for Azurite to start and verify it's running
|
|
21
|
+
echo "ā³ Waiting for Azurite to start..."
|
|
22
|
+
sleep 3
|
|
23
|
+
|
|
24
|
+
# Verify Azurite is responding
|
|
25
|
+
echo "š Checking Azurite connectivity..."
|
|
26
|
+
timeout 10s bash -c 'until curl -s http://127.0.0.1:10000/devstoreaccount1?comp=list >/dev/null 2>&1; do sleep 1; done' || {
|
|
27
|
+
echo "ā Azurite failed to start or is not responding"
|
|
28
|
+
kill $AZURITE_PID 2>/dev/null
|
|
29
|
+
exit 1
|
|
30
|
+
}
|
|
14
31
|
|
|
15
32
|
# Create test container
|
|
16
|
-
echo "Setting up Azure
|
|
17
|
-
node scripts/setup-azure-container.js
|
|
33
|
+
echo "š¦ Setting up Azure containers..."
|
|
34
|
+
DOTENV_CONFIG_PATH=.env.test.azure NODE_ENV=test node -r dotenv/config scripts/setup-azure-container.js
|
|
35
|
+
if [ $? -ne 0 ]; then
|
|
36
|
+
echo "ā Container setup failed. Exiting."
|
|
37
|
+
kill $AZURITE_PID 2>/dev/null
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
18
40
|
|
|
19
41
|
# Run the tests
|
|
20
42
|
echo "Running tests..."
|
|
21
|
-
|
|
43
|
+
echo "š Starting AVA test runner..."
|
|
44
|
+
echo "š Test files to run:"
|
|
45
|
+
find tests -name "*.test.js" | head -10
|
|
46
|
+
echo "ā” Executing AVA..."
|
|
47
|
+
timeout 300s node -r dotenv/config node_modules/ava/entrypoints/cli.mjs "$@" --verbose
|
|
22
48
|
|
|
23
49
|
# Store test result
|
|
24
50
|
TEST_RESULT=$?
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
# Check if Docker is available
|
|
4
|
+
if ! command -v docker &> /dev/null; then
|
|
5
|
+
echo "ā Error: Docker is not installed or not available in PATH"
|
|
6
|
+
echo " Please install Docker to run this test script"
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
# Check if Docker daemon is running
|
|
11
|
+
if ! docker info &> /dev/null; then
|
|
12
|
+
echo "ā Error: Docker daemon is not running"
|
|
13
|
+
echo " Please start Docker and try again"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Validate environment variables first - fail fast if missing
|
|
18
|
+
echo "š Validating environment configuration..."
|
|
19
|
+
DOTENV_CONFIG_PATH=.env.test.gcs NODE_ENV=test node -r dotenv/config scripts/validate-env.js
|
|
20
|
+
if [ $? -ne 0 ]; then
|
|
21
|
+
echo "ā Environment validation failed. Exiting."
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
3
25
|
# Exit on error
|
|
4
26
|
set -e
|
|
5
27
|
|
|
@@ -42,8 +64,8 @@ fi
|
|
|
42
64
|
|
|
43
65
|
# Create containers
|
|
44
66
|
echo "Setting up test containers..."
|
|
45
|
-
node scripts/setup-test-containers.js
|
|
67
|
+
DOTENV_CONFIG_PATH=.env.test.gcs NODE_ENV=test node -r dotenv/config scripts/setup-test-containers.js
|
|
46
68
|
|
|
47
69
|
# Run the tests
|
|
48
70
|
echo "Running tests..."
|
|
49
|
-
node -r dotenv/config node_modules/ava/entrypoints/cli.mjs "$@"
|
|
71
|
+
DOTENV_CONFIG_PATH=.env.test.gcs NODE_ENV=test node -r dotenv/config node_modules/ava/entrypoints/cli.mjs "$@"
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Environment Variable Validation Script
|
|
5
|
+
*
|
|
6
|
+
* This script validates that all required environment variables are present
|
|
7
|
+
* and properly configured before running tests. It fails fast if any critical
|
|
8
|
+
* environment variables are missing or misconfigured.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
import { execSync } from 'child_process';
|
|
14
|
+
|
|
15
|
+
// Required environment variables for Azure tests
|
|
16
|
+
const REQUIRED_ENV_VARS = {
|
|
17
|
+
NODE_ENV: {
|
|
18
|
+
required: true,
|
|
19
|
+
expectedValue: 'test',
|
|
20
|
+
description: 'Must be set to "test" for test environment'
|
|
21
|
+
},
|
|
22
|
+
AZURE_STORAGE_CONNECTION_STRING: {
|
|
23
|
+
required: true,
|
|
24
|
+
expectedValue: 'UseDevelopmentStorage=true',
|
|
25
|
+
description: 'Must be set to use Azurite development storage'
|
|
26
|
+
},
|
|
27
|
+
AZURE_STORAGE_CONTAINER_NAME: {
|
|
28
|
+
required: true,
|
|
29
|
+
description: 'Must specify container names (comma-separated for multiple)'
|
|
30
|
+
},
|
|
31
|
+
REDIS_CONNECTION_STRING: {
|
|
32
|
+
required: false,
|
|
33
|
+
description: 'Redis connection string (optional for tests)'
|
|
34
|
+
},
|
|
35
|
+
PORT: {
|
|
36
|
+
required: false,
|
|
37
|
+
description: 'Port for test server'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Validate environment variables
|
|
42
|
+
function validateEnvironment() {
|
|
43
|
+
console.log('š Validating environment variables for Azure tests...\n');
|
|
44
|
+
|
|
45
|
+
let hasErrors = false;
|
|
46
|
+
const errors = [];
|
|
47
|
+
const warnings = [];
|
|
48
|
+
|
|
49
|
+
// Validate each required environment variable
|
|
50
|
+
for (const [varName, config] of Object.entries(REQUIRED_ENV_VARS)) {
|
|
51
|
+
const value = process.env[varName];
|
|
52
|
+
|
|
53
|
+
if (config.required && (!value || value.trim() === '')) {
|
|
54
|
+
errors.push(`ā Missing required environment variable: ${varName}`);
|
|
55
|
+
if (config.description) {
|
|
56
|
+
errors.push(` Description: ${config.description}`);
|
|
57
|
+
}
|
|
58
|
+
hasErrors = true;
|
|
59
|
+
} else if (config.expectedValue && value !== config.expectedValue) {
|
|
60
|
+
errors.push(`ā Invalid value for ${varName}: "${value}"`);
|
|
61
|
+
errors.push(` Expected: "${config.expectedValue}"`);
|
|
62
|
+
errors.push(` Description: ${config.description}`);
|
|
63
|
+
hasErrors = true;
|
|
64
|
+
} else if (value) {
|
|
65
|
+
console.log(`ā
${varName}: ${value}`);
|
|
66
|
+
} else if (!config.required) {
|
|
67
|
+
warnings.push(`ā ļø Optional variable ${varName} not set`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Validate container names format
|
|
72
|
+
const containerNames = process.env.AZURE_STORAGE_CONTAINER_NAME;
|
|
73
|
+
if (containerNames) {
|
|
74
|
+
const containers = containerNames.split(',').map(name => name.trim());
|
|
75
|
+
console.log(`ā
Container names: ${containers.join(', ')}`);
|
|
76
|
+
|
|
77
|
+
// Check for common test containers that might be missing
|
|
78
|
+
const commonTestContainers = ['test1', 'test2', 'test3', 'container1', 'container2', 'container3', 'test-container'];
|
|
79
|
+
const missingContainers = commonTestContainers.filter(container => !containers.includes(container));
|
|
80
|
+
|
|
81
|
+
if (missingContainers.length > 0) {
|
|
82
|
+
warnings.push(`ā ļø Some test containers might be missing: ${missingContainers.join(', ')}`);
|
|
83
|
+
warnings.push(` Consider adding them to AZURE_STORAGE_CONTAINER_NAME if tests fail`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Check if Azurite is available
|
|
88
|
+
try {
|
|
89
|
+
execSync('which azurite', { stdio: 'ignore' });
|
|
90
|
+
console.log('ā
Azurite is installed and available');
|
|
91
|
+
} catch (error) {
|
|
92
|
+
errors.push('ā Azurite is not installed or not in PATH');
|
|
93
|
+
errors.push(' Install with: npm install -g azurite');
|
|
94
|
+
hasErrors = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Print warnings
|
|
98
|
+
if (warnings.length > 0) {
|
|
99
|
+
console.log('\nā ļø Warnings:');
|
|
100
|
+
warnings.forEach(warning => console.log(warning));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Print errors and exit if any
|
|
104
|
+
if (hasErrors) {
|
|
105
|
+
console.log('\nā Environment validation failed:');
|
|
106
|
+
errors.forEach(error => console.log(error));
|
|
107
|
+
console.log('\nš” To fix these issues:');
|
|
108
|
+
console.log('1. Ensure .env.test.azure exists and contains all required variables');
|
|
109
|
+
console.log('2. Install Azurite: npm install -g azurite');
|
|
110
|
+
console.log('3. Check that DOTENV_CONFIG_PATH=.env.test.azure is set when running tests');
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log('\nā
Environment validation passed! Ready to run Azure tests.');
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Run validation if called directly
|
|
119
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
120
|
+
try {
|
|
121
|
+
validateEnvironment();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error('ā Environment validation failed:', error.message);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { validateEnvironment };
|