@azure/data-tables 13.3.1-alpha.20250620.1 → 13.3.1-alpha.20250721.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/dist/browser/TableClient.js +105 -61
- package/dist/browser/TableClient.js.map +1 -1
- package/dist/browser/TableServiceClient.js +59 -48
- package/dist/browser/TableServiceClient.js.map +1 -1
- package/dist/browser/TableTransaction.js +34 -9
- package/dist/browser/TableTransaction.js.map +1 -1
- package/dist/browser/generated/generatedClient.js +11 -3
- package/dist/browser/generated/generatedClient.js.map +1 -1
- package/dist/browser/generated/generatedClientContext.js +9 -2
- package/dist/browser/generated/generatedClientContext.js.map +1 -1
- package/dist/browser/generated/models/mappers.js +5 -2
- package/dist/browser/generated/models/mappers.js.map +1 -1
- package/dist/browser/generated/operations/service.js +1 -0
- package/dist/browser/generated/operations/service.js.map +1 -1
- package/dist/browser/generated/operations/table.js +1 -0
- package/dist/browser/generated/operations/table.js.map +1 -1
- package/dist/browser/sas/generateAccountSas.js +8 -3
- package/dist/browser/sas/generateAccountSas.js.map +1 -1
- package/dist/browser/sas/generateTableSas.js +5 -2
- package/dist/browser/sas/generateTableSas.js.map +1 -1
- package/dist/browser/sas/sasQueryParameters.js +112 -0
- package/dist/browser/sas/sasQueryParameters.js.map +1 -1
- package/dist/browser/sas/tableSasSignatureValues.js +6 -7
- package/dist/browser/sas/tableSasSignatureValues.js.map +1 -1
- package/dist/browser/secondaryEndpointPolicy.js +10 -2
- package/dist/browser/secondaryEndpointPolicy.js.map +1 -1
- package/dist/browser/serialization.js +16 -10
- package/dist/browser/serialization.js.map +1 -1
- package/dist/browser/utils/continuationToken.js +5 -1
- package/dist/browser/utils/continuationToken.js.map +1 -1
- package/dist/browser/utils/errorHelpers.js +3 -4
- package/dist/browser/utils/errorHelpers.js.map +1 -1
- package/dist/browser/utils/isCosmosEndpoint.js +2 -3
- package/dist/browser/utils/isCosmosEndpoint.js.map +1 -1
- package/dist/commonjs/TableClient.js +105 -61
- package/dist/commonjs/TableClient.js.map +1 -1
- package/dist/commonjs/TableServiceClient.js +59 -48
- package/dist/commonjs/TableServiceClient.js.map +1 -1
- package/dist/commonjs/TableTransaction.js +34 -9
- package/dist/commonjs/TableTransaction.js.map +1 -1
- package/dist/commonjs/generated/generatedClient.js +11 -3
- package/dist/commonjs/generated/generatedClient.js.map +1 -1
- package/dist/commonjs/generated/generatedClientContext.js +9 -2
- package/dist/commonjs/generated/generatedClientContext.js.map +1 -1
- package/dist/commonjs/generated/models/mappers.js +5 -2
- package/dist/commonjs/generated/models/mappers.js.map +1 -1
- package/dist/commonjs/generated/operations/service.js +1 -0
- package/dist/commonjs/generated/operations/service.js.map +1 -1
- package/dist/commonjs/generated/operations/table.js +1 -0
- package/dist/commonjs/generated/operations/table.js.map +1 -1
- package/dist/commonjs/sas/generateAccountSas.js +8 -3
- package/dist/commonjs/sas/generateAccountSas.js.map +1 -1
- package/dist/commonjs/sas/generateTableSas.js +5 -2
- package/dist/commonjs/sas/generateTableSas.js.map +1 -1
- package/dist/commonjs/sas/sasQueryParameters.js +112 -0
- package/dist/commonjs/sas/sasQueryParameters.js.map +1 -1
- package/dist/commonjs/sas/tableSasSignatureValues.js +6 -7
- package/dist/commonjs/sas/tableSasSignatureValues.js.map +1 -1
- package/dist/commonjs/secondaryEndpointPolicy.js +10 -2
- package/dist/commonjs/secondaryEndpointPolicy.js.map +1 -1
- package/dist/commonjs/serialization.js +16 -10
- package/dist/commonjs/serialization.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utils/continuationToken.js +5 -1
- package/dist/commonjs/utils/continuationToken.js.map +1 -1
- package/dist/commonjs/utils/errorHelpers.js +3 -4
- package/dist/commonjs/utils/errorHelpers.js.map +1 -1
- package/dist/commonjs/utils/isCosmosEndpoint.js +2 -3
- package/dist/commonjs/utils/isCosmosEndpoint.js.map +1 -1
- package/dist/commonjs/utils/transactionHeaders.js +5 -2
- package/dist/commonjs/utils/transactionHeaders.js.map +1 -1
- package/dist/esm/TableClient.js +105 -61
- package/dist/esm/TableClient.js.map +1 -1
- package/dist/esm/TableServiceClient.js +59 -48
- package/dist/esm/TableServiceClient.js.map +1 -1
- package/dist/esm/TableTransaction.js +34 -9
- package/dist/esm/TableTransaction.js.map +1 -1
- package/dist/esm/generated/generatedClient.js +11 -3
- package/dist/esm/generated/generatedClient.js.map +1 -1
- package/dist/esm/generated/generatedClientContext.js +9 -2
- package/dist/esm/generated/generatedClientContext.js.map +1 -1
- package/dist/esm/generated/models/mappers.js +5 -2
- package/dist/esm/generated/models/mappers.js.map +1 -1
- package/dist/esm/generated/operations/service.js +1 -0
- package/dist/esm/generated/operations/service.js.map +1 -1
- package/dist/esm/generated/operations/table.js +1 -0
- package/dist/esm/generated/operations/table.js.map +1 -1
- package/dist/esm/sas/generateAccountSas.js +8 -3
- package/dist/esm/sas/generateAccountSas.js.map +1 -1
- package/dist/esm/sas/generateTableSas.js +5 -2
- package/dist/esm/sas/generateTableSas.js.map +1 -1
- package/dist/esm/sas/sasQueryParameters.js +112 -0
- package/dist/esm/sas/sasQueryParameters.js.map +1 -1
- package/dist/esm/sas/tableSasSignatureValues.js +6 -7
- package/dist/esm/sas/tableSasSignatureValues.js.map +1 -1
- package/dist/esm/secondaryEndpointPolicy.js +10 -2
- package/dist/esm/secondaryEndpointPolicy.js.map +1 -1
- package/dist/esm/serialization.js +16 -10
- package/dist/esm/serialization.js.map +1 -1
- package/dist/esm/utils/continuationToken.js +5 -1
- package/dist/esm/utils/continuationToken.js.map +1 -1
- package/dist/esm/utils/errorHelpers.js +3 -4
- package/dist/esm/utils/errorHelpers.js.map +1 -1
- package/dist/esm/utils/isCosmosEndpoint.js +2 -3
- package/dist/esm/utils/isCosmosEndpoint.js.map +1 -1
- package/dist/esm/utils/transactionHeaders.js +5 -2
- package/dist/esm/utils/transactionHeaders.js.map +1 -1
- package/dist/react-native/TableClient.js +105 -61
- package/dist/react-native/TableClient.js.map +1 -1
- package/dist/react-native/TableServiceClient.js +59 -48
- package/dist/react-native/TableServiceClient.js.map +1 -1
- package/dist/react-native/TableTransaction.js +34 -9
- package/dist/react-native/TableTransaction.js.map +1 -1
- package/dist/react-native/generated/generatedClient.js +11 -3
- package/dist/react-native/generated/generatedClient.js.map +1 -1
- package/dist/react-native/generated/generatedClientContext.js +9 -2
- package/dist/react-native/generated/generatedClientContext.js.map +1 -1
- package/dist/react-native/generated/models/mappers.js +5 -2
- package/dist/react-native/generated/models/mappers.js.map +1 -1
- package/dist/react-native/generated/operations/service.js +1 -0
- package/dist/react-native/generated/operations/service.js.map +1 -1
- package/dist/react-native/generated/operations/table.js +1 -0
- package/dist/react-native/generated/operations/table.js.map +1 -1
- package/dist/react-native/sas/generateAccountSas.js +8 -3
- package/dist/react-native/sas/generateAccountSas.js.map +1 -1
- package/dist/react-native/sas/generateTableSas.js +5 -2
- package/dist/react-native/sas/generateTableSas.js.map +1 -1
- package/dist/react-native/sas/sasQueryParameters.js +112 -0
- package/dist/react-native/sas/sasQueryParameters.js.map +1 -1
- package/dist/react-native/sas/tableSasSignatureValues.js +6 -7
- package/dist/react-native/sas/tableSasSignatureValues.js.map +1 -1
- package/dist/react-native/secondaryEndpointPolicy.js +10 -2
- package/dist/react-native/secondaryEndpointPolicy.js.map +1 -1
- package/dist/react-native/serialization.js +16 -10
- package/dist/react-native/serialization.js.map +1 -1
- package/dist/react-native/utils/continuationToken.js +5 -1
- package/dist/react-native/utils/continuationToken.js.map +1 -1
- package/dist/react-native/utils/errorHelpers.js +3 -4
- package/dist/react-native/utils/errorHelpers.js.map +1 -1
- package/dist/react-native/utils/isCosmosEndpoint.js +2 -3
- package/dist/react-native/utils/isCosmosEndpoint.js.map +1 -1
- package/dist/react-native/utils/transactionHeaders.js +5 -2
- package/dist/react-native/utils/transactionHeaders.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.TableServiceClient = void 0;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
const core_auth_1 = require("@azure/core-auth");
|
|
8
7
|
const constants_js_1 = require("./utils/constants.js");
|
|
9
8
|
const secondaryEndpointPolicy_js_1 = require("./secondaryEndpointPolicy.js");
|
|
@@ -24,19 +23,36 @@ const isCosmosEndpoint_js_1 = require("./utils/isCosmosEndpoint.js");
|
|
|
24
23
|
* to perform operations on the tables and the entities.
|
|
25
24
|
*/
|
|
26
25
|
class TableServiceClient {
|
|
26
|
+
/**
|
|
27
|
+
* Table Account URL
|
|
28
|
+
*/
|
|
29
|
+
url;
|
|
30
|
+
/**
|
|
31
|
+
* Represents a pipeline for making a HTTP request to a URL.
|
|
32
|
+
* Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.
|
|
33
|
+
*/
|
|
34
|
+
pipeline;
|
|
35
|
+
table;
|
|
36
|
+
service;
|
|
27
37
|
constructor(url, credentialOrOptions, options) {
|
|
28
38
|
this.url = url;
|
|
29
39
|
const isCosmos = (0, isCosmosEndpoint_js_1.isCosmosEndpoint)(this.url);
|
|
30
40
|
const credential = (0, isCredential_js_1.isCredential)(credentialOrOptions) ? credentialOrOptions : undefined;
|
|
31
41
|
const clientOptions = (!(0, isCredential_js_1.isCredential)(credentialOrOptions) ? credentialOrOptions : options) || {};
|
|
32
|
-
const internalPipelineOptions =
|
|
42
|
+
const internalPipelineOptions = {
|
|
43
|
+
...clientOptions,
|
|
44
|
+
endpoint: clientOptions.endpoint || this.url,
|
|
45
|
+
loggingOptions: {
|
|
33
46
|
logger: logger_js_1.logger.info,
|
|
34
47
|
additionalAllowedHeaderNames: [...constants_js_1.TablesLoggingAllowedHeaderNames],
|
|
35
|
-
},
|
|
48
|
+
},
|
|
49
|
+
deserializationOptions: {
|
|
36
50
|
parseXML: core_xml_1.parseXML,
|
|
37
|
-
},
|
|
51
|
+
},
|
|
52
|
+
serializationOptions: {
|
|
38
53
|
stringifyXML: core_xml_1.stringifyXML,
|
|
39
|
-
}
|
|
54
|
+
},
|
|
55
|
+
};
|
|
40
56
|
const client = new generatedClient_js_1.GeneratedClient(this.url, internalPipelineOptions);
|
|
41
57
|
client.pipeline.addPolicy(secondaryEndpointPolicy_js_1.tablesSecondaryEndpointPolicy);
|
|
42
58
|
if ((0, core_auth_1.isNamedKeyCredential)(credential)) {
|
|
@@ -49,7 +65,7 @@ class TableServiceClient {
|
|
|
49
65
|
const scope = isCosmos ? constants_js_1.COSMOS_SCOPE : constants_js_1.STORAGE_SCOPE;
|
|
50
66
|
(0, challengeAuthenticationUtils_js_1.setTokenChallengeAuthenticationPolicy)(client.pipeline, credential, scope);
|
|
51
67
|
}
|
|
52
|
-
if (options
|
|
68
|
+
if (options?.version) {
|
|
53
69
|
client.pipeline.addPolicy((0, apiVersionPolicy_js_1.apiVersionPolicy)(options.version));
|
|
54
70
|
}
|
|
55
71
|
this.pipeline = client.pipeline;
|
|
@@ -92,7 +108,7 @@ class TableServiceClient {
|
|
|
92
108
|
await this.table.create({ name }, updatedOptions);
|
|
93
109
|
}
|
|
94
110
|
catch (e) {
|
|
95
|
-
(0, errorHelpers_js_1.handleTableAlreadyExists)(e,
|
|
111
|
+
(0, errorHelpers_js_1.handleTableAlreadyExists)(e, { ...updatedOptions, logger: logger_js_1.logger, tableName: name });
|
|
96
112
|
}
|
|
97
113
|
});
|
|
98
114
|
}
|
|
@@ -132,57 +148,52 @@ class TableServiceClient {
|
|
|
132
148
|
return this;
|
|
133
149
|
},
|
|
134
150
|
byPage: (settings) => {
|
|
135
|
-
const pageOptions =
|
|
136
|
-
|
|
151
|
+
const pageOptions = {
|
|
152
|
+
...options,
|
|
153
|
+
queryOptions: { ...options?.queryOptions, top: settings?.maxPageSize },
|
|
154
|
+
};
|
|
155
|
+
if (settings?.continuationToken) {
|
|
137
156
|
pageOptions.continuationToken = settings.continuationToken;
|
|
138
157
|
}
|
|
139
158
|
return this.listTablesPage(pageOptions);
|
|
140
159
|
},
|
|
141
160
|
};
|
|
142
161
|
}
|
|
143
|
-
listTablesAll(options) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_d = false;
|
|
155
|
-
const page = _c;
|
|
156
|
-
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
160
|
-
finally {
|
|
161
|
-
try {
|
|
162
|
-
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
|
|
163
|
-
}
|
|
164
|
-
finally { if (e_1) throw e_1.error; }
|
|
165
|
-
}
|
|
162
|
+
async *listTablesAll(options) {
|
|
163
|
+
const firstPage = await this._listTables(options);
|
|
164
|
+
const { continuationToken } = firstPage;
|
|
165
|
+
yield* firstPage;
|
|
166
|
+
if (continuationToken) {
|
|
167
|
+
const optionsWithContinuation = {
|
|
168
|
+
...options,
|
|
169
|
+
continuationToken,
|
|
170
|
+
};
|
|
171
|
+
for await (const page of this.listTablesPage(optionsWithContinuation)) {
|
|
172
|
+
yield* page;
|
|
166
173
|
}
|
|
167
|
-
}
|
|
174
|
+
}
|
|
168
175
|
}
|
|
169
|
-
listTablesPage() {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
result
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
176
|
+
async *listTablesPage(options = {}) {
|
|
177
|
+
let result = await tracing_js_1.tracingClient.withSpan("TableServiceClient.listTablesPage", options, (updatedOptions) => this._listTables(updatedOptions));
|
|
178
|
+
yield result;
|
|
179
|
+
while (result.continuationToken) {
|
|
180
|
+
const optionsWithContinuation = {
|
|
181
|
+
...options,
|
|
182
|
+
continuationToken: result.continuationToken,
|
|
183
|
+
};
|
|
184
|
+
result = await tracing_js_1.tracingClient.withSpan("TableServiceClient.listTablesPage", optionsWithContinuation, async (updatedOptions, span) => {
|
|
185
|
+
span.setAttribute("continuationToken", updatedOptions.continuationToken);
|
|
186
|
+
return this._listTables(updatedOptions);
|
|
187
|
+
});
|
|
188
|
+
yield result;
|
|
189
|
+
}
|
|
182
190
|
}
|
|
183
191
|
async _listTables(options = {}) {
|
|
184
|
-
const { continuationToken: nextTableName
|
|
185
|
-
const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query(
|
|
192
|
+
const { continuationToken: nextTableName, ...listOptions } = options;
|
|
193
|
+
const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query({
|
|
194
|
+
...listOptions,
|
|
195
|
+
nextTableName,
|
|
196
|
+
});
|
|
186
197
|
return Object.assign([...value], { continuationToken });
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableServiceClient.js","sourceRoot":"","sources":["../../src/TableServiceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAqBlC,gDAA4F;AAC5F,uDAAoG;AAEpG,6EAGsC;AACtC,8CAAyD;AAEzD,uEAAiE;AAIjE,qEAA+D;AAC/D,qEAAkF;AAClF,6DAAmE;AACnE,6DAAuD;AACvD,2CAAqC;AACrC,6FAAgG;AAChG,qFAAkF;AAClF,uEAAiE;AACjE,mDAAmD;AACnD,qEAA+D;AAE/D;;;GAGG;AACH,MAAa,kBAAkB;IAuG7B,YACE,GAAW,EACX,mBAI6B,EAC7B,OAAmC;QAEnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,MAAM,QAAQ,GAAG,IAAA,sCAAgB,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,IAAA,8BAAY,EAAC,mBAAmB,CAAC,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A8VC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n GetPropertiesResponse,\n GetStatisticsResponse,\n ServiceProperties,\n SetPropertiesOptions,\n SetPropertiesResponse,\n} from \"./generatedModels.js\";\nimport type {\n InternalClientPipelineOptions,\n OperationOptions,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport type {\n ListTableItemsOptions,\n TableItem,\n TableQueryOptions,\n TableServiceClientOptions,\n} from \"./models.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isNamedKeyCredential, isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { COSMOS_SCOPE, STORAGE_SCOPE, TablesLoggingAllowedHeaderNames } from \"./utils/constants.js\";\nimport type { Service, Table } from \"./generated/index.js\";\nimport {\n injectSecondaryEndpointHeader,\n tablesSecondaryEndpointPolicy,\n} from \"./secondaryEndpointPolicy.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { Pipeline } from \"@azure/core-rest-pipeline\";\nimport type { TableItemResultPage } from \"./models.js\";\nimport { apiVersionPolicy } from \"./utils/apiVersionPolicy.js\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString.js\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers.js\";\nimport { isCredential } from \"./utils/isCredential.js\";\nimport { logger } from \"./logger.js\";\nimport { setTokenChallengeAuthenticationPolicy } from \"./utils/challengeAuthenticationUtils.js\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy.js\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint.js\";\n\n/**\n * A TableServiceClient represents a Client to the Azure Tables service allowing you\n * to perform operations on the tables and the entities.\n */\nexport class TableServiceClient {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.\n */\n public pipeline: Pipeline;\n private table: Table;\n private service: Service;\n\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - NamedKeyCredential | SASCredential used to authenticate requests. Only Supported for Node\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient_NamedKeyCredential\n * import { AzureNamedKeyCredential, TableServiceClient } from \"@azure/data-tables\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n *\n * const credential = new AzureNamedKeyCredential(account, accountKey);\n * const serviceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential,\n * );\n * ```\n */\n constructor(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - SASCredential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using a SAS Token.\n *\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { TableServiceClient, AzureSASCredential } from \"@azure/data-tables\";\n *\n * const account = \"<account name>\";\n * const sas = \"<service Shared Access Signature Token>\";\n *\n * const serviceClientWithSAS = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * new AzureSASCredential(sas),\n * );\n * ```\n */\n constructor(url: string, credential: SASCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TableServiceClient } from \"@azure/data-tables\";\n *\n * const credential = new DefaultAzureCredential();\n * const account = \"<account name>\";\n *\n * const clientWithAAD = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential,\n * );\n * ```\n */\n constructor(url: string, credential: TokenCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as\n * \"https://myaccount.table.core.windows.net\". You can append a SAS,\n * such as \"https://myaccount.table.core.windows.net?sasString\".\n * @param options - Options to configure the HTTP pipeline.\n * Example appending a SAS token:\n *\n * ```ts snippet:ReadmeSampleCreateClient_SASTokenURL\n * import { TableServiceClient } from \"@azure/data-tables\";\n *\n * const account = \"<account name>\";\n * const sasToken = \"<SAS token>\";\n * const tableName = \"<tableName>\";\n *\n * const serviceClientWithSASURL = new TableServiceClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * );\n * ```\n */\n constructor(url: string, options?: TableServiceClientOptions);\n constructor(\n url: string,\n credentialOrOptions?:\n | NamedKeyCredential\n | SASCredential\n | TokenCredential\n | TableServiceClientOptions,\n options?: TableServiceClientOptions,\n ) {\n this.url = url;\n const isCosmos = isCosmosEndpoint(this.url);\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n const clientOptions =\n (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n const internalPipelineOptions: ServiceClientOptions & InternalClientPipelineOptions = {\n ...clientOptions,\n endpoint: clientOptions.endpoint || this.url,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n };\n const client = new GeneratedClient(this.url, internalPipelineOptions);\n client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);\n\n if (isNamedKeyCredential(credential)) {\n client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n client.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n if (isTokenCredential(credential)) {\n const scope = isCosmos ? COSMOS_SCOPE : STORAGE_SCOPE;\n setTokenChallengeAuthenticationPolicy(client.pipeline, credential, scope);\n }\n\n if (options?.version) {\n client.pipeline.addPolicy(apiVersionPolicy(options.version));\n }\n\n this.pipeline = client.pipeline;\n this.table = client.table;\n this.service = client.service;\n }\n\n /**\n * Retrieves statistics related to replication for the Table service. It is only available on the\n * secondary location endpoint when read-access geo-redundant replication is enabled for the account.\n * @param options - The options parameters.\n */\n public async getStatistics(options: OperationOptions = {}): Promise<GetStatisticsResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getStatistics\", options, (updatedOptions) =>\n this.service.getStatistics(injectSecondaryEndpointHeader(updatedOptions)),\n );\n }\n\n /**\n * Gets the properties of an account's Table service, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param options - The options parameters.\n */\n public getProperties(options: OperationOptions = {}): Promise<GetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getProperties\", options, (updatedOptions) =>\n this.service.getProperties(updatedOptions),\n );\n }\n\n /**\n * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param properties - The Table Service properties.\n * @param options - The options parameters.\n */\n public setProperties(\n properties: ServiceProperties,\n options: SetPropertiesOptions = {},\n ): Promise<SetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.setProperties\", options, (updatedOptions) =>\n this.service.setProperties(properties, updatedOptions),\n );\n }\n\n /**\n * Creates a new table under the given account.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public createTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.createTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.create({ name }, updatedOptions);\n } catch (e: any) {\n handleTableAlreadyExists(e, { ...updatedOptions, logger, tableName: name });\n }\n },\n );\n }\n\n /**\n * Operation permanently deletes the specified table.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public deleteTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.deleteTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.delete(name, updatedOptions);\n } catch (e: any) {\n if (e.statusCode === 404) {\n logger.info(\"TableServiceClient.deleteTable: Table doesn't exist\");\n } else {\n throw e;\n }\n }\n },\n );\n }\n\n /**\n * Queries tables under the given account.\n * @param options - The options parameters.\n */\n public listTables(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ListTableItemsOptions,\n ): PagedAsyncIterableIterator<TableItem, TableItemResultPage> {\n const iter = this.listTablesAll(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTablesOptions = {\n ...options,\n queryOptions: { ...options?.queryOptions, top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listTablesPage(pageOptions);\n },\n };\n }\n\n private async *listTablesAll(\n options?: InternalListTablesOptions,\n ): AsyncIterableIterator<TableItem> {\n const firstPage = await this._listTables(options);\n const { continuationToken } = firstPage;\n yield* firstPage;\n if (continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken,\n };\n for await (const page of this.listTablesPage(optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listTablesPage(\n options: InternalListTablesOptions = {},\n ): AsyncIterableIterator<TableItemResultPage> {\n let result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n options,\n (updatedOptions) => this._listTables(updatedOptions),\n );\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken: result.continuationToken,\n };\n result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n optionsWithContinuation,\n async (updatedOptions, span) => {\n span.setAttribute(\"continuationToken\", updatedOptions.continuationToken);\n return this._listTables(updatedOptions);\n },\n );\n yield result;\n }\n }\n\n private async _listTables(options: InternalListTablesOptions = {}): Promise<TableItemResultPage> {\n const { continuationToken: nextTableName, ...listOptions } = options;\n const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query({\n ...listOptions,\n nextTableName,\n });\n return Object.assign([...value], { continuationToken });\n }\n\n /**\n *\n * Creates an instance of TableServiceClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Options to configure the HTTP pipeline.\n * @returns A new TableServiceClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableServiceClientOptions,\n ): TableServiceClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n\n if (credential) {\n return new TableServiceClient(url, credential, clientOptions);\n } else {\n return new TableServiceClient(url, clientOptions);\n }\n }\n}\n\ntype InternalListTablesOptions = ListTableItemsOptions & {\n queryOptions?: TableQueryOptions & { top?: number };\n /**\n * A table query continuation token from a previous call.\n */\n continuationToken?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"TableServiceClient.js","sourceRoot":"","sources":["../../src/TableServiceClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAqBlC,gDAA4F;AAC5F,uDAAoG;AAEpG,6E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EACJ,GAAG,EACH,OAAO,EAAE,aAAa,EACtB,UAAU,GACX,GAAG,IAAA,yDAAmC,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAEnE,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,kBAAkB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AA9VD,gDA8VC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n GetPropertiesResponse,\n GetStatisticsResponse,\n ServiceProperties,\n SetPropertiesOptions,\n SetPropertiesResponse,\n} from \"./generatedModels.js\";\nimport type {\n InternalClientPipelineOptions,\n OperationOptions,\n ServiceClientOptions,\n} from \"@azure/core-client\";\nimport type {\n ListTableItemsOptions,\n TableItem,\n TableQueryOptions,\n TableServiceClientOptions,\n} from \"./models.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isNamedKeyCredential, isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { COSMOS_SCOPE, STORAGE_SCOPE, TablesLoggingAllowedHeaderNames } from \"./utils/constants.js\";\nimport type { Service, Table } from \"./generated/index.js\";\nimport {\n injectSecondaryEndpointHeader,\n tablesSecondaryEndpointPolicy,\n} from \"./secondaryEndpointPolicy.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\n\nimport { GeneratedClient } from \"./generated/generatedClient.js\";\nimport type { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport type { Pipeline } from \"@azure/core-rest-pipeline\";\nimport type { TableItemResultPage } from \"./models.js\";\nimport { apiVersionPolicy } from \"./utils/apiVersionPolicy.js\";\nimport { getClientParamsFromConnectionString } from \"./utils/connectionString.js\";\nimport { handleTableAlreadyExists } from \"./utils/errorHelpers.js\";\nimport { isCredential } from \"./utils/isCredential.js\";\nimport { logger } from \"./logger.js\";\nimport { setTokenChallengeAuthenticationPolicy } from \"./utils/challengeAuthenticationUtils.js\";\nimport { tablesNamedKeyCredentialPolicy } from \"./tablesNamedCredentialPolicy.js\";\nimport { tablesSASTokenPolicy } from \"./tablesSASTokenPolicy.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint.js\";\n\n/**\n * A TableServiceClient represents a Client to the Azure Tables service allowing you\n * to perform operations on the tables and the entities.\n */\nexport class TableServiceClient {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.\n */\n public pipeline: Pipeline;\n private table: Table;\n private service: Service;\n\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - NamedKeyCredential | SASCredential used to authenticate requests. Only Supported for Node\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an account name/key:\n *\n * ```ts snippet:ReadmeSampleCreateClient_NamedKeyCredential\n * import { AzureNamedKeyCredential, TableServiceClient } from \"@azure/data-tables\";\n *\n * const account = \"<account>\";\n * const accountKey = \"<accountkey>\";\n *\n * const credential = new AzureNamedKeyCredential(account, accountKey);\n * const serviceClient = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential,\n * );\n * ```\n */\n constructor(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - SASCredential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using a SAS Token.\n *\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { TableServiceClient, AzureSASCredential } from \"@azure/data-tables\";\n *\n * const account = \"<account name>\";\n * const sas = \"<service Shared Access Signature Token>\";\n *\n * const serviceClientWithSAS = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * new AzureSASCredential(sas),\n * );\n * ```\n */\n constructor(url: string, credential: SASCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as \"https://myaccount.table.core.windows.net\".\n * @param credential - Azure Active Directory credential used to authenticate requests\n * @param options - Options to configure the HTTP pipeline.\n *\n * ### Example using an Azure Active Directory credential:\n *\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import { TableServiceClient } from \"@azure/data-tables\";\n *\n * const credential = new DefaultAzureCredential();\n * const account = \"<account name>\";\n *\n * const clientWithAAD = new TableServiceClient(\n * `https://${account}.table.core.windows.net`,\n * credential,\n * );\n * ```\n */\n constructor(url: string, credential: TokenCredential, options?: TableServiceClientOptions);\n /**\n * Creates a new instance of the TableServiceClient class.\n *\n * @param url - The URL of the service account that is the target of the desired operation., such as\n * \"https://myaccount.table.core.windows.net\". You can append a SAS,\n * such as \"https://myaccount.table.core.windows.net?sasString\".\n * @param options - Options to configure the HTTP pipeline.\n * Example appending a SAS token:\n *\n * ```ts snippet:ReadmeSampleCreateClient_SASTokenURL\n * import { TableServiceClient } from \"@azure/data-tables\";\n *\n * const account = \"<account name>\";\n * const sasToken = \"<SAS token>\";\n * const tableName = \"<tableName>\";\n *\n * const serviceClientWithSASURL = new TableServiceClient(\n * `https://${account}.table.core.windows.net?${sasToken}`,\n * );\n * ```\n */\n constructor(url: string, options?: TableServiceClientOptions);\n constructor(\n url: string,\n credentialOrOptions?:\n | NamedKeyCredential\n | SASCredential\n | TokenCredential\n | TableServiceClientOptions,\n options?: TableServiceClientOptions,\n ) {\n this.url = url;\n const isCosmos = isCosmosEndpoint(this.url);\n const credential = isCredential(credentialOrOptions) ? credentialOrOptions : undefined;\n const clientOptions =\n (!isCredential(credentialOrOptions) ? credentialOrOptions : options) || {};\n\n const internalPipelineOptions: ServiceClientOptions & InternalClientPipelineOptions = {\n ...clientOptions,\n endpoint: clientOptions.endpoint || this.url,\n loggingOptions: {\n logger: logger.info,\n additionalAllowedHeaderNames: [...TablesLoggingAllowedHeaderNames],\n },\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n };\n const client = new GeneratedClient(this.url, internalPipelineOptions);\n client.pipeline.addPolicy(tablesSecondaryEndpointPolicy);\n\n if (isNamedKeyCredential(credential)) {\n client.pipeline.addPolicy(tablesNamedKeyCredentialPolicy(credential));\n } else if (isSASCredential(credential)) {\n client.pipeline.addPolicy(tablesSASTokenPolicy(credential));\n }\n\n if (isTokenCredential(credential)) {\n const scope = isCosmos ? COSMOS_SCOPE : STORAGE_SCOPE;\n setTokenChallengeAuthenticationPolicy(client.pipeline, credential, scope);\n }\n\n if (options?.version) {\n client.pipeline.addPolicy(apiVersionPolicy(options.version));\n }\n\n this.pipeline = client.pipeline;\n this.table = client.table;\n this.service = client.service;\n }\n\n /**\n * Retrieves statistics related to replication for the Table service. It is only available on the\n * secondary location endpoint when read-access geo-redundant replication is enabled for the account.\n * @param options - The options parameters.\n */\n public async getStatistics(options: OperationOptions = {}): Promise<GetStatisticsResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getStatistics\", options, (updatedOptions) =>\n this.service.getStatistics(injectSecondaryEndpointHeader(updatedOptions)),\n );\n }\n\n /**\n * Gets the properties of an account's Table service, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param options - The options parameters.\n */\n public getProperties(options: OperationOptions = {}): Promise<GetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.getProperties\", options, (updatedOptions) =>\n this.service.getProperties(updatedOptions),\n );\n }\n\n /**\n * Sets properties for an account's Table service endpoint, including properties for Analytics and CORS\n * (Cross-Origin Resource Sharing) rules.\n * @param properties - The Table Service properties.\n * @param options - The options parameters.\n */\n public setProperties(\n properties: ServiceProperties,\n options: SetPropertiesOptions = {},\n ): Promise<SetPropertiesResponse> {\n return tracingClient.withSpan(\"TableServiceClient.setProperties\", options, (updatedOptions) =>\n this.service.setProperties(properties, updatedOptions),\n );\n }\n\n /**\n * Creates a new table under the given account.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public createTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.createTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.create({ name }, updatedOptions);\n } catch (e: any) {\n handleTableAlreadyExists(e, { ...updatedOptions, logger, tableName: name });\n }\n },\n );\n }\n\n /**\n * Operation permanently deletes the specified table.\n * @param name - The name of the table.\n * @param options - The options parameters.\n */\n public deleteTable(name: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"TableServiceClient.deleteTable\",\n options,\n async (updatedOptions) => {\n try {\n await this.table.delete(name, updatedOptions);\n } catch (e: any) {\n if (e.statusCode === 404) {\n logger.info(\"TableServiceClient.deleteTable: Table doesn't exist\");\n } else {\n throw e;\n }\n }\n },\n );\n }\n\n /**\n * Queries tables under the given account.\n * @param options - The options parameters.\n */\n public listTables(\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ListTableItemsOptions,\n ): PagedAsyncIterableIterator<TableItem, TableItemResultPage> {\n const iter = this.listTablesAll(options);\n\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: (settings) => {\n const pageOptions: InternalListTablesOptions = {\n ...options,\n queryOptions: { ...options?.queryOptions, top: settings?.maxPageSize },\n };\n\n if (settings?.continuationToken) {\n pageOptions.continuationToken = settings.continuationToken;\n }\n\n return this.listTablesPage(pageOptions);\n },\n };\n }\n\n private async *listTablesAll(\n options?: InternalListTablesOptions,\n ): AsyncIterableIterator<TableItem> {\n const firstPage = await this._listTables(options);\n const { continuationToken } = firstPage;\n yield* firstPage;\n if (continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken,\n };\n for await (const page of this.listTablesPage(optionsWithContinuation)) {\n yield* page;\n }\n }\n }\n\n private async *listTablesPage(\n options: InternalListTablesOptions = {},\n ): AsyncIterableIterator<TableItemResultPage> {\n let result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n options,\n (updatedOptions) => this._listTables(updatedOptions),\n );\n\n yield result;\n\n while (result.continuationToken) {\n const optionsWithContinuation: InternalListTablesOptions = {\n ...options,\n continuationToken: result.continuationToken,\n };\n result = await tracingClient.withSpan(\n \"TableServiceClient.listTablesPage\",\n optionsWithContinuation,\n async (updatedOptions, span) => {\n span.setAttribute(\"continuationToken\", updatedOptions.continuationToken);\n return this._listTables(updatedOptions);\n },\n );\n yield result;\n }\n }\n\n private async _listTables(options: InternalListTablesOptions = {}): Promise<TableItemResultPage> {\n const { continuationToken: nextTableName, ...listOptions } = options;\n const { xMsContinuationNextTableName: continuationToken, value = [] } = await this.table.query({\n ...listOptions,\n nextTableName,\n });\n return Object.assign([...value], { continuationToken });\n }\n\n /**\n *\n * Creates an instance of TableServiceClient from connection string.\n *\n * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.\n * [ Note - Account connection string can only be used in NODE.JS runtime. ]\n * Account connection string example -\n * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`\n * SAS connection string example -\n * `BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`\n * @param options - Options to configure the HTTP pipeline.\n * @returns A new TableServiceClient from the given connection string.\n */\n public static fromConnectionString(\n connectionString: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: TableServiceClientOptions,\n ): TableServiceClient {\n const {\n url,\n options: clientOptions,\n credential,\n } = getClientParamsFromConnectionString(connectionString, options);\n\n if (credential) {\n return new TableServiceClient(url, credential, clientOptions);\n } else {\n return new TableServiceClient(url, clientOptions);\n }\n }\n}\n\ntype InternalListTablesOptions = ListTableItemsOptions & {\n queryOptions?: TableQueryOptions & { top?: number };\n /**\n * A table query continuation token from a previous call.\n */\n continuationToken?: string;\n};\n"]}
|
|
@@ -17,8 +17,12 @@ const tracing_js_1 = require("./utils/tracing.js");
|
|
|
17
17
|
* Helper to build a list of transaction actions
|
|
18
18
|
*/
|
|
19
19
|
class TableTransaction {
|
|
20
|
+
/**
|
|
21
|
+
* List of actions to perform in a transaction
|
|
22
|
+
*/
|
|
23
|
+
actions;
|
|
20
24
|
constructor(actions) {
|
|
21
|
-
this.actions = actions
|
|
25
|
+
this.actions = actions ?? [];
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Adds a create action to the transaction
|
|
@@ -45,7 +49,7 @@ class TableTransaction {
|
|
|
45
49
|
// UpdateMode is a string union
|
|
46
50
|
const realUpdateMode = typeof updateModeOrOptions === "string" ? updateModeOrOptions : undefined;
|
|
47
51
|
const realUpdateOptions = typeof updateModeOrOptions === "object" ? updateModeOrOptions : updateOptions;
|
|
48
|
-
this.actions.push(["update", entity, realUpdateMode
|
|
52
|
+
this.actions.push(["update", entity, realUpdateMode ?? "Merge", realUpdateOptions ?? {}]);
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one
|
|
@@ -61,6 +65,17 @@ exports.TableTransaction = TableTransaction;
|
|
|
61
65
|
* TableTransaction collects sub-operations that can be submitted together via submitTransaction
|
|
62
66
|
*/
|
|
63
67
|
class InternalTableTransaction {
|
|
68
|
+
/**
|
|
69
|
+
* Table Account URL
|
|
70
|
+
*/
|
|
71
|
+
url;
|
|
72
|
+
/**
|
|
73
|
+
* State that holds the information about a particular transation
|
|
74
|
+
*/
|
|
75
|
+
state;
|
|
76
|
+
interceptClient;
|
|
77
|
+
allowInsecureConnection;
|
|
78
|
+
client;
|
|
64
79
|
/**
|
|
65
80
|
* @param url - Tables account url
|
|
66
81
|
* @param partitionKey - partition key
|
|
@@ -160,7 +175,14 @@ class InternalTableTransaction {
|
|
|
160
175
|
const body = (0, transactionHelpers_js_1.getTransactionHttpRequestBody)(this.state.bodyParts, this.state.transactionId, this.state.changesetId);
|
|
161
176
|
const headers = (0, transactionHeaders_js_1.getTransactionHeaders)(this.state.transactionId);
|
|
162
177
|
return tracing_js_1.tracingClient.withSpan("TableTransaction.submitTransaction", options, async (updatedOptions) => {
|
|
163
|
-
const request = (0, core_rest_pipeline_1.createPipelineRequest)(
|
|
178
|
+
const request = (0, core_rest_pipeline_1.createPipelineRequest)({
|
|
179
|
+
...updatedOptions,
|
|
180
|
+
url: this.url,
|
|
181
|
+
method: "POST",
|
|
182
|
+
body,
|
|
183
|
+
headers: (0, core_rest_pipeline_1.createHttpHeaders)(headers),
|
|
184
|
+
allowInsecureConnection: this.allowInsecureConnection,
|
|
185
|
+
});
|
|
164
186
|
const rawTransactionResponse = await this.client.sendRequest(request);
|
|
165
187
|
return parseTransactionResponse(rawTransactionResponse);
|
|
166
188
|
});
|
|
@@ -189,7 +211,7 @@ function parseTransactionResponse(transactionResponse) {
|
|
|
189
211
|
const subResponses = splitBody.slice(1, splitBody.length - 1);
|
|
190
212
|
const responses = subResponses.map((subResponse) => {
|
|
191
213
|
const statusMatch = subResponse.match(/HTTP\/1.1 ([0-9]*)/);
|
|
192
|
-
if (
|
|
214
|
+
if (statusMatch?.length !== 2) {
|
|
193
215
|
throw new Error(`Couldn't extract status from sub-response:\n ${subResponse}`);
|
|
194
216
|
}
|
|
195
217
|
const subResponseStatus = Number.parseInt(statusMatch[1]);
|
|
@@ -197,12 +219,16 @@ function parseTransactionResponse(transactionResponse) {
|
|
|
197
219
|
throw new Error(`Expected sub-response status to be an integer ${subResponseStatus}`);
|
|
198
220
|
}
|
|
199
221
|
const bodyMatch = subResponse.match(/\{(.*)\}/);
|
|
200
|
-
if (
|
|
222
|
+
if (bodyMatch?.length === 2) {
|
|
201
223
|
handleBodyError(bodyMatch[0], subResponseStatus, transactionResponse.request, transactionResponse);
|
|
202
224
|
}
|
|
203
225
|
const etagMatch = subResponse.match(/ETag: (.*)/);
|
|
204
226
|
const rowKeyMatch = subResponse.match(/RowKey='(.*)'/);
|
|
205
|
-
return
|
|
227
|
+
return {
|
|
228
|
+
status: subResponseStatus,
|
|
229
|
+
...(rowKeyMatch?.length === 2 && { rowKey: rowKeyMatch[1] }),
|
|
230
|
+
...(etagMatch?.length === 2 && { etag: etagMatch[1] }),
|
|
231
|
+
};
|
|
206
232
|
});
|
|
207
233
|
return {
|
|
208
234
|
status,
|
|
@@ -211,12 +237,11 @@ function parseTransactionResponse(transactionResponse) {
|
|
|
211
237
|
};
|
|
212
238
|
}
|
|
213
239
|
function handleBodyError(bodyAsText, statusCode, request, response) {
|
|
214
|
-
var _a, _b;
|
|
215
240
|
let parsedError;
|
|
216
241
|
try {
|
|
217
242
|
parsedError = JSON.parse(bodyAsText);
|
|
218
243
|
}
|
|
219
|
-
catch
|
|
244
|
+
catch {
|
|
220
245
|
parsedError = {};
|
|
221
246
|
}
|
|
222
247
|
let message = "Transaction Failed";
|
|
@@ -224,7 +249,7 @@ function handleBodyError(bodyAsText, statusCode, request, response) {
|
|
|
224
249
|
// Only transaction sub-responses return body
|
|
225
250
|
if (parsedError && parsedError["odata.error"]) {
|
|
226
251
|
const error = parsedError["odata.error"];
|
|
227
|
-
message =
|
|
252
|
+
message = error.message?.value ?? message;
|
|
228
253
|
code = error.code;
|
|
229
254
|
}
|
|
230
255
|
throw new core_rest_pipeline_1.RestError(message, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableTransaction.js","sourceRoot":"","sources":["../../src/TableTransaction.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA6TlC,4DAoDC;AAqCD,gEA2BC;AApaD,oDAAkF;AAElF,kEAAgG;AAChG,yEAGuC;AACvC,yD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IAAA,mDAAgC,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7E,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,SAAS,CAAC,IAAA,uCAAiB,GAAE,EAAE;YACtC,aAAa,EAAE,CAAC,oDAAiC,CAAC;YAClD,cAAc,EAAE,CAAC,qCAAuB,EAAE,uDAAoC,CAAC;SAChF,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DeleteTableEntityOptions,\n TableEntity,\n TableTransactionEntityResponse,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n} from \"./models.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport type { OperationOptions, ServiceClient } from \"@azure/core-client\";\nimport { serializationPolicy, serializationPolicyName } from \"@azure/core-client\";\nimport type { Pipeline, PipelineRequest, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { RestError, createHttpHeaders, createPipelineRequest } from \"@azure/core-rest-pipeline\";\nimport {\n getInitialTransactionBody,\n getTransactionHttpRequestBody,\n} from \"./utils/transactionHelpers.js\";\nimport {\n transactionHeaderFilterPolicy,\n transactionHeaderFilterPolicyName,\n transactionRequestAssemblePolicy,\n transactionRequestAssemblePolicyName,\n} from \"./TablePolicies.js\";\n\nimport type { TableClientLike } from \"./utils/internalModels.js\";\nimport type { TableServiceErrorOdataError } from \"./generated/index.js\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy.js\";\nimport { getTransactionHeaders } from \"./utils/transactionHeaders.js\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\n\n/**\n * Helper to build a list of transaction actions\n */\nexport class TableTransaction {\n /**\n * List of actions to perform in a transaction\n */\n public actions: TransactionAction[];\n\n constructor(actions?: TransactionAction[]) {\n this.actions = actions ?? [];\n }\n\n /**\n * Adds a create action to the transaction\n * @param entity - entity to create\n */\n createEntity<T extends object = Record<string, unknown>>(entity: TableEntity<T>): void {\n this.actions.push([\"create\", entity]);\n }\n\n /**\n * Adds a delete action to the transaction\n * @param partitionKey - partition key of the entity to delete\n * @param rowKey - rowKey of the entity to delete\n */\n deleteEntity(partitionKey: string, rowKey: string): void {\n this.actions.push([\"delete\", { partitionKey, rowKey }]);\n }\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateOptions?: UpdateTableEntityOptions,\n ): void;\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateMode - update mode\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode,\n updateOptions?: UpdateTableEntityOptions,\n ): void;\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateModeOrOptions - update mode or update options\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateModeOrOptions: UpdateMode | UpdateTableEntityOptions | undefined,\n updateOptions?: UpdateTableEntityOptions,\n ): void {\n // UpdateMode is a string union\n const realUpdateMode: UpdateMode | undefined =\n typeof updateModeOrOptions === \"string\" ? updateModeOrOptions : undefined;\n const realUpdateOptions: UpdateTableEntityOptions | undefined =\n typeof updateModeOrOptions === \"object\" ? updateModeOrOptions : updateOptions;\n this.actions.push([\"update\", entity, realUpdateMode ?? \"Merge\", realUpdateOptions ?? {}]);\n }\n\n /**\n * Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one\n * @param entity - entity to upsert\n * @param updateMode - update mode\n */\n upsertEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\",\n ): void {\n this.actions.push([\"upsert\", entity, updateMode]);\n }\n}\n\n/**\n * TableTransaction collects sub-operations that can be submitted together via submitTransaction\n */\nexport class InternalTableTransaction {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * State that holds the information about a particular transation\n */\n private state: {\n transactionId: string;\n changesetId: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n partitionKey: string;\n };\n private interceptClient: TableClientLike;\n private allowInsecureConnection: boolean;\n private client: ServiceClient;\n\n /**\n * @param url - Tables account url\n * @param partitionKey - partition key\n * @param credential - credential to authenticate the transaction request\n */\n constructor(\n url: string,\n partitionKey: string,\n transactionId: string,\n changesetId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: ServiceClient,\n interceptClient: TableClientLike,\n credential?: NamedKeyCredential | SASCredential | TokenCredential,\n allowInsecureConnection: boolean = false,\n ) {\n this.client = client;\n this.url = url;\n this.interceptClient = interceptClient;\n this.allowInsecureConnection = allowInsecureConnection;\n\n // Initialize the state\n this.state = this.initializeState(transactionId, changesetId, partitionKey);\n\n // Depending on the auth method used we need to build the url\n if (!credential) {\n // When the SAS token is provided as part of the URL we need to move it after $batch\n const urlParts = url.split(\"?\");\n this.url = urlParts[0];\n const sas = urlParts.length > 1 ? `?${urlParts[1]}` : \"\";\n this.url = `${this.getUrlWithSlash()}$batch${sas}`;\n } else {\n // When using a SharedKey credential no SAS token is needed\n this.url = `${this.getUrlWithSlash()}$batch`;\n }\n }\n\n private initializeState(\n transactionId: string,\n changesetId: string,\n partitionKey: string,\n ): {\n transactionId: string;\n changesetId: string;\n partitionKey: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n } {\n const pendingOperations: Promise<any>[] = [];\n const bodyParts = getInitialTransactionBody(transactionId, changesetId);\n const isCosmos = isCosmosEndpoint(this.url);\n prepateTransactionPipeline(this.interceptClient.pipeline, bodyParts, changesetId, isCosmos);\n\n return {\n transactionId,\n changesetId,\n partitionKey,\n pendingOperations,\n bodyParts,\n };\n }\n\n /**\n * Adds a createEntity operation to the transaction\n * @param entity - Entity to create\n */\n public createEntity<T extends object>(entity: TableEntity<T>): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n\n /**\n * Adds a createEntity operation to the transaction per each entity in the entities array\n * @param entities - Array of entities to create\n */\n public createEntities<T extends object>(entities: TableEntity<T>[]): void {\n for (const entity of entities) {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n }\n\n /**\n * Adds a deleteEntity operation to the transaction\n * @param partitionKey - Partition key of the entity to delete\n * @param rowKey - Row key of the entity to delete\n * @param options - Options for the delete operation\n */\n public deleteEntity(\n partitionKey: string,\n rowKey: string,\n options?: DeleteTableEntityOptions,\n ): void {\n this.checkPartitionKey(partitionKey);\n this.state.pendingOperations.push(\n this.interceptClient.deleteEntity(partitionKey, rowKey, options),\n );\n }\n\n /**\n * Adds an updateEntity operation to the transaction\n * @param entity - Entity to update\n * @param mode - Update mode (Merge or Replace)\n * @param options - Options for the update operation\n */\n public updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: UpdateTableEntityOptions,\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.updateEntity(entity, mode, options));\n }\n\n /**\n * Adds an upsertEntity operation to the transaction\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 public upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: OperationOptions,\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.upsertEntity(entity, mode, options));\n }\n\n /**\n * Submits the operations in the transaction\n * @param options - Options for the request.\n */\n public async submitTransaction(\n options: OperationOptions = {},\n ): Promise<TableTransactionResponse> {\n await Promise.all(this.state.pendingOperations);\n const body = getTransactionHttpRequestBody(\n this.state.bodyParts,\n this.state.transactionId,\n this.state.changesetId,\n );\n\n const headers = getTransactionHeaders(this.state.transactionId);\n\n return tracingClient.withSpan(\n \"TableTransaction.submitTransaction\",\n options,\n async (updatedOptions) => {\n const request = createPipelineRequest({\n ...updatedOptions,\n url: this.url,\n method: \"POST\",\n body,\n headers: createHttpHeaders(headers),\n allowInsecureConnection: this.allowInsecureConnection,\n });\n\n const rawTransactionResponse = await this.client.sendRequest(request);\n return parseTransactionResponse(rawTransactionResponse);\n },\n );\n }\n\n private checkPartitionKey(partitionKey: string): void {\n if (this.state.partitionKey !== partitionKey) {\n throw new Error(\"All operations in a transaction must target the same partitionKey\");\n }\n }\n\n private getUrlWithSlash(): string {\n return this.url.endsWith(\"/\") ? this.url : `${this.url}/`;\n }\n}\n\nexport function parseTransactionResponse(\n transactionResponse: PipelineResponse,\n): TableTransactionResponse {\n const subResponsePrefix = `--changesetresponse_`;\n const status = transactionResponse.status;\n const rawBody = transactionResponse.bodyAsText || \"\";\n const splitBody = rawBody.split(subResponsePrefix);\n const isSuccessByStatus = 200 <= status && status < 300;\n\n if (!isSuccessByStatus) {\n handleBodyError(rawBody, status, transactionResponse.request, transactionResponse);\n }\n\n // Dropping the first and last elements as they are the boundaries\n // we just care about sub request content\n const subResponses = splitBody.slice(1, splitBody.length - 1);\n\n const responses: TableTransactionEntityResponse[] = subResponses.map((subResponse) => {\n const statusMatch = subResponse.match(/HTTP\\/1.1 ([0-9]*)/);\n if (statusMatch?.length !== 2) {\n throw new Error(`Couldn't extract status from sub-response:\\n ${subResponse}`);\n }\n const subResponseStatus = Number.parseInt(statusMatch[1]);\n if (!Number.isInteger(subResponseStatus)) {\n throw new Error(`Expected sub-response status to be an integer ${subResponseStatus}`);\n }\n\n const bodyMatch = subResponse.match(/\\{(.*)\\}/);\n if (bodyMatch?.length === 2) {\n handleBodyError(\n bodyMatch[0],\n subResponseStatus,\n transactionResponse.request,\n transactionResponse,\n );\n }\n\n const etagMatch = subResponse.match(/ETag: (.*)/);\n const rowKeyMatch = subResponse.match(/RowKey='(.*)'/);\n\n return {\n status: subResponseStatus,\n ...(rowKeyMatch?.length === 2 && { rowKey: rowKeyMatch[1] }),\n ...(etagMatch?.length === 2 && { etag: etagMatch[1] }),\n };\n });\n\n return {\n status,\n subResponses: responses,\n getResponseForEntity: (rowKey: string) => responses.find((r) => r.rowKey === rowKey),\n };\n}\n\nfunction handleBodyError(\n bodyAsText: string,\n statusCode: number,\n request: PipelineRequest,\n response: PipelineResponse,\n): void {\n let parsedError;\n\n try {\n parsedError = JSON.parse(bodyAsText);\n } catch {\n parsedError = {};\n }\n\n let message = \"Transaction Failed\";\n let code: string | undefined;\n // Only transaction sub-responses return body\n if (parsedError && parsedError[\"odata.error\"]) {\n const error: TableServiceErrorOdataError = parsedError[\"odata.error\"];\n message = error.message?.value ?? message;\n code = error.code;\n }\n\n throw new RestError(message, {\n code,\n statusCode,\n request,\n response,\n });\n}\n\n/**\n * Prepares the transaction pipeline to intercept operations\n * @param pipeline - Client pipeline\n */\nexport function prepateTransactionPipeline(\n pipeline: Pipeline,\n bodyParts: string[],\n changesetId: string,\n isCosmos: boolean,\n): void {\n // Fist, we need to clear all the existing policies to make sure we start\n // with a fresh state.\n const policies = pipeline.getOrderedPolicies();\n for (const policy of policies) {\n pipeline.removePolicy({\n name: policy.name,\n });\n }\n\n // With the clear state we now initialize the pipelines required for intercepting the requests.\n // Use transaction assemble policy to assemble request and intercept request from going to wire\n\n pipeline.addPolicy(serializationPolicy(), { phase: \"Serialize\" });\n pipeline.addPolicy(transactionHeaderFilterPolicy());\n pipeline.addPolicy(transactionRequestAssemblePolicy(bodyParts, changesetId));\n if (isCosmos) {\n pipeline.addPolicy(cosmosPatchPolicy(), {\n afterPolicies: [transactionHeaderFilterPolicyName],\n beforePolicies: [serializationPolicyName, transactionRequestAssemblePolicyName],\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TableTransaction.js","sourceRoot":"","sources":["../../src/TableTransaction.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AE,CAAC,CAAC;IAClE,QAAQ,CAAC,SAAS,CAAC,IAAA,gDAA6B,GAAE,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,IAAA,mDAAgC,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7E,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,SAAS,CAAC,IAAA,uCAAiB,GAAE,EAAE;YACtC,aAAa,EAAE,CAAC,oDAAiC,CAAC;YAClD,cAAc,EAAE,CAAC,qCAAuB,EAAE,uDAAoC,CAAC;SAChF,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DeleteTableEntityOptions,\n TableEntity,\n TableTransactionEntityResponse,\n TableTransactionResponse,\n TransactionAction,\n UpdateMode,\n UpdateTableEntityOptions,\n} from \"./models.js\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport type { OperationOptions, ServiceClient } from \"@azure/core-client\";\nimport { serializationPolicy, serializationPolicyName } from \"@azure/core-client\";\nimport type { Pipeline, PipelineRequest, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { RestError, createHttpHeaders, createPipelineRequest } from \"@azure/core-rest-pipeline\";\nimport {\n getInitialTransactionBody,\n getTransactionHttpRequestBody,\n} from \"./utils/transactionHelpers.js\";\nimport {\n transactionHeaderFilterPolicy,\n transactionHeaderFilterPolicyName,\n transactionRequestAssemblePolicy,\n transactionRequestAssemblePolicyName,\n} from \"./TablePolicies.js\";\n\nimport type { TableClientLike } from \"./utils/internalModels.js\";\nimport type { TableServiceErrorOdataError } from \"./generated/index.js\";\nimport { cosmosPatchPolicy } from \"./cosmosPathPolicy.js\";\nimport { getTransactionHeaders } from \"./utils/transactionHeaders.js\";\nimport { isCosmosEndpoint } from \"./utils/isCosmosEndpoint.js\";\nimport { tracingClient } from \"./utils/tracing.js\";\n\n/**\n * Helper to build a list of transaction actions\n */\nexport class TableTransaction {\n /**\n * List of actions to perform in a transaction\n */\n public actions: TransactionAction[];\n\n constructor(actions?: TransactionAction[]) {\n this.actions = actions ?? [];\n }\n\n /**\n * Adds a create action to the transaction\n * @param entity - entity to create\n */\n createEntity<T extends object = Record<string, unknown>>(entity: TableEntity<T>): void {\n this.actions.push([\"create\", entity]);\n }\n\n /**\n * Adds a delete action to the transaction\n * @param partitionKey - partition key of the entity to delete\n * @param rowKey - rowKey of the entity to delete\n */\n deleteEntity(partitionKey: string, rowKey: string): void {\n this.actions.push([\"delete\", { partitionKey, rowKey }]);\n }\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateOptions?: UpdateTableEntityOptions,\n ): void;\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateMode - update mode\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode,\n updateOptions?: UpdateTableEntityOptions,\n ): void;\n\n /**\n * Adds an update action to the transaction\n * @param entity - entity to update\n * @param updateModeOrOptions - update mode or update options\n * @param updateOptions - options for the update operation\n */\n updateEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateModeOrOptions: UpdateMode | UpdateTableEntityOptions | undefined,\n updateOptions?: UpdateTableEntityOptions,\n ): void {\n // UpdateMode is a string union\n const realUpdateMode: UpdateMode | undefined =\n typeof updateModeOrOptions === \"string\" ? updateModeOrOptions : undefined;\n const realUpdateOptions: UpdateTableEntityOptions | undefined =\n typeof updateModeOrOptions === \"object\" ? updateModeOrOptions : updateOptions;\n this.actions.push([\"update\", entity, realUpdateMode ?? \"Merge\", realUpdateOptions ?? {}]);\n }\n\n /**\n * Adds an upsert action to the transaction, which inserts if the entity doesn't exist or updates the existing one\n * @param entity - entity to upsert\n * @param updateMode - update mode\n */\n upsertEntity<T extends object = Record<string, unknown>>(\n entity: TableEntity<T>,\n updateMode: UpdateMode = \"Merge\",\n ): void {\n this.actions.push([\"upsert\", entity, updateMode]);\n }\n}\n\n/**\n * TableTransaction collects sub-operations that can be submitted together via submitTransaction\n */\nexport class InternalTableTransaction {\n /**\n * Table Account URL\n */\n public url: string;\n /**\n * State that holds the information about a particular transation\n */\n private state: {\n transactionId: string;\n changesetId: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n partitionKey: string;\n };\n private interceptClient: TableClientLike;\n private allowInsecureConnection: boolean;\n private client: ServiceClient;\n\n /**\n * @param url - Tables account url\n * @param partitionKey - partition key\n * @param credential - credential to authenticate the transaction request\n */\n constructor(\n url: string,\n partitionKey: string,\n transactionId: string,\n changesetId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\n client: ServiceClient,\n interceptClient: TableClientLike,\n credential?: NamedKeyCredential | SASCredential | TokenCredential,\n allowInsecureConnection: boolean = false,\n ) {\n this.client = client;\n this.url = url;\n this.interceptClient = interceptClient;\n this.allowInsecureConnection = allowInsecureConnection;\n\n // Initialize the state\n this.state = this.initializeState(transactionId, changesetId, partitionKey);\n\n // Depending on the auth method used we need to build the url\n if (!credential) {\n // When the SAS token is provided as part of the URL we need to move it after $batch\n const urlParts = url.split(\"?\");\n this.url = urlParts[0];\n const sas = urlParts.length > 1 ? `?${urlParts[1]}` : \"\";\n this.url = `${this.getUrlWithSlash()}$batch${sas}`;\n } else {\n // When using a SharedKey credential no SAS token is needed\n this.url = `${this.getUrlWithSlash()}$batch`;\n }\n }\n\n private initializeState(\n transactionId: string,\n changesetId: string,\n partitionKey: string,\n ): {\n transactionId: string;\n changesetId: string;\n partitionKey: string;\n pendingOperations: Promise<any>[];\n bodyParts: string[];\n } {\n const pendingOperations: Promise<any>[] = [];\n const bodyParts = getInitialTransactionBody(transactionId, changesetId);\n const isCosmos = isCosmosEndpoint(this.url);\n prepateTransactionPipeline(this.interceptClient.pipeline, bodyParts, changesetId, isCosmos);\n\n return {\n transactionId,\n changesetId,\n partitionKey,\n pendingOperations,\n bodyParts,\n };\n }\n\n /**\n * Adds a createEntity operation to the transaction\n * @param entity - Entity to create\n */\n public createEntity<T extends object>(entity: TableEntity<T>): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n\n /**\n * Adds a createEntity operation to the transaction per each entity in the entities array\n * @param entities - Array of entities to create\n */\n public createEntities<T extends object>(entities: TableEntity<T>[]): void {\n for (const entity of entities) {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.createEntity(entity));\n }\n }\n\n /**\n * Adds a deleteEntity operation to the transaction\n * @param partitionKey - Partition key of the entity to delete\n * @param rowKey - Row key of the entity to delete\n * @param options - Options for the delete operation\n */\n public deleteEntity(\n partitionKey: string,\n rowKey: string,\n options?: DeleteTableEntityOptions,\n ): void {\n this.checkPartitionKey(partitionKey);\n this.state.pendingOperations.push(\n this.interceptClient.deleteEntity(partitionKey, rowKey, options),\n );\n }\n\n /**\n * Adds an updateEntity operation to the transaction\n * @param entity - Entity to update\n * @param mode - Update mode (Merge or Replace)\n * @param options - Options for the update operation\n */\n public updateEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: UpdateTableEntityOptions,\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.updateEntity(entity, mode, options));\n }\n\n /**\n * Adds an upsertEntity operation to the transaction\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 public upsertEntity<T extends object>(\n entity: TableEntity<T>,\n mode: UpdateMode,\n options?: OperationOptions,\n ): void {\n this.checkPartitionKey(entity.partitionKey);\n this.state.pendingOperations.push(this.interceptClient.upsertEntity(entity, mode, options));\n }\n\n /**\n * Submits the operations in the transaction\n * @param options - Options for the request.\n */\n public async submitTransaction(\n options: OperationOptions = {},\n ): Promise<TableTransactionResponse> {\n await Promise.all(this.state.pendingOperations);\n const body = getTransactionHttpRequestBody(\n this.state.bodyParts,\n this.state.transactionId,\n this.state.changesetId,\n );\n\n const headers = getTransactionHeaders(this.state.transactionId);\n\n return tracingClient.withSpan(\n \"TableTransaction.submitTransaction\",\n options,\n async (updatedOptions) => {\n const request = createPipelineRequest({\n ...updatedOptions,\n url: this.url,\n method: \"POST\",\n body,\n headers: createHttpHeaders(headers),\n allowInsecureConnection: this.allowInsecureConnection,\n });\n\n const rawTransactionResponse = await this.client.sendRequest(request);\n return parseTransactionResponse(rawTransactionResponse);\n },\n );\n }\n\n private checkPartitionKey(partitionKey: string): void {\n if (this.state.partitionKey !== partitionKey) {\n throw new Error(\"All operations in a transaction must target the same partitionKey\");\n }\n }\n\n private getUrlWithSlash(): string {\n return this.url.endsWith(\"/\") ? this.url : `${this.url}/`;\n }\n}\n\nexport function parseTransactionResponse(\n transactionResponse: PipelineResponse,\n): TableTransactionResponse {\n const subResponsePrefix = `--changesetresponse_`;\n const status = transactionResponse.status;\n const rawBody = transactionResponse.bodyAsText || \"\";\n const splitBody = rawBody.split(subResponsePrefix);\n const isSuccessByStatus = 200 <= status && status < 300;\n\n if (!isSuccessByStatus) {\n handleBodyError(rawBody, status, transactionResponse.request, transactionResponse);\n }\n\n // Dropping the first and last elements as they are the boundaries\n // we just care about sub request content\n const subResponses = splitBody.slice(1, splitBody.length - 1);\n\n const responses: TableTransactionEntityResponse[] = subResponses.map((subResponse) => {\n const statusMatch = subResponse.match(/HTTP\\/1.1 ([0-9]*)/);\n if (statusMatch?.length !== 2) {\n throw new Error(`Couldn't extract status from sub-response:\\n ${subResponse}`);\n }\n const subResponseStatus = Number.parseInt(statusMatch[1]);\n if (!Number.isInteger(subResponseStatus)) {\n throw new Error(`Expected sub-response status to be an integer ${subResponseStatus}`);\n }\n\n const bodyMatch = subResponse.match(/\\{(.*)\\}/);\n if (bodyMatch?.length === 2) {\n handleBodyError(\n bodyMatch[0],\n subResponseStatus,\n transactionResponse.request,\n transactionResponse,\n );\n }\n\n const etagMatch = subResponse.match(/ETag: (.*)/);\n const rowKeyMatch = subResponse.match(/RowKey='(.*)'/);\n\n return {\n status: subResponseStatus,\n ...(rowKeyMatch?.length === 2 && { rowKey: rowKeyMatch[1] }),\n ...(etagMatch?.length === 2 && { etag: etagMatch[1] }),\n };\n });\n\n return {\n status,\n subResponses: responses,\n getResponseForEntity: (rowKey: string) => responses.find((r) => r.rowKey === rowKey),\n };\n}\n\nfunction handleBodyError(\n bodyAsText: string,\n statusCode: number,\n request: PipelineRequest,\n response: PipelineResponse,\n): void {\n let parsedError;\n\n try {\n parsedError = JSON.parse(bodyAsText);\n } catch {\n parsedError = {};\n }\n\n let message = \"Transaction Failed\";\n let code: string | undefined;\n // Only transaction sub-responses return body\n if (parsedError && parsedError[\"odata.error\"]) {\n const error: TableServiceErrorOdataError = parsedError[\"odata.error\"];\n message = error.message?.value ?? message;\n code = error.code;\n }\n\n throw new RestError(message, {\n code,\n statusCode,\n request,\n response,\n });\n}\n\n/**\n * Prepares the transaction pipeline to intercept operations\n * @param pipeline - Client pipeline\n */\nexport function prepateTransactionPipeline(\n pipeline: Pipeline,\n bodyParts: string[],\n changesetId: string,\n isCosmos: boolean,\n): void {\n // Fist, we need to clear all the existing policies to make sure we start\n // with a fresh state.\n const policies = pipeline.getOrderedPolicies();\n for (const policy of policies) {\n pipeline.removePolicy({\n name: policy.name,\n });\n }\n\n // With the clear state we now initialize the pipelines required for intercepting the requests.\n // Use transaction assemble policy to assemble request and intercept request from going to wire\n\n pipeline.addPolicy(serializationPolicy(), { phase: \"Serialize\" });\n pipeline.addPolicy(transactionHeaderFilterPolicy());\n pipeline.addPolicy(transactionRequestAssemblePolicy(bodyParts, changesetId));\n if (isCosmos) {\n pipeline.addPolicy(cosmosPatchPolicy(), {\n afterPolicies: [transactionHeaderFilterPolicyName],\n beforePolicies: [serializationPolicyName, transactionRequestAssemblePolicyName],\n });\n }\n}\n"]}
|
|
@@ -13,13 +13,14 @@ const coreClient = tslib_1.__importStar(require("@azure/core-client"));
|
|
|
13
13
|
const index_js_1 = require("./operations/index.js");
|
|
14
14
|
/** @internal */
|
|
15
15
|
class GeneratedClient extends coreClient.ServiceClient {
|
|
16
|
+
url;
|
|
17
|
+
version;
|
|
16
18
|
/**
|
|
17
19
|
* Initializes a new instance of the GeneratedClient class.
|
|
18
20
|
* @param url The URL of the service account or table that is the target of the desired operation.
|
|
19
21
|
* @param options The parameter options
|
|
20
22
|
*/
|
|
21
23
|
constructor(url, options) {
|
|
22
|
-
var _a, _b;
|
|
23
24
|
if (url === undefined) {
|
|
24
25
|
throw new Error("'url' cannot be null");
|
|
25
26
|
}
|
|
@@ -34,9 +35,14 @@ class GeneratedClient extends coreClient.ServiceClient {
|
|
|
34
35
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
35
36
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
36
37
|
: `${packageDetails}`;
|
|
37
|
-
const optionsWithDefaults =
|
|
38
|
+
const optionsWithDefaults = {
|
|
39
|
+
...defaults,
|
|
40
|
+
...options,
|
|
41
|
+
userAgentOptions: {
|
|
38
42
|
userAgentPrefix
|
|
39
|
-
},
|
|
43
|
+
},
|
|
44
|
+
baseUri: options.endpoint ?? options.baseUri ?? "{url}"
|
|
45
|
+
};
|
|
40
46
|
super(optionsWithDefaults);
|
|
41
47
|
// Parameter assignments
|
|
42
48
|
this.url = url;
|
|
@@ -45,6 +51,8 @@ class GeneratedClient extends coreClient.ServiceClient {
|
|
|
45
51
|
this.table = new index_js_1.TableImpl(this);
|
|
46
52
|
this.service = new index_js_1.ServiceImpl(this);
|
|
47
53
|
}
|
|
54
|
+
table;
|
|
55
|
+
service;
|
|
48
56
|
}
|
|
49
57
|
exports.GeneratedClient = GeneratedClient;
|
|
50
58
|
//# sourceMappingURL=generatedClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AACjD,oDAA+D;AAI/D,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"generatedClient.js","sourceRoot":"","sources":["../../../src/generated/generatedClient.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AACjD,oDAA+D;AAI/D,gBAAgB;AAChB,MAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa;IAC3D,GAAG,CAAS;IACZ,OAAO,CAAS;IAEhB;;;;OAIG;IACH,YAAY,GAAW,EAAE,OAAuC;QAC9D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;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,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB;YACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO;SACxD,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;QAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAW,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAQ;IACb,OAAO,CAAU;CAClB;AAhDD,0CAgDC","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 { TableImpl, ServiceImpl } from \"./operations/index.js\";\nimport { Table, Service } from \"./operationsInterfaces/index.js\";\nimport { GeneratedClientOptionalParams } from \"./models/index.js\";\n\n/** @internal */\nexport class GeneratedClient extends coreClient.ServiceClient {\n url: string;\n version: string;\n\n /**\n * Initializes a new instance of the GeneratedClient 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.1.2`;\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 ?? options.baseUri ?? \"{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 this.table = new TableImpl(this);\n this.service = new ServiceImpl(this);\n }\n\n table: Table;\n service: Service;\n}\n"]}
|
|
@@ -12,6 +12,8 @@ const tslib_1 = require("tslib");
|
|
|
12
12
|
const coreClient = tslib_1.__importStar(require("@azure/core-client"));
|
|
13
13
|
/** @internal */
|
|
14
14
|
class GeneratedClientContext extends coreClient.ServiceClient {
|
|
15
|
+
url;
|
|
16
|
+
version;
|
|
15
17
|
/**
|
|
16
18
|
* Initializes a new instance of the GeneratedClientContext class.
|
|
17
19
|
* @param url The URL of the service account or table that is the target of the desired operation.
|
|
@@ -32,9 +34,14 @@ class GeneratedClientContext extends coreClient.ServiceClient {
|
|
|
32
34
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
33
35
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
34
36
|
: `${packageDetails}`;
|
|
35
|
-
const optionsWithDefaults =
|
|
37
|
+
const optionsWithDefaults = {
|
|
38
|
+
...defaults,
|
|
39
|
+
...options,
|
|
40
|
+
userAgentOptions: {
|
|
36
41
|
userAgentPrefix
|
|
37
|
-
},
|
|
42
|
+
},
|
|
43
|
+
baseUri: options.endpoint || "{url}"
|
|
44
|
+
};
|
|
38
45
|
super(optionsWithDefaults);
|
|
39
46
|
// Parameter assignments
|
|
40
47
|
this.url = url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAIjD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,UAAU,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"generatedClientContext.js","sourceRoot":"","sources":["../../../src/generated/generatedClientContext.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAEH,uEAAiD;AAIjD,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,UAAU,CAAC,aAAa;IAClE,GAAG,CAAS;IACZ,OAAO,CAAS;IAEhB;;;;OAIG;IACH,YAAY,GAAW,EAAE,OAAuC;QAC9D,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;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,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB;YACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO;SACrC,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;AA3CD,wDA2CC","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\";\n\nimport { GeneratedClientOptionalParams } from \"./models/index.js\";\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.3.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 || \"2020-12-06\";\n }\n}\n"]}
|
|
@@ -510,13 +510,16 @@ exports.TableResponse = {
|
|
|
510
510
|
type: {
|
|
511
511
|
name: "Composite",
|
|
512
512
|
className: "TableResponse",
|
|
513
|
-
modelProperties:
|
|
513
|
+
modelProperties: {
|
|
514
|
+
...exports.TableResponseProperties.type.modelProperties,
|
|
515
|
+
odataMetadata: {
|
|
514
516
|
serializedName: "odata\\.metadata",
|
|
515
517
|
xmlName: "odata\\.metadata",
|
|
516
518
|
type: {
|
|
517
519
|
name: "String"
|
|
518
520
|
}
|
|
519
|
-
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
520
523
|
}
|
|
521
524
|
};
|
|
522
525
|
exports.TableQueryHeaders = {
|