@better-giving/endowment 3.0.5 → 4.0.1
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 +3 -2
- package/dist/db.mjs +6 -2
- package/package.json +3 -3
- package/src/db.mts +13 -7
package/dist/db.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Db } from "@better-giving/db";
|
|
1
|
+
import { Db, type UpdateComps } from "@better-giving/db";
|
|
2
2
|
import type { IMedia, IMediaPage, INpoReferredBy, INpoWithRegNum, INpoWithRid, TBinFlag, TNpoDbKeys, TNpoDbProjectedTo } from "./interfaces.mjs";
|
|
3
3
|
import type { IMediaSearchObj, IMilestone, IMilestoneUpdate, INpo, INpoUpdate, IProgram, IProgramDb, IProgramNew, IProgramUpdate, TMediaType } from "./schema.mjs";
|
|
4
4
|
export declare class NpoDb extends Db {
|
|
@@ -132,7 +132,8 @@ export declare class NpoDb extends Db {
|
|
|
132
132
|
npo_med(npo: number, mid: string): Promise<IMedia | undefined>;
|
|
133
133
|
npo_med_delete(npo: number, mid: string): Promise<import("@aws-sdk/lib-dynamodb").DeleteCommandOutput>;
|
|
134
134
|
npo<T extends TNpoDbKeys[]>(id: string | number, fields?: T): Promise<TNpoDbProjectedTo<T> | undefined>;
|
|
135
|
-
|
|
135
|
+
npo_update_comps({ target, slug, social_media_urls, ...update }: INpoUpdate): Promise<UpdateComps>;
|
|
136
|
+
npo_update(id: number, update: INpoUpdate): Promise<import("@aws-sdk/lib-dynamodb").UpdateCommandOutput>;
|
|
136
137
|
prog_milestones(id: string): Promise<IMilestone[]>;
|
|
137
138
|
prog_milestone_delete(pid: string, mid: string): Promise<import("@aws-sdk/lib-dynamodb").DeleteCommandOutput>;
|
|
138
139
|
prog_milestone_update(pid: string, mid: string, update: IMilestoneUpdate): Promise<Record<string, any> | undefined>;
|
package/dist/db.mjs
CHANGED
|
@@ -222,7 +222,7 @@ export class NpoDb extends Db {
|
|
|
222
222
|
const { Item: i } = await this.client.send(cmd);
|
|
223
223
|
return i ? this.sans_keys(i) : undefined;
|
|
224
224
|
}
|
|
225
|
-
async
|
|
225
|
+
async npo_update_comps({ target, slug, social_media_urls, ...update }) {
|
|
226
226
|
const updates = new UpdateBuilder();
|
|
227
227
|
if (slug)
|
|
228
228
|
updates.set("slug", slug);
|
|
@@ -243,11 +243,15 @@ export class NpoDb extends Db {
|
|
|
243
243
|
continue;
|
|
244
244
|
updates.set(k, v);
|
|
245
245
|
}
|
|
246
|
+
return updates.collect();
|
|
247
|
+
}
|
|
248
|
+
async npo_update(id, update) {
|
|
249
|
+
const upd8 = this.npo_update_comps(update);
|
|
246
250
|
const cmd = new UpdateCommand({
|
|
247
251
|
TableName: NpoDb.name,
|
|
248
252
|
Key: this.key_npo(id),
|
|
253
|
+
...upd8,
|
|
249
254
|
ReturnValues: "ALL_NEW",
|
|
250
|
-
...updates.collect(),
|
|
251
255
|
});
|
|
252
256
|
return this.client.send(cmd);
|
|
253
257
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-giving/endowment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"ksuid": "3.0.0"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@better-giving/schemas": "
|
|
8
|
+
"@better-giving/schemas": "2.0.0",
|
|
9
9
|
"@better-giving/types": "1.1.8",
|
|
10
|
-
"@better-giving/db": "
|
|
10
|
+
"@better-giving/db": "2.0.0",
|
|
11
11
|
"@aws-sdk/lib-dynamodb": "3.485.0",
|
|
12
12
|
"valibot": "0.42.0"
|
|
13
13
|
},
|
package/src/db.mts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
TransactWriteCommand,
|
|
7
7
|
UpdateCommand,
|
|
8
8
|
} from "@aws-sdk/lib-dynamodb";
|
|
9
|
-
import { Db, Txs, UpdateBuilder } from "@better-giving/db";
|
|
9
|
+
import { Db, Txs, UpdateBuilder, type UpdateComps } from "@better-giving/db";
|
|
10
10
|
import KSUID from "ksuid";
|
|
11
11
|
import type {
|
|
12
12
|
IMedia,
|
|
@@ -288,10 +288,12 @@ export class NpoDb extends Db {
|
|
|
288
288
|
return i ? this.sans_keys(i) : undefined;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
async
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
async npo_update_comps({
|
|
292
|
+
target,
|
|
293
|
+
slug,
|
|
294
|
+
social_media_urls,
|
|
295
|
+
...update
|
|
296
|
+
}: INpoUpdate): Promise<UpdateComps> {
|
|
295
297
|
const updates = new UpdateBuilder();
|
|
296
298
|
|
|
297
299
|
if (slug) updates.set("slug", slug);
|
|
@@ -313,13 +315,17 @@ export class NpoDb extends Db {
|
|
|
313
315
|
updates.set(k, v);
|
|
314
316
|
}
|
|
315
317
|
|
|
318
|
+
return updates.collect();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async npo_update(id: number, update: INpoUpdate) {
|
|
322
|
+
const upd8 = this.npo_update_comps(update);
|
|
316
323
|
const cmd = new UpdateCommand({
|
|
317
324
|
TableName: NpoDb.name,
|
|
318
325
|
Key: this.key_npo(id),
|
|
326
|
+
...upd8,
|
|
319
327
|
ReturnValues: "ALL_NEW",
|
|
320
|
-
...updates.collect(),
|
|
321
328
|
});
|
|
322
|
-
|
|
323
329
|
return this.client.send(cmd);
|
|
324
330
|
}
|
|
325
331
|
|