@better-giving/endowment 3.0.3 → 3.0.5

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
@@ -37,6 +37,7 @@ export declare class NpoDb extends Db {
37
37
  gsi1PK: string;
38
38
  gsi1SK: string;
39
39
  };
40
+ npo_count_inc(): Promise<number>;
40
41
  npo_media(npo: number, opts: IMediaSearchObj): Promise<IMediaPage>;
41
42
  npo_referred_by(id: string): Promise<INpoReferredBy[]>;
42
43
  npo_with_rid(id: string): Promise<INpoWithRid | undefined>;
package/dist/db.mjs CHANGED
@@ -55,6 +55,20 @@ export class NpoDb extends Db {
55
55
  gsi1SK: med_sk(id, type, featured),
56
56
  };
57
57
  }
58
+ async npo_count_inc() {
59
+ const cmd = new UpdateCommand({
60
+ TableName: NpoDb.name,
61
+ Key: this.key_count,
62
+ UpdateExpression: "SET #count = #count + :one",
63
+ ExpressionAttributeNames: {
64
+ "#count": "count",
65
+ },
66
+ ExpressionAttributeValues: { ":one": 1 },
67
+ ReturnValues: "UPDATED_NEW",
68
+ });
69
+ const res = await this.client.send(cmd);
70
+ return res.Attributes?.count ?? 1;
71
+ }
58
72
  async npo_media(npo, opts) {
59
73
  const PK = this.key_npo_med("ksuid-sk", npo).PK;
60
74
  const [expression, values] = med_key_filter(PK, opts);
package/dist/schema.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, int_gte1, org_designation, unsdg_num, slug } from "@better-giving/schemas";
1
+ import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, int_gte1, org_designation, slug, unsdg_num } from "@better-giving/schemas";
2
2
  export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, slug, };
3
3
  import * as v from "valibot";
4
4
  export declare const min_payout_amount = 50;
package/dist/schema.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, https_url, int_gte1, org_designation, unsdg_num, slug, } from "@better-giving/schemas";
1
+ import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, https_url, int_gte1, org_designation, slug, unsdg_num, } from "@better-giving/schemas";
2
2
  export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, slug, };
3
3
  import * as v from "valibot";
4
4
  export const min_payout_amount = 50;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "dependencies": {
5
5
  "ksuid": "3.0.0"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@better-giving/schemas": "1.2.3",
9
9
  "@better-giving/types": "1.1.8",
10
- "@better-giving/db": "1.0.11",
10
+ "@better-giving/db": "1.0.12",
11
11
  "@aws-sdk/lib-dynamodb": "3.485.0",
12
12
  "valibot": "0.42.0"
13
13
  },
package/src/db.mts CHANGED
@@ -91,6 +91,23 @@ export class NpoDb extends Db {
91
91
  gsi1SK: med_sk(id, type, featured),
92
92
  };
93
93
  }
94
+
95
+ async npo_count_inc(): Promise<number> {
96
+ const cmd = new UpdateCommand({
97
+ TableName: NpoDb.name,
98
+ Key: this.key_count,
99
+ UpdateExpression: "SET #count = #count + :one",
100
+ ExpressionAttributeNames: {
101
+ "#count": "count",
102
+ },
103
+
104
+ ExpressionAttributeValues: { ":one": 1 },
105
+ ReturnValues: "UPDATED_NEW",
106
+ });
107
+ const res = await this.client.send(cmd);
108
+ return res.Attributes?.count ?? 1;
109
+ }
110
+
94
111
  async npo_media(npo: number, opts: IMediaSearchObj): Promise<IMediaPage> {
95
112
  const PK: string = this.key_npo_med("ksuid-sk", npo).PK;
96
113
  const [expression, values] = med_key_filter(PK, opts);
@@ -305,6 +322,7 @@ export class NpoDb extends Db {
305
322
 
306
323
  return this.client.send(cmd);
307
324
  }
325
+
308
326
  async prog_milestones(id: string): Promise<IMilestone[]> {
309
327
  const command = new QueryCommand({
310
328
  TableName: NpoDb.name,
package/src/schema.mts CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  https_url,
10
10
  int_gte1,
11
11
  org_designation,
12
- unsdg_num,
13
12
  slug,
13
+ unsdg_num,
14
14
  } from "@better-giving/schemas";
15
15
  export {
16
16
  org_designation as endow_designation,