@better-giving/endowment 1.1.7 → 1.1.9

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,3 +1,4 @@
1
+ import type { Ensure } from "@better-giving/types/utils";
1
2
  import type { EndowId, Endowment as EndowmentShape, Environment, MediaId, MediaType, Milestone as MilestoneShape, MilestoneId, Program as ProgramShape, ProgramId } from "./schema.mjs";
2
3
  export type { EndowId, SocialMediaURLs, Allocation, Increment, EndowDesignation, Environment, ProgramId, } from "./schema.mjs";
3
4
  export declare const endowGsi: {
@@ -19,7 +20,10 @@ export declare namespace Endow {
19
20
  SK: Environment;
20
21
  };
21
22
  type NonKeyAttributes = EndowmentShape & {
22
- referral_id: string;
23
+ /** referral id */
24
+ gsi1PK?: `ReferredBy#${string}`;
25
+ /** expiry / date onboarded */
26
+ gsi1SK?: string;
23
27
  /** will only be present for unclaimed NPOs */
24
28
  updated_at_auto?: string;
25
29
  /** in USD @deprecated */
@@ -66,9 +70,6 @@ export declare namespace Milestone {
66
70
  interface DbRecord extends Keys, MilestoneShape {
67
71
  }
68
72
  }
69
- export declare const mediaGsi: {
70
- readonly 1: "gsi1";
71
- };
72
73
  export declare namespace Media {
73
74
  interface Keys {
74
75
  PK: `Endow#${EndowId}#${Environment}`;
@@ -90,11 +91,18 @@ export declare namespace Media {
90
91
  interface VideoDbRecord extends Keys, VideoAttributes {
91
92
  }
92
93
  type DbRecord = VideoDbRecord;
93
- namespace Gsi1 {
94
- type Name = (typeof mediaGsi)[1];
95
- interface Keys extends Pick<NonKeyAttributes, "gsi1PK" | "gsi1SK"> {
94
+ }
95
+ export declare namespace Gsi1 {
96
+ namespace MediaList {
97
+ interface Keys extends Pick<Media.NonKeyAttributes, "gsi1PK" | "gsi1SK"> {
98
+ }
99
+ interface DbRecord extends Media.DbRecord {
100
+ }
101
+ }
102
+ namespace ReferredNpos {
103
+ interface Keys extends Required<Pick<Endow.NonKeyAttributes, "gsi1PK" | "gsi1SK">> {
96
104
  }
97
- interface DbRecord extends Keys, NonKeyAttributes {
105
+ interface DbRecord extends Ensure<Endow.DbRecord, "gsi1PK" | "gsi1SK" | "referrer" | "referrer_expiry"> {
98
106
  }
99
107
  }
100
108
  }
package/dist/db.mjs CHANGED
@@ -2,6 +2,3 @@ export const endowGsi = {
2
2
  regnumEnv: "regnum-env-gsi",
3
3
  slugEnv: "slug-env-gsi",
4
4
  };
5
- export const mediaGsi = {
6
- 1: "gsi1",
7
- };
package/dist/schema.d.mts CHANGED
@@ -104,6 +104,7 @@ export declare const endowment: import("valibot").ObjectSchema<{
104
104
  readonly claimed: import("valibot").BooleanSchema<undefined>;
105
105
  readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
106
106
  readonly fiscal_sponsored: import("valibot").BooleanSchema<undefined>;
107
+ readonly referral_id: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
107
108
  readonly referrer: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
108
109
  readonly referrer_expiry: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, undefined>]>, never>;
109
110
  }, undefined>;
@@ -162,6 +163,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
162
163
  readonly claimed: import("valibot").BooleanSchema<undefined>;
163
164
  readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
164
165
  readonly fiscal_sponsored: import("valibot").BooleanSchema<undefined>;
166
+ readonly referral_id: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
165
167
  readonly referrer: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
166
168
  readonly referrer_expiry: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, undefined>]>, never>;
167
169
  }, undefined>, "_types" | "_run" | "entries"> & {
@@ -220,6 +222,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
220
222
  readonly claimed: import("valibot").BooleanSchema<undefined>;
221
223
  readonly kyc_donors_only: import("valibot").BooleanSchema<undefined>;
222
224
  readonly fiscal_sponsored: import("valibot").BooleanSchema<undefined>;
225
+ readonly referral_id: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
223
226
  readonly referrer: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>;
224
227
  readonly referrer_expiry: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, undefined>]>, never>;
225
228
  }, "id" | "env" | "claimed" | "kyc_donors_only" | "fiscal_sponsored">;
@@ -270,6 +273,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
270
273
  }[] | undefined;
271
274
  fund_opt_in?: boolean | undefined;
272
275
  target?: string | undefined;
276
+ referral_id?: string | undefined;
273
277
  referrer?: string | undefined;
274
278
  referrer_expiry?: string | undefined;
275
279
  }, import("valibot").StringIssue | import("valibot").RegexIssue<string> | import("valibot").NumberIssue | import("valibot").IntegerIssue<number> | import("valibot").MinValueIssue<number, 0> | import("valibot").MaxValueIssue<number, 100> | import("valibot").ObjectIssue | import("valibot").CheckIssue<{
@@ -321,6 +325,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
321
325
  }[] | undefined;
322
326
  fund_opt_in?: boolean | undefined;
323
327
  target?: string | undefined;
328
+ referral_id?: string | undefined;
324
329
  referrer?: string | undefined;
325
330
  referrer_expiry?: string | undefined;
326
331
  };
