@topolo/cli 0.1.19 → 0.1.20

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 (2) hide show
  1. package/dist/index.js +94 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4189,18 +4189,32 @@ function scaffoldFiles(options) {
4189
4189
  }
4190
4190
  );
4191
4191
  if (options.api && application.serviceId) {
4192
- files.push({
4193
- path: `PlatformApplications/TopoloAuth/catalog/service-manifests/${application.serviceId}.json`,
4194
- purpose: "Auth service manifest for first-party permissions, role bundles, and API-key scopes.",
4195
- requiredSignals: [
4196
- "serviceId matches the generated Worker service id",
4197
- "permissions, role bundles, and API-key scopes exist before the app is catalog-visible",
4198
- "systems metadata maps the service back to the generated TopoloDocs entries"
4199
- ],
4200
- content: serviceManifestJson(application, {
4201
- tenancy: options.payload.tenancy
4202
- })
4203
- });
4192
+ files.push(
4193
+ {
4194
+ path: `PlatformApplications/TopoloAuth/catalog/service-manifests/${application.serviceId}.json`,
4195
+ purpose: "Auth service manifest for first-party permissions, role bundles, and API-key scopes.",
4196
+ requiredSignals: [
4197
+ "serviceId matches the generated Worker service id",
4198
+ "permissions, role bundles, and API-key scopes exist before the app is catalog-visible",
4199
+ "systems metadata maps the service back to the generated TopoloDocs entries"
4200
+ ],
4201
+ content: serviceManifestJson(application, {
4202
+ tenancy: options.payload.tenancy
4203
+ })
4204
+ },
4205
+ {
4206
+ path: `PlatformApplications/TopoloAuth/scripts/add-topolo-${slug}-service-production.sql`,
4207
+ purpose: "Auth service catalog registration for embedded first-party login, launcher visibility, and callback origins.",
4208
+ requiredSignals: [
4209
+ "services.id matches the generated Worker service id",
4210
+ "settings.launcher.category is first_party so embedded password login is allowed",
4211
+ "base_url and auth_domain define the production callback origin"
4212
+ ],
4213
+ content: serviceRegistrationSql(application, {
4214
+ tenancy: options.payload.tenancy
4215
+ })
4216
+ }
4217
+ );
4204
4218
  }
