@databricks/appkit-ui 0.92.0 → 0.94.0

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.
Files changed (72) hide show
  1. package/CLAUDE.md +3 -0
  2. package/dist/cli/commands/docs.js +231 -10
  3. package/dist/cli/commands/docs.js.map +1 -1
  4. package/dist/cli/commands/plugin/add/add.js +398 -0
  5. package/dist/cli/commands/plugin/add/add.js.map +1 -0
  6. package/dist/cli/commands/plugin/add/plan.js +216 -0
  7. package/dist/cli/commands/plugin/add/plan.js.map +1 -0
  8. package/dist/cli/commands/plugin/add/resolve.js +45 -0
  9. package/dist/cli/commands/plugin/add/resolve.js.map +1 -0
  10. package/dist/cli/commands/plugin/index.js +4 -1
  11. package/dist/cli/commands/plugin/index.js.map +1 -1
  12. package/dist/cli/commands/registry/add.js +3 -2
  13. package/dist/cli/commands/registry/add.js.map +1 -1
  14. package/dist/cli/commands/registry/config-plan.js +1 -1
  15. package/dist/cli/commands/registry/config-plan.js.map +1 -1
  16. package/dist/cli/commands/registry/config-writer.js +77 -9
  17. package/dist/cli/commands/registry/config-writer.js.map +1 -1
  18. package/dist/cli/commands/registry/env-writer.js +1 -1
  19. package/dist/cli/commands/registry/env-writer.js.map +1 -1
  20. package/dist/cli/commands/registry/server-register.js +62 -26
  21. package/dist/cli/commands/registry/server-register.js.map +1 -1
  22. package/dist/cli/commands/registry/workspace-picker.js +1 -1
  23. package/dist/cli/deploy-config.js.map +1 -1
  24. package/dist/cli/index.js +1 -1
  25. package/dist/react/beta.d.ts +3 -1
  26. package/dist/react/beta.js +3 -1
  27. package/dist/react/charts/base.d.ts +1 -1
  28. package/dist/react/charts/base.d.ts.map +1 -1
  29. package/dist/react/charts/base.js +5 -3
  30. package/dist/react/charts/base.js.map +1 -1
  31. package/dist/react/charts/constants.js +13 -1
  32. package/dist/react/charts/constants.js.map +1 -1
  33. package/dist/react/charts/create-chart.js +1 -1
  34. package/dist/react/charts/create-chart.js.map +1 -1
  35. package/dist/react/charts/index.d.ts +1 -1
  36. package/dist/react/charts/types.d.ts +17 -8
  37. package/dist/react/charts/types.d.ts.map +1 -1
  38. package/dist/react/charts/types.js.map +1 -1
  39. package/dist/react/charts/wrapper.d.ts +1 -1
  40. package/dist/react/charts/wrapper.d.ts.map +1 -1
  41. package/dist/react/charts/wrapper.js +12 -5
  42. package/dist/react/charts/wrapper.js.map +1 -1
  43. package/dist/react/design-page.d.ts +33 -0
  44. package/dist/react/design-page.d.ts.map +1 -0
  45. package/dist/react/design-page.js +173 -0
  46. package/dist/react/design-page.js.map +1 -0
  47. package/dist/react/hooks/use-design-ready.d.ts +19 -0
  48. package/dist/react/hooks/use-design-ready.d.ts.map +1 -0
  49. package/dist/react/hooks/use-design-ready.js +33 -0
  50. package/dist/react/hooks/use-design-ready.js.map +1 -0
  51. package/dist/react/index.d.ts +2 -2
  52. package/dist/react/table/data-table.d.ts +6 -0
  53. package/dist/react/table/data-table.d.ts.map +1 -1
  54. package/dist/react/table/data-table.js +6 -0
  55. package/dist/react/table/data-table.js.map +1 -1
  56. package/dist/shared/src/plugin.d.ts.map +1 -1
  57. package/docs/api/appkit/Variable.design.md +6 -0
  58. package/docs/api/appkit-ui/data/AreaChart.md +25 -25
  59. package/docs/api/appkit-ui/data/BarChart.md +23 -23
  60. package/docs/api/appkit-ui/data/DataTable.md +2 -0
  61. package/docs/api/appkit-ui/data/DonutChart.md +24 -24
  62. package/docs/api/appkit-ui/data/HeatmapChart.md +25 -25
  63. package/docs/api/appkit-ui/data/LineChart.md +24 -24
  64. package/docs/api/appkit-ui/data/PieChart.md +24 -24
  65. package/docs/api/appkit-ui/data/RadarChart.md +22 -22
  66. package/docs/api/appkit-ui/data/ScatterChart.md +22 -22
  67. package/docs/api/appkit.md +1 -0
  68. package/docs/plugins/analytics.md +9 -1
  69. package/docs/plugins/design.md +233 -0
  70. package/llms.txt +3 -0
  71. package/package.json +1 -1
  72. package/sbom.cdx.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config-plan.js","names":[],"sources":["../../../../src/cli/commands/registry/config-plan.ts"],"sourcesContent":["import type { AppYamlEnvEntry, ResourceBinding } from \"../../deploy-config\";\nimport {\n fieldOrigin,\n isValidEnvName,\n type ResourceRequirementRow,\n} from \"./requirements\";\n\n/**\n * Deploy-config generation for a plugin's resources, reproducing what\n * `databricks apps init` renders. Verified byte-for-byte against golden\n * fixtures (see __fixtures__/) for the resource types listed in\n * {@link BINDING_SPECS}. Unverified types degrade safely: their env entries\n * are still produced (that shape is uniform), but the databricks.yml resource\n * binding is skipped with a warning rather than guessed.\n */\n\n/** A `databricks.yml` top-level bundle variable. */\nexport interface BundleVariable {\n name: string;\n description?: string;\n /** The value placed under targets.default.variables. */\n value?: string;\n}\n\nexport interface ConfigPlan {\n appYamlEnv: AppYamlEnvEntry[];\n bundleVariables: BundleVariable[];\n resourceBindings: ResourceBinding[];\n /** Resource types encountered that have no verified binding spec. */\n unverifiedTypes: string[];\n}\n\n/**\n * Per-type rules for producing databricks.yml bundle variables and the app\n * resource binding. Only types verified against golden fixtures appear here.\n *\n * - `variableFields`: field keys that become bundle variables (a superset of\n * the binding fields; e.g. postgres declares project+branch+database).\n * - `bindingFields`: field keys included in the resource binding (a subset;\n * e.g. postgres binds branch+database but not project).\n * - `variable(field)`: the bundle-variable name for a given field key.\n */\ninterface BindingSpec {\n variableFields: string[];\n bindingFields: string[];\n variable: (fieldKey: string) => string;\n}\n\nconst BINDING_SPECS: Record<string, BindingSpec> = {\n // Verified against __fixtures__/analytics.\n sql_warehouse: {\n variableFields: [\"id\"],\n bindingFields: [\"id\"],\n // fixture: variable is `sql_warehouse_id`\n variable: (f) => `sql_warehouse_${f}`,\n },\n // Verified against __fixtures__/lakebase.\n postgres: {\n variableFields: [\"project\", \"branch\", \"database\"],\n bindingFields: [\"branch\", \"database\"],\n // fixture: variables are `postgres_<fieldKey>` (project/branch/database)\n variable: (f) => `postgres_${f}`,\n },\n};\n\n/**\n * Builds the deploy-config plan for a set of resource rows. `values` supplies\n * the concrete values for the target-level bundle variables (keyed by the\n * manifest field's env var name for env-bearing fields, else by field key);\n * missing values leave the variable value undefined.\n */\nexport function buildConfigPlan(\n rows: ResourceRequirementRow[],\n values: Record<string, string> = {},\n): ConfigPlan {\n const appYamlEnv: AppYamlEnvEntry[] = [];\n const bundleVariables: BundleVariable[] = [];\n const resourceBindings: ResourceBinding[] = [];\n const unverifiedTypes: string[] = [];\n const seenEnv = new Set<string>();\n const seenVar = new Set<string>();\n\n for (const row of rows) {\n // app.yaml env: every env-bearing field maps to valueFrom = resourceKey,\n // except platform-injected fields (the platform provides those directly).\n const resourceKey = row.resourceKey ?? row.type;\n for (const field of row.fields) {\n if (!field.env || fieldOrigin(field) === \"platform\") continue;\n // env names are untrusted manifest data emitted into app.yaml — drop\n // anything that isn't a plain env identifier (mirrors the .env guard).\n if (!isValidEnvName(field.env)) continue;\n if (seenEnv.has(field.env)) continue;\n seenEnv.add(field.env);\n appYamlEnv.push({ name: field.env, valueFrom: resourceKey });\n }\n\n const spec = BINDING_SPECS[row.type];\n if (!spec) {\n if (!unverifiedTypes.includes(row.type)) unverifiedTypes.push(row.type);\n continue;\n }\n\n // Bundle variables (superset of binding fields for this type).\n for (const fieldKey of spec.variableFields) {\n const varName = spec.variable(fieldKey);\n if (seenVar.has(varName)) continue;\n seenVar.add(varName);\n const field = row.fields.find((f) => f.key === fieldKey);\n const valueKey = field?.env ?? fieldKey;\n bundleVariables.push({\n name: varName,\n description: field?.description,\n value: values[valueKey] ?? field?.value,\n });\n }\n\n // Resource binding: only the spec's binding fields, referencing ${var.X}.\n const fields: Record<string, string> = {};\n for (const fieldKey of spec.bindingFields) {\n fields[fieldKey] = `\\${var.${spec.variable(fieldKey)}}`;\n }\n resourceBindings.push({\n name: resourceKey,\n type: row.type,\n permission: row.permission,\n fields,\n });\n }\n\n return { appYamlEnv, bundleVariables, resourceBindings, unverifiedTypes };\n}\n\n/**\n * A bundle-variable value the user must supply that the .env reconciliation\n * flow can't collect — a binding field with NO `env` name (e.g. postgres\n * project/branch/database). Without collecting these, databricks.yml declares\n * `${var.postgres_branch}` but never assigns it, and `bundle validate` fails.\n * Keyed by `fieldKey` (matching how buildConfigPlan looks up `values`).\n */\nexport interface BindingValueNeed {\n fieldKey: string;\n resourceType: string;\n description?: string;\n}\n\n/**\n * Binding fields that carry a bundle-variable value but have no `env` name and\n * no static default — so they're invisible to collectEnvNeeds and must be\n * collected separately (keyed by fieldKey) to produce a valid databricks.yml.\n */\nexport function collectBindingValueNeeds(\n rows: ResourceRequirementRow[],\n): BindingValueNeed[] {\n const needs: BindingValueNeed[] = [];\n const seen = new Set<string>();\n for (const row of rows) {\n const spec = BINDING_SPECS[row.type];\n if (!spec) continue;\n for (const fieldKey of spec.variableFields) {\n const field = row.fields.find((f) => f.key === fieldKey);\n // Skip fields that already flow through .env (have an env name) or carry\n // a static default — those get their value elsewhere.\n if (field?.env || field?.value !== undefined) continue;\n if (seen.has(fieldKey)) continue;\n seen.add(fieldKey);\n needs.push({\n fieldKey,\n resourceType: row.type,\n description: field?.description,\n });\n }\n }\n return needs;\n}\n\n/** True when the plan has any deploy-config content to write. */\nexport function planHasContent(plan: ConfigPlan): boolean {\n return (\n plan.appYamlEnv.length > 0 ||\n plan.bundleVariables.length > 0 ||\n plan.resourceBindings.length > 0\n );\n}\n"],"mappings":";;;AAgDA,MAAM,gBAA6C;CAEjD,eAAe;EACb,gBAAgB,CAAC,KAAK;EACtB,eAAe,CAAC,KAAK;EAErB,WAAW,MAAM,iBAAiB;EACnC;CAED,UAAU;EACR,gBAAgB;GAAC;GAAW;GAAU;GAAW;EACjD,eAAe,CAAC,UAAU,WAAW;EAErC,WAAW,MAAM,YAAY;EAC9B;CACF;;;;;;;AAQD,SAAgB,gBACd,MACA,SAAiC,EAAE,EACvB;CACZ,MAAM,aAAgC,EAAE;CACxC,MAAM,kBAAoC,EAAE;CAC5C,MAAM,mBAAsC,EAAE;CAC9C,MAAM,kBAA4B,EAA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AAM;EACtB,MAAM,OAAO,cAAc,IAAI;AAC/B,MAAI,CAAC,KAAM;AACX,OAAK,MAAM,YAAY,KAAK,gBAAgB;GAC1C,MAAM,QAAQ,IAAI,OAAO,MAAM,MAAM,EAAE,QAAQ,SAAS;AAGxD,OAAI,OAAO,OAAO,OAAO,UAAU,OAAW;AAC9C,OAAI,KAAK,IAAI,SAAS,CAAE;AACxB,QAAK,IAAI,SAAS;AAClB,SAAM,KAAK;IACT;IACA,cAAc,IAAI;IAClB,aAAa,OAAO;IACrB,CAAC;;;AAGN,QAAO;;;AAIT,SAAgB,eAAe,MAA2B;AACxD,QACE,KAAK,WAAW,SAAS,KACzB,KAAK,gBAAgB,SAAS,KAC9B,KAAK,iBAAiB,SAAS"}