@@ -364,6 +369,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
364
369
  }[] | undefined;
365
370
  fund_opt_in?: boolean | undefined;
366
371
  target?: string | undefined;
372
+ referral_id?: string | undefined;
367
373
  referrer?: string | undefined;
368
374
  referrer_expiry?: string | undefined;
369
375
  };
@@ -413,6 +419,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
413
419
  }[], 4, undefined>]>, never>, never>;
414
420
  readonly fund_opt_in: import("valibot").OptionalSchema<import("valibot").OptionalSchema<import("valibot").BooleanSchema<undefined>, never>, never>;
415
421
  readonly target: import("valibot").OptionalSchema<import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").LiteralSchema<"smart", undefined>, import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TransformAction<string, number>, import("valibot").NumberSchema<undefined>, import("valibot").MinValueAction<number, 0, undefined>, import("valibot").TransformAction<number, string>]>], undefined>, never>, never>;
422
+ readonly referral_id: import("valibot").OptionalSchema<import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>, never>;
416
423
  readonly referrer: import("valibot").OptionalSchema<import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">]>, never>, never>;
417
424
  readonly referrer_expiry: import("valibot").OptionalSchema<import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").IsoTimestampAction<string, undefined>]>, never>, never>;
418
425
  readonly registration_number: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").NonEmptyAction<string, "required">, import("valibot").RegexAction<string, "must only contain letters and numbers">]>, never>;
@@ -463,6 +470,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
463
470
  }[] | undefined;
464
471
  fund_opt_in?: boolean | undefined;
465
472
  target?: string | undefined;
473
+ referral_id?: string | undefined;
466
474
  referrer?: string | undefined;
467
475
  referrer_expiry?: string | undefined;
468
476
  registration_number?: string | undefined;
@@ -514,6 +522,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
514
522
  }[] | undefined;
515
523
  fund_opt_in?: boolean | undefined;
516
524
  target?: string | undefined;
525
+ referral_id?: string | undefined;
517
526
  referrer?: string | undefined;
518
527
  referrer_expiry?: string | undefined;
519
528
  registration_number?: string | undefined;
@@ -557,6 +566,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
557
566
  }[] | undefined;
558
567
  fund_opt_in?: boolean | undefined;
559
568
  target?: string | undefined;
569
+ referral_id?: string | undefined;
560
570
  referrer?: string | undefined;
561
571
  referrer_expiry?: string | undefined;
562
572
  registration_number?: string | undefined;
@@ -581,7 +591,7 @@ export declare const endowUpdate: Omit<Omit<import("valibot").ObjectSchema<{
581
591
  }[], 4> | import("valibot").LiteralIssue | import("valibot").UnionIssue<import("valibot").StringIssue | import("valibot").NumberIssue | import("valibot").MinValueIssue<number, 0> | import("valibot").LiteralIssue> | import("valibot").IsoTimestampIssue<string>;
582
592
  } | undefined;
583
593
  };
584
- export declare const endowFields: import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "target", "referrer", "referrer_expiry", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only", "fiscal_sponsored"], undefined>;
594
+ export declare const endowFields: import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "target", "referral_id", "referrer", "referrer_expiry", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only", "fiscal_sponsored"], undefined>;
585
595
  export interface Endowment extends InferOutput<typeof endowment> {
586
596
  }
