@noormdev/sdk 1.0.0-alpha.29 → 1.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1903,12 +1903,6 @@ declare class ChangeManager {
1903
1903
  * requireTest: true,
1904
1904
  * })
1905
1905
  *
1906
- * // Allow destructive ops on protected config
1907
- * const ctx = await createContext({
1908
- * config: 'staging',
1909
- * allowProtected: true,
1910
- * })
1911
- *
1912
1906
  * // Env-only mode (CI/CD) - no stored config needed
1913
1907
  * // Requires NOORM_CONNECTION_DIALECT and NOORM_CONNECTION_DATABASE
1914
1908
  * const ctx = await createContext()
@@ -1932,8 +1926,6 @@ export interface CreateContextOptions {
1932
1926
  projectRoot?: string;
1933
1927
  /** Refuse if config.isTest !== true. Default: false */
1934
1928
  requireTest?: boolean;
1935
- /** Allow destructive ops on protected configs. Default: false */
1936
- allowProtected?: boolean;
1937
1929
  /** Stage name for stage defaults (from settings.yml) */
1938
1930
  stage?: string;
1939
1931
  }
@@ -4350,8 +4342,8 @@ export declare class RequireTestError extends Error {
4350
4342
  *
4351
4343
  * @example
4352
4344
  * ```typescript
4353
- * // If config.protected is true and allowProtected is false
4354
- * await ctx.truncate() // Throws ProtectedConfigError
4345
+ * // config.protected is true — all destructive ops are blocked
4346
+ * await ctx.noorm.db.truncate() // Throws ProtectedConfigError
4355
4347
  * ```
4356
4348
  */
4357
4349
  export declare class ProtectedConfigError extends Error {
@@ -4385,12 +4377,6 @@ export declare class ProtectedConfigError extends Error {
4385
4377
  * requireTest: true,
4386
4378
  * })
4387
4379
  *
4388
- * // Allow destructive ops on protected config
4389
- * const ctx = await createContext({
4390
- * config: 'staging',
4391
- * allowProtected: true,
4392
- * })
4393
- *
4394
4380
  * // Env-only mode (CI/CD) - no stored config needed
4395
4381
  * // Requires NOORM_CONNECTION_DIALECT and NOORM_CONNECTION_DATABASE
4396
4382
  * const ctx = await createContext()
package/dist/index.js CHANGED
@@ -19957,6 +19957,33 @@ var ChangeManager = class {
19957
19957
  }
19958
19958
  };
19959
19959
 
19960
+ // src/sdk/guards.ts
19961
+ var RequireTestError = class extends Error {
19962
+ constructor(configName) {
19963
+ super(`Config "${configName}" does not have isTest: true`);
19964
+ this.configName = configName;
19965
+ }
19966
+ name = "RequireTestError";
19967
+ };
19968
+ var ProtectedConfigError = class extends Error {
19969
+ constructor(configName, operation) {
19970
+ super(`Cannot ${operation} on protected config "${configName}"`);
19971
+ this.configName = configName;
19972
+ this.operation = operation;
19973
+ }
19974
+ name = "ProtectedConfigError";
19975
+ };
19976
+ function checkRequireTest(config2, options) {
19977
+ if (options.requireTest && !config2.isTest) {
19978
+ throw new RequireTestError(config2.name);
19979
+ }
19980
+ }
19981
+ function checkProtectedConfig(config2, operation) {
19982
+ if (config2.protected) {
19983
+ throw new ProtectedConfigError(config2.name, operation);
19984
+ }
19985
+ }
19986
+
19960
19987
  // src/sdk/namespaces/changes.ts
19961
19988
  var ChangesNamespace = class {
19962
19989
  #state;
@@ -20098,6 +20125,7 @@ var ChangesNamespace = class {
20098
20125
  * ```
20099
20126
  */
20100
20127
  async revert(name, options) {
20128
+ checkProtectedConfig(this.#state.config, "changes.revert");
20101
20129
  return this.#getManager().revert(name, options);
20102
20130
  }
20103
20131
  /**
@@ -20188,6 +20216,7 @@ var ChangesNamespace = class {
20188
20216
  * ```
20189
20217
  */
20190
20218
  async rewind(target) {
20219
+ checkProtectedConfig(this.#state.config, "changes.revert");
20191
20220
  return this.#getManager().rewind(target);
20192
20221
  }
20193
20222
  /**
@@ -23677,33 +23706,6 @@ async function executePostScript(db, scriptPath) {
23677
23706
  return { executed: true };
23678
23707
  }
23679
23708
 
23680
- // src/sdk/guards.ts
23681
- var RequireTestError = class extends Error {
23682
- constructor(configName) {
23683
- super(`Config "${configName}" does not have isTest: true`);
23684
- this.configName = configName;
23685
- }
23686
- name = "RequireTestError";
23687
- };
23688
- var ProtectedConfigError = class extends Error {
23689
- constructor(configName, operation) {
23690
- super(`Cannot ${operation} on protected config "${configName}"`);
23691
- this.configName = configName;
23692
- this.operation = operation;
23693
- }
23694
- name = "ProtectedConfigError";
23695
- };
23696
- function checkRequireTest(config2, options) {
23697
- if (options.requireTest && !config2.isTest) {
23698
- throw new RequireTestError(config2.name);
23699
- }
23700
- }
23701
- function checkProtectedConfig(config2, operation, options) {
23702
- if (config2.protected && !options.allowProtected) {
23703
- throw new ProtectedConfigError(config2.name, operation);
23704
- }
23705
- }
23706
-
23707
23709
  // src/sdk/namespaces/db.ts
23708
23710
  var DbNamespace = class {
23709
23711
  #state;
@@ -23893,7 +23895,7 @@ var DbNamespace = class {
23893
23895
  * ```
23894
23896
  */
23895
23897
  async truncate(options) {
23896
- checkProtectedConfig(this.#state.config, "truncate", this.#state.options);
23898
+ checkProtectedConfig(this.#state.config, "truncate");
23897
23899
  const preserve = options?.preserve ?? this.#state.settings.teardown?.preserveTables;
23898
23900
  return truncateData(this.#kysely, this.#dialect, {
23899
23901
  ...options,
@@ -23909,7 +23911,7 @@ var DbNamespace = class {
23909
23911
  * ```
23910
23912
  */
23911
23913
  async teardown() {
23912
- checkProtectedConfig(this.#state.config, "teardown", this.#state.options);
23914
+ checkProtectedConfig(this.#state.config, "teardown");
23913
23915
  return teardownSchema(this.#kysely, this.#dialect, {
23914
23916
  configName: this.#state.config.name,
23915
23917
  executedBy: formatIdentity(this.#state.identity),
@@ -23926,7 +23928,7 @@ var DbNamespace = class {
23926
23928
  * ```
23927
23929
  */
23928
23930
  async reset() {
23929
- checkProtectedConfig(this.#state.config, "reset", this.#state.options);
23931
+ checkProtectedConfig(this.#state.config, "reset");
23930
23932
  await this.teardown();
23931
23933
  if (this.#buildFn) {
23932
23934
  await this.#buildFn({ force: true });
@@ -27407,6 +27409,7 @@ var DtNamespace = class {
27407
27409
  * ```
27408
27410
  */
27409
27411
  async importFile(filepath, options) {
27412
+ checkProtectedConfig(this.#state.config, "dt.import");
27410
27413
  return importDtFile({
27411
27414
  filepath,
27412
27415
  db: this.#kysely,