4205
4219
  } else {
4206
4220
  files.push(
@@ -5595,6 +5609,7 @@ function internalDocs(application, options) {
5595
5609
  ...options.api ? [`- \`PlatformApplications/${application.appDir}/src/worker.ts\``] : [],
5596
5610
  `- \`PlatformApplications/${application.appDir}/topolo.cloudcontrol.json\``,
5597
5611
  ...options.api && application.serviceId ? [`- \`PlatformApplications/TopoloAuth/catalog/service-manifests/${application.serviceId}.json\``] : [],
5612
+ ...options.api && application.serviceId ? [`- \`PlatformApplications/TopoloAuth/scripts/add-topolo-${slug}-service-production.sql\``] : [],
5598
5613
  "",
5599
5614
  "## API Reference",
5600
5615
  "",
@@ -5625,6 +5640,7 @@ function internalDocs(application, options) {
5625
5640
  "- run `topolo apps audit <app> --local --repo-root /Users/ashes/Projects/topolo --fail-on needs_review --json` after SDK catalog registration",
5626
5641
  "- inspect `topolo.cloudcontrol.json` before deployment changes",
5627
5642
  ...options.api && application.serviceId ? [`- inspect \`PlatformApplications/TopoloAuth/catalog/service-manifests/${application.serviceId}.json\` when permission grants fail`] : [],
5643
+ ...options.api && application.serviceId ? [`- inspect \`PlatformApplications/TopoloAuth/scripts/add-topolo-${slug}-service-production.sql\` when embedded app login fails`] : [],
5628
5644
  "",
5629
5645
  "## Change Log / Verification",
5630
5646
  "",
@@ -5768,6 +5784,62 @@ function serviceManifestJson(application, options) {
5768
5784
  })}
5769
5785
  `;
5770
5786
  }
5787
+ function serviceRegistrationSql(application, options) {
5788
+ const slug = toSlug(application.id);
5789
+ const title = toTitle(application.name);
5790
+ const serviceId = application.serviceId ?? application.id;
5791
+ const productionUrl = application.productionUrl ?? `https://${slug}.topolo.app`;
5792
+ const authDomain = hostnameFromUrl(productionUrl);
5793
+ const surface = options.tenancy === "household" ? "personal-workspace" : "workspace";
5794
+ const settings = JSON.stringify({
5795
+ app_slug: `topolo-${slug}`,
5796
+ surface,
5797
+ auth_domain: authDomain,
5798
+ launcher: {
5799
+ category: "first_party",
5800
+ app_id: slug
5801
+ }
5802
+ });
5803
+ return [
5804
+ `-- Register ${title} in the Topolo Auth service catalog.`,
5805
+ "-- Safe to rerun.",
5806
+ "",
5807
+ "INSERT INTO services (",
5808
+ " id,",
5809
+ " name,",
5810
+ " description,",
5811
+ " base_url,",
5812
+ " version,",
5813
+ " status,",
5814
+ " settings,",
5815
+ " created_at,",
5816
+ " updated_at,",
5817
+ " show_in_app_switcher",
5818
+ ")",
5819
+ "VALUES (",
5820
+ ` '${sqlString(serviceId)}',`,
5821
+ ` '${sqlString(title)}',`,
5822
+ ` 'First-party ${sqlString(title)} ${sqlString(surface)} application.',`,
5823
+ ` '${sqlString(productionUrl)}',`,
5824
+ " '1.0.0',",
5825
+ " 'active',",
5826
+ ` '${sqlString(settings)}',`,
5827
+ " strftime('%s', 'now'),",
5828
+ " strftime('%s', 'now'),",
5829
+ " 1",
5830
+ ")",
5831
+ "ON CONFLICT(id) DO UPDATE SET",
5832
+ " name = excluded.name,",
5833
+ " description = excluded.description,",
5834
+ " base_url = excluded.base_url,",
5835
+ " version = excluded.version,",
5836
+ " status = excluded.status,",
5837
+ " settings = excluded.settings,",
5838
+ " updated_at = strftime('%s', 'now'),",
5839
+ " show_in_app_switcher = excluded.show_in_app_switcher;",
5840
+ ""
5841
+ ].join("\n");
5842
+ }
5771
5843
  function developerManifest(application, options) {
5772
5844
  return `${json({
5773
5845
  schema: "https://topolo.app/schemas/topolo-app-manifest.v1.json",
@@ -5891,6 +5963,13 @@ function toTitle(value) {
5891
5963
  function json(value) {
5892
5964
  return JSON.stringify(value, null, 2);
5893
5965
  }
5966
+ function hostnameFromUrl(value) {
5967
+ try {
5968
+ return new URL(value).hostname;
5969
+ } catch {
5970
+ return value.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
5971
+ }
5972
+ }
5894
5973
  async function pathExists(path4) {
5895
5974
  try {
5896
5975
  await access(path4, constants.F_OK);
@@ -5913,6 +5992,9 @@ function escapeHtml(value) {
5913
5992
  function escapeSingleQuoted(value) {
5914
5993
  return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
5915
5994
  }
5995
+ function sqlString(value) {
5996
+ return value.replace(/'/g, "''");
5997
+ }
5916
5998
  function escapeDoubleQuoted(value) {
5917
5999
  return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
5918
6000
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topolo/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Command-line interface for Topolo developers, operators, and agents, with internal first-party scaffolding available under the topolo platform namespace.",
5
5
  "type": "module",
6
6
  "bin": {