1
+ {"version":3,"file":"config-plan.js","names":[],"sources":["../../../../src/cli/commands/registry/config-plan.ts"],"sourcesContent":["import type { AppYamlEnvEntry, ResourceBinding } from \"../../deploy-config\";\nimport {\n fieldOrigin,\n isValidEnvName,\n type ResourceRequirementRow,\n} from \"./requirements\";\n\n/**\n * Deploy-config generation for a plugin's resources, reproducing what\n * `databricks apps init` renders. Verified byte-for-byte against golden\n * fixtures (see __fixtures__/) for the resource types listed in\n * {@link BINDING_SPECS}. Unverified types degrade safely: their env entries\n * are still produced (that shape is uniform), but the databricks.yml resource\n * binding is skipped with a warning rather than guessed.\n */\n\n/** A `databricks.yml` top-level bundle variable. */\nexport interface BundleVariable {\n name: string;\n description?: string;\n /** The value placed under targets.default.variables. */\n value?: string;\n}\n\nexport interface ConfigPlan {\n appYamlEnv: AppYamlEnvEntry[];\n bundleVariables: BundleVariable[];\n resourceBindings: ResourceBinding[];\n /** Entries for resources.apps.app.user_api_scopes (added if absent). */\n userApiScopes?: string[];\n /** Resource types encountered that have no verified binding spec. */\n unverifiedTypes: string[];\n}\n\n/**\n * Per-type rules for producing databricks.yml bundle variables and the app\n * resource binding. Only types verified against golden fixtures appear here.\n *\n * - `variableFields`: field keys that become bundle variables (a superset of\n * the binding fields; e.g. postgres declares project+branch+database).\n * - `bindingFields`: field keys included in the resource binding (a subset;\n * e.g. postgres binds branch+database but not project).\n * - `variable(field)`: the bundle-variable name for a given field key.\n */\ninterface BindingSpec {\n variableFields: string[];\n bindingFields: string[];\n variable: (fieldKey: string) => string;\n}\n\nconst BINDING_SPECS: Record<string, BindingSpec> = {\n // Verified against __fixtures__/analytics.\n sql_warehouse: {\n variableFields: [\"id\"],\n bindingFields: [\"id\"],\n // fixture: variable is `sql_warehouse_id`\n variable: (f) => `sql_warehouse_${f}`,\n },\n // Verified against __fixtures__/lakebase.\n postgres: {\n variableFields: [\"project\", \"branch\", \"database\"],\n bindingFields: [\"branch\", \"database\"],\n // fixture: variables are `postgres_<fieldKey>` (project/branch/database)\n variable: (f) => `postgres_${f}`,\n },\n};\n\n/**\n * Builds the deploy-config plan for a set of resource rows. `values` supplies\n * the concrete values for the target-level bundle variables (keyed by the\n * manifest field's env var name for env-bearing fields, else by field key);\n * missing values leave the variable value undefined.\n */\nexport function buildConfigPlan(\n rows: ResourceRequirementRow[],\n values: Record<string, string> = {},\n): ConfigPlan {\n const appYamlEnv: AppYamlEnvEntry[] = [];\n const bundleVariables: BundleVariable[] = [];\n const resourceBindings: ResourceBinding[] = [];\n const unverifiedTypes: string[] = [];\n const seenEnv = new Set<string>();\n const seenVar = new Set<string>();\n\n for (const row of rows) {\n // app.yaml env: every env-bearing field maps to valueFrom = resourceKey,\n // except platform-injected fields (the platform provides those directly).\n const resourceKey = row.resourceKey ?? row.type;\n for (const field of row.fields) {\n if (!field.env || fieldOrigin(field) === \"platform\") continue;\n // env names are untrusted manifest data emitted into app.yaml — drop\n // anything that isn't a plain env identifier (mirrors the .env guard).\n if (!isValidEnvName(field.env)) continue;\n if (seenEnv.has(field.env)) continue;\n seenEnv.add(field.env);\n appYamlEnv.push({ name: field.env, valueFrom: resourceKey });\n }\n\n const spec = BINDING_SPECS[row.type];\n if (!spec) {\n if (!unverifiedTypes.includes(row.type)) unverifiedTypes.push(row.type);\n continue;\n }\n\n // Bundle variables (superset of binding fields for this type).\n for (const fieldKey of spec.variableFields) {\n const varName = spec.variable(fieldKey);\n if (seenVar.has(varName)) continue;\n seenVar.add(varName);\n const field = row.fields.find((f) => f.key === fieldKey);\n const valueKey = field?.env ?? fieldKey;\n bundleVariables.push({\n name: varName,\n description: field?.description,\n value: values[valueKey] ?? field?.value,\n });\n }\n\n // Resource binding: only the spec's binding fields, referencing ${var.X}.\n const fields: Record<string, string> = {};\n for (const fieldKey of spec.bindingFields) {\n fields[fieldKey] = `\\${var.${spec.variable(fieldKey)}}`;\n }\n resourceBindings.push({\n name: resourceKey,\n type: row.type,\n permission: row.permission,\n fields,\n });\n }\n\n return { appYamlEnv, bundleVariables, resourceBindings, unverifiedTypes };\n}\n\n/**\n * A bundle-variable value the user must supply that the .env reconciliation\n * flow can't collect — a binding field with NO `env` name (e.g. postgres\n * project/branch/database). Without collecting these, databricks.yml declares\n * `${var.postgres_branch}` but never assigns it, and `bundle validate` fails.\n * Keyed by `fieldKey` (matching how buildConfigPlan looks up `values`).\n */\nexport interface BindingValueNeed {\n fieldKey: string;\n resourceType: string;\n description?: string;\n}\n\n/**\n * Binding fields that carry a bundle-variable value but have no `env` name and\n * no static default — so they're invisible to collectEnvNeeds and must be\n * collected separately (keyed by fieldKey) to produce a valid databricks.yml.\n */\nexport function collectBindingValueNeeds(\n rows: ResourceRequirementRow[],\n): BindingValueNeed[] {\n const needs: BindingValueNeed[] = [];\n const seen = new Set<string>();\n for (const row of rows) {\n const spec = BINDING_SPECS[row.type];\n if (!spec) continue;\n for (const fieldKey of spec.variableFields) {\n const field = row.fields.find((f) => f.key === fieldKey);\n // Skip fields that already flow through .env (have an env name) or carry\n // a static default — those get their value elsewhere.\n if (field?.env || field?.value !== undefined) continue;\n if (seen.has(fieldKey)) continue;\n seen.add(fieldKey);\n needs.push({\n fieldKey,\n resourceType: row.type,\n description: field?.description,\n });\n }\n }\n return needs;\n}\n\n/** True when the plan has any deploy-config content to write. */\nexport function planHasContent(plan: ConfigPlan): boolean {\n return (\n plan.appYamlEnv.length > 0 ||\n plan.bundleVariables.length > 0 ||\n plan.resourceBindings.length > 0 ||\n (plan.userApiScopes?.length ?? 0) > 0\n );\n}\n"],"mappings":";;;AAkDA,MAAM,gBAA6C;CAEjD,eAAe;EACb,gBAAgB,CAAC,KAAK;EACtB,eAAe,CAAC,KAAK;EAErB,WAAW,MAAM,iBAAiB;EACnC;CAED,UAAU;EACR,gBAAgB;GAAC;GAAW;GAAU;GAAW;EACjD,eAAe,CAAC,UAAU,WAAW;EAErC,WAAW,MAAM,YAAY;EAC9B;CACF;;;;;;;AAQD,SAAgB,gBACd,MACA,SAAiC,EAAE,EACvB;CACZ,MAAM,aAAgC,EAAE;CACxC,MAAM,kBAAoC,EAAE;CAC5C,MAAM,mBAAsC,EAAE;CAC9C,MAAM,kBAA4B,EAAE;CACpC,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,0BAAU,IAAI,KAAa;AAEjC,MAAK,MAAM,OAAO,MAAM;EAGtB,MAAM,cAAc,IAAI,eAAe,IAAI;AAC3C,OAAK,MAAM,SAAS,IAAI,QAAQ;AAC9B,OAAI,CAAC,MAAM,OAAO,YAAY,MAAM,KAAK,WAAY;AAGrD,OAAI,CAAC,eAAe,MAAM,IAAI,CAAE;AAChC,OAAI,QAAQ,IAAI,MAAM,IAAI,CAAE;AAC5B,WAAQ,IAAI,MAAM,IAAI;AACtB,cAAW,KAAK;IAAE,MAAM,MAAM;IAAK,WAAW;IAAa,CAAC;;EAG9D,MAAM,OAAO,cAAc,IAAI;AAC/B,MAAI,CAAC,MAAM;AACT,OAAI,CAAC,gBAAgB,SAAS,IAAI,KAAK,CAAE,iBAAgB,KAAK,IAAI,KAAK;AACvE;;AAIF,OAAK,MAAM,YAAY,KAAK,gBAAgB;GAC1C,MAAM,UAAU,KAAK,SAAS,SAAS;AACvC,OAAI,QAAQ,IAAI,QAAQ,CAAE;AAC1B,WAAQ,IAAI,QAAQ;GACpB,MAAM,QAAQ,IAAI,OAAO,MAAM,MAAM,EAAE,QAAQ,SAAS;GACxD,MAAM,WAAW,OAAO,OAAO;AAC/B,mBAAgB,KAAK;IACnB,MAAM;IACN,aAAa,OAAO;IACpB,OAAO,OAAO,aAAa,OAAO;IACnC,CAAC;;EAIJ,MAAM,SAAiC,EAAE;AACzC,OAAK,MAAM,YAAY,KAAK,cAC1B,QAAO,YAAY,UAAU,KAAK,SAAS,SAAS,CAAC;AAEvD,mBAAiB,KAAK;GACpB,MAAM;GACN,MAAM,IAAI;GACV,YAAY,IAAI;GAChB;GACD,CAAC;;AAGJ,QAAO;EAAE;EAAY;EAAiB;EAAkB;EAAiB;;;;;;;AAqB3E,SAAgB,yBACd,MACoB;CACpB,MAAM,QAA4B,EAAE;CACpC,MAAM,uBAAO,IAAI,KAAa;AAC9B,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,OAAO,cAAc,IAAI;AAC/B,MAAI,CAAC,KAAM;AACX,OAAK,MAAM,YAAY,KAAK,gBAAgB;GAC1C,MAAM,QAAQ,IAAI,OAAO,MAAM,MAAM,EAAE,QAAQ,SAAS;AAGxD,OAAI,OAAO,OAAO,OAAO,UAAU,OAAW;AAC9C,OAAI,KAAK,IAAI,SAAS,CAAE;AACxB,QAAK,IAAI,SAAS;AAClB,SAAM,KAAK;IACT;IACA,cAAc,IAAI;IAClB,aAAa,OAAO;IACrB,CAAC;;;AAGN,QAAO;;;AAIT,SAAgB,eAAe,MAA2B;AACxD,QACE,KAAK,WAAW,SAAS,KACzB,KAAK,gBAAgB,SAAS,KAC9B,KAAK,iBAAiB,SAAS,MAC9B,KAAK,eAAe,UAAU,KAAK"}
@@ -9,8 +9,10 @@ import { parseDocument } from "yaml";
9
9
  //#region src/cli/commands/registry/config-writer.ts
10
10
  /** Reads and parses a YAML file into a Document, or a fresh doc if absent. */
11
11
  function loadDoc(file) {
12
- if (fs.existsSync(file)) return parseDocument(fs.readFileSync(file, "utf-8"));
13
- return parseDocument("");
12
+ if (!fs.existsSync(file)) return parseDocument("");
13
+ const doc = parseDocument(fs.readFileSync(file, "utf-8"));
14
+ if (doc.errors.length > 0) throw new Error(`${path.basename(file)} is not valid YAML: ${doc.errors[0].message}`);
15
+ return doc;
14
16
  }
