amazon-connect / amazon-connect-streams

Amazon Connect Streams - a browser-based contact center integration API, typically with CRM systems.
https://docs.aws.amazon.com/connect/latest/userguide/
Apache License 2.0
388 stars 311 forks source link

AttributeDictionary: partial record #895

Closed mfulton26 closed 3 weeks ago

mfulton26 commented 3 months ago

AttributeDictionary is currently typed in such a way that when accessing an attribute, it is assumed to be present but the object for a key may not be present.

https://github.com/amazon-connect/amazon-connect-streams/blob/8cfe111ef0a850b84cac35450324b93f36dcbc41/src/index.d.ts#L1448-L1453

Can this be updated so that undefined is a possible value? This should make consuming code more resilient as TyepScript will require better type checking before attempting to consume something that isn't there.

    interface AttributeDictionary {
        readonly [key: string]:
            | {
                  name: string;
                  value: string;
              }
            | undefined;
    }

My guess is that there are other types that could similarly be updated (SegmentAttributeDictionary, ReferenceDictionary, etc.).