* @hidden Verify config checks that the constructor provided config matches the expected proto * structure, or the previously accepted legacy structure. If the legacy structure is used, it is * converted to the new structure.
(
// `any` is used here to facilitate the type merging of the legacy table config, which is very
// different to the new structure.
unverifiedConfig: dataform.ActionConfig.TableConfig | ILegacyTableConfig | any
)
| 594 | * converted to the new structure. |
| 595 | */ |
| 596 | private verifyConfig( |
| 597 | // `any` is used here to facilitate the type merging of the legacy table config, which is very |
| 598 | // different to the new structure. |
| 599 | unverifiedConfig: dataform.ActionConfig.TableConfig | ILegacyTableConfig | any |
| 600 | ): dataform.ActionConfig.TableConfig { |
| 601 | // The "type" field only exists on legacy table configs. Here we convert them to the |
| 602 | // new format. |
| 603 | if (unverifiedConfig.type) { |
| 604 | if (unverifiedConfig.type !== "table") { |
| 605 | throw ReferenceError( |
| 606 | `Unexpected type for Table; want "table", got ${unverifiedConfig.type}` |
| 607 | ); |
| 608 | } |
| 609 | delete unverifiedConfig.type; |
| 610 | if (unverifiedConfig.dependencies) { |
| 611 | unverifiedConfig.dependencyTargets = unverifiedConfig.dependencies.map( |
| 612 | (dependency: string | object) => resolvableAsActionConfigTarget(dependency) |
| 613 | ); |
| 614 | delete unverifiedConfig.dependencies; |
| 615 | } |
| 616 | if (unverifiedConfig.database) { |
| 617 | unverifiedConfig.project = unverifiedConfig.database; |
| 618 | delete unverifiedConfig.database; |
| 619 | } |
| 620 | if (unverifiedConfig.schema) { |
| 621 | unverifiedConfig.dataset = unverifiedConfig.schema; |
| 622 | delete unverifiedConfig.schema; |
| 623 | } |
| 624 | if (unverifiedConfig.fileName) { |
| 625 | unverifiedConfig.filename = unverifiedConfig.fileName; |
| 626 | delete unverifiedConfig.fileName; |
| 627 | } |
| 628 | if (unverifiedConfig.columns) { |
| 629 | unverifiedConfig.columns = ColumnDescriptors.mapLegacyObjectToConfigProto( |
| 630 | unverifiedConfig.columns as any |
| 631 | ); |
| 632 | } |
| 633 | |
| 634 | unverifiedConfig = LegacyConfigConverter.insertLegacyInlineAssertionsToConfigProto( |
| 635 | unverifiedConfig |
| 636 | ); |
| 637 | unverifiedConfig = LegacyConfigConverter.insertLegacyBigQueryOptionsToConfigProto( |
| 638 | unverifiedConfig |
| 639 | ); |
| 640 | if (unverifiedConfig.bigquery) { |
| 641 | checkExcessProperties( |
| 642 | (e: Error) => { |
| 643 | throw e; |
| 644 | }, |
| 645 | unverifiedConfig.bigquery, |
| 646 | strictKeysOf<ILegacyBigQueryOptions>()([ |
| 647 | "partitionBy", |
| 648 | "clusterBy", |
| 649 | "updatePartitionFilter", |
| 650 | "labels", |
| 651 | "partitionExpirationDays", |
| 652 | "requirePartitionFilter", |
| 653 | "additionalOptions", |
no test coverage detected