15
17
  /**
16
18
  * Additively patches `app.yaml`'s `env:` list with entries not already present
@@ -32,10 +34,7 @@ function patchAppYaml(file, entries) {
32
34
  const added = [];
33
35
  for (const entry of entries) {
34
36
  if (existingNames.has(entry.name)) continue;
35
- seq.add(doc.createNode({
36
- name: entry.name,
37
- valueFrom: entry.valueFrom
38
- }));
37
+ seq.add(doc.createNode(entry));
39
38
  added.push(entry.name);
40
39
  }
41
40
  if (added.length > 0) fs.writeFileSync(file, doc.toString());
@@ -56,6 +55,57 @@ function ensureMap(doc, pathKeys) {
56
55
  }
57
56
  return node;
58
57
  }
58
+ /** The bundle's only app, else `app`; throws on several apps with none named `app`. */
59
+ function appKey(doc) {
60
+ const keys = Object.keys(doc.toJSON()?.resources?.apps ?? {});
61
+ if (keys.length === 1) return keys[0];
62
+ if (keys.length === 0 || keys.includes("app")) return "app";
63
+ throw new Error(`databricks.yml defines several apps (${keys.join(", ")}); add the resources to the right one by hand`);
64
+ }
65
+ /** Throws before any write when app.yaml or databricks.yml can't be patched. */
66
+ function preflightConfig(cwd) {
67
+ loadDoc(path.join(cwd, APP_YAML_FILE));
68
+ appKey(loadDoc(path.join(cwd, DATABRICKS_YML_FILE)));
69
+ }
70
+ /** JSON with sorted keys, for comparing YAML nodes regardless of key order. */
71
+ function canonical(v) {
72
+ if (Array.isArray(v)) return `[${v.map(canonical).join(",")}]`;
73
+ if (v && typeof v === "object") return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(",")}}`;
74
+ return JSON.stringify(v);
75
+ }
76
+ /**
77
+ * Bundle variables and bindings the plan would set differently from
78
+ * databricks.yml (any target's value or a variable default) or from earlier
79
+ * plans of the same run, which the additive writer would silently keep.
80
+ */
81
+ function bundleConflicts(cwd, plan, pending = []) {
82
+ const doc = loadDoc(path.join(cwd, DATABRICKS_YML_FILE));
83
+ const json = doc.toJSON() ?? {};
84
+ const values = /* @__PURE__ */ new Map();
85
+ const addValue = (name, v) => {
86
+ if (v === void 0 || v === null) return;
87
+ if (!values.has(name)) values.set(name, /* @__PURE__ */ new Set());
88
+ values.get(name)?.add(String(v));
89
+ };
90
+ for (const [name, v] of Object.entries(json.variables ?? {})) addValue(name, v?.default);
91
+ for (const t of Object.values(json.targets ?? {})) for (const [name, v] of Object.entries(t?.variables ?? {})) addValue(name, v);
92
+ const bindings = /* @__PURE__ */ new Map();
93
+ for (const b of json.resources?.apps?.[appKey(doc)]?.resources ?? []) if (b?.name) bindings.set(b.name, canonical(b));
94
+ for (const p of pending) {
95
+ for (const v of p.bundleVariables) if (!values.has(v.name)) addValue(v.name, v.value);
96
+ for (const b of p.resourceBindings) if (!bindings.has(b.name)) bindings.set(b.name, canonical(bindingToNode(b)));
97
+ }
98
+ const out = [];
99
+ for (const v of plan.bundleVariables) {
100
+ const have = values.get(v.name);
101
+ if (v.value !== void 0 && have && [...have].some((x) => x !== v.value)) out.push(`variable ${v.name}`);
102
+ }
103
+ for (const b of plan.resourceBindings) {
104
+ const have = bindings.get(b.name);
105
+ if (have !== void 0 && have !== canonical(bindingToNode(b))) out.push(`binding ${b.name}`);
106
+ }
107
+ return out;
108
+ }
59
109
  /**
60
110
  * Additively patches `databricks.yml`: adds bundle `variables`, the app
61
111
  * `resources` bindings, and the target-level variable values — each only if
@@ -63,7 +113,7 @@ function ensureMap(doc, pathKeys) {
63
113
  * (a target-value-only write changes the file without adding any names).
64
114
  */
65
115
  function patchDatabricksYml(file, plan) {
66
- if (plan.bundleVariables.length === 0 && plan.resourceBindings.length === 0) return {
116
+ if (plan.bundleVariables.length === 0 && plan.resourceBindings.length === 0 && !plan.userApiScopes?.length) return {
67
117
  added: [],
68
118
  changed: false
69
119
  };
@@ -83,7 +133,7 @@ function patchDatabricksYml(file, plan) {
83
133
  const app = ensureMap(doc, [
84
134
  "resources",
85
135
  "apps",
86
- "app"
136
+ appKey(doc)
87
137
  ]);
88
138
  let bindings = app.get("resources");
89
139
  if (!bindings || typeof bindings.add !== "function") {
@@ -101,6 +151,24 @@ function patchDatabricksYml(file, plan) {
101
151
  added.push(binding.name);
102
152
  }
103
153
  }
154
+ if (plan.userApiScopes?.length) {
155
+ const app = ensureMap(doc, [
156
+ "resources",
157
+ "apps",
158
+ appKey(doc)
159
+ ]);
160
+ let scopes = app.get("user_api_scopes");
161
+ if (!scopes || typeof scopes.add !== "function") {
162
+ app.set("user_api_scopes", doc.createNode([]));
163
+ scopes = app.get("user_api_scopes");
164
+ }
165
+ const existing = new Set(scopes.toJSON());
166
+ for (const scope of plan.userApiScopes) {
167
+ if (existing.has(scope)) continue;
168
+ scopes.add(scope);
169
+ added.push(scope);
170
+ }
171
+ }
104
172
  let wroteTargetValue = false;
105
173
  const withValues = plan.bundleVariables.filter((v) => v.value !== void 0);
106
174
  if (withValues.length > 0) {
@@ -172,5 +240,5 @@ function reportConfigWrite(result) {
172
240
  }
173
241
 
174
242
  //#endregion
175
- export { reportConfigWrite, validateBundle, writeConfig };
243
+ export { bundleConflicts, preflightConfig, reportConfigWrite, validateBundle, writeConfig };
176
244
  //# sourceMappingURL=config-writer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-writer.js","names":[],"sources":["../../../../src/cli/commands/registry/config-writer.ts"],"sourcesContent":["import { type SpawnSyncReturns, spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\nimport { parseDocument, type YAMLMap, type YAMLSeq } from \"yaml\";\n\nimport {\n APP_YAML_FILE,\n type AppYamlEnvEntry,\n bindingToNode,\n DATABRICKS_YML_FILE,\n} from \"../../deploy-config\";\nimport { type ConfigPlan, planHasContent } from \"./config-plan\";\n\nexport interface ConfigWriteResult {\n appYamlChanged: boolean;\n databricksYmlChanged: boolean;\n /** Env/binding names actually added (skipping ones already present). */\n added: string[];\n /** Resource types skipped for lack of a verified binding spec. */\n unverifiedTypes: string[];\n}\n\n/** Reads and parses a YAML file into a Document, or a fresh doc if absent. */\nfunction loadDoc(file: string): ReturnType<typeof parseDocument> {\n if (fs.existsSync(file)) {\n return parseDocument(fs.readFileSync(file, \"utf-8\"));\n }\n return parseDocument(\"\");\n}\n\n/**\n * Additively patches `app.yaml`'s `env:` list with entries not already present\n * (matched by `name`). Returns the names added.\n */\nfunction patchAppYaml(file: string, entries: AppYamlEnvEntry[]): string[] {\n if (entries.length === 0) return [];\n const doc = loadDoc(file);\n let seq = doc.get(\"env\") as YAMLSeq | undefined;\n if (!seq || typeof (seq as YAMLSeq).add !== \"function\") {\n doc.set(\"env\", doc.createNode([]));\n seq = doc.get(\"env\") as YAMLSeq;\n }\n\n const existingNames = new Set<string>();\n for (const item of seq.items) {\n const name = (item as YAMLMap)?.get?.(\"name\");\n if (typeof name === \"string\") existingNames.add(name);\n }\n\n const added: string[] = [];\n for (const entry of entries) {\n if (existingNames.has(entry.name)) continue;\n seq.add(doc.createNode({ name: entry.name, valueFrom: entry.valueFrom }));\n added.push(entry.name);\n }\n\n if (added.length > 0) fs.writeFileSync(file, doc.toString());\n return added;\n}\n\n/** Navigates/creates a nested map path, returning the leaf map. */\nfunction ensureMap(\n doc: ReturnType<typeof parseDocument>,\n pathKeys: string[],\n): YAMLMap {\n let node = doc.contents as unknown as YAMLMap;\n const walked: string[] = [];\n for (const key of pathKeys) {\n walked.push(key);\n let child = doc.getIn(walked) as YAMLMap | undefined;\n if (!child || typeof (child as YAMLMap).set !== \"function\") {\n doc.setIn(walked, doc.createNode({}));\n child = doc.getIn(walked) as YAMLMap;\n }\n node = child;\n }\n return node;\n}\n\n/**\n * Additively patches `databricks.yml`: adds bundle `variables`, the app\n * `resources` bindings, and the target-level variable values — each only if\n * not already present. Returns the names added plus whether the file changed\n * (a target-value-only write changes the file without adding any names).\n */\nfunction patchDatabricksYml(\n file: string,\n plan: ConfigPlan,\n): { added: string[]; changed: boolean } {\n if (plan.bundleVariables.length === 0 && plan.resourceBindings.length === 0) {\n return { added: [], changed: false };\n }\n const doc = loadDoc(file);\n const added: string[] = [];\n\n // Top-level bundle variables.\n if (plan.bundleVariables.length > 0) {\n const vars = ensureMap(doc, [\"variables\"]);\n for (const v of plan.bundleVariables) {\n if (vars.has(v.name)) continue;\n const body: Record<string, string> = {};\n if (v.description) body.description = v.description;\n vars.set(v.name, doc.createNode(body));\n added.push(v.name);\n }\n }\n\n // App resource bindings.\n if (plan.resourceBindings.length > 0) {\n const app = ensureMap(doc, [\"resources\", \"apps\", \"app\"]);\n let bindings = app.get(\"resources\") as YAMLSeq | undefined;\n if (!bindings || typeof (bindings as YAMLSeq).add !== \"function\") {\n app.set(\"resources\", doc.createNode([]));\n bindings = app.get(\"resources\") as YAMLSeq;\n }\n const existing = new Set<string>();\n for (const item of bindings.items) {\n const name = (item as YAMLMap)?.get?.(\"name\");\n if (typeof name === \"string\") existing.add(name);\n }\n for (const binding of plan.resourceBindings) {\n if (existing.has(binding.name)) continue;\n bindings.add(doc.createNode(bindingToNode(binding)));\n added.push(binding.name);\n }\n }\n\n // Target-level variable values. Tracked separately from `added` because the\n // binding/top-level var may already exist (e.g. from scaffold) while the\n // target VALUE is still missing — in that case nothing is in `added` yet the\n // file still needs writing to persist the assigned value.\n let wroteTargetValue = false;\n const withValues = plan.bundleVariables.filter((v) => v.value !== undefined);\n if (withValues.length > 0) {\n const targetVars = ensureMap(doc, [\"targets\", \"default\", \"variables\"]);\n for (const v of withValues) {\n if (targetVars.has(v.name)) continue;\n targetVars.set(v.name, v.value);\n wroteTargetValue = true;\n }\n }\n\n const changed = added.length > 0 || wroteTargetValue;\n if (changed) fs.writeFileSync(file, doc.toString());\n return { added, changed };\n}\n\n/**\n * Applies a config plan to `app.yaml` and `databricks.yml` in `cwd` via\n * comment-preserving additive patches. Never overwrites existing entries.\n */\nexport function writeConfig(cwd: string, plan: ConfigPlan): ConfigWriteResult {\n const appAdded = patchAppYaml(path.join(cwd, APP_YAML_FILE), plan.appYamlEnv);\n const db = patchDatabricksYml(path.join(cwd, DATABRICKS_YML_FILE), plan);\n return {\n appYamlChanged: appAdded.length > 0,\n databricksYmlChanged: db.changed,\n added: [...new Set([...appAdded, ...db.added])],\n unverifiedTypes: plan.unverifiedTypes,\n };\n}\n\n/**\n * Runs `databricks bundle validate` as a post-write correctness gate. Returns\n * true when the config validates (or when the CLI is unavailable — a missing\n * CLI shouldn't fail an install). Surfaces validation errors to the user.\n */\nexport function validateBundle(cwd: string, profile?: string): boolean {\n const args = [\"bundle\", \"validate\"];\n if (profile) args.push(\"-p\", profile);\n let result: SpawnSyncReturns<string>;\n try {\n result = spawnSync(\"databricks\", args, { cwd, encoding: \"utf-8\" });\n } catch {\n console.warn(\n pc.yellow(\" Skipped bundle validate (databricks CLI not found).\"),\n );\n return true;\n }\n if (result.error) {\n console.warn(\n pc.yellow(\" Skipped bundle validate (databricks CLI not found).\"),\n );\n return true;\n }\n if (result.status !== 0) {\n console.warn(pc.yellow(\" databricks bundle validate reported issues:\"));\n if (result.stderr) console.warn(result.stderr.trim());\n return false;\n }\n return true;\n}\n\n/** Reports what the config write did, including any unverified-type warnings. */\nexport function reportConfigWrite(result: ConfigWriteResult): void {\n if (result.added.length > 0) {\n console.log(\n `${pc.green(\"Updated deploy config:\")} ${result.added.join(\", \")}`,\n );\n }\n if (result.unverifiedTypes.length > 0) {\n console.warn(\n pc.yellow(\n ` No databricks.yml binding written for: ${result.unverifiedTypes.join(\", \")}. ` +\n \"Add the resource binding manually before deploy.\",\n ),\n );\n }\n}\n\nexport { planHasContent };\n"],"mappings":";;;;;;;;;;AAyBA,SAAS,QAAQ,MAAgD;AAC/D,KAAI,GAAG,WAAW,KAAK,CACrB,QAAO,cAAc,GAAG,aAAa,MAAM,QAAQ,CAAC;AAEtD,QAAO,cAAc,GAAG;;;;;;AAO1B,SAAS,aAAa,MAAc,SAA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,KAAK,CAAC,oDAE/E,CACF"}
