@adminide-stack/core
Advanced tools
Comparing version 9.1.1-alpha.102 to 9.2.1-alpha.0
import { DataProxy } from '@apollo/client/cache'; | ||
import { ApolloClient } from '@apollo/client/index.js'; | ||
import { IUserContext, IUserProfile, IIAuth0Token, IAuthStrategyEnum } from './generated'; | ||
import { CdmLogger } from '@cdm-logger/core'; | ||
import express from 'express'; | ||
import { IPreferncesTransformed } from '@common-stack/server-core'; | ||
import { IUserContext, IUserProfile, IIAuth0Token, IAuthStrategyEnum } from './generated'; | ||
import { IClientService } from './service'; | ||
import { IEnvironmentService } from './environment'; | ||
import { IPreferencesService } from './preferences-service'; | ||
/** | ||
@@ -37,14 +39,22 @@ * | ||
} | ||
export interface ServerContext { | ||
req: express.Request & { | ||
export interface IHttpMiddlewareContext { | ||
req?: express.Request & { | ||
authStrategy: IAuthStrategyEnum | string; | ||
permissions?: any; | ||
cdecodeuri?: any; | ||
logger?: CdmLogger.ILogger; | ||
user?: IIAuth0Token; | ||
errors?: any; | ||
profile?: IUserProfile; | ||
}; | ||
res: express.Response; | ||
userContext: IUserContext; | ||
} | ||
export interface ServerContext extends IHttpMiddlewareContext { | ||
accessRoleService: any; | ||
user?: IIAuth0Token; | ||
userContext?: IUserContext; | ||
orgname?: string; | ||
profile?: IUserProfile; | ||
/** Backend Datasource */ | ||
dataSources: IDataSources; | ||
profile: IUserProfile; | ||
user: IIAuth0Token; | ||
orgname?: string; | ||
orgRole?: string; | ||
@@ -54,2 +64,3 @@ teamName?: string; | ||
environmentService: IEnvironmentService; | ||
preferenceService?: IPreferencesService; | ||
} |
@@ -6,2 +6,3 @@ import { URI } from '@vscode-alt/monaco-editor/esm/vs/base/common/uri'; | ||
organization: string; | ||
project?: string; | ||
resourceType?: IConfigCollectionName; | ||
@@ -20,2 +21,21 @@ resourceId?: string; | ||
}, fragment?: string) => URI; | ||
/** | ||
* valid | ||
* `cdecode://us-west-2-permissions/rranrn/${IConfigCollectionName.Teams}/JohnDoe` | ||
* `cdecode://us-west-2-permissions/rranrn/${IConfigCollectionName.Teams}/JohnDoe?param1=1¶m2=2` | ||
* `cdecode://us-west-2-permissions/rranrn?param1=1` | ||
* `cdecode://us-west-2-permissions/` | ||
* `cdecode://us-west-2-permissions///` | ||
* `cdecode://us-west-2-permissions/orgA/projX/${IConfigCollectionName.Teams}/JohnDoe` | ||
* `cdecode://us-west-2-permissions/orgA` | ||
* `cdecode://us-west-2-permissions/orgA/projectX` | ||
* | ||
* not valid | ||
* `cdecode://us-west-2-permissions/orgA/projectX/${IConfigCollectionName.Teams}` | ||
* `cdecode://us-west-2-permissions/orgA/projectX/${IConfigCollectionName.Teams}/` | ||
* `cdecode://us-west-2-permissions/rranrn/inValidCollectionName/JohnDoe` // if `inValidCollectionName` not in `IConfigCollectionName` | ||
* `cdecode://us-west-2-permissions/rranrn/projectX/inValidCollectionName/JohnDoe` // if `inValidCollectionName` not in `IConfigCollectionName` | ||
* @param uriString | ||
* @returns | ||
*/ | ||
export declare function parseCdecodeUri(uriString: string | URI): ICdecodeParsedUri; |
@@ -1,2 +0,2 @@ | ||
import {URI}from'@vscode-alt/monaco-editor/esm/vs/base/common/uri.js';import {Schemas}from'@workbench-stack/core/lib/core/network.js';import sortKeys from'sort-keys';import queryString from'query-string';const generateCdecodeUri = (authority, params, query = {}, fragment) => { | ||
import {URI}from'@vscode-alt/monaco-editor/esm/vs/base/common/uri.js';import {Schemas}from'@workbench-stack/core/lib/core/network.js';import sortKeys from'sort-keys';import queryString from'query-string';import {IConfigCollectionName}from'../interfaces/generated/generated-models.js';import'../interfaces/configuration/configuration.js';import'../interfaces/organization/organization-context.js';import'@workbench-stack/core/lib/constants/extensions.js';import'@workbench-stack/core/lib/interfaces/lifecycle/lifecycle.js';import'../interfaces/permissions.js';const generateCdecodeUri = (authority, params, query = {}, fragment) => { | ||
const orderedParams = sortKeys(query); | ||
@@ -13,20 +13,76 @@ const queryInString = queryString.stringify(orderedParams); | ||
}; | ||
/** | ||
* valid | ||
* `cdecode://us-west-2-permissions/rranrn/${IConfigCollectionName.Teams}/JohnDoe` | ||
* `cdecode://us-west-2-permissions/rranrn/${IConfigCollectionName.Teams}/JohnDoe?param1=1¶m2=2` | ||
* `cdecode://us-west-2-permissions/rranrn?param1=1` | ||
* `cdecode://us-west-2-permissions/` | ||
* `cdecode://us-west-2-permissions///` | ||
* `cdecode://us-west-2-permissions/orgA/projX/${IConfigCollectionName.Teams}/JohnDoe` | ||
* `cdecode://us-west-2-permissions/orgA` | ||
* `cdecode://us-west-2-permissions/orgA/projectX` | ||
* | ||
* not valid | ||
* `cdecode://us-west-2-permissions/orgA/projectX/${IConfigCollectionName.Teams}` | ||
* `cdecode://us-west-2-permissions/orgA/projectX/${IConfigCollectionName.Teams}/` | ||
* `cdecode://us-west-2-permissions/rranrn/inValidCollectionName/JohnDoe` // if `inValidCollectionName` not in `IConfigCollectionName` | ||
* `cdecode://us-west-2-permissions/rranrn/projectX/inValidCollectionName/JohnDoe` // if `inValidCollectionName` not in `IConfigCollectionName` | ||
* @param uriString | ||
* @returns | ||
*/ | ||
function parseCdecodeUri(uriString) { | ||
const uri = typeof uriString === 'string' ? URI.parse(uriString) : uriString; | ||
// Extract and clean the path segments | ||
// Extract and clean the path segments | ||
const pathSegmentsArray = uri.path.split('/').filter(Boolean); | ||
const pathSegmentsArray = uri.path.split('/').filter(Boolean); // Clean the path segments | ||
const pathSegments = { | ||
organization: pathSegmentsArray[0] | ||
organization: pathSegmentsArray[0] || undefined // Organization is required if present | ||
}; | ||
if (pathSegmentsArray.length >= 2) { | ||
pathSegments.resourceType = pathSegmentsArray[1]; | ||
if (pathSegmentsArray.length === 0) { | ||
// Handle the case with no path segments (e.g., `cdecode://us-west-2-permissions/`) | ||
return { | ||
scheme: uri.scheme, | ||
authority: uri.authority, | ||
pathSegments, | ||
queryData: queryString.parse(uri.query), | ||
fragmentData: uri.fragment.includes('=') ? queryString.parse(uri.fragment) : uri.fragment | ||
}; | ||
} | ||
if (pathSegmentsArray.length >= 3) { | ||
pathSegments.resourceId = pathSegmentsArray[2]; | ||
if (pathSegmentsArray.length === 3) { | ||
// Case: organization/resourceType/resourceId | ||
const possibleResourceType = pathSegmentsArray[1]; | ||
const resourceId = pathSegmentsArray[2]; | ||
// Validate the resourceType against IConfigCollectionName | ||
const isResourceType = Object.values(IConfigCollectionName).includes(possibleResourceType); | ||
if (!isResourceType) { | ||
throw new Error(`Invalid URI structure: The resourceType "${possibleResourceType}" is not included in IConfigCollectionName.`); | ||
} | ||
// Assign resourceType and resourceId | ||
pathSegments.resourceType = possibleResourceType; | ||
pathSegments.resourceId = resourceId; | ||
} else if (pathSegmentsArray.length === 2) { | ||
// Case: organization/project or organization/resourceType | ||
const possibleResourceTypeOrProject = pathSegmentsArray[1]; | ||
// Check if it's a valid resourceType | ||
const isResourceType = Object.values(IConfigCollectionName).includes(possibleResourceTypeOrProject); | ||
if (isResourceType) { | ||
// If it's a valid resourceType, validate further | ||
throw new Error(`Invalid URI structure: The resourceType "${possibleResourceTypeOrProject}" is missing the resourceId.`); | ||
} | ||
// Otherwise, treat it as a project | ||
pathSegments.project = possibleResourceTypeOrProject; | ||
} else if (pathSegmentsArray.length > 3) { | ||
// Case: organization/project/resourceType/resourceId | ||
pathSegments.project = pathSegmentsArray[1]; | ||
const possibleResourceType = pathSegmentsArray[2]; | ||
const resourceId = pathSegmentsArray[3]; | ||
// Validate the resourceType | ||
const isResourceType = Object.values(IConfigCollectionName).includes(possibleResourceType); | ||
if (!isResourceType) { | ||
throw new Error(`Invalid URI structure: The resourceType "${possibleResourceType}" is not included in IConfigCollectionName.`); | ||
} | ||
// Assign resourceType and resourceId | ||
pathSegments.resourceType = possibleResourceType; | ||
pathSegments.resourceId = resourceId; | ||
} | ||
// Parse the query string into key-value pairs | ||
// Parse query and fragment | ||
const queryData = queryString.parse(uri.query); | ||
// Parse the fragment into key-value pairs | ||
// Determine if the fragment is key-value pairs or just a string | ||
let fragmentData = uri.fragment; | ||
@@ -39,6 +95,6 @@ if (uri.fragment.includes('=')) { | ||
authority: uri.authority, | ||
pathSegments: pathSegments, | ||
queryData: queryData, | ||
fragmentData: fragmentData | ||
pathSegments, | ||
queryData, | ||
fragmentData | ||
}; | ||
}export{generateCdecodeUri,parseCdecodeUri};//# sourceMappingURL=cdecodeUri.js.map |
{ | ||
"name": "@adminide-stack/core", | ||
"version": "9.1.1-alpha.102", | ||
"version": "9.2.1-alpha.0", | ||
"description": "AdminIDE core for higher packages to depend on", | ||
@@ -40,3 +40,3 @@ "license": "ISC", | ||
}, | ||
"gitHead": "26771e5031febcd9f574d782f40ca38a2a9082e2" | ||
"gitHead": "51bb42d8b26d285f0381f684d0f0ca45b27675e0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
36687
1688228