@dpuse/dpuse-shared 0.3.851 → 0.3.863
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/README.md +143 -154
- package/dist/componentConfig.schema-DT3mO5rS.js.map +1 -1
- package/dist/dpuse-shared-component.es.js.map +1 -1
- package/dist/dpuse-shared-componentDataView.es.js.map +1 -1
- package/dist/dpuse-shared-componentModuleConnector.es.js +1 -1
- package/dist/dpuse-shared-componentModuleConnector.es.js.map +1 -1
- package/dist/dpuse-shared-componentRecipe.es.js +0 -4
- package/dist/dpuse-shared-encoding.es.js.map +1 -1
- package/dist/dpuse-shared-errors.es.js +1 -1
- package/dist/dpuse-shared-errors.es.js.map +1 -1
- package/dist/dpuse-shared-locale.es.js.map +1 -1
- package/dist/label-DexpXrnC.js.map +1 -1
- package/dist/types/src/component/connection/index.d.ts +5 -4
- package/dist/types/src/component/context/index.d.ts +2 -1
- package/dist/types/src/component/context/model/entity/event/index.d.ts +2 -1
- package/dist/types/src/component/context/model/entity/index.d.ts +2 -1
- package/dist/types/src/component/dataView/index.d.ts +8 -7
- package/dist/types/src/component/index.d.ts +2 -3
- package/dist/types/src/component/module/connector/index.d.ts +1 -11
- package/dist/types/src/component/module/cookbook/index.d.ts +1 -2
- package/dist/types/src/component/module/index.d.ts +1 -2
- package/dist/types/src/component/presentation/index.d.ts +0 -12
- package/dist/types/src/component/recipe/index.d.ts +1 -2
- package/dist/types/src/encoding/index.d.ts +4 -4
- package/dist/types/src/errors/index.d.ts +2 -1
- package/dist/types/src/locale/label.d.ts +2 -1
- package/package.json +9 -16
- package/dist/dpuse-shared-componentRecipe.es.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-shared-component.es.js","names":[],"sources":["../src/component/index.ts"],"sourcesContent":["// ── External Dependencies & Registrations\nimport type { InferOutput } from 'valibot';\nimport { strictObject } from 'valibot';\n\n// ── DPUse Framework\nimport { componentBaseConfigSchema } from '
|
|
1
|
+
{"version":3,"file":"dpuse-shared-component.es.js","names":[],"sources":["../src/component/index.ts"],"sourcesContent":["// ── External Dependencies & Registrations\nimport type { InferOutput } from 'valibot';\nimport { strictObject } from 'valibot';\n\n// ── DPUse Framework\nimport { componentBaseConfigSchema } from './componentConfig.schema';\nimport { DEFAULT_LOCALE_ID } from '@/locale/label';\nimport type { componentInstanceConfigSchema, componentReferenceConfigSchema, componentStatusColorIdSchema, componentStatusConfigSchema } from './componentConfig.schema';\nimport type { LocaleId, LocaleLabel } from '@/locale/label';\n\n// ── Schemas ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport { componentInstanceConfigSchema } from './componentConfig.schema';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface Component {\n readonly config: ComponentInstanceConfig;\n}\n\n// ── Types - Base ─────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type ComponentBaseConfig = InferOutput<ReturnType<typeof strictObject<typeof componentBaseConfigSchema>>>;\n\n// ── Types - Instance Configuration ───────────────────────────────────────────────────────────────────────────────────\n\nexport type ComponentInstanceConfig = InferOutput<typeof componentInstanceConfigSchema>;\n\n// ── Types - Reference Configuration ──────────────────────────────────────────────────────────────────────────────────\n\nexport type ComponentReferenceConfig = InferOutput<typeof componentReferenceConfigSchema>;\n\n// ── Types - Status ───────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype ComponentStatus = InferOutput<typeof componentStatusConfigSchema>;\ntype ComponentStatusColorId = InferOutput<typeof componentStatusColorIdSchema>;\n\n// ── Constants - Status ───────────────────────────────────────────────────────────────────────────────────────────────\n\nconst COMPONENT_STATUS_CONFIGS: { id: string; color: ComponentStatusColorId; labels: LocaleLabel }[] = [\n { id: 'alpha', color: 'danger', labels: { en: 'alpha', es: 'alfa' } },\n { id: 'beta', color: 'warning', labels: { en: 'beta', es: 'beta' } },\n { id: 'releaseCandidate', color: 'success', labels: { en: 'release-candidate', es: 'candidato-de-lanzamiento' } },\n { id: 'generalAvailability', color: 'success', labels: { en: '', es: '' } }\n];\n\n// ── Actions - Status ─────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function getComponentStatus(id: string, localeId: LocaleId = DEFAULT_LOCALE_ID): ComponentStatus {\n const componentStatus = COMPONENT_STATUS_CONFIGS.find((componentStatus) => componentStatus.id === id);\n if (componentStatus) {\n const label = componentStatus.labels[localeId] ?? componentStatus.labels[DEFAULT_LOCALE_ID] ?? componentStatus.id;\n return { color: componentStatus.color, label };\n }\n return { color: 'danger', label: id };\n}\n"],"mappings":";;;AAuCA,IAAM,IAAiG;CACnG;EAAE,IAAI;EAAS,OAAO;EAAU,QAAQ;GAAE,IAAI;GAAS,IAAI;EAAO;CAAE;CACpE;EAAE,IAAI;EAAQ,OAAO;EAAW,QAAQ;GAAE,IAAI;GAAQ,IAAI;EAAO;CAAE;CACnE;EAAE,IAAI;EAAoB,OAAO;EAAW,QAAQ;GAAE,IAAI;GAAqB,IAAI;EAA2B;CAAE;CAChH;EAAE,IAAI;EAAuB,OAAO;EAAW,QAAQ;GAAE,IAAI;GAAI,IAAI;EAAG;CAAE;AAC9E;AAIA,SAAgB,EAAmB,GAAY,IAAA,MAAyD;CACpG,IAAM,IAAkB,EAAyB,MAAM,MAAoB,EAAgB,OAAO,CAAE;CACpG,IAAI,GAAiB;EACjB,IAAM,IAAQ,EAAgB,OAAO,MAAa,EAAgB,OAAA,MAA6B,EAAgB;EAC/G,OAAO;GAAE,OAAO,EAAgB;GAAO;EAAM;CACjD;CACA,OAAO;EAAE,OAAO;EAAU,OAAO;CAAG;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-shared-componentDataView.es.js","names":[],"sources":["../src/component/dataView/index.ts"],"sourcesContent":["// ── External Dependencies & Registrations\nimport type { FileTypeResult } from 'file-type';\n\n// ── DPUse Framework\nimport type { Component, ComponentInstanceConfig } from '@/component';\nimport type { ConnectionNodeConfig, ObjectColumnConfig } from '@/component/connection';\nimport { createLabelMap, DEFAULT_LOCALE_ID, type LocaleLabelMap, resolveLabel } from '@/locale/label';\n\n// ── Types - Interface ────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype DataViewInterface = Component;\n\n// ── Types - Configuration ────────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DataViewConfig extends ComponentInstanceConfig {\n typeId: 'dataView';\n connectionId: string | undefined;\n connectionNodeConfig: ConnectionNodeConfig | undefined;\n previewConfig: PreviewConfig | undefined;\n contentAuditConfig: ContentAuditConfig | undefined;\n relationshipsAuditConfig: RelationshipsAuditConfig | undefined;\n}\n\n// ── Types - Preview Configuration ────────────────────────────────────────────────────────────────────────────────────\n\nexport interface PreviewConfig {\n asAt: number;\n commentMarkId?: string | undefined; // TODO: under review.\n commentMarkOtherCharSeq?: string | undefined; // TODO: under review.\n columnConfigs: ObjectColumnConfig[];\n dataFormatId: DataFormatId;\n duration: number;\n encodingConfidenceLevel: number | undefined;\n encodingId: string | undefined;\n errorMessage?: string | undefined; // TODO: under review.\n fileType: FileTypeResult | undefined;\n hasHeaders: boolean | undefined;\n inferenceRecords: InferenceRecord[];\n linesToSkipAtStart?: number | undefined; // TODO: under review.\n parsedRecords: ParsingRecord[];\n quoteEscapeChar?: string | undefined; // TODO: under review.\n quoteMarkId?: string | undefined; // TODO: under review.\n quoteMarkOtherCharSeq?: string | undefined; // TODO: under review.\n recordDelimiterId: RecordDelimiterId | undefined;\n recordDelimiterOtherCharSeq?: string | undefined; // TODO: under review.\n size: number | undefined;\n skipEmptyLines?: boolean | undefined; // TODO: under review.\n skipLinesWithEmptyValues?: boolean | undefined; // TODO: under review.\n skipLinesWithErrors?: boolean | undefined; // TODO: under review.\n text: string | undefined;\n valueDelimiterId: ValueDelimiterId | undefined;\n valueDelimiterOtherCharSeq?: string | undefined; // TODO: under review.\n valueTrimMethodId?: ValueTrimMethodId | undefined; // TODO: under review.\n}\n\nexport type DataFormatId = 'dpe' | 'dtv' | 'json' | 'spss' | 'xlsx' | 'xml' | 'unknown';\n\nexport type ParsingRecord = ParsingResult[];\n\nexport interface ParsingResult {\n value: string | null;\n valueWasQuoted: boolean;\n}\n\nexport type RecordDelimiterId = '\\n' | '\\r' | '\\r\\n'; // TODO: We need a special value here (NOT '') for when a user specified delimiter is implemented.\n\nexport type ValueDelimiterId = '' | ':' | ',' | '!' | '0x1E' | ';' | ' ' | '\\t' | '_' | '0x1F' | '|'; // TODO: We need a special value here (NOT '') for when a user specified delimiter is implemented.\n\nexport type ValueTrimMethodId = 'both' | 'left' | 'right' | 'none';\n\n// ── Types - Content Audit Configuration ──────────────────────────────────────────────────────────────────────────────\n\nexport interface ContentAuditConfig {\n asAt: number;\n columns: ObjectColumnConfig[];\n commentLineCount: number;\n emptyLineCount: number;\n invalidFieldLengthCount: number;\n duration: number;\n lineCount: number;\n recordCount: number;\n}\n\n// ── Types - Relationships Audit Configuration ────────────────────────────────────────────────────────────────────────\n\nexport interface RelationshipsAuditConfig {\n placeholder: string; // TODO\n}\n\n// ── Types - Data Type Identifiers ────────────────────────────────────────────────────────────────────────────────────\n\nexport type DataTypeId = 'boolean' | 'numeric' | 'string' | 'temporal' | 'unknown';\n\nexport type DataSubtypeId = NumericSubtypeId | StringSubtypeId | TemporalSubtypeId;\n\nexport type NumericSubtypeId = 'bigint' | 'integer' | 'decimal';\n\nexport type StringSubtypeId = 'email' | 'ipv4' | 'ipv6' | 'ulid' | 'uuid' | 'url' | 'plain';\n\nexport type TemporalSubtypeId = 'date' | 'dateTime' | 'time';\n\n// ── Types - Data Type Inference ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface InferenceSummary {\n columnConfigs: ObjectColumnConfig[];\n hasHeaderRow: boolean;\n typedRecords: InferenceRecord[];\n}\n\nexport type InferenceRecord = InferenceResult[];\n\nexport type InferenceResult = BooleanInferenceResult | NumericInferenceResult | StringInferenceResult | TemporalInferenceResult | UnknownInferenceResult;\n\nexport interface BooleanInferenceResult {\n dataTypeId: 'boolean';\n dataSubtypeId: undefined;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: boolean;\n}\n\nexport type NumericInferenceResult = BigIntInferenceResult | NumberInferenceResult;\n\nexport interface BigIntInferenceResult {\n dataTypeId: 'numeric';\n dataSubtypeId: 'bigint';\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: bigint;\n currencySymbolId: string | undefined;\n decimalPlaces: number;\n signId: NumericSignId;\n unitsId: NumericUnitsId;\n}\n\nexport interface NumberInferenceResult {\n dataTypeId: 'numeric';\n dataSubtypeId: 'integer' | 'decimal';\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: number;\n currencySymbolId: string | undefined;\n decimalPlaces: number;\n signId: NumericSignId;\n unitsId: NumericUnitsId;\n}\n\nexport type NumericSignId = 'negative' | 'zero' | 'positive';\n\nexport type NumericUnitsId = 'currency' | 'percentage' | 'plain';\n\nexport interface StringInferenceResult {\n dataTypeId: 'string';\n dataSubtypeId: StringSubtypeId;\n format: string | undefined;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: string;\n}\n\nexport interface TemporalInferenceResult {\n dataTypeId: 'temporal';\n dataSubtypeId: TemporalSubtypeId;\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: Date;\n}\n\nexport interface UnknownInferenceResult {\n dataTypeId: 'unknown';\n dataSubtypeId: undefined;\n inputValue: string | null;\n inputValueWasQuoted: boolean;\n inferredValue: null;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst DATA_FORMATS_CONFIG: { id: DataFormatId; labels: LocaleLabelMap }[] = [\n { id: 'dpe', labels: createLabelMap({ en: 'Data Positioning Events' }) },\n { id: 'dtv', labels: createLabelMap({ en: 'Delimited Text' }) },\n { id: 'json', labels: createLabelMap({ en: 'JSON' }) },\n { id: 'spss', labels: createLabelMap({ en: 'SPSS' }) },\n { id: 'xlsx', labels: createLabelMap({ en: 'XLSX' }) },\n { id: 'xml', labels: createLabelMap({ en: 'XML' }) }\n];\n\nexport const ORDERED_VALUE_DELIMITER_IDS: ValueDelimiterId[] = [',', ';', '\\t', '|', ' ', ':', '_', '!', '0x1F', '0x1E']; // Ordered from estimated most common to least common.\n\nconst RECORD_DELIMITERS_CONFIG: { id: RecordDelimiterId; labels: LocaleLabelMap }[] = [\n { id: '\\n', labels: createLabelMap({ en: 'Newline' }) },\n { id: '\\r', labels: createLabelMap({ en: 'Carriage Return' }) },\n { id: '\\r\\n', labels: createLabelMap({ en: 'Carriage Return/Newline' }) }\n];\n\nconst VALUE_DELIMITERS_CONFIG: { id: ValueDelimiterId; labels: LocaleLabelMap }[] = [\n { id: ':', labels: createLabelMap({ en: 'Colon' }) },\n { id: ',', labels: createLabelMap({ en: 'Comma' }) },\n { id: '!', labels: createLabelMap({ en: 'Exclamation Mark' }) },\n // { id: '', label: { 'en': 'Other' } }, // TODO: Maybe set this to a 'not printing' or special ascii character when there is a user supplied delimited, rather than ''?\n { id: '0x1E', labels: createLabelMap({ en: 'Record Separator' }) },\n { id: ';', labels: createLabelMap({ en: 'Semicolon' }) },\n { id: ' ', labels: createLabelMap({ en: 'Space' }) },\n { id: '\\t', labels: createLabelMap({ en: 'Tab' }) },\n { id: '_', labels: createLabelMap({ en: 'Underscore' }) },\n { id: '0x1F', labels: createLabelMap({ en: 'Unit Separator' }) },\n { id: '|', labels: createLabelMap({ en: 'Vertical Bar' }) }\n];\n\n// ── Actions - Data Format(s) ─────────────────────────────────────────────────────────────────────────────────────────\n\ninterface ObjectDataFormat {\n id: DataFormatId;\n label: string;\n}\n\nfunction getDataFormat(id: DataFormatId, localeId = DEFAULT_LOCALE_ID): ObjectDataFormat {\n const dataFormat = DATA_FORMATS_CONFIG.find((dataFormat) => dataFormat.id === id);\n if (dataFormat) {\n const localizedLabel = resolveLabel(dataFormat.labels, localeId);\n return { id: dataFormat.id, label: localizedLabel ?? dataFormat.id };\n }\n return { id, label: id };\n}\n\nfunction getDataFormats(localeId = DEFAULT_LOCALE_ID): ObjectDataFormat[] {\n const items: ObjectDataFormat[] = [];\n for (const dataFormat of DATA_FORMATS_CONFIG) {\n const localizedLabel = resolveLabel(dataFormat.labels, localeId);\n items.push({ id: dataFormat.id, label: localizedLabel ?? dataFormat.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n}\n\n// ── Actions - Record Delimiter(s) ────────────────────────────────────────────────────────────────────────────────────\n\ninterface ObjectRecordDelimiter {\n id: RecordDelimiterId;\n label: string;\n}\n\nconst getRecordDelimiter = (id: RecordDelimiterId, localeId = DEFAULT_LOCALE_ID): ObjectRecordDelimiter => {\n const recordDelimiter = RECORD_DELIMITERS_CONFIG.find((recordDelimiter) => recordDelimiter.id === id);\n if (recordDelimiter) {\n const localizedLabel = resolveLabel(recordDelimiter.labels, localeId);\n return { id: recordDelimiter.id, label: localizedLabel ?? recordDelimiter.id };\n }\n return { id, label: id };\n};\n\nconst getRecordDelimiters = (localeId = DEFAULT_LOCALE_ID): ObjectRecordDelimiter[] => {\n const items: ObjectRecordDelimiter[] = [];\n for (const recordDelimiter of RECORD_DELIMITERS_CONFIG) {\n const localizedLabel = resolveLabel(recordDelimiter.labels, localeId);\n items.push({ id: recordDelimiter.id, label: localizedLabel ?? recordDelimiter.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n};\n\n// ── Actions - Value Delimiter(s) ─────────────────────────────────────────────────────────────────────────────────────\n\ninterface ValueDelimiter {\n id: ValueDelimiterId;\n label: string;\n}\nconst getValueDelimiter = (id: ValueDelimiterId, localeId = DEFAULT_LOCALE_ID): ValueDelimiter => {\n const valueDelimiter = VALUE_DELIMITERS_CONFIG.find((valueDelimiter) => valueDelimiter.id === id);\n if (valueDelimiter) {\n const localizedLabel = resolveLabel(valueDelimiter.labels, localeId);\n return { id: valueDelimiter.id, label: localizedLabel ?? valueDelimiter.id };\n }\n return { id, label: id };\n};\n\nconst getValueDelimiters = (localeId = DEFAULT_LOCALE_ID): ValueDelimiter[] => {\n const items: ValueDelimiter[] = [];\n for (const valueDelimiter of VALUE_DELIMITERS_CONFIG) {\n const localizedLabel = resolveLabel(valueDelimiter.labels, localeId);\n items.push({ id: valueDelimiter.id, label: localizedLabel ?? valueDelimiter.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n};\n"],"mappings":";;AAsLyB,EAAe,EAAE,IAAI,0BAA0B,CAAC,GAChD,EAAe,EAAE,IAAI,iBAAiB,CAAC,GACtC,EAAe,EAAE,IAAI,OAAO,CAAC,GAC7B,EAAe,EAAE,IAAI,OAAO,CAAC,GAC7B,EAAe,EAAE,IAAI,OAAO,CAAC,GAC9B,EAAe,EAAE,IAAI,MAAM,CAAC;AAGrD,IAAa,IAAkD;CAAC;CAAK;CAAK;CAAM;CAAK;CAAK;CAAK;CAAK;CAAK;CAAQ;AAAM;AAG/F,EAAe,EAAE,IAAI,UAAU,CAAC,GAChC,EAAe,EAAE,IAAI,kBAAkB,CAAC,GACtC,EAAe,EAAE,IAAI,0BAA0B,CAAC,GAInD,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC9B,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC9B,EAAe,EAAE,IAAI,mBAAmB,CAAC,GAEtC,EAAe,EAAE,IAAI,mBAAmB,CAAC,GAC5C,EAAe,EAAE,IAAI,YAAY,CAAC,GAClC,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC7B,EAAe,EAAE,IAAI,MAAM,CAAC,GAC7B,EAAe,EAAE,IAAI,aAAa,CAAC,GAChC,EAAe,EAAE,IAAI,iBAAiB,CAAC,GAC1C,EAAe,EAAE,IAAI,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"dpuse-shared-componentDataView.es.js","names":[],"sources":["../src/component/dataView/index.ts"],"sourcesContent":["// ── External Dependencies & Registrations\nimport type { FileTypeResult } from 'file-type';\n\n// ── DPUse Framework\nimport type { Component, ComponentInstanceConfig } from '@/component';\nimport type { ConnectionNodeConfig, ObjectColumnConfig } from '@/component/connection';\nimport { createLabelMap, DEFAULT_LOCALE_ID, type LocaleLabelMap, resolveLabel } from '@/locale/label';\n\n// ── Types - Interface ────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype DataViewInterface = Component;\n\n// ── Types - Configuration ────────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DataViewConfig extends ComponentInstanceConfig {\n typeId: 'dataView';\n connectionId: string | undefined;\n connectionNodeConfig: ConnectionNodeConfig | undefined;\n previewConfig: PreviewConfig | undefined;\n contentAuditConfig: ContentAuditConfig | undefined;\n relationshipsAuditConfig: RelationshipsAuditConfig | undefined;\n}\n\n// ── Types - Preview Configuration ────────────────────────────────────────────────────────────────────────────────────\n\nexport interface PreviewConfig {\n asAt: number;\n commentMarkId?: string | undefined; // TODO: under review.\n commentMarkOtherCharSeq?: string | undefined; // TODO: under review.\n columnConfigs: ObjectColumnConfig[];\n dataFormatId: DataFormatId;\n duration: number;\n encodingConfidenceLevel: number | undefined;\n encodingId: string | undefined;\n errorMessage?: string | undefined; // TODO: under review.\n fileType: FileTypeResult | undefined;\n hasHeaders: boolean | undefined;\n inferenceRecords: InferenceRecord[];\n linesToSkipAtStart?: number | undefined; // TODO: under review.\n parsedRecords: ParsingRecord[];\n quoteEscapeChar?: string | undefined; // TODO: under review.\n quoteMarkId?: string | undefined; // TODO: under review.\n quoteMarkOtherCharSeq?: string | undefined; // TODO: under review.\n recordDelimiterId: RecordDelimiterId | undefined;\n recordDelimiterOtherCharSeq?: string | undefined; // TODO: under review.\n size: number | undefined;\n skipEmptyLines?: boolean | undefined; // TODO: under review.\n skipLinesWithEmptyValues?: boolean | undefined; // TODO: under review.\n skipLinesWithErrors?: boolean | undefined; // TODO: under review.\n text: string | undefined;\n valueDelimiterId: ValueDelimiterId | undefined;\n valueDelimiterOtherCharSeq?: string | undefined; // TODO: under review.\n valueTrimMethodId?: ValueTrimMethodId | undefined; // TODO: under review.\n}\n\nexport type DataFormatId = 'dpe' | 'dtv' | 'json' | 'spss' | 'xlsx' | 'xml' | 'unknown';\n\nexport type ParsingRecord = ParsingResult[];\n\ninterface ParsingResult {\n value: string | null;\n valueWasQuoted: boolean;\n}\n\nexport type RecordDelimiterId = '\\n' | '\\r' | '\\r\\n'; // TODO: We need a special value here (NOT '') for when a user specified delimiter is implemented.\n\nexport type ValueDelimiterId = '' | ':' | ',' | '!' | '0x1E' | ';' | ' ' | '\\t' | '_' | '0x1F' | '|'; // TODO: We need a special value here (NOT '') for when a user specified delimiter is implemented.\n\ntype ValueTrimMethodId = 'both' | 'left' | 'right' | 'none';\n\n// ── Types - Content Audit Configuration ──────────────────────────────────────────────────────────────────────────────\n\nexport interface ContentAuditConfig {\n asAt: number;\n columns: ObjectColumnConfig[];\n commentLineCount: number;\n emptyLineCount: number;\n invalidFieldLengthCount: number;\n duration: number;\n lineCount: number;\n recordCount: number;\n}\n\n// ── Types - Relationships Audit Configuration ────────────────────────────────────────────────────────────────────────\n\ninterface RelationshipsAuditConfig {\n placeholder: string; // TODO\n}\n\n// ── Types - Data Type Identifiers ────────────────────────────────────────────────────────────────────────────────────\n\nexport type DataTypeId = 'boolean' | 'numeric' | 'string' | 'temporal' | 'unknown';\n\nexport type DataSubtypeId = NumericSubtypeId | StringSubtypeId | TemporalSubtypeId;\n\nexport type NumericSubtypeId = 'bigint' | 'integer' | 'decimal';\n\ntype StringSubtypeId = 'email' | 'ipv4' | 'ipv6' | 'ulid' | 'uuid' | 'url' | 'plain';\n\nexport type TemporalSubtypeId = 'date' | 'dateTime' | 'time';\n\n// ── Types - Data Type Inference ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface InferenceSummary {\n columnConfigs: ObjectColumnConfig[];\n hasHeaderRow: boolean;\n typedRecords: InferenceRecord[];\n}\n\nexport type InferenceRecord = InferenceResult[];\n\nexport type InferenceResult = BooleanInferenceResult | NumericInferenceResult | StringInferenceResult | TemporalInferenceResult | UnknownInferenceResult;\n\nexport interface BooleanInferenceResult {\n dataTypeId: 'boolean';\n dataSubtypeId: undefined;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: boolean;\n}\n\nexport type NumericInferenceResult = BigIntInferenceResult | NumberInferenceResult;\n\ninterface BigIntInferenceResult {\n dataTypeId: 'numeric';\n dataSubtypeId: 'bigint';\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: bigint;\n currencySymbolId: string | undefined;\n decimalPlaces: number;\n signId: NumericSignId;\n unitsId: NumericUnitsId;\n}\n\ninterface NumberInferenceResult {\n dataTypeId: 'numeric';\n dataSubtypeId: 'integer' | 'decimal';\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: number;\n currencySymbolId: string | undefined;\n decimalPlaces: number;\n signId: NumericSignId;\n unitsId: NumericUnitsId;\n}\n\nexport type NumericSignId = 'negative' | 'zero' | 'positive';\n\nexport type NumericUnitsId = 'currency' | 'percentage' | 'plain';\n\nexport interface StringInferenceResult {\n dataTypeId: 'string';\n dataSubtypeId: StringSubtypeId;\n format: string | undefined;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: string;\n}\n\nexport interface TemporalInferenceResult {\n dataTypeId: 'temporal';\n dataSubtypeId: TemporalSubtypeId;\n format: string;\n inputValue: string;\n inputValueWasQuoted: boolean;\n inferredValue: Date;\n}\n\ninterface UnknownInferenceResult {\n dataTypeId: 'unknown';\n dataSubtypeId: undefined;\n inputValue: string | null;\n inputValueWasQuoted: boolean;\n inferredValue: null;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst DATA_FORMATS_CONFIG: { id: DataFormatId; labels: LocaleLabelMap }[] = [\n { id: 'dpe', labels: createLabelMap({ en: 'Data Positioning Events' }) },\n { id: 'dtv', labels: createLabelMap({ en: 'Delimited Text' }) },\n { id: 'json', labels: createLabelMap({ en: 'JSON' }) },\n { id: 'spss', labels: createLabelMap({ en: 'SPSS' }) },\n { id: 'xlsx', labels: createLabelMap({ en: 'XLSX' }) },\n { id: 'xml', labels: createLabelMap({ en: 'XML' }) }\n];\n\nexport const ORDERED_VALUE_DELIMITER_IDS: ValueDelimiterId[] = [',', ';', '\\t', '|', ' ', ':', '_', '!', '0x1F', '0x1E']; // Ordered from estimated most common to least common.\n\nconst RECORD_DELIMITERS_CONFIG: { id: RecordDelimiterId; labels: LocaleLabelMap }[] = [\n { id: '\\n', labels: createLabelMap({ en: 'Newline' }) },\n { id: '\\r', labels: createLabelMap({ en: 'Carriage Return' }) },\n { id: '\\r\\n', labels: createLabelMap({ en: 'Carriage Return/Newline' }) }\n];\n\nconst VALUE_DELIMITERS_CONFIG: { id: ValueDelimiterId; labels: LocaleLabelMap }[] = [\n { id: ':', labels: createLabelMap({ en: 'Colon' }) },\n { id: ',', labels: createLabelMap({ en: 'Comma' }) },\n { id: '!', labels: createLabelMap({ en: 'Exclamation Mark' }) },\n // { id: '', label: { 'en': 'Other' } }, // TODO: Maybe set this to a 'not printing' or special ascii character when there is a user supplied delimited, rather than ''?\n { id: '0x1E', labels: createLabelMap({ en: 'Record Separator' }) },\n { id: ';', labels: createLabelMap({ en: 'Semicolon' }) },\n { id: ' ', labels: createLabelMap({ en: 'Space' }) },\n { id: '\\t', labels: createLabelMap({ en: 'Tab' }) },\n { id: '_', labels: createLabelMap({ en: 'Underscore' }) },\n { id: '0x1F', labels: createLabelMap({ en: 'Unit Separator' }) },\n { id: '|', labels: createLabelMap({ en: 'Vertical Bar' }) }\n];\n\n// ── Actions - Data Format(s) ─────────────────────────────────────────────────────────────────────────────────────────\n\ninterface ObjectDataFormat {\n id: DataFormatId;\n label: string;\n}\n\nfunction getDataFormat(id: DataFormatId, localeId = DEFAULT_LOCALE_ID): ObjectDataFormat {\n const dataFormat = DATA_FORMATS_CONFIG.find((dataFormat) => dataFormat.id === id);\n if (dataFormat) {\n const localizedLabel = resolveLabel(dataFormat.labels, localeId);\n return { id: dataFormat.id, label: localizedLabel ?? dataFormat.id };\n }\n return { id, label: id };\n}\n\nfunction getDataFormats(localeId = DEFAULT_LOCALE_ID): ObjectDataFormat[] {\n const items: ObjectDataFormat[] = [];\n for (const dataFormat of DATA_FORMATS_CONFIG) {\n const localizedLabel = resolveLabel(dataFormat.labels, localeId);\n items.push({ id: dataFormat.id, label: localizedLabel ?? dataFormat.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n}\n\n// ── Actions - Record Delimiter(s) ────────────────────────────────────────────────────────────────────────────────────\n\ninterface ObjectRecordDelimiter {\n id: RecordDelimiterId;\n label: string;\n}\n\nconst getRecordDelimiter = (id: RecordDelimiterId, localeId = DEFAULT_LOCALE_ID): ObjectRecordDelimiter => {\n const recordDelimiter = RECORD_DELIMITERS_CONFIG.find((recordDelimiter) => recordDelimiter.id === id);\n if (recordDelimiter) {\n const localizedLabel = resolveLabel(recordDelimiter.labels, localeId);\n return { id: recordDelimiter.id, label: localizedLabel ?? recordDelimiter.id };\n }\n return { id, label: id };\n};\n\nconst getRecordDelimiters = (localeId = DEFAULT_LOCALE_ID): ObjectRecordDelimiter[] => {\n const items: ObjectRecordDelimiter[] = [];\n for (const recordDelimiter of RECORD_DELIMITERS_CONFIG) {\n const localizedLabel = resolveLabel(recordDelimiter.labels, localeId);\n items.push({ id: recordDelimiter.id, label: localizedLabel ?? recordDelimiter.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n};\n\n// ── Actions - Value Delimiter(s) ─────────────────────────────────────────────────────────────────────────────────────\n\ninterface ValueDelimiter {\n id: ValueDelimiterId;\n label: string;\n}\nconst getValueDelimiter = (id: ValueDelimiterId, localeId = DEFAULT_LOCALE_ID): ValueDelimiter => {\n const valueDelimiter = VALUE_DELIMITERS_CONFIG.find((valueDelimiter) => valueDelimiter.id === id);\n if (valueDelimiter) {\n const localizedLabel = resolveLabel(valueDelimiter.labels, localeId);\n return { id: valueDelimiter.id, label: localizedLabel ?? valueDelimiter.id };\n }\n return { id, label: id };\n};\n\nconst getValueDelimiters = (localeId = DEFAULT_LOCALE_ID): ValueDelimiter[] => {\n const items: ValueDelimiter[] = [];\n for (const valueDelimiter of VALUE_DELIMITERS_CONFIG) {\n const localizedLabel = resolveLabel(valueDelimiter.labels, localeId);\n items.push({ id: valueDelimiter.id, label: localizedLabel ?? valueDelimiter.id });\n }\n return items.toSorted((first, second) => first.label.localeCompare(second.label));\n};\n"],"mappings":";;AAsLyB,EAAe,EAAE,IAAI,0BAA0B,CAAC,GAChD,EAAe,EAAE,IAAI,iBAAiB,CAAC,GACtC,EAAe,EAAE,IAAI,OAAO,CAAC,GAC7B,EAAe,EAAE,IAAI,OAAO,CAAC,GAC7B,EAAe,EAAE,IAAI,OAAO,CAAC,GAC9B,EAAe,EAAE,IAAI,MAAM,CAAC;AAGrD,IAAa,IAAkD;CAAC;CAAK;CAAK;CAAM;CAAK;CAAK;CAAK;CAAK;CAAK;CAAQ;AAAM;AAG/F,EAAe,EAAE,IAAI,UAAU,CAAC,GAChC,EAAe,EAAE,IAAI,kBAAkB,CAAC,GACtC,EAAe,EAAE,IAAI,0BAA0B,CAAC,GAInD,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC9B,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC9B,EAAe,EAAE,IAAI,mBAAmB,CAAC,GAEtC,EAAe,EAAE,IAAI,mBAAmB,CAAC,GAC5C,EAAe,EAAE,IAAI,YAAY,CAAC,GAClC,EAAe,EAAE,IAAI,QAAQ,CAAC,GAC7B,EAAe,EAAE,IAAI,MAAM,CAAC,GAC7B,EAAe,EAAE,IAAI,aAAa,CAAC,GAChC,EAAe,EAAE,IAAI,iBAAiB,CAAC,GAC1C,EAAe,EAAE,IAAI,eAAe,CAAC"}
|
|
@@ -179,4 +179,4 @@ function j(e) {
|
|
|
179
179
|
return n;
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
|
-
export {
|
|
182
|
+
export { S as connectorConfigSchema, k as constructConnectorCategoryConfig, A as constructConnectorUsageConfig, O as determineConnectorUsageId, j as getConnectorActionsTable };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-shared-componentModuleConnector.es.js","names":[],"sources":["../src/component/module/connector/connectorConfig.schema.ts","../src/component/module/connector/index.ts"],"sourcesContent":["/**\n * Defines the configuration metadata for a connector. Used for validation\n * of connector manifests and capability discovery at runtime.\n */\n\n// ── External Dependencies & Registrations\nimport { array, boolean, literal, nullable, number, optional, record, strictObject, string } from 'valibot';\n\n// ── DPUse Framework\nimport { literalUnion } from '@/schema';\nimport { localeLabelSchema } from '@/locale/locale.schema';\nimport { moduleConfigCoreFields } from '@/component/module/moduleConfig.schema';\n\n// ── Schemas - Action Name ────────────────────────────────────────────────────────────────────────────────────────────\n\n// Names of the operations a connector may implement.\nexport const connectorActionNameSchema = literalUnion([\n 'abortOperation',\n 'auditObjectContent',\n 'createObject',\n 'describeConnection',\n 'dropObject',\n 'findObject',\n 'getInfo',\n 'getReadableStream',\n 'getRecord',\n 'listNodes',\n 'previewObject',\n 'removeRecords',\n 'retrieveChunks',\n 'retrieveRecords',\n 'upsertRecords'\n]);\n\n// ── Schemas - Category Configuration ─────────────────────────────────────────────────────────────────────────────────\n\nconst connectorCategoryIdSchema = literalUnion(['application', 'curatedDataset', 'database', 'fileStore']); // Category identifiers used for grouping and filtering connectors.\n\nexport const connectorCategoryConfigSchema = strictObject({\n label: localeLabelSchema\n});\n\n// ── Schemas - Usage ──────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport const connectorUsageIdSchema = literalUnion(['bidirectional', 'destination', 'source', 'unknown']); // Connector data pipeline usage identifiers.\n\nexport const connectorUsageConfigSchema = strictObject({\n label: localeLabelSchema\n});\n\n// ── Schemas - Implementation ─────────────────────────────────────────────────────────────────────────────────────────\n\nconst connectorAuthMethodIdSchema = literalUnion(['apiKey', 'disabled', 'oAuth2', 'none']); // Authentication method identifiers supported by a connector implementation.\n\nconst connectorImplementationParametersSchema = record(string(), string()); // One set of implementation parameters, keyed by name.\n\n// A connector implementation variant. A single connector may expose multiple implementations differing by auth method, limits, or vendor-specific behavior.\nconst connectorImplementationSchema = strictObject({\n authMethodId: connectorAuthMethodIdSchema,\n activeConnectionCount: optional(number()),\n canDescribe: optional(boolean()),\n id: optional(string()),\n label: optional(localeLabelSchema),\n maxConnectionCount: nullable(number()),\n params: optional(array(connectorImplementationParametersSchema))\n});\n\n// ── Schemas - Configuration ──────────────────────────────────────────────────────────────────────────────────────────\n\nexport const connectorConfigSchema = strictObject({\n ...moduleConfigCoreFields,\n typeId: literal('connector'),\n actionNames: array(connectorActionNameSchema),\n category: nullable(connectorCategoryConfigSchema),\n categoryId: connectorCategoryIdSchema,\n implementations: record(string(), connectorImplementationSchema),\n usage: nullable(connectorUsageConfigSchema),\n usageId: nullable(connectorUsageIdSchema)\n});\n","// ── External Dependencies & Registrations\nimport type { InferOutput } from 'valibot';\n\n// ── DPUse Framework\nimport type { Component } from '@/component';\nimport type { EngineConnectorActionOptions } from '@/component/module/engine';\nimport type { ToolConfig } from '@/component/module/tool';\nimport type { ConnectionDescriptionConfig, ConnectionNodeConfig, ObjectColumnConfig } from '@/component/connection';\nimport type {\n connectorActionNameSchema,\n connectorCategoryConfigSchema,\n connectorConfigSchema,\n connectorUsageConfigSchema,\n connectorUsageIdSchema\n} from '@/component/module/connector/connectorConfig.schema';\nimport type { ContentAuditConfig, InferenceRecord, InferenceSummary, ParsingRecord, PreviewConfig, ValueDelimiterId } from '@/component/dataView';\nimport { createLabelMap, DEFAULT_LOCALE_ID, type LocaleLabel, resolveLabel } from '@/locale/label';\nimport type { LocalisedConfig } from '@/locale';\n\n// ── Schemas ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport { connectorConfigSchema } from '@/component/module/connector/connectorConfig.schema';\n\n// ── Types - Interface ────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ConnectorInterface extends Component {\n abortController: AbortController | undefined;\n readonly config: ConnectorConfig;\n readonly toolConfigs: ToolConfig[];\n abortOperation?(): void; // Abort the active long running action.\n auditObjectContent?(options: AuditObjectContentOptions, chunk: (rowCount: number) => void): Promise<AuditObjectContentResult>;\n createObject?(options: CreateObjectOptions): Promise<void>; // Create an object for a specified connection.\n describeConnection?(options: DescribeConnectionOptions): Promise<DescribeConnectionResult>; // Describe a specified connection.\n dropObject?(options: DropObjectOptions): Promise<void>; // Drop (delete) an object for a specified connection.\n findObject?(options: FindObjectOptions): Promise<FindObjectResult>; // Find an object for a specified connection.\n getInfo?(options: GetInfoOptions): Promise<GetInfoResult>; // Get metadata/info for a node (at any hierarchy level) for a specified connection.\n getReadableStream?(options: GetReadableStreamOptions): Promise<ReadableStream<Uint8Array>>; // Get a reader that can retrieve all records from an object for a specified connection.\n getRecord?(options: GetRecordOptions): Promise<GetRecordResult>; // Get a record for an object for a specified connection.\n listNodes?(options: ListNodesOptions): Promise<ListNodesResult>; // List nodes in a folder for a specified connection.\n previewObject?(options: PreviewObjectOptions): Promise<PreviewConfig>; // Preview an object for a specified connection.\n removeRecords?(options: RemoveRecordsOptions): Promise<void>; // Remove one or more records from an object for a specified connection.\n retrieveChunks?(options: RetrieveChunksOptions, chunk: (data: Uint8Array) => void, complete: () => void): Promise<void>; // Retrieve all chunks from an object for a specified connection.\n retrieveRecords?(\n options: RetrieveRecordsOptions,\n chunk: (typeId: RecordRetrievalTypeId, records: Record<string, unknown>[] | ParsingRecord[]) => void,\n complete: (result: RetrieveRecordsSummary) => void\n ): Promise<void>; // Retrieve all records from an object for a specified connection.\n upsertRecords?(options: UpsertRecordsOptions): Promise<void>; // Upsert one or more records into an object for a specified connection.\n}\n\nexport type ConnectorActionName = InferOutput<typeof connectorActionNameSchema>; // Names of the actions a connector may implement.\n\nexport type ConnectorConstructor = new (connectorUtilities: ConnectorUtilities, toolConfigs: ToolConfig[]) => ConnectorInterface;\n\nexport interface ConnectorUtilities {\n hasReadableStreamTransferSupport(): boolean;\n inferValues: (parsedRecord: ParsingRecord, columnConfigs: ObjectColumnConfig[], hasLeadingRecord: boolean) => InferenceRecord;\n inferDataTypes: (parsedRecords: ParsingRecord[]) => InferenceSummary;\n}\n\n// ── Types - Configuration ────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type ConnectorConfig = InferOutput<typeof connectorConfigSchema>;\n\ntype ConnectorCategoryConfig = InferOutput<typeof connectorCategoryConfigSchema>;\n\ntype ConnectorUsageConfig = InferOutput<typeof connectorUsageConfigSchema>;\n\n// ── Types - Action - Audit Object Content ────────────────────────────────────────────────────────────────────────────\n\nexport interface AuditObjectContentOptions1 extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\nexport interface AuditObjectContentResult1 {\n contentAuditConfig: ContentAuditConfig;\n}\n\nexport interface AuditObjectContentOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n parsingToolName: string | undefined;\n path: string;\n supportsTransferableStreams: boolean;\n valueDelimiterId: ValueDelimiterId;\n}\nexport interface AuditObjectContentResult {\n processedRowCount: number;\n durationMs: number;\n}\n\n// ── Types - Action - Create Object ───────────────────────────────────────────────────────────────────────────────────\n\nexport interface CreateObjectOptions extends EngineConnectorActionOptions {\n path: string;\n structure: string;\n}\n\n// ── Types - Action - Describe Connection ─────────────────────────────────────────────────────────────────────────────\n\nexport type DescribeConnectionOptions = EngineConnectorActionOptions;\n\ninterface DescribeConnectionResult {\n descriptionConfig: ConnectionDescriptionConfig;\n}\n\n// ── Types - Action - Drop Object ─────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DropObjectOptions extends EngineConnectorActionOptions {\n path: string;\n}\n\n// ── Types - Action - Find Object ─────────────────────────────────────────────────────────────────────────────────────\n\nexport interface FindObjectOptions extends EngineConnectorActionOptions {\n storeId: string | undefined;\n nodeId: string;\n}\nexport interface FindObjectResult {\n path: string | undefined;\n}\n\n// ── Types - Action - Get Info ────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface GetInfoOptions extends EngineConnectorActionOptions {\n path: string;\n}\nexport interface GetInfoResult {\n info: Record<string, unknown>; // Raw, connector-specific metadata — not yet normalized to a common shape.\n}\n\n// ── Types - Action - Get Readable Stream ─────────────────────────────────────────────────────────────────────────────\n\nexport interface GetReadableStreamOptions extends EngineConnectorActionOptions {\n id: string;\n path: string;\n}\n\n// ── Types - Action - Get Record ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface GetRecordOptions extends EngineConnectorActionOptions {\n id: string;\n path: string;\n}\nexport interface GetRecordResult {\n record?: string[] | Record<string, unknown>;\n}\n\n// ── Types - Action - List Nodes ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ListNodesOptions extends EngineConnectorActionOptions {\n folderPath: string;\n limit?: number;\n offset?: number;\n totalCount?: number;\n}\nexport interface ListNodesResult {\n cursor: string | number | undefined;\n connectionNodeConfigs: ConnectionNodeConfig[];\n isMore: boolean;\n totalCount: number;\n}\n\n// ── Types - Action - Preview Object ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface PreviewObjectOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n extension: string | undefined;\n path: string;\n}\n\n// ── Types - Action - Remove Records ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface RemoveRecordsOptions extends EngineConnectorActionOptions {\n keys: string[];\n path: string;\n}\n\n// ── Types - Action - Retrieve Chunks ─────────────────────────────────────────────────────────────────────────────────\n\nexport interface RetrieveChunksOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\n\n// ── Types - Action - Retrieve Records ────────────────────────────────────────────────────────────────────────────────\n\nexport interface RetrieveRecordsOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\nexport interface RetrieveRecordsSummary {\n byteCount: number; // Number of processed bytes.\n commentLineCount: number; // Count the number of lines being fully commented.\n emptyLineCount: number; // Count the number of processed empty lines; work only with the skip_empty_lines option or an error will be thrown if an empty line is found.\n lineCount: number; // Number of lines encountered in the source dataset, start at 1 for the first line.\n nonUniformRecordCount: number; // Number of non uniform records when relax_column_count is true.\n recordCount: number; // Count the number of processed records.\n}\n\nexport type RecordRetrievalTypeId = 'jsonRecordArray' | 'parsingRecordArray';\n\n// ── Types - Action - Upsert Records ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface UpsertRecordsOptions extends EngineConnectorActionOptions {\n records: Record<string, unknown>[];\n path: string;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_CATEGORY_CONFIGS: { id: string; label: LocaleLabel }[] = [\n { id: 'application', label: { en: 'Application', es: 'Aplicación' } },\n { id: 'curatedDataset', label: { en: 'Curated Dataset', es: 'Conjunto de Datos Curado' } },\n { id: 'database', label: { en: 'Database', es: 'Base de Datos' } },\n { id: 'fileStore', label: { en: 'File Store', es: 'Almacén de Archivos' } }\n];\n\nexport const CONNECTOR_ACTION_NAME_MAP: Record<ConnectorActionName, string> = {\n abortOperation: 'Abort Operation',\n auditObjectContent: 'Audit Object Content',\n createObject: 'Create Object',\n describeConnection: 'Describe Connection',\n dropObject: 'Drop Object',\n findObject: 'Find Object',\n getInfo: 'Get Info',\n getReadableStream: 'Get Readable Stream',\n getRecord: 'Get Record',\n listNodes: 'List Nodes',\n previewObject: 'Preview Object',\n removeRecords: 'Remove Records',\n retrieveChunks: 'Retrieve Chunks',\n retrieveRecords: 'Retrieve Records',\n upsertRecords: 'Upsert Records'\n};\n\nconst CONNECTOR_USAGE_CONFIGS: { id: string; label: LocaleLabel }[] = [\n { id: 'bidirectional', label: { en: 'Bidirectional', es: 'Bidireccional' } },\n { id: 'destination', label: { en: 'Destination', es: 'Destino' } },\n { id: 'source', label: { en: 'Source', es: 'Origen' } },\n { id: 'unknown', label: { en: 'Unknown', es: 'Desconocido' } }\n];\n\nconst CONNECTOR_DESTINATION_OPERATIONS = new Set<ConnectorActionName>(['createObject', 'dropObject', 'removeRecords', 'upsertRecords']);\nconst CONNECTOR_SOURCE_OPERATIONS = new Set<ConnectorActionName>([\n 'auditObjectContent',\n 'findObject',\n 'getInfo',\n 'getReadableStream',\n 'getRecord',\n 'listNodes',\n 'previewObject',\n 'retrieveChunks',\n 'retrieveRecords'\n]);\n\n// ── Types - Usage ────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type ConnectorUsageId = InferOutput<typeof connectorUsageIdSchema>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Determines whether a connector is a source, destination, or bidirectional connector, based on the actions it implements.\nexport function determineConnectorUsageId(actionNames: ConnectorActionName[]): ConnectorUsageId {\n let isSourceOperation = false;\n let isDestinationOperation = false;\n for (const actionName of actionNames) {\n if (CONNECTOR_SOURCE_OPERATIONS.has(actionName)) isSourceOperation = true;\n if (CONNECTOR_DESTINATION_OPERATIONS.has(actionName)) isDestinationOperation = true;\n }\n if (isSourceOperation && isDestinationOperation) return 'bidirectional';\n if (isSourceOperation) return 'source';\n return isDestinationOperation ? 'destination' : 'unknown'; // Neither reads nor writes data, e.g. only 'abortOperation' or 'describeConnection'.\n}\n\nexport const constructConnectorCategoryConfig = (id: string, localeId = DEFAULT_LOCALE_ID): LocalisedConfig<ConnectorCategoryConfig> => {\n const connectorCategory = CONNECTOR_CATEGORY_CONFIGS.find((connectorCategory) => connectorCategory.id === id);\n if (connectorCategory) {\n const labelMap = createLabelMap(connectorCategory.label);\n const localizedLabel = resolveLabel(labelMap, localeId);\n return { label: localizedLabel ?? connectorCategory.id, description: '' };\n }\n return { label: id, description: '' };\n};\n\nexport const constructConnectorUsageConfig = (id: string, localeId = DEFAULT_LOCALE_ID): LocalisedConfig<ConnectorUsageConfig> => {\n const connectorUsage = CONNECTOR_USAGE_CONFIGS.find((connectorUsage) => connectorUsage.id === id);\n if (connectorUsage) {\n const labelMap = createLabelMap(connectorUsage.label);\n const localizedLabel = resolveLabel(labelMap, localeId);\n return { label: localizedLabel ?? connectorUsage.id, description: '' };\n }\n return { label: id, description: '' };\n};\n\nexport function getConnectorActionsTable(supported: ConnectorActionName[]): string {\n const supportedSet = new Set(supported);\n let md = '|Action|Supported|\\n';\n md += '|:----|:-------:|\\n';\n for (const id of Object.keys(CONNECTOR_ACTION_NAME_MAP) as ConnectorActionName[]) {\n md += `| ${CONNECTOR_ACTION_NAME_MAP[id]} | ${supportedSet.has(id) ? '✓' : ''} |\\n`;\n }\n return md;\n}\n"],"mappings":";;;;AAgBA,IAAa,IAA4B,EAAa;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,GAIK,IAA4B,EAAa;CAAC;CAAe;CAAkB;CAAY;AAAW,CAAC,GAE5F,IAAgC,EAAa,EACtD,OAAO,EACX,CAAC,GAIY,IAAyB,EAAa;CAAC;CAAiB;CAAe;CAAU;AAAS,CAAC,GAE3F,IAA6B,EAAa,EACnD,OAAO,EACX,CAAC,GAIK,IAA8B,EAAa;CAAC;CAAU;CAAY;CAAU;AAAM,CAAC,GAEnF,IAA0C,EAAO,EAAO,GAAG,EAAO,CAAC,GAGnE,IAAgC,EAAa;CAC/C,cAAc;CACd,uBAAuB,EAAS,EAAO,CAAC;CACxC,aAAa,EAAS,EAAQ,CAAC;CAC/B,IAAI,EAAS,EAAO,CAAC;CACrB,OAAO,EAAS,CAAiB;CACjC,oBAAoB,EAAS,EAAO,CAAC;CACrC,QAAQ,EAAS,EAAM,CAAuC,CAAC;AACnE,CAAC,GAIY,IAAwB,EAAa;CAC9C,GAAG;CACH,QAAQ,EAAQ,WAAW;CAC3B,aAAa,EAAM,CAAyB;CAC5C,UAAU,EAAS,CAA6B;CAChD,YAAY;CACZ,iBAAiB,EAAO,EAAO,GAAG,CAA6B;CAC/D,OAAO,EAAS,CAA0B;CAC1C,SAAS,EAAS,CAAsB;AAC5C,CAAC,GC2IK,IAAmE;CACrE;EAAE,IAAI;EAAe,OAAO;GAAE,IAAI;GAAe,IAAI;EAAa;CAAE;CACpE;EAAE,IAAI;EAAkB,OAAO;GAAE,IAAI;GAAm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,GAAU,CAC9B,KAAkB,EAAkB;GAAI,aAAa;EAAG;CAC5E;CACA,OAAO;EAAE,OAAO;EAAI,aAAa;CAAG;AACxC,GAEa,KAAiC,GAAY,IAAA,SAAwE;CAC9H,IAAM,IAAiB,EAAwB,MAAM,MAAmB,EAAe,OAAO,CAAE;CAChG,IAAI,GAAgB;EAChB,IAAM,IAAW,EAAe,EAAe,KAAK;EAEpD,OAAO;GAAE,OADc,EAAa,GAAU,CAC9B,KAAkB,EAAe;GAAI,aAAa;EAAG;CACzE;CACA,OAAO;EAAE,OAAO;EAAI,aAAa;CAAG;AACxC;AAEA,SAAgB,EAAyB,GAA0C;CAC/E,IAAM,IAAe,IAAI,IAAI,CAAS,GAClC,IAAK;CACT,KAAM;CACN,KAAK,IAAM,KAAM,OAAO,KAAK,CAAyB,GAClD,KAAM,KAAK,EAA0B,GAAI,KAAK,EAAa,IAAI,CAAE,IAAI,MAAM,GAAG;CAElF,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"dpuse-shared-componentModuleConnector.es.js","names":[],"sources":["../src/component/module/connector/connectorConfig.schema.ts","../src/component/module/connector/index.ts"],"sourcesContent":["/**\n * Defines the configuration metadata for a connector. Used for validation\n * of connector manifests and capability discovery at runtime.\n */\n\n// ── External Dependencies & Registrations\nimport { array, boolean, literal, nullable, number, optional, record, strictObject, string } from 'valibot';\n\n// ── DPUse Framework\nimport { literalUnion } from '@/schema';\nimport { localeLabelSchema } from '@/locale/locale.schema';\nimport { moduleConfigCoreFields } from '@/component/module/moduleConfig.schema';\n\n// ── Schemas - Action Name ────────────────────────────────────────────────────────────────────────────────────────────\n\n// Names of the operations a connector may implement.\nexport const connectorActionNameSchema = literalUnion([\n 'abortOperation',\n 'auditObjectContent',\n 'createObject',\n 'describeConnection',\n 'dropObject',\n 'findObject',\n 'getInfo',\n 'getReadableStream',\n 'getRecord',\n 'listNodes',\n 'previewObject',\n 'removeRecords',\n 'retrieveChunks',\n 'retrieveRecords',\n 'upsertRecords'\n]);\n\n// ── Schemas - Category Configuration ─────────────────────────────────────────────────────────────────────────────────\n\nconst connectorCategoryIdSchema = literalUnion(['application', 'curatedDataset', 'database', 'fileStore']); // Category identifiers used for grouping and filtering connectors.\n\nexport const connectorCategoryConfigSchema = strictObject({\n label: localeLabelSchema\n});\n\n// ── Schemas - Usage ──────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport const connectorUsageIdSchema = literalUnion(['bidirectional', 'destination', 'source', 'unknown']); // Connector data pipeline usage identifiers.\n\nexport const connectorUsageConfigSchema = strictObject({\n label: localeLabelSchema\n});\n\n// ── Schemas - Implementation ─────────────────────────────────────────────────────────────────────────────────────────\n\nconst connectorAuthMethodIdSchema = literalUnion(['apiKey', 'disabled', 'oAuth2', 'none']); // Authentication method identifiers supported by a connector implementation.\n\nconst connectorImplementationParametersSchema = record(string(), string()); // One set of implementation parameters, keyed by name.\n\n// A connector implementation variant. A single connector may expose multiple implementations differing by auth method, limits, or vendor-specific behavior.\nconst connectorImplementationSchema = strictObject({\n authMethodId: connectorAuthMethodIdSchema,\n activeConnectionCount: optional(number()),\n canDescribe: optional(boolean()),\n id: optional(string()),\n label: optional(localeLabelSchema),\n maxConnectionCount: nullable(number()),\n params: optional(array(connectorImplementationParametersSchema))\n});\n\n// ── Schemas - Configuration ──────────────────────────────────────────────────────────────────────────────────────────\n\nexport const connectorConfigSchema = strictObject({\n ...moduleConfigCoreFields,\n typeId: literal('connector'),\n actionNames: array(connectorActionNameSchema),\n category: nullable(connectorCategoryConfigSchema),\n categoryId: connectorCategoryIdSchema,\n implementations: record(string(), connectorImplementationSchema),\n usage: nullable(connectorUsageConfigSchema),\n usageId: nullable(connectorUsageIdSchema)\n});\n","// ── External Dependencies & Registrations\nimport type { InferOutput } from 'valibot';\n\n// ── DPUse Framework\nimport type { Component } from '@/component';\nimport type { EngineConnectorActionOptions } from '@/component/module/engine';\nimport type { ToolConfig } from '@/component/module/tool';\nimport type { ConnectionDescriptionConfig, ConnectionNodeConfig, ObjectColumnConfig } from '@/component/connection';\nimport type {\n connectorActionNameSchema,\n connectorCategoryConfigSchema,\n connectorConfigSchema,\n connectorUsageConfigSchema,\n connectorUsageIdSchema\n} from './connectorConfig.schema';\nimport type { ContentAuditConfig, InferenceRecord, InferenceSummary, ParsingRecord, PreviewConfig, ValueDelimiterId } from '@/component/dataView';\nimport { createLabelMap, DEFAULT_LOCALE_ID, type LocaleLabel, resolveLabel } from '@/locale/label';\nimport type { LocalisedConfig } from '@/locale';\n\n// ── Schemas ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport { connectorConfigSchema } from './connectorConfig.schema';\n\n// ── Types - Interface ────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ConnectorInterface extends Component {\n abortController: AbortController | undefined;\n readonly config: ConnectorConfig;\n readonly toolConfigs: ToolConfig[];\n abortOperation?(): void; // Abort the active long running action.\n auditObjectContent?(options: AuditObjectContentOptions, chunk: (rowCount: number) => void): Promise<AuditObjectContentResult>;\n createObject?(options: CreateObjectOptions): Promise<void>; // Create an object for a specified connection.\n describeConnection?(options: DescribeConnectionOptions): Promise<DescribeConnectionResult>; // Describe a specified connection.\n dropObject?(options: DropObjectOptions): Promise<void>; // Drop (delete) an object for a specified connection.\n findObject?(options: FindObjectOptions): Promise<FindObjectResult>; // Find an object for a specified connection.\n getInfo?(options: GetInfoOptions): Promise<GetInfoResult>; // Get metadata/info for a node (at any hierarchy level) for a specified connection.\n getReadableStream?(options: GetReadableStreamOptions): Promise<ReadableStream<Uint8Array>>; // Get a reader that can retrieve all records from an object for a specified connection.\n getRecord?(options: GetRecordOptions): Promise<GetRecordResult>; // Get a record for an object for a specified connection.\n listNodes?(options: ListNodesOptions): Promise<ListNodesResult>; // List nodes in a folder for a specified connection.\n previewObject?(options: PreviewObjectOptions): Promise<PreviewConfig>; // Preview an object for a specified connection.\n removeRecords?(options: RemoveRecordsOptions): Promise<void>; // Remove one or more records from an object for a specified connection.\n retrieveChunks?(options: RetrieveChunksOptions, chunk: (data: Uint8Array) => void, complete: () => void): Promise<void>; // Retrieve all chunks from an object for a specified connection.\n retrieveRecords?(\n options: RetrieveRecordsOptions,\n chunk: (typeId: RecordRetrievalTypeId, records: Record<string, unknown>[] | ParsingRecord[]) => void,\n complete: (result: RetrieveRecordsSummary) => void\n ): Promise<void>; // Retrieve all records from an object for a specified connection.\n upsertRecords?(options: UpsertRecordsOptions): Promise<void>; // Upsert one or more records into an object for a specified connection.\n}\n\nexport type ConnectorActionName = InferOutput<typeof connectorActionNameSchema>; // Names of the actions a connector may implement.\n\nexport type ConnectorConstructor = new (connectorUtilities: ConnectorUtilities, toolConfigs: ToolConfig[]) => ConnectorInterface;\n\nexport interface ConnectorUtilities {\n hasReadableStreamTransferSupport(): boolean;\n inferValues: (parsedRecord: ParsingRecord, columnConfigs: ObjectColumnConfig[], hasLeadingRecord: boolean) => InferenceRecord;\n inferDataTypes: (parsedRecords: ParsingRecord[]) => InferenceSummary;\n}\n\n// ── Types - Configuration ────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type ConnectorConfig = InferOutput<typeof connectorConfigSchema>;\n\ntype ConnectorCategoryConfig = InferOutput<typeof connectorCategoryConfigSchema>;\n\ntype ConnectorUsageConfig = InferOutput<typeof connectorUsageConfigSchema>;\n\n// ── Types - Action - Audit Object Content ────────────────────────────────────────────────────────────────────────────\n\ninterface AuditObjectContentOptions1 extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\ninterface AuditObjectContentResult1 {\n contentAuditConfig: ContentAuditConfig;\n}\n\nexport interface AuditObjectContentOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n parsingToolName: string | undefined;\n path: string;\n supportsTransferableStreams: boolean;\n valueDelimiterId: ValueDelimiterId;\n}\nexport interface AuditObjectContentResult {\n processedRowCount: number;\n durationMs: number;\n}\n\n// ── Types - Action - Create Object ───────────────────────────────────────────────────────────────────────────────────\n\nexport interface CreateObjectOptions extends EngineConnectorActionOptions {\n path: string;\n structure: string;\n}\n\n// ── Types - Action - Describe Connection ─────────────────────────────────────────────────────────────────────────────\n\nexport type DescribeConnectionOptions = EngineConnectorActionOptions;\n\ninterface DescribeConnectionResult {\n descriptionConfig: ConnectionDescriptionConfig;\n}\n\n// ── Types - Action - Drop Object ─────────────────────────────────────────────────────────────────────────────────────\n\nexport interface DropObjectOptions extends EngineConnectorActionOptions {\n path: string;\n}\n\n// ── Types - Action - Find Object ─────────────────────────────────────────────────────────────────────────────────────\n\nexport interface FindObjectOptions extends EngineConnectorActionOptions {\n storeId: string | undefined;\n nodeId: string;\n}\nexport interface FindObjectResult {\n path: string | undefined;\n}\n\n// ── Types - Action - Get Info ────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface GetInfoOptions extends EngineConnectorActionOptions {\n path: string;\n}\nexport interface GetInfoResult {\n info: Record<string, unknown>; // Raw, connector-specific metadata — not yet normalized to a common shape.\n}\n\n// ── Types - Action - Get Readable Stream ─────────────────────────────────────────────────────────────────────────────\n\nexport interface GetReadableStreamOptions extends EngineConnectorActionOptions {\n id: string;\n path: string;\n}\n\n// ── Types - Action - Get Record ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface GetRecordOptions extends EngineConnectorActionOptions {\n id: string;\n path: string;\n}\nexport interface GetRecordResult {\n record?: string[] | Record<string, unknown>;\n}\n\n// ── Types - Action - List Nodes ──────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ListNodesOptions extends EngineConnectorActionOptions {\n folderPath: string;\n limit?: number;\n offset?: number;\n totalCount?: number;\n}\nexport interface ListNodesResult {\n cursor: string | number | undefined;\n connectionNodeConfigs: ConnectionNodeConfig[];\n isMore: boolean;\n totalCount: number;\n}\n\n// ── Types - Action - Preview Object ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface PreviewObjectOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n extension: string | undefined;\n path: string;\n}\n\n// ── Types - Action - Remove Records ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface RemoveRecordsOptions extends EngineConnectorActionOptions {\n keys: string[];\n path: string;\n}\n\n// ── Types - Action - Retrieve Chunks ─────────────────────────────────────────────────────────────────────────────────\n\nexport interface RetrieveChunksOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\n\n// ── Types - Action - Retrieve Records ────────────────────────────────────────────────────────────────────────────────\n\nexport interface RetrieveRecordsOptions extends EngineConnectorActionOptions {\n chunkSize: number | undefined;\n encodingId: string;\n path: string;\n valueDelimiterId: ValueDelimiterId;\n}\nexport interface RetrieveRecordsSummary {\n byteCount: number; // Number of processed bytes.\n commentLineCount: number; // Count the number of lines being fully commented.\n emptyLineCount: number; // Count the number of processed empty lines; work only with the skip_empty_lines option or an error will be thrown if an empty line is found.\n lineCount: number; // Number of lines encountered in the source dataset, start at 1 for the first line.\n nonUniformRecordCount: number; // Number of non uniform records when relax_column_count is true.\n recordCount: number; // Count the number of processed records.\n}\n\nexport type RecordRetrievalTypeId = 'jsonRecordArray' | 'parsingRecordArray';\n\n// ── Types - Action - Upsert Records ──────────────────────────────────────────────────────────────────────────────────\n\nexport interface UpsertRecordsOptions extends EngineConnectorActionOptions {\n records: Record<string, unknown>[];\n path: string;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst CONNECTOR_CATEGORY_CONFIGS: { id: string; label: LocaleLabel }[] = [\n { id: 'application', label: { en: 'Application', es: 'Aplicación' } },\n { id: 'curatedDataset', label: { en: 'Curated Dataset', es: 'Conjunto de Datos Curado' } },\n { id: 'database', label: { en: 'Database', es: 'Base de Datos' } },\n { id: 'fileStore', label: { en: 'File Store', es: 'Almacén de Archivos' } }\n];\n\nconst CONNECTOR_ACTION_NAME_MAP: Record<ConnectorActionName, string> = {\n abortOperation: 'Abort Operation',\n auditObjectContent: 'Audit Object Content',\n createObject: 'Create Object',\n describeConnection: 'Describe Connection',\n dropObject: 'Drop Object',\n findObject: 'Find Object',\n getInfo: 'Get Info',\n getReadableStream: 'Get Readable Stream',\n getRecord: 'Get Record',\n listNodes: 'List Nodes',\n previewObject: 'Preview Object',\n removeRecords: 'Remove Records',\n retrieveChunks: 'Retrieve Chunks',\n retrieveRecords: 'Retrieve Records',\n upsertRecords: 'Upsert Records'\n};\n\nconst CONNECTOR_USAGE_CONFIGS: { id: string; label: LocaleLabel }[] = [\n { id: 'bidirectional', label: { en: 'Bidirectional', es: 'Bidireccional' } },\n { id: 'destination', label: { en: 'Destination', es: 'Destino' } },\n { id: 'source', label: { en: 'Source', es: 'Origen' } },\n { id: 'unknown', label: { en: 'Unknown', es: 'Desconocido' } }\n];\n\nconst CONNECTOR_DESTINATION_OPERATIONS = new Set<ConnectorActionName>(['createObject', 'dropObject', 'removeRecords', 'upsertRecords']);\nconst CONNECTOR_SOURCE_OPERATIONS = new Set<ConnectorActionName>([\n 'auditObjectContent',\n 'findObject',\n 'getInfo',\n 'getReadableStream',\n 'getRecord',\n 'listNodes',\n 'previewObject',\n 'retrieveChunks',\n 'retrieveRecords'\n]);\n\n// ── Types - Usage ────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type ConnectorUsageId = InferOutput<typeof connectorUsageIdSchema>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Determines whether a connector is a source, destination, or bidirectional connector, based on the actions it implements.\nexport function determineConnectorUsageId(actionNames: ConnectorActionName[]): ConnectorUsageId {\n let isSourceOperation = false;\n let isDestinationOperation = false;\n for (const actionName of actionNames) {\n if (CONNECTOR_SOURCE_OPERATIONS.has(actionName)) isSourceOperation = true;\n if (CONNECTOR_DESTINATION_OPERATIONS.has(actionName)) isDestinationOperation = true;\n }\n if (isSourceOperation && isDestinationOperation) return 'bidirectional';\n if (isSourceOperation) return 'source';\n return isDestinationOperation ? 'destination' : 'unknown'; // Neither reads nor writes data, e.g. only 'abortOperation' or 'describeConnection'.\n}\n\nexport const constructConnectorCategoryConfig = (id: string, localeId = DEFAULT_LOCALE_ID): LocalisedConfig<ConnectorCategoryConfig> => {\n const connectorCategory = CONNECTOR_CATEGORY_CONFIGS.find((connectorCategory) => connectorCategory.id === id);\n if (connectorCategory) {\n const labelMap = createLabelMap(connectorCategory.label);\n const localizedLabel = resolveLabel(labelMap, localeId);\n return { label: localizedLabel ?? connectorCategory.id, description: '' };\n }\n return { label: id, description: '' };\n};\n\nexport const constructConnectorUsageConfig = (id: string, localeId = DEFAULT_LOCALE_ID): LocalisedConfig<ConnectorUsageConfig> => {\n const connectorUsage = CONNECTOR_USAGE_CONFIGS.find((connectorUsage) => connectorUsage.id === id);\n if (connectorUsage) {\n const labelMap = createLabelMap(connectorUsage.label);\n const localizedLabel = resolveLabel(labelMap, localeId);\n return { label: localizedLabel ?? connectorUsage.id, description: '' };\n }\n return { label: id, description: '' };\n};\n\nexport function getConnectorActionsTable(supported: ConnectorActionName[]): string {\n const supportedSet = new Set(supported);\n let md = '|Action|Supported|\\n';\n md += '|:----|:-------:|\\n';\n for (const id of Object.keys(CONNECTOR_ACTION_NAME_MAP) as ConnectorActionName[]) {\n md += `| ${CONNECTOR_ACTION_NAME_MAP[id]} | ${supportedSet.has(id) ? '✓' : ''} |\\n`;\n }\n return md;\n}\n"],"mappings":";;;;AAgBA,IAAa,IAA4B,EAAa;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,GAIK,IAA4B,EAAa;CAAC;CAAe;CAAkB;CAAY;AAAW,CAAC,GAE5F,IAAgC,EAAa,EACtD,OAAO,EACX,CAAC,GAIY,IAAyB,EAAa;CAAC;CAAiB;CAAe;CAAU;AAAS,CAAC,GAE3F,IAA6B,EAAa,EACnD,OAAO,EACX,CAAC,GAIK,IAA8B,EAAa;CAAC;CAAU;CAAY;CAAU;AAAM,CAAC,GAEnF,IAA0C,EAAO,EAAO,GAAG,EAAO,CAAC,GAGn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puse-shared-encoding.es.js","names":[],"sources":["../src/encoding/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID, type LocaleId, type LocaleLabel } from '@/locale/label';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type EncodingGroupId = keyof typeof ENCODING_GROUP_CONFIG_DATA;\nexport type EncodingTypeId = keyof typeof ENCODING_TYPE_CONFIG_DATA;\n\nexport interface EncodingGroupConfig {\n id: EncodingGroupId;\n label: LocaleLabel;\n}\n\nexport interface EncodingTypeConfig {\n id: EncodingTypeId;\n groupId: EncodingGroupId | null; // Null for encodings that belong to no group, e.g. 'ascii' and 'utf-8'.\n isDetectable: boolean;\n isDecodable: boolean;\n}\nexport interface EncodingTypeConfigLocalised {\n id: EncodingTypeId;\n groupLabel: string;\n label: string;\n isDetectable: boolean;\n isDecodable: boolean;\n}\n\nexport interface EncodingDetectionConfig {\n id: EncodingTypeId;\n confidenceLevel: number | undefined;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst ENCODING_GROUP_CONFIG_DATA = {\n arabic: { id: 'arabic', label: { en: 'Arabic', es: 'Árabe' } },\n baltic: { id: 'baltic', label: { en: 'Baltic', es: 'Báltico' } },\n celtic: { id: 'celtic', label: { en: 'Celtic', es: 'Celta' } },\n centralEuropean: { id: 'centralEuropean', label: { en: 'Central European', es: 'Centroeuropeo' } },\n chineseSimplified: { id: 'chineseSimplified', label: { en: 'Chinese Simplified', es: 'Chino simplificado' } },\n chineseTraditional: { id: 'chineseTraditional', label: { en: 'Chinese Traditional', es: 'Chino tradicional' } },\n cyrillic: { id: 'cyrillic', label: { en: 'Cyrillic', es: 'Cirílico' } },\n greek: { id: 'greek', label: { en: 'Greek', es: 'Griego' } },\n hebrew: { id: 'hebrew', label: { en: 'Hebrew', es: 'Hebreo' } },\n japanese: { id: 'japanese', label: { en: 'Japanese', es: 'Japonés' } },\n korean: { id: 'korean', label: { en: 'Korean', es: 'Coreano' } },\n nordic: { id: 'nordic', label: { en: 'Nordic', es: 'Nórdico' } },\n other: { id: 'other', label: { en: 'Other', es: 'Otro' } },\n romanian: { id: 'romanian', label: { en: 'Romanian', es: 'Rumano' } },\n southernEuropean: { id: 'southernEuropean', label: { en: 'Southern European', es: 'Europeo meridional' } },\n thai: { id: 'thai', label: { en: 'Thai', es: 'Tailandés' } },\n turkish: { id: 'turkish', label: { en: 'Turkish', es: 'Turco' } },\n unicode16: { id: 'unicode16', label: { en: 'Unicode 16', es: 'Unicode 16' } },\n unicode32: { id: 'unicode32', label: { en: 'Unicode 32', es: 'Unicode 32' } },\n vietnamese: { id: 'vietnamese', label: { en: 'Vietnamese', es: 'Vietnamita' } },\n western: { id: 'western', label: { en: 'Western', es: 'Occidental' } }\n} as const satisfies Record<string, { id: string; label: LocaleLabel }>;\n\nconst ENCODING_TYPE_CONFIG_DATA = {\n ascii: { id: 'ascii', groupId: null, isDetectable: false, isDecodable: true },\n big5: { id: 'big5', groupId: 'chineseTraditional', isDetectable: true, isDecodable: true },\n 'euc-jp': { id: 'euc-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'euc-kr': { id: 'euc-kr', groupId: 'korean', isDetectable: true, isDecodable: true },\n gb18030: { id: 'gb18030', groupId: 'chineseSimplified', isDetectable: true, isDecodable: true },\n gbk: { id: 'gbk', groupId: 'chineseSimplified', isDetectable: false, isDecodable: true },\n ibm866: { id: 'ibm866', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'iso-2022-cn': { id: 'iso-2022-cn', groupId: 'chineseSimplified', isDetectable: true, isDecodable: false },\n 'iso-2022-jp': { id: 'iso-2022-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'iso-2022-kr': { id: 'iso-2022-kr', groupId: 'korean', isDetectable: true, isDecodable: false },\n 'iso-8859-1': { id: 'iso-8859-1', groupId: 'western', isDetectable: true, isDecodable: true },\n 'iso-8859-2': { id: 'iso-8859-2', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'iso-8859-3': { id: 'iso-8859-3', groupId: 'southernEuropean', isDetectable: false, isDecodable: true },\n 'iso-8859-4': { id: 'iso-8859-4', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-5': { id: 'iso-8859-5', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'iso-8859-6': { id: 'iso-8859-6', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'iso-8859-7': { id: 'iso-8859-7', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'iso-8859-8': { id: 'iso-8859-8', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'iso-8859-9': { id: 'iso-8859-9', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'iso-8859-10': { id: 'iso-8859-10', groupId: 'nordic', isDetectable: false, isDecodable: true },\n 'iso-8859-11': { id: 'iso-8859-11', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'iso-8859-13': { id: 'iso-8859-13', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-14': { id: 'iso-8859-14', groupId: 'celtic', isDetectable: false, isDecodable: true },\n 'iso-8859-15': { id: 'iso-8859-15', groupId: 'western', isDetectable: false, isDecodable: true },\n 'iso-8859-16': { id: 'iso-8859-16', groupId: 'romanian', isDetectable: false, isDecodable: true },\n 'koi8-r': { id: 'koi8-r', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'koi8-u': { id: 'koi8-u', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n latin1: { id: 'latin1', groupId: 'western', isDetectable: false, isDecodable: true },\n macintosh: { id: 'macintosh', groupId: 'western', isDetectable: false, isDecodable: true },\n shift_jis: { id: 'shift_jis', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'tis-620': { id: 'tis-620', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'utf-16': { id: 'utf-16', groupId: 'unicode16', isDetectable: false, isDecodable: true },\n 'utf-16be': { id: 'utf-16be', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-16le': { id: 'utf-16le', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-32be': { id: 'utf-32be', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-32le': { id: 'utf-32le', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-8': { id: 'utf-8', groupId: null, isDetectable: true, isDecodable: true },\n 'windows-1250': { id: 'windows-1250', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'windows-1251': { id: 'windows-1251', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'windows-1252': { id: 'windows-1252', groupId: 'western', isDetectable: true, isDecodable: true },\n 'windows-1253': { id: 'windows-1253', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'windows-1254': { id: 'windows-1254', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'windows-1255': { id: 'windows-1255', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'windows-1256': { id: 'windows-1256', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'windows-1257': { id: 'windows-1257', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'windows-1258': { id: 'windows-1258', groupId: 'vietnamese', isDetectable: false, isDecodable: true },\n 'windows-874': { id: 'windows-874', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'x-mac-cyrillic': { id: 'x-mac-cyrillic', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'x-user-defined': { id: 'x-user-defined', groupId: 'other', isDetectable: false, isDecodable: true }\n} as const satisfies Record<string, { id: string; groupId: keyof typeof ENCODING_GROUP_CONFIG_DATA | null; isDetectable: boolean; isDecodable: boolean }>;\n\nexport const ENCODING_GROUP_CONFIG_MAP = ENCODING_GROUP_CONFIG_DATA as Record<EncodingGroupId, EncodingGroupConfig>;\nexport const ENCODING_TYPE_CONFIG_MAP = ENCODING_TYPE_CONFIG_DATA as Record<EncodingTypeId, EncodingTypeConfig>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Narrows a name from outside the app, such as one reported by encoding detection, to a known encoding id. Check with\n// this once where the name arrives, so everything after it works with 'EncodingTypeId'.\nexport function isEncodingTypeId(value: string): value is EncodingTypeId {\n return Object.hasOwn(ENCODING_TYPE_CONFIG_MAP, value);\n}\n\nexport function getEncodingTypeConfigs(localeId: LocaleId = DEFAULT_LOCALE_ID): EncodingTypeConfigLocalised[] {\n const encodingTypeConfigs: EncodingTypeConfigLocalised[] = Array.from(Object.values(ENCODING_TYPE_CONFIG_MAP), ({ groupId, id, isDecodable, isDetectable }) => {\n const groupLabel = groupId == null ? '' : resolveGroupLabel(groupId, localeId);\n return { id, groupLabel, label: groupLabel ? `${groupLabel} (${id})` : id, isDetectable, isDecodable };\n });\n return encodingTypeConfigs.toSorted((left, right) => left.groupLabel.localeCompare(right.groupLabel, localeId) || left.label.localeCompare(right.label, localeId));\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nfunction resolveGroupLabel(groupId: EncodingGroupId, localeId: LocaleId): string {\n const labels = ENCODING_GROUP_CONFIG_MAP[groupId].label;\n return labels[localeId] ?? labels[DEFAULT_LOCALE_ID] ?? groupId;\n}\n"],"mappings":";;AAkCA,IAAM,IAA6B;CAC/B,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,iBAAiB;EAAE,IAAI;EAAmB,OAAO;GAAE,IAAI;GAAoB,IAAI;EAAgB;CAAE;CACjG,mBAAmB;EAAE,IAAI;EAAqB,OAAO;GAAE,IAAI;GAAsB,IAAI;EAAqB;CAAE;CAC5G,oBAAoB;EAAE,IAAI;EAAsB,OAAO;GAAE,IAAI;GAAuB,IAAI;EAAoB;C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AAM,cAAc,EAAM,OAAO,CAAQ,CAAC;AACrK;AAIA,SAAS,EAAkB,GAA0B,GAA4B;CAC7E,IAAM,IAAS,EAA0B,EAAQ,CAAC;CAClD,OAAO,EAAO,MAAa,EAAA,MAA6B;AAC5D"}
|
|
1
|
+
{"version":3,"file":"dpuse-shared-encoding.es.js","names":[],"sources":["../src/encoding/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID, type LocaleId, type LocaleLabel } from '@/locale/label';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype EncodingGroupId = keyof typeof ENCODING_GROUP_CONFIG_DATA;\ntype EncodingTypeId = keyof typeof ENCODING_TYPE_CONFIG_DATA;\n\ninterface EncodingGroupConfig {\n id: EncodingGroupId;\n label: LocaleLabel;\n}\n\ninterface EncodingTypeConfig {\n id: EncodingTypeId;\n groupId: EncodingGroupId | null; // Null for encodings that belong to no group, e.g. 'ascii' and 'utf-8'.\n isDetectable: boolean;\n isDecodable: boolean;\n}\nexport interface EncodingTypeConfigLocalised {\n id: EncodingTypeId;\n groupLabel: string;\n label: string;\n isDetectable: boolean;\n isDecodable: boolean;\n}\n\nexport interface EncodingDetectionConfig {\n id: EncodingTypeId;\n confidenceLevel: number | undefined;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst ENCODING_GROUP_CONFIG_DATA = {\n arabic: { id: 'arabic', label: { en: 'Arabic', es: 'Árabe' } },\n baltic: { id: 'baltic', label: { en: 'Baltic', es: 'Báltico' } },\n celtic: { id: 'celtic', label: { en: 'Celtic', es: 'Celta' } },\n centralEuropean: { id: 'centralEuropean', label: { en: 'Central European', es: 'Centroeuropeo' } },\n chineseSimplified: { id: 'chineseSimplified', label: { en: 'Chinese Simplified', es: 'Chino simplificado' } },\n chineseTraditional: { id: 'chineseTraditional', label: { en: 'Chinese Traditional', es: 'Chino tradicional' } },\n cyrillic: { id: 'cyrillic', label: { en: 'Cyrillic', es: 'Cirílico' } },\n greek: { id: 'greek', label: { en: 'Greek', es: 'Griego' } },\n hebrew: { id: 'hebrew', label: { en: 'Hebrew', es: 'Hebreo' } },\n japanese: { id: 'japanese', label: { en: 'Japanese', es: 'Japonés' } },\n korean: { id: 'korean', label: { en: 'Korean', es: 'Coreano' } },\n nordic: { id: 'nordic', label: { en: 'Nordic', es: 'Nórdico' } },\n other: { id: 'other', label: { en: 'Other', es: 'Otro' } },\n romanian: { id: 'romanian', label: { en: 'Romanian', es: 'Rumano' } },\n southernEuropean: { id: 'southernEuropean', label: { en: 'Southern European', es: 'Europeo meridional' } },\n thai: { id: 'thai', label: { en: 'Thai', es: 'Tailandés' } },\n turkish: { id: 'turkish', label: { en: 'Turkish', es: 'Turco' } },\n unicode16: { id: 'unicode16', label: { en: 'Unicode 16', es: 'Unicode 16' } },\n unicode32: { id: 'unicode32', label: { en: 'Unicode 32', es: 'Unicode 32' } },\n vietnamese: { id: 'vietnamese', label: { en: 'Vietnamese', es: 'Vietnamita' } },\n western: { id: 'western', label: { en: 'Western', es: 'Occidental' } }\n} as const satisfies Record<string, { id: string; label: LocaleLabel }>;\n\nconst ENCODING_TYPE_CONFIG_DATA = {\n ascii: { id: 'ascii', groupId: null, isDetectable: false, isDecodable: true },\n big5: { id: 'big5', groupId: 'chineseTraditional', isDetectable: true, isDecodable: true },\n 'euc-jp': { id: 'euc-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'euc-kr': { id: 'euc-kr', groupId: 'korean', isDetectable: true, isDecodable: true },\n gb18030: { id: 'gb18030', groupId: 'chineseSimplified', isDetectable: true, isDecodable: true },\n gbk: { id: 'gbk', groupId: 'chineseSimplified', isDetectable: false, isDecodable: true },\n ibm866: { id: 'ibm866', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'iso-2022-cn': { id: 'iso-2022-cn', groupId: 'chineseSimplified', isDetectable: true, isDecodable: false },\n 'iso-2022-jp': { id: 'iso-2022-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'iso-2022-kr': { id: 'iso-2022-kr', groupId: 'korean', isDetectable: true, isDecodable: false },\n 'iso-8859-1': { id: 'iso-8859-1', groupId: 'western', isDetectable: true, isDecodable: true },\n 'iso-8859-2': { id: 'iso-8859-2', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'iso-8859-3': { id: 'iso-8859-3', groupId: 'southernEuropean', isDetectable: false, isDecodable: true },\n 'iso-8859-4': { id: 'iso-8859-4', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-5': { id: 'iso-8859-5', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'iso-8859-6': { id: 'iso-8859-6', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'iso-8859-7': { id: 'iso-8859-7', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'iso-8859-8': { id: 'iso-8859-8', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'iso-8859-9': { id: 'iso-8859-9', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'iso-8859-10': { id: 'iso-8859-10', groupId: 'nordic', isDetectable: false, isDecodable: true },\n 'iso-8859-11': { id: 'iso-8859-11', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'iso-8859-13': { id: 'iso-8859-13', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-14': { id: 'iso-8859-14', groupId: 'celtic', isDetectable: false, isDecodable: true },\n 'iso-8859-15': { id: 'iso-8859-15', groupId: 'western', isDetectable: false, isDecodable: true },\n 'iso-8859-16': { id: 'iso-8859-16', groupId: 'romanian', isDetectable: false, isDecodable: true },\n 'koi8-r': { id: 'koi8-r', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'koi8-u': { id: 'koi8-u', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n latin1: { id: 'latin1', groupId: 'western', isDetectable: false, isDecodable: true },\n macintosh: { id: 'macintosh', groupId: 'western', isDetectable: false, isDecodable: true },\n shift_jis: { id: 'shift_jis', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'tis-620': { id: 'tis-620', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'utf-16': { id: 'utf-16', groupId: 'unicode16', isDetectable: false, isDecodable: true },\n 'utf-16be': { id: 'utf-16be', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-16le': { id: 'utf-16le', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-32be': { id: 'utf-32be', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-32le': { id: 'utf-32le', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-8': { id: 'utf-8', groupId: null, isDetectable: true, isDecodable: true },\n 'windows-1250': { id: 'windows-1250', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'windows-1251': { id: 'windows-1251', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'windows-1252': { id: 'windows-1252', groupId: 'western', isDetectable: true, isDecodable: true },\n 'windows-1253': { id: 'windows-1253', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'windows-1254': { id: 'windows-1254', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'windows-1255': { id: 'windows-1255', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'windows-1256': { id: 'windows-1256', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'windows-1257': { id: 'windows-1257', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'windows-1258': { id: 'windows-1258', groupId: 'vietnamese', isDetectable: false, isDecodable: true },\n 'windows-874': { id: 'windows-874', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'x-mac-cyrillic': { id: 'x-mac-cyrillic', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'x-user-defined': { id: 'x-user-defined', groupId: 'other', isDetectable: false, isDecodable: true }\n} as const satisfies Record<string, { id: string; groupId: keyof typeof ENCODING_GROUP_CONFIG_DATA | null; isDetectable: boolean; isDecodable: boolean }>;\n\nexport const ENCODING_GROUP_CONFIG_MAP = ENCODING_GROUP_CONFIG_DATA as Record<EncodingGroupId, EncodingGroupConfig>;\nexport const ENCODING_TYPE_CONFIG_MAP = ENCODING_TYPE_CONFIG_DATA as Record<EncodingTypeId, EncodingTypeConfig>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Narrows a name from outside the app, such as one reported by encoding detection, to a known encoding id. Check with\n// this once where the name arrives, so everything after it works with 'EncodingTypeId'.\nexport function isEncodingTypeId(value: string): value is EncodingTypeId {\n return Object.hasOwn(ENCODING_TYPE_CONFIG_MAP, value);\n}\n\nexport function getEncodingTypeConfigs(localeId: LocaleId = DEFAULT_LOCALE_ID): EncodingTypeConfigLocalised[] {\n const encodingTypeConfigs: EncodingTypeConfigLocalised[] = Array.from(Object.values(ENCODING_TYPE_CONFIG_MAP), ({ groupId, id, isDecodable, isDetectable }) => {\n const groupLabel = groupId == null ? '' : resolveGroupLabel(groupId, localeId);\n return { id, groupLabel, label: groupLabel ? `${groupLabel} (${id})` : id, isDetectable, isDecodable };\n });\n return encodingTypeConfigs.toSorted((left, right) => left.groupLabel.localeCompare(right.groupLabel, localeId) || left.label.localeCompare(right.label, localeId));\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nfunction resolveGroupLabel(groupId: EncodingGroupId, localeId: LocaleId): string {\n const labels = ENCODING_GROUP_CONFIG_MAP[groupId].label;\n return labels[localeId] ?? labels[DEFAULT_LOCALE_ID] ?? groupId;\n}\n"],"mappings":";;AAkCA,IAAM,IAA6B;CAC/B,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,iBAAiB;EAAE,IAAI;EAAmB,OAAO;GAAE,IA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AC7E,OAAO;GAAE;GAAI;GAAY,OAAO,IAAa,GAAG,EAAW,IAAI,EAAG,KAAK;GAAI;GAAc;EAAY;CACzG,CACO,CAAA,CAAoB,UAAU,GAAM,MAAU,EAAK,WAAW,cAAc,EAAM,YAAY,CAAQ,KAAK,EAAK,MAAM,cAAc,EAAM,OAAO,CAAQ,CAAC;AACrK;AAIA,SAAS,EAAkB,GAA0B,GAA4B;CAC7E,IAAM,IAAS,EAA0B,EAAQ,CAAC;CAClD,OAAO,EAAO,MAAa,EAAA,MAA6B;AAC5D"}
|
|
@@ -147,4 +147,4 @@ function S(e) {
|
|
|
147
147
|
}, null];
|
|
148
148
|
}
|
|
149
149
|
//#endregion
|
|
150
|
-
export { o as APIError, a as AppError, c as ConnectorError,
|
|
150
|
+
export { o as APIError, a as AppError, c as ConnectorError, s as EngineError, l as FetchError, u as buildFetchError, d as concatenateSerialisedErrorMessages, f as ignoreErrors, p as normalizeToError, m as serialiseError, h as unserialiseError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-shared-errors.es.js","names":[],"sources":["../src/errors/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Serializable representation of an error; used for transporting errors across api and worker boundaries\nexport interface SerialisedError {\n data: Record<string, unknown> | undefined;\n locator: string; // Error locator 'package.module.method'\n message: string; // Human-readable error message\n name: string; // Error class or type name\n stack: string | undefined; // Stack trace if available\n}\n\n// ── Constants ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst RESPONSE_ERROR_BODY_LIMIT = 2048;\n\n// Redaction — serialised errors are shown in the browser and stored in Axiom, so secrets and email addresses are masked\n// first. Best effort: it catches the common shapes, not every possible secret.\nconst REDACTED = '[REDACTED]';\nconst REDACTION_MAX_DEPTH = 10; // Deeper 'data' is replaced whole rather than walked.\nconst SECRET_KEY_PATTERN = /api[-_]?key|authori[sz]ation|cookie|credential|passw(?:or)?d|private[-_]?key|secret|token/i; // A 'data' field whose name matches has its whole value masked.\n// Each pattern is anchored to the start of a word, so it runs in linear time even over a long response body.\nconst SECRET_TEXT_PATTERNS: [RegExp, (match: string, ...groups: string[]) => string][] = [\n [/\\b(Bearer|Basic) +[\\w.~+/=-]+/gi, (_match, scheme) => `${scheme} ${REDACTED}`], // Authorisation header values.\n // Any 'name: value' or 'name=value' pair, in JSON, query strings, form bodies or headers; masked when the name looks\n // secret. A bare 'Basic' or 'Bearer' value is the scheme left by the pattern above, whose token is already masked.\n [\n /(?<![\\w-])([\\w-]+)([\"']?[ \\t]*[:=][ \\t]*[\"']?)([^\\s\"'&,;}?#]+)/g,\n (match, name, separator, value) => (SECRET_KEY_PATTERN.test(name) && !/^(?:Basic|Bearer)$/i.test(value) ? `${name}${separator}${REDACTED}` : match)\n ],\n [/\\beyJ[\\w-]+\\.[\\w-]+\\.[\\w-]*/g, () => REDACTED], // JSON web tokens.\n [/\\b(?:sk-|xaat-|xapt-|sl\\.)[\\w-]{16,}/g, () => REDACTED], // Known token prefixes: OpenAI, Anthropic, Axiom, Dropbox.\n [/(?<![\\w.+-])[\\w.+-]+@[\\w-]+\\.[\\w.-]+/g, () => REDACTED] // Email addresses.\n];\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Base class for all DPUse errors; includes a locator for the error; never thrown directly\nexport class DPUseError extends Error {\n readonly data: Record<string, unknown> | undefined;\n readonly locator: string; // Error locator 'package.module.method'\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, options);\n this.name = 'DPUseError';\n this.data = data;\n this.locator = locator;\n }\n}\n\n// Thrown when an app (studio/assistant) error occurs\nexport class AppError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'AppError';\n }\n}\n\n// Thrown when an API request fails\nexport class APIError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'APIError';\n }\n}\n\n// Thrown when an engine request fails\nexport class EngineError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'EngineError';\n }\n}\n\n// Thrown when an connector operation fails; will always be wrapped in an engine error\nexport class ConnectorError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'ConnectorError';\n }\n}\n\n// Thrown when an HTTP request fails; may include a sanitized portion of the response body for diagnostic purposes\nexport class FetchError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'FetchError';\n }\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fetch error from an HTTP response; includes a text copy of the response body\nexport async function buildFetchError(response: { status: number; statusText: string; text: () => Promise<string> }, message: string, locator: string): Promise<FetchError> {\n const responseStatusStuff = ` - ${response.statusText}`;\n const fetchMessage = `${message} Response status '${String(response.status)}${response.statusText ? responseStatusStuff : ''}' received.`;\n let bodyText: string;\n try {\n bodyText = await response.text();\n } catch (error) {\n const normalised = normalizeToError(error);\n bodyText = `<body unavailable: ${normalised.message}>`;\n }\n return new FetchError(fetchMessage, locator, { body: sanitizeResponseErrorBody(bodyText) });\n}\n\n// Concatenates serialized error messages into a single string\nexport function concatenateSerialisedErrorMessages(serialisedErrors: SerialisedError[]): string {\n return serialisedErrors.map((serialisedError) => serialisedError.message).join(' ');\n}\n\n// Ignore best-effort cleanup errors to keep teardown noise-free\nexport function ignoreErrors(action: () => void): void {\n try {\n action();\n } catch {\n // Intentionally ignore errors\n }\n}\n\n// Normalizes an unknown thrown value into an error\nexport function normalizeToError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return new Error(String(value));\n if (typeof value === 'symbol') return new Error(value.description ?? 'Unknown error');\n if (typeof value === 'object') {\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error('Unknown error');\n }\n }\n return new Error('Unknown error');\n}\n\n// Serializes an error and its cause chain into a array of serialised error objects;\n// errors are ordered from outermost to root cause;\n// cycles in the cause chain are safely ignored;\n// messages are normalized to end with punctuation;\n// secrets and email addresses in messages, stacks and data are redacted\nexport function serialiseError(error?: unknown): SerialisedError[] {\n const seenCauses = new Set();\n const serialisedErrors: SerialisedError[] = [];\n let cause: Error | null = normalizeToError(error);\n while (cause != null && !seenCauses.has(cause)) {\n seenCauses.add(cause);\n const [serialisedError, nextCause] = serialiseSingleError(cause);\n if (!/(?:\\.{3}|[.!?])$/.test(serialisedError.message)) serialisedError.message += '.';\n serialisedErrors.push(redactSerialisedError(serialisedError));\n cause = nextCause;\n }\n return serialisedErrors;\n}\n\n// Unserialises an array of serialised error objects back into an error with a cause chain;\n// reconstructs the appropriate error class based on serialized properties;\n// chains errors from outermost to root cause using the `cause` option;\n// returns a placeholder error if the input array is empty\nexport function unserialiseError(serialisedErrors: SerialisedError[]): Error {\n // Build the error chain from root cause (end) to outermost (start)\n let rebuiltError: Error | undefined;\n for (const serialised of serialisedErrors.toReversed()) {\n const error = reconstructError(serialised, rebuiltError);\n if (serialised.stack !== undefined) error.stack = serialised.stack; // Restore stack trace if available\n rebuiltError = error;\n }\n return rebuiltError ?? new Error('No error to unserialise.');\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fallback message for non-error throwables\nfunction buildFallbackMessage(cause: unknown): string {\n let fallbackMessage: string;\n try {\n fallbackMessage = JSON.stringify(cause);\n } catch {\n if (typeof cause === 'symbol') fallbackMessage = cause.description ?? 'Unknown error';\n else if (typeof cause === 'bigint') fallbackMessage = cause.toString();\n else fallbackMessage = 'Unknown error';\n }\n if (fallbackMessage === '') fallbackMessage = 'Unknown error';\n return fallbackMessage;\n}\n\nfunction reconstructError(serialised: SerialisedError, cause: Error | undefined): Error {\n switch (serialised.name) {\n case 'APIError':\n return new APIError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'AppError':\n return new AppError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'ConnectorError':\n return new ConnectorError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'EngineError':\n return new EngineError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'FetchError':\n return new FetchError(serialised.message, serialised.locator, serialised.data, { cause });\n default: {\n const name = serialised.name;\n return new (class extends Error {\n override name = name;\n })(serialised.message, { cause });\n }\n }\n}\n\nfunction redactSerialisedError(serialisedError: SerialisedError): SerialisedError {\n const { data, message, stack } = serialisedError;\n return {\n ...serialisedError,\n data: data === undefined ? undefined : (redactValue(data, new WeakSet(), 0) as Record<string, unknown>),\n message: redactText(message),\n stack: stack === undefined ? undefined : redactText(stack)\n };\n}\n\nfunction redactText(text: string): string {\n let redactedText = text;\n for (const [pattern, replacement] of SECRET_TEXT_PATTERNS)\n redactedText = redactedText.replaceAll(pattern, (match: string, ...groups: string[]) => replacement(match, ...groups));\n return redactedText;\n}\n\n// Walks 'data', masking any field whose name looks secret and any secret found in text.\nfunction redactValue(value: unknown, seen: WeakSet<object>, depth: number): unknown {\n if (typeof value === 'string') return redactText(value);\n if (typeof value !== 'object' || value === null) return value;\n if (depth >= REDACTION_MAX_DEPTH) return REDACTED;\n if (seen.has(value)) return '[Circular]';\n seen.add(value);\n return Array.isArray(value)\n ? value.map((item) => redactValue(item, seen, depth + 1))\n : Object.fromEntries(\n Object.entries(value).map(([key, entryValue]) => [key, entryValue != null && SECRET_KEY_PATTERN.test(key) ? REDACTED : redactValue(entryValue, seen, depth + 1)])\n );\n}\n\n// Sanitizes a response body; limits body size to avoid excessive payloads when logging\nfunction sanitizeResponseErrorBody(body?: string): string | undefined {\n if (body == null || body === '') return undefined;\n return body.length > RESPONSE_ERROR_BODY_LIMIT ? `${body.slice(0, RESPONSE_ERROR_BODY_LIMIT)}... [truncated]` : body;\n}\n\nfunction serialiseSingleError(cause: Error): [SerialisedError, Error | null] {\n const nextCause = cause.cause == null ? null : normalizeToError(cause.cause);\n if (cause instanceof DPUseError) {\n return [{ data: cause.data, locator: cause.locator, message: cause.message, name: cause.name, stack: cause.stack }, nextCause];\n }\n const customProperties = Object.fromEntries(Object.entries(cause).filter(([k]) => k !== 'cause'));\n return cause.name\n ? [{ data: customProperties, locator: '', message: cause.message, name: cause.name, stack: cause.stack }, nextCause]\n : [{ data: customProperties, locator: '', message: buildFallbackMessage(cause), name: 'Error', stack: undefined }, null];\n}\n"],"mappings":";AAaA,IAAM,IAA4B,MAI5B,IAAW,cAEX,IAAqB,8FAErB,IAAmF;CACrF,CAAC,oCAAoC,GAAQ,MAAW,GAAG,EAAO,GAAG,GAAU;CAG/E,CACI,oEACC,GAAO,GAAM,GAAW,MAAW,EAAmB,KAAK,CAAI,KAAK,CAAC,sBAAsB,KAAK,CAAK,IAAI,GAAG,IAAO,IAAY,MAAa,CACjJ;CACA,CAAC,sCAAsC,CAAQ;CAC/C,CAAC,+CAA+C,CAAQ;CACxD,CAAC,+CAA+C,CAAQ;AAC5D,GAKa,IAAb,cAAgC,MAAM;CAClC;CACA;CACA,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAIlG,AAHA,MAAM,GAAS,CAAO,GACtB,KAAK,OAAO,cACZ,KAAK,OAAO,GACZ,KAAK,UAAU;CACnB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAAiC,EAAW;CACxC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,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AS,EAA0B,GAAmC;CAClE,IAAI,KAAQ,QAAQ,MAAS,IAC7B,OAAO,EAAK,SAAS,IAA4B,GAAG,EAAK,MAAM,GAAG,CAAyB,EAAE,mBAAmB;AACpH;AAEA,SAAS,EAAqB,GAA+C;CACzE,IAAM,IAAY,EAAM,SAAS,OAAO,OAAO,EAAiB,EAAM,KAAK;CAC3E,IAAI,aAAiB,GACjB,OAAO,CAAC;EAAE,MAAM,EAAM;EAAM,SAAS,EAAM;EAAS,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS;CAEjI,IAAM,IAAmB,OAAO,YAAY,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,MAAM,OAAO,CAAC;CAChG,OAAO,EAAM,OACP,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS,IACjH,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAqB,CAAK;EAAG,MAAM;EAAS,OAAO,KAAA;CAAU,GAAG,IAAI;AAC/H"}
|
|
1
|
+
{"version":3,"file":"dpuse-shared-errors.es.js","names":[],"sources":["../src/errors/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Serializable representation of an error; used for transporting errors across api and worker boundaries\nexport interface SerialisedError {\n data: Record<string, unknown> | undefined;\n locator: string; // Error locator 'package.module.method'\n message: string; // Human-readable error message\n name: string; // Error class or type name\n stack: string | undefined; // Stack trace if available\n}\n\n// ── Constants ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst RESPONSE_ERROR_BODY_LIMIT = 2048;\n\n// Redaction — serialised errors are shown in the browser and stored in Axiom, so secrets and email addresses are masked\n// first. Best effort: it catches the common shapes, not every possible secret.\nconst REDACTED = '[REDACTED]';\nconst REDACTION_MAX_DEPTH = 10; // Deeper 'data' is replaced whole rather than walked.\nconst SECRET_KEY_PATTERN = /api[-_]?key|authori[sz]ation|cookie|credential|passw(?:or)?d|private[-_]?key|secret|token/i; // A 'data' field whose name matches has its whole value masked.\n// Each pattern is anchored to the start of a word, so it runs in linear time even over a long response body.\nconst SECRET_TEXT_PATTERNS: [RegExp, (match: string, ...groups: string[]) => string][] = [\n [/\\b(Bearer|Basic) +[\\w.~+/=-]+/gi, (_match, scheme) => `${scheme} ${REDACTED}`], // Authorisation header values.\n // Any 'name: value' or 'name=value' pair, in JSON, query strings, form bodies or headers; masked when the name looks\n // secret. A bare 'Basic' or 'Bearer' value is the scheme left by the pattern above, whose token is already masked.\n [\n /(?<![\\w-])([\\w-]+)([\"']?[ \\t]*[:=][ \\t]*[\"']?)([^\\s\"'&,;}?#]+)/g,\n (match, name, separator, value) => (SECRET_KEY_PATTERN.test(name) && !/^(?:Basic|Bearer)$/i.test(value) ? `${name}${separator}${REDACTED}` : match)\n ],\n [/\\beyJ[\\w-]+\\.[\\w-]+\\.[\\w-]*/g, () => REDACTED], // JSON web tokens.\n [/\\b(?:sk-|xaat-|xapt-|sl\\.)[\\w-]{16,}/g, () => REDACTED], // Known token prefixes: OpenAI, Anthropic, Axiom, Dropbox.\n [/(?<![\\w.+-])[\\w.+-]+@[\\w-]+\\.[\\w.-]+/g, () => REDACTED] // Email addresses.\n];\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Base class for all DPUse errors; includes a locator for the error; never thrown directly\nclass DPUseError extends Error {\n readonly data: Record<string, unknown> | undefined;\n readonly locator: string; // Error locator 'package.module.method'\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, options);\n this.name = 'DPUseError';\n this.data = data;\n this.locator = locator;\n }\n}\n\n// Thrown when an app (studio/assistant) error occurs\nexport class AppError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'AppError';\n }\n}\n\n// Thrown when an API request fails\nexport class APIError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'APIError';\n }\n}\n\n// Thrown when an engine request fails\nexport class EngineError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'EngineError';\n }\n}\n\n// Thrown when an connector operation fails; will always be wrapped in an engine error\nexport class ConnectorError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'ConnectorError';\n }\n}\n\n// Thrown when an HTTP request fails; may include a sanitized portion of the response body for diagnostic purposes\nexport class FetchError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'FetchError';\n }\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fetch error from an HTTP response; includes a text copy of the response body\nexport async function buildFetchError(response: { status: number; statusText: string; text: () => Promise<string> }, message: string, locator: string): Promise<FetchError> {\n const responseStatusStuff = ` - ${response.statusText}`;\n const fetchMessage = `${message} Response status '${String(response.status)}${response.statusText ? responseStatusStuff : ''}' received.`;\n let bodyText: string;\n try {\n bodyText = await response.text();\n } catch (error) {\n const normalised = normalizeToError(error);\n bodyText = `<body unavailable: ${normalised.message}>`;\n }\n return new FetchError(fetchMessage, locator, { body: sanitizeResponseErrorBody(bodyText) });\n}\n\n// Concatenates serialized error messages into a single string\nexport function concatenateSerialisedErrorMessages(serialisedErrors: SerialisedError[]): string {\n return serialisedErrors.map((serialisedError) => serialisedError.message).join(' ');\n}\n\n// Ignore best-effort cleanup errors to keep teardown noise-free\nexport function ignoreErrors(action: () => void): void {\n try {\n action();\n } catch {\n // Intentionally ignore errors\n }\n}\n\n// Normalizes an unknown thrown value into an error\nexport function normalizeToError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return new Error(String(value));\n if (typeof value === 'symbol') return new Error(value.description ?? 'Unknown error');\n if (typeof value === 'object') {\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error('Unknown error');\n }\n }\n return new Error('Unknown error');\n}\n\n// Serializes an error and its cause chain into a array of serialised error objects;\n// errors are ordered from outermost to root cause;\n// cycles in the cause chain are safely ignored;\n// messages are normalized to end with punctuation;\n// secrets and email addresses in messages, stacks and data are redacted\nexport function serialiseError(error?: unknown): SerialisedError[] {\n const seenCauses = new Set();\n const serialisedErrors: SerialisedError[] = [];\n let cause: Error | null = normalizeToError(error);\n while (cause != null && !seenCauses.has(cause)) {\n seenCauses.add(cause);\n const [serialisedError, nextCause] = serialiseSingleError(cause);\n if (!/(?:\\.{3}|[.!?])$/.test(serialisedError.message)) serialisedError.message += '.';\n serialisedErrors.push(redactSerialisedError(serialisedError));\n cause = nextCause;\n }\n return serialisedErrors;\n}\n\n// Unserialises an array of serialised error objects back into an error with a cause chain;\n// reconstructs the appropriate error class based on serialized properties;\n// chains errors from outermost to root cause using the `cause` option;\n// returns a placeholder error if the input array is empty\nexport function unserialiseError(serialisedErrors: SerialisedError[]): Error {\n // Build the error chain from root cause (end) to outermost (start)\n let rebuiltError: Error | undefined;\n for (const serialised of serialisedErrors.toReversed()) {\n const error = reconstructError(serialised, rebuiltError);\n if (serialised.stack !== undefined) error.stack = serialised.stack; // Restore stack trace if available\n rebuiltError = error;\n }\n return rebuiltError ?? new Error('No error to unserialise.');\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fallback message for non-error throwables\nfunction buildFallbackMessage(cause: unknown): string {\n let fallbackMessage: string;\n try {\n fallbackMessage = JSON.stringify(cause);\n } catch {\n if (typeof cause === 'symbol') fallbackMessage = cause.description ?? 'Unknown error';\n else if (typeof cause === 'bigint') fallbackMessage = cause.toString();\n else fallbackMessage = 'Unknown error';\n }\n if (fallbackMessage === '') fallbackMessage = 'Unknown error';\n return fallbackMessage;\n}\n\nfunction reconstructError(serialised: SerialisedError, cause: Error | undefined): Error {\n switch (serialised.name) {\n case 'APIError':\n return new APIError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'AppError':\n return new AppError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'ConnectorError':\n return new ConnectorError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'EngineError':\n return new EngineError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'FetchError':\n return new FetchError(serialised.message, serialised.locator, serialised.data, { cause });\n default: {\n const name = serialised.name;\n return new (class extends Error {\n override name = name;\n })(serialised.message, { cause });\n }\n }\n}\n\nfunction redactSerialisedError(serialisedError: SerialisedError): SerialisedError {\n const { data, message, stack } = serialisedError;\n return {\n ...serialisedError,\n data: data === undefined ? undefined : (redactValue(data, new WeakSet(), 0) as Record<string, unknown>),\n message: redactText(message),\n stack: stack === undefined ? undefined : redactText(stack)\n };\n}\n\nfunction redactText(text: string): string {\n let redactedText = text;\n for (const [pattern, replacement] of SECRET_TEXT_PATTERNS)\n redactedText = redactedText.replaceAll(pattern, (match: string, ...groups: string[]) => replacement(match, ...groups));\n return redactedText;\n}\n\n// Walks 'data', masking any field whose name looks secret and any secret found in text.\nfunction redactValue(value: unknown, seen: WeakSet<object>, depth: number): unknown {\n if (typeof value === 'string') return redactText(value);\n if (typeof value !== 'object' || value === null) return value;\n if (depth >= REDACTION_MAX_DEPTH) return REDACTED;\n if (seen.has(value)) return '[Circular]';\n seen.add(value);\n return Array.isArray(value)\n ? value.map((item) => redactValue(item, seen, depth + 1))\n : Object.fromEntries(\n Object.entries(value).map(([key, entryValue]) => [key, entryValue != null && SECRET_KEY_PATTERN.test(key) ? REDACTED : redactValue(entryValue, seen, depth + 1)])\n );\n}\n\n// Sanitizes a response body; limits body size to avoid excessive payloads when logging\nfunction sanitizeResponseErrorBody(body?: string): string | undefined {\n if (body == null || body === '') return undefined;\n return body.length > RESPONSE_ERROR_BODY_LIMIT ? `${body.slice(0, RESPONSE_ERROR_BODY_LIMIT)}... [truncated]` : body;\n}\n\nfunction serialiseSingleError(cause: Error): [SerialisedError, Error | null] {\n const nextCause = cause.cause == null ? null : normalizeToError(cause.cause);\n if (cause instanceof DPUseError) {\n return [{ data: cause.data, locator: cause.locator, message: cause.message, name: cause.name, stack: cause.stack }, nextCause];\n }\n const customProperties = Object.fromEntries(Object.entries(cause).filter(([k]) => k !== 'cause'));\n return cause.name\n ? [{ data: customProperties, locator: '', message: cause.message, name: cause.name, stack: cause.stack }, nextCause]\n : [{ data: customProperties, locator: '', message: buildFallbackMessage(cause), name: 'Error', stack: undefined }, null];\n}\n"],"mappings":";AAaA,IAAM,IAA4B,MAI5B,IAAW,cAEX,IAAqB,8FAErB,IAAmF;CACrF,CAAC,oCAAoC,GAAQ,MAAW,GAAG,EAAO,GAAG,GAAU;CAG/E,CACI,oEACC,GAAO,GAAM,GAAW,MAAW,EAAmB,KAAK,CAAI,KAAK,CAAC,sBAAsB,KAAK,CAAK,IAAI,GAAG,IAAO,IAAY,MAAa,CACjJ;CACA,CAAC,sCAAsC,CAAQ;CAC/C,CAAC,+CAA+C,CAAQ;CACxD,CAAC,+CAA+C,CAAQ;AAC5D,GAKM,IAAN,cAAyB,MAAM;CAC3B;CACA;CACA,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAIlG,AAHA,MAAM,GAAS,CAAO,GACtB,KAAK,OAAO,cACZ,KAAK,OAAO,GACZ,KAAK,UAAU;CACnB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,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B,KAAK,CAAG,IAAI,IAAW,EAAY,GAAY,GAAM,IAAQ,CAAC,CAAC,CAAC,CACpK;AACV;AAGA,SAAS,EAA0B,GAAmC;CAClE,IAAI,KAAQ,QAAQ,MAAS,IAC7B,OAAO,EAAK,SAAS,IAA4B,GAAG,EAAK,MAAM,GAAG,CAAyB,EAAE,mBAAmB;AACpH;AAEA,SAAS,EAAqB,GAA+C;CACzE,IAAM,IAAY,EAAM,SAAS,OAAO,OAAO,EAAiB,EAAM,KAAK;CAC3E,IAAI,aAAiB,GACjB,OAAO,CAAC;EAAE,MAAM,EAAM;EAAM,SAAS,EAAM;EAAS,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS;CAEjI,IAAM,IAAmB,OAAO,YAAY,OAAO,QAAQ,CAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,MAAM,OAAO,CAAC;CAChG,OAAO,EAAM,OACP,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAM;EAAS,MAAM,EAAM;EAAM,OAAO,EAAM;CAAM,GAAG,CAAS,IACjH,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAI,SAAS,EAAqB,CAAK;EAAG,MAAM;EAAS,OAAO,KAAA;CAAU,GAAG,IAAI;AAC/H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dpuse-shared-locale.es.js","names":[],"sources":["../src/locale/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID } from '
|
|
1
|
+
{"version":3,"file":"dpuse-shared-locale.es.js","names":[],"sources":["../src/locale/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID } from './label';\nimport type { LocaleDescription, LocaleId, LocaleLabel } from './label';\n\n// The label vocabulary is re-exported so that the published '@dpuse/dpuse-shared/locale' entry point stays one import\n// for consumers, while modules inside this package can depend on '@/locale/label' alone.\nexport * from './label';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type LocalisedConfig<T> = Omit<T, 'label' | 'description' | 'verb'> & { label: string; description: string; verb?: string | undefined };\n\ninterface UnlocalisedConfig {\n id: string;\n label: LocaleLabel;\n description: LocaleDescription;\n verb?: LocaleLabel | undefined;\n}\n\nexport type LocalisedReference<T> = Omit<T, 'label' | 'description'> & { label: string; description: string };\n\ninterface UnlocalisedReference {\n id: string;\n label: LocaleLabel;\n description: LocaleDescription;\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function localiseConfig<T extends UnlocalisedConfig>(config: T, localeId: LocaleId): LocalisedConfig<T> {\n return {\n ...config,\n label: config.label[localeId] ?? config.id,\n description: config.description[localeId] ?? config.description[DEFAULT_LOCALE_ID] ?? '',\n verb: config.verb?.[localeId] ?? undefined\n };\n}\n\nexport function localiseConfigs<T extends UnlocalisedConfig>(configs: T[], localeId: LocaleId, isResultSorted = false): LocalisedConfig<T>[] {\n const mapped = configs.map((config) => ({\n ...config,\n label: config.label[localeId] ?? config.id,\n description: config.description[localeId] ?? config.description[DEFAULT_LOCALE_ID] ?? '',\n verb: config.verb?.[localeId] ?? undefined\n }));\n return isResultSorted ? mapped.toSorted((a, b) => a.label.localeCompare(b.label) || a.id.localeCompare(b.id)) : mapped;\n}\n\nexport function localiseReference<T extends UnlocalisedReference>(reference: T, localeId: LocaleId): LocalisedReference<T> {\n return {\n ...reference,\n label: reference.label[localeId] ?? reference.id,\n description: reference.description[localeId] ?? reference.description[DEFAULT_LOCALE_ID] ?? ''\n };\n}\n"],"mappings":";;AA6BA,SAAgB,EAA4C,GAAW,GAAwC;CAC3G,OAAO;EACH,GAAG;EACH,OAAO,EAAO,MAAM,MAAa,EAAO;EACxC,aAAa,EAAO,YAAY,MAAa,EAAO,YAAA,MAAkC;EACtF,MAAM,EAAO,OAAO,MAAa,KAAA;CACrC;AACJ;AAEA,SAAgB,EAA6C,GAAc,GAAoB,IAAiB,IAA6B;CACzI,IAAM,IAAS,EAAQ,KAAK,OAAY;EACpC,GAAG;EACH,OAAO,EAAO,MAAM,MAAa,EAAO;EACxC,aAAa,EAAO,YAAY,MAAa,EAAO,YAAA,MAAkC;EACtF,MAAM,EAAO,OAAO,MAAa,KAAA;CACrC,EAAE;CACF,OAAO,IAAiB,EAAO,UAAU,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,KAAK,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC,IAAI;AACpH;AAEA,SAAgB,EAAkD,GAAc,GAA2C;CACvH,OAAO;EACH,GAAG;EACH,OAAO,EAAU,MAAM,MAAa,EAAU;EAC9C,aAAa,EAAU,YAAY,MAAa,EAAU,YAAA,MAAkC;CAChG;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-DexpXrnC.js","names":[],"sources":["../src/locale/label.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\
|
|
1
|
+
{"version":3,"file":"label-DexpXrnC.js","names":[],"sources":["../src/locale/label.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\ntype FlagId = 'es' | 'gb';\n\nexport type LocaleId = 'en' | 'es';\n\nexport type LocaleLabel = Partial<Record<LocaleId, string>>;\n\nexport type LocaleDescription = Partial<Record<LocaleId, string>>;\n\nexport type LocaleLabelMap = ReadonlyMap<string, string>;\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport const DEFAULT_LOCALE_ID: LocaleId = 'en';\n\nexport const SUPPORTED_LANGUAGES: { id: LocaleId; flag: FlagId; label: string }[] = [\n { id: 'en', flag: 'gb', label: 'English' },\n { id: 'es', flag: 'es', label: 'Español' }\n];\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport function createLabelMap(labels: Record<string, string>): LocaleLabelMap {\n return new Map(Object.entries(labels));\n}\n\nexport function resolveLabel(labels: LocaleLabelMap, localeId: string, fallbackLocaleId = DEFAULT_LOCALE_ID): string | undefined {\n const localizedLabel = labels.get(localeId);\n if (localizedLabel !== undefined) return localizedLabel;\n return fallbackLocaleId === localeId ? undefined : labels.get(fallbackLocaleId);\n}\n"],"mappings":";AAcA,IAAa,IAA8B,MAE9B,IAAuE,CAChF;CAAE,IAAI;CAAM,MAAM;CAAM,OAAO;AAAU,GACzC;CAAE,IAAI;CAAM,MAAM;CAAM,OAAO;AAAU,CAC7C;AAIA,SAAgB,EAAe,GAAgD;CAC3E,OAAO,IAAI,IAAI,OAAO,QAAQ,CAAM,CAAC;AACzC;AAEA,SAAgB,EAAa,GAAwB,GAAkB,IAAA,MAA0D;CAC7H,IAAM,IAAiB,EAAO,IAAI,CAAQ;CAE1C,OADI,MAAmB,KAAA,IAChB,MAAqB,IAAW,KAAA,IAAY,EAAO,IAAI,CAAgB,IADrC;AAE7C"}
|
|
@@ -9,7 +9,7 @@ export interface ConnectionConfig extends ComponentInstanceConfig {
|
|
|
9
9
|
lastVerifiedAt: number;
|
|
10
10
|
notation: string | undefined;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface ConnectionAuthorisationConfig {
|
|
13
13
|
accessToken: string;
|
|
14
14
|
accountId: string;
|
|
15
15
|
expiresAt: number;
|
|
@@ -43,11 +43,11 @@ export interface ConnectionNodeConfig {
|
|
|
43
43
|
size: number | undefined;
|
|
44
44
|
typeId: NodeTypeId;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
interface DPAFileSystemFileHandle {
|
|
47
47
|
readonly kind: 'file';
|
|
48
48
|
getFile(): Promise<File>;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
type NodeTypeId = 'folder' | 'object';
|
|
51
51
|
export interface ObjectColumnConfig {
|
|
52
52
|
dataTypeId: DataTypeId;
|
|
53
53
|
dataSubtypeId: DataSubtypeId | undefined;
|
|
@@ -71,4 +71,5 @@ export interface ObjectColumnConfig {
|
|
|
71
71
|
validValues: Record<string, string>;
|
|
72
72
|
voidValueCount: number | undefined;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
type StorageTypeId = 'binary' | 'boolean' | 'byte' | 'date' | 'dateTime' | 'dateTimeOffset' | 'decimal' | 'double' | 'int8' | 'int16' | 'int32' | 'int64' | 'object' | 'single' | 'string' | 'time' | 'unknown';
|
|
75
|
+
export {};
|
|
@@ -3,8 +3,9 @@ export interface ContextConfig extends ComponentInstanceConfig {
|
|
|
3
3
|
typeId: 'context';
|
|
4
4
|
areas: ContextAreaConfig[];
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
interface ContextAreaConfig extends ComponentInstanceConfig {
|
|
7
7
|
typeId: 'contextArea';
|
|
8
8
|
models: ComponentReferenceConfig[];
|
|
9
9
|
order: number;
|
|
10
10
|
}
|
|
11
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocaleDescription, LocaleLabel } from '../../../../../locale/label';
|
|
2
|
-
|
|
2
|
+
type ContextModelEntityEventId = 'creation' | 'activation' | 'recognition' | 'correction' | 'modification' | 'derecognition' | 'deactivation' | 'archival' | 'deletion';
|
|
3
3
|
export interface ContextModelEntityEventConfig {
|
|
4
4
|
id: ContextModelEntityEventId;
|
|
5
5
|
labelAction: LocaleLabel;
|
|
@@ -7,3 +7,4 @@ export interface ContextModelEntityEventConfig {
|
|
|
7
7
|
description: LocaleDescription;
|
|
8
8
|
}
|
|
9
9
|
export type ContextModelEntityEventsConfig = ContextModelEntityEventConfig[];
|
|
10
|
+
export {};
|
|
@@ -12,6 +12,7 @@ export interface ContextModelEntityConfig extends ComponentInstanceConfig {
|
|
|
12
12
|
parents?: ContextModelEntityParentConfig[];
|
|
13
13
|
primaryMeasures: ContextModelEntityPrimaryMeasuresConfig;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
interface ContextModelEntityParentConfig {
|
|
16
16
|
entityTypeId: string;
|
|
17
17
|
}
|
|
18
|
+
export {};
|