1
+ {"version":3,"file":"config-writer.js","names":[],"sources":["../../../../src/cli/commands/registry/config-writer.ts"],"sourcesContent":["import { type SpawnSyncReturns, spawnSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\nimport { parseDocument, type YAMLMap, type YAMLSeq } from \"yaml\";\n\nimport {\n APP_YAML_FILE,\n type AppYamlEnvEntry,\n bindingToNode,\n DATABRICKS_YML_FILE,\n} from \"../../deploy-config\";\nimport { type ConfigPlan, planHasContent } from \"./config-plan\";\n\nexport interface ConfigWriteResult {\n appYamlChanged: boolean;\n databricksYmlChanged: boolean;\n /** Env/binding names actually added (skipping ones already present). */\n added: string[];\n /** Resource types skipped for lack of a verified binding spec. */\n unverifiedTypes: string[];\n}\n\n/** Reads and parses a YAML file into a Document, or a fresh doc if absent. */\nfunction loadDoc(file: string): ReturnType<typeof parseDocument> {\n if (!fs.existsSync(file)) return parseDocument(\"\");\n const doc = parseDocument(fs.readFileSync(file, \"utf-8\"));\n if (doc.errors.length > 0) {\n throw new Error(\n `${path.basename(file)} is not valid YAML: ${doc.errors[0].message}`,\n );\n }\n return doc;\n}\n\n/**\n * Additively patches `app.yaml`'s `env:` list with entries not already present\n * (matched by `name`). Returns the names added.\n */\nfunction patchAppYaml(file: string, entries: AppYamlEnvEntry[]): string[] {\n if (entries.length === 0) return [];\n const doc = loadDoc(file);\n let seq = doc.get(\"env\") as YAMLSeq | undefined;\n if (!seq || typeof (seq as YAMLSeq).add !== \"function\") {\n doc.set(\"env\", doc.createNode([]));\n seq = doc.get(\"env\") as YAMLSeq;\n }\n\n const existingNames = new Set<string>();\n for (const item of seq.items) {\n const name = (item as YAMLMap)?.get?.(\"name\");\n if (typeof name === \"string\") existingNames.add(name);\n }\n\n const added: string[] = [];\n for (const entry of entries) {\n if (existingNames.has(entry.name)) continue;\n seq.add(doc.createNode(entry));\n added.push(entry.name);\n }\n\n if (added.length > 0) fs.writeFileSync(file, doc.toString());\n return added;\n}\n\n/** Navigates/creates a nested map path, returning the leaf map. */\nfunction ensureMap(\n doc: ReturnType<typeof parseDocument>,\n pathKeys: string[],\n): YAMLMap {\n let node = doc.contents as unknown as YAMLMap;\n const walked: string[] = [];\n for (const key of pathKeys) {\n walked.push(key);\n let child = doc.getIn(walked) as YAMLMap | undefined;\n if (!child || typeof (child as YAMLMap).set !== \"function\") {\n doc.setIn(walked, doc.createNode({}));\n child = doc.getIn(walked) as YAMLMap;\n }\n node = child;\n }\n return node;\n}\n\n/** The bundle's only app, else `app`; throws on several apps with none named `app`. */\nfunction appKey(doc: ReturnType<typeof parseDocument>): string {\n const keys = Object.keys(doc.toJSON()?.resources?.apps ?? {});\n if (keys.length === 1) return keys[0];\n if (keys.length === 0 || keys.includes(\"app\")) return \"app\";\n throw new Error(\n `databricks.yml defines several apps (${keys.join(\", \")}); add the resources to the right one by hand`,\n );\n}\n\n/** Throws before any write when app.yaml or databricks.yml can't be patched. */\nexport function preflightConfig(cwd: string): void {\n loadDoc(path.join(cwd, APP_YAML_FILE));\n appKey(loadDoc(path.join(cwd, DATABRICKS_YML_FILE)));\n}\n\n/** JSON with sorted keys, for comparing YAML nodes regardless of key order. */\nfunction canonical(v: unknown): string {\n if (Array.isArray(v)) return `[${v.map(canonical).join(\",\")}]`;\n if (v && typeof v === \"object\") {\n return `{${Object.keys(v)\n .sort()\n .map(\n (k) =>\n `${JSON.stringify(k)}:${canonical((v as Record<string, unknown>)[k])}`,\n )\n .join(\",\")}}`;\n }\n return JSON.stringify(v);\n}\n\n/**\n * Bundle variables and bindings the plan would set differently from\n * databricks.yml (any target's value or a variable default) or from earlier\n * plans of the same run, which the additive writer would silently keep.\n */\nexport function bundleConflicts(\n cwd: string,\n plan: ConfigPlan,\n pending: ConfigPlan[] = [],\n): string[] {\n const doc = loadDoc(path.join(cwd, DATABRICKS_YML_FILE));\n const json = (doc.toJSON() ?? {}) as {\n variables?: Record<string, { default?: unknown } | null>;\n targets?: Record<string, { variables?: Record<string, unknown> } | null>;\n resources?: { apps?: Record<string, { resources?: { name?: string }[] }> };\n };\n const values = new Map<string, Set<string>>();\n const addValue = (name: string, v: unknown) => {\n if (v === undefined || v === null) return;\n if (!values.has(name)) values.set(name, new Set());\n values.get(name)?.add(String(v));\n };\n for (const [name, v] of Object.entries(json.variables ?? {}))\n addValue(name, v?.default);\n for (const t of Object.values(json.targets ?? {})) {\n for (const [name, v] of Object.entries(t?.variables ?? {}))\n addValue(name, v);\n }\n const bindings = new Map<string, string>();\n for (const b of json.resources?.apps?.[appKey(doc)]?.resources ?? []) {\n if (b?.name) bindings.set(b.name, canonical(b));\n }\n for (const p of pending) {\n for (const v of p.bundleVariables)\n if (!values.has(v.name)) addValue(v.name, v.value);\n for (const b of p.resourceBindings) {\n if (!bindings.has(b.name))\n bindings.set(b.name, canonical(bindingToNode(b)));\n }\n }\n const out: string[] = [];\n for (const v of plan.bundleVariables) {\n const have = values.get(v.name);\n if (v.value !== undefined && have && [...have].some((x) => x !== v.value)) {\n out.push(`variable ${v.name}`);\n }\n }\n for (const b of plan.resourceBindings) {\n const have = bindings.get(b.name);\n if (have !== undefined && have !== canonical(bindingToNode(b))) {\n out.push(`binding ${b.name}`);\n }\n }\n return out;\n}\n\n/**\n * Additively patches `databricks.yml`: adds bundle `variables`, the app\n * `resources` bindings, and the target-level variable values — each only if\n * not already present. Returns the names added plus whether the file changed\n * (a target-value-only write changes the file without adding any names).\n */\nfunction patchDatabricksYml(\n file: string,\n plan: ConfigPlan,\n): { added: string[]; changed: boolean } {\n if (\n plan.bundleVariables.length === 0 &&\n plan.resourceBindings.length === 0 &&\n !plan.userApiScopes?.length\n ) {\n return { added: [], changed: false };\n }\n const doc = loadDoc(file);\n const added: string[] = [];\n\n // Top-level bundle variables.\n if (plan.bundleVariables.length > 0) {\n const vars = ensureMap(doc, [\"variables\"]);\n for (const v of plan.bundleVariables) {\n if (vars.has(v.name)) continue;\n const body: Record<string, string> = {};\n if (v.description) body.description = v.description;\n vars.set(v.name, doc.createNode(body));\n added.push(v.name);\n }\n }\n\n // App resource bindings.\n if (plan.resourceBindings.length > 0) {\n const app = ensureMap(doc, [\"resources\", \"apps\", appKey(doc)]);\n let bindings = app.get(\"resources\") as YAMLSeq | undefined;\n if (!bindings || typeof (bindings as YAMLSeq).add !== \"function\") {\n app.set(\"resources\", doc.createNode([]));\n bindings = app.get(\"resources\") as YAMLSeq;\n }\n const existing = new Set<string>();\n for (const item of bindings.items) {\n const name = (item as YAMLMap)?.get?.(\"name\");\n if (typeof name === \"string\") existing.add(name);\n }\n for (const binding of plan.resourceBindings) {\n if (existing.has(binding.name)) continue;\n bindings.add(doc.createNode(bindingToNode(binding)));\n added.push(binding.name);\n }\n }\n\n if (plan.userApiScopes?.length) {\n const app = ensureMap(doc, [\"resources\", \"apps\", appKey(doc)]);\n let scopes = app.get(\"user_api_scopes\") as YAMLSeq | undefined;\n if (!scopes || typeof (scopes as YAMLSeq).add !== \"function\") {\n app.set(\"user_api_scopes\", doc.createNode([]));\n scopes = app.get(\"user_api_scopes\") as YAMLSeq;\n }\n const existing = new Set(scopes.toJSON() as unknown[]);\n for (const scope of plan.userApiScopes) {\n if (existing.has(scope)) continue;\n scopes.add(scope);\n added.push(scope);\n }\n }\n\n // Target-level variable values. Tracked separately from `added` because the\n // binding/top-level var may already exist (e.g. from scaffold) while the\n // target VALUE is still missing — in that case nothing is in `added` yet the\n // file still needs writing to persist the assigned value.\n let wroteTargetValue = false;\n const withValues = plan.bundleVariables.filter((v) => v.value !== undefined);\n if (withValues.length > 0) {\n const targetVars = ensureMap(doc, [\"targets\", \"default\", \"variables\"]);\n for (const v of withValues) {\n if (targetVars.has(v.name)) continue;\n targetVars.set(v.name, v.value);\n wroteTargetValue = true;\n }\n }\n\n const changed = added.length > 0 || wroteTargetValue;\n if (changed) fs.writeFileSync(file, doc.toString());\n return { added, changed };\n}\n\n/**\n * Applies a config plan to `app.yaml` and `databricks.yml` in `cwd` via\n * comment-preserving additive patches. Never overwrites existing entries.\n */\nexport function writeConfig(cwd: string, plan: ConfigPlan): ConfigWriteResult {\n const appAdded = patchAppYaml(path.join(cwd, APP_YAML_FILE), plan.appYamlEnv);\n const db = patchDatabricksYml(path.join(cwd, DATABRICKS_YML_FILE), plan);\n return {\n appYamlChanged: appAdded.length > 0,\n databricksYmlChanged: db.changed,\n added: [...new Set([...appAdded, ...db.added])],\n unverifiedTypes: plan.unverifiedTypes,\n };\n}\n\n/**\n * Runs `databricks bundle validate` as a post-write correctness gate. Returns\n * true when the config validates (or when the CLI is unavailable — a missing\n * CLI shouldn't fail an install). Surfaces validation errors to the user.\n */\nexport function validateBundle(cwd: string, profile?: string): boolean {\n const args = [\"bundle\", \"validate\"];\n if (profile) args.push(\"-p\", profile);\n let result: SpawnSyncReturns<string>;\n try {\n result = spawnSync(\"databricks\", args, { cwd, encoding: \"utf-8\" });\n } catch {\n console.warn(\n pc.yellow(\" Skipped bundle validate (databricks CLI not found).\"),\n );\n return true;\n }\n if (result.error) {\n console.warn(\n pc.yellow(\" Skipped bundle validate (databricks CLI not found).\"),\n );\n return true;\n }\n if (result.status !== 0) {\n console.warn(pc.yellow(\" databricks bundle validate reported issues:\"));\n if (result.stderr) console.warn(result.stderr.trim());\n return false;\n }\n return true;\n}\n\n/** Reports what the config write did, including any unverified-type warnings. */\nexport function reportConfigWrite(result: ConfigWriteResult): void {\n if (result.added.length > 0) {\n console.log(\n `${pc.green(\"Updated deploy config:\")} ${result.added.join(\", \")}`,\n );\n }\n if (result.unverifiedTypes.length > 0) {\n console.warn(\n pc.yellow(\n ` No databricks.yml binding written for: ${result.unverifiedTypes.join(\", \")}. ` +\n \"Add the resource binding manually before deploy.\",\n ),\n );\n }\n}\n\nexport { planHasContent };\n"],"mappings":";;;;;;;;;;AAyBA,SAAS,QAAQ,MAAgD;AAC/D,KAAI,CAAC,GAAG,WAAW,KAAK,CAAE,QAAO,cAAc,GAAG;CAClD,MAAM,MAAM,cAAc,GAAG,aAA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ACN,GAAG,OAAO,wDAAwD,CACnE;AACD,SAAO;;AAET,KAAI,OAAO,WAAW,GAAG;AACvB,UAAQ,KAAK,GAAG,OAAO,gDAAgD,CAAC;AACxE,MAAI,OAAO,OAAQ,SAAQ,KAAK,OAAO,OAAO,MAAM,CAAC;AACrD,SAAO;;AAET,QAAO;;;AAIT,SAAgB,kBAAkB,QAAiC;AACjE,KAAI,OAAO,MAAM,SAAS,EACxB,SAAQ,IACN,GAAG,GAAG,MAAM,yBAAyB,CAAC,GAAG,OAAO,MAAM,KAAK,KAAK,GACjE;AAEH,KAAI,OAAO,gBAAgB,SAAS,EAClC,SAAQ,KACN,GAAG,OACD,4CAA4C,OAAO,gBAAgB,KAAK,KAAK,CAAC,oDAE/E,CACF"}
@@ -210,5 +210,5 @@ function reportEnvResolutions(resolutions) {
210
210
  }
211
211
 
212
212
  //#endregion
213
- export { collectBindingValues, reportEnvResolutions, syncEnv };
213
+ export { collectBindingValues, readEnvFile, reportEnvResolutions, syncEnv };
214
214
  //# sourceMappingURL=env-writer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-writer.js","names":[],"sources":["../../../../src/cli/commands/registry/env-writer.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport type { BindingValueNeed } from \"./config-plan\";\nimport {\n collectEnvNeeds,\n type EnvNeed,\n type EnvResolution,\n parseEnv,\n reconcileEnv,\n serializeEnvAppend,\n type ValueProvider,\n} from \"./env-reconcile\";\nimport type { ResourceRequirementRow } from \"./requirements\";\nimport {\n composeResourceId,\n DEFAULT_PARENTS,\n isFlatListable,\n isParentContext,\n listParentContextStep,\n listWorkspaceResources,\n parentContextDepth,\n} from \"./workspace-picker\";\n\nexport interface EnvSyncOptions {\n /** Directory holding `.env` / `.env.example` (the app root). */\n cwd: string;\n /** true = never prompt (agent/CI). Uses flag values or leaves unset. */\n nonInteractive: boolean;\n /** Pre-supplied env values from flags, e.g. { DATABRICKS_WAREHOUSE_ID: \"abc\" }. */\n values?: Record<string, string>;\n /** Databricks profile for the workspace picker (else the CLI default). */\n profile?: string;\n}\n\n/** Sentinel select value meaning \"let me type the id myself\". */\nconst MANUAL = \"__manual__\";\nconst BROWSE = \"__browse__\";\n\n/**\n * Max resources shown in a picker select. Real workspaces can have thousands\n * (e.g. 5000+ SQL warehouses); an unbounded select is unusable. Beyond this we\n * show the first N and log how many were hidden — never silently drop — and the\n * \"Enter manually\" option always lets the user type an id the list omits.\n */\nconst PICKER_LIMIT = 25;\n\n/** Reads a `.env`-style file into a map; empty when the file is absent. */\nfunction readEnvFile(file: string): Record<string, string> {\n if (!fs.existsSync(file)) return {};\n return parseEnv(fs.readFileSync(file, \"utf-8\"));\n}\n\n/** Appends text to a file, creating it (with a trailing newline) if needed. */\nfunction appendToFile(file: string, text: string): void {\n if (text === \"\") return;\n if (fs.existsSync(file)) {\n const existing = fs.readFileSync(file, \"utf-8\");\n const sep = existing.length > 0 && !existing.endsWith(\"\\n\") ? \"\\n\" : \"\";\n fs.writeFileSync(file, existing + sep + text);\n } else {\n fs.writeFileSync(file, text);\n }\n}\n\n/**\n * Caps a choice list to {@link PICKER_LIMIT} for display, logging how many were\n * hidden so the truncation is never silent. The caller always appends an\n * \"Enter manually\" option, so an omitted resource is still reachable.\n */\nexport function capChoices<T>(\n choices: T[],\n resourceType: string,\n limit = PICKER_LIMIT,\n): T[] {\n if (choices.length <= limit) return choices;\n console.log(\n pc.dim(\n ` ${choices.length} ${resourceType}s found; showing first ${limit}. ` +\n 'Use \"Enter manually\" if yours is not listed.',\n ),\n );\n return choices.slice(0, limit);\n}\n\n/** Free-text prompt for one env need; undefined to skip. */\nasync function promptText(need: EnvNeed): Promise<string | undefined> {\n const { isCancel, text } = await import(\"@clack/prompts\");\n const tag = need.required ? \"required\" : \"optional\";\n const answer = await text({\n message: `${need.env} (${need.resourceType}, ${tag})`,\n placeholder: need.description ?? \"leave blank to skip\",\n });\n if (isCancel(answer)) return undefined;\n const value = (answer ?? \"\").trim();\n return value === \"\" ? undefined : value;\n}\n\n/** Presents one workspace list as a select; MANUAL/cancel handled by caller. */\nasync function selectFrom(\n message: string,\n choices: { value: string; label: string }[],\n): Promise<string | typeof MANUAL | null> {\n const { isCancel, select } = await import(\"@clack/prompts\");\n const picked = await select({\n message,\n options: [...choices, { value: MANUAL, label: \"Enter manually / skip\" }],\n });\n if (isCancel(picked)) return null;\n return String(picked) as string | typeof MANUAL;\n}\n\n/**\n * Type-to-filter picker over the full choice list (no cap): the user searches\n * by name/id as they type. Appends \"Enter manually\" so an omitted value is\n * still reachable. Returns MANUAL to fall through to free-text, or null on\n * cancel.\n */\nasync function autocompleteFrom(\n message: string,\n choices: { value: string; label: string }[],\n): Promise<string | typeof MANUAL | null> {\n const { autocomplete, isCancel } = await import(\"@clack/prompts\");\n const picked = await autocomplete({\n message,\n options: [...choices, { value: MANUAL, label: \"Enter manually / skip\" }],\n placeholder: \"type to search…\",\n });\n if (isCancel(picked)) return null;\n return String(picked) as string | typeof MANUAL;\n}\n\n/**\n * Drill-down picker for parent-context types (volume→catalog/schema,\n * secret→scope, vector_search_index→endpoint). Walks each step, listing the\n * next level from the prior pick. Returns the final resource id, or undefined\n * to fall back to free-text (on cancel, empty level, or MANUAL at any step).\n */\nasync function pickParentContext(\n need: EnvNeed,\n profile: string | undefined,\n): Promise<string | undefined> {\n const depth = parentContextDepth(need.resourceType);\n const defaults = DEFAULT_PARENTS[need.resourceType];\n if (defaults) {\n // Open on the default parents; an empty listing falls through to the walk.\n const step = listParentContextStep(\n need.resourceType,\n defaults.length,\n defaults,\n profile,\n );\n if (step && step.choices.length > 0) {\n const picked = await selectFrom(\n `${need.env} — pick a ${step.key} in ${defaults.join(\".\")}`,\n [\n ...capChoices(step.choices, step.key),\n { value: BROWSE, label: \"Browse other catalogs...\" },\n ],\n );\n if (picked === null || picked === MANUAL) return undefined;\n if (picked !== BROWSE) {\n return composeResourceId(need.resourceType, [...defaults, picked]);\n }\n }\n }\n const picks: string[] = [];\n for (let i = 0; i < depth; i++) {\n const step = listParentContextStep(need.resourceType, i, picks, profile);\n if (!step || step.choices.length === 0) {\n console.log(\n pc.dim(\n ` No ${step?.key ?? need.resourceType} found — enter the id manually.`,\n ),\n );\n return undefined;\n }\n const picked = await selectFrom(\n `${need.env} — pick a ${step.key}`,\n capChoices(step.choices, step.key),\n );\n if (picked === null || picked === MANUAL) return undefined;\n picks.push(picked);\n }\n // Compose the id from the picks: most types end on a self-qualified id, but a\n // secret needs both scope and key (scope/key).\n return composeResourceId(need.resourceType, picks);\n}\n\n/**\n * Builds the value provider. Precedence: --env flag, then (interactive only) a\n * workspace picker — flat select for flat-listable types, drill-down for\n * parent-context types — else a free-text prompt. The picker degrades to\n * free-text whenever the workspace can't be listed (no profile, offline, auth\n * error, empty) so it never hard-fails.\n */\nfunction makeProvider(opts: EnvSyncOptions): ValueProvider {\n return async (need: EnvNeed) => {\n const fromFlag = opts.values?.[need.env];\n if (fromFlag !== undefined) return fromFlag;\n if (opts.nonInteractive) return undefined;\n\n if (isFlatListable(need.resourceType)) {\n const { choices, truncated, error } = await listWorkspaceResources(\n need.resourceType,\n opts.profile,\n );\n if (choices.length > 0) {\n if (truncated) {\n console.log(\n pc.dim(\n ` Showing the first ${choices.length} ${need.resourceType}s; use \"Enter manually\" if yours isn't listed.`,\n ),\n );\n }\n const picked = await autocompleteFrom(\n `${need.env} — search ${need.resourceType}s`,\n choices,\n );\n if (picked === null) return undefined;\n if (picked !== MANUAL) return picked;\n // fall through to free-text\n } else if (error) {\n // Listing failed (usually auth/profile) — say so, don't pretend the\n // workspace is empty, and point at the fix.\n console.log(\n pc.yellow(\n ` Couldn't list ${need.resourceType}s from the workspace (${error}).`,\n ),\n );\n console.log(\n pc.dim(\n \" Enter an id manually, or re-run with --profile <name> (or set DATABRICKS_CONFIG_PROFILE) so the picker can reach the workspace.\",\n ),\n );\n } else {\n console.log(\n pc.dim(\n ` No ${need.resourceType} found in the workspace — enter an id manually.`,\n ),\n );\n }\n } else if (isParentContext(need.resourceType)) {\n const picked = await pickParentContext(need, opts.profile);\n if (picked !== undefined) return picked;\n // fall through to free-text\n }\n\n return promptText(need);\n };\n}\n\n/**\n * Reconciles a plugin's declared resource env vars into the app's local `.env`\n * (and mirrors variable names into `.env.example`). Never overwrites keys the\n * user already set; skips platform-injected fields. Returns the per-var\n * resolutions so callers can report what happened.\n */\nexport async function syncEnv(\n rows: ResourceRequirementRow[],\n opts: EnvSyncOptions,\n): Promise<EnvResolution[]> {\n const needs = collectEnvNeeds(rows);\n if (needs.length === 0) return [];\n\n const envPath = path.join(opts.cwd, \".env\");\n const examplePath = path.join(opts.cwd, \".env.example\");\n const existing = readEnvFile(envPath);\n\n const resolutions = await reconcileEnv(needs, {\n existing,\n provide: makeProvider(opts),\n });\n\n const written = resolutions.filter(\n (r): r is EnvResolution & { value: string } =>\n r.status === \"written\" && r.value !== undefined,\n );\n appendToFile(\n envPath,\n serializeEnvAppend(written.map((r) => ({ env: r.env, value: r.value }))),\n );\n\n // .env.example carries the variable names (no secret values), and only for\n // vars not already documented there.\n const exampleExisting = readEnvFile(examplePath);\n const newExampleKeys = needs.filter((n) => !(n.env in exampleExisting));\n appendToFile(\n examplePath,\n serializeEnvAppend(newExampleKeys.map((n) => ({ env: n.env, value: \"\" }))),\n );\n\n return resolutions;\n}\n\n/**\n * Prompts for the {@link BindingValueNeed}s that `.env` reconciliation can't\n * collect, returning a `fieldKey -> value` map for buildConfigPlan. Values are\n * not written to `.env` (these fields have no env var). Non-interactive mode\n * uses `values[fieldKey]` if provided, else leaves the field unset.\n */\nexport async function collectBindingValues(\n needs: BindingValueNeed[],\n opts: EnvSyncOptions,\n): Promise<Record<string, string>> {\n const { isCancel, text } = await import(\"@clack/prompts\");\n const out: Record<string, string> = {};\n for (const need of needs) {\n const fromFlag = opts.values?.[need.fieldKey];\n if (fromFlag !== undefined) {\n out[need.fieldKey] = fromFlag;\n continue;\n }\n if (opts.nonInteractive) continue;\n const answer = await text({\n message: `${need.fieldKey} (${need.resourceType}) — required for databricks.yml`,\n placeholder: need.description ?? \"leave blank to set before deploy\",\n });\n if (isCancel(answer)) continue;\n const value = (answer ?? \"\").trim();\n if (value !== \"\") out[need.fieldKey] = value;\n }\n return out;\n}\n\n/** Prints a concise summary of what env reconciliation did. */\nexport function reportEnvResolutions(resolutions: EnvResolution[]): void {\n if (resolutions.length === 0) return;\n const written = resolutions.filter((r) => r.status === \"written\");\n const already = resolutions.filter((r) => r.status === \"already-set\");\n const skipped = resolutions.filter((r) => r.status === \"skipped\");\n\n if (written.length > 0) {\n console.log(\n `${pc.green(\"Wrote to .env:\")} ${written.map((r) => r.env).join(\", \")}`,\n );\n }\n if (already.length > 0) {\n console.log(pc.dim(`Already set: ${already.map((r) => r.env).join(\", \")}`));\n }\n if (skipped.length > 0) {\n console.log(\n `${pc.yellow(\"Left unset (set before deploy):\")} ${skipped\n .map((r) => r.env)\n .join(\", \")}`,\n );\n }\n}\n"],"mappings":";;;;;;;;AAsCA,MAAM,SAAS;AACf,MAAM,SAAS;;;;;;;AAQf,MAAM,eAAe;;AAGrB,SAAS,YAAY,MAAsC;AACzD,KAAI,CAAC,GAAG,WAAW,KAAK,CAAE,QAAO,EAAE;AACnC,QAAO,SAAS,GAAG,aAAa,MAAM,QAAQ,CAAC;;;AAIjD,SAAS,aAAa,MAAc,MAAoB;AACtD,KAAI,SAAS,GAAI;AACjB,KAAI,GAAG,WAAW,KAAK,EAAE;EACvB,MAAM,WAAW,GAAG,aAAa,MAAM,QAAQ;EAC/C,MAAM,MAAM,SAAS,SAAS,KAAK,CAAC,SAAS,SAAS,KAAK,GAAG,OAAO;AACrE,KAAG,cAAc,MAAM,WAAW,MAAM,KAAK;OAE7C,IAAG,cAAc,MAAM,KAAK;;;;;;;AAShC,SAAgB,WACd,SACA,cACA,QAAQ,cACH;AACL,KAAI,QAAQ,UAAU,MAAO,QAAO;AACpC,SAAQ,IACN,GAAG,IACD,KAAK,QAAQ,OAAO,GAAG,a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MAAI,KAAK,eAAgB;EACzB,MAAM,SAAS,MAAM,KAAK;GACxB,SAAS,GAAG,KAAK,SAAS,IAAI,KAAK,aAAa;GAChD,aAAa,KAAK,eAAe;GAClC,CAAC;AACF,MAAI,SAAS,OAAO,CAAE;EACtB,MAAM,SAAS,UAAU,IAAI,MAAM;AACnC,MAAI,UAAU,GAAI,KAAI,KAAK,YAAY;;AAEzC,QAAO;;;AAIT,SAAgB,qBAAqB,aAAoC;AACvE,KAAI,YAAY,WAAW,EAAG;CAC9B,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,UAAU;CACjE,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,cAAc;CACrE,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,UAAU;AAEjE,KAAI,QAAQ,SAAS,EACnB,SAAQ,IACN,GAAG,GAAG,MAAM,iBAAiB,CAAC,GAAG,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,GACtE;AAEH,KAAI,QAAQ,SAAS,EACnB,SAAQ,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC;AAE7E,KAAI,QAAQ,SAAS,EACnB,SAAQ,IACN,GAAG,GAAG,OAAO,kCAAkC,CAAC,GAAG,QAChD,KAAK,MAAM,EAAE,IAAI,CACjB,KAAK,KAAK,GACd"}
