@azure/data-tables 13.0.0-alpha.20211109.2 → 13.0.1-alpha.20211112.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.
@@ -24,7 +24,7 @@ export class GeneratedClientContext extends coreClient.ServiceClient {
24
24
  const defaults = {
25
25
  requestContentType: "application/json; charset=utf-8"
26
26
  };
27
- const packageDetails = `azsdk-js-data-tables/13.0.0`;
27
+ const packageDetails = `azsdk-js-data-tables/13.0.1`;
28
28
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
29
29
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
30
30
  : `${packageDetails}`;
@@ -1 +1 @@
1
- {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;OAIG;IACH,YAAY,GAAW,EAAE,OAAuC;QAC9D,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,6BAA6B,CAAC;QACrD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,GACrC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,0CAA0C;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC;IACjD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n url: string;\n version: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param url The URL of the service account or table that is the target of the desired operation.\n * @param options The parameter options\n */\n constructor(url: string, options?: GeneratedClientOptionalParams) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-data-tables/13.0.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n\n // Assigning values to Constant parameters\n this.version = options.version || \"2019-02-02\";\n }\n}\n"]}
1
+ {"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAGjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAIlE;;;;OAIG;IACH,YAAY,GAAW,EAAE,OAAuC;QAC9D,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QACD,MAAM,QAAQ,GAAkC;YAC9C,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,6BAA6B,CAAC;QACrD,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,iDACpB,QAAQ,GACR,OAAO,KACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB,EACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,GACrC,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,0CAA0C;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC;IACjD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport * as coreClient from \"@azure/core-client\";\nimport { GeneratedClientOptionalParams } from \"./models\";\n\n/** @internal */\nexport class GeneratedClientContext extends coreClient.ServiceClient {\n url: string;\n version: string;\n\n /**\n * Initializes a new instance of the GeneratedClientContext class.\n * @param url The URL of the service account or table that is the target of the desired operation.\n * @param options The parameter options\n */\n constructor(url: string, options?: GeneratedClientOptionalParams) {\n if (url === undefined) {\n throw new Error(\"'url' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: GeneratedClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-data-tables/13.0.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint || \"{url}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.url = url;\n\n // Assigning values to Constant parameters\n this.version = options.version || \"2019-02-02\";\n }\n}\n"]}
@@ -8,4 +8,5 @@ export { TableTransaction } from "./TableTransaction";
8
8
  export { TableClient } from "./TableClient";
9
9
  export { odata } from "./odata";
10
10
  export { AzureNamedKeyCredential, AzureSASCredential } from "@azure/core-auth";
11
+ export { RestError } from "@azure/core-rest-pipeline";
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./generatedModels\";\nexport * from \"./models\";\nexport * from \"./sas\";\n\nexport { TableServiceClient } from \"./TableServiceClient\";\nexport { TableTransaction } from \"./TableTransaction\";\nexport { TableClient } from \"./TableClient\";\nexport { odata } from \"./odata\";\nexport { AzureNamedKeyCredential, AzureSASCredential } from \"@azure/core-auth\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./generatedModels\";\nexport * from \"./models\";\nexport * from \"./sas\";\n\nexport { TableServiceClient } from \"./TableServiceClient\";\nexport { TableTransaction } from \"./TableTransaction\";\nexport { TableClient } from \"./TableClient\";\nexport { odata } from \"./odata\";\nexport { AzureNamedKeyCredential, AzureSASCredential } from \"@azure/core-auth\";\nexport { RestError } from \"@azure/core-rest-pipeline\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TableGetAccessPolicyHeaders, TableInsertEntityHeaders } from \"./generated/models\";\nimport { OperationOptions, CommonClientOptions } from \"@azure/core-client\";\n\n/**\n * Represents the Create or Delete Entity operation to be included in a Transaction request\n */\nexport type CreateDeleteEntityAction = [\"create\" | \"delete\", TableEntity];\n\n/**\n * Represents the Update or Upsert Entity operation to be included in a Transaction request\n */\nexport type UpdateEntityAction =\n | [\"update\" | \"upsert\", TableEntity]\n | [\"update\" | \"upsert\", TableEntity, \"Merge\" | \"Replace\"];\n\n/**\n * Represents the union of all the available transactional actions\n */\nexport type TransactionAction = CreateDeleteEntityAction | UpdateEntityAction;\n\n/**\n * Client options used to configure Tables Api requests\n */\nexport type TableServiceClientOptions = CommonClientOptions & {\n endpoint?: string;\n version?: string;\n};\n\n/**\n * Contains response data for the createEntity operation.\n */\nexport type CreateTableEntityResponse = TableInsertEntityHeaders;\n\n/**\n * Contains response data for the listEntities operation.\n */\nexport type GetTableEntityResponse<T extends object> = TableEntityResult<T>;\n\n/**\n * Optional parameters for DeleteTableEntity operation\n */\nexport type DeleteTableEntityOptions = OperationOptions & {\n /**\n * UTC date/time value generated by the service that indicates the time at which the response was initiated\n */\n etag?: string;\n};\n\n/** The properties for the table item. */\nexport interface TableItem {\n /** The name of the table. */\n name?: string;\n}\n\n/**\n * OData Query options to limit the set of tables returned.\n */\nexport interface TableQueryOptions {\n /**\n * OData filter expression.\n */\n filter?: string;\n}\n\n/**\n * OData Query options to limit the set of entities returned.\n */\nexport interface TableEntityQueryOptions {\n /**\n * OData filter expression.\n */\n filter?: string;\n /**\n * A select expression limits the properties on each entity to just those requested.\n */\n select?: string[];\n}\n\n/**\n * List tables optional parameters.\n */\nexport type ListTableItemsOptions = OperationOptions & {\n /**\n * Query options group\n */\n queryOptions?: TableQueryOptions;\n};\n\n/**\n * Output type for query operations\n */\nexport type TableEntityResult<T> = T & {\n /**\n * etag property. Always returned by the service\n */\n etag: string;\n /**\n * Partition key property. Omitted if a select filter is set and this property is not requested\n */\n partitionKey?: string;\n /**\n * Row key property. Omitted if a select filter is set and this property is not requested\n */\n rowKey?: string;\n /**\n * Timestamp property. This property is assinged by the service on entity creation\n * Omitted if a select filter is set and this property is not requested\n */\n timestamp?: string;\n};\n\n/**\n * Output page type for query operations\n */\nexport type TableEntityResultPage<T> = Array<TableEntityResult<T>> & {\n /**\n * Continuation token to get the next page\n */\n continuationToken?: string;\n};\n\n/**\n * List entities optional parameters.\n */\nexport type ListTableEntitiesOptions = OperationOptions & {\n /**\n * Query options group\n */\n queryOptions?: TableEntityQueryOptions;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n};\n\n/**\n * GetEntity optional parameters.\n */\nexport type GetTableEntityOptions = OperationOptions & {\n /**\n * Parameter group\n */\n queryOptions?: TableEntityQueryOptions;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n};\n\n/**\n * Update entity optional parameters.\n */\nexport type UpdateTableEntityOptions = OperationOptions & {\n /**\n * Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a replace will be performed if an existing entity is found.\n */\n etag?: string;\n};\n\n/**\n * A set of key-value pairs representing the table entity.\n */\nexport type TableEntity<T extends object = Record<string, unknown>> = T & {\n /**\n * The PartitionKey property of the entity.\n */\n partitionKey: string;\n /**\n * The RowKey property of the entity.\n */\n rowKey: string;\n};\n\n/**\n * Supported EDM Types by Azure Tables.\n */\nexport type EdmTypes =\n | \"Binary\"\n | \"Boolean\"\n | \"DateTime\"\n | \"Double\"\n | \"Guid\"\n | \"Int32\"\n | \"Int64\"\n | \"String\";\n\n/**\n * Entity Data Model representation for an entity property.\n */\nexport interface Edm<T extends EdmTypes> {\n /**\n * The value of the entity property\n */\n value: T extends \"Binary\"\n ? Uint8Array\n : T extends \"Boolean\"\n ? boolean\n : T extends \"Double\"\n ? number\n : T extends \"Int32\"\n ? number\n : string;\n /**\n * The type of the entity property\n */\n type: T;\n}\n\n/**\n * The different modes for Update and Upsert methods\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 */\nexport type UpdateMode = \"Merge\" | \"Replace\";\n\n/**\n * Represents the response of a Transaction operation\n */\nexport interface TableTransactionResponse {\n /**\n * Collection of sub responses\n */\n subResponses: TableTransactionEntityResponse[];\n /**\n * Main Transaction request status code\n */\n status: number;\n /**\n * Gets a specific response given a row key\n */\n getResponseForEntity: (rowKey: string) => TableTransactionEntityResponse | undefined;\n}\n\n/** The properties for the table query response. */\nexport interface TableQueryResponse {\n /** List of tables. */\n value?: TableItem[];\n}\n\n/**\n * Output page type for table query operations\n */\nexport interface TableItemResultPage extends Array<TableItem> {\n /**\n * Continuation token to get the next TableItem page\n */\n continuationToken?: string;\n}\n\n/**\n * Represents a sub-response of a Transaction operation\n */\nexport interface TableTransactionEntityResponse {\n /**\n * Entity's etag\n */\n etag?: string;\n /**\n * Entity's rowKey\n */\n rowKey?: string;\n /**\n * Sub-response status\n */\n status: number;\n}\n\n/** A signed identifier. */\nexport interface SignedIdentifier {\n /** A unique id. */\n id: string;\n /** The access policy. */\n accessPolicy?: AccessPolicy;\n}\n\n/** An Access policy. */\nexport interface AccessPolicy {\n /** The start datetime from which the policy is active. */\n start?: Date;\n /** The datetime that the policy expires. */\n expiry?: Date;\n /** The permissions for the acl policy. */\n permission?: string;\n}\n\n/** Contains response data for the getAccessPolicy operation. */\nexport type GetAccessPolicyResponse = TableGetAccessPolicyHeaders & SignedIdentifier[];\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TableGetAccessPolicyHeaders, TableInsertEntityHeaders } from \"./generated/models\";\nimport { OperationOptions, CommonClientOptions } from \"@azure/core-client\";\n\n/**\n * Represents the Create or Delete Entity operation to be included in a Transaction request\n */\nexport type CreateDeleteEntityAction = [\"create\" | \"delete\", TableEntity];\n\n/**\n * Represents the Update or Upsert Entity operation to be included in a Transaction request\n */\nexport type UpdateEntityAction =\n | [\"update\" | \"upsert\", TableEntity]\n | [\"update\" | \"upsert\", TableEntity, \"Merge\" | \"Replace\"];\n\n/**\n * Represents the union of all the available transactional actions\n */\nexport type TransactionAction = CreateDeleteEntityAction | UpdateEntityAction;\n\n/**\n * Client options used to configure Tables Api requests\n */\nexport type TableServiceClientOptions = CommonClientOptions & {\n endpoint?: string;\n version?: string;\n};\n\n/**\n * Contains response data for the createEntity operation.\n */\nexport type CreateTableEntityResponse = TableInsertEntityHeaders;\n\n/**\n * Contains response data for the listEntities operation.\n */\nexport type GetTableEntityResponse<T extends object> = TableEntityResult<T>;\n\n/**\n * Optional parameters for DeleteTableEntity operation\n */\nexport type DeleteTableEntityOptions = OperationOptions & {\n /**\n * UTC date/time value generated by the service that indicates the time at which the response was initiated\n */\n etag?: string;\n};\n\n/** The properties for the table item. */\nexport interface TableItem {\n /** The name of the table. */\n name?: string;\n}\n\n/**\n * OData Query options to limit the set of tables returned.\n */\nexport interface TableQueryOptions {\n /**\n * OData filter expression.\n */\n filter?: string;\n}\n\n/**\n * OData Query options to limit the set of entities returned.\n */\nexport interface TableEntityQueryOptions {\n /**\n * OData filter expression.\n */\n filter?: string;\n /**\n * A select expression limits the properties on each entity to just those requested.\n */\n select?: string[];\n}\n\n/**\n * List tables optional parameters.\n */\nexport type ListTableItemsOptions = OperationOptions & {\n /**\n * Query options group\n */\n queryOptions?: TableQueryOptions;\n};\n\n/**\n * Output type for query operations\n */\nexport type TableEntityResult<T> = T & {\n /**\n * etag property. Always returned by the service\n */\n etag: string;\n /**\n * Partition key property. Omitted if a select filter is set and this property is not requested\n */\n partitionKey?: string;\n /**\n * Row key property. Omitted if a select filter is set and this property is not requested\n */\n rowKey?: string;\n /**\n * Timestamp property. This property is assinged by the service on entity creation\n * Omitted if a select filter is set and this property is not requested\n */\n timestamp?: string;\n};\n\n/**\n * Output page type for query operations\n */\nexport type TableEntityResultPage<T> = Array<TableEntityResult<T>> & {\n /**\n * Continuation token to get the next page\n */\n continuationToken?: string;\n};\n\n/**\n * List entities optional parameters.\n */\nexport type ListTableEntitiesOptions = OperationOptions & {\n /**\n * Query options group\n */\n queryOptions?: TableEntityQueryOptions;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n};\n\n/**\n * GetEntity optional parameters.\n */\nexport type GetTableEntityOptions = OperationOptions & {\n /**\n * Parameter group\n */\n queryOptions?: TableEntityQueryOptions;\n /**\n * If true, automatic type conversion will be disabled and entity properties will\n * be represented by full metadata types. For example, an Int32 value will be \\{value: \"123\", type: \"Int32\"\\} instead of 123.\n * This option applies for all the properties\n */\n disableTypeConversion?: boolean;\n};\n\n/**\n * Update entity optional parameters.\n */\nexport type UpdateTableEntityOptions = OperationOptions & {\n /**\n * Match condition for an entity to be updated. If specified and a matching entity is not found, an error will be raised. To force an unconditional update, set to the wildcard character (*). If not specified, an insert will be performed when no existing entity is found to update and a replace will be performed if an existing entity is found.\n */\n etag?: string;\n};\n\n/**\n * A set of key-value pairs representing the table entity.\n */\nexport type TableEntity<T extends object = Record<string, unknown>> = T & {\n /**\n * The PartitionKey property of the entity.\n */\n partitionKey: string;\n /**\n * The RowKey property of the entity.\n */\n rowKey: string;\n};\n\n/**\n * Supported EDM Types by Azure Tables.\n */\nexport type EdmTypes =\n | \"Binary\"\n | \"Boolean\"\n | \"DateTime\"\n | \"Double\"\n | \"Guid\"\n | \"Int32\"\n | \"Int64\"\n | \"String\";\n\n/**\n * Entity Data Model representation for an entity property.\n */\nexport interface Edm<T extends EdmTypes> {\n /**\n * The value of the entity property\n */\n value: T extends \"Binary\"\n ? string\n : T extends \"Boolean\"\n ? boolean\n : T extends \"Double\"\n ? number\n : T extends \"Int32\"\n ? number\n : string;\n /**\n * The type of the entity property\n */\n type: T;\n}\n\n/**\n * The different modes for Update and Upsert methods\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 */\nexport type UpdateMode = \"Merge\" | \"Replace\";\n\n/**\n * Represents the response of a Transaction operation\n */\nexport interface TableTransactionResponse {\n /**\n * Collection of sub responses\n */\n subResponses: TableTransactionEntityResponse[];\n /**\n * Main Transaction request status code\n */\n status: number;\n /**\n * Gets a specific response given a row key\n */\n getResponseForEntity: (rowKey: string) => TableTransactionEntityResponse | undefined;\n}\n\n/** The properties for the table query response. */\nexport interface TableQueryResponse {\n /** List of tables. */\n value?: TableItem[];\n}\n\n/**\n * Output page type for table query operations\n */\nexport interface TableItemResultPage extends Array<TableItem> {\n /**\n * Continuation token to get the next TableItem page\n */\n continuationToken?: string;\n}\n\n/**\n * Represents a sub-response of a Transaction operation\n */\nexport interface TableTransactionEntityResponse {\n /**\n * Entity's etag\n */\n etag?: string;\n /**\n * Entity's rowKey\n */\n rowKey?: string;\n /**\n * Sub-response status\n */\n status: number;\n}\n\n/** A signed identifier. */\nexport interface SignedIdentifier {\n /** A unique id. */\n id: string;\n /** The access policy. */\n accessPolicy?: AccessPolicy;\n}\n\n/** An Access policy. */\nexport interface AccessPolicy {\n /** The start datetime from which the policy is active. */\n start?: Date;\n /** The datetime that the policy expires. */\n expiry?: Date;\n /** The permissions for the acl policy. */\n permission?: string;\n}\n\n/** Contains response data for the getAccessPolicy operation. */\nexport type GetAccessPolicyResponse = TableGetAccessPolicyHeaders & SignedIdentifier[];\n"]}
@@ -53,14 +53,11 @@ function serializeObject(obj) {
53
53
  obj.type === "Guid" ||
54
54
  obj.type === "Int32" ||
55
55
  obj.type === "Int64" ||
56
- obj.type === "String") {
56
+ obj.type === "String" ||
57
+ obj.type === "Binary") {
57
58
  serializedValue.value = obj.value;
58
59
  serializedValue.type = Edm[obj.type];
59
60
  }
