atmn 1.1.18 → 1.1.19

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/cli.js +301 -97
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -47088,11 +47088,22 @@ var init_apiToSdk = __esm(() => {
47088
47088
 
47089
47089
  // src/lib/transforms/inPlaceUpdate/parseConfig.ts
47090
47090
  import { readFileSync as readFileSync3 } from "node:fs";
47091
- function extractId(lines) {
47091
+ function extractIdentity({
47092
+ identitiesByTypeAndVarName,
47093
+ lines,
47094
+ type,
47095
+ varName
47096
+ }) {
47092
47097
  const joined = lines.join(`
47093
47098
  `);
47094
- const match = joined.match(/id:\s*['"]([^'"]+)['"]/);
47095
- return match ? match[1] ?? null : null;
47099
+ const mapped = type && varName ? identitiesByTypeAndVarName?.get(type)?.get(varName) : undefined;
47100
+ const id = joined.match(/id:\s*['"]([^'"]+)['"]/)?.[1];
47101
+ if (!id)
47102
+ return mapped ?? null;
47103
+ if (mapped?.id === id)
47104
+ return mapped;
47105
+ const version = joined.match(/id:\s*['"][^'"]+['"]\s*,?\s*version:\s*(\d+)/)?.[1];
47106
+ return { id, version: version === undefined ? undefined : Number(version) };
47096
47107
  }
47097
47108
  function extractVarName(line) {
47098
47109
  const match = line.match(/export\s+const\s+(\w+)\s*=/);
@@ -47122,7 +47133,10 @@ function determineEntityType(lines) {
47122
47133
  }
47123
47134
  return null;
47124
47135
  }
47125
- function parseExistingConfig(configPath) {
47136
+ function parseExistingConfig({
47137
+ configPath,
47138
+ identitiesByTypeAndVarName
47139
+ }) {
47126
47140
  const source = readFileSync3(configPath, "utf-8");
47127
47141
  const lines = source.split(`
47128
47142
  `);
@@ -47198,11 +47212,23 @@ function parseExistingConfig(configPath) {
47198
47212
  }
47199
47213
  const endLine = i;
47200
47214
  const blockLines = lines.slice(startLine, endLine + 1);
47201
- const id = extractId(blockLines);
47202
47215
  const entityType = determineEntityType(blockLines);
47203
- if (id && entityType && varName) {
47216
+ const blockSource = blockLines.join(`
47217
+ `);
47218
+ const declaration = entityType && varName && isResourceExpression(blockSource) ? {
47219
+ requiresRuntimeIdentity: !/id:\s*['"][^'"]+['"]/.test(blockSource),
47220
+ type: entityType,
47221
+ varName
47222
+ } : undefined;
47223
+ const identity2 = extractIdentity({
47224
+ identitiesByTypeAndVarName,
47225
+ lines: blockLines,
47226
+ type: entityType,
47227
+ varName
47228
+ });
47229
+ if (identity2 && entityType && varName) {
47204
47230
  const entity = {
47205
- id,
47231
+ ...identity2,
47206
47232
  type: entityType,
47207
47233
  varName,
47208
47234
  startLine,
@@ -47214,6 +47240,7 @@ function parseExistingConfig(configPath) {
47214
47240
  startLine,
47215
47241
  endLine,
47216
47242
  lines: blockLines,
47243
+ declaration,
47217
47244
  entity
47218
47245
  });
47219
47246
  entities.push(entity);
@@ -47222,7 +47249,8 @@ function parseExistingConfig(configPath) {
47222
47249
  type: "other",
47223
47250
  startLine,
47224
47251
  endLine,
47225
- lines: blockLines
47252
+ lines: blockLines,
47253
+ declaration
47226
47254
  });
47227
47255
  }
47228
47256
  i++;
@@ -47243,6 +47271,7 @@ function parseExistingConfig(configPath) {
47243
47271
  source
47244
47272
  };
47245
47273
  }
47274
+ var isResourceExpression = (source) => /=\s*(?:feature|plan|referralProgram|reward)\s*\(/.test(source) || /=\s*\w+\.variant\s*\(/.test(source);
47246
47275
  var init_parseConfig = () => {};
47247
47276
 
47248
47277
  // src/lib/config/loadConfig.ts
@@ -47250,7 +47279,7 @@ import { existsSync as existsSync4 } from "node:fs";
47250
47279
  import { resolve as resolve3 } from "node:path";
47251
47280
  import { pathToFileURL } from "node:url";
47252
47281
  import createJiti from "jiti";
47253
- var DEFAULT_REWARD_EXPORT_ERROR = "Rewards and referral programs must be named reward() and referralProgram() exports; move them out of the default export before pulling or pushing.", importConfig = async ({
47282
+ var DEFAULT_REWARD_EXPORT_ERROR = "Rewards and referral programs must be named reward() and referralProgram() exports; move them out of the default export before pulling or pushing.", loadConfigModule = async ({
47254
47283
  cwd: cwd2
47255
47284
  }) => {
47256
47285
  const configPath = resolveConfigPath(cwd2);
@@ -47260,7 +47289,7 @@ var DEFAULT_REWARD_EXPORT_ERROR = "Rewards and referral programs must be named r
47260
47289
  }, loadConfig = async ({
47261
47290
  cwd: cwd2 = process.cwd()
47262
47291
  } = {}) => {
47263
- const mod = await importConfig({ cwd: cwd2 });
47292
+ const mod = await loadConfigModule({ cwd: cwd2 });
47264
47293
  const config = {
47265
47294
  features: [],
47266
47295
  plans: [],
@@ -47410,7 +47439,10 @@ function formatValue(value) {
47410
47439
  }
47411
47440
  return String(value);
47412
47441
  }
47413
- var upperFirst2 = (value) => value.charAt(0).toUpperCase() + value.slice(1), allocateVarNames = ({
47442
+ var upperFirst2 = (value) => value.charAt(0).toUpperCase() + value.slice(1), versionedCodegenId = ({
47443
+ id,
47444
+ version
47445
+ }) => version === undefined ? id : `${id}-v-${version}`, allocateVarNames = ({
47414
47446
  ids,
47415
47447
  candidate,
47416
47448
  suffix,
@@ -47779,7 +47811,7 @@ function generatePlanWithVariantsCode({
47779
47811
  variant,
47780
47812
  features,
47781
47813
  featureVarMap,
47782
- varNameOverride: variantVarMap.get(variant.id)
47814
+ varNameOverride: variantVarMap.get(versionedCodegenId(variant))
47783
47815
  }));
47784
47816
  return [basePlanCode, ...variantCodes].join(`
47785
47817
 
@@ -47796,10 +47828,31 @@ async function updateConfigInPlace({
47796
47828
  if (!existsSync5(configPath)) {
47797
47829
  throw new Error(`Config file not found: ${configPath}`);
47798
47830
  }
47799
- const parsed = parseExistingConfig(configPath);
47831
+ let parsed = parseExistingConfig({ configPath });
47800
47832
  const hasDefaultResources = /\bexport\s+default\b/.test(parsed.source) && /\b(?:rewards|referralPrograms)\b/.test(parsed.source);
47801
47833
  if (hasDefaultResources)
47802
47834
  throw new Error(DEFAULT_REWARD_EXPORT_ERROR);
47835
+ const versionedIdsByType = new Map([
47836
+ ["plan", versionedIds(plans)],
47837
+ ["variant", versionedIds(plans.flatMap((plan) => plan.variants ?? []))]
47838
+ ]);
47839
+ const runtimeDeclarations = parsed.blocks.flatMap(({ declaration, entity }) => declaration && (declaration.requiresRuntimeIdentity || entity && versionedIdsByType.get(entity.type)?.has(entity.id)) ? [declaration] : []);
47840
+ if (runtimeDeclarations.length) {
47841
+ const mod = await loadConfigModule({ cwd: cwd2 });
47842
+ const identitiesByTypeAndVarName = new Map;
47843
+ for (const declaration of runtimeDeclarations) {
47844
+ const value = mod[declaration.varName];
47845
+ if (typeof value?.id !== "string")
47846
+ throw new Error(`Could not resolve the ID of export '${declaration.varName}'.`);
47847
+ const identities = identitiesByTypeAndVarName.get(declaration.type) ?? new Map;
47848
+ identities.set(declaration.varName, {
47849
+ id: value.id,
47850
+ version: typeof value.version === "number" ? value.version : undefined
47851
+ });
47852
+ identitiesByTypeAndVarName.set(declaration.type, identities);
47853
+ }
47854
+ parsed = parseExistingConfig({ configPath, identitiesByTypeAndVarName });
47855
+ }
47803
47856
  const requiredImports = [
47804
47857
  ...plans.some((plan) => plan.billingControls) ? ["billingControls"] : [],
47805
47858
  ...rewards?.length ? ["reward"] : [],
@@ -47814,17 +47867,17 @@ async function updateConfigInPlace({
47814
47867
  plansDeleted: 0
47815
47868
  };
47816
47869
  const apiFeatureMap = new Map(features.map((f) => [f.id, f]));
47817
- const apiPlanMap = new Map(plans.map((p) => [p.id, p]));
47870
+ const apiPlanMap = new Map(plans.map((p) => [versionedCodegenId(p), p]));
47818
47871
  const apiRewardMap = new Map((rewards ?? []).map((reward) => [reward.id, reward]));
47819
47872
  const apiReferralProgramMap = new Map((referralPrograms ?? []).map((program2) => [program2.id, program2]));
47820
- const apiVariantMap = new Map(plans.flatMap((plan) => (plan.variants ?? []).map((variant) => [variant.id, variant])));
47873
+ const apiVariantMap = new Map(plans.flatMap((plan) => (plan.variants ?? []).map((variant) => [versionedCodegenId(variant), variant])));
47821
47874
  const featureVarMap = new Map;
47822
47875
  const existingVariantVarMap = new Map;
47823
47876
  for (const entity of parsed.entities) {
47824
47877
  if (entity.type === "feature") {
47825
47878
  featureVarMap.set(entity.id, entity.varName);
47826
47879
  } else if (entity.type === "variant") {
47827
- existingVariantVarMap.set(entity.id, entity.varName);
47880
+ existingVariantVarMap.set(versionedCodegenId(entity), entity.varName);
47828
47881
  }
47829
47882
  }
47830
47883
  const existingVarNames = new Set([...parsed.source.matchAll(/export\s+const\s+([\w$]+)\s*=/g)].flatMap(([, varName]) => varName ? [varName] : []));
@@ -47839,8 +47892,8 @@ async function updateConfigInPlace({
47839
47892
  newFeatureVarMap.set(id, varName);
47840
47893
  featureVarMap.set(id, varName);
47841
47894
  }
47842
- const existingPlanIds = new Set(parsed.entities.filter((e) => e.type === "plan").map((e) => e.id));
47843
- const newPlanIds = plans.filter((p) => !existingPlanIds.has(p.id)).map((p) => p.id);
47895
+ const existingPlanIds = new Set(parsed.entities.filter((e) => e.type === "plan").map(versionedCodegenId));
47896
+ const newPlanIds = plans.filter((p) => !existingPlanIds.has(versionedCodegenId(p))).map(versionedCodegenId);
47844
47897
  const newPlanVarMap = new Map;
47845
47898
  for (const id of newPlanIds) {
47846
47899
  const varName = claimVarName({
@@ -47851,17 +47904,17 @@ async function updateConfigInPlace({
47851
47904
  newPlanVarMap.set(id, varName);
47852
47905
  }
47853
47906
  const variantVarMap = new Map;
47854
- for (const id of apiVariantMap.keys()) {
47855
- if (existingVariantVarMap.has(id)) {
47856
- variantVarMap.set(id, existingVariantVarMap.get(id));
47907
+ for (const key of apiVariantMap.keys()) {
47908
+ if (existingVariantVarMap.has(key)) {
47909
+ variantVarMap.set(key, existingVariantVarMap.get(key));
47857
47910
  continue;
47858
47911
  }
47859
47912
  const varName = claimVarName({
47860
- candidate: variantIdToVarName(id),
47913
+ candidate: variantIdToVarName(key),
47861
47914
  suffix: "Variant",
47862
47915
  usedNames: existingVarNames
47863
47916
  });
47864
- variantVarMap.set(id, varName);
47917
+ variantVarMap.set(key, varName);
47865
47918
  }
47866
47919
  const newRewardVarMap = new Map;
47867
47920
  for (const { id } of rewards ?? []) {
@@ -47941,7 +47994,8 @@ async function updateConfigInPlace({
47941
47994
  result2.featuresDeleted++;
47942
47995
  }
47943
47996
  } else if (entity.type === "plan") {
47944
- const apiPlan = apiPlanMap.get(entity.id);
47997
+ const planKey2 = versionedCodegenId(entity);
47998
+ const apiPlan = apiPlanMap.get(planKey2);
47945
47999
  if (apiPlan) {
47946
48000
  const newCode = generatePlanWithVariantsCode({
47947
48001
  featureVarMap,
@@ -47951,14 +48005,14 @@ async function updateConfigInPlace({
47951
48005
  variantVarMap
47952
48006
  });
47953
48007
  outputBlocks.push(newCode);
47954
- matchedPlanIds.add(entity.id);
48008
+ matchedPlanIds.add(planKey2);
47955
48009
  lastPlanBlockIndex = outputBlocks.length - 1;
47956
48010
  result2.plansUpdated++;
47957
48011
  } else {
47958
48012
  result2.plansDeleted++;
47959
48013
  }
47960
48014
  } else if (entity.type === "variant") {
47961
- if (!apiVariantMap.has(entity.id)) {
48015
+ if (!apiVariantMap.has(versionedCodegenId(entity))) {
47962
48016
  result2.plansDeleted++;
47963
48017
  }
47964
48018
  } else if (entity.type === "reward") {
@@ -48053,13 +48107,13 @@ ${newFeatureCode}`);
48053
48107
  }
48054
48108
  result2.featuresAdded = newFeatures.length;
48055
48109
  }
48056
- const newPlans = plans.filter((p) => !matchedPlanIds.has(p.id));
48110
+ const newPlans = plans.filter((p) => !matchedPlanIds.has(versionedCodegenId(p)));
48057
48111
  if (newPlans.length > 0) {
48058
48112
  const newPlanCode = newPlans.map((p) => generatePlanWithVariantsCode({
48059
48113
  featureVarMap,
48060
48114
  features,
48061
48115
  plan: p,
48062
- planVarName: newPlanVarMap.get(p.id),
48116
+ planVarName: newPlanVarMap.get(versionedCodegenId(p)),
48063
48117
  variantVarMap
48064
48118
  })).join(`
48065
48119
 
@@ -48119,7 +48173,7 @@ ${newReferralPrograms.map((program2) => buildReferralProgramCode(program2, newRe
48119
48173
  writeFileSync2(configPath, output, "utf-8");
48120
48174
  return result2;
48121
48175
  }
48122
- var ensureAtmnImports = (importText, imports) => imports.reduce((text, name) => new RegExp(`\\b${name}\\b`).test(text) ? text : text.replace(/\{/, `{ ${name},`), importText);
48176
+ var ensureAtmnImports = (importText, imports) => imports.reduce((text, name) => new RegExp(`\\b${name}\\b`).test(text) ? text : text.replace(/\{/, `{ ${name},`), importText), versionedIds = (resources) => new Set(resources.flatMap(({ id, version }) => version === undefined ? [] : [id]));
48123
48177
  var init_updateConfig = __esm(() => {
48124
48178
  init_loadConfig();
48125
48179
  init_env();
@@ -48193,10 +48247,6 @@ function buildConfigFile(features, plans, rewards = [], referralPrograms = []) {
48193
48247
  return sections.join(`
48194
48248
  `);
48195
48249
  }
48196
- var versionedCodegenId = ({
48197
- id,
48198
- version
48199
- }) => version === undefined ? id : `${id}-v-${version}`;
48200
48250
  var init_configFile = __esm(() => {
48201
48251
  init_feature2();
48202
48252
  init_plan2();
@@ -48433,7 +48483,7 @@ var init_pull = __esm(() => {
48433
48483
  });
48434
48484
 
48435
48485
  // src/lib/version.ts
48436
- var APP_VERSION = "1.1.18";
48486
+ var APP_VERSION = "1.1.19";
48437
48487
 
48438
48488
  // ../../node_modules/.bun/@tanstack+query-core@5.101.1/node_modules/@tanstack/query-core/build/modern/subscribable.js
48439
48489
  var Subscribable = class {
@@ -92314,17 +92364,13 @@ var init_cusEntTable = __esm(() => {
92314
92364
  name: "customer_entitlements_entitlement_id_fkey"
92315
92365
  }).onUpdate("cascade").onDelete("cascade"),
92316
92366
  index("idx_customer_entitlements_product_id").on(table3.customer_product_id),
92317
- index("idx_customer_entitlements_internal_customer_id").using("hash", table3.internal_customer_id),
92318
92367
  index("idx_customer_entitlements_internal_customer_id_btree").on(table3.internal_customer_id),
92319
92368
  index("idx_customer_entitlements_entitlement_id").on(table3.entitlement_id),
92320
92369
  index("idx_customer_entitlements_internal_feature_id_c").on(sql`${table3.internal_feature_id} COLLATE "C"`).concurrently(),
92321
92370
  index("idx_ce_internal_feature_id").on(table3.internal_feature_id).concurrently(),
92322
92371
  index("idx_ce_customer_product_id_c").on(sql`${table3.customer_product_id} COLLATE "C"`).concurrently(),
92323
- index("idx_ce_loose_next_reset").on(table3.next_reset_at).where(sql`${table3.customer_product_id} IS NULL`).concurrently(),
92324
- index("idx_customer_entitlements_nonnull_entity_by_id").on(table3.id).where(sql`${table3.internal_entity_id} IS NOT NULL`).concurrently(),
92325
92372
  index("idx_customer_entitlements_internal_entity_id").using("hash", table3.internal_entity_id),
92326
92373
  index("idx_customer_entitlements_on_next_reset_at").on(table3.next_reset_at),
92327
- index("idx_customer_entitlements_separate_interval_reset").on(table3.next_reset_at, table3.id).where(sql`${table3.separate_interval} = true AND ${table3.next_reset_at} IS NOT NULL`).concurrently(),
92328
92374
  index("idx_customer_entitlements_loose_customer_expires").on(table3.internal_customer_id, table3.expires_at).where(sql`${table3.customer_product_id} IS NULL`),
92329
92375
  index("idx_customer_entitlements_next_reset_not_expired").on(table3.next_reset_at).where(sql`${table3.expired} IS NOT TRUE AND ${table3.next_reset_at} IS NOT NULL`).concurrently(),
92330
92376
  index("idx_customer_entitlements_pooled_contribution").on(table3.pooled_contribution_id).where(sql`${table3.pooled_contribution_id} IS NOT NULL`).concurrently(),
@@ -116319,16 +116365,64 @@ var init_V0_2_CusProductChange = __esm(() => {
116319
116365
  init_utils11();
116320
116366
  });
116321
116367
 
116368
+ // ../../shared/models/orgModels/orgConfig.ts
116369
+ var InvoicePaymentMethodSchema, OrgConfigSchema;
116370
+ var init_orgConfig = __esm(() => {
116371
+ init_v4();
116372
+ init_usageAlert();
116373
+ InvoicePaymentMethodSchema = exports_external.enum([
116374
+ "card",
116375
+ "customer_balance",
116376
+ "us_bank_account",
116377
+ "sepa_debit",
116378
+ "bacs_debit",
116379
+ "acss_debit",
116380
+ "link"
116381
+ ]);
116382
+ OrgConfigSchema = exports_external.object({
116383
+ usage_alerts: exports_external.array(DbUsageAlertSchema).optional().default([]),
116384
+ sandbox_usage_alerts: exports_external.array(DbUsageAlertSchema).optional().default([]),
116385
+ bill_upgrade_immediately: exports_external.boolean().default(true),
116386
+ convert_to_charge_automatically: exports_external.boolean().default(true),
116387
+ anchor_start_of_month: exports_external.boolean().default(false),
116388
+ cancel_on_past_due: exports_external.boolean().default(false),
116389
+ prorate_unused: exports_external.boolean().default(true),
116390
+ checkout_on_failed_payment: exports_external.boolean().default(true),
116391
+ reverse_deduction_order: exports_external.boolean().default(false),
116392
+ include_past_due: exports_external.boolean().default(true),
116393
+ sync_status: exports_external.boolean().default(true),
116394
+ merge_billing_cycles: exports_external.boolean().default(true),
116395
+ multiple_trials: exports_external.boolean().default(false),
116396
+ allow_paid_default: exports_external.boolean().default(false),
116397
+ cache_customer: exports_external.boolean().default(false),
116398
+ invoice_memos: exports_external.boolean().default(false),
116399
+ entity_product: exports_external.boolean().default(false),
116400
+ void_invoices_on_subscription_deletion: exports_external.boolean().default(false),
116401
+ default_applies_to_entities: exports_external.boolean().default(false),
116402
+ disable_overage_billing: exports_external.boolean().default(false),
116403
+ disable_stripe_writes: exports_external.boolean().default(false),
116404
+ disabled_auto_topup: exports_external.boolean().default(false),
116405
+ persist_free_overage: exports_external.boolean().default(false),
116406
+ dryrun_autotopups: exports_external.boolean().default(false),
116407
+ forward_customer_metadata: exports_external.boolean().default(false),
116408
+ automatic_tax: exports_external.boolean().default(false),
116409
+ multi_currency: exports_external.boolean().default(false),
116410
+ allowed_payment_methods: exports_external.array(InvoicePaymentMethodSchema).min(1).nullish()
116411
+ });
116412
+ });
116413
+
116322
116414
  // ../../shared/models/billingModels/context/billingContext.ts
116323
116415
  var InvoiceModeSchema, BillingVersion;
116324
116416
  var init_billingContext = __esm(() => {
116417
+ init_orgConfig();
116325
116418
  init_v4();
116326
116419
  InvoiceModeSchema = exports_external.object({
116327
116420
  finalizeInvoice: exports_external.boolean().default(false),
116328
116421
  enableProductImmediately: exports_external.boolean().default(true),
116329
116422
  footer: exports_external.string().optional(),
116330
116423
  memo: exports_external.string().optional(),
116331
- daysUntilDue: exports_external.number().optional()
116424
+ daysUntilDue: exports_external.number().optional(),
116425
+ paymentMethodTypes: exports_external.array(InvoicePaymentMethodSchema).optional()
116332
116426
  });
116333
116427
  ((BillingVersion2) => {
116334
116428
  BillingVersion2["V1"] = "v1";
@@ -120990,7 +121084,8 @@ var init_attachParamsV0 = __esm(() => {
120990
121084
  carry_over_usages: exports_external.object({
120991
121085
  enabled: exports_external.boolean(),
120992
121086
  feature_ids: exports_external.array(exports_external.string()).optional()
120993
- }).optional()
121087
+ }).optional(),
121088
+ remove_plan_ids: exports_external.array(exports_external.string()).optional()
120994
121089
  });
120995
121090
  });
120996
121091
 
@@ -121140,6 +121235,9 @@ var init_attachParamsV1 = __esm(() => {
121140
121235
  }),
121141
121236
  currency: CurrencyCodeSchema.optional().meta({
121142
121237
  description: "Currency to bill this attach in (e.g. usd, eur). Must match the customer's currency if they are already locked to one, and the plan must offer a paid price in it. Defaults to the customer's currency, then the org default."
121238
+ }),
121239
+ remove_plan_ids: exports_external.array(exports_external.string()).optional().meta({
121240
+ description: "Plan IDs to expire on the customer as part of this attach. Each must be an active plan billed on the same subscription as the attach (or a free plan); plans on a separate subscription are rejected."
121143
121241
  })
121144
121242
  });
121145
121243
  });
@@ -122148,6 +122246,11 @@ var init_customerProductsToStripeSubscriptionIds = __esm(() => {
122148
122246
  init_shared2();
122149
122247
  });
122150
122248
 
122249
+ // ../../shared/utils/cusProductUtils/convertCusProduct/customerProductToApiSubscriptionStatus.ts
122250
+ var init_customerProductToApiSubscriptionStatus = __esm(() => {
122251
+ init_cusProductEnums();
122252
+ });
122253
+
122151
122254
  // ../../shared/utils/cusProductUtils/convertCusProduct/customerProductToReplacementKey.ts
122152
122255
  var init_customerProductToReplacementKey = __esm(() => {
122153
122256
  init_classifyProductUtils();
@@ -122618,6 +122721,7 @@ var init_cusProductUtils2 = __esm(() => {
122618
122721
  init_cusProductToConvertedFeatureOptions();
122619
122722
  init_customerProductsToRecurringActiveAndScheduled();
122620
122723
  init_customerProductsToStripeSubscriptionIds();
122724
+ init_customerProductToApiSubscriptionStatus();
122621
122725
  init_customerProductToEffectivePrices();
122622
122726
  init_customerProductToReplacementKey();
122623
122727
  init_cusProductConstants();
@@ -122858,7 +122962,6 @@ var init_classifyItemUtils = __esm(() => {
122858
122962
  init_productItemModels();
122859
122963
  init_convertItemUtils();
122860
122964
  });
122861
-
122862
122965
  // ../../shared/utils/productV2Utils/productItemUtils/sortPlanItems.ts
122863
122966
  var init_sortPlanItems = __esm(() => {
122864
122967
  init_productItemModels();
@@ -123356,6 +123459,98 @@ var init_planParamsV1ToProductV2 = __esm(() => {
123356
123459
  init_planParamsV1ToProductItems();
123357
123460
  });
123358
123461
 
123462
+ // ../../shared/api/products/components/planChange/planItemChangeV0.ts
123463
+ var PlanItemChangeV0Schema;
123464
+ var init_planItemChangeV0 = __esm(() => {
123465
+ init_v4();
123466
+ init_apiPlanItemV1();
123467
+ PlanItemChangeV0Schema = exports_external.object({
123468
+ action: exports_external.enum(["created", "deleted"]).meta({
123469
+ description: "Whether the item was added to or removed from the plan."
123470
+ }),
123471
+ feature_id: exports_external.string().meta({
123472
+ description: "The ID of the feature that was added or removed."
123473
+ }),
123474
+ item: ApiPlanItemV1Schema.meta({
123475
+ description: "The plan item snapshot that was added or removed."
123476
+ })
123477
+ });
123478
+ });
123479
+
123480
+ // ../../shared/api/products/components/planChange/planPreviousAttributesV0.ts
123481
+ var PlanPreviousAttributesV0Schema;
123482
+ var init_planPreviousAttributesV0 = __esm(() => {
123483
+ init_customerBillingControls();
123484
+ init_apiPlanV1();
123485
+ init_apiFreeTrialV2();
123486
+ PlanPreviousAttributesV0Schema = ApiPlanV1Schema.pick({
123487
+ id: true,
123488
+ name: true,
123489
+ description: true,
123490
+ group: true,
123491
+ add_on: true,
123492
+ auto_enable: true,
123493
+ config: true
123494
+ }).partial().extend({
123495
+ free_trial: ApiFreeTrialV2Schema.nullable().optional().meta({
123496
+ description: "Previous free trial when it changed. Null when the plan had none."
123497
+ }),
123498
+ billing_controls: CustomerBillingControlsSchema.nullable().optional().meta({
123499
+ description: "Previous billing controls when they changed. Null when unset."
123500
+ })
123501
+ });
123502
+ });
123503
+
123504
+ // ../../shared/api/products/components/planChange/planChangeV0.ts
123505
+ var PlanPriceChangeV0Schema, PlanFreeTrialChangeV0Schema, PlanChangeV0Schema;
123506
+ var init_planChangeV0 = __esm(() => {
123507
+ init_v4();
123508
+ init_apiPlanV1();
123509
+ init_apiFreeTrialV2();
123510
+ init_planItemChangeV0();
123511
+ init_planPreviousAttributesV0();
123512
+ PlanPriceChangeV0Schema = exports_external.object({
123513
+ previous: ApiPlanV1Schema.shape.price.meta({
123514
+ description: "The plan's price before the change."
123515
+ }),
123516
+ current: ApiPlanV1Schema.shape.price.meta({
123517
+ description: "The plan's price after the change."
123518
+ })
123519
+ });
123520
+ PlanFreeTrialChangeV0Schema = exports_external.object({
123521
+ previous: ApiFreeTrialV2Schema.nullable().meta({
123522
+ description: "The plan's free trial before the change. Null when none."
123523
+ }),
123524
+ current: ApiFreeTrialV2Schema.nullable().meta({
123525
+ description: "The plan's free trial after the change. Null when none."
123526
+ })
123527
+ });
123528
+ PlanChangeV0Schema = exports_external.object({
123529
+ plan: ApiPlanV1Schema.optional().meta({
123530
+ description: "The plan after the change. Omitted unless the caller expands it."
123531
+ }),
123532
+ previous_attributes: PlanPreviousAttributesV0Schema.nullable().meta({
123533
+ description: "Sparse map of scalar plan fields that changed, holding their previous values. Null when the plan is new."
123534
+ }),
123535
+ price_change: PlanPriceChangeV0Schema.optional().meta({
123536
+ description: "Present when the plan's price changed."
123537
+ }),
123538
+ free_trial_change: PlanFreeTrialChangeV0Schema.optional().meta({
123539
+ description: "Present when the plan's free trial changed."
123540
+ }),
123541
+ item_changes: exports_external.array(PlanItemChangeV0Schema).default([]).meta({
123542
+ description: "Feature items added to or removed from the plan."
123543
+ })
123544
+ });
123545
+ });
123546
+
123547
+ // ../../shared/api/products/components/planChange/index.ts
123548
+ var init_planChange = __esm(() => {
123549
+ init_planChangeV0();
123550
+ init_planItemChangeV0();
123551
+ init_planPreviousAttributesV0();
123552
+ });
123553
+
123359
123554
  // ../../shared/api/products/crud/createVariantParamsV2.ts
123360
123555
  var CreateVariantParamsV2Schema;
123361
123556
  var init_createVariantParamsV2 = __esm(() => {
@@ -124233,6 +124428,7 @@ var init_products2 = __esm(() => {
124233
124428
  init_basePriceToProductItem();
124234
124429
  init_billingMethod();
124235
124430
  init_display();
124431
+ init_planChange();
124236
124432
  init_planExpand();
124237
124433
  init_crud3();
124238
124434
  init_items();
@@ -125221,17 +125417,22 @@ var init_checkoutResponseV0 = __esm(() => {
125221
125417
  });
125222
125418
 
125223
125419
  // ../../shared/api/billing/common/customerPlanChange.ts
125224
- var PlanChangeActionEnum, SubscriptionStatusEnum, PurchaseStatusEnum, SubscriptionSnapshotSchema, PurchaseSnapshotSchema, CustomerPlanItemChangeSchema, CustomerPlanChangeSchema;
125420
+ var PlanChangeActionEnum, SubscriptionStatusEnum, PurchaseStatusEnum, SubscriptionSnapshotSchema, PurchaseSnapshotSchema, CustomerPlanPreviousAttributesSchema, CustomerPlanChangeSchema;
125225
125421
  var init_customerPlanChange = __esm(() => {
125422
+ init_planChangeV0();
125423
+ init_planItemChangeV0();
125226
125424
  init_v4();
125227
- init_apiPlanItemV1();
125228
125425
  PlanChangeActionEnum = exports_external.enum([
125229
125426
  "activated",
125230
125427
  "scheduled",
125231
125428
  "updated",
125232
125429
  "expired"
125233
125430
  ]);
125234
- SubscriptionStatusEnum = exports_external.enum(["active", "scheduled", "expired"]);
125431
+ SubscriptionStatusEnum = exports_external.enum([
125432
+ "active",
125433
+ "scheduled",
125434
+ "expired"
125435
+ ]);
125235
125436
  PurchaseStatusEnum = exports_external.enum(["active", "scheduled", "expired"]);
125236
125437
  SubscriptionSnapshotSchema = exports_external.object({
125237
125438
  plan_id: exports_external.string().meta({
@@ -125273,17 +125474,13 @@ var init_customerPlanChange = __esm(() => {
125273
125474
  description: "When the purchase ends, in milliseconds since the Unix epoch, or null if no expiry is set."
125274
125475
  })
125275
125476
  });
125276
- CustomerPlanItemChangeSchema = exports_external.object({
125277
- action: exports_external.enum(["created", "deleted"]).meta({
125278
- description: "Whether the feature was added to or removed from the plan."
125279
- }),
125280
- feature_id: exports_external.string().meta({
125281
- description: "The ID of the feature that was added or removed."
125282
- }),
125283
- item: ApiPlanItemV1Schema.meta({
125284
- description: "The item snapshot that was added or removed."
125285
- })
125286
- });
125477
+ CustomerPlanPreviousAttributesSchema = SubscriptionSnapshotSchema.pick({
125478
+ status: true,
125479
+ past_due: true,
125480
+ canceled_at: true,
125481
+ expires_at: true,
125482
+ trial_ends_at: true
125483
+ }).partial();
125287
125484
  CustomerPlanChangeSchema = exports_external.object({
125288
125485
  action: PlanChangeActionEnum.meta({
125289
125486
  description: "The lifecycle action applied to this plan: activated (newly active on the customer), scheduled (queued for a future start), updated (mutated in place), or expired (ended)."
@@ -125294,11 +125491,15 @@ var init_customerPlanChange = __esm(() => {
125294
125491
  purchase: PurchaseSnapshotSchema.optional().meta({
125295
125492
  description: "The purchase as it stands after this change. Present when the plan is a one-off purchase."
125296
125493
  }),
125297
- previous_attributes: exports_external.record(exports_external.string(), exports_external.unknown()).nullable().meta({
125298
- description: "Sparse map of scalar fields whose values changed, holding their previous values. Null when the plan is newly activated or scheduled."
125494
+ previous_attributes: CustomerPlanPreviousAttributesSchema.nullable().meta({
125495
+ description: "Sparse map of lifecycle scalar fields whose values changed, holding their previous values. Null when the plan is newly activated or scheduled, or when no lifecycle field changed."
125496
+ }),
125497
+ plan_change: PlanChangeV0Schema.optional().meta({
125498
+ description: "Content-level change to the plan definition for this customer plan (items, base price, free trial)."
125299
125499
  }),
125300
- item_changes: exports_external.array(CustomerPlanItemChangeSchema).default([]).meta({
125301
- description: "Features that were added to or removed from this plan. Only populated for updated plans."
125500
+ item_changes: exports_external.array(PlanItemChangeV0Schema).default([]).meta({
125501
+ deprecated: true,
125502
+ description: "Deprecated — use plan_change.item_changes. Features that were added to or removed from this plan."
125302
125503
  })
125303
125504
  });
125304
125505
  });
@@ -125403,6 +125604,34 @@ var init_common3 = __esm(() => {
125403
125604
  init_transitionRules();
125404
125605
  });
125405
125606
 
125607
+ // ../../shared/api/billing/components/billingChanges/previewBalanceChange.ts
125608
+ var PreviewBalanceSchema, PreviewBalanceChangeSchema;
125609
+ var init_previewBalanceChange = __esm(() => {
125610
+ init_v4();
125611
+ PreviewBalanceSchema = exports_external.object({
125612
+ granted: exports_external.number(),
125613
+ remaining: exports_external.number(),
125614
+ usage: exports_external.number(),
125615
+ unlimited: exports_external.boolean(),
125616
+ next_reset_at: exports_external.number().nullable()
125617
+ });
125618
+ PreviewBalanceChangeSchema = exports_external.object({
125619
+ feature_id: exports_external.string(),
125620
+ balance: PreviewBalanceSchema,
125621
+ previous_attributes: exports_external.record(exports_external.string(), exports_external.unknown()).default({})
125622
+ });
125623
+ });
125624
+
125625
+ // ../../shared/api/billing/components/billingChanges/previewFlagChange.ts
125626
+ var PreviewFlagChangeSchema;
125627
+ var init_previewFlagChange = __esm(() => {
125628
+ init_v4();
125629
+ PreviewFlagChangeSchema = exports_external.object({
125630
+ action: exports_external.enum(["created", "deleted"]),
125631
+ feature_id: exports_external.string()
125632
+ });
125633
+ });
125634
+
125406
125635
  // ../../shared/api/billing/dfu/dfuFlashParams.ts
125407
125636
  var ProcessorTypeSchema, FlashCustomerDataSchema, FlashProcessorIdentitySchema, FlashLinkSchema, FlashStartingAfterSchema, FlashBalanceFilterSchema, FlashRolloverSchema, FlashBalanceSchema, FlashFeatureQuantitySchema, FlashPlanSchema, FlashPhaseSchema, FlashBillableSchema, FlashEntitySchema, DfuFlashParamsSchema, DfuFlashedPlanSchema, DfuFlashResultSchema;
125408
125637
  var init_dfuFlashParams = __esm(() => {
@@ -125884,7 +126113,7 @@ var init_syncProposalsV2 = __esm(() => {
125884
126113
  });
125885
126114
 
125886
126115
  // ../../shared/api/billing/verify/verifyParamsV1.ts
125887
- var VerifyParamsV1Schema, ItemMismatchReasonSchema, message, severity, ItemMismatchSchema, BasePriceMismatchSchema, PrepaidQuantityMismatchSchema, PrepaidPriceMismatchSchema, ScheduleMismatchSchema, CancelStateMismatchSchema, RewardMismatchSchema, StripeSubNotInAutumnMismatchSchema, StaleSubscriptionLinkMismatchSchema, ExpectedStateErrorMismatchSchema, SubscriptionMismatchSchema, SubscriptionVerifyResultSchema, VerifyResponseSchema;
126116
+ var VerifyParamsV1Schema, ItemMismatchReasonSchema, message, severity, ItemMismatchSchema, BasePriceMismatchSchema, PrepaidQuantityMismatchSchema, PrepaidPriceMismatchSchema, ScheduleMismatchSchema, CancelStateMismatchSchema, RewardMismatchSchema, StripeSubNotInAutumnMismatchSchema, StaleSubscriptionLinkMismatchSchema, ExpectedStateErrorMismatchSchema, SharedStripeCustomerMismatchSchema, SubscriptionMismatchSchema, SubscriptionVerifyResultSchema, VerifyResponseSchema;
125888
126117
  var init_verifyParamsV1 = __esm(() => {
125889
126118
  init_v4();
125890
126119
  VerifyParamsV1Schema = exports_external.object({
@@ -126009,6 +126238,13 @@ var init_verifyParamsV1 = __esm(() => {
126009
126238
  severity,
126010
126239
  error: exports_external.string()
126011
126240
  });
126241
+ SharedStripeCustomerMismatchSchema = exports_external.object({
126242
+ type: exports_external.literal("shared_stripe_customer"),
126243
+ message,
126244
+ severity,
126245
+ stripe_customer_id: exports_external.string(),
126246
+ other_customer_ids: exports_external.array(exports_external.string())
126247
+ });
126012
126248
  SubscriptionMismatchSchema = exports_external.discriminatedUnion("type", [
126013
126249
  BasePriceMismatchSchema,
126014
126250
  ItemMismatchSchema,
@@ -126019,7 +126255,8 @@ var init_verifyParamsV1 = __esm(() => {
126019
126255
  RewardMismatchSchema,
126020
126256
  StripeSubNotInAutumnMismatchSchema,
126021
126257
  StaleSubscriptionLinkMismatchSchema,
126022
- ExpectedStateErrorMismatchSchema
126258
+ ExpectedStateErrorMismatchSchema,
126259
+ SharedStripeCustomerMismatchSchema
126023
126260
  ]);
126024
126261
  SubscriptionVerifyResultSchema = exports_external.object({
126025
126262
  stripe_subscription_id: exports_external.string(),
@@ -126028,6 +126265,7 @@ var init_verifyParamsV1 = __esm(() => {
126028
126265
  });
126029
126266
  VerifyResponseSchema = exports_external.object({
126030
126267
  customer_id: exports_external.string(),
126268
+ customer_mismatches: exports_external.array(SubscriptionMismatchSchema),
126031
126269
  subscriptions: exports_external.array(SubscriptionVerifyResultSchema)
126032
126270
  });
126033
126271
  });
@@ -126043,6 +126281,8 @@ var init_billing = __esm(() => {
126043
126281
  init_checkoutParamsV0();
126044
126282
  init_checkoutResponseV0();
126045
126283
  init_common3();
126284
+ init_previewBalanceChange();
126285
+ init_previewFlagChange();
126046
126286
  init_createScheduleParamsV0();
126047
126287
  init_createScheduleResponse();
126048
126288
  init_dfuFlashParams();
@@ -132868,42 +133108,6 @@ var init_idempotencyConfig = __esm(() => {
132868
133108
  });
132869
133109
  });
132870
133110
 
132871
- // ../../shared/models/orgModels/orgConfig.ts
132872
- var OrgConfigSchema;
132873
- var init_orgConfig = __esm(() => {
132874
- init_v4();
132875
- init_usageAlert();
132876
- OrgConfigSchema = exports_external.object({
132877
- usage_alerts: exports_external.array(DbUsageAlertSchema).optional().default([]),
132878
- sandbox_usage_alerts: exports_external.array(DbUsageAlertSchema).optional().default([]),
132879
- bill_upgrade_immediately: exports_external.boolean().default(true),
132880
- convert_to_charge_automatically: exports_external.boolean().default(true),
132881
- anchor_start_of_month: exports_external.boolean().default(false),
132882
- cancel_on_past_due: exports_external.boolean().default(false),
132883
- prorate_unused: exports_external.boolean().default(true),
132884
- checkout_on_failed_payment: exports_external.boolean().default(true),
132885
- reverse_deduction_order: exports_external.boolean().default(false),
132886
- include_past_due: exports_external.boolean().default(true),
132887
- sync_status: exports_external.boolean().default(true),
132888
- merge_billing_cycles: exports_external.boolean().default(true),
132889
- multiple_trials: exports_external.boolean().default(false),
132890
- allow_paid_default: exports_external.boolean().default(false),
132891
- cache_customer: exports_external.boolean().default(false),
132892
- invoice_memos: exports_external.boolean().default(false),
132893
- entity_product: exports_external.boolean().default(false),
132894
- void_invoices_on_subscription_deletion: exports_external.boolean().default(false),
132895
- default_applies_to_entities: exports_external.boolean().default(false),
132896
- disable_overage_billing: exports_external.boolean().default(false),
132897
- disable_stripe_writes: exports_external.boolean().default(false),
132898
- disabled_auto_topup: exports_external.boolean().default(false),
132899
- persist_free_overage: exports_external.boolean().default(false),
132900
- dryrun_autotopups: exports_external.boolean().default(false),
132901
- forward_customer_metadata: exports_external.boolean().default(false),
132902
- automatic_tax: exports_external.boolean().default(false),
132903
- multi_currency: exports_external.boolean().default(false)
132904
- });
132905
- });
132906
-
132907
133111
  // ../../shared/models/orgModels/frontendOrg.ts
132908
133112
  var FrontendOrgSchema;
132909
133113
  var init_frontendOrg = __esm(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atmn",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "atmn": "dist/cli.js"