1
+ {"version":3,"file":"env-writer.js","names":[],"sources":["../../../../src/cli/commands/registry/env-writer.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport type { BindingValueNeed } from \"./config-plan\";\nimport {\n collectEnvNeeds,\n type EnvNeed,\n type EnvResolution,\n parseEnv,\n reconcileEnv,\n serializeEnvAppend,\n type ValueProvider,\n} from \"./env-reconcile\";\nimport type { ResourceRequirementRow } from \"./requirements\";\nimport {\n composeResourceId,\n DEFAULT_PARENTS,\n isFlatListable,\n isParentContext,\n listParentContextStep,\n listWorkspaceResources,\n parentContextDepth,\n} from \"./workspace-picker\";\n\nexport interface EnvSyncOptions {\n /** Directory holding `.env` / `.env.example` (the app root). */\n cwd: string;\n /** true = never prompt (agent/CI). Uses flag values or leaves unset. */\n nonInteractive: boolean;\n /** Pre-supplied env values from flags, e.g. { DATABRICKS_WAREHOUSE_ID: \"abc\" }. */\n values?: Record<string, string>;\n /** Databricks profile for the workspace picker (else the CLI default). */\n profile?: string;\n}\n\n/** Sentinel select value meaning \"let me type the id myself\". */\nconst MANUAL = \"__manual__\";\nconst BROWSE = \"__browse__\";\n\n/**\n * Max resources shown in a picker select. Real workspaces can have thousands\n * (e.g. 5000+ SQL warehouses); an unbounded select is unusable. Beyond this we\n * show the first N and log how many were hidden — never silently drop — and the\n * \"Enter manually\" option always lets the user type an id the list omits.\n */\nconst PICKER_LIMIT = 25;\n\n/** Reads a `.env`-style file into a map; empty when the file is absent. */\nexport function readEnvFile(file: string): Record<string, string> {\n if (!fs.existsSync(file)) return {};\n return parseEnv(fs.readFileSync(file, \"utf-8\"));\n}\n\n/** Appends text to a file, creating it (with a trailing newline) if needed. */\nfunction appendToFile(file: string, text: string): void {\n if (text === \"\") return;\n if (fs.existsSync(file)) {\n const existing = fs.readFileSync(file, \"utf-8\");\n const sep = existing.length > 0 && !existing.endsWith(\"\\n\") ? \"\\n\" : \"\";\n fs.writeFileSync(file, existing + sep + text);\n } else {\n fs.writeFileSync(file, text);\n }\n}\n\n/**\n * Caps a choice list to {@link PICKER_LIMIT} for display, logging how many were\n * hidden so the truncation is never silent. The caller always appends an\n * \"Enter manually\" option, so an omitted resource is still reachable.\n */\nexport function capChoices<T>(\n choices: T[],\n resourceType: string,\n limit = PICKER_LIMIT,\n): T[] {\n if (choices.length <= limit) return choices;\n console.log(\n pc.dim(\n ` ${choices.length} ${resourceType}s found; showing first ${limit}. ` +\n 'Use \"Enter manually\" if yours is not listed.',\n ),\n );\n return choices.slice(0, limit);\n}\n\n/** Free-text prompt for one env need; undefined to skip. */\nasync function promptText(need: EnvNeed): Promise<string | undefined> {\n const { isCancel, text } = await import(\"@clack/prompts\");\n const tag = need.required ? \"required\" : \"optional\";\n const answer = await text({\n message: `${need.env} (${need.resourceType}, ${tag})`,\n placeholder: need.description ?? \"leave blank to skip\",\n });\n if (isCancel(answer)) return undefined;\n const value = (answer ?? \"\").trim();\n return value === \"\" ? undefined : value;\n}\n\n/** Presents one workspace list as a select; MANUAL/cancel handled by caller. */\nasync function selectFrom(\n message: string,\n choices: { value: string; label: string }[],\n): Promise<string | typeof MANUAL | null> {\n const { isCancel, select } = await import(\"@clack/prompts\");\n const picked = await select({\n message,\n options: [...choices, { value: MANUAL, label: \"Enter manually / skip\" }],\n });\n if (isCancel(picked)) return null;\n return String(picked) as string | typeof MANUAL;\n}\n\n/**\n * Type-to-filter picker over the full choice list (no cap): the user searches\n * by name/id as they type. Appends \"Enter manually\" so an omitted value is\n * still reachable. Returns MANUAL to fall through to free-text, or null on\n * cancel.\n */\nasync function autocompleteFrom(\n message: string,\n choices: { value: string; label: string }[],\n): Promise<string | typeof MANUAL | null> {\n const { autocomplete, isCancel } = await import(\"@clack/prompts\");\n const picked = await autocomplete({\n message,\n options: [...choices, { value: MANUAL, label: \"Enter manually / skip\" }],\n placeholder: \"type to search…\",\n });\n if (isCancel(picked)) return null;\n return String(picked) as string | typeof MANUAL;\n}\n\n/**\n * Drill-down picker for parent-context types (volume→catalog/schema,\n * secret→scope, vector_search_index→endpoint). Walks each step, listing the\n * next level from the prior pick. Returns the final resource id, or undefined\n * to fall back to free-text (on cancel, empty level, or MANUAL at any step).\n */\nasync function pickParentContext(\n need: EnvNeed,\n profile: string | undefined,\n): Promise<string | undefined> {\n const depth = parentContextDepth(need.resourceType);\n const defaults = DEFAULT_PARENTS[need.resourceType];\n if (defaults) {\n // Open on the default parents; an empty listing falls through to the walk.\n const step = listParentContextStep(\n need.resourceType,\n defaults.length,\n defaults,\n profile,\n );\n if (step && step.choices.length > 0) {\n const picked = await selectFrom(\n `${need.env} — pick a ${step.key} in ${defaults.join(\".\")}`,\n [\n ...capChoices(step.choices, step.key),\n { value: BROWSE, label: \"Browse other catalogs...\" },\n ],\n );\n if (picked === null || picked === MANUAL) return undefined;\n if (picked !== BROWSE) {\n return composeResourceId(need.resourceType, [...defaults, picked]);\n }\n }\n }\n const picks: string[] = [];\n for (let i = 0; i < depth; i++) {\n const step = listParentContextStep(need.resourceType, i, picks, profile);\n if (!step || step.choices.length === 0) {\n console.log(\n pc.dim(\n ` No ${step?.key ?? need.resourceType} found — enter the id manually.`,\n ),\n );\n return undefined;\n }\n const picked = await selectFrom(\n `${need.env} — pick a ${step.key}`,\n capChoices(step.choices, step.key),\n );\n if (picked === null || picked === MANUAL) return undefined;\n picks.push(picked);\n }\n // Compose the id from the picks: most types end on a self-qualified id, but a\n // secret needs both scope and key (scope/key).\n return composeResourceId(need.resourceType, picks);\n}\n\n/**\n * Builds the value provider. Precedence: --env flag, then (interactive only) a\n * workspace picker — flat select for flat-listable types, drill-down for\n * parent-context types — else a free-text prompt. The picker degrades to\n * free-text whenever the workspace can't be listed (no profile, offline, auth\n * error, empty) so it never hard-fails.\n */\nfunction makeProvider(opts: EnvSyncOptions): ValueProvider {\n return async (need: EnvNeed) => {\n const fromFlag = opts.values?.[need.env];\n if (fromFlag !== undefined) return fromFlag;\n if (opts.nonInteractive) return undefined;\n\n if (isFlatListable(need.resourceType)) {\n const { choices, truncated, error } = await listWorkspaceResources(\n need.resourceType,\n opts.profile,\n );\n if (choices.length > 0) {\n if (truncated) {\n console.log(\n pc.dim(\n ` Showing the first ${choices.length} ${need.resourceType}s; use \"Enter manually\" if yours isn't listed.`,\n ),\n );\n }\n const picked = await autocompleteFrom(\n `${need.env} — search ${need.resourceType}s`,\n choices,\n );\n if (picked === null) return undefined;\n if (picked !== MANUAL) return picked;\n // fall through to free-text\n } else if (error) {\n // Listing failed (usually auth/profile) — say so, don't pretend the\n // workspace is empty, and point at the fix.\n console.log(\n pc.yellow(\n ` Couldn't list ${need.resourceType}s from the workspace (${error}).`,\n ),\n );\n console.log(\n pc.dim(\n \" Enter an id manually, or re-run with --profile <name> (or set DATABRICKS_CONFIG_PROFILE) so the picker can reach the workspace.\",\n ),\n );\n } else {\n console.log(\n pc.dim(\n ` No ${need.resourceType} found in the workspace — enter an id manually.`,\n ),\n );\n }\n } else if (isParentContext(need.resourceType)) {\n const picked = await pickParentContext(need, opts.profile);\n if (picked !== undefined) return picked;\n // fall through to free-text\n }\n\n return promptText(need);\n };\n}\n\n/**\n * Reconciles a plugin's declared resource env vars into the app's local `.env`\n * (and mirrors variable names into `.env.example`). Never overwrites keys the\n * user already set; skips platform-injected fields. Returns the per-var\n * resolutions so callers can report what happened.\n */\nexport async function syncEnv(\n rows: ResourceRequirementRow[],\n opts: EnvSyncOptions,\n): Promise<EnvResolution[]> {\n const needs = collectEnvNeeds(rows);\n if (needs.length === 0) return [];\n\n const envPath = path.join(opts.cwd, \".env\");\n const examplePath = path.join(opts.cwd, \".env.example\");\n const existing = readEnvFile(envPath);\n\n const resolutions = await reconcileEnv(needs, {\n existing,\n provide: makeProvider(opts),\n });\n\n const written = resolutions.filter(\n (r): r is EnvResolution & { value: string } =>\n r.status === \"written\" && r.value !== undefined,\n );\n appendToFile(\n envPath,\n serializeEnvAppend(written.map((r) => ({ env: r.env, value: r.value }))),\n );\n\n // .env.example carries the variable names (no secret values), and only for\n // vars not already documented there.\n const exampleExisting = readEnvFile(examplePath);\n const newExampleKeys = needs.filter((n) => !(n.env in exampleExisting));\n appendToFile(\n examplePath,\n serializeEnvAppend(newExampleKeys.map((n) => ({ env: n.env, value: \"\" }))),\n );\n\n return resolutions;\n}\n\n/**\n * Prompts for the {@link BindingValueNeed}s that `.env` reconciliation can't\n * collect, returning a `fieldKey -> value` map for buildConfigPlan. Values are\n * not written to `.env` (these fields have no env var). Non-interactive mode\n * uses `values[fieldKey]` if provided, else leaves the field unset.\n */\nexport async function collectBindingValues(\n needs: BindingValueNeed[],\n opts: EnvSyncOptions,\n): Promise<Record<string, string>> {\n const { isCancel, text } = await import(\"@clack/prompts\");\n const out: Record<string, string> = {};\n for (const need of needs) {\n const fromFlag = opts.values?.[need.fieldKey];\n if (fromFlag !== undefined) {\n out[need.fieldKey] = fromFlag;\n continue;\n }\n if (opts.nonInteractive) continue;\n const answer = await text({\n message: `${need.fieldKey} (${need.resourceType}) — required for databricks.yml`,\n placeholder: need.description ?? \"leave blank to set before deploy\",\n });\n if (isCancel(answer)) continue;\n const value = (answer ?? \"\").trim();\n if (value !== \"\") out[need.fieldKey] = value;\n }\n return out;\n}\n\n/** Prints a concise summary of what env reconciliation did. */\nexport function reportEnvResolutions(resolutions: EnvResolution[]): void {\n if (resolutions.length === 0) return;\n const written = resolutions.filter((r) => r.status === \"written\");\n const already = resolutions.filter((r) => r.status === \"already-set\");\n const skipped = resolutions.filter((r) => r.status === \"skipped\");\n\n if (written.length > 0) {\n console.log(\n `${pc.green(\"Wrote to .env:\")} ${written.map((r) => r.env).join(\", \")}`,\n );\n }\n if (already.length > 0) {\n console.log(pc.dim(`Already set: ${already.map((r) => r.env).join(\", \")}`));\n }\n if (skipped.length > 0) {\n console.log(\n `${pc.yellow(\"Left unset (set before deploy):\")} ${skipped\n .map((r) => r.env)\n .join(\", \")}`,\n );\n }\n}\n"],"mappings":";;;;;;;;AAsCA,MAAM,SAAS;AACf,MAAM,SAAS;;;;;;;AAQf,MAAM,eAAe;;AAGrB,SAAgB,YAAY,MAAsC;AAChE,KAAI,CAAC,GAAG,WAAW,KAAK,CAAE,QAAO,EAAE;AACnC,QAAO,SAAS,GAAG,aAAa,MAAM,QAAQ,CAAC;;;AAIjD,SAAS,aAAa,MAAc,MAAoB;AACtD,KAAI,SAAS,GAAI;AACjB,KAAI,GAAG,WAAW,KAAK,EAAE;EACvB,MAAM,WAAW,GAAG,aAAa,MAAM,QAAQ;EAC/C,MAAM,MAAM,SAAS,SAAS,KAAK,CAAC,SAAS,SAAS,KAAK,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,eAAsB,qBACpB,OACA,MACiC;CACjC,MAAM,EAAE,UAAU,SAAS,MAAM,OAAO;CACxC,MAAM,MAA8B,EAAE;AACtC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,SAAS,KAAK;AACpC,MAAI,aAAa,QAAW;AAC1B,OAAI,KAAK,YAAY;AACrB;;AAEF,MAAI,KAAK,eAAgB;EACzB,MAAM,SAAS,MAAM,KAAK;GACxB,SAAS,GAAG,KAAK,SAAS,IAAI,KAAK,aAAa;GAChD,aAAa,KAAK,eAAe;GAClC,CAAC;AACF,MAAI,SAAS,OAAO,CAAE;EACtB,MAAM,SAAS,UAAU,IAAI,MAAM;AACnC,MAAI,UAAU,GAAI,KAAI,KAAK,YAAY;;AAEzC,QAAO;;;AAIT,SAAgB,qBAAqB,aAAoC;AACvE,KAAI,YAAY,WAAW,EAAG;CAC9B,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,UAAU;CACjE,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,cAAc;CACrE,MAAM,UAAU,YAAY,QAAQ,MAAM,EAAE,WAAW,UAAU;AAEjE,KAAI,QAAQ,SAAS,EACnB,SAAQ,IACN,GAAG,GAAG,MAAM,iBAAiB,CAAC,GAAG,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,GACtE;AAEH,KAAI,QAAQ,SAAS,EACnB,SAAQ,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC;AAE7E,KAAI,QAAQ,SAAS,EACnB,SAAQ,IACN,GAAG,GAAG,OAAO,kCAAkC,CAAC,GAAG,QAChD,KAAK,MAAM,EAAE,IAAI,CACjB,KAAK,KAAK,GACd"}
@@ -18,6 +18,17 @@ function findServerFile(serverRoot) {
18
18
  }
