@base44-preview/cli 0.0.51-pr.503.abe7299 → 0.0.51-pr.503.f6edfc1

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/cli/index.js CHANGED
@@ -124338,7 +124338,7 @@ var init_prettier = __esm(() => {
124338
124338
  const absolute = [];
124339
124339
  const relative22 = [];
124340
124340
  for (const pattern of patterns) {
124341
- if (isAbsolute2(pattern)) {
124341
+ if (isAbsolute3(pattern)) {
124342
124342
  absolute.push(pattern);
124343
124343
  } else {
124344
124344
  relative22.push(pattern);
@@ -124347,10 +124347,10 @@ var init_prettier = __esm(() => {
124347
124347
  return [absolute, relative22];
124348
124348
  }
124349
124349
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
124350
- function isAbsolute2(pattern) {
124350
+ function isAbsolute3(pattern) {
124351
124351
  return path152.isAbsolute(pattern);
124352
124352
  }
124353
- exports.isAbsolute = isAbsolute2;
124353
+ exports.isAbsolute = isAbsolute3;
124354
124354
  }
124355
124355
  });
124356
124356
  require_merge22 = __commonJS2({
@@ -234623,7 +234623,7 @@ var SiteConfigSchema = exports_external.object({
234623
234623
  installCommand: exports_external.string().optional()
234624
234624
  });
234625
234625
  var PluginMetadataSchema = exports_external.object({
234626
- id: exports_external.string().min(1, "Plugin id cannot be empty").regex(/^[a-zA-Z0-9_-]+$/, "Plugin id can only contain letters, numbers, underscores, and dashes")
234626
+ namespace: exports_external.string().min(1, "Plugin namespace cannot be empty").regex(/^[a-zA-Z0-9_-]+$/, "Plugin namespace can only contain letters, numbers, underscores, and dashes")
234627
234627
  });
234628
234628
  var PluginReferenceSchema = exports_external.object({
234629
234629
  source: exports_external.string().min(1, "Plugin source cannot be empty")
@@ -241591,36 +241591,36 @@ import { dirname as dirname6, join as join9 } from "node:path";
241591
241591
 
241592
241592
  // src/core/project/plugins.ts
241593
241593
  import { createRequire as createRequire2 } from "node:module";
241594
- import { dirname as dirname3, join as join3, resolve } from "node:path";
241594
+ import { dirname as dirname3, isAbsolute as isAbsolute2, join as join3, resolve } from "node:path";
241595
241595
  function resolvePluginRoot(pluginSource, fromRoot) {
241596
- if (pluginSource.startsWith(".")) {
241596
+ if (pluginSource.startsWith(".") || isAbsolute2(pluginSource)) {
241597
241597
  return resolve(fromRoot, pluginSource);
241598
241598
  }
241599
241599
  const req = createRequire2(join3(fromRoot, "package.json"));
241600
241600
  return dirname3(req.resolve(`${pluginSource}/package.json`));
241601
241601
  }
241602
- function requirePluginId(project, pluginSource, configPath) {
241603
- if (!project.plugin?.id) {
241604
- throw new ConfigInvalidError(`Plugin loaded from "${pluginSource}" must define plugin.id`, configPath);
241602
+ function requirePluginNamespace(project, pluginSource, configPath) {
241603
+ if (!project.plugin?.namespace) {
241604
+ throw new ConfigInvalidError(`Plugin loaded from "${pluginSource}" must define plugin.namespace`, configPath);
241605
241605
  }
241606
- return project.plugin.id;
241606
+ return project.plugin.namespace;
241607
241607
  }
241608
- function namespacePluginFunctions(functions, pluginId) {
241608
+ function namespacePluginFunctions(functions, pluginNamespace) {
241609
241609
  return functions.map((fn) => ({
241610
241610
  ...fn,
241611
- name: `${pluginId}__${fn.name}`,
241611
+ name: `${pluginNamespace}__${fn.name}`,
241612
241612
  source: {
241613
241613
  type: "plugin",
241614
- id: pluginId
241614
+ namespace: pluginNamespace
241615
241615
  }
241616
241616
  }));
241617
241617
  }
241618
- function markPluginEntities(entities, pluginId) {
241618
+ function markPluginEntities(entities, pluginNamespace) {
241619
241619
  return entities.map((entity) => ({
241620
241620
  ...entity,
241621
241621
  source: {
241622
241622
  type: "plugin",
241623
- id: pluginId
241623
+ namespace: pluginNamespace
241624
241624
  }
241625
241625
  }));
241626
241626
  }
@@ -242782,7 +242782,7 @@ var ResourceSourceSchema = exports_external.discriminatedUnion("type", [
242782
242782
  }),
242783
242783
  exports_external.object({
242784
242784
  type: exports_external.literal("plugin"),
242785
- id: exports_external.string().min(1, "Plugin id cannot be empty")
242785
+ namespace: exports_external.string().min(1, "Plugin namespace cannot be empty")
242786
242786
  })
242787
242787
  ]);
242788
242788
 
@@ -242943,7 +242943,7 @@ async function readAllEntities(entitiesDir) {
242943
242943
  const names = new Set;
242944
242944
  for (const entity of entities) {
242945
242945
  if (names.has(entity.name)) {
242946
- throw new InvalidInputError(`Duplicate entity name "${entity.name}"`, {
242946
+ throw new ConfigInvalidError(`Duplicate entity name "${entity.name}" in ${entitiesDir}`, entitiesDir, {
242947
242947
  hints: [
242948
242948
  {
242949
242949
  message: `Remove duplicate entities with name "${entity.name}" - only one entity per name is allowed`
@@ -242969,11 +242969,8 @@ var entityResource = {
242969
242969
  };
242970
242970
  // src/core/resources/entity/merge.ts
242971
242971
  function mergePluginEntity(pluginEntity, projectEntity, configPath) {
242972
- const unsupportedFields = [
242973
- projectEntity.title ? "title" : null,
242974
- projectEntity.description ? "description" : null,
242975
- projectEntity.rls ? "rls" : null
242976
- ].filter(Boolean);
242972
+ const projectEntityFields = new Set(Object.keys(projectEntity));
242973
+ const unsupportedFields = ["title", "description", "rls"].filter((field) => projectEntityFields.has(field));
242977
242974
  if (unsupportedFields.length > 0) {
242978
242975
  throw new ConfigInvalidError(`Project entity "${projectEntity.name}" extends a plugin entity and cannot override fields: ${unsupportedFields.join(", ")}.`, configPath);
242979
242976
  }
@@ -242986,7 +242983,7 @@ function mergePluginEntity(pluginEntity, projectEntity, configPath) {
242986
242983
  }
242987
242984
  for (const requiredProperty of projectEntity.required ?? []) {
242988
242985
  if (!addedPropertyNames.has(requiredProperty)) {
242989
- throw new ConfigInvalidError(`Required property "${requiredProperty}" must be declared in project entity "${projectEntity.name}" properties`, configPath);
242986
+ throw new ConfigInvalidError(`Project entity "${projectEntity.name}" can only mark project-added properties as required; "${requiredProperty}" is not declared in the project extension.`, configPath);
242990
242987
  }
242991
242988
  }
242992
242989
  const required2 = pluginEntity.required || projectEntity.required ? [
@@ -243297,7 +243294,7 @@ async function readAllFunctions(functionsDir) {
243297
243294
  const names = new Set;
243298
243295
  for (const fn of functions) {
243299
243296
  if (names.has(fn.name)) {
243300
- throw new InvalidInputError(`Duplicate function name "${fn.name}"`, {
243297
+ throw new ConfigInvalidError(`Duplicate function name "${fn.name}" in ${functionsDir}`, functionsDir, {
243301
243298
  hints: [
243302
243299
  {
243303
243300
  message: "Ensure each function has a unique name (or path for zero-config functions)."
@@ -243464,18 +243461,19 @@ async function findProjectRoot(startPath) {
243464
243461
  }
243465
243462
 
243466
243463
  class ProjectConfigReader {
243467
- pluginIds = new Set;
243464
+ pluginSourceByNamespace = new Map;
243468
243465
  async readProjectConfig(projectRoot) {
243469
243466
  const { root, configPath } = await this.findConfigOrThrow(projectRoot);
243470
243467
  const project = await this.readConfigFile(configPath);
243471
243468
  this.assertPluginProjectDoesNotLoadPlugins(project, configPath);
243472
243469
  const localResources = await this.readProjectResources(configPath, project);
243473
- const pluginResources = await this.readPlugins(project.plugins, root);
243470
+ const pluginResources = await this.readPlugins(project.plugins, configPath);
243474
243471
  const entities = mergeProjectAndPluginEntities(localResources.entities, pluginResources.entities, configPath);
243475
243472
  const functions = [
243476
243473
  ...localResources.functions,
243477
243474
  ...pluginResources.functions
243478
243475
  ];
243476
+ this.validateFunctionNames(functions, configPath);
243479
243477
  return {
243480
243478
  project: { ...project, root, configPath },
243481
243479
  entities,
@@ -243522,48 +243520,54 @@ class ProjectConfigReader {
243522
243520
  throw new ConfigInvalidError("Plugin projects cannot define plugins in this version.", configPath);
243523
243521
  }
243524
243522
  }
243525
- registerPluginId(pluginId, configPath) {
243526
- if (this.pluginIds.has(pluginId)) {
243527
- throw new ConfigInvalidError(`Duplicate plugin id "${pluginId}" in project configuration`, configPath, {
243523
+ registerPluginNamespace(namespace, source, configPath) {
243524
+ const existingSource = this.pluginSourceByNamespace.get(namespace);
243525
+ if (existingSource) {
243526
+ throw new ConfigInvalidError(`Duplicate plugin namespace "${namespace}" in project configuration: "${existingSource}" and "${source}".`, configPath, {
243528
243527
  hints: [
243529
243528
  {
243530
- message: "Remove the plugin or change plugin id"
243529
+ message: "Remove the plugin or change plugin namespace"
243531
243530
  }
243532
243531
  ]
243533
243532
  });
243534
243533
  }
243535
- this.pluginIds.add(pluginId);
243534
+ this.pluginSourceByNamespace.set(namespace, source);
243536
243535
  }
243537
- async readPluginConfig(plugin, hostRoot) {
243538
- const pluginRoot = resolvePluginRoot(plugin.source, hostRoot);
243536
+ async readPluginConfig(plugin, hostConfigPath) {
243537
+ const pluginRoot = resolvePluginRoot(plugin.source, dirname6(hostConfigPath));
243539
243538
  const { configPath } = await this.findConfigOrThrow(pluginRoot);
243540
243539
  const project = await this.readConfigFile(configPath);
243541
- const pluginId = requirePluginId(project, plugin.source, configPath);
243540
+ const namespace = requirePluginNamespace(project, plugin.source, configPath);
243542
243541
  this.assertPluginProjectDoesNotLoadPlugins(project, configPath);
243543
- return { configPath, pluginId, project };
243542
+ return { configPath, namespace, project, source: plugin.source };
243544
243543
  }
243545
- async readPluginResources(project, configPath, pluginId) {
243544
+ async readPluginResources(project, configPath, namespace) {
243546
243545
  const resources = await this.readProjectResources(configPath, project);
243547
243546
  return {
243548
- entities: markPluginEntities(resources.entities, pluginId),
243549
- functions: namespacePluginFunctions(resources.functions, pluginId),
243547
+ entities: markPluginEntities(resources.entities, namespace),
243548
+ functions: namespacePluginFunctions(resources.functions, namespace),
243550
243549
  agents: [],
243551
243550
  connectors: [],
243552
243551
  authConfig: []
243553
243552
  };
243554
243553
  }
243555
- async readPlugins(plugins, projectRoot) {
243554
+ async readPlugins(plugins, configPath) {
243556
243555
  const entities = [];
243557
243556
  const functions = [];
243558
- const entityNameByPluginId = new Map;
243557
+ const pluginSourceByEntityName = new Map;
243559
243558
  for (const plugin of plugins) {
243560
- const { configPath, pluginId, project } = await this.readPluginConfig(plugin, projectRoot);
243561
- this.registerPluginId(pluginId, configPath);
243562
- const pluginData = await this.readPluginResources(project, configPath, pluginId);
243559
+ const {
243560
+ configPath: pluginConfigPath,
243561
+ namespace,
243562
+ project,
243563
+ source
243564
+ } = await this.readPluginConfig(plugin, configPath);
243565
+ this.registerPluginNamespace(namespace, source, pluginConfigPath);
243566
+ const pluginData = await this.readPluginResources(project, pluginConfigPath, namespace);
243563
243567
  for (const entity of pluginData.entities) {
243564
- const existingPluginId = entityNameByPluginId.get(entity.name);
243565
- if (existingPluginId) {
243566
- throw new ConfigInvalidError(`Entity "${entity.name}" is defined by more than one plugin: "${existingPluginId}" and "${pluginId}".`, configPath, {
243568
+ const existingSource = pluginSourceByEntityName.get(entity.name);
243569
+ if (existingSource) {
243570
+ throw new ConfigInvalidError(`Entity "${entity.name}" is defined by more than one plugin: "${existingSource}" and "${source}".`, pluginConfigPath, {
243567
243571
  hints: [
243568
243572
  {
243569
243573
  message: "Plugin entity names are not namespaced. Remove one plugin or rename one of the entities."
@@ -243571,7 +243575,7 @@ class ProjectConfigReader {
243571
243575
  ]
243572
243576
  });
243573
243577
  }
243574
- entityNameByPluginId.set(entity.name, pluginId);
243578
+ pluginSourceByEntityName.set(entity.name, source);
243575
243579
  }
243576
243580
  entities.push(...pluginData.entities);
243577
243581
  functions.push(...pluginData.functions);
@@ -243584,6 +243588,22 @@ class ProjectConfigReader {
243584
243588
  authConfig: []
243585
243589
  };
243586
243590
  }
243591
+ validateFunctionNames(functions, configPath) {
243592
+ const functionsByName = new Map;
243593
+ for (const fn of functions) {
243594
+ const existingFunction = functionsByName.get(fn.name);
243595
+ if (existingFunction) {
243596
+ throw new ConfigInvalidError(`Duplicate function name "${fn.name}" after loading project plugins.`, configPath, {
243597
+ hints: [
243598
+ {
243599
+ message: "Rename the project function or change the plugin namespace/function name so every deploy name is unique."
243600
+ }
243601
+ ]
243602
+ });
243603
+ }
243604
+ functionsByName.set(fn.name, fn);
243605
+ }
243606
+ }
243587
243607
  }
243588
243608
  async function readProjectConfig(projectRoot) {
243589
243609
  const reader = new ProjectConfigReader;
@@ -252799,12 +252819,12 @@ async function pullFunctionsAction({ log, runTask: runTask2 }, name2) {
252799
252819
  successMessage: "Functions fetched successfully",
252800
252820
  errorMessage: "Failed to fetch functions"
252801
252821
  });
252802
- const matchingRemote = name2 ? remoteFunctions.filter((f) => f.name === name2) : remoteFunctions;
252803
252822
  if (name2 && pluginFunctionNames.has(name2)) {
252804
252823
  return {
252805
252824
  outroMessage: `Function "${name2}" is managed by a plugin and was not pulled into ${functionsDir}`
252806
252825
  };
252807
252826
  }
252827
+ const matchingRemote = name2 ? remoteFunctions.filter((f) => f.name === name2) : remoteFunctions;
252808
252828
  if (name2 && matchingRemote.length === 0) {
252809
252829
  return {
252810
252830
  outroMessage: `Function "${name2}" not found on remote`
@@ -261525,4 +261545,4 @@ export {
261525
261545
  CLIExitError
261526
261546
  };
261527
261547
 
261528
- //# debugId=6F53421EFB4CBB2764756E2164756E21
261548
+ //# debugId=2ADA1E4C26BBE1A464756E2164756E21