587
597
  export interface EndowUpdate extends InferOutput<typeof endowUpdate> {
@@ -589,7 +599,7 @@ export interface EndowUpdate extends InferOutput<typeof endowUpdate> {
589
599
  export type EndowFields = InferOutput<typeof endowFields>;
590
600
  /** for ein path, only fields in reg-num/env gsi is available */
591
601
  export declare const endowQueryParams: import("valibot").ObjectSchema<{
592
- readonly fields: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "target", "referrer", "referrer_expiry", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only", "fiscal_sponsored"], undefined>, undefined>]>, never>;
602
+ readonly fields: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").LazySchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]> | import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").RegexAction<string, "invalid csv">]>>, import("valibot").TransformAction<string, string[]>, import("valibot").FilterItemsAction<string[]>]>, import("valibot").ArraySchema<import("valibot").PicklistSchema<["url", "slug", "name", "overview", "tagline", "image", "logo", "card_img", "hq_country", "active_in_countries", "street_address", "sdgs", "receiptMsg", "hide_bg_tip", "published", "progDonationsAllowed", "allocation", "donateMethods", "increments", "fund_opt_in", "target", "referral_id", "referrer", "referrer_expiry", "id", "env", "registration_number", "endow_designation", "social_media_urls", "claimed", "kyc_donors_only", "fiscal_sponsored"], undefined>, undefined>]>, never>;
593
603
  }, undefined>;
594
604
  export interface EndowQueryParams extends InferInput<typeof endowQueryParams> {
595
605
  }
package/dist/schema.mjs CHANGED
@@ -90,6 +90,7 @@ export const endowment = object({
90
90
  claimed: boolean(),
91
91
  kyc_donors_only: boolean(),
92
92
  fiscal_sponsored: boolean(),
93
+ referral_id: optional(pipe(str, nonEmpty("required"))),
93
94
  referrer: optional(pipe(str, nonEmpty("required"))),
94
95
  referrer_expiry: optional(pipe(str, isoTimestamp())),
95
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-giving/endowment",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "peerDependencies": {
5
5
  "@better-giving/schemas": "1.1.2",
6
6
  "@better-giving/types": "1.1.3",
package/src/db.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Ensure } from "@better-giving/types/utils";
1
2
  import type {
2
3
  EndowId,
3
4
  Endowment as EndowmentShape,
@@ -41,7 +42,11 @@ export namespace Endow {
41
42
  };
42
43
 
43
44
  export type NonKeyAttributes = EndowmentShape & {
44
- referral_id: string;
45
+ /** referral id */
46
+ gsi1PK?: `ReferredBy#${string}`;
47
+ /** expiry / date onboarded */
48
+ gsi1SK?: string;
49
+
45
50
  /** will only be present for unclaimed NPOs */
46
51
  updated_at_auto?: string;
47
52
  /** in USD @deprecated */
@@ -91,9 +96,6 @@ export namespace Milestone {
91
96
  export interface DbRecord extends Keys, MilestoneShape {}
92
97
  }
93
98
 
94
- export const mediaGsi = {
95
- 1: "gsi1",
96
- } as const;
97
99
  export namespace Media {
98
100
  export interface Keys {
99
101
  PK: `Endow#${EndowId}#${Environment}`;
@@ -117,11 +119,23 @@ export namespace Media {
117
119
 
118
120
  export interface VideoDbRecord extends Keys, VideoAttributes {}
119
121
  export type DbRecord = VideoDbRecord; // | album | article
122
+ }
123
+
124
+ export namespace Gsi1 {
125
+ export namespace MediaList {
126
+ export interface Keys
127
+ extends Pick<Media.NonKeyAttributes, "gsi1PK" | "gsi1SK"> {}
128
+ export interface DbRecord extends Media.DbRecord {}
129
+ }
120
130
 
121
- export namespace Gsi1 {
122
- export type Name = (typeof mediaGsi)[1];
123
- export interface Keys extends Pick<NonKeyAttributes, "gsi1PK" | "gsi1SK"> {}
124
- export interface DbRecord extends Keys, NonKeyAttributes {}
131
+ export namespace ReferredNpos {
132
+ export interface Keys
133
+ extends Required<Pick<Endow.NonKeyAttributes, "gsi1PK" | "gsi1SK">> {}
134
+ export interface DbRecord
135
+ extends Ensure<
136
+ Endow.DbRecord,
137
+ "gsi1PK" | "gsi1SK" | "referrer" | "referrer_expiry"
138
+ > {}
125
139
  }
126
140
  }
127
141
 
package/src/schema.mts CHANGED
@@ -216,6 +216,7 @@ export const endowment = object({
216
216
  claimed: boolean(),
217
217
  kyc_donors_only: boolean(),
218
218
  fiscal_sponsored: boolean(),
219
+ referral_id: optional(pipe(str, nonEmpty("required"))),
219
220
  referrer: optional(pipe(str, nonEmpty("required"))),
220
221
  referrer_expiry: optional(pipe(str, isoTimestamp())),
221
222
  });