@platform-mesh/portal-ui-lib 0.23.0 → 0.24.0
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/assets/platform-mesh-portal-ui-wc.js +35 -31
- package/fesm2022/platform-mesh-portal-ui-lib-models.mjs +8 -0
- package/fesm2022/platform-mesh-portal-ui-lib-models.mjs.map +1 -1
- package/fesm2022/platform-mesh-portal-ui-lib-services.mjs +94 -19
- package/fesm2022/platform-mesh-portal-ui-lib-services.mjs.map +1 -1
- package/fesm2022/platform-mesh-portal-ui-lib-utils.mjs +4 -1
- package/fesm2022/platform-mesh-portal-ui-lib-utils.mjs.map +1 -1
- package/models/index.d.ts +16 -1
- package/package.json +1 -1
- package/services/index.d.ts +3 -0
- package/utils/index.d.ts +2 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
const ResourceOperationTypeMap = {
|
|
2
|
+
ADDED: 'ADDED',
|
|
3
|
+
MODIFIED: 'MODIFIED',
|
|
4
|
+
DELETED: 'DELETED',
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Generated bundle index. Do not edit.
|
|
3
9
|
*/
|
|
10
|
+
|
|
11
|
+
export { ResourceOperationTypeMap };
|
|
4
12
|
//# sourceMappingURL=platform-mesh-portal-ui-lib-models.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-mesh-portal-ui-lib-models.mjs","sources":["../../projects/lib/models/platform-mesh-portal-ui-lib-models.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"platform-mesh-portal-ui-lib-models.mjs","sources":["../../projects/lib/models/models/resource.ts","../../projects/lib/models/platform-mesh-portal-ui-lib-models.ts"],"sourcesContent":["import { Condition, ObjectMeta } from 'kubernetes-types/meta/v1';\n\nexport interface LabelDisplay {\n backgroundColor?: string;\n color?: string;\n fontWeight?: string;\n fontStyle?: string;\n textDecoration?: string;\n textTransform?: string;\n}\n\nexport type TransformType =\n | 'uppercase'\n | 'lowercase'\n | 'capitalize'\n | 'decode'\n | 'encode';\n\nexport interface PropertyField {\n key: string;\n transform?: TransformType[];\n}\n\nexport interface UiSettings {\n labelDisplay?: LabelDisplay | boolean;\n displayAs?: 'secret' | 'boolIcon' | 'link';\n withCopyButton?: boolean;\n}\n\nexport interface FieldDefinition {\n label?: string;\n property: string | string[];\n propertyField?: PropertyField;\n jsonPathExpression?: string;\n required?: boolean;\n values?: string[];\n group?: {\n name: string;\n label?: string;\n delimiter?: string;\n multiline?: boolean;\n };\n uiSettings?: UiSettings;\n dynamicValuesDefinition?: {\n operation: string;\n gqlQuery: string;\n value: string;\n key: string;\n };\n}\n\nexport interface ResourceStatus {\n conditions: Condition[];\n}\n\nexport interface ResourceSpec extends Record<string, any> {\n type: string;\n description?: string;\n displayName?: string;\n}\n\nexport interface AccountInfo {\n metadata: ObjectMeta;\n spec: {\n clusterInfo: { ca: string };\n organization: { originClusterId: string };\n };\n}\n\nexport interface Resource extends Record<string, any> {\n metadata: ObjectMeta;\n spec?: ResourceSpec;\n status?: ResourceStatus;\n __typename?: string;\n ready?: boolean;\n data?: Record<string, any>;\n}\n\nexport interface ResourceDefinition {\n group: string;\n plural: string;\n singular: string;\n kind: string;\n scope?: KubernetesScope;\n namespace?: string;\n readyCondition?: {\n jsonPathExpression: string;\n property: string | string[];\n };\n ui?: UIDefinition;\n}\n\ninterface UiView {\n fields: FieldDefinition[];\n}\n\nexport interface UIDefinition {\n logoUrl?: string;\n listView?: UiView;\n createView?: UiView;\n detailView?: UiView;\n}\n\nexport const ResourceOperationTypeMap = {\n ADDED: 'ADDED',\n MODIFIED: 'MODIFIED',\n DELETED: 'DELETED',\n} as const;\n\nexport type ResourceOperationType =\n (typeof ResourceOperationTypeMap)[keyof typeof ResourceOperationTypeMap];\n\nexport interface ResourceSubscriptionResult {\n type: ResourceOperationType;\n object: Resource;\n}\n\nexport interface ResourceListResult {\n resourceVersion: string;\n items: Resource[];\n}\n\nexport type KubernetesScope = 'Cluster' | 'Namespaced';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAuGO,MAAM,wBAAwB,GAAG;AACtC,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,OAAO,EAAE,SAAS;;;AC1GpB;;AAEG;;;;"}
|
|
@@ -8,10 +8,11 @@ import { Apollo, gql } from 'apollo-angular';
|
|
|
8
8
|
import { HttpLink } from 'apollo-angular/http';
|
|
9
9
|
import { print } from 'graphql';
|
|
10
10
|
import { createClient } from 'graphql-sse';
|
|
11
|
-
import {
|
|
11
|
+
import { ResourceOperationTypeMap } from '@platform-mesh/portal-ui-lib/models';
|
|
12
|
+
import { getValueByPath, replaceDotsAndHyphensWithUnderscores, capitalize, stripTypename } from '@platform-mesh/portal-ui-lib/utils';
|
|
12
13
|
import * as gqlBuilder from 'gql-query-builder';
|
|
13
|
-
import { EMPTY } from 'rxjs';
|
|
14
|
-
import { map, catchError } from 'rxjs/operators';
|
|
14
|
+
import { EMPTY, throwError } from 'rxjs';
|
|
15
|
+
import { map, catchError, switchMap, startWith } from 'rxjs/operators';
|
|
15
16
|
|
|
16
17
|
class GatewayService {
|
|
17
18
|
constructor() {
|
|
@@ -170,33 +171,107 @@ class ResourceService {
|
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
list(operation, fieldsOrRawQuery, nodeContext, readFromParentKcpPath = false) {
|
|
174
|
+
return fieldsOrRawQuery instanceof Array
|
|
175
|
+
? this.listWithFields(operation, fieldsOrRawQuery, nodeContext, readFromParentKcpPath)
|
|
176
|
+
: this.listWithRawQuery(operation, fieldsOrRawQuery, nodeContext, readFromParentKcpPath);
|
|
177
|
+
}
|
|
178
|
+
listWithFields(operation, fields, nodeContext, readFromParentKcpPath) {
|
|
179
|
+
const resourceDefinition = nodeContext.resourceDefinition;
|
|
180
|
+
if (!resourceDefinition) {
|
|
181
|
+
return throwError(() => new Error('Resource definition is required'));
|
|
182
|
+
}
|
|
173
183
|
const isNamespacedResource = this.isNamespacedResource(nodeContext);
|
|
174
184
|
const variables = {
|
|
175
185
|
...(isNamespacedResource && {
|
|
176
186
|
namespace: { type: 'String', value: nodeContext.namespaceId },
|
|
177
187
|
}),
|
|
178
188
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
fields.push({ metadata: ['uid'] });
|
|
190
|
+
return this.initialListQuery(resourceDefinition, fields, nodeContext, readFromParentKcpPath, variables).pipe(switchMap((value) => {
|
|
191
|
+
const { resourceVersion, items } = value;
|
|
192
|
+
const subscriptionQuery = gqlBuilder.subscription({
|
|
193
|
+
operation: operation,
|
|
194
|
+
fields: ['type', { object: fields }],
|
|
195
|
+
variables: {
|
|
196
|
+
...variables,
|
|
197
|
+
resourceVersion: { type: 'String', value: resourceVersion },
|
|
198
|
+
},
|
|
185
199
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
query:
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
const result = new Map(items.map((item) => [item.metadata.uid, item]));
|
|
201
|
+
return this.apolloFactory
|
|
202
|
+
.apollo(nodeContext, readFromParentKcpPath)
|
|
203
|
+
.subscribe({
|
|
204
|
+
query: gql `
|
|
205
|
+
${subscriptionQuery.query}
|
|
206
|
+
`,
|
|
207
|
+
variables: subscriptionQuery.variables,
|
|
208
|
+
})
|
|
209
|
+
.pipe(map((res) => {
|
|
210
|
+
const resourceResult = getValueByPath(res.data, operation);
|
|
211
|
+
if (!resourceResult) {
|
|
212
|
+
return Array.from(result.values());
|
|
213
|
+
}
|
|
214
|
+
const { type, object } = resourceResult;
|
|
215
|
+
if (type === ResourceOperationTypeMap.ADDED) {
|
|
216
|
+
result.set(object.metadata.uid, object);
|
|
217
|
+
}
|
|
218
|
+
else if (type === ResourceOperationTypeMap.MODIFIED) {
|
|
219
|
+
result.set(object.metadata.uid, object);
|
|
220
|
+
}
|
|
221
|
+
else if (type === ResourceOperationTypeMap.DELETED) {
|
|
222
|
+
result.delete(object.metadata.uid);
|
|
223
|
+
}
|
|
224
|
+
return Array.from(result.values());
|
|
225
|
+
}), startWith(Array.from(result.values())), catchError((error) => {
|
|
226
|
+
this.alertErrors(error);
|
|
227
|
+
console.error('Error executing GraphQL query.', error);
|
|
228
|
+
return error;
|
|
229
|
+
}));
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
initialListQuery(resourceDefinition, fields, nodeContext, readFromParentKcpPath, variables) {
|
|
233
|
+
const operation = replaceDotsAndHyphensWithUnderscores(resourceDefinition.group);
|
|
234
|
+
const kind = capitalize(resourceDefinition.plural);
|
|
235
|
+
const listQuery = gqlBuilder.query({
|
|
236
|
+
operation,
|
|
237
|
+
fields: [
|
|
238
|
+
{
|
|
239
|
+
[kind]: ['resourceVersion', { items: fields }],
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
variables: variables,
|
|
243
|
+
});
|
|
244
|
+
console.log(listQuery.query);
|
|
193
245
|
return this.apolloFactory
|
|
194
246
|
.apollo(nodeContext, readFromParentKcpPath)
|
|
195
|
-
.
|
|
247
|
+
.query({
|
|
248
|
+
query: gql `
|
|
249
|
+
${listQuery.query}
|
|
250
|
+
`,
|
|
251
|
+
variables: listQuery.variables,
|
|
252
|
+
})
|
|
253
|
+
.pipe(map((res) => {
|
|
254
|
+
const resourceListResult = getValueByPath(res.data, `${operation}.${kind}`);
|
|
255
|
+
if (!resourceListResult) {
|
|
256
|
+
throw new Error('Resource list result not found');
|
|
257
|
+
}
|
|
258
|
+
return resourceListResult;
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
listWithRawQuery(operation, rawQuery, nodeContext, readFromParentKcpPath) {
|
|
262
|
+
const isNamespacedResource = this.isNamespacedResource(nodeContext);
|
|
263
|
+
const variables = {
|
|
264
|
+
...(isNamespacedResource && {
|
|
265
|
+
namespace: { type: 'String', value: nodeContext.namespaceId },
|
|
266
|
+
}),
|
|
267
|
+
};
|
|
268
|
+
return this.apolloFactory
|
|
269
|
+
.apollo(nodeContext, readFromParentKcpPath)
|
|
270
|
+
.query({
|
|
196
271
|
query: gql `
|
|
197
|
-
${
|
|
272
|
+
${rawQuery}
|
|
198
273
|
`,
|
|
199
|
-
variables:
|
|
274
|
+
variables: this.normalizeGqlBuilderVariables(variables),
|
|
200
275
|
})
|
|
201
276
|
.pipe(map((res) => getValueByPath(res.data, operation) ?? []), catchError((error) => {
|
|
202
277
|
this.alertErrors(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-mesh-portal-ui-lib-services.mjs","sources":["../../projects/lib/services/resource/gateway.service.ts","../../projects/lib/services/resource/apollo-factory.ts","../../projects/lib/services/resource/resource.service.ts","../../projects/lib/services/platform-mesh-portal-ui-lib-services.ts"],"sourcesContent":["import { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport { LuigiCoreService } from '@openmfp/portal-ui-lib';\n\n@Injectable({ providedIn: 'root' })\nexport class GatewayService {\n private luigiCoreService = inject(LuigiCoreService);\n\n public getGatewayUrl(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ) {\n const gatewayUrl = nodeContext.portalContext.crdGatewayApiUrl;\n const currentKcpPath = gatewayUrl.match(/\\/([^\\/]+)\\/graphql$/)?.[1] || '';\n return gatewayUrl?.replace(\n currentKcpPath,\n this.resolveKcpPath(nodeContext, readFromParentKcpPath),\n );\n }\n\n public updateCrdGatewayUrlWithEntityPath(kcpPath: string) {\n const gatewayUrl =\n this.luigiCoreService.getGlobalContext().portalContext.crdGatewayApiUrl;\n const kcpPathRegexp = /(.*\\/)[^/]+(?=\\/graphql$)/;\n this.luigiCoreService.getGlobalContext().portalContext.crdGatewayApiUrl =\n gatewayUrl.replace(kcpPathRegexp, `$1${kcpPath}`);\n }\n\n public resolveKcpPath(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): string {\n const gatewayUrl = nodeContext.portalContext.crdGatewayApiUrl;\n\n let kcpPath = gatewayUrl.match(/\\/([^\\/]+)\\/graphql$/)?.[1] || '';\n if (nodeContext.kcpPath) {\n kcpPath = nodeContext.kcpPath;\n }\n\n if (readFromParentKcpPath) {\n const lastIndex = kcpPath.lastIndexOf(':');\n if (lastIndex !== -1) {\n kcpPath = kcpPath.slice(0, lastIndex);\n }\n }\n\n return kcpPath;\n }\n}\n","import { GatewayService } from './gateway.service';\nimport { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport {\n type ApolloClientOptions,\n ApolloLink,\n Observable as ApolloObservable,\n FetchResult,\n InMemoryCache,\n Operation,\n split,\n} from '@apollo/client/core';\nimport { setContext } from '@apollo/client/link/context';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport { Apollo } from 'apollo-angular';\nimport { HttpLink } from 'apollo-angular/http';\nimport { print } from 'graphql';\nimport { Client, ClientOptions, createClient } from 'graphql-sse';\n\nclass SSELink extends ApolloLink {\n private client: Client;\n\n constructor(options: ClientOptions) {\n super();\n this.client = createClient(options);\n }\n\n public override request(operation: Operation): ApolloObservable<FetchResult> {\n return new ApolloObservable((sink) => {\n return this.client.subscribe(\n { ...operation, query: print(operation.query) },\n {\n next: sink.next.bind(sink),\n complete: sink.complete.bind(sink),\n error: sink.error.bind(sink),\n },\n );\n });\n }\n}\n\nconst noopZone = {\n run: (fn: any) => fn(),\n runOutsideAngular: (fn: any) => fn(),\n} as any;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ApolloFactory {\n private httpLink = inject(HttpLink);\n private gatewayService = inject(GatewayService);\n\n public readonly apollo = (\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): Apollo =>\n new Apollo(\n noopZone,\n this.createApolloOptions(nodeContext, readFromParentKcpPath),\n );\n\n private createApolloOptions(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): ApolloClientOptions<any> {\n const contextLink = setContext(() => {\n return {\n uri: () =>\n this.gatewayService.getGatewayUrl(nodeContext, readFromParentKcpPath),\n headers: {\n Authorization: `Bearer ${nodeContext.token}`,\n Accept: 'charset=utf-8',\n },\n };\n });\n\n const splitClient = split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === 'OperationDefinition' &&\n definition.operation === 'subscription'\n );\n },\n new SSELink({\n url: () =>\n this.gatewayService.getGatewayUrl(nodeContext, readFromParentKcpPath),\n headers: () => ({\n Authorization: `Bearer ${nodeContext.token}`,\n }),\n }),\n this.httpLink.create({}),\n );\n\n const link = ApolloLink.from([contextLink, splitClient]);\n const cache = new InMemoryCache();\n\n return {\n link,\n cache,\n };\n }\n}\n","import { ApolloFactory } from './apollo-factory';\nimport { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport { TypedDocumentNode } from '@apollo/client/core';\nimport { LuigiCoreService } from '@openmfp/portal-ui-lib';\nimport {\n AccountInfo,\n Resource,\n ResourceDefinition,\n} from '@platform-mesh/portal-ui-lib/models';\nimport {\n getValueByPath,\n replaceDotsAndHyphensWithUnderscores,\n stripTypename,\n} from '@platform-mesh/portal-ui-lib/utils';\nimport { gql } from 'apollo-angular';\nimport * as gqlBuilder from 'gql-query-builder';\nimport VariableOptions from 'gql-query-builder/build/VariableOptions';\nimport { EMPTY, Observable } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\ninterface ResourceResponseError extends Record<string, any> {\n message: string;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ResourceService {\n private apolloFactory = inject(ApolloFactory);\n private luigiCoreService = inject(LuigiCoreService);\n\n read(\n resourceId: string,\n operation: string,\n kind: string,\n fieldsOrRawQuery: any[] | string,\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean = true,\n ): Observable<Resource> {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n let query: string | TypedDocumentNode<any, any> = this.resolveReadQuery(\n fieldsOrRawQuery,\n kind,\n resourceId,\n isNamespacedResource ? nodeContext.namespaceId : undefined,\n operation,\n );\n\n try {\n query = gql`\n ${query}\n `;\n } catch (error) {\n this.luigiCoreService.showAlert({\n text: `Could not read a resource: ${resourceId}. Wrong read query: <br/><br/> ${query}`,\n type: 'error',\n });\n return EMPTY;\n }\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .query({\n query,\n variables: {\n name: resourceId,\n ...(isNamespacedResource && {\n namespace: nodeContext.namespaceId,\n }),\n },\n })\n .pipe(\n map((res) => res.data?.[operation]?.[kind]),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private resolveReadQuery(\n fieldsOrRawQuery: any[] | string,\n kind: string,\n resourceId: string,\n namespace: string | undefined,\n operation: string,\n ) {\n if (fieldsOrRawQuery instanceof Array) {\n return (\n gqlBuilder\n .query({\n operation: kind,\n variables: {\n name: { value: resourceId, type: 'String!' },\n ...(namespace && {\n namespace: { value: namespace, type: 'String' },\n }),\n },\n fields: fieldsOrRawQuery,\n })\n .query.replace(kind, `${operation} { ${kind}`)\n .trim() + '}'\n );\n } else {\n return fieldsOrRawQuery;\n }\n }\n\n list(\n operation: string,\n fieldsOrRawQuery: any[] | string,\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean = false,\n ): Observable<Resource[] | any> {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const variables = {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: nodeContext.namespaceId },\n }),\n };\n\n let query: { variables: any; query: string };\n\n if (fieldsOrRawQuery instanceof Array) {\n query = gqlBuilder.subscription({\n operation,\n fields: fieldsOrRawQuery,\n variables: variables,\n });\n } else {\n query = {\n variables: this.normalizeGqlBuilderVariables(variables),\n query: fieldsOrRawQuery,\n };\n }\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .subscribe({\n query: gql`\n ${query.query}\n `,\n variables: query.variables,\n })\n .pipe(\n map(\n (res: any): Resource[] =>\n getValueByPath<any, Resource[]>(res.data, operation) ?? [],\n ),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private alertErrors(res: ResourceResponseError) {\n this.luigiCoreService.showAlert({\n text: res.message,\n type: 'error',\n });\n }\n\n delete(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const kind = resourceDefinition.kind;\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `delete${kind}`,\n variables: {\n name: { type: 'String!', value: resource.metadata.name },\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: nodeContext.namespaceId },\n }),\n },\n fields: [],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate<void>({\n mutation: gql`\n ${mutation.query}\n `,\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n create(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const kind = resourceDefinition.kind;\n const namespace = nodeContext.namespaceId;\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `create${kind}`,\n variables: {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: namespace },\n }),\n object: { type: `${kind}Input!`, value: resource },\n },\n fields: ['__typename'],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate({\n mutation: gql`\n ${mutation.query}\n `,\n fetchPolicy: 'no-cache',\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n update(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const kind = resourceDefinition.kind;\n const namespace = nodeContext.namespaceId;\n\n const cleanResource = stripTypename(resource);\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `update${kind}`,\n variables: {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: namespace },\n }),\n name: { type: 'String!', value: resource.metadata.name },\n object: {\n type: `${kind}Input!`,\n value: cleanResource,\n },\n },\n fields: ['__typename'],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate({\n mutation: gql`\n ${mutation.query}\n `,\n fetchPolicy: 'no-cache',\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n readAccountInfo(nodeContext: ResourceNodeContext): Observable<AccountInfo> {\n return this.apolloFactory\n .apollo(nodeContext)\n .query<string>({\n query: gql`\n {\n core_platform_mesh_io {\n AccountInfo(name: \"account\") {\n metadata {\n name\n annotations\n }\n spec {\n clusterInfo {\n ca\n }\n organization {\n originClusterId\n }\n }\n }\n }\n }\n `,\n })\n .pipe(\n map((res: any) => {\n return res.data.core_platform_mesh_io.AccountInfo;\n }),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private isNamespacedResource(nodeContext: ResourceNodeContext) {\n return nodeContext?.resourceDefinition?.scope === 'Namespaced';\n }\n\n private normalizeGqlBuilderVariables(\n variables: VariableOptions,\n ): Record<string, any> {\n return Object.fromEntries(\n Object.entries(variables).map(([key, value]) => [key, value.value]),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["ApolloObservable"],"mappings":";;;;;;;;;;;;;;;MAKa,cAAc,CAAA;AAD3B,IAAA,WAAA,GAAA;AAEU,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AA0CpD,IAAA;AAxCQ,IAAA,aAAa,CAClB,WAAgC,EAChC,qBAAqB,GAAG,KAAK,EAAA;AAE7B,QAAA,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,gBAAgB;AAC7D,QAAA,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AAC1E,QAAA,OAAO,UAAU,EAAE,OAAO,CACxB,cAAc,EACd,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,qBAAqB,CAAC,CACxD;IACH;AAEO,IAAA,iCAAiC,CAAC,OAAe,EAAA;AACtD,QAAA,MAAM,UAAU,GACd,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,gBAAgB;QACzE,MAAM,aAAa,GAAG,2BAA2B;QACjD,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,gBAAgB;YACrE,UAAU,CAAC,OAAO,CAAC,aAAa,EAAE,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAC;IACrD;AAEO,IAAA,cAAc,CACnB,WAAgC,EAChC,qBAAqB,GAAG,KAAK,EAAA;AAE7B,QAAA,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,gBAAgB;AAE7D,QAAA,IAAI,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AACjE,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACvB,YAAA,OAAO,GAAG,WAAW,CAAC,OAAO;QAC/B;Q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AA,oBAAoB,CAAC,WAAgC,EAAA;AAC3D,QAAA,OAAO,WAAW,EAAE,kBAAkB,EAAE,KAAK,KAAK,YAAY;IAChE;AAEQ,IAAA,4BAA4B,CAClC,SAA0B,EAAA;AAE1B,QAAA,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CACpE;IACH;+GAvUW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAf,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFd,MAAM,EAAA,CAAA,CAAA;;4FAEP,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AC3BD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"platform-mesh-portal-ui-lib-services.mjs","sources":["../../projects/lib/services/resource/gateway.service.ts","../../projects/lib/services/resource/apollo-factory.ts","../../projects/lib/services/resource/resource.service.ts","../../projects/lib/services/platform-mesh-portal-ui-lib-services.ts"],"sourcesContent":["import { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport { LuigiCoreService } from '@openmfp/portal-ui-lib';\n\n@Injectable({ providedIn: 'root' })\nexport class GatewayService {\n private luigiCoreService = inject(LuigiCoreService);\n\n public getGatewayUrl(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ) {\n const gatewayUrl = nodeContext.portalContext.crdGatewayApiUrl;\n const currentKcpPath = gatewayUrl.match(/\\/([^\\/]+)\\/graphql$/)?.[1] || '';\n return gatewayUrl?.replace(\n currentKcpPath,\n this.resolveKcpPath(nodeContext, readFromParentKcpPath),\n );\n }\n\n public updateCrdGatewayUrlWithEntityPath(kcpPath: string) {\n const gatewayUrl =\n this.luigiCoreService.getGlobalContext().portalContext.crdGatewayApiUrl;\n const kcpPathRegexp = /(.*\\/)[^/]+(?=\\/graphql$)/;\n this.luigiCoreService.getGlobalContext().portalContext.crdGatewayApiUrl =\n gatewayUrl.replace(kcpPathRegexp, `$1${kcpPath}`);\n }\n\n public resolveKcpPath(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): string {\n const gatewayUrl = nodeContext.portalContext.crdGatewayApiUrl;\n\n let kcpPath = gatewayUrl.match(/\\/([^\\/]+)\\/graphql$/)?.[1] || '';\n if (nodeContext.kcpPath) {\n kcpPath = nodeContext.kcpPath;\n }\n\n if (readFromParentKcpPath) {\n const lastIndex = kcpPath.lastIndexOf(':');\n if (lastIndex !== -1) {\n kcpPath = kcpPath.slice(0, lastIndex);\n }\n }\n\n return kcpPath;\n }\n}\n","import { GatewayService } from './gateway.service';\nimport { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport {\n type ApolloClientOptions,\n ApolloLink,\n Observable as ApolloObservable,\n FetchResult,\n InMemoryCache,\n Operation,\n split,\n} from '@apollo/client/core';\nimport { setContext } from '@apollo/client/link/context';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport { Apollo } from 'apollo-angular';\nimport { HttpLink } from 'apollo-angular/http';\nimport { print } from 'graphql';\nimport { Client, ClientOptions, createClient } from 'graphql-sse';\n\nclass SSELink extends ApolloLink {\n private client: Client;\n\n constructor(options: ClientOptions) {\n super();\n this.client = createClient(options);\n }\n\n public override request(operation: Operation): ApolloObservable<FetchResult> {\n return new ApolloObservable((sink) => {\n return this.client.subscribe(\n { ...operation, query: print(operation.query) },\n {\n next: sink.next.bind(sink),\n complete: sink.complete.bind(sink),\n error: sink.error.bind(sink),\n },\n );\n });\n }\n}\n\nconst noopZone = {\n run: (fn: any) => fn(),\n runOutsideAngular: (fn: any) => fn(),\n} as any;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ApolloFactory {\n private httpLink = inject(HttpLink);\n private gatewayService = inject(GatewayService);\n\n public readonly apollo = (\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): Apollo =>\n new Apollo(\n noopZone,\n this.createApolloOptions(nodeContext, readFromParentKcpPath),\n );\n\n private createApolloOptions(\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath = false,\n ): ApolloClientOptions<any> {\n const contextLink = setContext(() => {\n return {\n uri: () =>\n this.gatewayService.getGatewayUrl(nodeContext, readFromParentKcpPath),\n headers: {\n Authorization: `Bearer ${nodeContext.token}`,\n Accept: 'charset=utf-8',\n },\n };\n });\n\n const splitClient = split(\n ({ query }) => {\n const definition = getMainDefinition(query);\n return (\n definition.kind === 'OperationDefinition' &&\n definition.operation === 'subscription'\n );\n },\n new SSELink({\n url: () =>\n this.gatewayService.getGatewayUrl(nodeContext, readFromParentKcpPath),\n headers: () => ({\n Authorization: `Bearer ${nodeContext.token}`,\n }),\n }),\n this.httpLink.create({}),\n );\n\n const link = ApolloLink.from([contextLink, splitClient]);\n const cache = new InMemoryCache();\n\n return {\n link,\n cache,\n };\n }\n}\n","import { ApolloFactory } from './apollo-factory';\nimport { ResourceNodeContext } from './resource-node-context';\nimport { Injectable, inject } from '@angular/core';\nimport { TypedDocumentNode } from '@apollo/client/core';\nimport { LuigiCoreService } from '@openmfp/portal-ui-lib';\nimport {\n AccountInfo,\n Resource,\n ResourceDefinition,\n ResourceListResult,\n ResourceOperationTypeMap,\n ResourceSubscriptionResult,\n} from '@platform-mesh/portal-ui-lib/models';\nimport {\n capitalize,\n getValueByPath,\n replaceDotsAndHyphensWithUnderscores,\n stripTypename,\n} from '@platform-mesh/portal-ui-lib/utils';\nimport { gql } from 'apollo-angular';\nimport * as gqlBuilder from 'gql-query-builder';\nimport VariableOptions from 'gql-query-builder/build/VariableOptions';\nimport { EMPTY, Observable, throwError } from 'rxjs';\nimport { catchError, map, startWith, switchMap } from 'rxjs/operators';\n\ninterface ResourceResponseError extends Record<string, any> {\n message: string;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ResourceService {\n private apolloFactory = inject(ApolloFactory);\n private luigiCoreService = inject(LuigiCoreService);\n\n read(\n resourceId: string,\n operation: string,\n kind: string,\n fieldsOrRawQuery: any[] | string,\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean = true,\n ): Observable<Resource> {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n let query: string | TypedDocumentNode<any, any> = this.resolveReadQuery(\n fieldsOrRawQuery,\n kind,\n resourceId,\n isNamespacedResource ? nodeContext.namespaceId : undefined,\n operation,\n );\n\n try {\n query = gql`\n ${query}\n `;\n } catch (error) {\n this.luigiCoreService.showAlert({\n text: `Could not read a resource: ${resourceId}. Wrong read query: <br/><br/> ${query}`,\n type: 'error',\n });\n return EMPTY;\n }\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .query({\n query,\n variables: {\n name: resourceId,\n ...(isNamespacedResource && {\n namespace: nodeContext.namespaceId,\n }),\n },\n })\n .pipe(\n map((res) => res.data?.[operation]?.[kind]),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private resolveReadQuery(\n fieldsOrRawQuery: any[] | string,\n kind: string,\n resourceId: string,\n namespace: string | undefined,\n operation: string,\n ) {\n if (fieldsOrRawQuery instanceof Array) {\n return (\n gqlBuilder\n .query({\n operation: kind,\n variables: {\n name: { value: resourceId, type: 'String!' },\n ...(namespace && {\n namespace: { value: namespace, type: 'String' },\n }),\n },\n fields: fieldsOrRawQuery,\n })\n .query.replace(kind, `${operation} { ${kind}`)\n .trim() + '}'\n );\n } else {\n return fieldsOrRawQuery;\n }\n }\n\n list(\n operation: string,\n fieldsOrRawQuery: any[] | string,\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean = false,\n ): Observable<Resource[] | any> {\n return fieldsOrRawQuery instanceof Array\n ? this.listWithFields(\n operation,\n fieldsOrRawQuery,\n nodeContext,\n readFromParentKcpPath,\n )\n : this.listWithRawQuery(\n operation,\n fieldsOrRawQuery,\n nodeContext,\n readFromParentKcpPath,\n );\n }\n\n private listWithFields(\n operation: string,\n fields: any[],\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean,\n ): Observable<Resource[] | any> {\n const resourceDefinition = nodeContext.resourceDefinition;\n if (!resourceDefinition) {\n return throwError(() => new Error('Resource definition is required'));\n }\n\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const variables = {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: nodeContext.namespaceId },\n }),\n };\n\n fields.push({ metadata: ['uid'] });\n\n return this.initialListQuery(\n resourceDefinition,\n fields,\n nodeContext,\n readFromParentKcpPath,\n variables,\n ).pipe(\n switchMap((value: ResourceListResult) => {\n const { resourceVersion, items } = value;\n const subscriptionQuery = gqlBuilder.subscription({\n operation: operation,\n fields: ['type', { object: fields }],\n variables: {\n ...variables,\n resourceVersion: { type: 'String', value: resourceVersion },\n },\n });\n\n const result = new Map<string, Resource>(\n items.map((item) => [item.metadata.uid!, item]),\n );\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .subscribe({\n query: gql`\n ${subscriptionQuery.query}\n `,\n variables: subscriptionQuery.variables,\n })\n .pipe(\n map((res: any): Resource[] => {\n const resourceResult: ResourceSubscriptionResult | undefined =\n getValueByPath(res.data, operation);\n\n if (!resourceResult) {\n return Array.from(result.values());\n }\n\n const { type, object } = resourceResult;\n if (type === ResourceOperationTypeMap.ADDED) {\n result.set(object.metadata.uid!, object);\n } else if (type === ResourceOperationTypeMap.MODIFIED) {\n result.set(object.metadata.uid!, object);\n } else if (type === ResourceOperationTypeMap.DELETED) {\n result.delete(object.metadata.uid!);\n }\n\n return Array.from(result.values());\n }),\n startWith(Array.from(result.values())),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }),\n );\n }\n\n private initialListQuery(\n resourceDefinition: ResourceDefinition,\n fields: any[],\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean,\n variables?: VariableOptions,\n ): Observable<ResourceListResult> {\n const operation = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const kind = capitalize(resourceDefinition.plural);\n const listQuery = gqlBuilder.query({\n operation,\n fields: [\n {\n [kind]: ['resourceVersion', { items: fields }],\n },\n ],\n variables: variables,\n });\n\n console.log(listQuery.query);\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .query({\n query: gql`\n ${listQuery.query}\n `,\n variables: listQuery.variables,\n })\n .pipe(\n map((res: any): ResourceListResult => {\n const resourceListResult = getValueByPath<any, any>(\n res.data,\n `${operation}.${kind}`,\n );\n if (!resourceListResult) {\n throw new Error('Resource list result not found');\n }\n\n return resourceListResult;\n }),\n );\n }\n\n private listWithRawQuery(\n operation: string,\n rawQuery: string,\n nodeContext: ResourceNodeContext,\n readFromParentKcpPath: boolean,\n ): Observable<any> {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const variables = {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: nodeContext.namespaceId },\n }),\n };\n\n return this.apolloFactory\n .apollo(nodeContext, readFromParentKcpPath)\n .query({\n query: gql`\n ${rawQuery}\n `,\n variables: this.normalizeGqlBuilderVariables(variables),\n })\n .pipe(\n map(\n (res: any): Resource[] =>\n getValueByPath<any, any>(res.data, operation) ?? [],\n ),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private alertErrors(res: ResourceResponseError) {\n this.luigiCoreService.showAlert({\n text: res.message,\n type: 'error',\n });\n }\n\n delete(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const kind = resourceDefinition.kind;\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `delete${kind}`,\n variables: {\n name: { type: 'String!', value: resource.metadata.name },\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: nodeContext.namespaceId },\n }),\n },\n fields: [],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate<void>({\n mutation: gql`\n ${mutation.query}\n `,\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n create(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const kind = resourceDefinition.kind;\n const namespace = nodeContext.namespaceId;\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `create${kind}`,\n variables: {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: namespace },\n }),\n object: { type: `${kind}Input!`, value: resource },\n },\n fields: ['__typename'],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate({\n mutation: gql`\n ${mutation.query}\n `,\n fetchPolicy: 'no-cache',\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n update(\n resource: Resource,\n resourceDefinition: ResourceDefinition,\n nodeContext: ResourceNodeContext,\n ) {\n const isNamespacedResource = this.isNamespacedResource(nodeContext);\n const group = replaceDotsAndHyphensWithUnderscores(\n resourceDefinition.group,\n );\n const kind = resourceDefinition.kind;\n const namespace = nodeContext.namespaceId;\n\n const cleanResource = stripTypename(resource);\n\n const mutation = gqlBuilder.mutation({\n operation: group,\n fields: [\n {\n operation: `update${kind}`,\n variables: {\n ...(isNamespacedResource && {\n namespace: { type: 'String', value: namespace },\n }),\n name: { type: 'String!', value: resource.metadata.name },\n object: {\n type: `${kind}Input!`,\n value: cleanResource,\n },\n },\n fields: ['__typename'],\n },\n ],\n });\n\n return this.apolloFactory\n .apollo(nodeContext)\n .mutate({\n mutation: gql`\n ${mutation.query}\n `,\n fetchPolicy: 'no-cache',\n variables: mutation.variables,\n })\n .pipe(\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n readAccountInfo(nodeContext: ResourceNodeContext): Observable<AccountInfo> {\n return this.apolloFactory\n .apollo(nodeContext)\n .query<string>({\n query: gql`\n {\n core_platform_mesh_io {\n AccountInfo(name: \"account\") {\n metadata {\n name\n annotations\n }\n spec {\n clusterInfo {\n ca\n }\n organization {\n originClusterId\n }\n }\n }\n }\n }\n `,\n })\n .pipe(\n map((res: any) => {\n return res.data.core_platform_mesh_io.AccountInfo;\n }),\n catchError((error) => {\n this.alertErrors(error);\n console.error('Error executing GraphQL query.', error);\n return error;\n }),\n );\n }\n\n private isNamespacedResource(nodeContext: ResourceNodeContext) {\n return nodeContext?.resourceDefinition?.scope === 'Namespaced';\n }\n\n private normalizeGqlBuilderVariables(\n variables: VariableOptions,\n ): Record<string, any> {\n return Object.fromEntries(\n Object.entries(variables).map(([key, value]) => [key, value.value]),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["ApolloObservable"],"mappings":";;;;;;;;;;;;;;;;MAKa,cAAc,CAAA;AAD3B,IAAA,WAAA,GAAA;AAEU,QAAA,IAAA,CAAA,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;AA0CpD,IAAA;AAxCQ,IAAA,aAAa,CAClB,WAAgC,EAChC,qBAAqB,GAAG,KAAK,E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AAA,CAAA;AAAf,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFd,MAAM,EAAA,CAAA,CAAA;;4FAEP,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AC/BD;;AAEG;;;;"}
|
|
@@ -122,6 +122,9 @@ function replaceDotsAndHyphensWithUnderscores(input) {
|
|
|
122
122
|
}
|
|
123
123
|
return input.replace(/[.-]/g, '_');
|
|
124
124
|
}
|
|
125
|
+
function capitalize(input) {
|
|
126
|
+
return input.charAt(0).toUpperCase() + input.slice(1);
|
|
127
|
+
}
|
|
125
128
|
|
|
126
129
|
const isLocalSetup = () => {
|
|
127
130
|
return window.location.hostname.includes('localhost') || window.location.hostname.includes('portal.dev.local');
|
|
@@ -146,5 +149,5 @@ function stripTypename(value) {
|
|
|
146
149
|
* Generated bundle index. Do not edit.
|
|
147
150
|
*/
|
|
148
151
|
|
|
149
|
-
export { decodeBase64, encodeBase64, generateGraphQLFields, getResourceValueByJsonPath, getValueByPath, isLocalSetup, replaceDotsAndHyphensWithUnderscores, stripTypename };
|
|
152
|
+
export { capitalize, decodeBase64, encodeBase64, generateGraphQLFields, getResourceValueByJsonPath, getValueByPath, isLocalSetup, replaceDotsAndHyphensWithUnderscores, stripTypename };
|
|
150
153
|
//# sourceMappingURL=platform-mesh-portal-ui-lib-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-mesh-portal-ui-lib-utils.mjs","sources":["../../projects/lib/utils/utils/columns-to-gql-fields.ts","../../projects/lib/utils/utils/resource-field-by-path.ts","../../projects/lib/utils/utils/get-value-by-path.ts","../../projects/lib/utils/utils/group-name-sanitizer.ts","../../projects/lib/utils/utils/is-local-setup.ts","../../projects/lib/utils/utils/resource-sanitizer.ts","../../projects/lib/utils/platform-mesh-portal-ui-lib-utils.ts"],"sourcesContent":["import { FieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\nexport const generateGraphQLFields = (uiFields: FieldDefinition[]): any[] => {\n const graphQLFields = [];\n uiFields.map((field) => {\n if (field.property instanceof Array) {\n field.property.map((property) => generate(property, graphQLFields));\n } else {\n generate(field.property, graphQLFields);\n }\n });\n return graphQLFields;\n};\n\nconst generate = (root: string, fields: any = []) => {\n if (!root) {\n return [];\n }\n\n const paths = root.split('.');\n\n for (const part of paths) {\n if (paths.length === 1) {\n fields.push(part);\n return fields;\n }\n\n fields.push({\n [part]: [...generate(paths.splice(1).join('.'))],\n });\n\n return fields;\n }\n};\n","import {\n PropertyField,\n Resource,\n TransformType,\n} from '@platform-mesh/portal-ui-lib/models';\nimport jsonpath from 'jsonpath';\n\nexport const getResourceValueByJsonPath = (\n resource: Resource,\n field: {\n jsonPathExpression?: string;\n property?: string | string[];\n propertyField?: PropertyField;\n },\n) => {\n const property = field.jsonPathExpression || field.property;\n if (!property) {\n return undefined;\n }\n\n if (property instanceof Array) {\n console.error(\n `Property defined as an array: ${JSON.stringify(property)}, provide \"jsonPathExpression\" field to properly ready resource value`,\n );\n return undefined;\n }\n\n const prefix = property.startsWith('$.') ? '' : '$.';\n const queryResult = jsonpath.query(resource, `${prefix}${property}`);\n const value = queryResult.length ? queryResult[0] : undefined;\n\n if (value && field.propertyField) {\n return executeTransform(\n value[field.propertyField.key],\n field.propertyField.transform,\n );\n }\n\n return value;\n};\n\nconst executeTransform = (\n value: string | undefined,\n transform: TransformType[] | undefined,\n): string | undefined => {\n if (value == null || transform == null || !transform.length) return value;\n\n return transform.reduce((acc, t) => {\n if (acc == null) return acc;\n\n switch (t) {\n case 'uppercase':\n return acc.toUpperCase();\n case 'lowercase':\n return acc.toLowerCase();\n case 'capitalize': {\n const str = String(acc);\n return str.length ? str.charAt(0).toUpperCase() + str.slice(1) : str;\n }\n case 'decode': {\n try {\n return decodeBase64(acc);\n } catch {\n return acc;\n }\n }\n case 'encode': {\n try {\n return encodeBase64(acc);\n } catch {\n return acc;\n }\n }\n default:\n return acc;\n }\n }, value);\n};\n\nexport const encodeBase64 = (str: string): string => {\n try {\n const utf8Bytes = new TextEncoder().encode(str);\n const binaryString = Array.from(utf8Bytes, (byte) =>\n String.fromCharCode(byte),\n ).join('');\n return btoa(binaryString);\n } catch (error) {\n console.error('Base64 encoding failed:', error);\n throw new Error('Failed to encode string to Base64');\n }\n};\n\nexport const decodeBase64 = (base64: string): string => {\n try {\n const binaryString = atob(base64);\n const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));\n return new TextDecoder().decode(bytes);\n } catch (error) {\n console.error('Base64 decoding failed:', error);\n throw new Error('Failed to decode Base64 string');\n }\n};\n","import { getResourceValueByJsonPath } from './resource-field-by-path';\nimport { Resource } from '@platform-mesh/portal-ui-lib/models';\n\nexport const getValueByPath = <T extends object, R = unknown>(\n obj: T,\n path: string,\n): R | undefined => {\n return getResourceValueByJsonPath(obj as Resource, {\n jsonPathExpression: path,\n });\n};\n","/**\n * Utility function to replace all occurrences of dots (.) and hyphens (-) with underscores (_)\n * @param input - The input string to process\n * @returns The processed string with dots and hyphens replaced by underscores\n */\nexport function replaceDotsAndHyphensWithUnderscores(input: string): string {\n if (!input) {\n return input;\n }\n\n return input.replace(/[.-]/g, '_');\n}\n","export const isLocalSetup = () => {\n return window.location.hostname.includes('localhost') || window.location.hostname.includes('portal.dev.local');\n};\n","export function stripTypename<T>(value: T): T {\n if (Array.isArray(value)) {\n return (value as unknown as any[]).map((v) => stripTypename(v)) as T;\n }\n if (value && typeof value === 'object') {\n const { __typename, ...rest } = value as Record<string, unknown> & {\n __typename?: string;\n };\n for (const k of Object.keys(rest)) {\n // @ts-ignore - rest is an indexable object\n rest[k] = stripTypename((rest as any)[k]);\n }\n return rest as T;\n }\n return value;\n}\n","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C;QAC3C;AACA,QAAA,OAAO,IAAS;IAClB;AACA,IAAA,OAAO,KAAK;AACd;;ACfA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"platform-mesh-portal-ui-lib-utils.mjs","sources":["../../projects/lib/utils/utils/columns-to-gql-fields.ts","../../projects/lib/utils/utils/resource-field-by-path.ts","../../projects/lib/utils/utils/get-value-by-path.ts","../../projects/lib/utils/utils/group-name-sanitizer.ts","../../projects/lib/utils/utils/is-local-setup.ts","../../projects/lib/utils/utils/resource-sanitizer.ts","../../projects/lib/utils/platform-mesh-portal-ui-lib-utils.ts"],"sourcesContent":["import { FieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\nexport const generateGraphQLFields = (uiFields: FieldDefinition[]): any[] => {\n const graphQLFields = [];\n uiFields.map((field) => {\n if (field.property instanceof Array) {\n field.property.map((property) => generate(property, graphQLFields));\n } else {\n generate(field.property, graphQLFields);\n }\n });\n return graphQLFields;\n};\n\nconst generate = (root: string, fields: any = []) => {\n if (!root) {\n return [];\n }\n\n const paths = root.split('.');\n\n for (const part of paths) {\n if (paths.length === 1) {\n fields.push(part);\n return fields;\n }\n\n fields.push({\n [part]: [...generate(paths.splice(1).join('.'))],\n });\n\n return fields;\n }\n};\n","import {\n PropertyField,\n Resource,\n TransformType,\n} from '@platform-mesh/portal-ui-lib/models';\nimport jsonpath from 'jsonpath';\n\nexport const getResourceValueByJsonPath = (\n resource: Resource,\n field: {\n jsonPathExpression?: string;\n property?: string | string[];\n propertyField?: PropertyField;\n },\n) => {\n const property = field.jsonPathExpression || field.property;\n if (!property) {\n return undefined;\n }\n\n if (property instanceof Array) {\n console.error(\n `Property defined as an array: ${JSON.stringify(property)}, provide \"jsonPathExpression\" field to properly ready resource value`,\n );\n return undefined;\n }\n\n const prefix = property.startsWith('$.') ? '' : '$.';\n const queryResult = jsonpath.query(resource, `${prefix}${property}`);\n const value = queryResult.length ? queryResult[0] : undefined;\n\n if (value && field.propertyField) {\n return executeTransform(\n value[field.propertyField.key],\n field.propertyField.transform,\n );\n }\n\n return value;\n};\n\nconst executeTransform = (\n value: string | undefined,\n transform: TransformType[] | undefined,\n): string | undefined => {\n if (value == null || transform == null || !transform.length) return value;\n\n return transform.reduce((acc, t) => {\n if (acc == null) return acc;\n\n switch (t) {\n case 'uppercase':\n return acc.toUpperCase();\n case 'lowercase':\n return acc.toLowerCase();\n case 'capitalize': {\n const str = String(acc);\n return str.length ? str.charAt(0).toUpperCase() + str.slice(1) : str;\n }\n case 'decode': {\n try {\n return decodeBase64(acc);\n } catch {\n return acc;\n }\n }\n case 'encode': {\n try {\n return encodeBase64(acc);\n } catch {\n return acc;\n }\n }\n default:\n return acc;\n }\n }, value);\n};\n\nexport const encodeBase64 = (str: string): string => {\n try {\n const utf8Bytes = new TextEncoder().encode(str);\n const binaryString = Array.from(utf8Bytes, (byte) =>\n String.fromCharCode(byte),\n ).join('');\n return btoa(binaryString);\n } catch (error) {\n console.error('Base64 encoding failed:', error);\n throw new Error('Failed to encode string to Base64');\n }\n};\n\nexport const decodeBase64 = (base64: string): string => {\n try {\n const binaryString = atob(base64);\n const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));\n return new TextDecoder().decode(bytes);\n } catch (error) {\n console.error('Base64 decoding failed:', error);\n throw new Error('Failed to decode Base64 string');\n }\n};\n","import { getResourceValueByJsonPath } from './resource-field-by-path';\nimport { Resource } from '@platform-mesh/portal-ui-lib/models';\n\nexport const getValueByPath = <T extends object, R = unknown>(\n obj: T,\n path: string,\n): R | undefined => {\n return getResourceValueByJsonPath(obj as Resource, {\n jsonPathExpression: path,\n });\n};\n","/**\n * Utility function to replace all occurrences of dots (.) and hyphens (-) with underscores (_)\n * @param input - The input string to process\n * @returns The processed string with dots and hyphens replaced by underscores\n */\nexport function replaceDotsAndHyphensWithUnderscores(input: string): string {\n if (!input) {\n return input;\n }\n\n return input.replace(/[.-]/g, '_');\n}\n\nexport function capitalize(input: string): string {\n return input.charAt(0).toUpperCase() + input.slice(1);\n}\n","export const isLocalSetup = () => {\n return window.location.hostname.includes('localhost') || window.location.hostname.includes('portal.dev.local');\n};\n","export function stripTypename<T>(value: T): T {\n if (Array.isArray(value)) {\n return (value as unknown as any[]).map((v) => stripTypename(v)) as T;\n }\n if (value && typeof value === 'object') {\n const { __typename, ...rest } = value as Record<string, unknown> & {\n __typename?: string;\n };\n for (const k of Object.keys(rest)) {\n // @ts-ignore - rest is an indexable object\n rest[k] = stripTypename((rest as any)[k]);\n }\n return rest as T;\n }\n return value;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB,GAAG,CAAC,QAA2B,KAAW;IAC1E,MAAM,aAAa,GAAG,EAAE;AACxB,IAAA,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,KAAI;AACrB,QAAA,IAAI,KAAK,CAAC,QAAQ,YAAY,KAAK,EAAE;AACnC,YAAA,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACrE;aAAO;AACL,YAAA,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC;QACzC;AACF,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,aAAa;AACtB;AAEA,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,MAAA,GAAc,EAAE,KAAI;IAClD,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,EAAE;IACX;IAEA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AAE7B,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,YAAA,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AACjB,YAAA,OAAO,MAAM;QACf;QAEA,MAAM,CAAC,IAAI,CAAC;AACV,YAAA,CAAC,I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,CAAC;AAChH;;ACFM,SAAU,aAAa,CAAI,KAAQ,EAAA;AACvC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,QAAA,OAAQ,KAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,CAAM;IACtE;AACA,IAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACtC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAE/B;QACD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;;YAEjC,IAAI,CAAC,CAAC,CAAC,GAAG,aAAa,CAAE,IAAY,CAAC,CAAC,CAAC,CAAC;QAC3C;AACA,QAAA,OAAO,IAAS;IAClB;AACA,IAAA,OAAO,KAAK;AACd;;ACfA;;AAEG;;;;"}
|
package/models/index.d.ts
CHANGED
|
@@ -88,6 +88,21 @@ interface UIDefinition {
|
|
|
88
88
|
createView?: UiView;
|
|
89
89
|
detailView?: UiView;
|
|
90
90
|
}
|
|
91
|
+
declare const ResourceOperationTypeMap: {
|
|
92
|
+
readonly ADDED: "ADDED";
|
|
93
|
+
readonly MODIFIED: "MODIFIED";
|
|
94
|
+
readonly DELETED: "DELETED";
|
|
95
|
+
};
|
|
96
|
+
type ResourceOperationType = (typeof ResourceOperationTypeMap)[keyof typeof ResourceOperationTypeMap];
|
|
97
|
+
interface ResourceSubscriptionResult {
|
|
98
|
+
type: ResourceOperationType;
|
|
99
|
+
object: Resource;
|
|
100
|
+
}
|
|
101
|
+
interface ResourceListResult {
|
|
102
|
+
resourceVersion: string;
|
|
103
|
+
items: Resource[];
|
|
104
|
+
}
|
|
91
105
|
type KubernetesScope = 'Cluster' | 'Namespaced';
|
|
92
106
|
|
|
93
|
-
export
|
|
107
|
+
export { ResourceOperationTypeMap };
|
|
108
|
+
export type { AccountInfo, FieldDefinition, KubernetesScope, LabelDisplay, PropertyField, Resource, ResourceDefinition, ResourceListResult, ResourceOperationType, ResourceSpec, ResourceStatus, ResourceSubscriptionResult, TransformType, UIDefinition, UiSettings };
|
package/package.json
CHANGED
package/services/index.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ declare class ResourceService {
|
|
|
46
46
|
read(resourceId: string, operation: string, kind: string, fieldsOrRawQuery: any[] | string, nodeContext: ResourceNodeContext, readFromParentKcpPath?: boolean): Observable<Resource>;
|
|
47
47
|
private resolveReadQuery;
|
|
48
48
|
list(operation: string, fieldsOrRawQuery: any[] | string, nodeContext: ResourceNodeContext, readFromParentKcpPath?: boolean): Observable<Resource[] | any>;
|
|
49
|
+
private listWithFields;
|
|
50
|
+
private initialListQuery;
|
|
51
|
+
private listWithRawQuery;
|
|
49
52
|
private alertErrors;
|
|
50
53
|
delete(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext): Observable<unknown>;
|
|
51
54
|
create(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext): Observable<unknown>;
|
package/utils/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare const getValueByPath: <T extends object, R = unknown>(obj: T, path: stri
|
|
|
10
10
|
* @returns The processed string with dots and hyphens replaced by underscores
|
|
11
11
|
*/
|
|
12
12
|
declare function replaceDotsAndHyphensWithUnderscores(input: string): string;
|
|
13
|
+
declare function capitalize(input: string): string;
|
|
13
14
|
|
|
14
15
|
declare const isLocalSetup: () => boolean;
|
|
15
16
|
|
|
@@ -23,4 +24,4 @@ declare const decodeBase64: (base64: string) => string;
|
|
|
23
24
|
|
|
24
25
|
declare function stripTypename<T>(value: T): T;
|
|
25
26
|
|
|
26
|
-
export { decodeBase64, encodeBase64, generateGraphQLFields, getResourceValueByJsonPath, getValueByPath, isLocalSetup, replaceDotsAndHyphensWithUnderscores, stripTypename };
|
|
27
|
+
export { capitalize, decodeBase64, encodeBase64, generateGraphQLFields, getResourceValueByJsonPath, getValueByPath, isLocalSetup, replaceDotsAndHyphensWithUnderscores, stripTypename };
|