@better-giving/endowment 4.0.8 → 4.0.10

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
@@ -1,6 +1,6 @@
1
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
- import type { IMediaSearchObj, IMediaUpdate, IMilestone, IMilestoneUpdate, INpo, INpoUpdate, IProgram, IProgramDb, IProgramNew, IProgramUpdate, TMediaType } from "./schema.mjs";
3
+ import type { IMediaSearchObj, IMediaUpdate, IMilestone, IMilestoneNew, IMilestoneUpdate, INpo, INpoUpdate, IProgram, IProgramDb, IProgramNew, IProgramUpdate, TMediaType } from "./schema.mjs";
4
4
  export declare class NpoDb extends Db {
5
5
  static readonly name = "endowments_v3";
6
6
  static readonly slug_env_gsi: "slug-env-gsi";
@@ -109,8 +109,7 @@ export declare class NpoDb extends Db {
109
109
  PK: string;
110
110
  SK: string;
111
111
  };
112
- prog_milestone_record(prog: string, data: IMilestone): {
113
- id: string;
112
+ prog_milestone_record(prog: string, data: IMilestoneNew): {
114
113
  date: string;
115
114
  title: string;
116
115
  description: string;
@@ -137,6 +136,7 @@ export declare class NpoDb extends Db {
137
136
  npo_update(id: number, update: INpoUpdate): Promise<import("@aws-sdk/lib-dynamodb").UpdateCommandOutput>;
138
137
  prog_milestones(id: string): Promise<IMilestone[]>;
139
138
  prog_milestone_delete(pid: string, mid: string): Promise<import("@aws-sdk/lib-dynamodb").DeleteCommandOutput>;
139
+ prog_milestone_put(pid: string, content: IMilestoneNew): Promise<string>;
140
140
  prog_milestone_update(pid: string, mid: string, update: IMilestoneUpdate): Promise<Record<string, any> | undefined>;
141
141
  npo_program(id: string, npo_id: number): Promise<IProgram | undefined>;
142
142
  npo_programs(id: number): Promise<IProgramDb[]>;
package/dist/db.mjs CHANGED
@@ -148,8 +148,9 @@ export class NpoDb extends Db {
148
148
  };
149
149
  }
150
150
  prog_milestone_record(prog, data) {
151
+ const mid = crypto.randomUUID();
151
152
  return {
152
- ...this.key_prog_milestone(data.id, prog),
153
+ ...this.key_prog_milestone(mid, prog),
153
154
  ...data,
154
155
  };
155
156
  }
@@ -289,6 +290,15 @@ export class NpoDb extends Db {
289
290
  });
290
291
  return this.client.send(cmd);
291
292
  }
293
+ async prog_milestone_put(pid, content) {
294
+ const mid = crypto.randomUUID();
295
+ const item = this.prog_milestone_record(pid, content);
296
+ const cmd = new PutCommand({
297
+ TableName: NpoDb.name,
298
+ Item: item,
299
+ });
300
+ return this.client.send(cmd).then(() => mid);
301
+ }
292
302
  async prog_milestone_update(pid, mid, update) {
293
303
  const upd8 = new UpdateBuilder();
294
304
  for (const [key, value] of Object.entries(update)) {
@@ -342,10 +352,9 @@ export class NpoDb extends Db {
342
352
  Item: db_prog,
343
353
  });
344
354
  for (const m of milestones || []) {
345
- const mid = crypto.randomUUID();
346
355
  txs.put({
347
356
  TableName: NpoDb.name,
348
- Item: this.prog_milestone_record(pid, { ...m, id: mid }),
357
+ Item: this.prog_milestone_record(pid, m),
349
358
  });
350
359
  }
351
360
  const cmd = new TransactWriteCommand({
@@ -1,6 +1,7 @@
1
1
  import type { IPageKeyed } from "@better-giving/types/api";
2
2
  import type { Ensure } from "@better-giving/types/utils";
3
3
  import type { IMediaUpdate, INpo, TMediaType } from "./schema.mjs";
4
+ import type { CloudsearchEndow } from "./cloudsearch.mjs";
4
5
  export type { IAllocation, INpo, INpoFields, INposSearch, INpoUpdate, IIncrement, IMediaSearch, IMediaSearchObj, TMediaType, IMediaUpdate, IMilestone, IMilestoneUpdate, IMilestoneNew, IProgram, IProgramDb, IProgramNew, IProgramUpdate, ISocialMediaURLs, } from "./schema.mjs";
5
6
  export { type OrgDesignation as EndowDesignation, type Environment, type UnSdgNum, type DonateMethodId, https_url, } from "@better-giving/schemas";
6
7
  export interface INpoDb extends INpo {
@@ -34,8 +35,8 @@ export type TNpoDbKeys = keyof INpoDb;
34
35
  export type TArrayValues<T extends readonly unknown[]> = T[number];
35
36
  export type TNpoDbProjectedTo<T> = T extends TNpoDbKeys[] ? Pick<INpoDb, TArrayValues<T>> : INpoDb;
36
37
  export type TBinFlag = "0" | "1";
37
- export interface INposPage<T extends keyof INpoDb = keyof INpoDb> {
38
- items: Pick<INpoDb, T>[];
38
+ export interface INposPage<T extends keyof CloudsearchEndow = keyof CloudsearchEndow> {
39
+ items: Pick<CloudsearchEndow, T>[];
39
40
  page: number;
40
41
  pages: number;
41
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "dependencies": {
5
5
  "ksuid": "3.0.0"
6
6
  },
package/src/db.mts CHANGED
@@ -25,6 +25,7 @@ import type {
25
25
  IMediaSearchObj,
26
26
  IMediaUpdate,
27
27
  IMilestone,
28
+ IMilestoneNew,
28
29
  IMilestoneUpdate,
29
30
  INpo,
30
31
  INpoUpdate,
@@ -200,9 +201,10 @@ export class NpoDb extends Db {
200
201
  };
201
202
  }
202
203
 
203
- prog_milestone_record(prog: string, data: IMilestone) {
204
+ prog_milestone_record(prog: string, data: IMilestoneNew) {
205
+ const mid = crypto.randomUUID();
204
206
  return {
205
- ...this.key_prog_milestone(data.id, prog),
207
+ ...this.key_prog_milestone(mid, prog),
206
208
  ...data,
207
209
  };
208
210
  }
@@ -370,6 +372,19 @@ export class NpoDb extends Db {
370
372
  });
371
373
  return this.client.send(cmd);
372
374
  }
375
+ async prog_milestone_put(
376
+ pid: string,
377
+ content: IMilestoneNew
378
+ ): Promise<string> {
379
+ const mid = crypto.randomUUID();
380
+ const item = this.prog_milestone_record(pid, content);
381
+ const cmd = new PutCommand({
382
+ TableName: NpoDb.name,
383
+ Item: item,
384
+ });
385
+ return this.client.send(cmd).then(() => mid);
386
+ }
387
+
373
388
  async prog_milestone_update(
374
389
  pid: string,
375
390
  mid: string,
@@ -434,10 +449,9 @@ export class NpoDb extends Db {
434
449
  });
435
450
 
436
451
  for (const m of milestones || []) {
437
- const mid = crypto.randomUUID();
438
452
  txs.put({
439
453
  TableName: NpoDb.name,
440
- Item: this.prog_milestone_record(pid, { ...m, id: mid }),
454
+ Item: this.prog_milestone_record(pid, m),
441
455
  });
442
456
  }
443
457
 
@@ -1,7 +1,7 @@
1
1
  import type { IPageKeyed } from "@better-giving/types/api";
2
2
  import type { Ensure } from "@better-giving/types/utils";
3
3
  import type { IMediaUpdate, INpo, TMediaType } from "./schema.mjs";
4
-
4
+ import type { CloudsearchEndow } from "./cloudsearch.mjs";
5
5
  export type {
6
6
  IAllocation,
7
7
  INpo,
@@ -71,8 +71,10 @@ export type TNpoDbProjectedTo<T> = T extends TNpoDbKeys[]
71
71
 
72
72
  export type TBinFlag = "0" | "1";
73
73
 
74
- export interface INposPage<T extends keyof INpoDb = keyof INpoDb> {
75
- items: Pick<INpoDb, T>[];
74
+ export interface INposPage<
75
+ T extends keyof CloudsearchEndow = keyof CloudsearchEndow,
76
+ > {
77
+ items: Pick<CloudsearchEndow, T>[];
76
78
  page: number;
77
79
  pages: number;
78
80
  }