@azure/data-tables 13.0.1-alpha.20211206.1 → 13.0.1-alpha.20211220.1
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/CHANGELOG.md +5 -0
- package/dist/index.js +305 -302
- package/dist/index.js.map +1 -1
- package/dist-esm/src/TableClient.js +12 -12
- package/dist-esm/src/TableClient.js.map +1 -1
- package/dist-esm/src/TablePolicies.js +2 -2
- package/dist-esm/src/TablePolicies.js.map +1 -1
- package/dist-esm/src/TableServiceClient.js +7 -7
- package/dist-esm/src/TableServiceClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js +9 -9
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/sas/accountSasSignatureValues.js +5 -5
- package/dist-esm/src/sas/accountSasSignatureValues.js.map +1 -1
- package/dist-esm/src/sas/generateAccountSas.js +1 -1
- package/dist-esm/src/sas/generateAccountSas.js.map +1 -1
- package/dist-esm/src/sas/generateTableSas.js +14 -8
- package/dist-esm/src/sas/generateTableSas.js.map +1 -1
- package/dist-esm/src/sas/sasQueryParameters.js +1 -1
- package/dist-esm/src/sas/sasQueryParameters.js.map +1 -1
- package/dist-esm/src/sas/tableSasSignatureValues.js +9 -9
- package/dist-esm/src/sas/tableSasSignatureValues.js.map +1 -1
- package/dist-esm/src/serialization.js +1 -1
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/tablesNamedCredentialPolicy.js.map +1 -1
- package/dist-esm/src/tablesSASTokenPolicy.js.map +1 -1
- package/dist-esm/src/utils/accountConnectionString.browser.js.map +1 -1
- package/dist-esm/src/utils/accountConnectionString.js.map +1 -1
- package/dist-esm/src/utils/connectionString.js.map +1 -1
- package/dist-esm/src/utils/errorHelpers.js.map +1 -1
- package/dist-esm/src/utils/internalModels.js.map +1 -1
- package/package.json +7 -9
- package/types/3.1/data-tables.d.ts +3 -2
- package/types/latest/data-tables.d.ts +3 -2
- package/types/latest/tsdoc-metadata.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablesNamedCredentialPolicy.js","sourceRoot":"","sources":["../../src/tablesNamedCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"tablesNamedCredentialPolicy.js","sourceRoot":"","sources":["../../src/tablesNamedCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,gCAAgC,CAAC;AAEnF;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,UAA8B;IAC3E,SAAS,WAAW,CAAC,OAAwB;QAC3C,MAAM,WAAW,GAAG,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAChE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,kCAAkC;QACxC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,WAAW,CAAC,OAAO,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAwB,EACxB,UAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;QACnD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,C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;IACtK,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,IAAI,EAAE;QACR,2BAA2B,GAAG,GAAG,2BAA2B,SAAS,IAAI,EAAE,CAAC;KAC7E;IAED,OAAO,2BAA2B,CAAC;AACrC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport { HeaderConstants } from \"./utils/constants\";\nimport { NamedKeyCredential } from \"@azure/core-auth\";\nimport { URL } from \"./utils/url\";\nimport { computeHMACSHA256 } from \"./utils/computeHMACSHA256\";\n\n/**\n * The programmatic identifier of the tablesNamedKeyCredentialPolicy.\n */\nexport const tablesNamedKeyCredentialPolicyName = \"tablesNamedKeyCredentialPolicy\";\n\n/**\n * tablesNamedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.\n */\nexport function tablesNamedKeyCredentialPolicy(credential: NamedKeyCredential): PipelinePolicy {\n function signRequest(request: PipelineRequest): void {\n const headerValue = getAuthorizationHeader(request, credential);\n request.headers.set(HeaderConstants.AUTHORIZATION, headerValue);\n }\n\n return {\n name: tablesNamedKeyCredentialPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n signRequest(request);\n return next(request);\n }\n };\n}\n\nexport function getAuthorizationHeader(\n request: PipelineRequest,\n credential: NamedKeyCredential\n): string {\n if (!request.headers.has(HeaderConstants.X_MS_DATE)) {\n request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());\n }\n\n if (request.body && typeof request.body === \"string\" && request.body.length > 0) {\n request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));\n }\n\n // If x-ms-date is present, use it otherwise date\n const dateHeader = getHeaderValueToSign(request, HeaderConstants.X_MS_DATE);\n\n if (!dateHeader) {\n throw new Error(\"Failed to sign request: x-ms-date or date header must be present\");\n }\n\n const stringToSign: string = [\n dateHeader,\n getCanonicalizedResourceString(request, credential)\n ].join(\"\\n\");\n\n const signature = computeHMACSHA256(stringToSign, credential.key);\n\n return `SharedKeyLite ${credential.name}:${signature}`;\n}\n\nfunction getHeaderValueToSign(request: PipelineRequest, headerName: string): string {\n const value = request.headers.get(headerName);\n\n if (!value) {\n return \"\";\n }\n return value;\n}\n\nfunction getCanonicalizedResourceString(\n request: PipelineRequest,\n credential: NamedKeyCredential\n): string {\n // https://docs.microsoft.com/rest/api/storageservices/authorize-with-shared-key#shared-key-lite-and-table-service-format-for-2009-09-19-and-later\n const url = new URL(request.url);\n const path = url.pathname || \"/\";\n let canonicalizedResourceString = \"/\" + credential.name + path;\n\n // The query string should include the question mark and the comp parameter (for example, ?comp=metadata). No other parameters should be included on the query string.\n const comp = url.searchParams.get(\"comp\");\n\n if (comp) {\n canonicalizedResourceString = `${canonicalizedResourceString}?comp=${comp}`;\n }\n\n return canonicalizedResourceString;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablesSASTokenPolicy.js","sourceRoot":"","sources":["../../src/tablesSASTokenPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"tablesSASTokenPolicy.js","sourceRoot":"","sources":["../../src/tablesSASTokenPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAyB;IAC5D,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,UAAyB;IAChF,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,SAAS,EAAE;QACrC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;KACtC;IACD,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport { URL, URLSearchParams } from \"./utils/url\";\nimport { SASCredential } from \"@azure/core-auth\";\n\n/**\n * The programmatic identifier of the tablesSASTokenPolicy.\n */\nexport const tablesSASTokenPolicyName = \"tablesSASTokenPolicy\";\n\n/**\n * tablesSASTokenPolicy is a policy used to sign HTTP request with a shared key.\n */\nexport function tablesSASTokenPolicy(credential: SASCredential): PipelinePolicy {\n return {\n name: tablesSASTokenPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n signURLWithSAS(request, credential);\n return next(request);\n }\n };\n}\n\nexport function signURLWithSAS(request: PipelineRequest, credential: SASCredential): void {\n const sasParams = new URLSearchParams(credential.signature);\n const url = new URL(request.url);\n\n for (const [name, value] of sasParams) {\n url.searchParams.append(name, value);\n }\n request.url = url.toString();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountConnectionString.browser.js","sourceRoot":"","sources":["../../../src/utils/accountConnectionString.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,+HAA+H;AAC/H,MAAM,UAAU,2BAA2B,CACzC,iBAAmC,EACnC,QAAoC;IAEpC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,YAAoB,EACpB,WAAmB,EACnB,yBAAiC,EACjC,eAAwB,EACxB,cAAuB;IAEvB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACxF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {
|
|
1
|
+
{"version":3,"file":"accountConnectionString.browser.js","sourceRoot":"","sources":["../../../src/utils/accountConnectionString.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;;;;GAKG;AACH,+HAA+H;AAC/H,MAAM,UAAU,2BAA2B,CACzC,iBAAmC,EACnC,QAAoC;IAEpC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,YAAoB,EACpB,WAAmB,EACnB,yBAAiC,EACjC,eAAwB,EACxB,cAAuB;IAEvB,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACxF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ConnectionString } from \"./internalModels\";\nimport { TableServiceClientOptions } from \"..\";\n\n/**\n * Gets client parameters from an Account Connection String\n * Only supported in Node.js not supported for Browsers\n * @param _extractedCreds - parsed connection string\n * @param _options - TablesServiceClient options\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types\nexport function fromAccountConnectionString(\n _connectionString: ConnectionString,\n _options?: TableServiceClientOptions\n) {\n throw new Error(\"Account connection string is only supported in Node.js environment\");\n}\n\nexport function getAccountConnectionString(\n _accountName: string,\n _accountKey: string,\n _defaultEndpointsProtocol: string,\n _endpointSuffix?: string,\n _tableEndpoint?: string\n): ConnectionString {\n throw new Error(\"Account connection string is only supported in Node.js environment\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountConnectionString.js","sourceRoot":"","sources":["../../../src/utils/accountConnectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"accountConnectionString.js","sourceRoot":"","sources":["../../../src/utils/accountConnectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAgC,EAChC,UAAqC,EAAE;IAEvC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,cAAc,CAAC,WAAY,EAC3B,cAAc,CAAC,UAAU,CAC1B,CAAC;IAEF,OAAO;QACL,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,OAAO;QACP,UAAU,EAAE,mBAAmB;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,WAAmB,EACnB,UAAkB,EAClB,wBAAgC,EAChC,cAAuB,EACvB,aAAsB;IAEtB,IAAI,CAAC,aAAa,EAAE;QAClB,gEAAgE;QAChE,8FAA8F;QAC9F,MAAM,QAAQ,GAAG,wBAAwB,CAAC,WAAW,EAAE,CAAC;QACxD,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,MAAM,EAAE;YAC/C,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;SACH;QACD,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;SAC7E;QACD,aAAa,GAAG,GAAG,wBAAwB,MAAM,WAAW,UAAU,cAAc,EAAE,CAAC;KACxF;IAED,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;SAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;KACzE;IAED,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,GAAG,EAAE,aAAa;QAClB,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { AzureNamedKeyCredential } from \"@azure/core-auth\";\nimport { TableServiceClientOptions } from \"..\";\n\n/**\n * Gets client parameters from an Account Connection String\n * Only supported in Node.js not supported for Browsers\n * @param extractedCreds - parsed connection string\n * @param options - TablesServiceClient options\n */\nexport function fromAccountConnectionString(\n extractedCreds: ConnectionString,\n options: TableServiceClientOptions = {}\n): ClientParamsFromConnectionString {\n const sharedKeyCredential = new AzureNamedKeyCredential(\n extractedCreds.accountName!,\n extractedCreds.accountKey\n );\n\n return {\n url: extractedCreds.url,\n options,\n credential: sharedKeyCredential\n };\n}\n\nexport function getAccountConnectionString(\n accountName: string,\n accountKey: string,\n defaultEndpointsProtocol: string,\n endpointSuffix?: string,\n tableEndpoint?: string\n): ConnectionString {\n if (!tableEndpoint) {\n // TableEndpoint is not present in the Account connection string\n // Can be obtained from `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`\n const protocol = defaultEndpointsProtocol.toLowerCase();\n if (protocol !== \"https\" && protocol !== \"http\") {\n throw new Error(\n \"Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'\"\n );\n }\n if (!endpointSuffix) {\n throw new Error(\"Invalid EndpointSuffix in the provided Connection String\");\n }\n tableEndpoint = `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n }\n\n if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided Connection String\");\n } else if (accountKey.length === 0) {\n throw new Error(\"Invalid AccountKey in the provided Connection String\");\n }\n\n return {\n kind: \"AccountConnString\",\n url: tableEndpoint,\n accountName,\n accountKey\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEpG,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/E,gBAAgB,GAAG,2BAA2B,CAAC;QAC/C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;KACxC;IACD,MAAM,cAAc,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IACtE,IAAI,cAAc,CAAC,IAAI,KAAK,mBAAmB,EAAE;QAC/C,OAAO,2BAA2B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;KAC7D;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,eAAe,EAAE;QAClD,OAAO;YACL,GAAG,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,cAAc,CAAC,UAAU,EAAE;YACzD,OAAO;SACR,CAAC;KACH;SAAM;QACL,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;KACH;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,gBAAwB;IACnE,0DAA0D;IAC1D,IAAI,aAAa,GAAG,oBAAoB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;IAC5E,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GAAW;IACxC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,GAAG,CAAC;KACZ;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,WAAW,CAAC;IAEhB,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;QACrD,0EAA0E;QAC1E,uCAAuC;QACvC,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAClC;SAAM,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;QAChC,iFAAiF;QACjF,2GAA2G;QAC3G,mCAAmC;QACnC,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TableServiceClientOptions } from \"../models\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { URL } from \"./url\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {}\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\"\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\"\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEpG,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/E,gBAAgB,GAAG,2BAA2B,CAAC;QAC/C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;KACxC;IACD,MAAM,cAAc,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IACtE,IAAI,cAAc,CAAC,IAAI,KAAK,mBAAmB,EAAE;QAC/C,OAAO,2BAA2B,CAAC,cAAc,EAAE,OAAO,CAAC,CAA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QAC3G,mCAAmC;QACnC,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\nimport { TableServiceClientOptions } from \"../models\";\nimport { URL } from \"./url\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {}\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\"\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\"\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHelpers.js","sourceRoot":"","sources":["../../../src/utils/errorHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"errorHelpers.js","sourceRoot":"","sources":["../../../src/utils/errorHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAkBr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under the MIT license.\n\nimport { OperationOptions, OperationRequest } from \"@azure/core-client\";\nimport { PipelineResponse, RestError } from \"@azure/core-rest-pipeline\";\nimport { AzureLogger } from \"@azure/logger\";\nimport { SpanStatusCode } from \"@azure/core-tracing\";\nimport { TableServiceError } from \"../generated\";\n\nexport type TableServiceErrorResponse = PipelineResponse & {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders?: Record<string, unknown>;\n /**\n * The response body as parsed JSON or XML.\n */\n parsedBody: TableServiceError;\n /**\n * The request that generated the response.\n */\n request: OperationRequest;\n};\n\nexport function handleTableAlreadyExists(\n error: unknown,\n options: OperationOptions & { tableName?: string; span?: any; logger?: AzureLogger } = {}\n): void {\n const responseError = getErrorResponse(error);\n if (\n responseError &&\n responseError.status === 409 &&\n responseError.parsedBody.odataError?.code === \"TableAlreadyExists\"\n ) {\n options.logger?.info(`Table ${options.tableName} already Exists`);\n\n if (options.onResponse) {\n options.onResponse(responseError, {});\n }\n } else {\n options?.span.setStatus({ code: SpanStatusCode.ERROR, message: (error as Error)?.message });\n throw error;\n }\n}\n\nfunction getErrorResponse(error: unknown): TableServiceErrorResponse | undefined {\n if (!isRestError(error)) {\n return undefined;\n }\n\n const errorResponse: TableServiceErrorResponse = error.response as TableServiceErrorResponse;\n\n if (!errorResponse || !isTableServiceErrorResponse(errorResponse.parsedBody)) {\n return undefined;\n }\n\n return errorResponse;\n}\n\nfunction isRestError(error: unknown): error is RestError {\n return (error as RestError).name === \"RestError\";\n}\n\nfunction isTableServiceErrorResponse(\n errorResponseBody: any\n): errorResponseBody is TableServiceError {\n return Boolean(errorResponseBody?.odataError);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalModels.js","sourceRoot":"","sources":["../../../src/utils/internalModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CreateTableEntityResponse,\n DeleteTableEntityOptions,\n GetTableEntityOptions,\n GetTableEntityResponse,\n ListTableEntitiesOptions,\n TableEntity,\n TableEntityResult,\n TableItem,\n TableServiceClientOptions,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions\n} from \"../models\";\nimport { Pipeline, PipelineRequest } from \"@azure/core-rest-pipeline\";\nimport { NamedKeyCredential } from \"@azure/core-auth\";\nimport {
|
|
1
|
+
{"version":3,"file":"internalModels.js","sourceRoot":"","sources":["../../../src/utils/internalModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n CreateTableEntityResponse,\n DeleteTableEntityOptions,\n GetTableEntityOptions,\n GetTableEntityResponse,\n ListTableEntitiesOptions,\n TableEntity,\n TableEntityResult,\n TableItem,\n TableServiceClientOptions,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions\n} from \"../models\";\nimport { DeleteTableEntityResponse, UpdateEntityResponse, UpsertEntityResponse } from \"..\";\nimport { Pipeline, PipelineRequest } from \"@azure/core-rest-pipeline\";\nimport { NamedKeyCredential } from \"@azure/core-auth\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\n\nexport interface ConnectionString {\n kind: \"AccountConnString\" | \"SASConnString\";\n url: string;\n accountName: string;\n accountKey?: any;\n accountSas?: string;\n}\n\n/**\n * Contains response data for the listTable operation.\n */\nexport type ListTableItemsResponse = Array<TableItem> & {\n /**\n * This header contains the continuation token value.\n */\n nextTableName?: string;\n};\n\n/**\n * Contains response data for the getEntity operation.\n */\nexport type ListEntitiesResponse<T extends object> = Array<TableEntityResult<T>> & {\n /**\n * Contains the continuation token value for the next page.\n */\n continuationToken?: string;\n};\n\nexport interface ClientParamsFromConnectionString {\n url: string;\n options?: TableServiceClientOptions;\n credential?: NamedKeyCredential;\n}\n\n/**\n * Transaction request builder\n */\nexport interface InnerTransactionRequest {\n /**\n * Transaction request body\n */\n body: string[];\n /**\n * Creates a pipeline to intercept sub-requests and\n * build the request body\n */\n createPipeline(): Pipeline;\n /**\n * Adds an operation to add to the transaction body\n * @param request - The operation to add\n */\n appendSubRequestToBody(request: PipelineRequest): void;\n /**\n * Gets the transaction request body\n */\n getHttpRequestBody(): string;\n}\n\nexport interface InternalTransactionClientOptions extends TableServiceClientOptions {\n innerTransactionRequest: InnerTransactionRequest;\n}\n\n/**\n * Describes the shape of a TableClient\n */\nexport interface TableClientLike {\n /**\n * Represents a pipeline for making a HTTP request to a URL.\n */\n pipeline: Pipeline;\n /**\n * Name of the table to perform operations on.\n */\n readonly tableName: string;\n /**\n * Creates the current table.\n * @param options - The options parameters.\n */\n createTable(options?: OperationOptions): Promise<void>;\n /**\n * Submits a Transaction which is composed of a set of actions.\n * @param actions - tuple that contains the action to perform, and the entity to perform the action with\n */\n submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse>;\n /**\n * Insert entity in the table.\n * @param entity - The properties for the table entity.\n * @param options - The options parameters.\n */\n createEntity<T extends object>(\n entity: TableEntity<T>,\n options?: OperationOptions\n ): Promise<CreateTableEntityResponse>;\n /**\n * Permanently deletes the current table with all of its entities.\n * @param options - The options parameters.\n */\n deleteTable(options?: OperationOptions): Promise<void>;\n /**\n * Permanently deletes the current table if it exists in the account.\n * @param options - The options parameters.\n */\n deleteEntity(\n partitionKey: string,\n rowKey: string,\n options?: DeleteTableEntityOptions\n ): Promise<DeleteTableEntityResponse>;\n /**\n * Returns a single entity in the table.\n * @param partitionKey - The partition key of the entity.\n * @param rowKey - The row key of the entity.\n * @param options - The options parameters.\n */\n getEntity<T extends object>(\n partitionKey: string,\n rowKey: string,\n options?: GetTableEntityOptions\n ): Promise<GetTableEntityResponse<T>>;\n /**\n * Queries entities in a table.\n * @param tableName - The name of the table.\n * @param options - The options parameters.\n */\n listEntities<T extends object>(\n options?: ListTableEntitiesOptions\n ): PagedAsyncIterableIterator<T, ListEntitiesResponse<T>>;\n /**\n * Update an entity in the table.\n * @param entity - The properties of the entity to be updated.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n */\n updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: UpdateTableEntityOptions\n ): Promise<UpdateEntityResponse>;\n /**\n * Upsert an entity in the table.\n * @param tableName - The name of the table.\n * @param entity - The properties for the table entity.\n * @param mode - The different modes for updating the entity:\n * - Merge: Updates an entity by updating the entity's properties without replacing the existing entity.\n * - Replace: Updates an existing entity by replacing the entire entity.\n * @param options - The options parameters.\n */\n upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: OperationOptions\n ): Promise<UpsertEntityResponse>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/data-tables",
|
|
3
|
-
"version": "13.0.1-alpha.
|
|
3
|
+
"version": "13.0.1-alpha.20211220.1",
|
|
4
4
|
"description": "An isomorphic client library for the Azure Tables service.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
|
38
38
|
"generate:client": "autorest --typescript ./swagger/README.md",
|
|
39
39
|
"integration-test:browser": "karma start --single-run",
|
|
40
|
-
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test
|
|
40
|
+
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace --exclude \"dist-esm/test/**/browser/**/*.spec.js\" \"dist-esm/test/**/*.spec.js\"",
|
|
41
41
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
|
42
42
|
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
|
43
43
|
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
|
@@ -46,9 +46,8 @@
|
|
|
46
46
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
|
47
47
|
"test": "npm run clean && npm run build:test && npm run unit-test",
|
|
48
48
|
"unit-test:browser": "karma start --single-run",
|
|
49
|
-
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test
|
|
50
|
-
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
51
|
-
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
|
|
49
|
+
"unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/**/*.spec.ts\" \"test/**/*.spec.ts\"",
|
|
50
|
+
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
|
52
51
|
},
|
|
53
52
|
"files": [
|
|
54
53
|
"dist/",
|
|
@@ -118,9 +117,9 @@
|
|
|
118
117
|
"karma-mocha-reporter": "^2.2.5",
|
|
119
118
|
"karma-sourcemap-loader": "^0.3.8",
|
|
120
119
|
"mocha": "^7.1.1",
|
|
121
|
-
"mocha-junit-reporter": "^
|
|
120
|
+
"mocha-junit-reporter": "^2.0.0",
|
|
122
121
|
"prettier": "^1.16.4",
|
|
123
|
-
"nyc": "^
|
|
122
|
+
"nyc": "^15.0.0",
|
|
124
123
|
"rimraf": "^3.0.0",
|
|
125
124
|
"rollup": "^1.16.3",
|
|
126
125
|
"rollup-plugin-sourcemaps": "^0.4.2",
|
|
@@ -134,8 +133,7 @@
|
|
|
134
133
|
"@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
|
|
135
134
|
"rollup-plugin-shim": "^1.0.0",
|
|
136
135
|
"@rollup/plugin-inject": "^4.0.0",
|
|
137
|
-
"ts-node": "^10.0.0"
|
|
138
|
-
"typedoc": "0.15.2"
|
|
136
|
+
"ts-node": "^10.0.0"
|
|
139
137
|
},
|
|
140
138
|
"//sampleConfiguration": {
|
|
141
139
|
"productName": "Azure Data Tables",
|
|
@@ -994,11 +994,12 @@ export declare interface TableSasSignatureValues {
|
|
|
994
994
|
*/
|
|
995
995
|
startsOn?: Date;
|
|
996
996
|
/**
|
|
997
|
-
* Optional
|
|
997
|
+
* Optional. If identifier is not provided has a default value of one hour from the time the token is generated.
|
|
998
|
+
* The time after which the SAS will no longer work.
|
|
998
999
|
*/
|
|
999
1000
|
expiresOn?: Date;
|
|
1000
1001
|
/**
|
|
1001
|
-
* Optional
|
|
1002
|
+
* Optional. If identifier is not provided has a default value of "read"
|
|
1002
1003
|
* Please refer to {@link TableSasPermissions} depending on the resource
|
|
1003
1004
|
* being accessed for help constructing the permissions string.
|
|
1004
1005
|
*/
|
|
@@ -1051,11 +1051,12 @@ export declare interface TableSasSignatureValues {
|
|
|
1051
1051
|
*/
|
|
1052
1052
|
startsOn?: Date;
|
|
1053
1053
|
/**
|
|
1054
|
-
* Optional
|
|
1054
|
+
* Optional. If identifier is not provided has a default value of one hour from the time the token is generated.
|
|
1055
|
+
* The time after which the SAS will no longer work.
|
|
1055
1056
|
*/
|
|
1056
1057
|
expiresOn?: Date;
|
|
1057
1058
|
/**
|
|
1058
|
-
* Optional
|
|
1059
|
+
* Optional. If identifier is not provided has a default value of "read"
|
|
1059
1060
|
* Please refer to {@link TableSasPermissions} depending on the resource
|
|
1060
1061
|
* being accessed for help constructing the permissions string.
|
|
1061
1062
|
*/
|