Skip to content

Commit

Permalink
#27: fix microsoftsharepointonline object schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Srebniak committed Nov 8, 2023
1 parent 74de4cd commit 85ef77e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 17 deletions.
38 changes: 31 additions & 7 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 20 additions & 5 deletions src/microsoftsharepointonline/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ export interface MicrosoftSharepointOnlineObject {
* An array of Microsoft Sharepoint Online site drives from which the documents are to be retrieved.
*
* Note: each drive requires full name starting with 'drives/'
* @deprecated. This property is deprecated and will be removed in a future release. Use {@link entities} instead
*/
readonly drives: string[];
readonly drives?: string[];

/**
* An array of Microsoft Sharepoint Online site entities from which the documents are to be retrieved.
*
* Note: each entity requires full name starting with 'drives/' followed by driveID and optional '/items/' followed by itemID
* @example: 'drives/${driveID}'
* @example: 'drives/${driveID}/items/${itemID}'
*/
readonly entities?: string[];
}

/**
Expand Down Expand Up @@ -65,15 +75,20 @@ export class MicrosoftSharepointOnlineSource implements ISource {

private buildSourceConnectorProperties(): CfnFlow.SourceConnectorPropertiesProperty {

if (this.props.object.drives.length < 1) {
throw new Error('At least one drive must be specified');
if (this.props.object.entities && this.props.object.drives) {
throw new Error('Only one of the properties entities or drives should be specified');
}

const entities = this.props.object.entities ?? this.props.object.drives ?? [];
if (entities.length < 1) {
throw new Error('At least one entity must be specified');
}

return {
customConnector: {
entityName: this.props.object.site,
customProperties: {
subEntities: `["${Fn.join('","', this.props.object.drives)}"]`,
subEntities: `["${Fn.join('","', entities)}"]`,
},
},
};
Expand All @@ -84,4 +99,4 @@ export class MicrosoftSharepointOnlineSource implements ISource {
scope.node.addDependency(resource);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const source = new MicrosoftSharepointOnlineSource({
apiVersion: MicrosoftSharepointOnlineApiVersion.V1,
object: {
site: secret.secretValueFromJson('site').toString(),
drives: [secret.secretValueFromJson('drive').toString()],
entities: [secret.secretValueFromJson('drive').toString()],
},
});

Expand Down
8 changes: 4 additions & 4 deletions test/microsoftsharepointonline/source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('MicrosoftSharepointOnlineSource', () => {
profile: MicrosoftSharepointOnlineConnectorProfile.fromConnectionProfileName(stack, 'TestProfile', 'dummy-profile'),
object: {
site: 'sites/dummysite.sharepoint.com,3f42g340-bc23-4a31-b7e5-722e57c39cb8,5bbc39fb-2b17-423b-a007-40ca508389a5',
drives: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
entities: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
},
apiVersion: MicrosoftSharepointOnlineApiVersion.V1,
});
Expand All @@ -42,7 +42,7 @@ describe('MicrosoftSharepointOnlineSource', () => {
profile: MicrosoftSharepointOnlineConnectorProfile.fromConnectionProfileName(stack, 'TestProfile', 'dummy-profile'),
object: {
site: 'sites/dummysite.sharepoint.com,3f42g340-bc23-4a31-b7e5-722e57c39cb8,5bbc39fb-2b17-423b-a007-40ca508389a5',
drives: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
entities: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
},
apiVersion: MicrosoftSharepointOnlineApiVersion.V1,
});
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('MicrosoftSharepointOnlineSource', () => {
profile: profile,
object: {
site: 'sites/dummysite.sharepoint.com,3f42g340-bc23-4a31-b7e5-722e57c39cb8,5bbc39fb-2b17-423b-a007-40ca508389a5',
drives: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
entities: ['drives/b!fcPDltwTLSougEJuDFjE?U5qHuXbkzlvSaA5oNoMW4tB0y6mebcx9m-ckwA9KtKE'],
},
apiVersion: MicrosoftSharepointOnlineApiVersion.V1,
});
Expand Down Expand Up @@ -227,4 +227,4 @@ describe('MicrosoftSharepointOnlineSource', () => {
],
});
});
});
});

0 comments on commit 85ef77e

Please sign in to comment.