@uipath/maestro-sdk 1.207.0-preview.338 → 1.207.0-preview.339

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.
@@ -1121,7 +1121,7 @@ var init_package = __esm(() => {
1121
1121
  name: "@uipath/integrationservice-sdk",
1122
1122
  author: "UiPath",
1123
1123
  license: "SEE LICENSE IN LICENSE.txt",
1124
- version: "1.207.0-preview.338",
1124
+ version: "1.207.0-preview.339",
1125
1125
  repository: {
1126
1126
  type: "git",
1127
1127
  url: "https://github.com/UiPath/cli.git",
@@ -24224,6 +24224,131 @@ var init_models3 = __esm(() => {
24224
24224
  });
24225
24225
  // ../packager/packager-core/src/package-descriptor/index.ts
24226
24226
  var init_package_descriptor = () => {};
24227
+
24228
+ // ../packager/packager-core/src/resource-declarations/languages.ts
24229
+ function resourceDeclarationsPaths(language) {
24230
+ const name = RESOURCE_DECLARATIONS_FILE_NAMES[language];
24231
+ return [name, `src/${name}`];
24232
+ }
24233
+ var RESOURCE_DECLARATIONS_FILE_NAMES;
24234
+ var init_languages = __esm(() => {
24235
+ RESOURCE_DECLARATIONS_FILE_NAMES = {
24236
+ typescript: "uipath_resources.ts",
24237
+ python: "uipath_resources.py"
24238
+ };
24239
+ });
24240
+
24241
+ // ../packager/packager-core/src/resource-declarations/scanner.ts
24242
+ var closingIndexOf;
24243
+ var init_scanner = __esm(() => {
24244
+ closingIndexOf = new Map;
24245
+ });
24246
+
24247
+ // ../packager/packager-core/src/resource-declarations/declarations.ts
24248
+ var RESOURCE_DECLARATIONS_FILE_NAME, RESOURCE_DECLARATIONS_PATHS, MAX_RESOURCE_DECLARATIONS_LENGTH;
24249
+ var init_declarations = __esm(() => {
24250
+ init_languages();
24251
+ init_scanner();
24252
+ RESOURCE_DECLARATIONS_FILE_NAME = RESOURCE_DECLARATIONS_FILE_NAMES.typescript;
24253
+ RESOURCE_DECLARATIONS_PATHS = resourceDeclarationsPaths("typescript");
24254
+ MAX_RESOURCE_DECLARATIONS_LENGTH = 1024 * 1024;
24255
+ });
24256
+
24257
+ // ../packager/packager-core/src/resource-declarations/bindings.ts
24258
+ var init_bindings = __esm(() => {
24259
+ init_declarations();
24260
+ });
24261
+
24262
+ // ../packager/packager-core/src/resource-declarations/editor.ts
24263
+ var RESERVED_IDENTIFIERS, SUB_TYPES_BY_KIND;
24264
+ var init_editor = __esm(() => {
24265
+ init_bindings();
24266
+ init_declarations();
24267
+ init_scanner();
24268
+ RESERVED_IDENTIFIERS = new Set([
24269
+ "constructor",
24270
+ "prototype",
24271
+ "name",
24272
+ "length",
24273
+ "caller",
24274
+ "arguments"
24275
+ ]);
24276
+ SUB_TYPES_BY_KIND = {
24277
+ asset: new Set(["text", "integer", "bool", "credential", "secret", "json"]),
24278
+ bucket: new Set(["orchestrator", "amazon", "azure"])
24279
+ };
24280
+ });
24281
+
24282
+ // ../packager/packager-core/src/resource-declarations/python.ts
24283
+ var PYTHON_KEYWORDS;
24284
+ var init_python = __esm(() => {
24285
+ init_bindings();
24286
+ init_declarations();
24287
+ init_editor();
24288
+ init_languages();
24289
+ init_scanner();
24290
+ PYTHON_KEYWORDS = new Set([
24291
+ "and",
24292
+ "as",
24293
+ "assert",
24294
+ "async",
24295
+ "await",
24296
+ "break",
24297
+ "class",
24298
+ "continue",
24299
+ "def",
24300
+ "del",
24301
+ "elif",
24302
+ "else",
24303
+ "except",
24304
+ "finally",
24305
+ "for",
24306
+ "from",
24307
+ "global",
24308
+ "if",
24309
+ "import",
24310
+ "in",
24311
+ "is",
24312
+ "lambda",
24313
+ "nonlocal",
24314
+ "not",
24315
+ "or",
24316
+ "pass",
24317
+ "raise",
24318
+ "return",
24319
+ "try",
24320
+ "while",
24321
+ "with",
24322
+ "yield"
24323
+ ]);
24324
+ });
24325
+
24326
+ // ../packager/packager-core/src/resource-declarations/source.ts
24327
+ var init_source = __esm(() => {
24328
+ init_bindings();
24329
+ init_declarations();
24330
+ init_editor();
24331
+ init_languages();
24332
+ init_python();
24333
+ });
24334
+
24335
+ // ../packager/packager-core/src/resource-declarations/project.ts
24336
+ var init_project = __esm(() => {
24337
+ init_bindings();
24338
+ init_declarations();
24339
+ init_source();
24340
+ });
24341
+
24342
+ // ../packager/packager-core/src/resource-declarations/index.ts
24343
+ var init_resource_declarations = __esm(() => {
24344
+ init_bindings();
24345
+ init_declarations();
24346
+ init_editor();
24347
+ init_languages();
24348
+ init_project();
24349
+ init_python();
24350
+ init_source();
24351
+ });
24227
24352
  // ../packager/packager-core/src/services/project-id.ts
24228
24353
  var init_project_id = () => {};
24229
24354
 
@@ -24319,6 +24444,7 @@ var init_src5 = __esm(() => {
24319
24444
  init_i18n();
24320
24445
  init_models3();
24321
24446
  init_package_descriptor();
24447
+ init_resource_declarations();
24322
24448
  init_services();
24323
24449
  });
24324
24450
 
@@ -31089,7 +31215,7 @@ var init_binding_overwrites_mapping_handler = __esm(() => {
31089
31215
  });
31090
31216
 
31091
31217
  // ../../node_modules/@uipath/resource-builder-sdk/dist/bindings/index.js
31092
- var init_bindings = __esm(() => {
31218
+ var init_bindings2 = __esm(() => {
31093
31219
  init_models5();
31094
31220
  init_bindings_metadata_serializer();
31095
31221
  init_bindings_requests();
@@ -32251,7 +32377,7 @@ var init_solution_builder = __esm(() => {
32251
32377
  init_detach_resource_file_command();
32252
32378
  init_exceptions();
32253
32379
  init_internal();
32254
- init_bindings();
32380
+ init_bindings2();
32255
32381
  init_solution();
32256
32382
  SolutionBuilder = class SolutionBuilder {
32257
32383
  dispose() {
@@ -43936,7 +44062,7 @@ function isGuid3(value) {
43936
44062
  }
43937
44063
  var BINDINGS_RESOLUTION_BATCH_SIZE = 10;
43938
44064
  var init_get_exportable_items_based_on_bindings_handler = __esm(() => {
43939
- init_bindings();
44065
+ init_bindings2();
43940
44066
  init_resource_subtype_mapper();
43941
44067
  init_exceptions();
43942
44068
  });
@@ -45548,7 +45674,7 @@ var init_container = __esm(() => {
45548
45674
  init_mediator2();
45549
45675
  init_resource_builder();
45550
45676
  init_handlers();
45551
- init_bindings();
45677
+ init_bindings2();
45552
45678
  init_solution();
45553
45679
  init_feature_flag_provider();
45554
45680
  init_clients();
@@ -51814,152 +51940,14 @@ var init_local_resource_matcher = __esm(() => {
51814
51940
  ORPHAN_CHECKED_KINDS = new Set(["process", "app"]);
51815
51941
  });
51816
51942
 
51817
- // ../solution-sdk/src/resources/services/project-artifacts-service.ts
51818
- async function addProjectArtifactsToSolutionAsync(options) {
51819
- const error = await createProjectInSolutionBuilder(options.solutionDir, options.projectId, options.projectName, normalizeProjectType(options.projectType), options.projectSubType);
51820
- return error ? artifactFailure(options, error) : { Created: true };
51821
- }
51822
- function artifactFailure(options, error) {
51823
- logger.warn(`Solution artifact-resource generation failed for project "${options.projectName}": ${error.message}. ` + "The project was created and registered, but 'uip solution pack' may omit its resource. " + "Re-run init with --force to retry, or run 'uip solution projects add' to finish setup.");
51824
- return { Created: false, Error: error.message };
51825
- }
51826
- var init_project_artifacts_service = __esm(() => {
51827
- init_src4();
51828
- init_solution_file();
51829
- init_project_utils();
51830
- });
51831
-
51832
- // ../solution-sdk/src/resources/services/project-template-types.ts
51833
- function hasBareTemplateRow(projectType) {
51834
- reader ??= new EmbeddedProjectConfigurationReader;
51835
- return reader.getTemplateResourcesByType(projectType, undefined, false).length > 0;
51836
- }
51837
- function hasAnyTemplateRow(projectType) {
51838
- reader ??= new EmbeddedProjectConfigurationReader;
51839
- const wanted = projectType.toLowerCase();
51840
- return Object.keys(reader.getAll()).some((row) => {
51841
- const key = row.toLowerCase();
51842
- return key === wanted || key.startsWith(`${wanted}_`);
51843
- });
51844
- }
51845
- var reader;
51846
- var init_project_template_types = __esm(() => {
51847
- init_config2();
51943
+ // ../../node_modules/@uipath/resource-builder-sdk/dist/entries/bindings.js
51944
+ var init_bindings3 = __esm(() => {
51945
+ init_bindings2();
51848
51946
  });
51849
51947
 
51850
- // ../solution-sdk/src/resources/services/remote-resources.ts
51851
- function getRemoteResourceClients(services) {
51852
- return {
51853
- catalog: services.container.resolve(Tokens.IResourceCatalogClientProxy),
51854
- importer: services.container.resolve(Tokens.IImportResourceHelper)
51855
- };
51856
- }
51857
- async function findCatalogEntityAsync(catalog, query, match) {
51858
- let pageCursor;
51859
- do {
51860
- const page = await catalog.searchFolderEntities({
51861
- ...query,
51862
- pageSize: 100,
51863
- pageCursor
51864
- });
51865
- const found = (page.items ?? []).find(match);
51866
- if (found) {
51867
- return found;
51868
- }
51869
- pageCursor = page.nextPage ?? undefined;
51870
- } while (pageCursor);
51871
- return;
51872
- }
51873
- async function findCatalogEntitiesAsync(catalog, query, match) {
51874
- const found = [];
51875
- let pageCursor;
51876
- do {
51877
- const page = await catalog.searchFolderEntities({
51878
- ...query,
51879
- pageSize: 100,
51880
- pageCursor
51881
- });
51882
- found.push(...(page.items ?? []).filter(match));
51883
- pageCursor = page.nextPage ?? undefined;
51884
- } while (pageCursor);
51885
- return found;
51886
- }
51887
- function toResourceReference(entity) {
51888
- return toCatalogReference({
51889
- kind: entity.entityType ?? "",
51890
- type: entity.entitySubType ?? undefined,
51891
- key: entity.entityKey ?? "",
51892
- name: entity.entityName ?? undefined,
51893
- folderPath: entity.fullyQualifiedName ?? undefined,
51894
- folderKey: entity.folderKey ?? undefined
51895
- });
51896
- }
51897
- function toCatalogReference(reference) {
51898
- const { folderPath, folderKey, ...rest } = reference;
51899
- return {
51900
- ...rest,
51901
- folder: folderPath ? { fullyQualifiedName: folderPath, folderKey } : undefined
51902
- };
51903
- }
51904
- async function exportResourceDefinitionAsync(importer, reference) {
51905
- const [error, payload] = await catchError2(importer.exportResourceAsync(reference));
51906
- if (error) {
51907
- throw withExportStatus(error);
51908
- }
51909
- return payload.resourceDefinitions.find((d) => d.key === reference.key);
51910
- }
51911
- function withExportStatus(error) {
51912
- if (!(error instanceof Error) || !("exceptionData" in error)) {
51913
- return error;
51914
- }
51915
- const data = error.exceptionData;
51916
- const text = typeof data === "object" && data !== null ? data.errorMessage : undefined;
51917
- const match = typeof text === "string" ? /^HTTP (\d{3})\b/.exec(text) : null;
51918
- return match ? new ResourceExportError(error.message, Number(match[1]), error) : error;
51919
- }
51920
- function readSpecProperty(spec, name) {
51921
- if (!spec) {
51922
- return;
51923
- }
51924
- if (spec[name] !== undefined) {
51925
- return spec[name];
51926
- }
51927
- const lower = name.toLowerCase();
51928
- const key = Object.keys(spec).find((k) => k.toLowerCase() === lower);
51929
- return key === undefined ? undefined : spec[key];
51930
- }
51931
- function readSpecEntryPoints(spec) {
51932
- const entryPoints = parseJsonString(readSpecProperty(spec, "entryPoints"));
51933
- if (!Array.isArray(entryPoints) || !entryPoints.every((entry) => entry !== null && typeof entry === "object")) {
51934
- return;
51935
- }
51936
- return entryPoints.map((entry) => ({
51937
- UniqueId: String(readSpecProperty(entry, "uniqueId") ?? ""),
51938
- Path: String(readSpecProperty(entry, "path") ?? ""),
51939
- DisplayName: String(readSpecProperty(entry, "displayName") ?? ""),
51940
- InputArguments: readSpecProperty(entry, "inputArguments"),
51941
- OutputArguments: readSpecProperty(entry, "outputArguments")
51942
- }));
51943
- }
51944
- function parseJsonString(raw) {
51945
- if (typeof raw !== "string") {
51946
- return raw;
51947
- }
51948
- const [error, parsed] = catchError2(() => JSON.parse(raw));
51949
- return error ? undefined : parsed;
51950
- }
51951
- var ResourceExportError;
51952
- var init_remote_resources = __esm(() => {
51953
- init_src4();
51954
- init_service_tokens();
51955
- ResourceExportError = class ResourceExportError extends Error {
51956
- status;
51957
- constructor(message, status, cause) {
51958
- super(message, { cause });
51959
- this.status = status;
51960
- this.name = "ResourceExportError";
51961
- }
51962
- };
51948
+ // ../../node_modules/@uipath/resource-builder-sdk/dist/mappings/index.js
51949
+ var init_mappings = __esm(() => {
51950
+ init_resource_subtype_mapper();
51963
51951
  });
51964
51952
 
51965
51953
  // ../solution-sdk/src/resources/services/resource-casing.ts
@@ -52128,186 +52116,6 @@ var init_resource_casing = __esm(() => {
52128
52116
  init_src2();
52129
52117
  });
52130
52118
 
52131
- // ../solution-sdk/src/resources/services/resource-configurations.ts
52132
- function isResourceKeyNotFound(error, resourceKey) {
52133
- if (!(error instanceof Error))
52134
- return false;
52135
- const typed = error;
52136
- const sameKey = (key) => key !== undefined && key.toLowerCase() === resourceKey.toLowerCase();
52137
- if (typeof typed.resourceType === "string" && typeof typed.resourceKey === "string") {
52138
- return ROOT_RESOURCE_TYPES.has(typed.resourceType.toLowerCase()) && sameKey(typed.resourceKey);
52139
- }
52140
- return sameKey(KEY_NOT_FOUND.exec(error.message.trim())?.[1]);
52141
- }
52142
- async function refreshArtefactSpecsAsync(builder, configurations) {
52143
- const resources = new Map;
52144
- const [loadError, solution] = await catchError2(builder.context.loadAsync());
52145
- if (loadError || !solution)
52146
- return resources;
52147
- for (const configuration of configurations) {
52148
- const resource = solution.resources.find((r) => r.key === configuration?.key);
52149
- if (!resource)
52150
- continue;
52151
- resources.set(resource.key, resource);
52152
- if (!resource.projectKey)
52153
- continue;
52154
- configuration.spec = await applyEntryPointEnhancementAsync(builder.context, resource, configuration.spec ?? {});
52155
- }
52156
- return resources;
52157
- }
52158
- async function exportResourceConfigurationsAsync(services, resourceKey, hint = {}) {
52159
- const { catalog, importer } = getRemoteResourceClients(services);
52160
- const byKey = (item) => item.entityKey === resourceKey;
52161
- const entity = (hint.name ? await findCatalogEntityAsync(catalog, { name: hint.name }, byKey) : undefined) ?? await findCatalogEntityAsync(catalog, {}, byKey);
52162
- if (!entity) {
52163
- throw new Error(`Resource '${resourceKey}' was not found in the solution or in the resource catalog`);
52164
- }
52165
- const payload = await importer.exportResourceAsync(toResourceReference(entity));
52166
- const definitions = payload.resourceDefinitions ?? [];
52167
- if (definitions.length === 0) {
52168
- throw new Error(`FPS export for '${resourceKey}' returned no resource definitions`);
52169
- }
52170
- return {
52171
- resources: definitions.map((d) => ({
52172
- key: d.key ?? "",
52173
- spec: d.spec ?? {},
52174
- locks: d.locks ?? [],
52175
- apiVersion: d.apiVersion,
52176
- isOverridable: d.isOverridable,
52177
- name: d.name ?? "",
52178
- kind: d.kind ?? "",
52179
- dependencies: (d.dependencies ?? []).map((dep) => ({
52180
- kind: dep.kind ?? "",
52181
- name: dep.name ?? ""
52182
- }))
52183
- }))
52184
- };
52185
- }
52186
- async function readLocalAsync(builder, resourceKey, read) {
52187
- if (!builder)
52188
- return;
52189
- const [error, value] = await catchError2(read(builder));
52190
- if (!error)
52191
- return { builder, value };
52192
- if (isResourceKeyNotFound(error, resourceKey))
52193
- return;
52194
- throw error;
52195
- }
52196
- async function readResourceConfigurationsAsync(services, builder, resourceKey, hint = {}) {
52197
- const local = await readLocalAsync(builder, resourceKey, (b) => b.getAllConfigurationsAsync(resourceKey));
52198
- if (!local) {
52199
- return exportResourceConfigurationsAsync(services, resourceKey, hint);
52200
- }
52201
- await refreshArtefactSpecsAsync(local.builder, local.value?.resources ?? []);
52202
- return local.value;
52203
- }
52204
- async function readResourceConfigurationAsync(services, builder, resourceKey) {
52205
- const local = await readLocalAsync(builder, resourceKey, (b) => b.getConfigurationAsync(resourceKey));
52206
- if (local) {
52207
- const configuration = local.value;
52208
- const resources = await refreshArtefactSpecsAsync(local.builder, [
52209
- configuration
52210
- ]);
52211
- return { configuration, resource: resources.get(configuration.key) };
52212
- }
52213
- const { resources } = await exportResourceConfigurationsAsync(services, resourceKey);
52214
- const primary = resources.find((r) => r.key === resourceKey) ?? resources[0];
52215
- const { key, spec, locks, apiVersion, isOverridable } = primary;
52216
- return { configuration: { key, spec, locks, apiVersion, isOverridable } };
52217
- }
52218
- var ROOT_RESOURCE_TYPES, KEY_NOT_FOUND;
52219
- var init_resource_configurations = __esm(() => {
52220
- init_src4();
52221
- init_entry_point_spec_enhancer();
52222
- init_remote_resources();
52223
- ROOT_RESOURCE_TYPES = new Set(["resource", "solutionresource"]);
52224
- KEY_NOT_FOUND = /^(?:Solution)?Resource with key '([^']+)' was not found$/i;
52225
- });
52226
-
52227
- // ../solution-sdk/src/resources/services/resource-lookup.ts
52228
- async function findResourcesByNameAsync(services, builder, { kind, name, subTypes, folderKey }) {
52229
- const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
52230
- const ofSubType = (type) => subTypes === undefined || subTypes.some((t) => same(type, t));
52231
- if (builder) {
52232
- const solution = await builder.context.loadAsync();
52233
- const local = solution.resources.filter((r) => same(r.kind, kind) && same(r.name, name) && ofSubType(r.type)).map((r) => ({
52234
- key: r.key,
52235
- local: true,
52236
- folderPath: r.folders?.[0]?.fullyQualifiedName
52237
- }));
52238
- if (local.length > 0)
52239
- return local;
52240
- }
52241
- const { catalog } = getRemoteResourceClients(services);
52242
- const rows = await findCatalogEntitiesAsync(catalog, { name, entityTypes: [kind] }, (row) => same(row.entityType, kind) && same(row.entityName, name) && ofSubType(row.entitySubType) && (folderKey === undefined || same(row.folderKey, folderKey)));
52243
- return rows.map((row) => ({
52244
- key: row.entityKey ?? "",
52245
- local: false,
52246
- folderPath: row.fullyQualifiedName ?? undefined,
52247
- folderKey: row.folderKey ?? undefined
52248
- }));
52249
- }
52250
- var init_resource_lookup = __esm(() => {
52251
- init_remote_resources();
52252
- });
52253
-
52254
- // ../solution-sdk/src/resources/services/resource-name.ts
52255
- function hasControlChar(value) {
52256
- for (let i = 0;i < value.length; i++) {
52257
- if (value.charCodeAt(i) < 32)
52258
- return true;
52259
- }
52260
- return false;
52261
- }
52262
- function hasUnsafeNameChars(name) {
52263
- return UNSAFE_NAME_CHARS.test(name) || hasControlChar(name);
52264
- }
52265
- function validateResourceName(name, options = {}) {
52266
- const optionName = options.optionName ?? "--name";
52267
- if (name.trim() === "") {
52268
- return {
52269
- ok: false,
52270
- message: `${optionName} must not be blank`,
52271
- instructions: "Pass a non-empty resource name."
52272
- };
52273
- }
52274
- if (name.length > MAX_RESOURCE_NAME_LENGTH) {
52275
- return {
52276
- ok: false,
52277
- message: `${optionName} exceeds the ${MAX_RESOURCE_NAME_LENGTH}-character limit (got ${name.length})`,
52278
- instructions: "Shorten the resource name. Orchestrator name limits are kind-specific (queues cap at 50, assets at 256)."
52279
- };
52280
- }
52281
- if (hasUnsafeNameChars(name)) {
52282
- return {
52283
- ok: false,
52284
- message: `${optionName} contains unsafe characters`,
52285
- instructions: 'Resource names cannot contain path separators (/, \\), control characters, or any of: : * ? " < > |'
52286
- };
52287
- }
52288
- return { ok: true };
52289
- }
52290
- function assertValidResourceName(name, options = {}) {
52291
- const result = validateResourceName(name, options);
52292
- if (!result.ok) {
52293
- throw new Error(`${result.message}. ${result.instructions}`);
52294
- }
52295
- }
52296
- var MAX_RESOURCE_NAME_LENGTH = 256, UNSAFE_NAME_CHARS;
52297
- var init_resource_name = __esm(() => {
52298
- UNSAFE_NAME_CHARS = /[\\/:*?"<>|]/;
52299
- });
52300
-
52301
- // ../../node_modules/@uipath/resource-builder-sdk/dist/entries/bindings.js
52302
- var init_bindings2 = __esm(() => {
52303
- init_bindings();
52304
- });
52305
-
52306
- // ../../node_modules/@uipath/resource-builder-sdk/dist/mappings/index.js
52307
- var init_mappings = __esm(() => {
52308
- init_resource_subtype_mapper();
52309
- });
52310
-
52311
52119
  // ../solution-sdk/src/resources/services/sync-resources-from-bindings.ts
52312
52120
  function placeholderForType(type) {
52313
52121
  switch ((type ?? "string").toLowerCase()) {
@@ -52399,6 +52207,54 @@ function sameResourceSubtype(a, b) {
52399
52207
  function findSubtypeEntry(list, type) {
52400
52208
  return list.find((r) => !!r.type && sameResourceSubtype(r.type, type));
52401
52209
  }
52210
+ function metadataString(metadata, name) {
52211
+ if (!metadata || typeof metadata !== "object")
52212
+ return;
52213
+ for (const [key, value] of Object.entries(metadata)) {
52214
+ if (key.toLowerCase() === name.toLowerCase() && typeof value === "string" && value.trim() !== "") {
52215
+ return value;
52216
+ }
52217
+ }
52218
+ return;
52219
+ }
52220
+ function declaredSubTypes(decoded, resources) {
52221
+ const subTypes = new Map;
52222
+ let document2;
52223
+ try {
52224
+ document2 = JSON.parse(decoded);
52225
+ } catch {
52226
+ return subTypes;
52227
+ }
52228
+ const entries = document2?.resources;
52229
+ if (!Array.isArray(entries))
52230
+ return subTypes;
52231
+ const byBinding = new Map;
52232
+ for (const entry of entries) {
52233
+ if (!entry || typeof entry !== "object")
52234
+ continue;
52235
+ const { resource, key, metadata } = entry;
52236
+ if (typeof resource !== "string" || typeof key !== "string" || !SUBTYPED_BINDING_KINDS.has(resource.toLowerCase())) {
52237
+ continue;
52238
+ }
52239
+ const subType = metadataString(metadata, "SubType");
52240
+ if (subType)
52241
+ byBinding.set(`${resource}\x00${key}`, subType);
52242
+ }
52243
+ for (const resource of resources) {
52244
+ const subType = byBinding.get(`${resource.originalResourceType}\x00${resource.bindingKey ?? ""}`);
52245
+ if (subType)
52246
+ subTypes.set(resource, subType);
52247
+ }
52248
+ return subTypes;
52249
+ }
52250
+ async function resolveDeclaredKindMetadata(resolveKindMetadata, kind, type, declaredSubType) {
52251
+ if (type === undefined && declaredSubType !== undefined) {
52252
+ const declared = await resolveKindMetadata(kind, declaredSubType);
52253
+ if (declared?.typeMatched)
52254
+ return declared;
52255
+ }
52256
+ return resolveKindMetadata(kind, type);
52257
+ }
52402
52258
  function resolveBindingResourceIdentity(binding) {
52403
52259
  switch (binding.resourceType) {
52404
52260
  case models_BindingsResourceType.TimeTrigger:
@@ -52435,7 +52291,11 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52435
52291
  return result;
52436
52292
  }
52437
52293
  const serializer = services.container.resolve(Tokens.IBindingsMetadataSerializer);
52438
- const { bindings: allBindings, parseErrors } = await collectBindings(bindingsJsonFallbackDirs, serializer, bindingSources(solutionDir, paths, uipxProjects, projectBindings));
52294
+ const {
52295
+ bindings: allBindings,
52296
+ parseErrors,
52297
+ subTypes
52298
+ } = await collectBindings(bindingsJsonFallbackDirs, serializer, bindingSources(solutionDir, paths, uipxProjects, projectBindings));
52439
52299
  if (parseErrors.length > 0) {
52440
52300
  const detail = parseErrors.map((e) => `${e.path}: ${e.reason}`).join("; ");
52441
52301
  throw new Error(`Invalid bindings file — ${detail}`);
@@ -52473,7 +52333,29 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52473
52333
  const resolvedKeys = new Set;
52474
52334
  const overwrittenKeys = new Set;
52475
52335
  const bindingKey = (kind, name) => `${kind}:${name ?? ""}`.toLowerCase();
52476
- const selfProvisionedKeys = new Set((selfProvisioned ?? []).map((r) => bindingKey(r.kind, r.name)));
52336
+ const anyFolderSelfProvisioned = new Set;
52337
+ const solutionFolderSelfProvisioned = new Set;
52338
+ for (const r of selfProvisioned ?? []) {
52339
+ (r.solutionFolderOnly ? solutionFolderSelfProvisioned : anyFolderSelfProvisioned).add(bindingKey(r.kind, r.name));
52340
+ }
52341
+ const isSelfProvisioned = (kind, name, folderPath) => {
52342
+ const key = bindingKey(kind, name);
52343
+ return anyFolderSelfProvisioned.has(key) || !normalizeFolderPath(folderPath) && solutionFolderSelfProvisioned.has(key);
52344
+ };
52345
+ const importedThisRun = new Set;
52346
+ let referencedKeys;
52347
+ const coveringResource = async (resources, kind, name, folderPath, selfProvisioned) => {
52348
+ const match = findMatchingLocalResource(resources, kind, name, folderPath);
52349
+ if (!match || !selfProvisioned)
52350
+ return match;
52351
+ referencedKeys ??= readReferencedResourceKeys(services, builder);
52352
+ const referenced = await referencedKeys;
52353
+ const owned = resources.filter((r) => {
52354
+ const key = r.key?.toLowerCase();
52355
+ return !key || !importedThisRun.has(key) && !referenced.has(key);
52356
+ });
52357
+ return findMatchingLocalResource(owned, kind, name, folderPath);
52358
+ };
52477
52359
  const recordUnchecked = async (error, kind, name, directCloudKey) => {
52478
52360
  if (error) {
52479
52361
  const failure = classifyCatalogFailure(error);
@@ -52501,7 +52383,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52501
52383
  continue;
52502
52384
  }
52503
52385
  const isConnection = isConnectionBinding(binding);
52504
- const metadata = await resolveKindMetadata(kind, identity.type);
52386
+ const metadata = await resolveDeclaredKindMetadata(resolveKindMetadata, kind, identity.type, subTypes.get(binding));
52505
52387
  const name = getResourceName(binding);
52506
52388
  const folderPath = getFolderPathProperty(binding).defaultValue;
52507
52389
  const directCloudKey = isConnection ? getConnectionKey(binding) : undefined;
@@ -52511,7 +52393,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52511
52393
  if (!isConnection && !name) {
52512
52394
  continue;
52513
52395
  }
52514
- if (!isConnection && !normalizeFolderPath(folderPath) && findMatchingLocalResource(solution.resources ?? [], kind, name, folderPath)) {
52396
+ const selfProvisioned = !isConnection && isSelfProvisioned(kind, name, folderPath);
52397
+ if (!isConnection && !normalizeFolderPath(folderPath) && await coveringResource(solution.resources ?? [], kind, name, folderPath, selfProvisioned)) {
52515
52398
  result.skipped++;
52516
52399
  logger.info(`Skipping ${kind} "${name}" — an in-solution resource already covers this solution-relative binding`);
52517
52400
  continue;
@@ -52521,7 +52404,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52521
52404
  logger.info(`Skipping ${kind} "${name}" — the solution provisions this project itself; its member declaration covers the binding`);
52522
52405
  continue;
52523
52406
  }
52524
- if (!isConnection && selfProvisionedKeys.has(bindingKey(kind, name))) {
52407
+ if (selfProvisioned) {
52525
52408
  virtualCandidates.push({
52526
52409
  binding,
52527
52410
  kind,
@@ -52529,7 +52412,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52529
52412
  metadata,
52530
52413
  name,
52531
52414
  folderPath,
52532
- catalogMiss: false
52415
+ catalogMiss: false,
52416
+ selfProvisioned
52533
52417
  });
52534
52418
  continue;
52535
52419
  }
@@ -52552,7 +52436,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52552
52436
  metadata,
52553
52437
  name,
52554
52438
  folderPath,
52555
- catalogMiss: true
52439
+ catalogMiss: true,
52440
+ selfProvisioned: false
52556
52441
  });
52557
52442
  continue;
52558
52443
  }
@@ -52581,6 +52466,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52581
52466
  if (rcsMatch.key) {
52582
52467
  knownResourceKeys.add(rcsMatch.key.toLowerCase());
52583
52468
  overwrittenKeys.add(rcsMatch.key.toLowerCase());
52469
+ importedThisRun.add(rcsMatch.key.toLowerCase());
52584
52470
  }
52585
52471
  result.imported++;
52586
52472
  logger.info(`Imported ${kind} "${rcsMatch.name}" (key: ${rcsMatch.key}) into solution`);
@@ -52607,7 +52493,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52607
52493
  metadata,
52608
52494
  name,
52609
52495
  folderPath,
52610
- catalogMiss: false
52496
+ catalogMiss: false,
52497
+ selfProvisioned: false
52611
52498
  });
52612
52499
  }
52613
52500
  const virtualCandidatesSeen = new Set;
@@ -52619,7 +52506,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
52619
52506
  return true;
52620
52507
  });
52621
52508
  for (const candidate of dedupedVirtuals) {
52622
- const [syncError, created] = await catchError2(createVirtualForBinding(builder, candidate.binding, candidate.kind, candidate.type, candidate.metadata, candidate.name, candidate.folderPath, result, candidate.catalogMiss));
52509
+ const [syncError, created] = await catchError2(createVirtualForBinding(builder, candidate.binding, candidate.kind, candidate.type, candidate.metadata, candidate.name, candidate.folderPath, result, candidate.catalogMiss, (resources) => coveringResource(resources, candidate.kind, candidate.name, undefined, candidate.selfProvisioned)));
52623
52510
  if (syncError) {
52624
52511
  logger.warn(`Failed to create virtual ${candidate.kind}/${candidate.name}: ${syncError.message}`);
52625
52512
  } else if (created) {
@@ -52698,6 +52585,15 @@ async function reportOrphanedDeclarations(services, builder, bindings, result) {
52698
52585
  logger.warn(warning);
52699
52586
  }
52700
52587
  }
52588
+ async function readReferencedResourceKeys(services, builder) {
52589
+ const overwrites = services.container.resolve(Tokens.IResourceOverwritesService);
52590
+ const [error, entries] = await catchError2(overwrites.getTenantResourceOverwritesAsync(builder.context));
52591
+ if (error) {
52592
+ logger.debug(`Could not read the resource overwrites, so no root resource is known to be an import: ${error.message}`);
52593
+ return new Set;
52594
+ }
52595
+ return new Set(entries.filter((e) => String(e.overwrite?.type) === REFERENCE_OVERWRITE).map((e) => e.solutionResourceKey.toLowerCase()));
52596
+ }
52701
52597
  async function isUncheckedBindingCovered(builder, knownResourceKeys, kind, name, directCloudKey) {
52702
52598
  if (directCloudKey) {
52703
52599
  return knownResourceKeys.has(directCloudKey.toLowerCase());
@@ -52797,10 +52693,10 @@ async function mintVirtualResource(builder, kind, type, name, metadata) {
52797
52693
  }
52798
52694
  return { resource, finalName: uniqueName };
52799
52695
  }
52800
- async function createVirtualForBinding(builder, _binding, kind, type, metadata, name, folderPath, result, catalogMiss) {
52696
+ async function createVirtualForBinding(builder, _binding, kind, type, metadata, name, folderPath, result, catalogMiss, findCovering) {
52801
52697
  const virtualizable = metadata?.virtualizable ?? false;
52802
52698
  const preLoadSolution = await builder.context.loadAsync();
52803
- const alreadyVirtualized = findMatchingLocalResource(preLoadSolution.resources, kind, name, undefined);
52699
+ const alreadyVirtualized = await findCovering(preLoadSolution.resources);
52804
52700
  if (alreadyVirtualized) {
52805
52701
  result.skipped++;
52806
52702
  logger.info(`Skipping virtual ${kind} "${name}" — existing resource "${alreadyVirtualized.name}" in solution_folder already covers this binding (requested folder "${folderPath}")`);
@@ -52862,6 +52758,35 @@ async function findResourceByKeyInRcs(builder, kind, expectedKey, folderPath, pr
52862
52758
  }
52863
52759
  return;
52864
52760
  }
52761
+ async function findResourcesByKeysInRcs(builder, kind, keys) {
52762
+ const wanted = new Set([...keys].map((key) => key.toLowerCase()));
52763
+ const found = new Map;
52764
+ let pageCursor;
52765
+ while (found.size < wanted.size) {
52766
+ const result = await builder.searchResourcesAsync(kind, undefined, undefined, pageCursor, 100, undefined, false);
52767
+ for (const folderResources of result.availableResources) {
52768
+ for (const resource of folderResources.resources) {
52769
+ const key = resource.key.toLowerCase();
52770
+ if (!wanted.has(key) || found.has(key))
52771
+ continue;
52772
+ found.set(key, {
52773
+ key: resource.key,
52774
+ name: resource.name,
52775
+ type: resource.type,
52776
+ folder: {
52777
+ fullyQualifiedName: folderResources.fullyQualifiedName,
52778
+ folderKey: folderResources.key,
52779
+ path: folderResources.path
52780
+ }
52781
+ });
52782
+ }
52783
+ }
52784
+ pageCursor = result.nextPage;
52785
+ if (!pageCursor)
52786
+ break;
52787
+ }
52788
+ return found;
52789
+ }
52865
52790
  async function searchRcsResources(builder, kind, name) {
52866
52791
  const [searchError, matches] = await catchError2(searchRcsResourcesStrict(builder, kind, name));
52867
52792
  if (searchError) {
@@ -53102,6 +53027,17 @@ async function collectBindings(bindingsJsonFallbackDirs, serializer, sources) {
53102
53027
  const fs = getFileSystem();
53103
53028
  const allBindings = [];
53104
53029
  const parseErrors = [];
53030
+ const subTypes = new Map;
53031
+ const collect = (parsed) => {
53032
+ if ("error" in parsed) {
53033
+ parseErrors.push(parsed.error);
53034
+ return;
53035
+ }
53036
+ allBindings.push(...parsed.resources);
53037
+ for (const [binding, subType] of parsed.subTypes) {
53038
+ subTypes.set(binding, subType);
53039
+ }
53040
+ };
53105
53041
  for (const { directory: dir, contribution } of sources) {
53106
53042
  if (contribution) {
53107
53043
  if (contribution.bindings.length === 0)
@@ -53110,10 +53046,7 @@ async function collectBindings(bindingsJsonFallbackDirs, serializer, sources) {
53110
53046
  version: "2.0",
53111
53047
  resources: contribution.bindings
53112
53048
  }), `${dir} (bindings contributed by the project's tool; project ${contribution.projectId})`, serializer);
53113
- if ("error" in parsed)
53114
- parseErrors.push(parsed.error);
53115
- else
53116
- allBindings.push(...parsed.resources);
53049
+ collect(parsed);
53117
53050
  continue;
53118
53051
  }
53119
53052
  const v2Path = fs.path.join(dir, "bindings_v2.json");
@@ -53134,13 +53067,9 @@ async function collectBindings(bindingsJsonFallbackDirs, serializer, sources) {
53134
53067
  });
53135
53068
  continue;
53136
53069
  }
53137
- const parsed = deserializeBindings(new TextDecoder().decode(content), bindingsPath, serializer);
53138
- if ("error" in parsed)
53139
- parseErrors.push(parsed.error);
53140
- else
53141
- allBindings.push(...parsed.resources);
53070
+ collect(deserializeBindings(new TextDecoder().decode(content), bindingsPath, serializer));
53142
53071
  }
53143
- return { bindings: allBindings, parseErrors };
53072
+ return { bindings: allBindings, parseErrors, subTypes };
53144
53073
  }
53145
53074
  function deserializeBindings(decoded, source, serializer) {
53146
53075
  let success;
@@ -53165,7 +53094,8 @@ function deserializeBindings(decoded, source, serializer) {
53165
53094
  }
53166
53095
  };
53167
53096
  }
53168
- return { resources: metadata?.resources ?? [] };
53097
+ const resources = metadata?.resources ?? [];
53098
+ return { resources, subTypes: declaredSubTypes(decoded, resources) };
53169
53099
  }
53170
53100
  async function syncAndLog(solutionDir, projectSubTypes, options) {
53171
53101
  const [syncError, syncResult] = await catchError2(syncResourcesFromBindings(solutionDir, undefined, projectSubTypes, options?.projectBindings, options?.selfProvisioned));
@@ -53185,11 +53115,11 @@ async function syncAndLog(solutionDir, projectSubTypes, options) {
53185
53115
  throw new CatalogLookupError(syncResult.catalogLookupFailure, syncResult.unresolved);
53186
53116
  }
53187
53117
  }
53188
- var TYPE_IS_IDENTITY_REPLACE_OPTIONS, BINDINGS_JSON_FALLBACK_TYPES, IMPLICIT_CONNECTION2 = "ImplicitConnection", OverwriteRefreshError;
53118
+ var TYPE_IS_IDENTITY_REPLACE_OPTIONS, BINDINGS_JSON_FALLBACK_TYPES, IMPLICIT_CONNECTION2 = "ImplicitConnection", OverwriteRefreshError, SUBTYPED_BINDING_KINDS, REFERENCE_OVERWRITE = "Reference";
53189
53119
  var init_sync_resources_from_bindings = __esm(() => {
53190
53120
  init_src4();
53191
53121
  init_src2();
53192
- init_bindings2();
53122
+ init_bindings3();
53193
53123
  init_mappings();
53194
53124
  init_solution2();
53195
53125
  init_service_tokens();
@@ -53206,6 +53136,400 @@ var init_sync_resources_from_bindings = __esm(() => {
53206
53136
  BINDINGS_JSON_FALLBACK_TYPES = new Set(["agent", "function"]);
53207
53137
  OverwriteRefreshError = class OverwriteRefreshError extends Error {
53208
53138
  };
53139
+ SUBTYPED_BINDING_KINDS = new Set([
53140
+ "asset",
53141
+ "bucket"
53142
+ ]);
53143
+ });
53144
+
53145
+ // ../solution-sdk/src/resources/services/imported-resources.ts
53146
+ async function resolveImportedResourcesAsync(services, builder, resources) {
53147
+ const overwrites = await services.container.resolve(Tokens.IResourceOverwritesService).getTenantResourceOverwritesAsync(builder.context);
53148
+ const tenantNames = new Map;
53149
+ for (const entry of overwrites) {
53150
+ if (String(entry.overwrite?.type) !== REFERENCE_OVERWRITE2)
53151
+ continue;
53152
+ tenantNames.set(entry.solutionResourceKey.toLowerCase(), entry.overwrite?.resourceName || undefined);
53153
+ }
53154
+ const resolved = new Map;
53155
+ const unresolved = new Map;
53156
+ const unchecked = new Set;
53157
+ const byKind = new Map;
53158
+ for (const resource of resources) {
53159
+ const key = resource.key?.toLowerCase();
53160
+ if (!key)
53161
+ continue;
53162
+ if (normalizeFolderPath(resource.folders?.[0]?.fullyQualifiedName)) {
53163
+ continue;
53164
+ }
53165
+ const recorded = tenantNames.has(key);
53166
+ if (!recorded && resource.isArtefactResource)
53167
+ continue;
53168
+ const kind = resource.kind ?? "";
53169
+ byKind.set(kind, [...byKind.get(kind) ?? [], { key, recorded }]);
53170
+ }
53171
+ const reportFailed = (entries, reason) => {
53172
+ for (const { key, recorded } of entries) {
53173
+ if (recorded)
53174
+ unresolved.set(key, reason);
53175
+ else
53176
+ unchecked.add(key);
53177
+ }
53178
+ };
53179
+ let failure;
53180
+ for (const [kind, entries] of byKind) {
53181
+ if (failure) {
53182
+ reportFailed(entries, failure);
53183
+ continue;
53184
+ }
53185
+ const [error, matches] = await catchError2(findResourcesByKeysInRcs(builder, kind, entries.map((entry) => entry.key)));
53186
+ if (error) {
53187
+ const reason = `the Resource Catalog could not be searched: ${error.message}`;
53188
+ reportFailed(entries, reason);
53189
+ if (stopsCatalogLookups(classifyCatalogFailure(error))) {
53190
+ failure = reason;
53191
+ }
53192
+ continue;
53193
+ }
53194
+ for (const { key, recorded } of entries) {
53195
+ const match = matches.get(key);
53196
+ if (match?.folder?.fullyQualifiedName) {
53197
+ resolved.set(key, {
53198
+ name: tenantNames.get(key) ?? match.name,
53199
+ folderPath: match.folder.fullyQualifiedName
53200
+ });
53201
+ } else if (recorded) {
53202
+ unresolved.set(key, "the Resource Catalog no longer lists it");
53203
+ }
53204
+ }
53205
+ }
53206
+ return { resolved, unresolved, unchecked };
53207
+ }
53208
+ var REFERENCE_OVERWRITE2 = "Reference";
53209
+ var init_imported_resources = __esm(() => {
53210
+ init_src4();
53211
+ init_service_tokens();
53212
+ init_catalog_lookup_failure();
53213
+ init_local_resource_matcher();
53214
+ init_sync_resources_from_bindings();
53215
+ });
53216
+
53217
+ // ../solution-sdk/src/resources/services/project-artifacts-service.ts
53218
+ async function addProjectArtifactsToSolutionAsync(options) {
53219
+ const error = await createProjectInSolutionBuilder(options.solutionDir, options.projectId, options.projectName, normalizeProjectType(options.projectType), options.projectSubType);
53220
+ return error ? artifactFailure(options, error) : { Created: true };
53221
+ }
53222
+ function artifactFailure(options, error) {
53223
+ logger.warn(`Solution artifact-resource generation failed for project "${options.projectName}": ${error.message}. ` + "The project was created and registered, but 'uip solution pack' may omit its resource. " + "Re-run init with --force to retry, or run 'uip solution projects add' to finish setup.");
53224
+ return { Created: false, Error: error.message };
53225
+ }
53226
+ var init_project_artifacts_service = __esm(() => {
53227
+ init_src4();
53228
+ init_solution_file();
53229
+ init_project_utils();
53230
+ });
53231
+
53232
+ // ../solution-sdk/src/resources/services/project-template-types.ts
53233
+ function hasBareTemplateRow(projectType) {
53234
+ reader ??= new EmbeddedProjectConfigurationReader;
53235
+ return reader.getTemplateResourcesByType(projectType, undefined, false).length > 0;
53236
+ }
53237
+ function hasAnyTemplateRow(projectType) {
53238
+ reader ??= new EmbeddedProjectConfigurationReader;
53239
+ const wanted = projectType.toLowerCase();
53240
+ return Object.keys(reader.getAll()).some((row) => {
53241
+ const key = row.toLowerCase();
53242
+ return key === wanted || key.startsWith(`${wanted}_`);
53243
+ });
53244
+ }
53245
+ var reader;
53246
+ var init_project_template_types = __esm(() => {
53247
+ init_config2();
53248
+ });
53249
+
53250
+ // ../solution-sdk/src/resources/services/remote-resources.ts
53251
+ function getRemoteResourceClients(services) {
53252
+ return {
53253
+ catalog: services.container.resolve(Tokens.IResourceCatalogClientProxy),
53254
+ importer: services.container.resolve(Tokens.IImportResourceHelper)
53255
+ };
53256
+ }
53257
+ async function findCatalogEntityAsync(catalog, query, match) {
53258
+ let pageCursor;
53259
+ do {
53260
+ const page = await catalog.searchFolderEntities({
53261
+ ...query,
53262
+ pageSize: 100,
53263
+ pageCursor
53264
+ });
53265
+ const found = (page.items ?? []).find(match);
53266
+ if (found) {
53267
+ return found;
53268
+ }
53269
+ pageCursor = page.nextPage ?? undefined;
53270
+ } while (pageCursor);
53271
+ return;
53272
+ }
53273
+ async function findCatalogEntitiesAsync(catalog, query, match) {
53274
+ const found = [];
53275
+ let pageCursor;
53276
+ do {
53277
+ const page = await catalog.searchFolderEntities({
53278
+ ...query,
53279
+ pageSize: 100,
53280
+ pageCursor
53281
+ });
53282
+ found.push(...(page.items ?? []).filter(match));
53283
+ pageCursor = page.nextPage ?? undefined;
53284
+ } while (pageCursor);
53285
+ return found;
53286
+ }
53287
+ function toResourceReference(entity) {
53288
+ return toCatalogReference({
53289
+ kind: entity.entityType ?? "",
53290
+ type: entity.entitySubType ?? undefined,
53291
+ key: entity.entityKey ?? "",
53292
+ name: entity.entityName ?? undefined,
53293
+ folderPath: entity.fullyQualifiedName ?? undefined,
53294
+ folderKey: entity.folderKey ?? undefined
53295
+ });
53296
+ }
53297
+ function toCatalogReference(reference) {
53298
+ const { folderPath, folderKey, ...rest } = reference;
53299
+ return {
53300
+ ...rest,
53301
+ folder: folderPath ? { fullyQualifiedName: folderPath, folderKey } : undefined
53302
+ };
53303
+ }
53304
+ async function exportResourceDefinitionAsync(importer, reference) {
53305
+ const [error, payload] = await catchError2(importer.exportResourceAsync(reference));
53306
+ if (error) {
53307
+ throw withExportStatus(error);
53308
+ }
53309
+ return payload.resourceDefinitions.find((d) => d.key === reference.key);
53310
+ }
53311
+ function withExportStatus(error) {
53312
+ if (!(error instanceof Error) || !("exceptionData" in error)) {
53313
+ return error;
53314
+ }
53315
+ const data = error.exceptionData;
53316
+ const text = typeof data === "object" && data !== null ? data.errorMessage : undefined;
53317
+ const match = typeof text === "string" ? /^HTTP (\d{3})\b/.exec(text) : null;
53318
+ return match ? new ResourceExportError(error.message, Number(match[1]), error) : error;
53319
+ }
53320
+ function readSpecProperty(spec, name) {
53321
+ if (!spec) {
53322
+ return;
53323
+ }
53324
+ if (spec[name] !== undefined) {
53325
+ return spec[name];
53326
+ }
53327
+ const lower = name.toLowerCase();
53328
+ const key = Object.keys(spec).find((k) => k.toLowerCase() === lower);
53329
+ return key === undefined ? undefined : spec[key];
53330
+ }
53331
+ function readSpecEntryPoints(spec) {
53332
+ const entryPoints = parseJsonString(readSpecProperty(spec, "entryPoints"));
53333
+ if (!Array.isArray(entryPoints) || !entryPoints.every((entry) => entry !== null && typeof entry === "object")) {
53334
+ return;
53335
+ }
53336
+ return entryPoints.map((entry) => ({
53337
+ UniqueId: String(readSpecProperty(entry, "uniqueId") ?? ""),
53338
+ Path: String(readSpecProperty(entry, "path") ?? ""),
53339
+ DisplayName: String(readSpecProperty(entry, "displayName") ?? ""),
53340
+ InputArguments: readSpecProperty(entry, "inputArguments"),
53341
+ OutputArguments: readSpecProperty(entry, "outputArguments")
53342
+ }));
53343
+ }
53344
+ function parseJsonString(raw) {
53345
+ if (typeof raw !== "string") {
53346
+ return raw;
53347
+ }
53348
+ const [error, parsed] = catchError2(() => JSON.parse(raw));
53349
+ return error ? undefined : parsed;
53350
+ }
53351
+ var ResourceExportError;
53352
+ var init_remote_resources = __esm(() => {
53353
+ init_src4();
53354
+ init_service_tokens();
53355
+ ResourceExportError = class ResourceExportError extends Error {
53356
+ status;
53357
+ constructor(message, status, cause) {
53358
+ super(message, { cause });
53359
+ this.status = status;
53360
+ this.name = "ResourceExportError";
53361
+ }
53362
+ };
53363
+ });
53364
+
53365
+ // ../solution-sdk/src/resources/services/resource-configurations.ts
53366
+ function isResourceKeyNotFound(error, resourceKey) {
53367
+ if (!(error instanceof Error))
53368
+ return false;
53369
+ const typed = error;
53370
+ const sameKey = (key) => key !== undefined && key.toLowerCase() === resourceKey.toLowerCase();
53371
+ if (typeof typed.resourceType === "string" && typeof typed.resourceKey === "string") {
53372
+ return ROOT_RESOURCE_TYPES.has(typed.resourceType.toLowerCase()) && sameKey(typed.resourceKey);
53373
+ }
53374
+ return sameKey(KEY_NOT_FOUND.exec(error.message.trim())?.[1]);
53375
+ }
53376
+ async function refreshArtefactSpecsAsync(builder, configurations) {
53377
+ const resources = new Map;
53378
+ const [loadError, solution] = await catchError2(builder.context.loadAsync());
53379
+ if (loadError || !solution)
53380
+ return resources;
53381
+ for (const configuration of configurations) {
53382
+ const resource = solution.resources.find((r) => r.key === configuration?.key);
53383
+ if (!resource)
53384
+ continue;
53385
+ resources.set(resource.key, resource);
53386
+ if (!resource.projectKey)
53387
+ continue;
53388
+ configuration.spec = await applyEntryPointEnhancementAsync(builder.context, resource, configuration.spec ?? {});
53389
+ }
53390
+ return resources;
53391
+ }
53392
+ async function exportResourceConfigurationsAsync(services, resourceKey, hint = {}) {
53393
+ const { catalog, importer } = getRemoteResourceClients(services);
53394
+ const byKey = (item) => item.entityKey === resourceKey;
53395
+ const entity = (hint.name ? await findCatalogEntityAsync(catalog, { name: hint.name }, byKey) : undefined) ?? await findCatalogEntityAsync(catalog, {}, byKey);
53396
+ if (!entity) {
53397
+ throw new Error(`Resource '${resourceKey}' was not found in the solution or in the resource catalog`);
53398
+ }
53399
+ const payload = await importer.exportResourceAsync(toResourceReference(entity));
53400
+ const definitions = payload.resourceDefinitions ?? [];
53401
+ if (definitions.length === 0) {
53402
+ throw new Error(`FPS export for '${resourceKey}' returned no resource definitions`);
53403
+ }
53404
+ return {
53405
+ resources: definitions.map((d) => ({
53406
+ key: d.key ?? "",
53407
+ spec: d.spec ?? {},
53408
+ locks: d.locks ?? [],
53409
+ apiVersion: d.apiVersion,
53410
+ isOverridable: d.isOverridable,
53411
+ name: d.name ?? "",
53412
+ kind: d.kind ?? "",
53413
+ dependencies: (d.dependencies ?? []).map((dep) => ({
53414
+ kind: dep.kind ?? "",
53415
+ name: dep.name ?? ""
53416
+ }))
53417
+ }))
53418
+ };
53419
+ }
53420
+ async function readLocalAsync(builder, resourceKey, read) {
53421
+ if (!builder)
53422
+ return;
53423
+ const [error, value] = await catchError2(read(builder));
53424
+ if (!error)
53425
+ return { builder, value };
53426
+ if (isResourceKeyNotFound(error, resourceKey))
53427
+ return;
53428
+ throw error;
53429
+ }
53430
+ async function readResourceConfigurationsAsync(services, builder, resourceKey, hint = {}) {
53431
+ const local = await readLocalAsync(builder, resourceKey, (b) => b.getAllConfigurationsAsync(resourceKey));
53432
+ if (!local) {
53433
+ return exportResourceConfigurationsAsync(services, resourceKey, hint);
53434
+ }
53435
+ await refreshArtefactSpecsAsync(local.builder, local.value?.resources ?? []);
53436
+ return local.value;
53437
+ }
53438
+ async function readResourceConfigurationAsync(services, builder, resourceKey) {
53439
+ const local = await readLocalAsync(builder, resourceKey, (b) => b.getConfigurationAsync(resourceKey));
53440
+ if (local) {
53441
+ const configuration = local.value;
53442
+ const resources = await refreshArtefactSpecsAsync(local.builder, [
53443
+ configuration
53444
+ ]);
53445
+ return { configuration, resource: resources.get(configuration.key) };
53446
+ }
53447
+ const { resources } = await exportResourceConfigurationsAsync(services, resourceKey);
53448
+ const primary = resources.find((r) => r.key === resourceKey) ?? resources[0];
53449
+ const { key, spec, locks, apiVersion, isOverridable } = primary;
53450
+ return { configuration: { key, spec, locks, apiVersion, isOverridable } };
53451
+ }
53452
+ var ROOT_RESOURCE_TYPES, KEY_NOT_FOUND;
53453
+ var init_resource_configurations = __esm(() => {
53454
+ init_src4();
53455
+ init_entry_point_spec_enhancer();
53456
+ init_remote_resources();
53457
+ ROOT_RESOURCE_TYPES = new Set(["resource", "solutionresource"]);
53458
+ KEY_NOT_FOUND = /^(?:Solution)?Resource with key '([^']+)' was not found$/i;
53459
+ });
53460
+
53461
+ // ../solution-sdk/src/resources/services/resource-lookup.ts
53462
+ async function findResourcesByNameAsync(services, builder, { kind, name, subTypes, folderKey }) {
53463
+ const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
53464
+ const ofSubType = (type) => subTypes === undefined || subTypes.some((t) => same(type, t));
53465
+ if (builder) {
53466
+ const solution = await builder.context.loadAsync();
53467
+ const local = solution.resources.filter((r) => same(r.kind, kind) && same(r.name, name) && ofSubType(r.type)).map((r) => ({
53468
+ key: r.key,
53469
+ local: true,
53470
+ folderPath: r.folders?.[0]?.fullyQualifiedName
53471
+ }));
53472
+ if (local.length > 0)
53473
+ return local;
53474
+ }
53475
+ const { catalog } = getRemoteResourceClients(services);
53476
+ const rows = await findCatalogEntitiesAsync(catalog, { name, entityTypes: [kind] }, (row) => same(row.entityType, kind) && same(row.entityName, name) && ofSubType(row.entitySubType) && (folderKey === undefined || same(row.folderKey, folderKey)));
53477
+ return rows.map((row) => ({
53478
+ key: row.entityKey ?? "",
53479
+ local: false,
53480
+ folderPath: row.fullyQualifiedName ?? undefined,
53481
+ folderKey: row.folderKey ?? undefined
53482
+ }));
53483
+ }
53484
+ var init_resource_lookup = __esm(() => {
53485
+ init_remote_resources();
53486
+ });
53487
+
53488
+ // ../solution-sdk/src/resources/services/resource-name.ts
53489
+ function hasControlChar(value) {
53490
+ for (let i = 0;i < value.length; i++) {
53491
+ if (value.charCodeAt(i) < 32)
53492
+ return true;
53493
+ }
53494
+ return false;
53495
+ }
53496
+ function hasUnsafeNameChars(name) {
53497
+ return UNSAFE_NAME_CHARS.test(name) || hasControlChar(name);
53498
+ }
53499
+ function validateResourceName(name, options = {}) {
53500
+ const optionName = options.optionName ?? "--name";
53501
+ if (name.trim() === "") {
53502
+ return {
53503
+ ok: false,
53504
+ message: `${optionName} must not be blank`,
53505
+ instructions: "Pass a non-empty resource name."
53506
+ };
53507
+ }
53508
+ if (name.length > MAX_RESOURCE_NAME_LENGTH) {
53509
+ return {
53510
+ ok: false,
53511
+ message: `${optionName} exceeds the ${MAX_RESOURCE_NAME_LENGTH}-character limit (got ${name.length})`,
53512
+ instructions: "Shorten the resource name. Orchestrator name limits are kind-specific (queues cap at 50, assets at 256)."
53513
+ };
53514
+ }
53515
+ if (hasUnsafeNameChars(name)) {
53516
+ return {
53517
+ ok: false,
53518
+ message: `${optionName} contains unsafe characters`,
53519
+ instructions: 'Resource names cannot contain path separators (/, \\), control characters, or any of: : * ? " < > |'
53520
+ };
53521
+ }
53522
+ return { ok: true };
53523
+ }
53524
+ function assertValidResourceName(name, options = {}) {
53525
+ const result = validateResourceName(name, options);
53526
+ if (!result.ok) {
53527
+ throw new Error(`${result.message}. ${result.instructions}`);
53528
+ }
53529
+ }
53530
+ var MAX_RESOURCE_NAME_LENGTH = 256, UNSAFE_NAME_CHARS;
53531
+ var init_resource_name = __esm(() => {
53532
+ UNSAFE_NAME_CHARS = /[\\/:*?"<>|]/;
53209
53533
  });
53210
53534
 
53211
53535
  // ../solution-sdk/src/resources/services/resource-refresh-service.ts
@@ -53246,7 +53570,11 @@ async function resourceRefreshAsync(solutionPath = ".", options = {}) {
53246
53570
  if (bindingsError) {
53247
53571
  resolverWarnings.push(`Could not read the bindings projects contribute: ${bindingsError.message}. Those projects were synced from any bindings_v2.json on disk instead; fix the tool install and re-run 'uip solution resources refresh'.`);
53248
53572
  }
53249
- const [syncError, result] = await catchError2(syncResourcesFromBindings(resolvedPath, undefined, projectSubTypes ?? new Map, projectBindings ?? new Map, undefined, {
53573
+ const [selfProvisionedError, selfProvisioned] = await catchError2(options.resolveSelfProvisionedAsync?.() ?? Promise.resolve([]));
53574
+ if (selfProvisionedError) {
53575
+ resolverWarnings.push(`Could not read the resources projects say the solution creates: ${selfProvisionedError.message}. They were looked up in the Resource Catalog instead; fix the tool install and re-run 'uip solution resources refresh'.`);
53576
+ }
53577
+ const [syncError, result] = await catchError2(syncResourcesFromBindings(resolvedPath, undefined, projectSubTypes ?? new Map, projectBindings ?? new Map, selfProvisioned?.length ? [...selfProvisioned] : undefined, {
53250
53578
  bindingsComplete: !bindingsError && (options.isProjectBindingsComplete?.() ?? true)
53251
53579
  }));
53252
53580
  if (syncError) {
@@ -53489,6 +53817,7 @@ __export(exports_resources, {
53489
53817
  findProjectFile: () => findProjectFile,
53490
53818
  findResourceByKeyInRcs: () => findResourceByKeyInRcs,
53491
53819
  findResourceInRcs: () => findResourceInRcs,
53820
+ findResourcesByKeysInRcs: () => findResourcesByKeysInRcs,
53492
53821
  findResourcesByNameAsync: () => findResourcesByNameAsync,
53493
53822
  formatResourceSubtypes: () => formatResourceSubtypes,
53494
53823
  getRemoteResourceClients: () => getRemoteResourceClients,
@@ -53510,6 +53839,7 @@ __export(exports_resources, {
53510
53839
  readSpecProperty: () => readSpecProperty,
53511
53840
  readUipxProjects: () => readUipxProjects,
53512
53841
  refreshArtefactSpecsAsync: () => refreshArtefactSpecsAsync,
53842
+ resolveImportedResourcesAsync: () => resolveImportedResourcesAsync,
53513
53843
  resolveProjectDirFromManifest: () => resolveProjectDirFromManifest,
53514
53844
  resolveResourceKindMetadata: () => resolveResourceKindMetadata,
53515
53845
  resolveSolutionFilePath: () => resolveSolutionFilePath,
@@ -53534,6 +53864,7 @@ var init_resources = __esm(() => {
53534
53864
  init_project_utils();
53535
53865
  init_resource_builder_init();
53536
53866
  init_entry_point_spec_enhancer();
53867
+ init_imported_resources();
53537
53868
  init_local_resource_matcher();
53538
53869
  init_project_artifacts_service();
53539
53870
  init_project_template_types();
@@ -265184,4 +265515,4 @@ export {
265184
265515
  studioCatalogTypeCache
265185
265516
  };
265186
265517
 
265187
- //# debugId=12ABF9BC3AC90FBF64756E2164756E21
265518
+ //# debugId=CC2886C87ED275EB64756E2164756E21