60
- else if (obj.type === "Binary") {
61
- serializedValue.value = base64Encode(obj.value);
62
- serializedValue.type = Edm.Binary;
63
- }
64
61
  else {
65
62
  throw new Error(`Unknown EDM type ${typeof obj.value}`);
66
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAMnE,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAiB;IACnE,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,YAAY,EAAE,MAAM,CAAC;IACtB,CAAC,WAAW,EAAE,WAAW,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,GAAG,GAAG;IACV,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;CACZ,CAAC;AASX,SAAS,kBAAkB,CAAC,KAAU;IACpC,MAAM,eAAe,GAAmB,EAAE,KAAK,EAAE,CAAC;IAClD,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ,EACzB;QACA,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;KAC/B;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,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjD,IAAI,MAAM,EAAE;QACV,WAAW,CAAC,MAAM,GAAG,MAAM;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aAC7C,GAAG,CAAC,qCAAqC,CAAC;aAC1C,IAAI,CAAC,GAAG,CAAC,CAAC;KACd;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { base64Encode, base64Decode } from \"./utils/bufferSerializer\";\nimport { EdmTypes, SignedIdentifier, TableEntityQueryOptions } from \"./models\";\nimport { truncatedISO8061Date } from \"./utils/truncateISO8061Date\";\nimport {\n SignedIdentifier as GeneratedSignedIdentifier,\n QueryOptions as GeneratedQueryOptions\n} from \"./generated/models\";\n\nconst propertyCaseMap: Map<string, string> = new Map<string, string>([\n [\"PartitionKey\", \"partitionKey\"],\n [\"RowKey\", \"rowKey\"],\n [\"odata.etag\", \"etag\"],\n [\"Timestamp\", \"timestamp\"]\n]);\n\nconst Edm = {\n Binary: \"Edm.Binary\",\n Boolean: \"Edm.Boolean\",\n DateTime: \"Edm.DateTime\",\n Double: \"Edm.Double\",\n Guid: \"Edm.Guid\",\n Int32: \"Edm.Int32\",\n Int64: \"Edm.Int64\",\n String: \"Edm.String\"\n} as const;\n\ntype supportedTypes = boolean | string | number | Date | Uint8Array | bigint;\n\ntype serializedType = {\n value: supportedTypes;\n type?: string;\n};\n\nfunction serializePrimitive(value: any): serializedType {\n const serializedValue: serializedType = { value };\n if (\n value === undefined ||\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"string\" ||\n typeof value === \"number\"\n ) {\n serializedValue.value = value;\n } else if (typeof value === \"bigint\") {\n serializedValue.value = value.toString();\n serializedValue.type = Edm.Int64;\n } else if (value instanceof Date) {\n serializedValue.value = value;\n serializedValue.type = Edm.DateTime;\n } else if (value instanceof Uint8Array) {\n serializedValue.value = base64Encode(value);\n serializedValue.type = Edm.Binary;\n } else {\n throw new Error(`Unknown EDM type ${typeof value}`);\n }\n\n return serializedValue;\n}\n\nfunction serializeObject(obj: { value: any; type: EdmTypes }): serializedType {\n const serializedValue: serializedType = { value: obj.value };\n if (\n obj.type === \"Boolean\" ||\n obj.type === \"DateTime\" ||\n obj.type === \"Double\" ||\n obj.type === \"Guid\" ||\n obj.type === \"Int32\" ||\n obj.type === \"Int64\" ||\n obj.type === \"String\"\n ) {\n serializedValue.value = obj.value;\n serializedValue.type = Edm[obj.type];\n } else if (obj.type === \"Binary\") {\n serializedValue.value = base64Encode(obj.value);\n serializedValue.type = Edm.Binary;\n } else {\n throw new Error(`Unknown EDM type ${typeof obj.value}`);\n }\n\n return serializedValue;\n}\n\nfunction getSerializedValue(value: any): serializedType {\n if (typeof value === \"object\" && value?.value !== undefined && value?.type !== undefined) {\n return serializeObject(value);\n } else {\n return serializePrimitive(value);\n }\n}\n\nfunction translatePropertyNameForSerialization(propertyName: string): string {\n for (const [original, internal] of propertyCaseMap) {\n if (internal === propertyName) {\n return original;\n }\n }\n\n return propertyName;\n}\n\nexport function serialize(obj: object): Record<string, Record<string, unknown>> {\n const serialized: any = {};\n for (const [propertyName, propertyValue] of Object.entries(obj)) {\n const transformedKey = translatePropertyNameForSerialization(propertyName);\n const serializedVal = getSerializedValue(propertyValue);\n serialized[transformedKey] = serializedVal.value;\n if (serializedVal.type) {\n serialized[`${transformedKey}@odata.type`] = serializedVal.type;\n }\n }\n return serialized;\n}\n\nfunction getTypedObject(value: any, type: string, disableTypeConversion: boolean): any {\n switch (type) {\n case Edm.Boolean:\n return disableTypeConversion ? { value, type: \"Boolean\" } : value;\n case Edm.Double:\n return disableTypeConversion ? { value, type: \"Double\" } : value;\n case Edm.Int32:\n return disableTypeConversion ? { value, type: \"Int32\" } : value;\n case Edm.String:\n return disableTypeConversion ? { value, type: \"String\" } : value;\n case Edm.DateTime:\n return disableTypeConversion ? { value, type: \"DateTime\" } : new Date(value);\n case Edm.Int64:\n return disableTypeConversion ? { value, type: \"Int64\" } : BigInt(value);\n case Edm.Guid:\n return { value, type: \"Guid\" };\n case Edm.Binary:\n return disableTypeConversion ? { value, type: \"Binary\" } : base64Decode(value);\n default:\n throw new Error(`Unknown EDM type ${type}`);\n }\n}\n\nexport function deserialize<T extends object = Record<string, any>>(\n obj: object,\n disableTypeConversion: boolean = false\n): T {\n const deserialized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key.indexOf(\"@odata.type\") === -1) {\n const transformedKey = propertyCaseMap.get(key) ?? key;\n let typedValue = value;\n if (`${key}@odata.type` in obj) {\n const type = (obj as any)[`${key}@odata.type`];\n typedValue = getTypedObject(value, type, disableTypeConversion);\n } else if (disableTypeConversion && [\"number\", \"string\", \"boolean\"].includes(typeof value)) {\n // The service, doesn't return type metadata for number, strings or booleans\n // if automatic type conversion is disabled we'll infer the EDM object\n typedValue = inferTypedObject(key, value);\n }\n\n deserialized[transformedKey] = typedValue;\n }\n }\n return deserialized;\n}\n\nfunction inferTypedObject(propertyName: string, value: number | string | boolean) {\n // We need to skip service metadata fields such as partitionKey and rowKey and use the same value returned by the service\n if (propertyCaseMap.has(propertyName)) {\n return value;\n }\n\n switch (typeof value) {\n case \"boolean\":\n return { value: String(value), type: \"Boolean\" };\n case \"number\":\n return getTypedNumber(value);\n case \"string\":\n return { value, type: \"String\" };\n default:\n return value;\n }\n}\n\n/**\n * Returns the number when typeConversion is enabled or the EDM object with the correct number format Double or Int32 if disabled\n */\nfunction getTypedNumber(value: number): { value: string; type: \"Int32\" | \"Double\" } {\n const valueStr = String(value);\n if (Number.isSafeInteger(value)) {\n return { value: valueStr, type: \"Int32\" };\n } else {\n return { value: valueStr, type: \"Double\" };\n }\n}\n\nexport function deserializeObjectsArray<T extends object>(\n objArray: object[],\n disableTypeConversion: boolean\n): T[] {\n return objArray.map((obj) => deserialize<T>(obj, disableTypeConversion));\n}\n\n/**\n * For ACL endpoints the Tables Service takes an ISO Date without decimals however\n * serializing a JavaScript date gives us a date with decimals 2021-07-08T09:10:09.000Z\n * which makes the XML request body invalid, these 2 functions serialize and deserialize the\n * dates so that they are in the expected format\n */\nexport function serializeSignedIdentifiers(\n signedIdentifiers: SignedIdentifier[]\n): GeneratedSignedIdentifier[] {\n return signedIdentifiers.map((acl) => {\n const { id, accessPolicy } = acl;\n const { start, expiry, ...rest } = accessPolicy ?? {};\n const serializedStart = start\n ? truncatedISO8061Date(start, false /** withMilliseconds */)\n : undefined;\n const serializedExpiry = expiry\n ? truncatedISO8061Date(expiry, false /** withMilliseconds */)\n : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(serializedExpiry && { expiry: serializedExpiry }),\n ...(serializedStart && { start: serializedStart }),\n ...rest\n }\n };\n });\n}\n\nexport function deserializeSignedIdentifier(\n signedIdentifiers: GeneratedSignedIdentifier[]\n): SignedIdentifier[] {\n return signedIdentifiers.map((si) => {\n const { id, accessPolicy } = si;\n const { start, expiry, ...restAcl } = accessPolicy ?? {};\n const deserializedStart = start ? new Date(start) : undefined;\n const deserializedExpiry = expiry ? new Date(expiry) : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(deserializedExpiry && { expiry: deserializedExpiry }),\n ...(deserializedStart && { start: deserializedStart }),\n ...restAcl\n }\n };\n });\n}\n\nexport function serializeQueryOptions(query: TableEntityQueryOptions): GeneratedQueryOptions {\n const { select, ...queryOptions } = query;\n const mappedQuery: GeneratedQueryOptions = { ...queryOptions };\n // Properties that are always returned by the service but are not allowed in select\n const excludeFromSelect = [\"etag\", \"odata.etag\"];\n if (select) {\n mappedQuery.select = select\n .filter((p) => !excludeFromSelect.includes(p))\n .map(translatePropertyNameForSerialization)\n .join(\",\");\n }\n return mappedQuery;\n}\n"]}
1
+ {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,Y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,CAAqB,CAAC;QACzD,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEjE,OAAO;YACL,EAAE;YACF,YAAY,gDACP,CAAC,kBAAkB,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,GACtD,CAAC,iBAAiB,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,GACnD,OAAO,CACX;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAA8B;IAClE,MAAM,EAAE,MAAM,KAAsB,KAAK,EAAtB,YAAY,UAAK,KAAK,EAAnC,UAA2B,CAAQ,CAAC;IAC1C,MAAM,WAAW,qBAA+B,YAAY,CAAE,CAAC;IAC/D,mFAAmF;IACnF,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjD,IAAI,MAAM,EAAE;QACV,WAAW,CAAC,MAAM,GAAG,MAAM;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aAC7C,GAAG,CAAC,qCAAqC,CAAC;aAC1C,IAAI,CAAC,GAAG,CAAC,CAAC;KACd;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { base64Encode, base64Decode } from \"./utils/bufferSerializer\";\nimport { EdmTypes, SignedIdentifier, TableEntityQueryOptions } from \"./models\";\nimport { truncatedISO8061Date } from \"./utils/truncateISO8061Date\";\nimport {\n SignedIdentifier as GeneratedSignedIdentifier,\n QueryOptions as GeneratedQueryOptions\n} from \"./generated/models\";\n\nconst propertyCaseMap: Map<string, string> = new Map<string, string>([\n [\"PartitionKey\", \"partitionKey\"],\n [\"RowKey\", \"rowKey\"],\n [\"odata.etag\", \"etag\"],\n [\"Timestamp\", \"timestamp\"]\n]);\n\nconst Edm = {\n Binary: \"Edm.Binary\",\n Boolean: \"Edm.Boolean\",\n DateTime: \"Edm.DateTime\",\n Double: \"Edm.Double\",\n Guid: \"Edm.Guid\",\n Int32: \"Edm.Int32\",\n Int64: \"Edm.Int64\",\n String: \"Edm.String\"\n} as const;\n\ntype supportedTypes = boolean | string | number | Date | Uint8Array | bigint;\n\ntype serializedType = {\n value: supportedTypes;\n type?: string;\n};\n\nfunction serializePrimitive(value: any): serializedType {\n const serializedValue: serializedType = { value };\n if (\n value === undefined ||\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"string\" ||\n typeof value === \"number\"\n ) {\n serializedValue.value = value;\n } else if (typeof value === \"bigint\") {\n serializedValue.value = value.toString();\n serializedValue.type = Edm.Int64;\n } else if (value instanceof Date) {\n serializedValue.value = value;\n serializedValue.type = Edm.DateTime;\n } else if (value instanceof Uint8Array) {\n serializedValue.value = base64Encode(value);\n serializedValue.type = Edm.Binary;\n } else {\n throw new Error(`Unknown EDM type ${typeof value}`);\n }\n\n return serializedValue;\n}\n\nfunction serializeObject(obj: { value: any; type: EdmTypes }): serializedType {\n const serializedValue: serializedType = { value: obj.value };\n if (\n obj.type === \"Boolean\" ||\n obj.type === \"DateTime\" ||\n obj.type === \"Double\" ||\n obj.type === \"Guid\" ||\n obj.type === \"Int32\" ||\n obj.type === \"Int64\" ||\n obj.type === \"String\" ||\n obj.type === \"Binary\"\n ) {\n serializedValue.value = obj.value;\n serializedValue.type = Edm[obj.type];\n } else {\n throw new Error(`Unknown EDM type ${typeof obj.value}`);\n }\n\n return serializedValue;\n}\n\nfunction getSerializedValue(value: any): serializedType {\n if (typeof value === \"object\" && value?.value !== undefined && value?.type !== undefined) {\n return serializeObject(value);\n } else {\n return serializePrimitive(value);\n }\n}\n\nfunction translatePropertyNameForSerialization(propertyName: string): string {\n for (const [original, internal] of propertyCaseMap) {\n if (internal === propertyName) {\n return original;\n }\n }\n\n return propertyName;\n}\n\nexport function serialize(obj: object): Record<string, Record<string, unknown>> {\n const serialized: any = {};\n for (const [propertyName, propertyValue] of Object.entries(obj)) {\n const transformedKey = translatePropertyNameForSerialization(propertyName);\n const serializedVal = getSerializedValue(propertyValue);\n serialized[transformedKey] = serializedVal.value;\n if (serializedVal.type) {\n serialized[`${transformedKey}@odata.type`] = serializedVal.type;\n }\n }\n return serialized;\n}\n\nfunction getTypedObject(value: any, type: string, disableTypeConversion: boolean): any {\n switch (type) {\n case Edm.Boolean:\n return disableTypeConversion ? { value, type: \"Boolean\" } : value;\n case Edm.Double:\n return disableTypeConversion ? { value, type: \"Double\" } : value;\n case Edm.Int32:\n return disableTypeConversion ? { value, type: \"Int32\" } : value;\n case Edm.String:\n return disableTypeConversion ? { value, type: \"String\" } : value;\n case Edm.DateTime:\n return disableTypeConversion ? { value, type: \"DateTime\" } : new Date(value);\n case Edm.Int64:\n return disableTypeConversion ? { value, type: \"Int64\" } : BigInt(value);\n case Edm.Guid:\n return { value, type: \"Guid\" };\n case Edm.Binary:\n return disableTypeConversion ? { value, type: \"Binary\" } : base64Decode(value);\n default:\n throw new Error(`Unknown EDM type ${type}`);\n }\n}\n\nexport function deserialize<T extends object = Record<string, any>>(\n obj: object,\n disableTypeConversion: boolean = false\n): T {\n const deserialized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key.indexOf(\"@odata.type\") === -1) {\n const transformedKey = propertyCaseMap.get(key) ?? key;\n let typedValue = value;\n if (`${key}@odata.type` in obj) {\n const type = (obj as any)[`${key}@odata.type`];\n typedValue = getTypedObject(value, type, disableTypeConversion);\n } else if (disableTypeConversion && [\"number\", \"string\", \"boolean\"].includes(typeof value)) {\n // The service, doesn't return type metadata for number, strings or booleans\n // if automatic type conversion is disabled we'll infer the EDM object\n typedValue = inferTypedObject(key, value);\n }\n\n deserialized[transformedKey] = typedValue;\n }\n }\n return deserialized;\n}\n\nfunction inferTypedObject(propertyName: string, value: number | string | boolean) {\n // We need to skip service metadata fields such as partitionKey and rowKey and use the same value returned by the service\n if (propertyCaseMap.has(propertyName)) {\n return value;\n }\n\n switch (typeof value) {\n case \"boolean\":\n return { value: String(value), type: \"Boolean\" };\n case \"number\":\n return getTypedNumber(value);\n case \"string\":\n return { value, type: \"String\" };\n default:\n return value;\n }\n}\n\n/**\n * Returns the number when typeConversion is enabled or the EDM object with the correct number format Double or Int32 if disabled\n */\nfunction getTypedNumber(value: number): { value: string; type: \"Int32\" | \"Double\" } {\n const valueStr = String(value);\n if (Number.isSafeInteger(value)) {\n return { value: valueStr, type: \"Int32\" };\n } else {\n return { value: valueStr, type: \"Double\" };\n }\n}\n\nexport function deserializeObjectsArray<T extends object>(\n objArray: object[],\n disableTypeConversion: boolean\n): T[] {\n return objArray.map((obj) => deserialize<T>(obj, disableTypeConversion));\n}\n\n/**\n * For ACL endpoints the Tables Service takes an ISO Date without decimals however\n * serializing a JavaScript date gives us a date with decimals 2021-07-08T09:10:09.000Z\n * which makes the XML request body invalid, these 2 functions serialize and deserialize the\n * dates so that they are in the expected format\n */\nexport function serializeSignedIdentifiers(\n signedIdentifiers: SignedIdentifier[]\n): GeneratedSignedIdentifier[] {\n return signedIdentifiers.map((acl) => {\n const { id, accessPolicy } = acl;\n const { start, expiry, ...rest } = accessPolicy ?? {};\n const serializedStart = start\n ? truncatedISO8061Date(start, false /** withMilliseconds */)\n : undefined;\n const serializedExpiry = expiry\n ? truncatedISO8061Date(expiry, false /** withMilliseconds */)\n : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(serializedExpiry && { expiry: serializedExpiry }),\n ...(serializedStart && { start: serializedStart }),\n ...rest\n }\n };\n });\n}\n\nexport function deserializeSignedIdentifier(\n signedIdentifiers: GeneratedSignedIdentifier[]\n): SignedIdentifier[] {\n return signedIdentifiers.map((si) => {\n const { id, accessPolicy } = si;\n const { start, expiry, ...restAcl } = accessPolicy ?? {};\n const deserializedStart = start ? new Date(start) : undefined;\n const deserializedExpiry = expiry ? new Date(expiry) : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(deserializedExpiry && { expiry: deserializedExpiry }),\n ...(deserializedStart && { start: deserializedStart }),\n ...restAcl\n }\n };\n });\n}\n\nexport function serializeQueryOptions(query: TableEntityQueryOptions): GeneratedQueryOptions {\n const { select, ...queryOptions } = query;\n const mappedQuery: GeneratedQueryOptions = { ...queryOptions };\n // Properties that are always returned by the service but are not allowed in select\n const excludeFromSelect = [\"etag\", \"odata.etag\"];\n if (select) {\n mappedQuery.select = select\n .filter((p) => !excludeFromSelect.includes(p))\n .map(translatePropertyNameForSerialization)\n .join(\",\");\n }\n return mappedQuery;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/data-tables",
3
- "version": "13.0.0-alpha.20211109.2",
3
+ "version": "13.0.1-alpha.20211112.1",
4
4
  "description": "An isomorphic client library for the Azure Tables service.",
5
5
  "sdk-type": "client",
6
6
  "main": "dist/index.js",
@@ -6,6 +6,7 @@ import { NamedKeyCredential } from '@azure/core-auth';
6
6
  import { OperationOptions } from '@azure/core-client';
7
7
  import { PagedAsyncIterableIterator } from '@azure/core-paging';
8
8
  import { Pipeline } from '@azure/core-rest-pipeline';
9
+ import { RestError } from '@azure/core-rest-pipeline';
9
10
  import { SASCredential } from '@azure/core-auth';
10
11
  import { TokenCredential } from '@azure/core-auth';
11
12
  /** An Access policy. */
@@ -147,7 +148,7 @@ export declare interface Edm<T extends EdmTypes> {
147
148
  /**
148
149
  * The value of the entity property
149
150
  */
150
- value: T extends "Binary" ? Uint8Array : T extends "Boolean" ? boolean : T extends "Double" ? number : T extends "Int32" ? number : string;
151
+ value: T extends "Binary" ? string : T extends "Boolean" ? boolean : T extends "Double" ? number : T extends "Int32" ? number : string;
151
152
  /**
152
153
  * The type of the entity property
153
154
  */
@@ -277,6 +278,7 @@ export declare interface Metrics {
277
278
  * Escapes an odata filter expression to avoid errors with quoting string literals.
278
279
  */
279
280
  export declare function odata(strings: TemplateStringsArray, ...values: unknown[]): string;
281
+ export { RestError };
280
282
  /** The retention policy. */
281
283
  export declare interface RetentionPolicy {
282
284
  /** Indicates whether a retention policy is enabled for the service. */
@@ -6,6 +6,7 @@ import { NamedKeyCredential } from '@azure/core-auth';
6
6
  import { OperationOptions } from '@azure/core-client';
7
7
  import { PagedAsyncIterableIterator } from '@azure/core-paging';
8
8
  import { Pipeline } from '@azure/core-rest-pipeline';
9
+ import { RestError } from '@azure/core-rest-pipeline';
9
10
  import { SASCredential } from '@azure/core-auth';
10
11
  import { TokenCredential } from '@azure/core-auth';
11
12
 
@@ -159,7 +160,7 @@ export declare interface Edm<T extends EdmTypes> {
159
160
  /**
160
161
  * The value of the entity property
161
162
  */
162
- value: T extends "Binary" ? Uint8Array : T extends "Boolean" ? boolean : T extends "Double" ? number : T extends "Int32" ? number : string;
163
+ value: T extends "Binary" ? string : T extends "Boolean" ? boolean : T extends "Double" ? number : T extends "Int32" ? number : string;
163
164
  /**
164
165
  * The type of the entity property
165
166
  */
@@ -306,6 +307,8 @@ export declare interface Metrics {
306
307
  */
307
308
  export declare function odata(strings: TemplateStringsArray, ...values: unknown[]): string;
308
309
 
310
+ export { RestError }
311
+
309
312
  /** The retention policy. */
310
313
  export declare interface RetentionPolicy {
311
314
  /** Indicates whether a retention policy is enabled for the service. */
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.17"
8
+ "packageVersion": "7.18.19"
9
9
  }
10
10
  ]
11
11
  }