19
19
  return null;
20
20
  }
21
+ /** `{ a, b }` of a value import from `module`; type-only imports are erased at compile time. */
22
+ function namedImportsFrom(stmts, module) {
23
+ for (const stmt of stmts) {
24
+ const source = stmt.field("source")?.text().slice(1, -1);
25
+ const typeOnly = stmt.children().some((c) => c.kind() === "type" && !c.isNamed());
26
+ if (source !== module || typeOnly) continue;
27
+ const named = stmt.find({ rule: { kind: "named_imports" } });
28
+ if (named) return named;
29
+ }
30
+ return null;
31
+ }
21
32
  /** The `plugins: [...]` array node inside a createApp call, if present. */
22
33
  function findPluginsArray(root) {
23
34
  for (const pair of root.findAll({ rule: { kind: "pair" } })) {
@@ -55,40 +66,54 @@ function importBindingNames(stmt) {
55
66
  }
56
67
  return names;
57
68
  }
58
- /**
59
- * Best-effort: register a plugin in the server entry's `createApp({ plugins })`
60
- * call by inserting the import and adding it to the array. Only edits the
61
- * standard shape (a `plugins: [...]` array literal); returns `skipped` otherwise
62
- * so the caller can fall back to printing manual instructions. Idempotent.
63
- */
64
- function registerPluginInServer(serverRoot, importPath, exportName) {
69
+ function registerPluginInServer(serverRoot, importPath, exportName, callArgs = "") {
70
+ return registerPluginsInServer(serverRoot, [{
71
+ importPath,
72
+ exportName,
73
+ callArgs
74
+ }])[0];
75
+ }
76
+ /** Registers the entries in order with a single write, so a dev server restarts once. */
77
+ function registerPluginsInServer(serverRoot, entries) {
78
+ const serverFile = findServerFile(serverRoot);
79
+ if (!serverFile) return entries.map(() => ({
80
+ status: "skipped",
81
+ reason: "no server entry file found"
82
+ }));
83
+ const file = path.relative(serverRoot, serverFile);
84
+ const lang = serverFile.endsWith(".tsx") ? Lang.Tsx : Lang.TypeScript;
85
+ const original = fs.readFileSync(serverFile, "utf-8");
86
+ let content = original;
87
+ const results = entries.map((e) => {
88
+ const { output, ...r } = registerInSource(content, lang, e);
89
+ if (output !== void 0) content = output;
90
+ return r.status === "skipped" ? r : {
91
+ ...r,
92
+ file
93
+ };
94
+ });
95
+ if (content !== original) fs.writeFileSync(serverFile, content);
96
+ return results;
97
+ }
98
+ /** Applies one entry to the server source; `output` is set when it changed. */
99
+ function registerInSource(content, lang, { importPath, exportName, callArgs = "" }) {
65
100
  if (!JS_IDENTIFIER.test(exportName)) return {
66
101
  status: "skipped",
67
102
  reason: "invalid plugin export name"
68
103
  };
69
- if (!/^[.][./A-Za-z0-9_-]*$/.test(importPath)) return {
104
+ if (!/^[.][./A-Za-z0-9_-]*$/.test(importPath) && !/^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(\/[\w.-]+)*$/i.test(importPath)) return {
70
105
  status: "skipped",
71
106
  reason: "invalid plugin import path"
72
107
  };
73
- const serverFile = findServerFile(serverRoot);
74
- if (!serverFile) return {
75
- status: "skipped",
76
- reason: "no server entry file found"
77
- };
78
- const content = fs.readFileSync(serverFile, "utf-8");
79
- const root = parse(serverFile.endsWith(".tsx") ? Lang.Tsx : Lang.TypeScript, content).root();
108
+ const root = parse(lang, content).root();
80
109
  const arr = findPluginsArray(root);
81
110
  if (!arr) return {
82
111
  status: "skipped",
83
112
  reason: "no createApp({ plugins: [...] }) array found"
84
113
  };
85
- const file = path.relative(serverRoot, serverFile);
86
- if (arrayElementNames(arr).has(exportName)) return {
87
- status: "already",
88
- file
89
- };
114
+ if (arrayElementNames(arr).has(exportName)) return { status: "already" };
90
115
  const edits = [];
91
- const newElem = `${exportName}()`;
116
+ const newElem = `${exportName}(${callArgs})`;
92
117
  const elementKinds = [
93
118
  "identifier",
94
119
  "call_expression",
@@ -106,19 +131,30 @@ function registerPluginInServer(serverRoot, importPath, exportName) {
106
131
  const importStmts = root.findAll({ rule: { kind: "import_statement" } });
107
132
  const hasBinding = importStmts.some((s) => importBindingNames(s).has(exportName));
108
133
  const importLine = `import { ${exportName} } from "${importPath}";`;
109
- if (!hasBinding && importStmts.length > 0) {
134
+ const named = hasBinding ? null : namedImportsFrom(importStmts, importPath);
135
+ if (named) {
136
+ const specs = named.findAll({ rule: { kind: "import_specifier" } });
137
+ const lastSpec = specs[specs.length - 1];
138
+ if (!lastSpec) edits.push(named.replace(`{ ${exportName} }`));
139
+ else {
140
+ const startIdx = lastSpec.range().start.index;
141
+ const lineStart = content.lastIndexOf("\n", startIdx - 1);
142
+ const indent = content.slice(lineStart + 1, startIdx);
143
+ const sep = named.text().includes("\n") && /^[ \t]*$/.test(indent) ? `,\n${indent}` : ", ";
144
+ edits.push(lastSpec.replace(`${lastSpec.text()}${sep}${exportName}`));
145
+ }
146
+ } else if (!hasBinding && importStmts.length > 0) {
110
147
  const last = importStmts[importStmts.length - 1];
111
148
  edits.push(last.replace(`${last.text()}\n${importLine}`));
112
149
  }
113
150
  let output = root.commitEdits(edits);
114
- if (!hasBinding && importStmts.length === 0) output = `${importLine}\n${output}`;
115
- fs.writeFileSync(serverFile, output);
151
+ if (!hasBinding && !named && importStmts.length === 0) output = `${importLine}\n${output}`;
116
152
  return {
117
153
  status: "wired",
118
- file
154
+ output
119
155
  };
120
156
  }
121
157
 
122
158
  //#endregion
123
- export { registerPluginInServer };
159
+ export { findServerFile, registerPluginInServer, registerPluginsInServer };
124
160
  //# sourceMappingURL=server-register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-register.js","names":[],"sources":["../../../../src/cli/commands/registry/server-register.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { Lang, parse, type SgNode } from \"@ast-grep/napi\";\n\nimport { JS_IDENTIFIER } from \"./constants\";\n\n/** Server entry candidates within the server root, in priority order. */\nconst SERVER_FILE_CANDIDATES = [\n \"server.ts\",\n \"index.ts\",\n \"src/server.ts\",\n \"src/index.ts\",\n];\n\nexport interface RegisterResult {\n /** wired = edited; already = plugin was present; skipped = couldn't safely edit. */\n status: \"wired\" | \"already\" | \"skipped\";\n file?: string;\n reason?: string;\n}\n\nfunction findServerFile(serverRoot: string): string | null {\n for (const candidate of SERVER_FILE_CANDIDATES) {\n const p = path.join(serverRoot, candidate);\n if (fs.existsSync(p)) return p;\n }\n return null;\n}\n\n/** The `plugins: [...]` array node inside a createApp call, if present. */\nfunction findPluginsArray(root: SgNode): SgNode | null {\n for (const pair of root.findAll({ rule: { kind: \"pair\" } })) {\n const key = pair.find({ rule: { kind: \"property_identifier\" } });\n if (key?.text() !== \"plugins\") continue;\n const arr = pair.find({ rule: { kind: \"array\" } });\n if (arr) return arr;\n }\n return null;\n}\n\nfunction arrayElementNames(arr: SgNode): Set<string> {\n const names = new Set<string>();\n for (const child of arr.children()) {\n if (child.kind() === \"identifier\") {\n names.add(child.text());\n } else if (child.kind() === \"call_expression\") {\n const callee = child.children()[0];\n if (callee?.kind() === \"identifier\") names.add(callee.text());\n }\n }\n return names;\n}\n\n/** Local binding names introduced by an import statement — default, namespace,\n * and named specifiers, with aliases resolved to the local name. */\nfunction importBindingNames(stmt: SgNode): Set<string> {\n const names = new Set<string>();\n const clause = stmt.find({ rule: { kind: \"import_clause\" } });\n if (!clause) return names;\n for (const child of clause.children()) {\n const kind = child.kind();\n if (kind === \"identifier\") {\n names.add(child.text());\n } else if (kind === \"namespace_import\") {\n const id = child.find({ rule: { kind: \"identifier\" } });\n if (id) names.add(id.text());\n } else if (kind === \"named_imports\") {\n for (const spec of child.findAll({\n rule: { kind: \"import_specifier\" },\n })) {\n const local = spec.field(\"alias\")?.text() ?? spec.field(\"name\")?.text();\n if (local) names.add(local);\n }\n }\n }\n return names;\n}\n\n/**\n * Best-effort: register a plugin in the server entry's `createApp({ plugins })`\n * call by inserting the import and adding it to the array. Only edits the\n * standard shape (a `plugins: [...]` array literal); returns `skipped` otherwise\n * so the caller can fall back to printing manual instructions. Idempotent.\n */\nexport function registerPluginInServer(\n serverRoot: string,\n importPath: string,\n exportName: string,\n): RegisterResult {\n // exportName and importPath are interpolated into the user's server source.\n // Registry items are untrusted, so refuse anything that isn't a plain JS\n // identifier / clean relative module path — prevents code injection via a\n // crafted export name or import path.\n if (!JS_IDENTIFIER.test(exportName)) {\n return { status: \"skipped\", reason: \"invalid plugin export name\" };\n }\n if (!/^[.][./A-Za-z0-9_-]*$/.test(importPath)) {\n return { status: \"skipped\", reason: \"invalid plugin import path\" };\n }\n\n const serverFile = findServerFile(serverRoot);\n if (!serverFile) {\n return { status: \"skipped\", reason: \"no server entry file found\" };\n }\n\n const content = fs.readFileSync(serverFile, \"utf-8\");\n const lang = serverFile.endsWith(\".tsx\") ? Lang.Tsx : Lang.TypeScript;\n const root = parse(lang, content).root();\n\n const arr = findPluginsArray(root);\n if (!arr) {\n return {\n status: \"skipped\",\n reason: \"no createApp({ plugins: [...] }) array found\",\n };\n }\n\n const file = path.relative(serverRoot, serverFile);\n if (arrayElementNames(arr).has(exportName)) {\n return { status: \"already\", file };\n }\n\n const edits = [];\n\n // toPlugin exports are factories, registered as a call: `hello()`.\n const newElem = `${exportName}()`;\n\n // Insert before the first element, matching its indentation so the array\n // formatting is preserved (or inline for a single-line array).\n const elementKinds = [\"identifier\", \"call_expression\", \"spread_element\"];\n const firstEl = arr\n .children()\n .find((c) => elementKinds.includes(c.kind() as string));\n if (!firstEl) {\n edits.push(arr.replace(`[${newElem}]`));\n } else {\n const startIdx = firstEl.range().start.index;\n const lineStart = content.lastIndexOf(\"\\n\", startIdx - 1);\n const indent = content.slice(lineStart + 1, startIdx);\n const multiline = lineStart !== -1 && /^[ \\t]*$/.test(indent);\n const sep = multiline ? `,\\n${indent}` : \", \";\n edits.push(firstEl.replace(`${newElem}${sep}${firstEl.text()}`));\n }\n\n // Add the import unless `exportName` is already bound by some import. De-dup\n // on the binding, not the module path: an existing import from the same path\n // under a different name (e.g. `import { HelloPlugin } from \"./plugins/hello\"`)\n // must not suppress this one, or the `${exportName}()` element just added to\n // the array would reference an unimported symbol and the server won't compile.\n const importStmts = root.findAll({ rule: { kind: \"import_statement\" } });\n const hasBinding = importStmts.some((s) =>\n importBindingNames(s).has(exportName),\n );\n const importLine = `import { ${exportName} } from \"${importPath}\";`;\n if (!hasBinding && importStmts.length > 0) {\n const last = importStmts[importStmts.length - 1];\n edits.push(last.replace(`${last.text()}\\n${importLine}`));\n }\n\n let output = root.commitEdits(edits);\n if (!hasBinding && importStmts.length === 0) {\n output = `${importL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OAAM,KAAK,IAAI,QAAQ,IAAI,QAAQ,GAAG,CAAC;MAClC;EACL,MAAM,WAAW,QAAQ,OAAO,CAAC,MAAM;EACvC,MAAM,YAAY,QAAQ,YAAY,MAAM,WAAW,EAAE;EACzD,MAAM,SAAS,QAAQ,MAAM,YAAY,GAAG,SAAS;EAErD,MAAM,MADY,cAAc,MAAM,WAAW,KAAK,OAAO,GACrC,MAAM,WAAW;AACzC,QAAM,KAAK,QAAQ,QAAQ,GAAG,UAAU,MAAM,QAAQ,MAAM,GAAG,CAAC;;CAQlE,MAAM,cAAc,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,EAAE,CAAC;CACxE,MAAM,aAAa,YAAY,MAAM,MACnC,mBAAmB,EAAE,CAAC,IAAI,WAAW,CACtC;CACD,MAAM,aAAa,YAAY,WAAW,WAAW,WAAW;AAChE,KAAI,CAAC,cAAc,YAAY,SAAS,GAAG;EACzC,MAAM,OAAO,YAAY,YAAY,SAAS;AAC9C,QAAM,KAAK,KAAK,QAAQ,GAAG,KAAK,MAAM,CAAC,IAAI,aAAa,CAAC;;CAG3D,IAAI,SAAS,KAAK,YAAY,MAAM;AACpC,KAAI,CAAC,cAAc,YAAY,WAAW,EACxC,UAAS,GAAG,WAAW,IAAI;AAE7B,IAAG,cAAc,YAAY,OAAO;AAEpC,QAAO;EAAE,QAAQ;EAAS;EAAM"}
1
+ {"version":3,"file":"server-register.js","names":[],"sources":["../../../../src/cli/commands/registry/server-register.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { Lang, parse, type SgNode } from \"@ast-grep/napi\";\n\nimport { JS_IDENTIFIER } from \"./constants\";\n\n/** Server entry candidates within the server root, in priority order. */\nconst SERVER_FILE_CANDIDATES = [\n \"server.ts\",\n \"index.ts\",\n \"src/server.ts\",\n \"src/index.ts\",\n];\n\nexport interface RegisterResult {\n /** wired = edited; already = plugin was present; skipped = couldn't safely edit. */\n status: \"wired\" | \"already\" | \"skipped\";\n file?: string;\n reason?: string;\n}\n\nexport function findServerFile(serverRoot: string): string | null {\n for (const candidate of SERVER_FILE_CANDIDATES) {\n const p = path.join(serverRoot, candidate);\n if (fs.existsSync(p)) return p;\n }\n return null;\n}\n\n/** `{ a, b }` of a value import from `module`; type-only imports are erased at compile time. */\nfunction namedImportsFrom(stmts: SgNode[], module: string): SgNode | null {\n for (const stmt of stmts) {\n const source = stmt.field(\"source\")?.text().slice(1, -1);\n // `import type` shows as an unnamed `type` token, wherever comments sit.\n const typeOnly = stmt\n .children()\n .some((c) => c.kind() === \"type\" && !c.isNamed());\n if (source !== module || typeOnly) continue;\n const named = stmt.find({ rule: { kind: \"named_imports\" } });\n if (named) return named;\n }\n return null;\n}\n\n/** The `plugins: [...]` array node inside a createApp call, if present. */\nfunction findPluginsArray(root: SgNode): SgNode | null {\n for (const pair of root.findAll({ rule: { kind: \"pair\" } })) {\n const key = pair.find({ rule: { kind: \"property_identifier\" } });\n if (key?.text() !== \"plugins\") continue;\n const arr = pair.find({ rule: { kind: \"array\" } });\n if (arr) return arr;\n }\n return null;\n}\n\nfunction arrayElementNames(arr: SgNode): Set<string> {\n const names = new Set<string>();\n for (const child of arr.children()) {\n if (child.kind() === \"identifier\") {\n names.add(child.text());\n } else if (child.kind() === \"call_expression\") {\n const callee = child.children()[0];\n if (callee?.kind() === \"identifier\") names.add(callee.text());\n }\n }\n return names;\n}\n\n/** Local binding names introduced by an import statement — default, namespace,\n * and named specifiers, with aliases resolved to the local name. */\nfunction importBindingNames(stmt: SgNode): Set<string> {\n const names = new Set<string>();\n const clause = stmt.find({ rule: { kind: \"import_clause\" } });\n if (!clause) return names;\n for (const child of clause.children()) {\n const kind = child.kind();\n if (kind === \"identifier\") {\n names.add(child.text());\n } else if (kind === \"namespace_import\") {\n const id = child.find({ rule: { kind: \"identifier\" } });\n if (id) names.add(id.text());\n } else if (kind === \"named_imports\") {\n for (const spec of child.findAll({\n rule: { kind: \"import_specifier\" },\n })) {\n const local = spec.field(\"alias\")?.text() ?? spec.field(\"name\")?.text();\n if (local) names.add(local);\n }\n }\n }\n return names;\n}\n\n/**\n * Best-effort: register a plugin in the server entry's `createApp({ plugins })`\n * call by inserting the import and adding it to the array. Only edits the\n * standard shape (a `plugins: [...]` array literal); returns `skipped` otherwise\n * so the caller can fall back to printing manual instructions. Idempotent.\n */\n/** `import { exportName } from importPath`, registered as `exportName(callArgs)`. */\nexport interface RegisterEntry {\n importPath: string;\n exportName: string;\n /** CLI-built, never registry data. */\n callArgs?: string;\n}\n\nexport function registerPluginInServer(\n serverRoot: string,\n importPath: string,\n exportName: string,\n callArgs = \"\",\n): RegisterResult {\n return registerPluginsInServer(serverRoot, [\n { importPath, exportName, callArgs },\n ])[0];\n}\n\n/** Registers the entries in order with a single write, so a dev server restarts once. */\nexport function registerPluginsInServer(\n serverRoot: string,\n entries: RegisterEntry[],\n): RegisterResult[] {\n const serverFile = findServerFile(serverRoot);\n if (!serverFile) {\n return entries.map(() => ({\n status: \"skipped\",\n reason: \"no server entry file found\",\n }));\n }\n const file = path.relative(serverRoot, serverFile);\n const lang = serverFile.endsWith(\".tsx\") ? Lang.Tsx : Lang.TypeScript;\n const original = fs.readFileSync(serverFile, \"utf-8\");\n let content = original;\n const results = entries.map((e): RegisterResult => {\n const { output, ...r } = registerInSource(content, lang, e);\n if (output !== undefined) content = output;\n return r.status === \"skipped\" ? r : { ...r, file };\n });\n if (content !== original) fs.writeFileSync(serverFile, content);\n return results;\n}\n\n/** Applies one entry to the server source; `output` is set when it changed. */\nfunction registerInSource(\n content: string,\n lang: Lang,\n { importPath, exportName, callArgs = \"\" }: RegisterEntry,\n): RegisterResult & { output?: string } {\n // exportName and importPath are interpolated into the user's server source.\n // Registry items are untrusted, so refuse anything that isn't a plain JS\n // identifier / clean relative module path — prevents code injection via a\n // crafted export name or import path. npm plugins use a plain package specifier.\n if (!JS_IDENTIFIER.test(exportName)) {\n return { status: \"skipped\", reason: \"invalid plugin export name\" };\n }\n if (\n !/^[.][./A-Za-z0-9_-]*$/.test(importPath) &&\n !/^(@[a-z0-9][\\w.-]*\\/)?[a-z0-9][\\w.-]*(\\/[\\w.-]+)*$/i.test(importPath)\n ) {\n return { status: \"skipped\", reason: \"invalid plugin import path\" };\n }\n\n const root = parse(lang, content).root();\n\n const arr = findPluginsArray(root);\n if (!arr) {\n return {\n status: \"skipped\",\n reason: \"no createApp({ plugins: [...] }) array found\",\n };\n }\n\n if (arrayElementNames(arr).has(exportName)) {\n return { status: \"already\" };\n }\n\n const edits = [];\n\n // toPlugin exports are factories, registered as a call: `hello()`.\n const newElem = `${exportName}(${callArgs})`;\n\n // Insert before the first element, matching its indentation so the array\n // formatting is preserved (or inline for a single-line array).\n const elementKinds = [\"identifier\", \"call_expression\", \"spread_element\"];\n const firstEl = arr\n .children()\n .find((c) => elementKinds.includes(c.kind() as string));\n if (!firstEl) {\n edits.push(arr.replace(`[${newElem}]`));\n } else {\n const startIdx = firstEl.range().start.index;\n const lineStart = content.lastIndexOf(\"\\n\", startIdx - 1);\n const indent = content.slice(lineStart + 1, startIdx);\n const multiline = lineStart !== -1 && /^[ \\t]*$/.test(indent);\n const sep = multiline ? `,\\n${indent}` : \", \";\n edits.push(firstEl.replace(`${newElem}${sep}${firstEl.text()}`));\n }\n\n // Add the import unless `exportName` is already bound by some import. De-dup\n // on the binding, not the module path: an existing import from the same path\n // under a different name (e.g. `import { HelloPlugin } from \"./plugins/hello\"`)\n // must not suppress this one, or the `${exportName}()` element just added to\n // the array would reference an unimported symbol and the server won't compile.\n const importStmts = root.findAll({ rule: { kind: \"import_statement\" } });\n const hasBinding = importStmts.some((s) =>\n importBindingNames(s).has(exportName),\n );\n const importLine = `import { ${exportName} } from \"${importPath}\";`;\n const named = hasBinding ? null : namedImportsFrom(importStmts, importPath);\n if (named) {\n // Append after the last specifier, matching a multi-line list's layout.\n const specs = named.findAll({ rule: { kind: \"import_specifier\" } });\n const lastSpec = specs[specs.length - 1];\n if (!lastSpec) {\n edits.push(named.replace(`{ ${exportName} }`));\n } else {\n const startIdx = lastSpec.range().start.index;\n const lineStart = content.lastIndexOf(\"\\n\", startIdx - 1);\n const indent = content.slice(lineStart + 1, startIdx);\n const multiline = named.text().includes(\"\\n\") && /^[ \\t]*$/.test(indent);\n const sep = multiline ? `,\\n${indent}` : \", \";\n edits.push(lastSpec.replace(`${lastSpec.text()}${sep}${exportName}`));\n }\n } else if (!hasBinding && importStmts.length > 0) {\n const last = importStmts[importStmts.length - 1];\n edits.push(last.replace(`${last.text()}\\n${importLine}`));\n }\n\n let output = root.commitEdits(edits);\n if (!hasBinding && !named && importStmts.length === 0) {\n output = `${importLine}\\n${output}`;\n }\n return { status: \"wired\", output };\n}\n"],"mappings":";;;;;;;AAQA,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACD;AASD,SAAgB,eAAe,YAAmC;AAChE,MAAK,MAAM,aAAa,wBAAwB;EAC9C,MAAM,IAAI,KAAK,KAAK,YAAY,UAAU;AAC1C,MAAI,GAAG,WAAW,EAAE,CAAE,QAAO;;AAE/B,QAAO;;;AAIT,SAAS,iBAAiB,OAAiB,QAA+B;AACxE,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,KAAK,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,GAAG,GAAG;EAExD,MAAM,WAAW,KACd,UAAU,CACV,MAAM,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC,EAAE,SAAS,CAAC;AACnD,MAAI,WAAW,UAAU,SAAU;EACnC,MAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,EAAE,CAAC;AAC5D,MAAI,MAAO,QAAO;;AAEpB,QAAO;;;AAIT,SAAS,iBAAiB,MAA6B;AACrD,MAAK,MAAM,QAAQ,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,EAAE,CAAC,EAAE;AAE3D,MADY,KAAK,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,EAAE,CAAC,EACvD,MAAM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QAAQ,GAAG,KAAK,MAAM,CAAC,IAAI,aAAa,CAAC;;CAG3D,IAAI,SAAS,KAAK,YAAY,MAAM;AACpC,KAAI,CAAC,cAAc,CAAC,SAAS,YAAY,WAAW,EAClD,UAAS,GAAG,WAAW,IAAI;AAE7B,QAAO;EAAE,QAAQ;EAAS;EAAQ"}
@@ -404,5 +404,5 @@ function composeResourceId(resourceType, picks) {
404
404
  }
405
405
 
406
406
  //#endregion
407
- export { DEFAULT_PARENTS, composeResourceId, isFlatListable, isParentContext, listParentContextStep, listWorkspaceResources, parentContextDepth };
407
+ export { DEFAULT_PARENTS, composeResourceId, isFlatListable, isParentContext, listParentContextStep, listWorkspaceResources, makeWorkspaceClient, parentContextDepth };
408
408
  //# sourceMappingURL=workspace-picker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy-config.js","names":[],"sources":["../../src/cli/deploy-config.ts"],"sourcesContent":["/**\n * Single source for the `app.yaml` + `databricks.yml` app-resource binding\n * contract, so the registry writer (`config-writer.ts`) and the doctor reader\n * (`bundle.ts`/`checks-wiring.ts`) on opposite ends of it can't drift apart.\n */\n\n/** Canonical Databricks bundle config file name. */\nexport const DATABRICKS_YML_FILE = \"databricks.yml\";\n\n/** Canonical Databricks Apps runtime config file name. */\nexport const APP_YAML_FILE = \"app.yaml\";\n\n/** An `app.yaml` env entry: `- name: <env>`, `valueFrom: <binding name>`. */\nexport interface AppYamlEnvEntry {\n name: string;\n valueFrom: string;\n}\n\n/**\n * A `databricks.yml` app-resource binding under `resources.apps.<app>.resources[]`,\n * serialized as `{ name, <type>: { ...fields, permission? } }` (see {@link bindingToNode}).\n */\nexport interface ResourceBinding {\n /** Binding name — the `valueFrom` join key (equals the resourceKey). */\n name: string;\n /** Resource type key, e.g. `sql_warehouse` / `postgres`. */\n type: string;\n permission?: string;\n /** Binding fields, typically `${var.<variable>}` references. */\n fields: Record<string, string>;\n}\n\n/**\n * Encodes a binding into its `databricks.yml` node: the type is the single\n * non-`name` object key. Inverse of {@link bindingTypeOf}.\n */\nexport function bindingToNode(\n binding: ResourceBinding,\n): Record<string, unknown> {\n const inner: Record<string, unknown> = { ...binding.fields };\n if (binding.permission) inner.permission = binding.permission;\n return { name: binding.name, [binding.type]: inner };\n}\n\n/**\n * Reads the type back out of a `databricks.yml` binding node — the single\n * non-`name` object-valued property; undefined if absent. See {@link bindingToNode}.\n */\nexport function bindingTypeOf(\n block: Record<string, unknown>,\n): string | undefined {\n for (const [k, v] of Object.entries(block)) {\n if (k === \"name\") continue;\n if (v && typeof v === \"object\") return k;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAsB;;AAGnC,MAAa,gBAAgB;;;;;AA0B7B,SAAgB,cACd,SACyB;CACzB,MAAM,QAAiC,EAAE,GAAG,QAAQ,QAAQ;AAC5D,KAAI,QAAQ,WAAY,OAAM,aAAa,QAAQ;AACnD,QAAO;EAAE,MAAM,QAAQ;GAAO,QAAQ,OAAO;EAAO;;;;;;AAOtD,SAAgB,cACd,OACoB;AACpB,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,EAAE;AAC1C,MAAI,MAAM,OAAQ;AAClB,MAAI,KAAK,OAAO,MAAM,SAAU,QAAO"}
1
+ {"version":3,"file":"deploy-config.js","names":[],"sources":["../../src/cli/deploy-config.ts"],"sourcesContent":["/**\n * Single source for the `app.yaml` + `databricks.yml` app-resource binding\n * contract, so the registry writer (`config-writer.ts`) and the doctor reader\n * (`bundle.ts`/`checks-wiring.ts`) on opposite ends of it can't drift apart.\n */\n\n/** Canonical Databricks bundle config file name. */\nexport const DATABRICKS_YML_FILE = \"databricks.yml\";\n\n/** Canonical Databricks Apps runtime config file name. */\nexport const APP_YAML_FILE = \"app.yaml\";\n\n/** An `app.yaml` env entry: `valueFrom` a binding, or a literal `value` (OBO-only resources). */\nexport type AppYamlEnvEntry =\n | { name: string; valueFrom: string }\n | { name: string; value: string };\n\n/**\n * A `databricks.yml` app-resource binding under `resources.apps.<app>.resources[]`,\n * serialized as `{ name, <type>: { ...fields, permission? } }` (see {@link bindingToNode}).\n */\nexport interface ResourceBinding {\n /** Binding name — the `valueFrom` join key (equals the resourceKey). */\n name: string;\n /** Resource type key, e.g. `sql_warehouse` / `postgres`. */\n type: string;\n permission?: string;\n /** Binding fields, typically `${var.<variable>}` references. */\n fields: Record<string, string>;\n}\n\n/**\n * Encodes a binding into its `databricks.yml` node: the type is the single\n * non-`name` object key. Inverse of {@link bindingTypeOf}.\n */\nexport function bindingToNode(\n binding: ResourceBinding,\n): Record<string, unknown> {\n const inner: Record<string, unknown> = { ...binding.fields };\n if (binding.permission) inner.permission = binding.permission;\n return { name: binding.name, [binding.type]: inner };\n}\n\n/**\n * Reads the type back out of a `databricks.yml` binding node — the single\n * non-`name` object-valued property; undefined if absent. See {@link bindingToNode}.\n */\nexport function bindingTypeOf(\n block: Record<string, unknown>,\n): string | undefined {\n for (const [k, v] of Object.entries(block)) {\n if (k === \"name\") continue;\n if (v && typeof v === \"object\") return k;\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AAOA,MAAa,sBAAsB;;AAGnC,MAAa,gBAAgB;;;;;AAyB7B,SAAgB,cACd,SACyB;CACzB,MAAM,QAAiC,EAAE,GAAG,QAAQ,QAAQ;AAC5D,KAAI,QAAQ,WAAY,OAAM,aAAa,QAAQ;AACnD,QAAO;EAAE,MAAM,QAAQ;GAAO,QAAQ,OAAO;EAAO;;;;;;AAOtD,SAAgB,cACd,OACoB;AACpB,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,MAAM,EAAE;AAC1C,MAAI,MAAM,OAAQ;AAClB,MAAI,KAAK,OAAO,MAAM,SAAU,QAAO"}
package/dist/cli/index.js CHANGED
@@ -5,8 +5,8 @@ import { docsCommand } from "./commands/docs.js";
5
5
  import { doctorCommand } from "./commands/doctor/index.js";
6
6
  import { generateTypesCommand } from "./commands/generate-types.js";
7
7
  import { lintCommand } from "./commands/lint.js";
8
- import { pluginCommand } from "./commands/plugin/index.js";
9
8
  import { addCommand } from "./commands/registry/add.js";
9
+ import { pluginCommand } from "./commands/plugin/index.js";
10
10
  import { registryCommand } from "./commands/registry/index.js";
11
11
  import { setupCommand } from "./commands/setup.js";
12
12
  import "dotenv/config";
@@ -13,4 +13,6 @@ import { DatabaseRowShape, DatabaseShape, UseDatabaseReadOptions, UseDatabaseRea
13
13
  import { UseDatabaseListOptions, UseDatabaseListResult, useDatabaseList } from "./hooks/use-database-list.js";
14
14
  import { UseDatabaseRecordOptions, UseDatabaseRecordResult, useDatabaseRecord } from "./hooks/use-database-record.js";
15
15
  import { UseDatabaseUpdateOptions, UseDatabaseUpdateResult, useDatabaseUpdate } from "./hooks/use-database-update.js";
16
- export { type AiSearchClientConfig, type AiSearchIndexSummary, type AiSearchQueryType, type AiSearchRequest, type AiSearchResponse, type AiSearchResult, DatabaseApiError, type DatabaseApiErrorCode, type DatabaseEntity, type DatabaseErrorDetail, type DatabaseId, type DatabaseInsert, type DatabaseInvalidation, type DatabaseKeyedEntity, type DatabaseListPage, type DatabaseListParams, type DatabaseListRow, type DatabaseRecordParams, type DatabaseRecordRow, type DatabaseRow, type DatabaseRowShape, type DatabaseShape, type DatabaseUpdate, type UseAiSearchQueryOptions, type UseAiSearchQueryResult, type UseDatabaseCreateOptions, type UseDatabaseCreateResult, type UseDatabaseDeleteOptions, type UseDatabaseDeleteResult, type UseDatabaseListOptions, type UseDatabaseListResult, type UseDatabaseReadOptions, type UseDatabaseReadResult, type UseDatabaseRecordOptions, type UseDatabaseRecordResult, type UseDatabaseUpdateOptions, type UseDatabaseUpdateResult, type UseDatabaseWriteOptions, type UseDatabaseWriteState, invalidateDatabaseReads, serialized, useAiSearchQuery, useDatabaseCreate, useDatabaseDelete, useDatabaseList, useDatabaseRecord, useDatabaseUpdate };
16
+ import { useDesignReady } from "./hooks/use-design-ready.js";
17
+ import { DesignPage, DesignPageProps, DraftPlaceholder, DraftPlaceholderKind } from "./design-page.js";
18
+ export { type AiSearchClientConfig, type AiSearchIndexSummary, type AiSearchQueryType, type AiSearchRequest, type AiSearchResponse, type AiSearchResult, DatabaseApiError, type DatabaseApiErrorCode, type DatabaseEntity, type DatabaseErrorDetail, type DatabaseId, type DatabaseInsert, type DatabaseInvalidation, type DatabaseKeyedEntity, type DatabaseListPage, type DatabaseListParams, type DatabaseListRow, type DatabaseRecordParams, type DatabaseRecordRow, type DatabaseRow, type DatabaseRowShape, type DatabaseShape, type DatabaseUpdate, DesignPage, type DesignPageProps, DraftPlaceholder, type DraftPlaceholderKind, type UseAiSearchQueryOptions, type UseAiSearchQueryResult, type UseDatabaseCreateOptions, type UseDatabaseCreateResult, type UseDatabaseDeleteOptions, type UseDatabaseDeleteResult, type UseDatabaseListOptions, type UseDatabaseListResult, type UseDatabaseReadOptions, type UseDatabaseReadResult, type UseDatabaseRecordOptions, type UseDatabaseRecordResult, type UseDatabaseUpdateOptions, type UseDatabaseUpdateResult, type UseDatabaseWriteOptions, type UseDatabaseWriteState, invalidateDatabaseReads, serialized, useAiSearchQuery, useDatabaseCreate, useDatabaseDelete, useDatabaseList, useDatabaseRecord, useDatabaseUpdate, useDesignReady };
@@ -7,5 +7,7 @@ import { serialized } from "./hooks/use-database-read.js";
7
7
  import { useDatabaseList } from "./hooks/use-database-list.js";
8
8
  import { useDatabaseRecord } from "./hooks/use-database-record.js";
9
9
  import { useDatabaseUpdate } from "./hooks/use-database-update.js";
10
+ import { useDesignReady } from "./hooks/use-design-ready.js";
11
+ import { DesignPage, DraftPlaceholder } from "./design-page.js";
10
12
 
11
- export { DatabaseApiError, invalidateDatabaseReads, serialized, useAiSearchQuery, useDatabaseCreate, useDatabaseDelete, useDatabaseList, useDatabaseRecord, useDatabaseUpdate };
13
+ export { DatabaseApiError, DesignPage, DraftPlaceholder, invalidateDatabaseReads, serialized, useAiSearchQuery, useDatabaseCreate, useDatabaseDelete, useDatabaseList, useDatabaseRecord, useDatabaseUpdate, useDesignReady };
@@ -13,7 +13,7 @@ interface BaseChartProps {
13
13
  yKey?: string | string[];
14
14
  /** Chart orientation @default "vertical" */
15
15
  orientation?: Orientation;
16
- /** Chart height in pixels @default 300 */
16
+ /** Chart height in pixels. Defaults to filling its parent (see `chartSizeStyle`). */
17
17
  height?: number;
18
18
  /** Chart title */
19
19
  title?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":[],"sources":["../../../src/react/charts/base.tsx"],"mappings":";;;;UAkHiB,cAAA;;EAEf,IAAA,EAAM,SAAA;EAFS;EAIf,SAAA,EAAW,SAAA;;EAEX,IAAA;EAFW;EAIX,IAAA;EAee;EAbf,WAAA,GAAc,WAAA;EAmDG;EAjDjB,MAAA;EA6DqC;EA3DrC,KAAA;EAZA;EAcA,UAAA;EAZA;;;;;;EAmBA,YAAA,GAAe,iBAAA;EATf;EAWA,MAAA;EAFA;EAIA,UAAA;EAFA;EAIA,MAAA;EAAA;EAEA,OAAA;EAEA;EAAA,UAAA;EAIA;EAFA,QAAA;EAMA;EAJA,WAAA;EAQA;EANA,UAAA;EAoBA;EAlBA,aAAA;EAoBA;EAlBA,QAAA;EAoBA;EAlBA,GAAA;EA4BsB;EA1BtB,GAAA;EA4BA;;;AAWF;;;;;;;;EA3BE,OAAA,GAAU,MAAA;EAkCV;EAhCA,cAAA,GAAiB,mBAAA;EAkCjB;EAhCA,SAAA;EAkCA;;;;;;;;;EAxBA,WAAA,IAAe,KAAA,EAAO,eAAA;EAkCtB;EAhCA,QAAA;AAAA;;;;;iBAWc,SAAA,CAAA;EACd,IAAA;EACA,SAAA;EACA,IAAA;EACA,IAAA;EACA,WAAA;EACA,MAAA;EACA,KAAA;EACA,UAAA;EACA,YAAA;EACA,MAAA,EAAQ,YAAA;EACR,UAAA;EACA,MAAA;EACA,OAAA;EACA,UAAA;EACA,QAAA;EACA,WAAA;EACA,UAAA;EACA,aAAA;EACA,QAAA;EACA,GAAA;EACA,GAAA;EACA,OAAA,EAAS,aAAA;EACT,cAAA;EACA,SAAA;EACA,WAAA;EACA;A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