Skip to content

Commit

Permalink
Merge pull request #1872 from rudderlabs/release/v1.102.0
Browse files Browse the repository at this point in the history
chore(release): pull release/v1.102.0 into main
  • Loading branch information
sanpj2292 authored Jan 22, 2025
2 parents ba1ccc9 + 264a5bf commit 9dc9111
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 62 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.102.0](https://github.com/rudderlabs/rudder-config-schema/compare/v1.101.1...v1.102.0) (2025-01-20)


### Features

* **http:** add urlPreview custom field to ui-config ([#1869](https://github.com/rudderlabs/rudder-config-schema/issues/1869)) ([41be203](https://github.com/rudderlabs/rudder-config-schema/commit/41be20376268251ebe06c6dd909f0e8752006647))

### [1.101.1](https://github.com/rudderlabs/rudder-config-schema/compare/v1.101.0...v1.101.1) (2025-01-14)

## [1.101.0](https://github.com/rudderlabs/rudder-config-schema/compare/v1.100.0...v1.101.0) (2025-01-14)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-config-schema",
"version": "1.101.1",
"version": "1.102.0",
"description": "",
"main": "src/index.ts",
"private": true,
Expand Down
28 changes: 28 additions & 0 deletions scripts/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const languageMap = {
web: ['ts', 'js'],
flutter: ['dart'],
ios: ['m', 'swift'],
android: ['kt', 'java'],
};

// Function to check if the template should be generated for a specific language
function filterLanguages(destination, langCode) {
if (!destination?.config?.supportedConnectionModes) {
console.warn(`Destination ${destination.name} is missing supportedConnectionModes`);
return false;
}
const { supportedConnectionModes } = destination.config;

// Filtering logic
return Object.keys(supportedConnectionModes)
.filter((platform) => {
const modes = supportedConnectionModes[platform];
// Check if "device" or "hybrid" mode is present
return modes.includes('device') || modes.includes('hybrid');
})
.some((platform) => languageMap[platform]?.includes(langCode));
}

module.exports = {
filterLanguages,
};
117 changes: 117 additions & 0 deletions scripts/dummySourceConfigApiToTestSdKs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');
const http = require('http');
const url = require('url');
const { filterLanguages } = require('./common');

const destinationsDir = path.join(__dirname, '../src/configurations/destinations');

const getJSDeviceModeDestinations = () =>
fs
.readdirSync(destinationsDir)
.map((destination) => {
const dbConfig = fs.readFileSync(
path.join(destinationsDir, destination, 'db-config.json'),
'utf8',
);
return JSON.parse(dbConfig);
})
.filter((destination) => filterLanguages(destination, 'js'))
.map((destinationDefinition) => {
const cleanDestName = destinationDefinition.name.replace(/[^\dA-Za-z]/g, '');
return {
id: cleanDestName,
name: destinationDefinition.name,
config: {},
enabled: true,
destinationDefinitionId: cleanDestName,
destinationDefinition: {
name: destinationDefinition.name,
displayName: destinationDefinition.displayName,
},
updatedAt: new Date().toISOString(),
};
});

const deviceModeJSDestinations = getJSDeviceModeDestinations();

// Sample JSON response for /sourceConfig
const getSourceConfig = (writeKey) => ({
source: {
id: 'someSourceId',
name: 'http dev',
writeKey,
config: {
statsCollection: {
errors: {
enabled: false,
},
metrics: {
enabled: false,
},
},
},
enabled: true,
workspaceId: 'someWorkspaceId',
destinations: deviceModeJSDestinations,
updatedAt: new Date().toISOString(),
dataplanes: {},
},
updatedAt: new Date().toISOString(),
});

// Function to decode and validate Basic Auth
function getAuthInfo(authHeader) {
if (!authHeader || !authHeader.startsWith('Basic ')) {
return {};
}

// Decode the Base64 string
const base64Credentials = authHeader.split(' ')[1];
const credentials = Buffer.from(base64Credentials, 'base64').toString('utf-8');
const [username, password] = credentials.split(':');

return { username, password };
}

// Function to handle CORS
function setCorsHeaders(res) {
res.setHeader('Access-Control-Allow-Origin', '*'); // Allow all origins
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); // Allowed methods
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); // Allowed headers
}

// Create the HTTP server
const server = http.createServer((req, res) => {
// Set CORS headers
setCorsHeaders(res);

// Handle OPTIONS preflight requests for CORS
if (req.method === 'OPTIONS') {
res.writeHead(204); // No Content
res.end();
return;
}

// Parse the request URL
const parsedUrl = url.parse(req.url, true); // `true` parses query parameters into an object
const { query } = parsedUrl;

const authHeader = req.headers.authorization;

const authInfo = getAuthInfo(authHeader);
const writeKey = authInfo?.username || query.writeKey;

// Set response headers
res.writeHead(200, { 'Content-Type': 'application/json' });

// Send JSON response
res.end(JSON.stringify(getSourceConfig(writeKey)));
});

// Start the server
const PORT = process.env.PORT || 8000;
server.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
26 changes: 1 addition & 25 deletions scripts/generateConstants.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
/* eslint-disable no-console */
const fs = require('fs');
const path = require('path');
const { filterLanguages } = require('./common');

const destinationNameRegex = /^\w+$/;
// Path to the templates and generated files
const templatesDir = path.join(__dirname, '../templates');
const generatedDir = path.join(__dirname, '../generated');
const destinationsDir = path.join(__dirname, '../src/configurations/destinations');

const languageMap = {
web: ['ts', 'js'],
flutter: ['dart'],
ios: ['m', 'swift'],
android: ['kt', 'java'],
};

// Function to check if the template should be generated for a specific language
function filterLanguages(destination, langCode) {
if (!destination?.config?.supportedConnectionModes) {
console.warn(`Destination ${destination.name} is missing supportedConnectionModes`);
return false;
}
const { supportedConnectionModes } = destination.config;

// Filtering logic
return Object.keys(supportedConnectionModes)
.filter((platform) => {
const modes = supportedConnectionModes[platform];
// Check if "device" or "hybrid" mode is present
return modes.includes('device') || modes.includes('hybrid');
})
.some((platform) => languageMap[platform]?.includes(langCode));
}

// Function to read the template file and process it
function processTemplate(template, data) {
// Create a function to evaluate the template with the data
Expand Down
20 changes: 10 additions & 10 deletions src/configurations/destinations/http/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"properties": {
"to": {
"type": "string",
"pattern": "^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
"pattern": "^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~\\- ]{1,100}$"
},
"from": {
"type": "string",
Expand All @@ -82,7 +82,7 @@
},
"from": {
"type": "string",
"pattern": "^\\$(?:\\.|(\\.(\\w+|\\*)|\\[\\d+\\]|\\[('\\w+'|\"\\w+\")\\]|\\[\\*\\]|\\.\\w+\\(\\))*)$|^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~-]{1,100}$"
"pattern": "^\\$(?:\\.|(\\.(\\w+|\\*)|\\[\\d+\\]|\\[('\\w+'|\"\\w+\")\\]|\\[\\*\\]|\\.\\w+\\(\\))*)$|^(?!\\$)[A-Za-z0-9!#$%&'*+.^_`|~\\- /\\\\]{1,100}$"
}
}
}
Expand Down Expand Up @@ -965,7 +965,7 @@
"properties": {
"username": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"
"pattern": "^(.{0,100})$"
}
},
"required": ["username"]
Expand All @@ -984,7 +984,7 @@
"properties": {
"password": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"
"pattern": "^(.{0,100})$"
}
},
"required": ["password"]
Expand All @@ -1003,7 +1003,7 @@
"properties": {
"bearerToken": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,255})$"
"pattern": "^(.{1,255})$"
}
},
"required": ["bearerToken"]
Expand All @@ -1020,9 +1020,9 @@
},
"then": {
"properties": {
"bearerToken": {
"apiKeyName": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"
"pattern": "^(\\S{1,100})$"
}
},
"required": ["apiKeyName"]
Expand All @@ -1039,9 +1039,9 @@
},
"then": {
"properties": {
"bearerToken": {
"apiKeyValue": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"
"pattern": "^(.{1,100})$"
}
},
"required": ["apiKeyValue"]
Expand All @@ -1060,7 +1060,7 @@
"properties": {
"maxBatchSize": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^([1-9][0-9]{0,1}|100)$"
"pattern": "^([1-9][0-9]{0,1}|100)$"
}
},
"required": ["maxBatchSize"]
Expand Down
Loading

0 comments on commit 9dc9111

Please sign in to comment.