@platform-mesh/portal-ui-lib 0.69.0 → 0.70.1
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 +236 -236
- package/fesm2022/platform-mesh-portal-ui-lib-services.mjs +72 -54
- package/fesm2022/platform-mesh-portal-ui-lib-services.mjs.map +1 -1
- package/fesm2022/platform-mesh-portal-ui-lib-utils.mjs +11 -27
- package/fesm2022/platform-mesh-portal-ui-lib-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/platform-mesh-portal-ui-lib-services.d.ts +9 -3
- package/types/platform-mesh-portal-ui-lib-utils.d.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-mesh-portal-ui-lib-utils.mjs","sources":["../../projects/lib/utils/utils/build-graphql-input-type-name.ts","../../projects/lib/utils/utils/build-resource-list-operation.ts","../../projects/lib/utils/utils/flatten-field-tree.ts","../../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/instance-permission-key.ts","../../projects/lib/utils/utils/is-local-setup.ts","../../projects/lib/utils/utils/is-namespaced-resource.ts","../../projects/lib/utils/utils/merge-list-with-subscription-result.ts","../../projects/lib/utils/utils/parse-raw-gql-query.ts","../../projects/lib/utils/utils/resource-action-allowed.ts","../../projects/lib/utils/utils/resource-sanitizer.ts","../../projects/lib/utils/utils/delete-property-by-path.ts","../../projects/lib/utils/utils/set-property-by-path.ts","../../projects/lib/utils/platform-mesh-portal-ui-lib-utils.ts"],"sourcesContent":["function sanitizeGroup(group: string): string {\n let sanitized = group.replace(/[^a-zA-Z0-9]/g, '_');\n if (/^[0-9]/.test(sanitized)) {\n sanitized = '_' + sanitized;\n }\n return sanitized;\n}\n\nfunction pascalize(snakeCase: string): string {\n return snakeCase\n .split('_')\n .filter((segment) => segment.length > 0)\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join('');\n}\n\nexport function buildGraphQLInputTypeName(\n apiGroup: string | undefined,\n version: string | undefined,\n entity: string,\n): string {\n let prefix: string;\n\n if (apiGroup && version) {\n prefix = pascalize(sanitizeGroup(apiGroup) + '_' + version);\n } else if (apiGroup) {\n prefix = pascalize(sanitizeGroup(apiGroup));\n } else if (version) {\n prefix = pascalize('_' + version);\n } else {\n return `${entity}_Input`;\n }\n\n return `${prefix}${entity}_Input`;\n}\n","export function buildResourcePath(\n input: {\n apiGroup?: string | undefined;\n entity: string;\n version?: string | undefined;\n },\n separator: string = '_',\n): string {\n return [input.apiGroup, input.version, input.entity]\n .filter((p): p is string => !!p)\n .join(separator);\n}\n","import { PlatformMeshFieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\n/** Flattens nested `propertyCollection` trees into a list of leaf field definitions. */\nexport function flattenFieldTree(\n fields: readonly PlatformMeshFieldDefinition[] | undefined,\n): PlatformMeshFieldDefinition[] {\n const result: PlatformMeshFieldDefinition[] = [];\n for (const field of fields ?? []) {\n if (field.propertyCollection?.length) {\n result.push(...flattenFieldTree(field.propertyCollection));\n continue;\n }\n result.push(field);\n }\n return result;\n}\n","import { flattenFieldTree } from './flatten-field-tree';\nimport { PlatformMeshFieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\nexport type GenerateGraphQLFieldsOptions = {\n /** Omit fields marked writeOnly (for queries/mutation return selections). */\n forRead?: boolean;\n};\n\n/** Builds GraphQL field selections for reads, omitting write-only secrets. */\nexport const generateGraphQLReadFields = (\n uiFields: readonly PlatformMeshFieldDefinition[],\n): any[] => generateGraphQLFields(uiFields, { forRead: true });\n\nexport const generateGraphQLFields = (\n uiFields: readonly PlatformMeshFieldDefinition[],\n options: GenerateGraphQLFieldsOptions = {},\n): any[] => {\n const graphQLFields: any[] = [];\n const flattened = flattenFieldTree(uiFields);\n const fields = options.forRead\n ? flattened.filter((field) => !field.writeOnly)\n : flattened;\n fields.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 | undefined, 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 TransformType,\n} from '@platform-mesh/portal-ui-lib/models';\nimport { JSONPath } from 'jsonpath-plus';\n\nexport const getResourceValueByJsonPath = <T>(\n resource: T,\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({\n path: `${prefix}${property}`,\n json: resource as object,\n });\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","import { InstancePermission } from '@platform-mesh/portal-ui-lib/models';\n\nexport const permissionKey = (\n instance: Partial<Omit<InstancePermission, 'actions'>>,\n): string =>\n [instance.resource, instance.namespace, instance.name]\n .filter(Boolean)\n .join('/');\n","export const isLocalSetup = () => {\n return (\n window.location.hostname.includes('localhost') ||\n window.location.hostname.includes('portal.dev.local')\n );\n};\n","import { NodeContext } from '@openmfp/portal-ui-lib';\n\nexport function isNamespacedResource(nodeContext: Partial<NodeContext>) {\n return nodeContext?.resourceDefinition?.scope === 'Namespaced';\n}\n","import {\n Resource,\n ResourceOperationTypeMap,\n ResourceSubscriptionResult,\n} from '@platform-mesh/portal-ui-lib/models';\n\nexport interface MergeListWithSubscriptionResultOptions<T> {\n getItemKey: (item: T) => string | undefined;\n mapSubscriptionObjectToItem: (object: Resource) => T;\n}\n\nexport function mergeListWithSubscriptionResult<T>(\n items: T[],\n subscriptionResult: ResourceSubscriptionResult | undefined,\n options: MergeListWithSubscriptionResultOptions<T>,\n): T[] {\n if (!subscriptionResult) {\n return items;\n }\n\n const { getItemKey, mapSubscriptionObjectToItem } = options;\n\n const result = new Map<string, T>();\n items.forEach((item) => {\n const key = getItemKey(item);\n if (!key) {\n return;\n }\n result.set(key, item);\n });\n\n const { type, object } = subscriptionResult;\n const mappedObject = mapSubscriptionObjectToItem(object);\n const objectKey = getItemKey(mappedObject);\n if (!objectKey) {\n return items;\n }\n\n if (type === ResourceOperationTypeMap.ADDED) {\n result.set(objectKey, mappedObject);\n } else if (type === ResourceOperationTypeMap.MODIFIED) {\n if (result.has(objectKey)) {\n result.set(objectKey, mappedObject);\n }\n } else if (type === ResourceOperationTypeMap.DELETED) {\n result.delete(objectKey);\n }\n\n return [...result.values()];\n}\n","export const parseRawGqlQueryToFields = (s: string): any[] => {\n const tokens = s.replace(/[{}]/g, ' $& ').trim().split(/\\s+/);\n const root: any[] = [];\n const stack: any[][] = [root];\n\n for (let i = 0; i < tokens.length; i++) {\n const v = tokens[i];\n\n if (v === '{') continue;\n if (v === '}') {\n stack.pop();\n continue;\n }\n\n if (tokens[i + 1] === '{') {\n const node = { [v]: [] };\n stack.at(-1)?.push(node);\n stack.push(node[v]);\n } else {\n stack.at(-1)?.push(v);\n }\n }\n\n return root;\n};\n","/**\n * Tier-1 resource-level permission check (fail-open).\n *\n * Returns true when the verb is granted for the resource, OR when no\n * permissions were fetched for the resource at all (no entry in\n * portalPermissions → we don't gate). Returns false ONLY when permissions\n * WERE fetched for the resource and the verb is absent.\n */\nexport const resourceActionAllowed = (\n portalPermissions: { [key: string]: string[] } | undefined,\n resource: string | undefined,\n verb: string,\n): boolean => portalPermissions?.[resource ?? '']?.includes(verb) ?? true;\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","export function deletePropertyByPath<T extends Record<string, unknown>>(\n object: T,\n path: string,\n): T {\n const segments = path.split('.').filter(Boolean);\n if (segments.length === 0) {\n return object;\n }\n\n let current: Record<string, unknown> = object;\n\n for (let i = 0; i < segments.length - 1; i += 1) {\n const key = segments[i];\n const next = current[key];\n if (next == null || typeof next !== 'object') {\n return object;\n }\n current = next as Record<string, unknown>;\n }\n\n delete current[segments[segments.length - 1]];\n return object;\n}\n","export function setPropertyByPath<T extends Record<string, any>>(\n object: T,\n path: string,\n value: unknown,\n): T {\n const segments = path.split('.').filter(Boolean);\n if (segments.length === 0) {\n return object;\n }\n\n let current: Record<string, any> = object;\n\n for (let i = 0; i < segments.length; i += 1) {\n const key = segments[i];\n if (i === segments.length - 1) {\n current[key] = value;\n break;\n }\n\n const existing = current[key];\n\n if (\n existing === undefined ||\n existing === null ||\n typeof existing !== 'object'\n ) {\n current[key] = {};\n }\n\n current = current[key];\n }\n\n return object;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA,SAAS,aAAa,CAAC,KAAa,EAAA;IAClC,IAAI,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;AACnD,IAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;AAC5B,QAAA,SAAS,GAAG,GAAG,GAAG,SAAS;IAC7B;AACA,IAAA,OAAO,SAAS;AAClB;AAEA,SAAS,SAAS,CAAC,SAAiB,EAAA;AAClC,IAAA,OAAO;SACJ,KAAK,CAAC,GAAG;SACT,MAAM,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC;SACtC,GAAG,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;SACnE,IAAI,CAAC,EAAE,CAAC;AACb;SAEgB,yBAAyB,CACvC,QAA4B,EAC5B,OAA2B,EAC3B,MAAc,EA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CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAC3C,QAAA,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;AAC7B,YAAA,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK;YACpB;QACF;AAEA,QAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;QAE7B,IACE,QAAQ,KAAK,SAAS;AACtB,YAAA,QAAQ,KAAK,IAAI;AACjB,YAAA,OAAO,QAAQ,KAAK,QAAQ,EAC5B;AACA,YAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACnB;AAEA,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB;AAEA,IAAA,OAAO,MAAM;AACf;;ACjCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"platform-mesh-portal-ui-lib-utils.mjs","sources":["../../projects/lib/utils/utils/build-graphql-input-type-name.ts","../../projects/lib/utils/utils/build-resource-list-operation.ts","../../projects/lib/utils/utils/flatten-field-tree.ts","../../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/instance-permission-key.ts","../../projects/lib/utils/utils/is-local-setup.ts","../../projects/lib/utils/utils/is-namespaced-resource.ts","../../projects/lib/utils/utils/merge-list-with-subscription-result.ts","../../projects/lib/utils/utils/parse-raw-gql-query.ts","../../projects/lib/utils/utils/resource-action-allowed.ts","../../projects/lib/utils/utils/resource-sanitizer.ts","../../projects/lib/utils/utils/delete-property-by-path.ts","../../projects/lib/utils/utils/set-property-by-path.ts","../../projects/lib/utils/platform-mesh-portal-ui-lib-utils.ts"],"sourcesContent":["const QUERY_SUFFIX = 'Query';\n\n/**\n * Builds the input type name of a mutation from the `__typename` of the query\n * type that holds the resource (e.g. `NetworkAPIFooBarV1alpha1Query`). The\n * gateway names the input type `<prefix><Kind>_Input` with the same prefix,\n * so the UI does not need its own copy of the gateway's naming rule.\n */\nexport function buildGraphQLInputTypeName(\n queryTypeName: string | undefined,\n entity: string,\n): string {\n if (!queryTypeName?.endsWith(QUERY_SUFFIX)) {\n throw new Error(`Unexpected GraphQL query type name: ${queryTypeName}`);\n }\n\n const prefix = queryTypeName.slice(0, -QUERY_SUFFIX.length);\n return `${prefix}${entity}_Input`;\n}\n","export function buildResourcePath(\n input: {\n apiGroup?: string | undefined;\n entity: string;\n version?: string | undefined;\n },\n separator: string = '_',\n): string {\n return [input.apiGroup, input.version, input.entity]\n .filter((p): p is string => !!p)\n .join(separator);\n}\n","import { PlatformMeshFieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\n/** Flattens nested `propertyCollection` trees into a list of leaf field definitions. */\nexport function flattenFieldTree(\n fields: readonly PlatformMeshFieldDefinition[] | undefined,\n): PlatformMeshFieldDefinition[] {\n const result: PlatformMeshFieldDefinition[] = [];\n for (const field of fields ?? []) {\n if (field.propertyCollection?.length) {\n result.push(...flattenFieldTree(field.propertyCollection));\n continue;\n }\n result.push(field);\n }\n return result;\n}\n","import { flattenFieldTree } from './flatten-field-tree';\nimport { PlatformMeshFieldDefinition } from '@platform-mesh/portal-ui-lib/models';\n\nexport type GenerateGraphQLFieldsOptions = {\n /** Omit fields marked writeOnly (for queries/mutation return selections). */\n forRead?: boolean;\n};\n\n/** Builds GraphQL field selections for reads, omitting write-only secrets. */\nexport const generateGraphQLReadFields = (\n uiFields: readonly PlatformMeshFieldDefinition[],\n): any[] => generateGraphQLFields(uiFields, { forRead: true });\n\nexport const generateGraphQLFields = (\n uiFields: readonly PlatformMeshFieldDefinition[],\n options: GenerateGraphQLFieldsOptions = {},\n): any[] => {\n const graphQLFields: any[] = [];\n const flattened = flattenFieldTree(uiFields);\n const fields = options.forRead\n ? flattened.filter((field) => !field.writeOnly)\n : flattened;\n fields.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 | undefined, 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 TransformType,\n} from '@platform-mesh/portal-ui-lib/models';\nimport { JSONPath } from 'jsonpath-plus';\n\nexport const getResourceValueByJsonPath = <T>(\n resource: T,\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({\n path: `${prefix}${property}`,\n json: resource as object,\n });\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","import { InstancePermission } from '@platform-mesh/portal-ui-lib/models';\n\nexport const permissionKey = (\n instance: Partial<Omit<InstancePermission, 'actions'>>,\n): string =>\n [instance.resource, instance.namespace, instance.name]\n .filter(Boolean)\n .join('/');\n","export const isLocalSetup = () => {\n return (\n window.location.hostname.includes('localhost') ||\n window.location.hostname.includes('portal.dev.local')\n );\n};\n","import { NodeContext } from '@openmfp/portal-ui-lib';\n\nexport function isNamespacedResource(nodeContext: Partial<NodeContext>) {\n return nodeContext?.resourceDefinition?.scope === 'Namespaced';\n}\n","import {\n Resource,\n ResourceOperationTypeMap,\n ResourceSubscriptionResult,\n} from '@platform-mesh/portal-ui-lib/models';\n\nexport interface MergeListWithSubscriptionResultOptions<T> {\n getItemKey: (item: T) => string | undefined;\n mapSubscriptionObjectToItem: (object: Resource) => T;\n}\n\nexport function mergeListWithSubscriptionResult<T>(\n items: T[],\n subscriptionResult: ResourceSubscriptionResult | undefined,\n options: MergeListWithSubscriptionResultOptions<T>,\n): T[] {\n if (!subscriptionResult) {\n return items;\n }\n\n const { getItemKey, mapSubscriptionObjectToItem } = options;\n\n const result = new Map<string, T>();\n items.forEach((item) => {\n const key = getItemKey(item);\n if (!key) {\n return;\n }\n result.set(key, item);\n });\n\n const { type, object } = subscriptionResult;\n const mappedObject = mapSubscriptionObjectToItem(object);\n const objectKey = getItemKey(mappedObject);\n if (!objectKey) {\n return items;\n }\n\n if (type === ResourceOperationTypeMap.ADDED) {\n result.set(objectKey, mappedObject);\n } else if (type === ResourceOperationTypeMap.MODIFIED) {\n if (result.has(objectKey)) {\n result.set(objectKey, mappedObject);\n }\n } else if (type === ResourceOperationTypeMap.DELETED) {\n result.delete(objectKey);\n }\n\n return [...result.values()];\n}\n","export const parseRawGqlQueryToFields = (s: string): any[] => {\n const tokens = s.replace(/[{}]/g, ' $& ').trim().split(/\\s+/);\n const root: any[] = [];\n const stack: any[][] = [root];\n\n for (let i = 0; i < tokens.length; i++) {\n const v = tokens[i];\n\n if (v === '{') continue;\n if (v === '}') {\n stack.pop();\n continue;\n }\n\n if (tokens[i + 1] === '{') {\n const node = { [v]: [] };\n stack.at(-1)?.push(node);\n stack.push(node[v]);\n } else {\n stack.at(-1)?.push(v);\n }\n }\n\n return root;\n};\n","/**\n * Tier-1 resource-level permission check (fail-open).\n *\n * Returns true when the verb is granted for the resource, OR when no\n * permissions were fetched for the resource at all (no entry in\n * portalPermissions → we don't gate). Returns false ONLY when permissions\n * WERE fetched for the resource and the verb is absent.\n */\nexport const resourceActionAllowed = (\n portalPermissions: { [key: string]: string[] } | undefined,\n resource: string | undefined,\n verb: string,\n): boolean => portalPermissions?.[resource ?? '']?.includes(verb) ?? true;\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","export function deletePropertyByPath<T extends Record<string, unknown>>(\n object: T,\n path: string,\n): T {\n const segments = path.split('.').filter(Boolean);\n if (segments.length === 0) {\n return object;\n }\n\n let current: Record<string, unknown> = object;\n\n for (let i = 0; i < segments.length - 1; i += 1) {\n const key = segments[i];\n const next = current[key];\n if (next == null || typeof next !== 'object') {\n return object;\n }\n current = next as Record<string, unknown>;\n }\n\n delete current[segments[segments.length - 1]];\n return object;\n}\n","export function setPropertyByPath<T extends Record<string, any>>(\n object: T,\n path: string,\n value: unknown,\n): T {\n const segments = path.split('.').filter(Boolean);\n if (segments.length === 0) {\n return object;\n }\n\n let current: Record<string, any> = object;\n\n for (let i = 0; i < segments.length; i += 1) {\n const key = segments[i];\n if (i === segments.length - 1) {\n current[key] = value;\n break;\n }\n\n const existing = current[key];\n\n if (\n existing === undefined ||\n existing === null ||\n typeof existing !== 'object'\n ) {\n current[key] = {};\n }\n\n current = current[key];\n }\n\n return object;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,OAAO;AAE5B;;;;;AAKG;AACG,SAAU,yBAAyB,CACvC,aAAiC,EACjC,MAAc,EAAA;IAEd,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE;AAC1C,QAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,aAAa,CAAA,CAAE,CAAC;IACzE;AAEA,IAAA,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;AAC3D,IAAA,OAAO,CAAA,EAAG,MAAM,CAAA,EAAG,MAAM,QAAQ;AACnC;;SClBgB,iBAAiB,CAC/B,KAIC,EACD,YAAoB,GAAG,EAAA;AAEvB,IAAA,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM;SAChD,MAAM,CAAC,CAAC,CAAC,KAAkB,CAAC,CAAC,CAAC;SAC9B,IAAI,CAAC,SAAS,CAAC;AACpB;;ACTA;AACM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AAO,MAAM;QACf;QACA,OAAO,GAAG,IAA+B;IAC3C;IAEA,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC7C,IAAA,OAAO,MAAM;AACf;;SCtBgB,iBAAiB,CAC/B,MAAS,EACT,IAAY,EACZ,KAAc,EAAA;AAEd,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;AAChD,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,MAAM;IACf;IAEA,IAAI,OAAO,GAAwB,MAAM;AAEzC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAC3C,QAAA,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;AAC7B,YAAA,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK;YACpB;QACF;AAEA,QAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;QAE7B,IACE,QAAQ,KAAK,SAAS;AACtB,YAAA,QAAQ,KAAK,IAAI;AACjB,YAAA,OAAO,QAAQ,KAAK,QAAQ,EAC5B;AACA,YAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACnB;AAEA,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB;AAEA,IAAA,OAAO,MAAM;AACf;;ACjCA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NodeContext } from '@openmfp/portal-ui-lib';
|
|
2
2
|
import { ResourceDefinition, PermissionsDefinition, ButtonSettings, PlatformMeshFieldDefinition, Resource, DownloadKubeconfigFromSecretRefButtonSettings, ResourceOperationType, ResourcePagination, ResourceListResult, ResourceSubscriptionResult, AccountInfo, LogicalCluster } from '@platform-mesh/portal-ui-lib/models';
|
|
3
|
-
import * as apollo_angular from 'apollo-angular';
|
|
4
3
|
import { Apollo } from 'apollo-angular';
|
|
5
4
|
import * as i0 from '@angular/core';
|
|
6
5
|
import { Observable } from 'rxjs';
|
|
@@ -186,9 +185,16 @@ declare class ResourceService {
|
|
|
186
185
|
getAccessibleName(item: Resource): string | undefined;
|
|
187
186
|
private listWithRawQuery;
|
|
188
187
|
resourceChangeSubscription(operation: string, fields: any[], nodeContext: ResourceNodeContext, resourceVersion: string, readFromParentKcpPath: boolean): Observable<ResourceSubscriptionResult | undefined>;
|
|
189
|
-
delete(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext, readFromParentKcpPath?: boolean): Observable<
|
|
190
|
-
create(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext): Observable<
|
|
188
|
+
delete(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext, readFromParentKcpPath?: boolean): Observable<Apollo.MutateResult<void>>;
|
|
189
|
+
create(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext): Observable<Apollo.MutateResult<unknown>>;
|
|
191
190
|
update(resource: Resource, resourceDefinition: ResourceDefinition, nodeContext: ResourceNodeContext, readFromParentKcpPath?: boolean, fields?: any[]): Observable<unknown>;
|
|
191
|
+
/**
|
|
192
|
+
* Reads the `__typename` of the query type that holds the resource, e.g.
|
|
193
|
+
* `{ network_api_foo_bar { v1alpha1 { __typename } } }`, and derives the
|
|
194
|
+
* mutation input type name from it. The gateway generates the schema, so
|
|
195
|
+
* its type names are the only source of truth.
|
|
196
|
+
*/
|
|
197
|
+
private readInputTypeName;
|
|
192
198
|
getNamespace(nodeContext: ResourceNodeContext, resource?: Resource): string | undefined;
|
|
193
199
|
private normalizeGqlBuilderVariables;
|
|
194
200
|
private calcQueryOptions;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { PlatformMeshFieldDefinition, InstancePermission, Resource, ResourceSubscriptionResult, PropertyField } from '@platform-mesh/portal-ui-lib/models';
|
|
2
2
|
import { NodeContext } from '@openmfp/portal-ui-lib';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Builds the input type name of a mutation from the `__typename` of the query
|
|
6
|
+
* type that holds the resource (e.g. `NetworkAPIFooBarV1alpha1Query`). The
|
|
7
|
+
* gateway names the input type `<prefix><Kind>_Input` with the same prefix,
|
|
8
|
+
* so the UI does not need its own copy of the gateway's naming rule.
|
|
9
|
+
*/
|
|
10
|
+
declare function buildGraphQLInputTypeName(queryTypeName: string | undefined, entity: string): string;
|
|
5
11
|
|
|
6
12
|
declare function buildResourcePath(input: {
|
|
7
13
|
apiGroup?: string | undefined;
|