Skip to content

Commit

Permalink
Added header to trace get mapi requests (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrik authored Feb 11, 2021
1 parent 9a4c915 commit 33316fb
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 153 deletions.
162 changes: 74 additions & 88 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"postinstall": "npm rebuild node-sass"
},
"devDependencies": {
"@azure/storage-blob": "12.2.1",
"@azure/storage-blob": "12.4.1",
"@types/chai": "^4.2.14",
"@types/google-maps": "^3.2.2",
"@types/knockout": "^3.4.69",
Expand Down
8 changes: 1 addition & 7 deletions src/components/filesystemBlobStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ export class FileSystemBlobStorage implements IBlobStorage {
return;
}

const arrayBuffer = new ArrayBuffer(buffer.length);
const unit8Array = new Uint8Array(arrayBuffer);

for (let i = 0; i < buffer.length; ++i) {
unit8Array[i] = buffer[i];
}

const unit8Array = new Uint8Array(buffer.buffer);
resolve(unit8Array);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/persistence/mapiBlobStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class MapiBlobStorage implements IBlobStorage {
});
}
else {
const result = await this.mapiClient.post<any>(`/portalSettings/mediaContent/listSecrets`);
const result = await this.mapiClient.post<any>(`/portalSettings/mediaContent/listSecrets`, [MapiClient.getPortalHeader("getStorageSasUrl")]);
const blobStorageUrl = result.containerSasUrl;

storageSettingsProvider = new StaticSettingsProvider({
Expand Down
6 changes: 3 additions & 3 deletions src/persistence/mapiObjectStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class MapiObjectStorage implements IObjectStorage {
const resource = this.paperbitsKeyToArmResource(key);
const contentType = this.getContentTypeFromResource(resource);
const isLocalized = localizedContentTypes.includes(contentType);
const item = await this.mapiClient.get<T>(`${resource}`);
const item = await this.mapiClient.get<T>(`${resource}`, [MapiClient.getPortalHeader("getObject")]);
const converted = this.convertArmContractToPaperbitsContract(item, isLocalized);

if (key.startsWith("blocks/")) {
Expand Down Expand Up @@ -341,7 +341,7 @@ export class MapiObjectStorage implements IObjectStorage {

private async loadNextPage<T>(resource: string, localeSearchPrefix: string, filterQueryString: string, orderQueryString: string, skip: number, isLocalized: boolean): Promise<Page<T>> {
const url = `${resource}?$skip=${skip}&$top=${defaultPageSize}${filterQueryString}${orderQueryString}`;
const pageOfTs = await this.mapiClient.get<PageContract<T>>(url);
const pageOfTs = await this.mapiClient.get<PageContract<T>>(url, [MapiClient.getPortalHeader("getPageData")]);
const searchResult = [];

for (const item of pageOfTs.value) {
Expand Down Expand Up @@ -413,7 +413,7 @@ export class MapiObjectStorage implements IObjectStorage {
}

if (key.includes("navigationItems")) {
const armContract = await this.mapiClient.get<any>(`${resource}?$orderby=${localeSearchPrefix}title${filterQueryString}`);
const armContract = await this.mapiClient.get<any>(`${resource}?$orderby=${localeSearchPrefix}title${filterQueryString}`, [MapiClient.getPortalHeader("searchObjects")]);
const paperbitsContract = this.convertArmContractToPaperbitsContract(armContract, isLocalized);
return paperbitsContract.nodes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/routing/signOutRouteGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class SignOutRouteGuard implements RouteGuard {

if (token) {
try {
const identity = await this.mapiClient.get<Identity>("/identity");
const identity = await this.mapiClient.get<Identity>("/identity", [MapiClient.getPortalHeader("delegationSignOut")]);

if (identity) {
const redirectUrl = await this.backendService.getDelegationUrl(DelegationAction.signOut, { userId: identity.id });
Expand Down
Loading

0 comments on commit 33316fb

Please sign in to comment.