@better-giving/endowment 4.0.31 → 4.0.32

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/db.d.mts CHANGED
@@ -134,7 +134,7 @@ export declare class NpoDb extends Db {
134
134
  npo_med_update(npo: number, prev: IMedia, update: IMediaUpdate): Promise<Record<string, any>>;
135
135
  npo_med_delete(npo: number, mid: string): Promise<import("@aws-sdk/lib-dynamodb").DeleteCommandOutput>;
136
136
  npo<T extends TNpoDbKeys[]>(id: string | number, fields?: T): Promise<TNpoDbProjectedTo<T> | undefined>;
137
- npo_update_comps({ target, slug, social_media_urls, ...update }: INpoUpdate): UpdateComps;
137
+ npo_update_comps({ target, slug, social_media_urls, increments, ...update }: INpoUpdate): UpdateComps;
138
138
  npo_update(id: number, update: INpoUpdate): Promise<import("@aws-sdk/lib-dynamodb").UpdateCommandOutput>;
139
139
  npo_update_txi(id: number, update: INpoUpdate): TxType["Update"];
140
140
  prog_milestones(id: string): Promise<IMilestone[]>;
package/dist/db.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import crypto from "node:crypto";
2
2
  import { BatchGetCommand, DeleteCommand, GetCommand, PutCommand, QueryCommand, TransactWriteCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
3
3
  import { Db, Txs, UpdateBuilder, } from "@better-giving/db";
4
+ import { projection } from "@better-giving/db/helpers";
4
5
  import KSUID from "ksuid";
5
6
  import { med_key_filter, med_sk, to_imedia } from "./media.mjs";
6
7
  import { npo_fields } from "./npo.mjs";
7
- import { projection } from "@better-giving/db/helpers";
8
8
  export class NpoDb extends Db {
9
9
  static table = "endowments_v3";
10
10
  static slug_env_gsi = "slug-env-gsi";
@@ -258,14 +258,19 @@ export class NpoDb extends Db {
258
258
  const { Item: i } = await this.client.send(cmd);
259
259
  return i ? this.sans_keys(i) : undefined;
260
260
  }
261
- npo_update_comps({ target, slug, social_media_urls, ...update }) {
261
+ npo_update_comps({ target, slug, social_media_urls, increments, ...update }) {
262
262
  const updates = new UpdateBuilder();
263
263
  if (slug)
264
264
  updates.set("slug", slug);
265
265
  if (slug === "")
266
266
  updates.remove("slug");
267
- if (target || target === "0") {
268
- updates.set("target", target);
267
+ if (increments) {
268
+ if (increments.length > 0) {
269
+ updates.set("increments", increments);
270
+ }
271
+ else {
272
+ updates.remove("increments");
273
+ }
269
274
  }
270
275
  if (social_media_urls) {
271
276
  for (const [k, v] of Object.entries(social_media_urls)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "4.0.31",
3
+ "version": "4.0.32",
4
4
  "dependencies": {
5
5
  "ksuid": "3.0.0"
6
6
  },
package/src/db.mts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  UpdateBuilder,
16
16
  type UpdateComps,
17
17
  } from "@better-giving/db";
18
+ import { projection } from "@better-giving/db/helpers";
18
19
  import KSUID from "ksuid";
19
20
  import type {
20
21
  IMedia,
@@ -28,6 +29,7 @@ import type {
28
29
  TNpoDbProjectedTo,
29
30
  } from "./interfaces.mjs";
30
31
  import { med_key_filter, med_sk, to_imedia } from "./media.mjs";
32
+ import { npo_fields } from "./npo.mjs";
31
33
  import type {
32
34
  IMediaSearchObj,
33
35
  IMediaUpdate,
@@ -42,8 +44,6 @@ import type {
42
44
  IProgramUpdate,
43
45
  TMediaType,
44
46
  } from "./schema.mjs";
45
- import { npo_fields } from "./npo.mjs";
46
- import { projection } from "@better-giving/db/helpers";
47
47
 
48
48
  export class NpoDb extends Db {
49
49
  static readonly table = "endowments_v3";
@@ -346,6 +346,7 @@ export class NpoDb extends Db {
346
346
  target,
347
347
  slug,
348
348
  social_media_urls,
349
+ increments,
349
350
  ...update
350
351
  }: INpoUpdate): UpdateComps {
351
352
  const updates = new UpdateBuilder();
@@ -353,8 +354,12 @@ export class NpoDb extends Db {
353
354
  if (slug) updates.set("slug", slug);
354
355
  if (slug === "") updates.remove("slug");
355
356
 
356
- if (target || target === "0") {
357
- updates.set("target", target);
357
+ if (increments) {
358
+ if (increments.length > 0) {
359
+ updates.set("increments", increments);
360
+ } else {
361
+ updates.remove("increments");
362
+ }
358
363
  }
359
364
 
360
365
  if (social_media_urls) {