@uipath/maestro-sdk 1.207.0-preview.337 → 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.
package/dist/index.js CHANGED
@@ -144975,7 +144975,7 @@ var init_package = __esm(() => {
144975
144975
  name: "@uipath/integrationservice-sdk",
144976
144976
  author: "UiPath",
144977
144977
  license: "SEE LICENSE IN LICENSE.txt",
144978
- version: "1.207.0-preview.337",
144978
+ version: "1.207.0-preview.339",
144979
144979
  repository: {
144980
144980
  type: "git",
144981
144981
  url: "https://github.com/UiPath/cli.git",
@@ -153653,6 +153653,131 @@ var init_models3 = __esm(() => {
153653
153653
  });
153654
153654
  // ../packager/packager-core/src/package-descriptor/index.ts
153655
153655
  var init_package_descriptor = () => {};
153656
+
153657
+ // ../packager/packager-core/src/resource-declarations/languages.ts
153658
+ function resourceDeclarationsPaths(language) {
153659
+ const name = RESOURCE_DECLARATIONS_FILE_NAMES[language];
153660
+ return [name, `src/${name}`];
153661
+ }
153662
+ var RESOURCE_DECLARATIONS_FILE_NAMES;
153663
+ var init_languages = __esm(() => {
153664
+ RESOURCE_DECLARATIONS_FILE_NAMES = {
153665
+ typescript: "uipath_resources.ts",
153666
+ python: "uipath_resources.py"
153667
+ };
153668
+ });
153669
+
153670
+ // ../packager/packager-core/src/resource-declarations/scanner.ts
153671
+ var closingIndexOf;
153672
+ var init_scanner = __esm(() => {
153673
+ closingIndexOf = new Map;
153674
+ });
153675
+
153676
+ // ../packager/packager-core/src/resource-declarations/declarations.ts
153677
+ var RESOURCE_DECLARATIONS_FILE_NAME, RESOURCE_DECLARATIONS_PATHS, MAX_RESOURCE_DECLARATIONS_LENGTH;
153678
+ var init_declarations = __esm(() => {
153679
+ init_languages();
153680
+ init_scanner();
153681
+ RESOURCE_DECLARATIONS_FILE_NAME = RESOURCE_DECLARATIONS_FILE_NAMES.typescript;
153682
+ RESOURCE_DECLARATIONS_PATHS = resourceDeclarationsPaths("typescript");
153683
+ MAX_RESOURCE_DECLARATIONS_LENGTH = 1024 * 1024;
153684
+ });
153685
+
153686
+ // ../packager/packager-core/src/resource-declarations/bindings.ts
153687
+ var init_bindings = __esm(() => {
153688
+ init_declarations();
153689
+ });
153690
+
153691
+ // ../packager/packager-core/src/resource-declarations/editor.ts
153692
+ var RESERVED_IDENTIFIERS, SUB_TYPES_BY_KIND;
153693
+ var init_editor = __esm(() => {
153694
+ init_bindings();
153695
+ init_declarations();
153696
+ init_scanner();
153697
+ RESERVED_IDENTIFIERS = new Set([
153698
+ "constructor",
153699
+ "prototype",
153700
+ "name",
153701
+ "length",
153702
+ "caller",
153703
+ "arguments"
153704
+ ]);
153705
+ SUB_TYPES_BY_KIND = {
153706
+ asset: new Set(["text", "integer", "bool", "credential", "secret", "json"]),
153707
+ bucket: new Set(["orchestrator", "amazon", "azure"])
153708
+ };
153709
+ });
153710
+
153711
+ // ../packager/packager-core/src/resource-declarations/python.ts
153712
+ var PYTHON_KEYWORDS;
153713
+ var init_python = __esm(() => {
153714
+ init_bindings();
153715
+ init_declarations();
153716
+ init_editor();
153717
+ init_languages();
153718
+ init_scanner();
153719
+ PYTHON_KEYWORDS = new Set([
153720
+ "and",
153721
+ "as",
153722
+ "assert",
153723
+ "async",
153724
+ "await",
153725
+ "break",
153726
+ "class",
153727
+ "continue",
153728
+ "def",
153729
+ "del",
153730
+ "elif",
153731
+ "else",
153732
+ "except",
153733
+ "finally",
153734
+ "for",
153735
+ "from",
153736
+ "global",
153737
+ "if",
153738
+ "import",
153739
+ "in",
153740
+ "is",
153741
+ "lambda",
153742
+ "nonlocal",
153743
+ "not",
153744
+ "or",
153745
+ "pass",
153746
+ "raise",
153747
+ "return",
153748
+ "try",
153749
+ "while",
153750
+ "with",
153751
+ "yield"
153752
+ ]);
153753
+ });
153754
+
153755
+ // ../packager/packager-core/src/resource-declarations/source.ts
153756
+ var init_source = __esm(() => {
153757
+ init_bindings();
153758
+ init_declarations();
153759
+ init_editor();
153760
+ init_languages();
153761
+ init_python();
153762
+ });
153763
+
153764
+ // ../packager/packager-core/src/resource-declarations/project.ts
153765
+ var init_project = __esm(() => {
153766
+ init_bindings();
153767
+ init_declarations();
153768
+ init_source();
153769
+ });
153770
+
153771
+ // ../packager/packager-core/src/resource-declarations/index.ts
153772
+ var init_resource_declarations = __esm(() => {
153773
+ init_bindings();
153774
+ init_declarations();
153775
+ init_editor();
153776
+ init_languages();
153777
+ init_project();
153778
+ init_python();
153779
+ init_source();
153780
+ });
153656
153781
  // ../packager/packager-core/src/services/project-id.ts
153657
153782
  var init_project_id = () => {};
153658
153783
 
@@ -153748,6 +153873,7 @@ var init_src5 = __esm(() => {
153748
153873
  init_i18n();
153749
153874
  init_models3();
153750
153875
  init_package_descriptor();
153876
+ init_resource_declarations();
153751
153877
  init_services();
153752
153878
  });
153753
153879
 
@@ -160518,7 +160644,7 @@ var init_binding_overwrites_mapping_handler = __esm(() => {
160518
160644
  });
160519
160645
 
160520
160646
  // ../../node_modules/@uipath/resource-builder-sdk/dist/bindings/index.js
160521
- var init_bindings = __esm(() => {
160647
+ var init_bindings2 = __esm(() => {
160522
160648
  init_models5();
160523
160649
  init_bindings_metadata_serializer();
160524
160650
  init_bindings_requests();
@@ -161680,7 +161806,7 @@ var init_solution_builder = __esm(() => {
161680
161806
  init_detach_resource_file_command();
161681
161807
  init_exceptions();
161682
161808
  init_internal();
161683
- init_bindings();
161809
+ init_bindings2();
161684
161810
  init_solution();
161685
161811
  SolutionBuilder = class SolutionBuilder {
161686
161812
  dispose() {
@@ -173365,7 +173491,7 @@ function isGuid3(value) {
173365
173491
  }
173366
173492
  var BINDINGS_RESOLUTION_BATCH_SIZE = 10;
173367
173493
  var init_get_exportable_items_based_on_bindings_handler = __esm(() => {
173368
- init_bindings();
173494
+ init_bindings2();
173369
173495
  init_resource_subtype_mapper();
173370
173496
  init_exceptions();
173371
173497
  });
@@ -174977,7 +175103,7 @@ var init_container = __esm(() => {
174977
175103
  init_mediator2();
174978
175104
  init_resource_builder();
174979
175105
  init_handlers();
174980
- init_bindings();
175106
+ init_bindings2();
174981
175107
  init_solution();
174982
175108
  init_feature_flag_provider();
174983
175109
  init_clients();
@@ -181243,152 +181369,14 @@ var init_local_resource_matcher = __esm(() => {
181243
181369
  ORPHAN_CHECKED_KINDS = new Set(["process", "app"]);
181244
181370
  });
181245
181371
 
181246
- // ../solution-sdk/src/resources/services/project-artifacts-service.ts
181247
- async function addProjectArtifactsToSolutionAsync(options) {
181248
- const error = await createProjectInSolutionBuilder(options.solutionDir, options.projectId, options.projectName, normalizeProjectType(options.projectType), options.projectSubType);
181249
- return error ? artifactFailure(options, error) : { Created: true };
181250
- }
181251
- function artifactFailure(options, error) {
181252
- 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.");
181253
- return { Created: false, Error: error.message };
181254
- }
181255
- var init_project_artifacts_service = __esm(() => {
181256
- init_src2();
181257
- init_solution_file();
181258
- init_project_utils();
181259
- });
181260
-
181261
- // ../solution-sdk/src/resources/services/project-template-types.ts
181262
- function hasBareTemplateRow(projectType) {
181263
- reader ??= new EmbeddedProjectConfigurationReader;
181264
- return reader.getTemplateResourcesByType(projectType, undefined, false).length > 0;
181265
- }
181266
- function hasAnyTemplateRow(projectType) {
181267
- reader ??= new EmbeddedProjectConfigurationReader;
181268
- const wanted = projectType.toLowerCase();
181269
- return Object.keys(reader.getAll()).some((row) => {
181270
- const key = row.toLowerCase();
181271
- return key === wanted || key.startsWith(`${wanted}_`);
181272
- });
181273
- }
181274
- var reader;
181275
- var init_project_template_types = __esm(() => {
181276
- init_config2();
181372
+ // ../../node_modules/@uipath/resource-builder-sdk/dist/entries/bindings.js
181373
+ var init_bindings3 = __esm(() => {
181374
+ init_bindings2();
181277
181375
  });
181278
181376
 
181279
- // ../solution-sdk/src/resources/services/remote-resources.ts
181280
- function getRemoteResourceClients(services) {
181281
- return {
181282
- catalog: services.container.resolve(Tokens.IResourceCatalogClientProxy),
181283
- importer: services.container.resolve(Tokens.IImportResourceHelper)
181284
- };
181285
- }
181286
- async function findCatalogEntityAsync(catalog, query, match) {
181287
- let pageCursor;
181288
- do {
181289
- const page = await catalog.searchFolderEntities({
181290
- ...query,
181291
- pageSize: 100,
181292
- pageCursor
181293
- });
181294
- const found = (page.items ?? []).find(match);
181295
- if (found) {
181296
- return found;
181297
- }
181298
- pageCursor = page.nextPage ?? undefined;
181299
- } while (pageCursor);
181300
- return;
181301
- }
181302
- async function findCatalogEntitiesAsync(catalog, query, match) {
181303
- const found = [];
181304
- let pageCursor;
181305
- do {
181306
- const page = await catalog.searchFolderEntities({
181307
- ...query,
181308
- pageSize: 100,
181309
- pageCursor
181310
- });
181311
- found.push(...(page.items ?? []).filter(match));
181312
- pageCursor = page.nextPage ?? undefined;
181313
- } while (pageCursor);
181314
- return found;
181315
- }
181316
- function toResourceReference(entity) {
181317
- return toCatalogReference({
181318
- kind: entity.entityType ?? "",
181319
- type: entity.entitySubType ?? undefined,
181320
- key: entity.entityKey ?? "",
181321
- name: entity.entityName ?? undefined,
181322
- folderPath: entity.fullyQualifiedName ?? undefined,
181323
- folderKey: entity.folderKey ?? undefined
181324
- });
181325
- }
181326
- function toCatalogReference(reference) {
181327
- const { folderPath, folderKey, ...rest } = reference;
181328
- return {
181329
- ...rest,
181330
- folder: folderPath ? { fullyQualifiedName: folderPath, folderKey } : undefined
181331
- };
181332
- }
181333
- async function exportResourceDefinitionAsync(importer, reference) {
181334
- const [error, payload] = await catchError(importer.exportResourceAsync(reference));
181335
- if (error) {
181336
- throw withExportStatus(error);
181337
- }
181338
- return payload.resourceDefinitions.find((d) => d.key === reference.key);
181339
- }
181340
- function withExportStatus(error) {
181341
- if (!(error instanceof Error) || !("exceptionData" in error)) {
181342
- return error;
181343
- }
181344
- const data = error.exceptionData;
181345
- const text = typeof data === "object" && data !== null ? data.errorMessage : undefined;
181346
- const match = typeof text === "string" ? /^HTTP (\d{3})\b/.exec(text) : null;
181347
- return match ? new ResourceExportError(error.message, Number(match[1]), error) : error;
181348
- }
181349
- function readSpecProperty(spec, name) {
181350
- if (!spec) {
181351
- return;
181352
- }
181353
- if (spec[name] !== undefined) {
181354
- return spec[name];
181355
- }
181356
- const lower = name.toLowerCase();
181357
- const key = Object.keys(spec).find((k) => k.toLowerCase() === lower);
181358
- return key === undefined ? undefined : spec[key];
181359
- }
181360
- function readSpecEntryPoints(spec) {
181361
- const entryPoints = parseJsonString(readSpecProperty(spec, "entryPoints"));
181362
- if (!Array.isArray(entryPoints) || !entryPoints.every((entry) => entry !== null && typeof entry === "object")) {
181363
- return;
181364
- }
181365
- return entryPoints.map((entry) => ({
181366
- UniqueId: String(readSpecProperty(entry, "uniqueId") ?? ""),
181367
- Path: String(readSpecProperty(entry, "path") ?? ""),
181368
- DisplayName: String(readSpecProperty(entry, "displayName") ?? ""),
181369
- InputArguments: readSpecProperty(entry, "inputArguments"),
181370
- OutputArguments: readSpecProperty(entry, "outputArguments")
181371
- }));
181372
- }
181373
- function parseJsonString(raw) {
181374
- if (typeof raw !== "string") {
181375
- return raw;
181376
- }
181377
- const [error, parsed] = catchError(() => JSON.parse(raw));
181378
- return error ? undefined : parsed;
181379
- }
181380
- var ResourceExportError;
181381
- var init_remote_resources = __esm(() => {
181382
- init_src2();
181383
- init_service_tokens();
181384
- ResourceExportError = class ResourceExportError extends Error {
181385
- status;
181386
- constructor(message, status, cause) {
181387
- super(message, { cause });
181388
- this.status = status;
181389
- this.name = "ResourceExportError";
181390
- }
181391
- };
181377
+ // ../../node_modules/@uipath/resource-builder-sdk/dist/mappings/index.js
181378
+ var init_mappings = __esm(() => {
181379
+ init_resource_subtype_mapper();
181392
181380
  });
181393
181381
 
181394
181382
  // ../solution-sdk/src/resources/services/resource-casing.ts
@@ -181557,186 +181545,6 @@ var init_resource_casing = __esm(() => {
181557
181545
  init_src();
181558
181546
  });
181559
181547
 
181560
- // ../solution-sdk/src/resources/services/resource-configurations.ts
181561
- function isResourceKeyNotFound(error, resourceKey) {
181562
- if (!(error instanceof Error))
181563
- return false;
181564
- const typed = error;
181565
- const sameKey = (key) => key !== undefined && key.toLowerCase() === resourceKey.toLowerCase();
181566
- if (typeof typed.resourceType === "string" && typeof typed.resourceKey === "string") {
181567
- return ROOT_RESOURCE_TYPES.has(typed.resourceType.toLowerCase()) && sameKey(typed.resourceKey);
181568
- }
181569
- return sameKey(KEY_NOT_FOUND.exec(error.message.trim())?.[1]);
181570
- }
181571
- async function refreshArtefactSpecsAsync(builder, configurations) {
181572
- const resources = new Map;
181573
- const [loadError, solution] = await catchError(builder.context.loadAsync());
181574
- if (loadError || !solution)
181575
- return resources;
181576
- for (const configuration of configurations) {
181577
- const resource = solution.resources.find((r) => r.key === configuration?.key);
181578
- if (!resource)
181579
- continue;
181580
- resources.set(resource.key, resource);
181581
- if (!resource.projectKey)
181582
- continue;
181583
- configuration.spec = await applyEntryPointEnhancementAsync(builder.context, resource, configuration.spec ?? {});
181584
- }
181585
- return resources;
181586
- }
181587
- async function exportResourceConfigurationsAsync(services, resourceKey, hint = {}) {
181588
- const { catalog, importer } = getRemoteResourceClients(services);
181589
- const byKey = (item) => item.entityKey === resourceKey;
181590
- const entity = (hint.name ? await findCatalogEntityAsync(catalog, { name: hint.name }, byKey) : undefined) ?? await findCatalogEntityAsync(catalog, {}, byKey);
181591
- if (!entity) {
181592
- throw new Error(`Resource '${resourceKey}' was not found in the solution or in the resource catalog`);
181593
- }
181594
- const payload = await importer.exportResourceAsync(toResourceReference(entity));
181595
- const definitions = payload.resourceDefinitions ?? [];
181596
- if (definitions.length === 0) {
181597
- throw new Error(`FPS export for '${resourceKey}' returned no resource definitions`);
181598
- }
181599
- return {
181600
- resources: definitions.map((d) => ({
181601
- key: d.key ?? "",
181602
- spec: d.spec ?? {},
181603
- locks: d.locks ?? [],
181604
- apiVersion: d.apiVersion,
181605
- isOverridable: d.isOverridable,
181606
- name: d.name ?? "",
181607
- kind: d.kind ?? "",
181608
- dependencies: (d.dependencies ?? []).map((dep) => ({
181609
- kind: dep.kind ?? "",
181610
- name: dep.name ?? ""
181611
- }))
181612
- }))
181613
- };
181614
- }
181615
- async function readLocalAsync(builder, resourceKey, read) {
181616
- if (!builder)
181617
- return;
181618
- const [error, value] = await catchError(read(builder));
181619
- if (!error)
181620
- return { builder, value };
181621
- if (isResourceKeyNotFound(error, resourceKey))
181622
- return;
181623
- throw error;
181624
- }
181625
- async function readResourceConfigurationsAsync(services, builder, resourceKey, hint = {}) {
181626
- const local = await readLocalAsync(builder, resourceKey, (b) => b.getAllConfigurationsAsync(resourceKey));
181627
- if (!local) {
181628
- return exportResourceConfigurationsAsync(services, resourceKey, hint);
181629
- }
181630
- await refreshArtefactSpecsAsync(local.builder, local.value?.resources ?? []);
181631
- return local.value;
181632
- }
181633
- async function readResourceConfigurationAsync(services, builder, resourceKey) {
181634
- const local = await readLocalAsync(builder, resourceKey, (b) => b.getConfigurationAsync(resourceKey));
181635
- if (local) {
181636
- const configuration = local.value;
181637
- const resources = await refreshArtefactSpecsAsync(local.builder, [
181638
- configuration
181639
- ]);
181640
- return { configuration, resource: resources.get(configuration.key) };
181641
- }
181642
- const { resources } = await exportResourceConfigurationsAsync(services, resourceKey);
181643
- const primary = resources.find((r) => r.key === resourceKey) ?? resources[0];
181644
- const { key, spec, locks, apiVersion, isOverridable } = primary;
181645
- return { configuration: { key, spec, locks, apiVersion, isOverridable } };
181646
- }
181647
- var ROOT_RESOURCE_TYPES, KEY_NOT_FOUND;
181648
- var init_resource_configurations = __esm(() => {
181649
- init_src2();
181650
- init_entry_point_spec_enhancer();
181651
- init_remote_resources();
181652
- ROOT_RESOURCE_TYPES = new Set(["resource", "solutionresource"]);
181653
- KEY_NOT_FOUND = /^(?:Solution)?Resource with key '([^']+)' was not found$/i;
181654
- });
181655
-
181656
- // ../solution-sdk/src/resources/services/resource-lookup.ts
181657
- async function findResourcesByNameAsync(services, builder, { kind, name, subTypes, folderKey }) {
181658
- const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
181659
- const ofSubType = (type) => subTypes === undefined || subTypes.some((t) => same(type, t));
181660
- if (builder) {
181661
- const solution = await builder.context.loadAsync();
181662
- const local = solution.resources.filter((r) => same(r.kind, kind) && same(r.name, name) && ofSubType(r.type)).map((r) => ({
181663
- key: r.key,
181664
- local: true,
181665
- folderPath: r.folders?.[0]?.fullyQualifiedName
181666
- }));
181667
- if (local.length > 0)
181668
- return local;
181669
- }
181670
- const { catalog } = getRemoteResourceClients(services);
181671
- 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)));
181672
- return rows.map((row) => ({
181673
- key: row.entityKey ?? "",
181674
- local: false,
181675
- folderPath: row.fullyQualifiedName ?? undefined,
181676
- folderKey: row.folderKey ?? undefined
181677
- }));
181678
- }
181679
- var init_resource_lookup = __esm(() => {
181680
- init_remote_resources();
181681
- });
181682
-
181683
- // ../solution-sdk/src/resources/services/resource-name.ts
181684
- function hasControlChar(value) {
181685
- for (let i = 0;i < value.length; i++) {
181686
- if (value.charCodeAt(i) < 32)
181687
- return true;
181688
- }
181689
- return false;
181690
- }
181691
- function hasUnsafeNameChars(name) {
181692
- return UNSAFE_NAME_CHARS.test(name) || hasControlChar(name);
181693
- }
181694
- function validateResourceName(name, options = {}) {
181695
- const optionName = options.optionName ?? "--name";
181696
- if (name.trim() === "") {
181697
- return {
181698
- ok: false,
181699
- message: `${optionName} must not be blank`,
181700
- instructions: "Pass a non-empty resource name."
181701
- };
181702
- }
181703
- if (name.length > MAX_RESOURCE_NAME_LENGTH) {
181704
- return {
181705
- ok: false,
181706
- message: `${optionName} exceeds the ${MAX_RESOURCE_NAME_LENGTH}-character limit (got ${name.length})`,
181707
- instructions: "Shorten the resource name. Orchestrator name limits are kind-specific (queues cap at 50, assets at 256)."
181708
- };
181709
- }
181710
- if (hasUnsafeNameChars(name)) {
181711
- return {
181712
- ok: false,
181713
- message: `${optionName} contains unsafe characters`,
181714
- instructions: 'Resource names cannot contain path separators (/, \\), control characters, or any of: : * ? " < > |'
181715
- };
181716
- }
181717
- return { ok: true };
181718
- }
181719
- function assertValidResourceName(name, options = {}) {
181720
- const result = validateResourceName(name, options);
181721
- if (!result.ok) {
181722
- throw new Error(`${result.message}. ${result.instructions}`);
181723
- }
181724
- }
181725
- var MAX_RESOURCE_NAME_LENGTH = 256, UNSAFE_NAME_CHARS;
181726
- var init_resource_name = __esm(() => {
181727
- UNSAFE_NAME_CHARS = /[\\/:*?"<>|]/;
181728
- });
181729
-
181730
- // ../../node_modules/@uipath/resource-builder-sdk/dist/entries/bindings.js
181731
- var init_bindings2 = __esm(() => {
181732
- init_bindings();
181733
- });
181734
-
181735
- // ../../node_modules/@uipath/resource-builder-sdk/dist/mappings/index.js
181736
- var init_mappings = __esm(() => {
181737
- init_resource_subtype_mapper();
181738
- });
181739
-
181740
181548
  // ../solution-sdk/src/resources/services/sync-resources-from-bindings.ts
181741
181549
  function placeholderForType(type) {
181742
181550
  switch ((type ?? "string").toLowerCase()) {
@@ -181828,6 +181636,54 @@ function sameResourceSubtype(a, b) {
181828
181636
  function findSubtypeEntry(list, type) {
181829
181637
  return list.find((r) => !!r.type && sameResourceSubtype(r.type, type));
181830
181638
  }
181639
+ function metadataString(metadata, name) {
181640
+ if (!metadata || typeof metadata !== "object")
181641
+ return;
181642
+ for (const [key, value] of Object.entries(metadata)) {
181643
+ if (key.toLowerCase() === name.toLowerCase() && typeof value === "string" && value.trim() !== "") {
181644
+ return value;
181645
+ }
181646
+ }
181647
+ return;
181648
+ }
181649
+ function declaredSubTypes(decoded, resources) {
181650
+ const subTypes = new Map;
181651
+ let document2;
181652
+ try {
181653
+ document2 = JSON.parse(decoded);
181654
+ } catch {
181655
+ return subTypes;
181656
+ }
181657
+ const entries = document2?.resources;
181658
+ if (!Array.isArray(entries))
181659
+ return subTypes;
181660
+ const byBinding = new Map;
181661
+ for (const entry of entries) {
181662
+ if (!entry || typeof entry !== "object")
181663
+ continue;
181664
+ const { resource, key, metadata } = entry;
181665
+ if (typeof resource !== "string" || typeof key !== "string" || !SUBTYPED_BINDING_KINDS.has(resource.toLowerCase())) {
181666
+ continue;
181667
+ }
181668
+ const subType = metadataString(metadata, "SubType");
181669
+ if (subType)
181670
+ byBinding.set(`${resource}\x00${key}`, subType);
181671
+ }
181672
+ for (const resource of resources) {
181673
+ const subType = byBinding.get(`${resource.originalResourceType}\x00${resource.bindingKey ?? ""}`);
181674
+ if (subType)
181675
+ subTypes.set(resource, subType);
181676
+ }
181677
+ return subTypes;
181678
+ }
181679
+ async function resolveDeclaredKindMetadata(resolveKindMetadata, kind, type, declaredSubType) {
181680
+ if (type === undefined && declaredSubType !== undefined) {
181681
+ const declared = await resolveKindMetadata(kind, declaredSubType);
181682
+ if (declared?.typeMatched)
181683
+ return declared;
181684
+ }
181685
+ return resolveKindMetadata(kind, type);
181686
+ }
181831
181687
  function resolveBindingResourceIdentity(binding) {
181832
181688
  switch (binding.resourceType) {
181833
181689
  case models_BindingsResourceType.TimeTrigger:
@@ -181864,7 +181720,11 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181864
181720
  return result;
181865
181721
  }
181866
181722
  const serializer = services.container.resolve(Tokens.IBindingsMetadataSerializer);
181867
- const { bindings: allBindings, parseErrors } = await collectBindings2(bindingsJsonFallbackDirs, serializer, bindingSources(solutionDir, paths, uipxProjects, projectBindings));
181723
+ const {
181724
+ bindings: allBindings,
181725
+ parseErrors,
181726
+ subTypes
181727
+ } = await collectBindings2(bindingsJsonFallbackDirs, serializer, bindingSources(solutionDir, paths, uipxProjects, projectBindings));
181868
181728
  if (parseErrors.length > 0) {
181869
181729
  const detail = parseErrors.map((e) => `${e.path}: ${e.reason}`).join("; ");
181870
181730
  throw new Error(`Invalid bindings file — ${detail}`);
@@ -181902,7 +181762,29 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181902
181762
  const resolvedKeys = new Set;
181903
181763
  const overwrittenKeys = new Set;
181904
181764
  const bindingKey = (kind, name) => `${kind}:${name ?? ""}`.toLowerCase();
181905
- const selfProvisionedKeys = new Set((selfProvisioned ?? []).map((r) => bindingKey(r.kind, r.name)));
181765
+ const anyFolderSelfProvisioned = new Set;
181766
+ const solutionFolderSelfProvisioned = new Set;
181767
+ for (const r of selfProvisioned ?? []) {
181768
+ (r.solutionFolderOnly ? solutionFolderSelfProvisioned : anyFolderSelfProvisioned).add(bindingKey(r.kind, r.name));
181769
+ }
181770
+ const isSelfProvisioned = (kind, name, folderPath) => {
181771
+ const key = bindingKey(kind, name);
181772
+ return anyFolderSelfProvisioned.has(key) || !normalizeFolderPath(folderPath) && solutionFolderSelfProvisioned.has(key);
181773
+ };
181774
+ const importedThisRun = new Set;
181775
+ let referencedKeys;
181776
+ const coveringResource = async (resources, kind, name, folderPath, selfProvisioned) => {
181777
+ const match = findMatchingLocalResource(resources, kind, name, folderPath);
181778
+ if (!match || !selfProvisioned)
181779
+ return match;
181780
+ referencedKeys ??= readReferencedResourceKeys(services, builder);
181781
+ const referenced = await referencedKeys;
181782
+ const owned = resources.filter((r) => {
181783
+ const key = r.key?.toLowerCase();
181784
+ return !key || !importedThisRun.has(key) && !referenced.has(key);
181785
+ });
181786
+ return findMatchingLocalResource(owned, kind, name, folderPath);
181787
+ };
181906
181788
  const recordUnchecked = async (error, kind, name, directCloudKey) => {
181907
181789
  if (error) {
181908
181790
  const failure = classifyCatalogFailure(error);
@@ -181930,7 +181812,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181930
181812
  continue;
181931
181813
  }
181932
181814
  const isConnection = isConnectionBinding(binding);
181933
- const metadata = await resolveKindMetadata(kind, identity.type);
181815
+ const metadata = await resolveDeclaredKindMetadata(resolveKindMetadata, kind, identity.type, subTypes.get(binding));
181934
181816
  const name = getResourceName(binding);
181935
181817
  const folderPath = getFolderPathProperty(binding).defaultValue;
181936
181818
  const directCloudKey = isConnection ? getConnectionKey(binding) : undefined;
@@ -181940,7 +181822,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181940
181822
  if (!isConnection && !name) {
181941
181823
  continue;
181942
181824
  }
181943
- if (!isConnection && !normalizeFolderPath(folderPath) && findMatchingLocalResource(solution.resources ?? [], kind, name, folderPath)) {
181825
+ const selfProvisioned = !isConnection && isSelfProvisioned(kind, name, folderPath);
181826
+ if (!isConnection && !normalizeFolderPath(folderPath) && await coveringResource(solution.resources ?? [], kind, name, folderPath, selfProvisioned)) {
181944
181827
  result.skipped++;
181945
181828
  logger.info(`Skipping ${kind} "${name}" — an in-solution resource already covers this solution-relative binding`);
181946
181829
  continue;
@@ -181950,7 +181833,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181950
181833
  logger.info(`Skipping ${kind} "${name}" — the solution provisions this project itself; its member declaration covers the binding`);
181951
181834
  continue;
181952
181835
  }
181953
- if (!isConnection && selfProvisionedKeys.has(bindingKey(kind, name))) {
181836
+ if (selfProvisioned) {
181954
181837
  virtualCandidates.push({
181955
181838
  binding,
181956
181839
  kind,
@@ -181958,7 +181841,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181958
181841
  metadata,
181959
181842
  name,
181960
181843
  folderPath,
181961
- catalogMiss: false
181844
+ catalogMiss: false,
181845
+ selfProvisioned
181962
181846
  });
181963
181847
  continue;
181964
181848
  }
@@ -181981,7 +181865,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
181981
181865
  metadata,
181982
181866
  name,
181983
181867
  folderPath,
181984
- catalogMiss: true
181868
+ catalogMiss: true,
181869
+ selfProvisioned: false
181985
181870
  });
181986
181871
  continue;
181987
181872
  }
@@ -182010,6 +181895,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
182010
181895
  if (rcsMatch.key) {
182011
181896
  knownResourceKeys.add(rcsMatch.key.toLowerCase());
182012
181897
  overwrittenKeys.add(rcsMatch.key.toLowerCase());
181898
+ importedThisRun.add(rcsMatch.key.toLowerCase());
182013
181899
  }
182014
181900
  result.imported++;
182015
181901
  logger.info(`Imported ${kind} "${rcsMatch.name}" (key: ${rcsMatch.key}) into solution`);
@@ -182036,7 +181922,8 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
182036
181922
  metadata,
182037
181923
  name,
182038
181924
  folderPath,
182039
- catalogMiss: false
181925
+ catalogMiss: false,
181926
+ selfProvisioned: false
182040
181927
  });
182041
181928
  }
182042
181929
  const virtualCandidatesSeen = new Set;
@@ -182048,7 +181935,7 @@ async function syncResourcesFromBindings(solutionDir, projectPaths, projectSubTy
182048
181935
  return true;
182049
181936
  });
182050
181937
  for (const candidate of dedupedVirtuals) {
182051
- const [syncError, created] = await catchError(createVirtualForBinding(builder, candidate.binding, candidate.kind, candidate.type, candidate.metadata, candidate.name, candidate.folderPath, result, candidate.catalogMiss));
181938
+ const [syncError, created] = await catchError(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)));
182052
181939
  if (syncError) {
182053
181940
  logger.warn(`Failed to create virtual ${candidate.kind}/${candidate.name}: ${syncError.message}`);
182054
181941
  } else if (created) {
@@ -182127,6 +182014,15 @@ async function reportOrphanedDeclarations(services, builder, bindings, result) {
182127
182014
  logger.warn(warning);
182128
182015
  }
182129
182016
  }
182017
+ async function readReferencedResourceKeys(services, builder) {
182018
+ const overwrites = services.container.resolve(Tokens.IResourceOverwritesService);
182019
+ const [error, entries] = await catchError(overwrites.getTenantResourceOverwritesAsync(builder.context));
182020
+ if (error) {
182021
+ logger.debug(`Could not read the resource overwrites, so no root resource is known to be an import: ${error.message}`);
182022
+ return new Set;
182023
+ }
182024
+ return new Set(entries.filter((e) => String(e.overwrite?.type) === REFERENCE_OVERWRITE).map((e) => e.solutionResourceKey.toLowerCase()));
182025
+ }
182130
182026
  async function isUncheckedBindingCovered(builder, knownResourceKeys, kind, name, directCloudKey) {
182131
182027
  if (directCloudKey) {
182132
182028
  return knownResourceKeys.has(directCloudKey.toLowerCase());
@@ -182226,10 +182122,10 @@ async function mintVirtualResource(builder, kind, type, name, metadata) {
182226
182122
  }
182227
182123
  return { resource, finalName: uniqueName };
182228
182124
  }
182229
- async function createVirtualForBinding(builder, _binding, kind, type, metadata, name, folderPath, result, catalogMiss) {
182125
+ async function createVirtualForBinding(builder, _binding, kind, type, metadata, name, folderPath, result, catalogMiss, findCovering) {
182230
182126
  const virtualizable = metadata?.virtualizable ?? false;
182231
182127
  const preLoadSolution = await builder.context.loadAsync();
182232
- const alreadyVirtualized = findMatchingLocalResource(preLoadSolution.resources, kind, name, undefined);
182128
+ const alreadyVirtualized = await findCovering(preLoadSolution.resources);
182233
182129
  if (alreadyVirtualized) {
182234
182130
  result.skipped++;
182235
182131
  logger.info(`Skipping virtual ${kind} "${name}" — existing resource "${alreadyVirtualized.name}" in solution_folder already covers this binding (requested folder "${folderPath}")`);
@@ -182291,6 +182187,35 @@ async function findResourceByKeyInRcs(builder, kind, expectedKey, folderPath, pr
182291
182187
  }
182292
182188
  return;
182293
182189
  }
182190
+ async function findResourcesByKeysInRcs(builder, kind, keys) {
182191
+ const wanted = new Set([...keys].map((key) => key.toLowerCase()));
182192
+ const found = new Map;
182193
+ let pageCursor;
182194
+ while (found.size < wanted.size) {
182195
+ const result = await builder.searchResourcesAsync(kind, undefined, undefined, pageCursor, 100, undefined, false);
182196
+ for (const folderResources of result.availableResources) {
182197
+ for (const resource of folderResources.resources) {
182198
+ const key = resource.key.toLowerCase();
182199
+ if (!wanted.has(key) || found.has(key))
182200
+ continue;
182201
+ found.set(key, {
182202
+ key: resource.key,
182203
+ name: resource.name,
182204
+ type: resource.type,
182205
+ folder: {
182206
+ fullyQualifiedName: folderResources.fullyQualifiedName,
182207
+ folderKey: folderResources.key,
182208
+ path: folderResources.path
182209
+ }
182210
+ });
182211
+ }
182212
+ }
182213
+ pageCursor = result.nextPage;
182214
+ if (!pageCursor)
182215
+ break;
182216
+ }
182217
+ return found;
182218
+ }
182294
182219
  async function searchRcsResources(builder, kind, name) {
182295
182220
  const [searchError, matches] = await catchError(searchRcsResourcesStrict(builder, kind, name));
182296
182221
  if (searchError) {
@@ -182531,6 +182456,17 @@ async function collectBindings2(bindingsJsonFallbackDirs, serializer, sources) {
182531
182456
  const fs = getFileSystem();
182532
182457
  const allBindings = [];
182533
182458
  const parseErrors = [];
182459
+ const subTypes = new Map;
182460
+ const collect = (parsed) => {
182461
+ if ("error" in parsed) {
182462
+ parseErrors.push(parsed.error);
182463
+ return;
182464
+ }
182465
+ allBindings.push(...parsed.resources);
182466
+ for (const [binding, subType] of parsed.subTypes) {
182467
+ subTypes.set(binding, subType);
182468
+ }
182469
+ };
182534
182470
  for (const { directory: dir, contribution } of sources) {
182535
182471
  if (contribution) {
182536
182472
  if (contribution.bindings.length === 0)
@@ -182539,10 +182475,7 @@ async function collectBindings2(bindingsJsonFallbackDirs, serializer, sources) {
182539
182475
  version: "2.0",
182540
182476
  resources: contribution.bindings
182541
182477
  }), `${dir} (bindings contributed by the project's tool; project ${contribution.projectId})`, serializer);
182542
- if ("error" in parsed)
182543
- parseErrors.push(parsed.error);
182544
- else
182545
- allBindings.push(...parsed.resources);
182478
+ collect(parsed);
182546
182479
  continue;
182547
182480
  }
182548
182481
  const v2Path = fs.path.join(dir, "bindings_v2.json");
@@ -182563,13 +182496,9 @@ async function collectBindings2(bindingsJsonFallbackDirs, serializer, sources) {
182563
182496
  });
182564
182497
  continue;
182565
182498
  }
182566
- const parsed = deserializeBindings(new TextDecoder().decode(content), bindingsPath, serializer);
182567
- if ("error" in parsed)
182568
- parseErrors.push(parsed.error);
182569
- else
182570
- allBindings.push(...parsed.resources);
182499
+ collect(deserializeBindings(new TextDecoder().decode(content), bindingsPath, serializer));
182571
182500
  }
182572
- return { bindings: allBindings, parseErrors };
182501
+ return { bindings: allBindings, parseErrors, subTypes };
182573
182502
  }
182574
182503
  function deserializeBindings(decoded, source, serializer) {
182575
182504
  let success;
@@ -182594,7 +182523,8 @@ function deserializeBindings(decoded, source, serializer) {
182594
182523
  }
182595
182524
  };
182596
182525
  }
182597
- return { resources: metadata?.resources ?? [] };
182526
+ const resources = metadata?.resources ?? [];
182527
+ return { resources, subTypes: declaredSubTypes(decoded, resources) };
182598
182528
  }
182599
182529
  async function syncAndLog(solutionDir, projectSubTypes, options) {
182600
182530
  const [syncError, syncResult] = await catchError(syncResourcesFromBindings(solutionDir, undefined, projectSubTypes, options?.projectBindings, options?.selfProvisioned));
@@ -182614,11 +182544,11 @@ async function syncAndLog(solutionDir, projectSubTypes, options) {
182614
182544
  throw new CatalogLookupError(syncResult.catalogLookupFailure, syncResult.unresolved);
182615
182545
  }
182616
182546
  }
182617
- var TYPE_IS_IDENTITY_REPLACE_OPTIONS, BINDINGS_JSON_FALLBACK_TYPES, IMPLICIT_CONNECTION2 = "ImplicitConnection", OverwriteRefreshError;
182547
+ var TYPE_IS_IDENTITY_REPLACE_OPTIONS, BINDINGS_JSON_FALLBACK_TYPES, IMPLICIT_CONNECTION2 = "ImplicitConnection", OverwriteRefreshError, SUBTYPED_BINDING_KINDS, REFERENCE_OVERWRITE = "Reference";
182618
182548
  var init_sync_resources_from_bindings = __esm(() => {
182619
182549
  init_src2();
182620
182550
  init_src();
182621
- init_bindings2();
182551
+ init_bindings3();
182622
182552
  init_mappings();
182623
182553
  init_solution2();
182624
182554
  init_service_tokens();
@@ -182635,6 +182565,400 @@ var init_sync_resources_from_bindings = __esm(() => {
182635
182565
  BINDINGS_JSON_FALLBACK_TYPES = new Set(["agent", "function"]);
182636
182566
  OverwriteRefreshError = class OverwriteRefreshError extends Error {
182637
182567
  };
182568
+ SUBTYPED_BINDING_KINDS = new Set([
182569
+ "asset",
182570
+ "bucket"
182571
+ ]);
182572
+ });
182573
+
182574
+ // ../solution-sdk/src/resources/services/imported-resources.ts
182575
+ async function resolveImportedResourcesAsync(services, builder, resources) {
182576
+ const overwrites = await services.container.resolve(Tokens.IResourceOverwritesService).getTenantResourceOverwritesAsync(builder.context);
182577
+ const tenantNames = new Map;
182578
+ for (const entry of overwrites) {
182579
+ if (String(entry.overwrite?.type) !== REFERENCE_OVERWRITE2)
182580
+ continue;
182581
+ tenantNames.set(entry.solutionResourceKey.toLowerCase(), entry.overwrite?.resourceName || undefined);
182582
+ }
182583
+ const resolved = new Map;
182584
+ const unresolved = new Map;
182585
+ const unchecked = new Set;
182586
+ const byKind = new Map;
182587
+ for (const resource of resources) {
182588
+ const key = resource.key?.toLowerCase();
182589
+ if (!key)
182590
+ continue;
182591
+ if (normalizeFolderPath(resource.folders?.[0]?.fullyQualifiedName)) {
182592
+ continue;
182593
+ }
182594
+ const recorded = tenantNames.has(key);
182595
+ if (!recorded && resource.isArtefactResource)
182596
+ continue;
182597
+ const kind = resource.kind ?? "";
182598
+ byKind.set(kind, [...byKind.get(kind) ?? [], { key, recorded }]);
182599
+ }
182600
+ const reportFailed = (entries, reason) => {
182601
+ for (const { key, recorded } of entries) {
182602
+ if (recorded)
182603
+ unresolved.set(key, reason);
182604
+ else
182605
+ unchecked.add(key);
182606
+ }
182607
+ };
182608
+ let failure;
182609
+ for (const [kind, entries] of byKind) {
182610
+ if (failure) {
182611
+ reportFailed(entries, failure);
182612
+ continue;
182613
+ }
182614
+ const [error, matches] = await catchError(findResourcesByKeysInRcs(builder, kind, entries.map((entry) => entry.key)));
182615
+ if (error) {
182616
+ const reason = `the Resource Catalog could not be searched: ${error.message}`;
182617
+ reportFailed(entries, reason);
182618
+ if (stopsCatalogLookups(classifyCatalogFailure(error))) {
182619
+ failure = reason;
182620
+ }
182621
+ continue;
182622
+ }
182623
+ for (const { key, recorded } of entries) {
182624
+ const match = matches.get(key);
182625
+ if (match?.folder?.fullyQualifiedName) {
182626
+ resolved.set(key, {
182627
+ name: tenantNames.get(key) ?? match.name,
182628
+ folderPath: match.folder.fullyQualifiedName
182629
+ });
182630
+ } else if (recorded) {
182631
+ unresolved.set(key, "the Resource Catalog no longer lists it");
182632
+ }
182633
+ }
182634
+ }
182635
+ return { resolved, unresolved, unchecked };
182636
+ }
182637
+ var REFERENCE_OVERWRITE2 = "Reference";
182638
+ var init_imported_resources = __esm(() => {
182639
+ init_src2();
182640
+ init_service_tokens();
182641
+ init_catalog_lookup_failure();
182642
+ init_local_resource_matcher();
182643
+ init_sync_resources_from_bindings();
182644
+ });
182645
+
182646
+ // ../solution-sdk/src/resources/services/project-artifacts-service.ts
182647
+ async function addProjectArtifactsToSolutionAsync(options) {
182648
+ const error = await createProjectInSolutionBuilder(options.solutionDir, options.projectId, options.projectName, normalizeProjectType(options.projectType), options.projectSubType);
182649
+ return error ? artifactFailure(options, error) : { Created: true };
182650
+ }
182651
+ function artifactFailure(options, error) {
182652
+ 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.");
182653
+ return { Created: false, Error: error.message };
182654
+ }
182655
+ var init_project_artifacts_service = __esm(() => {
182656
+ init_src2();
182657
+ init_solution_file();
182658
+ init_project_utils();
182659
+ });
182660
+
182661
+ // ../solution-sdk/src/resources/services/project-template-types.ts
182662
+ function hasBareTemplateRow(projectType) {
182663
+ reader ??= new EmbeddedProjectConfigurationReader;
182664
+ return reader.getTemplateResourcesByType(projectType, undefined, false).length > 0;
182665
+ }
182666
+ function hasAnyTemplateRow(projectType) {
182667
+ reader ??= new EmbeddedProjectConfigurationReader;
182668
+ const wanted = projectType.toLowerCase();
182669
+ return Object.keys(reader.getAll()).some((row) => {
182670
+ const key = row.toLowerCase();
182671
+ return key === wanted || key.startsWith(`${wanted}_`);
182672
+ });
182673
+ }
182674
+ var reader;
182675
+ var init_project_template_types = __esm(() => {
182676
+ init_config2();
182677
+ });
182678
+
182679
+ // ../solution-sdk/src/resources/services/remote-resources.ts
182680
+ function getRemoteResourceClients(services) {
182681
+ return {
182682
+ catalog: services.container.resolve(Tokens.IResourceCatalogClientProxy),
182683
+ importer: services.container.resolve(Tokens.IImportResourceHelper)
182684
+ };
182685
+ }
182686
+ async function findCatalogEntityAsync(catalog, query, match) {
182687
+ let pageCursor;
182688
+ do {
182689
+ const page = await catalog.searchFolderEntities({
182690
+ ...query,
182691
+ pageSize: 100,
182692
+ pageCursor
182693
+ });
182694
+ const found = (page.items ?? []).find(match);
182695
+ if (found) {
182696
+ return found;
182697
+ }
182698
+ pageCursor = page.nextPage ?? undefined;
182699
+ } while (pageCursor);
182700
+ return;
182701
+ }
182702
+ async function findCatalogEntitiesAsync(catalog, query, match) {
182703
+ const found = [];
182704
+ let pageCursor;
182705
+ do {
182706
+ const page = await catalog.searchFolderEntities({
182707
+ ...query,
182708
+ pageSize: 100,
182709
+ pageCursor
182710
+ });
182711
+ found.push(...(page.items ?? []).filter(match));
182712
+ pageCursor = page.nextPage ?? undefined;
182713
+ } while (pageCursor);
182714
+ return found;
182715
+ }
182716
+ function toResourceReference(entity) {
182717
+ return toCatalogReference({
182718
+ kind: entity.entityType ?? "",
182719
+ type: entity.entitySubType ?? undefined,
182720
+ key: entity.entityKey ?? "",
182721
+ name: entity.entityName ?? undefined,
182722
+ folderPath: entity.fullyQualifiedName ?? undefined,
182723
+ folderKey: entity.folderKey ?? undefined
182724
+ });
182725
+ }
182726
+ function toCatalogReference(reference) {
182727
+ const { folderPath, folderKey, ...rest } = reference;
182728
+ return {
182729
+ ...rest,
182730
+ folder: folderPath ? { fullyQualifiedName: folderPath, folderKey } : undefined
182731
+ };
182732
+ }
182733
+ async function exportResourceDefinitionAsync(importer, reference) {
182734
+ const [error, payload] = await catchError(importer.exportResourceAsync(reference));
182735
+ if (error) {
182736
+ throw withExportStatus(error);
182737
+ }
182738
+ return payload.resourceDefinitions.find((d) => d.key === reference.key);
182739
+ }
182740
+ function withExportStatus(error) {
182741
+ if (!(error instanceof Error) || !("exceptionData" in error)) {
182742
+ return error;
182743
+ }
182744
+ const data = error.exceptionData;
182745
+ const text = typeof data === "object" && data !== null ? data.errorMessage : undefined;
182746
+ const match = typeof text === "string" ? /^HTTP (\d{3})\b/.exec(text) : null;
182747
+ return match ? new ResourceExportError(error.message, Number(match[1]), error) : error;
182748
+ }
182749
+ function readSpecProperty(spec, name) {
182750
+ if (!spec) {
182751
+ return;
182752
+ }
182753
+ if (spec[name] !== undefined) {
182754
+ return spec[name];
182755
+ }
182756
+ const lower = name.toLowerCase();
182757
+ const key = Object.keys(spec).find((k) => k.toLowerCase() === lower);
182758
+ return key === undefined ? undefined : spec[key];
182759
+ }
182760
+ function readSpecEntryPoints(spec) {
182761
+ const entryPoints = parseJsonString(readSpecProperty(spec, "entryPoints"));
182762
+ if (!Array.isArray(entryPoints) || !entryPoints.every((entry) => entry !== null && typeof entry === "object")) {
182763
+ return;
182764
+ }
182765
+ return entryPoints.map((entry) => ({
182766
+ UniqueId: String(readSpecProperty(entry, "uniqueId") ?? ""),
182767
+ Path: String(readSpecProperty(entry, "path") ?? ""),
182768
+ DisplayName: String(readSpecProperty(entry, "displayName") ?? ""),
182769
+ InputArguments: readSpecProperty(entry, "inputArguments"),
182770
+ OutputArguments: readSpecProperty(entry, "outputArguments")
182771
+ }));
182772
+ }
182773
+ function parseJsonString(raw) {
182774
+ if (typeof raw !== "string") {
182775
+ return raw;
182776
+ }
182777
+ const [error, parsed] = catchError(() => JSON.parse(raw));
182778
+ return error ? undefined : parsed;
182779
+ }
182780
+ var ResourceExportError;
182781
+ var init_remote_resources = __esm(() => {
182782
+ init_src2();
182783
+ init_service_tokens();
182784
+ ResourceExportError = class ResourceExportError extends Error {
182785
+ status;
182786
+ constructor(message, status, cause) {
182787
+ super(message, { cause });
182788
+ this.status = status;
182789
+ this.name = "ResourceExportError";
182790
+ }
182791
+ };
182792
+ });
182793
+
182794
+ // ../solution-sdk/src/resources/services/resource-configurations.ts
182795
+ function isResourceKeyNotFound(error, resourceKey) {
182796
+ if (!(error instanceof Error))
182797
+ return false;
182798
+ const typed = error;
182799
+ const sameKey = (key) => key !== undefined && key.toLowerCase() === resourceKey.toLowerCase();
182800
+ if (typeof typed.resourceType === "string" && typeof typed.resourceKey === "string") {
182801
+ return ROOT_RESOURCE_TYPES.has(typed.resourceType.toLowerCase()) && sameKey(typed.resourceKey);
182802
+ }
182803
+ return sameKey(KEY_NOT_FOUND.exec(error.message.trim())?.[1]);
182804
+ }
182805
+ async function refreshArtefactSpecsAsync(builder, configurations) {
182806
+ const resources = new Map;
182807
+ const [loadError, solution] = await catchError(builder.context.loadAsync());
182808
+ if (loadError || !solution)
182809
+ return resources;
182810
+ for (const configuration of configurations) {
182811
+ const resource = solution.resources.find((r) => r.key === configuration?.key);
182812
+ if (!resource)
182813
+ continue;
182814
+ resources.set(resource.key, resource);
182815
+ if (!resource.projectKey)
182816
+ continue;
182817
+ configuration.spec = await applyEntryPointEnhancementAsync(builder.context, resource, configuration.spec ?? {});
182818
+ }
182819
+ return resources;
182820
+ }
182821
+ async function exportResourceConfigurationsAsync(services, resourceKey, hint = {}) {
182822
+ const { catalog, importer } = getRemoteResourceClients(services);
182823
+ const byKey = (item) => item.entityKey === resourceKey;
182824
+ const entity = (hint.name ? await findCatalogEntityAsync(catalog, { name: hint.name }, byKey) : undefined) ?? await findCatalogEntityAsync(catalog, {}, byKey);
182825
+ if (!entity) {
182826
+ throw new Error(`Resource '${resourceKey}' was not found in the solution or in the resource catalog`);
182827
+ }
182828
+ const payload = await importer.exportResourceAsync(toResourceReference(entity));
182829
+ const definitions = payload.resourceDefinitions ?? [];
182830
+ if (definitions.length === 0) {
182831
+ throw new Error(`FPS export for '${resourceKey}' returned no resource definitions`);
182832
+ }
182833
+ return {
182834
+ resources: definitions.map((d) => ({
182835
+ key: d.key ?? "",
182836
+ spec: d.spec ?? {},
182837
+ locks: d.locks ?? [],
182838
+ apiVersion: d.apiVersion,
182839
+ isOverridable: d.isOverridable,
182840
+ name: d.name ?? "",
182841
+ kind: d.kind ?? "",
182842
+ dependencies: (d.dependencies ?? []).map((dep) => ({
182843
+ kind: dep.kind ?? "",
182844
+ name: dep.name ?? ""
182845
+ }))
182846
+ }))
182847
+ };
182848
+ }
182849
+ async function readLocalAsync(builder, resourceKey, read) {
182850
+ if (!builder)
182851
+ return;
182852
+ const [error, value] = await catchError(read(builder));
182853
+ if (!error)
182854
+ return { builder, value };
182855
+ if (isResourceKeyNotFound(error, resourceKey))
182856
+ return;
182857
+ throw error;
182858
+ }
182859
+ async function readResourceConfigurationsAsync(services, builder, resourceKey, hint = {}) {
182860
+ const local = await readLocalAsync(builder, resourceKey, (b) => b.getAllConfigurationsAsync(resourceKey));
182861
+ if (!local) {
182862
+ return exportResourceConfigurationsAsync(services, resourceKey, hint);
182863
+ }
182864
+ await refreshArtefactSpecsAsync(local.builder, local.value?.resources ?? []);
182865
+ return local.value;
182866
+ }
182867
+ async function readResourceConfigurationAsync(services, builder, resourceKey) {
182868
+ const local = await readLocalAsync(builder, resourceKey, (b) => b.getConfigurationAsync(resourceKey));
182869
+ if (local) {
182870
+ const configuration = local.value;
182871
+ const resources = await refreshArtefactSpecsAsync(local.builder, [
182872
+ configuration
182873
+ ]);
182874
+ return { configuration, resource: resources.get(configuration.key) };
182875
+ }
182876
+ const { resources } = await exportResourceConfigurationsAsync(services, resourceKey);
182877
+ const primary = resources.find((r) => r.key === resourceKey) ?? resources[0];
182878
+ const { key, spec, locks, apiVersion, isOverridable } = primary;
182879
+ return { configuration: { key, spec, locks, apiVersion, isOverridable } };
182880
+ }
182881
+ var ROOT_RESOURCE_TYPES, KEY_NOT_FOUND;
182882
+ var init_resource_configurations = __esm(() => {
182883
+ init_src2();
182884
+ init_entry_point_spec_enhancer();
182885
+ init_remote_resources();
182886
+ ROOT_RESOURCE_TYPES = new Set(["resource", "solutionresource"]);
182887
+ KEY_NOT_FOUND = /^(?:Solution)?Resource with key '([^']+)' was not found$/i;
182888
+ });
182889
+
182890
+ // ../solution-sdk/src/resources/services/resource-lookup.ts
182891
+ async function findResourcesByNameAsync(services, builder, { kind, name, subTypes, folderKey }) {
182892
+ const same = (a, b) => (a ?? "").toLowerCase() === b.toLowerCase();
182893
+ const ofSubType = (type) => subTypes === undefined || subTypes.some((t) => same(type, t));
182894
+ if (builder) {
182895
+ const solution = await builder.context.loadAsync();
182896
+ const local = solution.resources.filter((r) => same(r.kind, kind) && same(r.name, name) && ofSubType(r.type)).map((r) => ({
182897
+ key: r.key,
182898
+ local: true,
182899
+ folderPath: r.folders?.[0]?.fullyQualifiedName
182900
+ }));
182901
+ if (local.length > 0)
182902
+ return local;
182903
+ }
182904
+ const { catalog } = getRemoteResourceClients(services);
182905
+ 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)));
182906
+ return rows.map((row) => ({
182907
+ key: row.entityKey ?? "",
182908
+ local: false,
182909
+ folderPath: row.fullyQualifiedName ?? undefined,
182910
+ folderKey: row.folderKey ?? undefined
182911
+ }));
182912
+ }
182913
+ var init_resource_lookup = __esm(() => {
182914
+ init_remote_resources();
182915
+ });
182916
+
182917
+ // ../solution-sdk/src/resources/services/resource-name.ts
182918
+ function hasControlChar(value) {
182919
+ for (let i = 0;i < value.length; i++) {
182920
+ if (value.charCodeAt(i) < 32)
182921
+ return true;
182922
+ }
182923
+ return false;
182924
+ }
182925
+ function hasUnsafeNameChars(name) {
182926
+ return UNSAFE_NAME_CHARS.test(name) || hasControlChar(name);
182927
+ }
182928
+ function validateResourceName(name, options = {}) {
182929
+ const optionName = options.optionName ?? "--name";
182930
+ if (name.trim() === "") {
182931
+ return {
182932
+ ok: false,
182933
+ message: `${optionName} must not be blank`,
182934
+ instructions: "Pass a non-empty resource name."
182935
+ };
182936
+ }
182937
+ if (name.length > MAX_RESOURCE_NAME_LENGTH) {
182938
+ return {
182939
+ ok: false,
182940
+ message: `${optionName} exceeds the ${MAX_RESOURCE_NAME_LENGTH}-character limit (got ${name.length})`,
182941
+ instructions: "Shorten the resource name. Orchestrator name limits are kind-specific (queues cap at 50, assets at 256)."
182942
+ };
182943
+ }
182944
+ if (hasUnsafeNameChars(name)) {
182945
+ return {
182946
+ ok: false,
182947
+ message: `${optionName} contains unsafe characters`,
182948
+ instructions: 'Resource names cannot contain path separators (/, \\), control characters, or any of: : * ? " < > |'
182949
+ };
182950
+ }
182951
+ return { ok: true };
182952
+ }
182953
+ function assertValidResourceName(name, options = {}) {
182954
+ const result = validateResourceName(name, options);
182955
+ if (!result.ok) {
182956
+ throw new Error(`${result.message}. ${result.instructions}`);
182957
+ }
182958
+ }
182959
+ var MAX_RESOURCE_NAME_LENGTH = 256, UNSAFE_NAME_CHARS;
182960
+ var init_resource_name = __esm(() => {
182961
+ UNSAFE_NAME_CHARS = /[\\/:*?"<>|]/;
182638
182962
  });
182639
182963
 
182640
182964
  // ../solution-sdk/src/resources/services/resource-refresh-service.ts
@@ -182675,7 +182999,11 @@ async function resourceRefreshAsync(solutionPath = ".", options = {}) {
182675
182999
  if (bindingsError) {
182676
183000
  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'.`);
182677
183001
  }
182678
- const [syncError, result] = await catchError(syncResourcesFromBindings(resolvedPath, undefined, projectSubTypes ?? new Map, projectBindings ?? new Map, undefined, {
183002
+ const [selfProvisionedError, selfProvisioned] = await catchError(options.resolveSelfProvisionedAsync?.() ?? Promise.resolve([]));
183003
+ if (selfProvisionedError) {
183004
+ 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'.`);
183005
+ }
183006
+ const [syncError, result] = await catchError(syncResourcesFromBindings(resolvedPath, undefined, projectSubTypes ?? new Map, projectBindings ?? new Map, selfProvisioned?.length ? [...selfProvisioned] : undefined, {
182679
183007
  bindingsComplete: !bindingsError && (options.isProjectBindingsComplete?.() ?? true)
182680
183008
  }));
182681
183009
  if (syncError) {
@@ -182918,6 +183246,7 @@ __export(exports_resources, {
182918
183246
  findProjectFile: () => findProjectFile,
182919
183247
  findResourceByKeyInRcs: () => findResourceByKeyInRcs,
182920
183248
  findResourceInRcs: () => findResourceInRcs,
183249
+ findResourcesByKeysInRcs: () => findResourcesByKeysInRcs,
182921
183250
  findResourcesByNameAsync: () => findResourcesByNameAsync,
182922
183251
  formatResourceSubtypes: () => formatResourceSubtypes,
182923
183252
  getRemoteResourceClients: () => getRemoteResourceClients,
@@ -182939,6 +183268,7 @@ __export(exports_resources, {
182939
183268
  readSpecProperty: () => readSpecProperty,
182940
183269
  readUipxProjects: () => readUipxProjects,
182941
183270
  refreshArtefactSpecsAsync: () => refreshArtefactSpecsAsync,
183271
+ resolveImportedResourcesAsync: () => resolveImportedResourcesAsync,
182942
183272
  resolveProjectDirFromManifest: () => resolveProjectDirFromManifest,
182943
183273
  resolveResourceKindMetadata: () => resolveResourceKindMetadata,
182944
183274
  resolveSolutionFilePath: () => resolveSolutionFilePath,
@@ -182963,6 +183293,7 @@ var init_resources = __esm(() => {
182963
183293
  init_project_utils();
182964
183294
  init_resource_builder_init();
182965
183295
  init_entry_point_spec_enhancer();
183296
+ init_imported_resources();
182966
183297
  init_local_resource_matcher();
182967
183298
  init_project_artifacts_service();
182968
183299
  init_project_template_types();
@@ -288905,4 +289236,4 @@ export {
288905
289236
  withPimsCall
288906
289237
  };
288907
289238
 
288908
- //# debugId=C081C16475589F1E64756E2164756E21
289239
+ //# debugId=8DE90ADEC582786064756E2164756E21