@atscript/typescript 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -4725,6 +4725,7 @@ const BANNER = DYE_COLORS.cyan(`
4725
4725
  #####
4726
4726
 
4727
4727
  `);
4728
+ const PENDING_HEADING = "Schema synced — work skipped in safe mode is still pending; the schema hash was not stored.";
4728
4729
  const PLAN_HEADER = [
4729
4730
  "",
4730
4731
  DYE_COLORS.bold("╔══════════════════════════════════════╗"),
@@ -4740,6 +4741,20 @@ const PLAN_HEADER = [
4740
4741
  refused: plan.entries.some((e) => e.refused)
4741
4742
  };
4742
4743
  }
4744
+ /** Run-level aggregates over the per-entry SyncEntry getters. */ function resultFlags(result) {
4745
+ return {
4746
+ errored: result.entries.filter((e) => e.hasErrors).length,
4747
+ hashWithheld: result.entries.some((e) => e.pending)
4748
+ };
4749
+ }
4750
+ /**
4751
+ * `Schema sync failed for N entries`, optionally pointing `see above`, and — only when a
4752
+ * pending entry withheld it — that the schema hash was not stored.
4753
+ */ function failedMessage(result, seeAbove = false) {
4754
+ const { errored, hashWithheld } = resultFlags(result);
4755
+ const notes = [seeAbove && "see above", hashWithheld && "the schema hash was not stored"].filter(Boolean).join("; ");
4756
+ return `Schema sync failed for ${`${errored} ${errored === 1 ? "entry" : "entries"}`}${notes && ` — ${notes}`}.`;
4757
+ }
4743
4758
  var DbSyncPrinter = class {
4744
4759
  log(...args) {
4745
4760
  if (!this.muted) console.log(...args);
@@ -4760,9 +4775,13 @@ var DbSyncPrinter = class {
4760
4775
  this.printGrouped(plan.entries, "plan");
4761
4776
  this.log("");
4762
4777
  }
4763
- result(result) {
4778
+ /** An applied run: every entry, under a failed, safe-mode pending or success heading. */ result(result) {
4779
+ const { errored, hashWithheld } = resultFlags(result);
4780
+ const c = this.colors;
4764
4781
  this.log("");
4765
- this.log(`${this.colors.green(this.colors.bold("Schema synced successfully."))} Hash: ${result.schemaHash}`);
4782
+ if (errored > 0) this.log(c.red(c.bold(failedMessage(result))));
4783
+ else if (hashWithheld) this.log(c.yellow(c.bold(PENDING_HEADING)));
4784
+ else this.log(`${c.green(c.bold("Schema synced successfully."))} Hash: ${result.schemaHash}`);
4766
4785
  this.log("");
4767
4786
  this.printGrouped(result.entries, "result");
4768
4787
  this.log("");
@@ -4920,13 +4939,7 @@ var DbSyncController = class {
4920
4939
  }
4921
4940
  if (plan.status === "up-to-date") return;
4922
4941
  if (!hasChanges) {
4923
- if (!dryRun) {
4924
- const result = await this.runSync(sync, dbTypes, safe);
4925
- if (result.entries.some((e) => e.hasErrors)) {
4926
- this.printer.result(result);
4927
- this.failOnErrors(result);
4928
- }
4929
- }
4942
+ if (!dryRun) await this.runSync(sync, dbTypes, safe);
4930
4943
  return;
4931
4944
  }
4932
4945
  if (dryRun) {
@@ -4941,14 +4954,14 @@ var DbSyncController = class {
4941
4954
  }
4942
4955
  }
4943
4956
  } else this.logger.log(`No destructive changes, proceeding to sync...`);
4944
- const result = await this.runSync(sync, dbTypes, safe);
4945
- this.printer.result(result);
4946
- this.failOnErrors(result);
4957
+ this.printer.result(await this.runSync(sync, dbTypes, safe));
4947
4958
  }
4948
4959
  /**
4949
- * Applies the sync. A refused run (`status: 'refused'`) issued no DDL and
4950
- * left tracking untouched — its refusal entries are printed and the command
4951
- * exits 1 instead of reporting a successful sync.
4960
+ * Applies the sync and returns a successful result. A refused run (`status: 'refused'`)
4961
+ * issued no DDL and left tracking untouched — its refusal entries are printed and the
4962
+ * command exits 1. An applied run that left entries with errors (`status: 'failed'` since
4963
+ * @atscript/db 0.1.170; earlier versions report `'synced'`, hence the entry check) is
4964
+ * printed and the command exits 1.
4952
4965
  */ async runSync(sync, dbTypes, safe) {
4953
4966
  const result = await sync.run(dbTypes, {
4954
4967
  force: true,
@@ -4958,16 +4971,13 @@ var DbSyncController = class {
4958
4971
  this.printer.refused(result);
4959
4972
  this.fail("Schema sync refused — nothing was applied. Fix the issues above and re-run.");
4960
4973
  }
4974
+ if (resultFlags(result).errored > 0) {
4975
+ this.printer.result(result);
4976
+ this.fail(failedMessage(result, true));
4977
+ }
4961
4978
  return result;
4962
4979
  }
4963
4980
  /**
4964
- * An applied run that left entries with errors (`status: 'failed'` since
4965
- * @atscript/db 0.1.170) withheld the schema hash — exit 1 after printing.
4966
- */ failOnErrors(result) {
4967
- const errored = result.entries.filter((e) => e.hasErrors).length;
4968
- if (errored > 0) this.fail(`Schema sync failed for ${errored} ${errored === 1 ? "entry" : "entries"} — see above; the schema hash was not stored.`);
4969
- }
4970
- /**
4971
4981
  * Loads the full model inventory or aborts. Diagnostics run first, every
4972
4982
  * generated module is imported individually, and any failure exits 1 before
4973
4983
  * a plan is computed.
@@ -4087,7 +4087,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4087
4087
  const UPPERCASE = 4;
4088
4088
  /**
4089
4089
  * Whether each node's subtree has normalizers: valid until the next type tree write (metadata or
4090
- * shape) or `invalidateCompiledValidators()` (checked by {@link normalizeForType}).
4090
+ * shape) or `invalidateCompiledValidators()` (checked by {@link typeHasNormalizers}).
4091
4091
  */ let reach = /* @__PURE__ */ new WeakMap();
4092
4092
  let stampWrites = -1;
4093
4093
  function newJudges(opts) {
package/dist/utils.cjs CHANGED
@@ -92,7 +92,7 @@ const LOWERCASE = 2;
92
92
  const UPPERCASE = 4;
93
93
  /**
94
94
  * Whether each node's subtree has normalizers: valid until the next type tree write (metadata or
95
- * shape) or `invalidateCompiledValidators()` (checked by {@link normalizeForType}).
95
+ * shape) or `invalidateCompiledValidators()` (checked by {@link typeHasNormalizers}).
96
96
  */ let reach = /* @__PURE__ */ new WeakMap();
97
97
  let stampWrites = -1;
98
98
  function newJudges(opts) {
package/dist/utils.mjs CHANGED
@@ -91,7 +91,7 @@ const LOWERCASE = 2;
91
91
  const UPPERCASE = 4;
92
92
  /**
93
93
  * Whether each node's subtree has normalizers: valid until the next type tree write (metadata or
94
- * shape) or `invalidateCompiledValidators()` (checked by {@link normalizeForType}).
94
+ * shape) or `invalidateCompiledValidators()` (checked by {@link typeHasNormalizers}).
95
95
  */ let reach = /* @__PURE__ */ new WeakMap();
96
96
  let stampWrites = -1;
97
97
  function newJudges(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/typescript",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "Atscript: typescript-gen support.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -67,14 +67,14 @@
67
67
  "moost": "^0.7.3"
68
68
  },
69
69
  "devDependencies": {
70
- "@atscript/db": "^0.1.167",
71
- "@uniqu/core": "^0.1.15",
70
+ "@atscript/db": "^0.1.170",
71
+ "@uniqu/core": "^0.2.1",
72
72
  "ajv": "8.20.0",
73
73
  "vitest": "4.1.12"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@atscript/db": "^0.1.159",
77
- "@atscript/core": "^0.2.7"
77
+ "@atscript/core": "^0.2.8"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@atscript/db": {