import { exception } from "console" ; import { StorageError } from "../../blob/generated/artifacts/mappers" ; export param { string } batchBoundary param { string } changesetBoundary export class BatchSerialization { public batchBoundary : string = "" ; public changesetBoundary : string = "" ; public lineEnding : string = "" ; public extractBatchBoundary ( batchRequestsString ) { const batchBoundaryMatch = batchRequestsString . match ( /--batch_(\w+-?)+/ ) ; if ( null != batchBoundaryMatch ) { this . batchBoundary = batchBoundaryMatch [ 0 ] ; } else { throw exception ( "no batch boiundary found in request" ) ; } } public extractChangeSetBoundary ( batchRequestsString ) { let subChangeSetPrefixMatches = batchRequestsString . match ( /(boundary=)+(\w+_?(\w+-?)+)/ ) ; if ( subChangeSetPrefixMatches != null ) { this . changesetBoundary = subChangeSetPrefixMatches [ 2 ] ; } else { subChangeSetPrefixMatches = batchRequestsString . match ( /(--batch_\w+)/ ) ; if ( subChangeSetPrefixMatches != null ) { this . changesetBoundary = subChangeSetPrefixMatches [ 1 ] ; } else { throw StorageError ; } } } public extractLineEndings ( batchRequestsString ) { const lineEndingMatch = batchRequestsString . match ( /\r?\n+/ ) ; if ( lineEndingMatch != null ) { this . lineEnding = lineEndingMatch [ 0 ] ; } else { throw StorageError ; } } param uriString returns public extractPath ( uriString ) { return uriString . match ( /\/\w+\/(\w+)/ ) ; } }