@azure/ai-projects 2.0.0 → 2.0.2
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/README.md +5 -5
- package/dist/browser/api/aiProjectContext.d.ts.map +1 -1
- package/dist/browser/api/aiProjectContext.js +2 -1
- package/dist/browser/api/aiProjectContext.js.map +1 -1
- package/dist/browser/api/beta/memoryStores/operations.d.ts.map +1 -1
- package/dist/browser/api/beta/memoryStores/operations.js +11 -0
- package/dist/browser/api/beta/memoryStores/operations.js.map +1 -1
- package/dist/browser/api/datasets/operations.d.ts.map +1 -1
- package/dist/browser/api/datasets/operations.js +9 -8
- package/dist/browser/api/datasets/operations.js.map +1 -1
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/constants.js +1 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/static-helpers/pollingHelpers.d.ts +11 -1
- package/dist/browser/static-helpers/pollingHelpers.d.ts.map +1 -1
- package/dist/browser/static-helpers/pollingHelpers.js +21 -9
- package/dist/browser/static-helpers/pollingHelpers.js.map +1 -1
- package/dist/commonjs/aiProjectClient.js +1 -0
- package/dist/commonjs/aiProjectClient.js.map +1 -1
- package/dist/commonjs/api/agents/index.js +1 -0
- package/dist/commonjs/api/agents/index.js.map +1 -1
- package/dist/commonjs/api/agents/operations.js +1 -0
- package/dist/commonjs/api/agents/operations.js.map +1 -1
- package/dist/commonjs/api/agents/options.js +1 -0
- package/dist/commonjs/api/agents/options.js.map +1 -1
- package/dist/commonjs/api/aiProjectContext.d.ts.map +1 -1
- package/dist/commonjs/api/aiProjectContext.js +3 -1
- package/dist/commonjs/api/aiProjectContext.js.map +3 -3
- package/dist/commonjs/api/beta/evaluationTaxonomies/index.js +1 -0
- package/dist/commonjs/api/beta/evaluationTaxonomies/index.js.map +1 -1
- package/dist/commonjs/api/beta/evaluationTaxonomies/operations.js +1 -0
- package/dist/commonjs/api/beta/evaluationTaxonomies/operations.js.map +1 -1
- package/dist/commonjs/api/beta/evaluationTaxonomies/options.js +1 -0
- package/dist/commonjs/api/beta/evaluationTaxonomies/options.js.map +1 -1
- package/dist/commonjs/api/beta/evaluators/index.js +1 -0
- package/dist/commonjs/api/beta/evaluators/index.js.map +1 -1
- package/dist/commonjs/api/beta/evaluators/operations.js +1 -0
- package/dist/commonjs/api/beta/evaluators/operations.js.map +1 -1
- package/dist/commonjs/api/beta/evaluators/options.js +1 -0
- package/dist/commonjs/api/beta/evaluators/options.js.map +1 -1
- package/dist/commonjs/api/beta/insights/index.js +1 -0
- package/dist/commonjs/api/beta/insights/index.js.map +1 -1
- package/dist/commonjs/api/beta/insights/operations.js +1 -0
- package/dist/commonjs/api/beta/insights/operations.js.map +1 -1
- package/dist/commonjs/api/beta/insights/options.js +1 -0
- package/dist/commonjs/api/beta/insights/options.js.map +1 -1
- package/dist/commonjs/api/beta/memoryStores/index.js +1 -0
- package/dist/commonjs/api/beta/memoryStores/index.js.map +1 -1
- package/dist/commonjs/api/beta/memoryStores/operations.d.ts.map +1 -1
- package/dist/commonjs/api/beta/memoryStores/operations.js +13 -1
- package/dist/commonjs/api/beta/memoryStores/operations.js.map +3 -3
- package/dist/commonjs/api/beta/memoryStores/options.js +1 -0
- package/dist/commonjs/api/beta/memoryStores/options.js.map +1 -1
- package/dist/commonjs/api/beta/redTeams/index.js +1 -0
- package/dist/commonjs/api/beta/redTeams/index.js.map +1 -1
- package/dist/commonjs/api/beta/redTeams/operations.js +1 -0
- package/dist/commonjs/api/beta/redTeams/operations.js.map +1 -1
- package/dist/commonjs/api/beta/redTeams/options.js +1 -0
- package/dist/commonjs/api/beta/redTeams/options.js.map +1 -1
- package/dist/commonjs/api/beta/schedules/index.js +1 -0
- package/dist/commonjs/api/beta/schedules/index.js.map +1 -1
- package/dist/commonjs/api/beta/schedules/operations.js +1 -0
- package/dist/commonjs/api/beta/schedules/operations.js.map +1 -1
- package/dist/commonjs/api/beta/schedules/options.js +1 -0
- package/dist/commonjs/api/beta/schedules/options.js.map +1 -1
- package/dist/commonjs/api/connections/index.js +1 -0
- package/dist/commonjs/api/connections/index.js.map +1 -1
- package/dist/commonjs/api/connections/operations.js +1 -0
- package/dist/commonjs/api/connections/operations.js.map +1 -1
- package/dist/commonjs/api/connections/options.js +1 -0
- package/dist/commonjs/api/connections/options.js.map +1 -1
- package/dist/commonjs/api/datasets/index.js +1 -0
- package/dist/commonjs/api/datasets/index.js.map +1 -1
- package/dist/commonjs/api/datasets/operations.d.ts.map +1 -1
- package/dist/commonjs/api/datasets/operations.js +10 -8
- package/dist/commonjs/api/datasets/operations.js.map +3 -3
- package/dist/commonjs/api/datasets/options.js +1 -0
- package/dist/commonjs/api/datasets/options.js.map +1 -1
- package/dist/commonjs/api/deployments/index.js +1 -0
- package/dist/commonjs/api/deployments/index.js.map +1 -1
- package/dist/commonjs/api/deployments/operations.js +1 -0
- package/dist/commonjs/api/deployments/operations.js.map +1 -1
- package/dist/commonjs/api/deployments/options.js +1 -0
- package/dist/commonjs/api/deployments/options.js.map +1 -1
- package/dist/commonjs/api/evaluationRules/index.js +1 -0
- package/dist/commonjs/api/evaluationRules/index.js.map +1 -1
- package/dist/commonjs/api/evaluationRules/operations.js +1 -0
- package/dist/commonjs/api/evaluationRules/operations.js.map +1 -1
- package/dist/commonjs/api/evaluationRules/options.js +1 -0
- package/dist/commonjs/api/evaluationRules/options.js.map +1 -1
- package/dist/commonjs/api/index.js +1 -0
- package/dist/commonjs/api/index.js.map +1 -1
- package/dist/commonjs/api/indexes/index.js +1 -0
- package/dist/commonjs/api/indexes/index.js.map +1 -1
- package/dist/commonjs/api/indexes/operations.js +1 -0
- package/dist/commonjs/api/indexes/operations.js.map +1 -1
- package/dist/commonjs/api/indexes/options.js +1 -0
- package/dist/commonjs/api/indexes/options.js.map +1 -1
- package/dist/commonjs/api/telemetry/index.js +1 -0
- package/dist/commonjs/api/telemetry/index.js.map +1 -1
- package/dist/commonjs/api/telemetry/operations.js +1 -0
- package/dist/commonjs/api/telemetry/operations.js.map +1 -1
- package/dist/commonjs/classic/agents/index.js +1 -0
- package/dist/commonjs/classic/agents/index.js.map +1 -1
- package/dist/commonjs/classic/beta/evaluationTaxonomies/index.js +1 -0
- package/dist/commonjs/classic/beta/evaluationTaxonomies/index.js.map +1 -1
- package/dist/commonjs/classic/beta/evaluators/index.js +1 -0
- package/dist/commonjs/classic/beta/evaluators/index.js.map +1 -1
- package/dist/commonjs/classic/beta/index.js +1 -0
- package/dist/commonjs/classic/beta/index.js.map +1 -1
- package/dist/commonjs/classic/beta/insights/index.js +1 -0
- package/dist/commonjs/classic/beta/insights/index.js.map +1 -1
- package/dist/commonjs/classic/beta/memoryStores/index.js +1 -0
- package/dist/commonjs/classic/beta/memoryStores/index.js.map +1 -1
- package/dist/commonjs/classic/beta/redTeams/index.js +1 -0
- package/dist/commonjs/classic/beta/redTeams/index.js.map +1 -1
- package/dist/commonjs/classic/beta/schedules/index.js +1 -0
- package/dist/commonjs/classic/beta/schedules/index.js.map +1 -1
- package/dist/commonjs/classic/connections/index.js +1 -0
- package/dist/commonjs/classic/connections/index.js.map +1 -1
- package/dist/commonjs/classic/datasets/index.js +1 -0
- package/dist/commonjs/classic/datasets/index.js.map +1 -1
- package/dist/commonjs/classic/deployments/index.js +1 -0
- package/dist/commonjs/classic/deployments/index.js.map +1 -1
- package/dist/commonjs/classic/evaluationRules/index.js +1 -0
- package/dist/commonjs/classic/evaluationRules/index.js.map +1 -1
- package/dist/commonjs/classic/index.js +1 -0
- package/dist/commonjs/classic/index.js.map +1 -1
- package/dist/commonjs/classic/indexes/index.js +1 -0
- package/dist/commonjs/classic/indexes/index.js.map +1 -1
- package/dist/commonjs/classic/telemetry/index.js +1 -0
- package/dist/commonjs/classic/telemetry/index.js.map +1 -1
- package/dist/commonjs/constants.d.ts +1 -1
- package/dist/commonjs/constants.js +2 -1
- package/dist/commonjs/constants.js.map +2 -2
- package/dist/commonjs/getCustomFetch.js +1 -0
- package/dist/commonjs/getCustomFetch.js.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/logger.js +1 -0
- package/dist/commonjs/logger.js.map +1 -1
- package/dist/commonjs/models/index.js +1 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/models.js +1 -0
- package/dist/commonjs/models/models.js.map +1 -1
- package/dist/commonjs/overwriteOpenAIClient.js +1 -0
- package/dist/commonjs/overwriteOpenAIClient.js.map +1 -1
- package/dist/commonjs/static-helpers/pagingHelpers.js +1 -0
- package/dist/commonjs/static-helpers/pagingHelpers.js.map +1 -1
- package/dist/commonjs/static-helpers/pollingHelpers.d.ts +11 -1
- package/dist/commonjs/static-helpers/pollingHelpers.d.ts.map +1 -1
- package/dist/commonjs/static-helpers/pollingHelpers.js +16 -8
- package/dist/commonjs/static-helpers/pollingHelpers.js.map +3 -3
- package/dist/commonjs/static-helpers/serialization/serialize-record.js +1 -0
- package/dist/commonjs/static-helpers/serialization/serialize-record.js.map +1 -1
- package/dist/commonjs/static-helpers/urlTemplate.js +1 -0
- package/dist/commonjs/static-helpers/urlTemplate.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util.js +1 -0
- package/dist/commonjs/util.js.map +1 -1
- package/dist/esm/aiProjectClient.js +119 -94
- package/dist/esm/aiProjectClient.js.map +1 -7
- package/dist/esm/api/agents/index.js +4 -28
- package/dist/esm/api/agents/index.js.map +1 -7
- package/dist/esm/api/agents/operations.js +375 -473
- package/dist/esm/api/agents/operations.js.map +1 -7
- package/dist/esm/api/agents/options.js +4 -0
- package/dist/esm/api/agents/options.js.map +1 -7
- package/dist/esm/api/aiProjectContext.d.ts.map +1 -1
- package/dist/esm/api/aiProjectContext.js +22 -19
- package/dist/esm/api/aiProjectContext.js.map +1 -7
- package/dist/esm/api/beta/evaluationTaxonomies/index.js +4 -8
- package/dist/esm/api/beta/evaluationTaxonomies/index.js.map +1 -7
- package/dist/esm/api/beta/evaluationTaxonomies/operations.js +150 -183
- package/dist/esm/api/beta/evaluationTaxonomies/operations.js.map +1 -7
- package/dist/esm/api/beta/evaluationTaxonomies/options.js +4 -0
- package/dist/esm/api/beta/evaluationTaxonomies/options.js.map +1 -7
- package/dist/esm/api/beta/evaluators/index.js +4 -16
- package/dist/esm/api/beta/evaluators/index.js.map +1 -7
- package/dist/esm/api/beta/evaluators/operations.js +192 -243
- package/dist/esm/api/beta/evaluators/operations.js.map +1 -7
- package/dist/esm/api/beta/evaluators/options.js +4 -0
- package/dist/esm/api/beta/evaluators/options.js.map +1 -7
- package/dist/esm/api/beta/insights/index.js +4 -6
- package/dist/esm/api/beta/insights/index.js.map +1 -7
- package/dist/esm/api/beta/insights/operations.js +109 -126
- package/dist/esm/api/beta/insights/operations.js.map +1 -7
- package/dist/esm/api/beta/insights/options.js +4 -0
- package/dist/esm/api/beta/insights/options.js.map +1 -7
- package/dist/esm/api/beta/memoryStores/index.js +4 -22
- package/dist/esm/api/beta/memoryStores/index.js.map +1 -7
- package/dist/esm/api/beta/memoryStores/operations.d.ts.map +1 -1
- package/dist/esm/api/beta/memoryStores/operations.js +305 -363
- package/dist/esm/api/beta/memoryStores/operations.js.map +1 -7
- package/dist/esm/api/beta/memoryStores/options.js +4 -0
- package/dist/esm/api/beta/memoryStores/options.js.map +1 -7
- package/dist/esm/api/beta/redTeams/index.js +4 -6
- package/dist/esm/api/beta/redTeams/index.js.map +1 -7
- package/dist/esm/api/beta/redTeams/operations.js +95 -119
- package/dist/esm/api/beta/redTeams/operations.js.map +1 -7
- package/dist/esm/api/beta/redTeams/options.js +4 -0
- package/dist/esm/api/beta/redTeams/options.js.map +1 -7
- package/dist/esm/api/beta/schedules/index.js +4 -9
- package/dist/esm/api/beta/schedules/index.js.map +1 -7
- package/dist/esm/api/beta/schedules/operations.js +204 -248
- package/dist/esm/api/beta/schedules/operations.js.map +1 -7
- package/dist/esm/api/beta/schedules/options.js +4 -0
- package/dist/esm/api/beta/schedules/options.js.map +1 -7
- package/dist/esm/api/connections/index.js +4 -6
- package/dist/esm/api/connections/index.js.map +1 -7
- package/dist/esm/api/connections/operations.js +109 -116
- package/dist/esm/api/connections/operations.js.map +1 -7
- package/dist/esm/api/connections/options.js +4 -0
- package/dist/esm/api/connections/options.js.map +1 -7
- package/dist/esm/api/datasets/index.js +4 -18
- package/dist/esm/api/datasets/index.js.map +1 -7
- package/dist/esm/api/datasets/operations.d.ts.map +1 -1
- package/dist/esm/api/datasets/operations.js +288 -355
- package/dist/esm/api/datasets/operations.js.map +1 -7
- package/dist/esm/api/datasets/options.js +4 -0
- package/dist/esm/api/datasets/options.js.map +1 -7
- package/dist/esm/api/deployments/index.js +4 -5
- package/dist/esm/api/deployments/index.js.map +1 -7
- package/dist/esm/api/deployments/operations.js +57 -70
- package/dist/esm/api/deployments/operations.js.map +1 -7
- package/dist/esm/api/deployments/options.js +4 -0
- package/dist/esm/api/deployments/options.js.map +1 -7
- package/dist/esm/api/evaluationRules/index.js +4 -7
- package/dist/esm/api/evaluationRules/index.js.map +1 -7
- package/dist/esm/api/evaluationRules/operations.js +121 -144
- package/dist/esm/api/evaluationRules/operations.js.map +1 -7
- package/dist/esm/api/evaluationRules/options.js +4 -0
- package/dist/esm/api/evaluationRules/options.js.map +1 -7
- package/dist/esm/api/index.js +4 -4
- package/dist/esm/api/index.js.map +1 -7
- package/dist/esm/api/indexes/index.js +4 -8
- package/dist/esm/api/indexes/index.js.map +1 -7
- package/dist/esm/api/indexes/operations.js +116 -161
- package/dist/esm/api/indexes/operations.js.map +1 -7
- package/dist/esm/api/indexes/options.js +4 -0
- package/dist/esm/api/indexes/options.js.map +1 -7
- package/dist/esm/api/telemetry/index.js +4 -4
- package/dist/esm/api/telemetry/index.js.map +1 -7
- package/dist/esm/api/telemetry/operations.js +53 -46
- package/dist/esm/api/telemetry/operations.js.map +1 -7
- package/dist/esm/classic/agents/index.js +40 -80
- package/dist/esm/classic/agents/index.js.map +1 -7
- package/dist/esm/classic/beta/evaluationTaxonomies/index.js +15 -21
- package/dist/esm/classic/beta/evaluationTaxonomies/index.js.map +1 -7
- package/dist/esm/classic/beta/evaluators/index.js +16 -23
- package/dist/esm/classic/beta/evaluators/index.js.map +1 -7
- package/dist/esm/classic/beta/index.js +18 -18
- package/dist/esm/classic/beta/index.js.map +1 -7
- package/dist/esm/classic/beta/insights/index.js +12 -12
- package/dist/esm/classic/beta/insights/index.js.map +1 -7
- package/dist/esm/classic/beta/memoryStores/index.js +19 -29
- package/dist/esm/classic/beta/memoryStores/index.js.map +1 -7
- package/dist/esm/classic/beta/redTeams/index.js +12 -12
- package/dist/esm/classic/beta/redTeams/index.js.map +1 -7
- package/dist/esm/classic/beta/schedules/index.js +16 -23
- package/dist/esm/classic/beta/schedules/index.js.map +1 -7
- package/dist/esm/classic/connections/index.js +13 -13
- package/dist/esm/classic/connections/index.js.map +1 -7
- package/dist/esm/classic/datasets/index.js +19 -29
- package/dist/esm/classic/datasets/index.js.map +1 -7
- package/dist/esm/classic/deployments/index.js +11 -11
- package/dist/esm/classic/deployments/index.js.map +1 -7
- package/dist/esm/classic/evaluationRules/index.js +13 -13
- package/dist/esm/classic/evaluationRules/index.js.map +1 -7
- package/dist/esm/classic/index.js +4 -0
- package/dist/esm/classic/index.js.map +1 -7
- package/dist/esm/classic/indexes/index.js +14 -14
- package/dist/esm/classic/indexes/index.js.map +1 -7
- package/dist/esm/classic/telemetry/index.js +7 -9
- package/dist/esm/classic/telemetry/index.js.map +1 -7
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +11 -6
- package/dist/esm/constants.js.map +1 -7
- package/dist/esm/getCustomFetch.js +40 -33
- package/dist/esm/getCustomFetch.js.map +1 -7
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -7
- package/dist/esm/logger.js +4 -4
- package/dist/esm/logger.js.map +1 -7
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/models/index.js.map +1 -7
- package/dist/esm/models/models.js +3709 -4160
- package/dist/esm/models/models.js.map +1 -7
- package/dist/esm/overwriteOpenAIClient.js +13 -13
- package/dist/esm/overwriteOpenAIClient.js.map +1 -7
- package/dist/esm/static-helpers/pagingHelpers.js +123 -99
- package/dist/esm/static-helpers/pagingHelpers.js.map +1 -7
- package/dist/esm/static-helpers/pollingHelpers.d.ts +11 -1
- package/dist/esm/static-helpers/pollingHelpers.d.ts.map +1 -1
- package/dist/esm/static-helpers/pollingHelpers.js +99 -69
- package/dist/esm/static-helpers/pollingHelpers.js.map +1 -7
- package/dist/esm/static-helpers/serialization/serialize-record.js +18 -16
- package/dist/esm/static-helpers/serialization/serialize-record.js.map +1 -7
- package/dist/esm/static-helpers/urlTemplate.js +169 -142
- package/dist/esm/static-helpers/urlTemplate.js.map +1 -7
- package/dist/esm/util.js +84 -63
- package/dist/esm/util.js.map +1 -7
- package/dist/react-native/api/aiProjectContext.d.ts.map +1 -1
- package/dist/react-native/api/aiProjectContext.js +2 -1
- package/dist/react-native/api/aiProjectContext.js.map +1 -1
- package/dist/react-native/api/beta/memoryStores/operations.d.ts.map +1 -1
- package/dist/react-native/api/beta/memoryStores/operations.js +11 -0
- package/dist/react-native/api/beta/memoryStores/operations.js.map +1 -1
- package/dist/react-native/api/datasets/operations.d.ts.map +1 -1
- package/dist/react-native/api/datasets/operations.js +9 -8
- package/dist/react-native/api/datasets/operations.js.map +1 -1
- package/dist/react-native/constants.d.ts +1 -1
- package/dist/react-native/constants.js +1 -1
- package/dist/react-native/constants.js.map +1 -1
- package/dist/react-native/static-helpers/pollingHelpers.d.ts +11 -1
- package/dist/react-native/static-helpers/pollingHelpers.d.ts.map +1 -1
- package/dist/react-native/static-helpers/pollingHelpers.js +21 -9
- package/dist/react-native/static-helpers/pollingHelpers.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,394 +1,327 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
1
3
|
import fs from "node:fs";
|
|
2
4
|
import nodePath from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
_pagedDatasetVersionDeserializer,
|
|
5
|
-
datasetVersionUnionSerializer,
|
|
6
|
-
datasetVersionUnionDeserializer,
|
|
7
|
-
pendingUploadRequestSerializer,
|
|
8
|
-
pendingUploadResponseDeserializer,
|
|
9
|
-
datasetCredentialDeserializer
|
|
10
|
-
} from "../../models/models.js";
|
|
5
|
+
import { _pagedDatasetVersionDeserializer, datasetVersionUnionSerializer, datasetVersionUnionDeserializer, pendingUploadRequestSerializer, pendingUploadResponseDeserializer, datasetCredentialDeserializer, } from "../../models/models.js";
|
|
11
6
|
import { buildPagedAsyncIterator } from "../../static-helpers/pagingHelpers.js";
|
|
12
7
|
import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js";
|
|
13
8
|
import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client";
|
|
14
9
|
import { ContainerClient } from "@azure/storage-blob";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"/datasets/{name}/versions/{version}/credentials{?api-version}",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
import { logger } from "../../logger.js";
|
|
11
|
+
export function _getCredentialsSend(context, name, version, options = { requestOptions: {} }) {
|
|
12
|
+
const path = expandUrlTemplate("/datasets/{name}/versions/{version}/credentials{?api-version}", {
|
|
13
|
+
name: name,
|
|
14
|
+
version: version,
|
|
15
|
+
"api-version": context.apiVersion,
|
|
16
|
+
}, {
|
|
17
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
18
|
+
});
|
|
19
|
+
return context.path(path).post({
|
|
20
|
+
...operationOptionsToRequestParameters(options),
|
|
21
|
+
headers: {
|
|
22
|
+
accept: "application/json",
|
|
23
|
+
...options.requestOptions?.headers,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export async function _getCredentialsDeserialize(result) {
|
|
28
|
+
const expectedStatuses = ["200"];
|
|
29
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
30
|
+
throw createRestError(result);
|
|
32
31
|
}
|
|
33
|
-
|
|
32
|
+
return datasetCredentialDeserializer(result.body);
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
return datasetCredentialDeserializer(result.body);
|
|
34
|
+
/** Get the SAS credential to access the storage account associated with a Dataset version. */
|
|
35
|
+
export async function getCredentials(context, name, version, options = { requestOptions: {} }) {
|
|
36
|
+
const result = await _getCredentialsSend(context, name, version, options);
|
|
37
|
+
return _getCredentialsDeserialize(result);
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
export function _pendingUploadSend(context, name, version, pendingUploadRequest, options = { requestOptions: {} }) {
|
|
40
|
+
const path = expandUrlTemplate("/datasets/{name}/versions/{version}/startPendingUpload{?api-version}", {
|
|
41
|
+
name: name,
|
|
42
|
+
version: version,
|
|
43
|
+
"api-version": context.apiVersion,
|
|
44
|
+
}, {
|
|
45
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
46
|
+
});
|
|
47
|
+
return context.path(path).post({
|
|
48
|
+
...operationOptionsToRequestParameters(options),
|
|
49
|
+
contentType: "application/json",
|
|
50
|
+
headers: {
|
|
51
|
+
accept: "application/json",
|
|
52
|
+
...options.requestOptions?.headers,
|
|
53
|
+
},
|
|
54
|
+
body: pendingUploadRequestSerializer(pendingUploadRequest),
|
|
55
|
+
});
|
|
45
56
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
name,
|
|
51
|
-
version,
|
|
52
|
-
"api-version": context.apiVersion
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
57
|
+
export async function _pendingUploadDeserialize(result) {
|
|
58
|
+
const expectedStatuses = ["200"];
|
|
59
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
60
|
+
throw createRestError(result);
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
return context.path(path).post({
|
|
59
|
-
...operationOptionsToRequestParameters(options),
|
|
60
|
-
contentType: "application/json",
|
|
61
|
-
headers: {
|
|
62
|
-
accept: "application/json",
|
|
63
|
-
...options.requestOptions?.headers
|
|
64
|
-
},
|
|
65
|
-
body: pendingUploadRequestSerializer(pendingUploadRequest)
|
|
66
|
-
});
|
|
62
|
+
return pendingUploadResponseDeserializer(result.body);
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
return pendingUploadResponseDeserializer(result.body);
|
|
64
|
+
/** Start a new or get an existing pending upload of a dataset for a specific version. */
|
|
65
|
+
export async function pendingUpload(context, name, version, pendingUploadRequest, options = { requestOptions: {} }) {
|
|
66
|
+
const result = await _pendingUploadSend(context, name, version, pendingUploadRequest, options);
|
|
67
|
+
return _pendingUploadDeserialize(result);
|
|
74
68
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
export function _createOrUpdateSend(context, name, version, datasetVersion, options = { requestOptions: {} }) {
|
|
70
|
+
const path = expandUrlTemplate("/datasets/{name}/versions/{version}{?api-version}", {
|
|
71
|
+
name: name,
|
|
72
|
+
version: version,
|
|
73
|
+
"api-version": context.apiVersion,
|
|
74
|
+
}, {
|
|
75
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
76
|
+
});
|
|
77
|
+
return context.path(path).patch({
|
|
78
|
+
...operationOptionsToRequestParameters(options),
|
|
79
|
+
contentType: "application/merge-patch+json",
|
|
80
|
+
headers: {
|
|
81
|
+
accept: "application/json",
|
|
82
|
+
...options.requestOptions?.headers,
|
|
83
|
+
},
|
|
84
|
+
body: datasetVersionUnionSerializer(datasetVersion),
|
|
85
|
+
});
|
|
78
86
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
name,
|
|
84
|
-
version,
|
|
85
|
-
"api-version": context.apiVersion
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
87
|
+
export async function _createOrUpdateDeserialize(result) {
|
|
88
|
+
const expectedStatuses = ["201", "200"];
|
|
89
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
90
|
+
throw createRestError(result);
|
|
89
91
|
}
|
|
90
|
-
|
|
91
|
-
return context.path(path).patch({
|
|
92
|
-
...operationOptionsToRequestParameters(options),
|
|
93
|
-
contentType: "application/merge-patch+json",
|
|
94
|
-
headers: {
|
|
95
|
-
accept: "application/json",
|
|
96
|
-
...options.requestOptions?.headers
|
|
97
|
-
},
|
|
98
|
-
body: datasetVersionUnionSerializer(datasetVersion)
|
|
99
|
-
});
|
|
92
|
+
return datasetVersionUnionDeserializer(result.body);
|
|
100
93
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return datasetVersionUnionDeserializer(result.body);
|
|
94
|
+
/** Create a new or update an existing DatasetVersion with the given version id */
|
|
95
|
+
export async function createOrUpdate(context, name, version, datasetVersion, options = { requestOptions: {} }) {
|
|
96
|
+
const result = await _createOrUpdateSend(context, name, version, datasetVersion, options);
|
|
97
|
+
return _createOrUpdateDeserialize(result);
|
|
107
98
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
export function _$deleteSend(context, name, version, options = { requestOptions: {} }) {
|
|
100
|
+
const path = expandUrlTemplate("/datasets/{name}/versions/{version}{?api-version}", {
|
|
101
|
+
name: name,
|
|
102
|
+
version: version,
|
|
103
|
+
"api-version": context.apiVersion,
|
|
104
|
+
}, {
|
|
105
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
106
|
+
});
|
|
107
|
+
return context.path(path).delete({ ...operationOptionsToRequestParameters(options) });
|
|
111
108
|
}
|
|
112
|
-
function _$
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
name,
|
|
117
|
-
version,
|
|
118
|
-
"api-version": context.apiVersion
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
109
|
+
export async function _$deleteDeserialize(result) {
|
|
110
|
+
const expectedStatuses = ["204"];
|
|
111
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
112
|
+
throw createRestError(result);
|
|
122
113
|
}
|
|
123
|
-
|
|
124
|
-
return context.path(path).delete({ ...operationOptionsToRequestParameters(options) });
|
|
114
|
+
return;
|
|
125
115
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
return;
|
|
116
|
+
/** Delete the specific version of the DatasetVersion. The service returns 204 No Content if the DatasetVersion was deleted successfully or if the DatasetVersion does not exist. */
|
|
117
|
+
export async function $delete(context, name, version, options = { requestOptions: {} }) {
|
|
118
|
+
const result = await _$deleteSend(context, name, version, options);
|
|
119
|
+
return _$deleteDeserialize(result);
|
|
132
120
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
export function _getSend(context, name, version, options = { requestOptions: {} }) {
|
|
122
|
+
const path = expandUrlTemplate("/datasets/{name}/versions/{version}{?api-version}", {
|
|
123
|
+
name: name,
|
|
124
|
+
version: version,
|
|
125
|
+
"api-version": context.apiVersion,
|
|
126
|
+
}, {
|
|
127
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
128
|
+
});
|
|
129
|
+
return context.path(path).get({
|
|
130
|
+
...operationOptionsToRequestParameters(options),
|
|
131
|
+
headers: {
|
|
132
|
+
accept: "application/json",
|
|
133
|
+
...options.requestOptions?.headers,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
136
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
name,
|
|
142
|
-
version,
|
|
143
|
-
"api-version": context.apiVersion
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
147
|
-
}
|
|
148
|
-
);
|
|
149
|
-
return context.path(path).get({
|
|
150
|
-
...operationOptionsToRequestParameters(options),
|
|
151
|
-
headers: {
|
|
152
|
-
accept: "application/json",
|
|
153
|
-
...options.requestOptions?.headers
|
|
137
|
+
export async function _getDeserialize(result) {
|
|
138
|
+
const expectedStatuses = ["200"];
|
|
139
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
140
|
+
throw createRestError(result);
|
|
154
141
|
}
|
|
155
|
-
|
|
142
|
+
return datasetVersionUnionDeserializer(result.body);
|
|
156
143
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
return datasetVersionUnionDeserializer(result.body);
|
|
144
|
+
/** Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the DatasetVersion does not exist. */
|
|
145
|
+
export async function get(context, name, version, options = { requestOptions: {} }) {
|
|
146
|
+
const result = await _getSend(context, name, version, options);
|
|
147
|
+
return _getDeserialize(result);
|
|
163
148
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
149
|
+
export function _listSend(context, options = { requestOptions: {} }) {
|
|
150
|
+
const path = expandUrlTemplate("/datasets{?api-version}", {
|
|
151
|
+
"api-version": context.apiVersion,
|
|
152
|
+
}, {
|
|
153
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
154
|
+
});
|
|
155
|
+
return context.path(path).get({
|
|
156
|
+
...operationOptionsToRequestParameters(options),
|
|
157
|
+
headers: {
|
|
158
|
+
accept: "application/json",
|
|
159
|
+
...options.requestOptions?.headers,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
167
162
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"api-version": context.apiVersion
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
163
|
+
export async function _listDeserialize(result) {
|
|
164
|
+
const expectedStatuses = ["200"];
|
|
165
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
166
|
+
throw createRestError(result);
|
|
176
167
|
}
|
|
177
|
-
|
|
178
|
-
return context.path(path).get({
|
|
179
|
-
...operationOptionsToRequestParameters(options),
|
|
180
|
-
headers: {
|
|
181
|
-
accept: "application/json",
|
|
182
|
-
...options.requestOptions?.headers
|
|
183
|
-
}
|
|
184
|
-
});
|
|
168
|
+
return _pagedDatasetVersionDeserializer(result.body);
|
|
185
169
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
throw createRestError(result);
|
|
190
|
-
}
|
|
191
|
-
return _pagedDatasetVersionDeserializer(result.body);
|
|
170
|
+
/** List the latest version of each DatasetVersion */
|
|
171
|
+
export function list(context, options = { requestOptions: {} }) {
|
|
172
|
+
return buildPagedAsyncIterator(context, () => _listSend(context, options), _listDeserialize, ["200"], { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion });
|
|
192
173
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
174
|
+
export function _listVersionsSend(context, name, options = { requestOptions: {} }) {
|
|
175
|
+
const path = expandUrlTemplate("/datasets/{name}/versions{?api-version}", {
|
|
176
|
+
name: name,
|
|
177
|
+
"api-version": context.apiVersion,
|
|
178
|
+
}, {
|
|
179
|
+
allowReserved: options?.requestOptions?.skipUrlEncoding,
|
|
180
|
+
});
|
|
181
|
+
return context.path(path).get({
|
|
182
|
+
...operationOptionsToRequestParameters(options),
|
|
183
|
+
headers: {
|
|
184
|
+
accept: "application/json",
|
|
185
|
+
...options.requestOptions?.headers,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
201
188
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
name,
|
|
207
|
-
"api-version": context.apiVersion
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
allowReserved: options?.requestOptions?.skipUrlEncoding
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
return context.path(path).get({
|
|
214
|
-
...operationOptionsToRequestParameters(options),
|
|
215
|
-
headers: {
|
|
216
|
-
accept: "application/json",
|
|
217
|
-
...options.requestOptions?.headers
|
|
189
|
+
export async function _listVersionsDeserialize(result) {
|
|
190
|
+
const expectedStatuses = ["200"];
|
|
191
|
+
if (!expectedStatuses.includes(result.status)) {
|
|
192
|
+
throw createRestError(result);
|
|
218
193
|
}
|
|
219
|
-
|
|
194
|
+
return _pagedDatasetVersionDeserializer(result.body);
|
|
220
195
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
throw createRestError(result);
|
|
225
|
-
}
|
|
226
|
-
return _pagedDatasetVersionDeserializer(result.body);
|
|
227
|
-
}
|
|
228
|
-
function listVersions(context, name, options = { requestOptions: {} }) {
|
|
229
|
-
return buildPagedAsyncIterator(
|
|
230
|
-
context,
|
|
231
|
-
() => _listVersionsSend(context, name, options),
|
|
232
|
-
_listVersionsDeserialize,
|
|
233
|
-
["200"],
|
|
234
|
-
{ itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion }
|
|
235
|
-
);
|
|
196
|
+
/** List all versions of the given DatasetVersion */
|
|
197
|
+
export function listVersions(context, name, options = { requestOptions: {} }) {
|
|
198
|
+
return buildPagedAsyncIterator(context, () => _listVersionsSend(context, name, options), _listVersionsDeserialize, ["200"], { itemName: "value", nextLinkName: "nextLink", apiVersion: context.apiVersion });
|
|
236
199
|
}
|
|
200
|
+
// Internal helper method to create a new dataset and return a ContainerClient from azure-storage-blob package, to the dataset's blob storage.
|
|
237
201
|
async function createDatasetAndGetItsContainer(context, name, version, options) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
`[createDatasetAndGetItsContainer] pendingUploadResponse.pendingUploadType = ${pendingUploadResponse.pendingUploadType}`
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
`[createDatasetAndGetItsContainer] blobReference.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const pipeline = containerClient["storageClientContext"].pipeline;
|
|
276
|
-
for (const { policy } of projectOptions.additionalPolicies ?? []) {
|
|
277
|
-
pipeline.addPolicy(policy, { afterPhase: "Sign" });
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
containerClient,
|
|
281
|
-
version
|
|
282
|
-
};
|
|
202
|
+
const { connectionName, projectOptions = {} } = options || {};
|
|
203
|
+
// Start a pending upload to get the container URL with SAS token
|
|
204
|
+
const pendingUploadResponse = await pendingUpload(context, name, version, {
|
|
205
|
+
pendingUploadType: "BlobReference",
|
|
206
|
+
connectionName,
|
|
207
|
+
});
|
|
208
|
+
const blobReference = pendingUploadResponse.blobReference;
|
|
209
|
+
// Validate the response
|
|
210
|
+
if (!blobReference) {
|
|
211
|
+
throw new Error("Blob reference for consumption is not present");
|
|
212
|
+
}
|
|
213
|
+
if (!blobReference.credential?.type) {
|
|
214
|
+
throw new Error("Credential type is not present");
|
|
215
|
+
}
|
|
216
|
+
if (blobReference.credential.type !== "SAS") {
|
|
217
|
+
throw new Error("Credential type is not SAS");
|
|
218
|
+
}
|
|
219
|
+
if (!blobReference.blobUri) {
|
|
220
|
+
throw new Error("Blob URI is not present or empty");
|
|
221
|
+
}
|
|
222
|
+
// Optional debug logging
|
|
223
|
+
logger.verbose(`[createDatasetAndGetItsContainer] pendingUploadResponse.pendingUploadId = ${pendingUploadResponse.pendingUploadId}`);
|
|
224
|
+
logger.verbose(`[createDatasetAndGetItsContainer] pendingUploadResponse.pendingUploadType = ${pendingUploadResponse.pendingUploadType}`);
|
|
225
|
+
logger.verbose(`[createDatasetAndGetItsContainer] blobReference.blobUri = ${blobReference.blobUri}`);
|
|
226
|
+
logger.verbose(`[createDatasetAndGetItsContainer] blobReference.storageAccountArmId = ${blobReference.storageAccountArmId}`);
|
|
227
|
+
logger.verbose(`[createDatasetAndGetItsContainer] blobReference.credential.sasUri = ${blobReference.credential.sasUri}`);
|
|
228
|
+
logger.verbose(`[createDatasetAndGetItsContainer] blobReference.credential.type = ${blobReference.credential.type}`);
|
|
229
|
+
// Create container client from the blob URI (which includes the SAS token)
|
|
230
|
+
const containerClient = new ContainerClient(blobReference.credential.sasUri);
|
|
231
|
+
const pipeline = containerClient["storageClientContext"].pipeline;
|
|
232
|
+
for (const { policy } of projectOptions.additionalPolicies ?? []) {
|
|
233
|
+
pipeline.addPolicy(policy, { afterPhase: "Sign" });
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
containerClient,
|
|
237
|
+
version,
|
|
238
|
+
};
|
|
283
239
|
}
|
|
284
|
-
async function uploadFile(context, name, version, filePath, options) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
name,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
return datasetVersion;
|
|
240
|
+
export async function uploadFile(context, name, version, filePath, options) {
|
|
241
|
+
// if file does not exist
|
|
242
|
+
const fileExists = fs.existsSync(filePath);
|
|
243
|
+
if (!fileExists) {
|
|
244
|
+
throw new Error(`File does not exist at path: ${filePath}`);
|
|
245
|
+
}
|
|
246
|
+
// Check if the file is a directory
|
|
247
|
+
const isDirectory = fs.lstatSync(filePath).isDirectory();
|
|
248
|
+
if (isDirectory) {
|
|
249
|
+
throw new Error(`The provided file is actually a folder. Use method uploadFolder instead`);
|
|
250
|
+
}
|
|
251
|
+
const { containerClient, version: outputVersion } = await createDatasetAndGetItsContainer(context, name, version, options);
|
|
252
|
+
// file name as blob name
|
|
253
|
+
const blobName = nodePath.basename(filePath);
|
|
254
|
+
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
|
255
|
+
await blockBlobClient.uploadStream(fs.createReadStream(filePath));
|
|
256
|
+
const datasetVersion = await createOrUpdate(context, name, outputVersion, {
|
|
257
|
+
name: name,
|
|
258
|
+
version: outputVersion,
|
|
259
|
+
type: "uri_file",
|
|
260
|
+
dataUri: blockBlobClient.url,
|
|
261
|
+
});
|
|
262
|
+
return datasetVersion;
|
|
309
263
|
}
|
|
310
|
-
async function uploadFolder(context, name, version, folderPath, options) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
name,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
264
|
+
export async function uploadFolder(context, name, version, folderPath, options) {
|
|
265
|
+
// Check if the folder exists
|
|
266
|
+
const folderExists = fs.existsSync(folderPath);
|
|
267
|
+
if (!folderExists) {
|
|
268
|
+
throw new Error(`Folder does not exist at path: ${folderPath}`);
|
|
269
|
+
}
|
|
270
|
+
// Check if the folder is a file
|
|
271
|
+
const isFile = fs.lstatSync(folderPath).isFile();
|
|
272
|
+
if (isFile) {
|
|
273
|
+
throw new Error(`The provided path is actually a file. Use method uploadFile instead`);
|
|
274
|
+
}
|
|
275
|
+
const { containerClient, version: outputVersion } = await createDatasetAndGetItsContainer(context, name, version, options);
|
|
276
|
+
// Helper function to recursively get all files in a directory
|
|
277
|
+
async function getAllFiles(dir, fileList = []) {
|
|
278
|
+
const files = await fs.promises.readdir(dir);
|
|
279
|
+
for (const file of files) {
|
|
280
|
+
const filePath = `${dir}/${file}`;
|
|
281
|
+
const stat = await fs.promises.lstat(filePath);
|
|
282
|
+
if (stat.isDirectory()) {
|
|
283
|
+
await getAllFiles(filePath, fileList);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
fileList.push(filePath);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return fileList;
|
|
290
|
+
}
|
|
291
|
+
// Get all files in the folder
|
|
292
|
+
const allFiles = await getAllFiles(folderPath);
|
|
293
|
+
let filteredFiles = allFiles;
|
|
294
|
+
if (options?.filePattern) {
|
|
295
|
+
try {
|
|
296
|
+
const filePattern = new RegExp(options.filePattern);
|
|
297
|
+
filteredFiles = allFiles.filter((file) => filePattern.test(file));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
// If regex pattern is invalid, ignore the pattern and upload all files
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (filteredFiles.length === 0) {
|
|
304
|
+
throw new Error("The provided folder is empty.");
|
|
335
305
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
306
|
+
// Upload each file to blob storage while maintaining relative paths
|
|
307
|
+
for (const filePath of filteredFiles) {
|
|
308
|
+
// Create blob name as relative path from the base folder
|
|
309
|
+
const relativePath = nodePath.relative(folderPath, filePath).split(nodePath.sep).join("/");
|
|
310
|
+
logger.verbose(`[uploadFolderAndCreate] Start uploading file '${filePath}' as blob '${relativePath}'`);
|
|
311
|
+
// Get a block blob client for the relative path
|
|
312
|
+
const blobClient = containerClient.getBlockBlobClient(relativePath);
|
|
313
|
+
// Upload the file using a readable stream for better performance
|
|
314
|
+
const fileStream = fs.createReadStream(filePath);
|
|
315
|
+
await blobClient.uploadStream(fileStream);
|
|
316
|
+
logger.verbose(`[uploadFolderAndCreate] Done uploading file '${filePath}' as blob '${relativePath}'`);
|
|
345
317
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
);
|
|
355
|
-
const blobClient = containerClient.getBlockBlobClient(relativePath);
|
|
356
|
-
const fileStream = fs.createReadStream(filePath);
|
|
357
|
-
await blobClient.uploadStream(fileStream);
|
|
358
|
-
console.debug(
|
|
359
|
-
`[uploadFolderAndCreate] Done uploading file '${filePath}' as blob '${relativePath}'`
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
const datasetVersion = await createOrUpdate(context, name, outputVersion, {
|
|
363
|
-
name,
|
|
364
|
-
version: outputVersion,
|
|
365
|
-
type: "uri_folder",
|
|
366
|
-
dataUri: containerClient.url
|
|
367
|
-
});
|
|
368
|
-
return datasetVersion;
|
|
318
|
+
// Create dataset version that references this folder
|
|
319
|
+
const datasetVersion = await createOrUpdate(context, name, outputVersion, {
|
|
320
|
+
name: name,
|
|
321
|
+
version: outputVersion,
|
|
322
|
+
type: "uri_folder",
|
|
323
|
+
dataUri: containerClient.url,
|
|
324
|
+
});
|
|
325
|
+
return datasetVersion;
|
|
369
326
|
}
|
|
370
|
-
|
|
371
|
-
$delete,
|
|
372
|
-
_$deleteDeserialize,
|
|
373
|
-
_$deleteSend,
|
|
374
|
-
_createOrUpdateDeserialize,
|
|
375
|
-
_createOrUpdateSend,
|
|
376
|
-
_getCredentialsDeserialize,
|
|
377
|
-
_getCredentialsSend,
|
|
378
|
-
_getDeserialize,
|
|
379
|
-
_getSend,
|
|
380
|
-
_listDeserialize,
|
|
381
|
-
_listSend,
|
|
382
|
-
_listVersionsDeserialize,
|
|
383
|
-
_listVersionsSend,
|
|
384
|
-
_pendingUploadDeserialize,
|
|
385
|
-
_pendingUploadSend,
|
|
386
|
-
createOrUpdate,
|
|
387
|
-
get,
|
|
388
|
-
getCredentials,
|
|
389
|
-
list,
|
|
390
|
-
listVersions,
|
|
391
|
-
pendingUpload,
|
|
392
|
-
uploadFile,
|
|
393
|
-
uploadFolder
|
|
394
|
-
};
|
|
327
|
+
//# sourceMappingURL=operations.js.map
|