@vandenberghinc/volt 1.2.12 → 1.2.13

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.
@@ -232,7 +232,7 @@ function find_matching_active_price(active_prices, app_price_id, expected_signat
232
232
  return match ?? null;
233
233
  }
234
234
  async function create_stripe_product(client, server, product) {
235
- server.log(0, `Creating Stripe product for product '${product.id}'`);
235
+ server.log(1, `Creating Stripe product for product '${product.id}'`);
236
236
  return await (0, import_utils.stripe_api_call)(() => client.products.create({
237
237
  name: product.name,
238
238
  description: product.description,
@@ -252,7 +252,7 @@ async function update_stripe_product_if_needed(client, server, stripe_product, p
252
252
  if (!needs_update) {
253
253
  return stripe_product;
254
254
  }
255
- server.log(0, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
255
+ server.log(1, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
256
256
  return await (0, import_utils.stripe_api_call)(() => client.products.update(stripe_product.id, {
257
257
  name: product.name,
258
258
  description: product.description,
@@ -277,13 +277,13 @@ async function update_stripe_product_default_price_if_needed(client, server, str
277
277
  if (default_price_id === default_price.id || other_plans_from_parent_subscription?.some((plan) => plan.stripe_price_id === default_price_id)) {
278
278
  return;
279
279
  }
280
- server.log(0, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
280
+ server.log(1, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
281
281
  await (0, import_utils.stripe_api_call)(() => client.products.update(stripe_product.id, {
282
282
  default_price: default_price.id
283
283
  }, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`update_product_default_price_${stripe_product.id}_${default_price.id}`) }), { operation: "products.update", app_product_id: stripe_product.metadata?.[app_product_id_metadata_key], stripe_product_id: stripe_product.id, action: "update_default_price" });
284
284
  }
285
285
  async function create_one_time_price(client, server, opts) {
286
- server.log(0, `Creating stripe one-time price for product: ${opts.product_id}`);
286
+ server.log(1, `Creating stripe one-time price for product: ${opts.product_id}`);
287
287
  return await (0, import_utils.stripe_api_call)(() => client.prices.create({
288
288
  product: opts.stripe_product_id,
289
289
  currency: opts.currency,
@@ -321,7 +321,7 @@ async function create_recurring_price(client, server, opts) {
321
321
  usage_type: opts.recurring_usage.usage_type,
322
322
  meter_id: opts.recurring_usage.usage_type === "metered" ? opts.recurring_usage.meter_id : void 0
323
323
  });
324
- server.log(0, `Creating stripe recurring price for product: ${opts.product_id}`);
324
+ server.log(1, `Creating stripe recurring price for product: ${opts.product_id}`);
325
325
  return await (0, import_utils.stripe_api_call)(() => client.prices.create({
326
326
  product: opts.stripe_product_id,
327
327
  currency: opts.currency,
@@ -340,7 +340,7 @@ async function create_stripe_meter(client, server, product) {
340
340
  const aggregation_formula = product.aggregation_formula ?? "sum";
341
341
  const customer_mapping_event_payload_key = product.customer_mapping_event_payload_key ?? "stripe_customer_id";
342
342
  const value_settings_event_payload_key = product.value_settings_event_payload_key ?? "value";
343
- server.log(0, `Creating stripe billing meter for product: ${product.id}`);
343
+ server.log(1, `Creating stripe billing meter for product: ${product.id}`);
344
344
  return await (0, import_utils.stripe_api_call)(() => client.billing.meters.create({
345
345
  display_name: product.name,
346
346
  event_name: product.meter_event_name,
@@ -215,6 +215,7 @@ async function register_or_update_stripe_webhook_endpoint(client, server, opts)
215
215
  const needs_event_update = !same_event_set(endpoint.enabled_events ?? [], enabled_events);
216
216
  const needs_enable = ensure_enabled && endpoint.status !== "enabled";
217
217
  if (needs_event_update || needs_enable) {
218
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
218
219
  const update_params = {
219
220
  enabled_events,
220
221
  ...needs_enable ? { disabled: false } : {},
@@ -257,6 +258,7 @@ async function register_or_update_stripe_webhook_endpoint(client, server, opts)
257
258
  const needs_enable = ensure_enabled && existing.status !== "enabled";
258
259
  const needs_url_update = existing.url !== opts.webhook_url;
259
260
  if (needs_event_update || needs_enable || needs_url_update) {
261
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
260
262
  const update_params = {
261
263
  enabled_events,
262
264
  ...needs_enable ? { disabled: false } : {},
@@ -277,6 +279,7 @@ async function register_or_update_stripe_webhook_endpoint(client, server, opts)
277
279
  }
278
280
  throw new import_error.InternalStripeError("webhook_endpoint_secret_missing", "Stripe webhook endpoint exists but signing secret is not available. Store the whsec_ value at creation time.", { webhook_url: opts.webhook_url, stripe_webhook_endpoint_id: existing.id });
279
281
  }
282
+ server.log(1, `Creating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
280
283
  const create_params = {
281
284
  // Docs: https://docs.stripe.com/api/webhook_endpoints/create
282
285
  url: opts.webhook_url,
@@ -295,6 +298,7 @@ async function register_or_update_stripe_webhook_endpoint(client, server, opts)
295
298
  throw new import_error.InternalStripeError("webhook_endpoint_secret_missing", "Stripe did not return a webhook signing secret on endpoint creation.", { webhook_url: opts.webhook_url, stripe_webhook_endpoint_id: created.id });
296
299
  }
297
300
  if (ensure_enabled && created.status !== "enabled") {
301
+ server.log(1, `Enabling webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
298
302
  await (0, import_utils.stripe_api_call)(() => client.webhookEndpoints.update(created.id, { disabled: false }, {
299
303
  idempotencyKey: (0, import_utils.stable_idempotency_key)(`webhook_endpoints.enable:${created.id}:${opts.webhook_url}`, 255)
300
304
  }), {
@@ -400,7 +400,7 @@ function find_matching_active_price(active_prices, app_price_id, expected_signat
400
400
  * Tax code docs: https://docs.stripe.com/tax/tax-codes
401
401
  */
402
402
  async function create_stripe_product(client, server, product) {
403
- server.log(0, `Creating Stripe product for product '${product.id}'`);
403
+ server.log(1, `Creating Stripe product for product '${product.id}'`);
404
404
  return await stripe_api_call(() => client.products.create({
405
405
  name: product.name,
406
406
  description: product.description,
@@ -429,7 +429,7 @@ async function update_stripe_product_if_needed(client, server, stripe_product, p
429
429
  if (!needs_update) {
430
430
  return stripe_product;
431
431
  }
432
- server.log(0, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
432
+ server.log(1, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
433
433
  return await stripe_api_call(() => client.products.update(stripe_product.id, {
434
434
  name: product.name,
435
435
  description: product.description,
@@ -463,7 +463,7 @@ async function update_stripe_product_default_price_if_needed(client, server, str
463
463
  || other_plans_from_parent_subscription?.some((plan) => plan.stripe_price_id === default_price_id)) {
464
464
  return;
465
465
  }
466
- server.log(0, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
466
+ server.log(1, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
467
467
  await stripe_api_call(() => client.products.update(stripe_product.id, {
468
468
  default_price: default_price.id,
469
469
  }, { idempotencyKey: generate_random_idempotency_key(`update_product_default_price_${stripe_product.id}_${default_price.id}`) }), { operation: "products.update", app_product_id: stripe_product.metadata?.[app_product_id_metadata_key], stripe_product_id: stripe_product.id, action: "update_default_price" });
@@ -474,7 +474,7 @@ async function update_stripe_product_default_price_if_needed(client, server, str
474
474
  * Docs: https://docs.stripe.com/api/prices/create
475
475
  */
476
476
  async function create_one_time_price(client, server, opts) {
477
- server.log(0, `Creating stripe one-time price for product: ${opts.product_id}`);
477
+ server.log(1, `Creating stripe one-time price for product: ${opts.product_id}`);
478
478
  return await stripe_api_call(() => client.prices.create({
479
479
  product: opts.stripe_product_id,
480
480
  currency: opts.currency,
@@ -520,7 +520,7 @@ async function create_recurring_price(client, server, opts) {
520
520
  usage_type: opts.recurring_usage.usage_type,
521
521
  meter_id: opts.recurring_usage.usage_type === "metered" ? opts.recurring_usage.meter_id : undefined,
522
522
  });
523
- server.log(0, `Creating stripe recurring price for product: ${opts.product_id}`);
523
+ server.log(1, `Creating stripe recurring price for product: ${opts.product_id}`);
524
524
  return await stripe_api_call(() => client.prices.create({
525
525
  product: opts.stripe_product_id,
526
526
  currency: opts.currency,
@@ -546,7 +546,7 @@ async function create_stripe_meter(client, server, product) {
546
546
  const aggregation_formula = product.aggregation_formula ?? "sum";
547
547
  const customer_mapping_event_payload_key = product.customer_mapping_event_payload_key ?? "stripe_customer_id";
548
548
  const value_settings_event_payload_key = product.value_settings_event_payload_key ?? "value";
549
- server.log(0, `Creating stripe billing meter for product: ${product.id}`);
549
+ server.log(1, `Creating stripe billing meter for product: ${product.id}`);
550
550
  return await stripe_api_call(() => client.billing.meters.create({
551
551
  display_name: product.name,
552
552
  event_name: product.meter_event_name,
@@ -290,6 +290,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
290
290
  // Stripe's WebhookEndpoint has `status` (enabled/disabled).
291
291
  const needs_enable = ensure_enabled && endpoint.status !== "enabled";
292
292
  if (needs_event_update || needs_enable) {
293
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
293
294
  const update_params = {
294
295
  enabled_events,
295
296
  ...(needs_enable ? { disabled: false } : {}),
@@ -335,6 +336,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
335
336
  const needs_enable = ensure_enabled && existing.status !== "enabled";
336
337
  const needs_url_update = existing.url !== opts.webhook_url;
337
338
  if (needs_event_update || needs_enable || needs_url_update) {
339
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
338
340
  const update_params = {
339
341
  enabled_events,
340
342
  ...(needs_enable ? { disabled: false } : {}),
@@ -357,6 +359,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
357
359
  // If you reached this branch without a DB record, you must provide the secret out-of-band.
358
360
  throw new InternalStripeError("webhook_endpoint_secret_missing", "Stripe webhook endpoint exists but signing secret is not available. Store the whsec_ value at creation time.", { webhook_url: opts.webhook_url, stripe_webhook_endpoint_id: existing.id });
359
361
  }
362
+ server.log(1, `Creating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
360
363
  // Third: create a new endpoint in Stripe.
361
364
  const create_params = {
362
365
  // Docs: https://docs.stripe.com/api/webhook_endpoints/create
@@ -378,6 +381,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
378
381
  }
379
382
  // Optionally enforce enabled state (Stripe defaults to enabled, but we harden this anyway).
380
383
  if (ensure_enabled && created.status !== "enabled") {
384
+ server.log(1, `Enabling webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
381
385
  await stripe_api_call(() => client.webhookEndpoints.update(created.id, { disabled: false }, {
382
386
  idempotencyKey: stable_idempotency_key(`webhook_endpoints.enable:${created.id}:${opts.webhook_url}`, 255),
383
387
  }), {
@@ -400,7 +400,7 @@ function find_matching_active_price(active_prices, app_price_id, expected_signat
400
400
  * Tax code docs: https://docs.stripe.com/tax/tax-codes
401
401
  */
402
402
  async function create_stripe_product(client, server, product) {
403
- server.log(0, `Creating Stripe product for product '${product.id}'`);
403
+ server.log(1, `Creating Stripe product for product '${product.id}'`);
404
404
  return await stripe_api_call(() => client.products.create({
405
405
  name: product.name,
406
406
  description: product.description,
@@ -429,7 +429,7 @@ async function update_stripe_product_if_needed(client, server, stripe_product, p
429
429
  if (!needs_update) {
430
430
  return stripe_product;
431
431
  }
432
- server.log(0, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
432
+ server.log(1, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
433
433
  return await stripe_api_call(() => client.products.update(stripe_product.id, {
434
434
  name: product.name,
435
435
  description: product.description,
@@ -463,7 +463,7 @@ async function update_stripe_product_default_price_if_needed(client, server, str
463
463
  || other_plans_from_parent_subscription?.some((plan) => plan.stripe_price_id === default_price_id)) {
464
464
  return;
465
465
  }
466
- server.log(0, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
466
+ server.log(1, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
467
467
  await stripe_api_call(() => client.products.update(stripe_product.id, {
468
468
  default_price: default_price.id,
469
469
  }, { idempotencyKey: generate_random_idempotency_key(`update_product_default_price_${stripe_product.id}_${default_price.id}`) }), { operation: "products.update", app_product_id: stripe_product.metadata?.[app_product_id_metadata_key], stripe_product_id: stripe_product.id, action: "update_default_price" });
@@ -474,7 +474,7 @@ async function update_stripe_product_default_price_if_needed(client, server, str
474
474
  * Docs: https://docs.stripe.com/api/prices/create
475
475
  */
476
476
  async function create_one_time_price(client, server, opts) {
477
- server.log(0, `Creating stripe one-time price for product: ${opts.product_id}`);
477
+ server.log(1, `Creating stripe one-time price for product: ${opts.product_id}`);
478
478
  return await stripe_api_call(() => client.prices.create({
479
479
  product: opts.stripe_product_id,
480
480
  currency: opts.currency,
@@ -520,7 +520,7 @@ async function create_recurring_price(client, server, opts) {
520
520
  usage_type: opts.recurring_usage.usage_type,
521
521
  meter_id: opts.recurring_usage.usage_type === "metered" ? opts.recurring_usage.meter_id : undefined,
522
522
  });
523
- server.log(0, `Creating stripe recurring price for product: ${opts.product_id}`);
523
+ server.log(1, `Creating stripe recurring price for product: ${opts.product_id}`);
524
524
  return await stripe_api_call(() => client.prices.create({
525
525
  product: opts.stripe_product_id,
526
526
  currency: opts.currency,
@@ -546,7 +546,7 @@ async function create_stripe_meter(client, server, product) {
546
546
  const aggregation_formula = product.aggregation_formula ?? "sum";
547
547
  const customer_mapping_event_payload_key = product.customer_mapping_event_payload_key ?? "stripe_customer_id";
548
548
  const value_settings_event_payload_key = product.value_settings_event_payload_key ?? "value";
549
- server.log(0, `Creating stripe billing meter for product: ${product.id}`);
549
+ server.log(1, `Creating stripe billing meter for product: ${product.id}`);
550
550
  return await stripe_api_call(() => client.billing.meters.create({
551
551
  display_name: product.name,
552
552
  event_name: product.meter_event_name,
@@ -290,6 +290,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
290
290
  // Stripe's WebhookEndpoint has `status` (enabled/disabled).
291
291
  const needs_enable = ensure_enabled && endpoint.status !== "enabled";
292
292
  if (needs_event_update || needs_enable) {
293
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
293
294
  const update_params = {
294
295
  enabled_events,
295
296
  ...(needs_enable ? { disabled: false } : {}),
@@ -335,6 +336,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
335
336
  const needs_enable = ensure_enabled && existing.status !== "enabled";
336
337
  const needs_url_update = existing.url !== opts.webhook_url;
337
338
  if (needs_event_update || needs_enable || needs_url_update) {
339
+ server.log(1, `Updating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
338
340
  const update_params = {
339
341
  enabled_events,
340
342
  ...(needs_enable ? { disabled: false } : {}),
@@ -357,6 +359,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
357
359
  // If you reached this branch without a DB record, you must provide the secret out-of-band.
358
360
  throw new InternalStripeError("webhook_endpoint_secret_missing", "Stripe webhook endpoint exists but signing secret is not available. Store the whsec_ value at creation time.", { webhook_url: opts.webhook_url, stripe_webhook_endpoint_id: existing.id });
359
361
  }
362
+ server.log(1, `Creating webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
360
363
  // Third: create a new endpoint in Stripe.
361
364
  const create_params = {
362
365
  // Docs: https://docs.stripe.com/api/webhook_endpoints/create
@@ -378,6 +381,7 @@ export async function register_or_update_stripe_webhook_endpoint(client, server,
378
381
  }
379
382
  // Optionally enforce enabled state (Stripe defaults to enabled, but we harden this anyway).
380
383
  if (ensure_enabled && created.status !== "enabled") {
384
+ server.log(1, `Enabling webhook ${opts.webhook_app_id} for URL ${opts.webhook_url}.`);
381
385
  await stripe_api_call(() => client.webhookEndpoints.update(created.id, { disabled: false }, {
382
386
  idempotencyKey: stable_idempotency_key(`webhook_endpoints.enable:${created.id}:${opts.webhook_url}`, 255),
383
387
  }), {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Daan van den Bergh",
3
3
  "name": "@vandenberghinc/volt",
4
- "version": "1.2.12",
4
+ "version": "1.2.13",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "types": "./backend/dist/esm/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "build": "npm run build:backend --silent && npm run build:backend:cjs --silent && npm run build:frontend --silent",
32
32
  "build:backend": "tsc -p backend/tsconfig.json",
33
33
  "build:backend:cjs": "vts --transform-esm --debug 1 --src backend/dist/esm/ --dest backend/dist/cjs/ --override --platform node --target es2023",
34
- "build:frontend": "tsc -p frontend/tsconfig.json && rsync -az --delete frontend/src/css/ frontend/dist/frontend/src/css/",
34
+ "build:frontend": "tsc -p frontend/tsconfig.json",
35
35
  "start": "node start.js",
36
36
  "check-circular-dependencies": "npx madge --circular frontend/src/"
37
37
  },