@better-giving/endowment 3.0.2 → 3.0.4
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 +1 -0
- package/dist/db.mjs +14 -0
- package/dist/schema.d.mts +12 -15
- package/dist/schema.mjs +2 -9
- package/package.json +1 -1
- package/src/db.mts +17 -0
- package/src/schema.mts +2 -0
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,5 +1,5 @@
|
|
|
1
|
-
import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, int_gte1, org_designation, unsdg_num } from "@better-giving/schemas";
|
|
2
|
-
export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, };
|
|
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
|
+
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;
|
|
5
5
|
export declare const csv: v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.RegexAction<string, "invalid csv">]>>;
|
|
@@ -15,9 +15,6 @@ export declare const allocation: v.SchemaWithPipe<[v.ObjectSchema<{
|
|
|
15
15
|
}, "must total to 100">]>;
|
|
16
16
|
export interface IAllocation extends v.InferOutput<typeof allocation> {
|
|
17
17
|
}
|
|
18
|
-
export declare const segment_max_chars = 30;
|
|
19
|
-
export declare const segment: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: v.MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>;
|
|
20
|
-
export declare const slug: v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: v.MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>>;
|
|
21
18
|
export declare const reg_number: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">, v.RegexAction<string, "must only contain letters and numbers">]>;
|
|
22
19
|
export declare const _url: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UrlAction<string, undefined>]>;
|
|
23
20
|
export declare const social_media_urls: v.ObjectSchema<{
|
|
@@ -46,7 +43,7 @@ export interface IIncrement extends v.InferOutput<typeof increment> {
|
|
|
46
43
|
export declare const npo: v.ObjectSchema<{
|
|
47
44
|
readonly id: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
48
45
|
readonly env: v.PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
49
|
-
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }:
|
|
46
|
+
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>>, never>;
|
|
50
47
|
readonly registration_number: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">, v.RegexAction<string, "must only contain letters and numbers">]>;
|
|
51
48
|
readonly name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">]>;
|
|
52
49
|
readonly endow_designation: v.PicklistSchema<readonly ["Charity", "Religious Organization", "University", "Hospital", "Other"], undefined>;
|
|
@@ -107,7 +104,7 @@ export declare const npo: v.ObjectSchema<{
|
|
|
107
104
|
export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
108
105
|
readonly id: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
109
106
|
readonly env: v.PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
110
|
-
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }:
|
|
107
|
+
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>>, never>;
|
|
111
108
|
readonly registration_number: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">, v.RegexAction<string, "must only contain letters and numbers">]>;
|
|
112
109
|
readonly name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">]>;
|
|
113
110
|
readonly endow_designation: v.PicklistSchema<readonly ["Charity", "Religious Organization", "University", "Hospital", "Other"], undefined>;
|
|
@@ -168,7 +165,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
168
165
|
readonly entries: Omit<{
|
|
169
166
|
readonly id: v.SchemaWithPipe<[v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
170
167
|
readonly env: v.PicklistSchema<readonly ["staging", "production"], undefined>;
|
|
171
|
-
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }:
|
|
168
|
+
readonly slug: v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>>, never>;
|
|
172
169
|
readonly registration_number: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">, v.RegexAction<string, "must only contain letters and numbers">]>;
|
|
173
170
|
readonly name: v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">]>;
|
|
174
171
|
readonly endow_designation: v.PicklistSchema<readonly ["Charity", "Religious Organization", "University", "Hospital", "Other"], undefined>;
|
|
@@ -230,7 +227,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
230
227
|
cash: number;
|
|
231
228
|
liq: number;
|
|
232
229
|
lock: number;
|
|
233
|
-
}> | v.
|
|
230
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
234
231
|
value: string;
|
|
235
232
|
label: string;
|
|
236
233
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>>): v.Dataset<{
|
|
@@ -282,7 +279,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
282
279
|
cash: number;
|
|
283
280
|
liq: number;
|
|
284
281
|
lock: number;
|
|
285
|
-
}> | v.
|
|
282
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
286
283
|
value: string;
|
|
287
284
|
label: string;
|
|
288
285
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>>;
|
|
@@ -383,7 +380,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
383
380
|
cash: number;
|
|
384
381
|
liq: number;
|
|
385
382
|
lock: number;
|
|
386
|
-
}> | v.
|
|
383
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
387
384
|
value: string;
|
|
388
385
|
label: string;
|
|
389
386
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>;
|
|
@@ -391,7 +388,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
391
388
|
}, "_run" | "_types" | "entries"> & {
|
|
392
389
|
readonly entries: {
|
|
393
390
|
readonly url: v.OptionalSchema<v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.NonEmptyAction<string, "required">]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.TransformAction<string, string>, v.UrlAction<string, "invalid url">]>>, never>, never>;
|
|
394
|
-
readonly slug: v.OptionalSchema<v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }:
|
|
391
|
+
readonly slug: v.OptionalSchema<v.OptionalSchema<v.LazySchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]> | v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 30, ({ requirement: r }: import("valibot").MaxLengthIssue<string, 30>) => string>, v.RegexAction<string, "should not be an id">, v.RegexAction<string, "allowed: numbers | letters | - | . | _ | ~">, v.ExcludesAction<string, "..", "should not contain double periods">, v.CustomSchema<string, "should not start with dot">, v.CustomSchema<string, "should not end with dot">]>>, never>, never>;
|
|
395
392
|
readonly overview: v.OptionalSchema<v.OptionalSchema<v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, never>, never>;
|
|
396
393
|
readonly tagline: v.OptionalSchema<v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.MaxLengthAction<string, 140, undefined>]>, never>, never>;
|
|
397
394
|
readonly image: v.OptionalSchema<v.OptionalSchema<v.SchemaWithPipe<[v.SchemaWithPipe<[v.StringSchema<undefined>, v.TrimAction]>, v.UrlAction<string, undefined>]>, never>, never>;
|
|
@@ -446,7 +443,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
446
443
|
cash: number;
|
|
447
444
|
liq: number;
|
|
448
445
|
lock: number;
|
|
449
|
-
}> | v.
|
|
446
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
450
447
|
value: string;
|
|
451
448
|
label: string;
|
|
452
449
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>>): v.Dataset<{
|
|
@@ -498,7 +495,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
498
495
|
cash: number;
|
|
499
496
|
liq: number;
|
|
500
497
|
lock: number;
|
|
501
|
-
}> | v.
|
|
498
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
502
499
|
value: string;
|
|
503
500
|
label: string;
|
|
504
501
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>>;
|
|
@@ -599,7 +596,7 @@ export declare const npo_update: Omit<Omit<v.ObjectSchema<{
|
|
|
599
596
|
cash: number;
|
|
600
597
|
liq: number;
|
|
601
598
|
lock: number;
|
|
602
|
-
}> | v.
|
|
599
|
+
}> | v.NonEmptyIssue<string> | v.UrlIssue<string> | v.MaxLengthIssue<string, 60> | v.PicklistIssue | v.CustomIssue | v.MaxLengthIssue<string, 30> | v.ExcludesIssue<string, ".."> | v.MaxLengthIssue<string, 140> | v.ArrayIssue | v.NonEmptyIssue<string[]> | v.MinLengthIssue<(2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17)[], 1> | v.MaxLengthIssue<string, 500> | v.BooleanIssue | v.MaxLengthIssue<{
|
|
603
600
|
value: string;
|
|
604
601
|
label: string;
|
|
605
602
|
}[], 4> | v.LiteralIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.MinValueIssue<number, 0> | v.LiteralIssue> | v.IsoTimestampIssue<string> | v.MinValueIssue<number, 50>;
|
package/dist/schema.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $, $int_gte1, $req, $req_num_gt0, donate_method_id, donate_method_ids, env, https_url, int_gte1, org_designation, unsdg_num, } from "@better-giving/schemas";
|
|
2
|
-
export { org_designation as endow_designation, env, unsdg_num, donate_method_id, donate_method_ids, $int_gte1, int_gte1, $, $req_num_gt0, $req, };
|
|
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
|
+
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;
|
|
5
5
|
export const csv = v.lazy((x) => {
|
|
@@ -14,13 +14,6 @@ export const allocation = v.pipe(v.object({
|
|
|
14
14
|
liq: pct,
|
|
15
15
|
lock: pct,
|
|
16
16
|
}), v.check((x) => x.cash + x.liq + x.lock === 100, "must total to 100"));
|
|
17
|
-
export const segment_max_chars = 30;
|
|
18
|
-
export const segment = v.pipe($, v.maxLength(segment_max_chars, ({ requirement: r }) => `cannot exceed ${r} chars`),
|
|
19
|
-
//must not be id-like
|
|
20
|
-
v.regex(/^(?!^\d+$)/, "should not be an id"),
|
|
21
|
-
//valid characters
|
|
22
|
-
v.regex(/^[a-zA-Z0-9-._~]+$/, "allowed: numbers | letters | - | . | _ | ~"), v.excludes("..", "should not contain double periods"), v.custom((x) => !x.startsWith("."), "should not start with dot"), v.custom((x) => !x.endsWith("."), "should not end with dot"));
|
|
23
|
-
export const slug = v.lazy((x) => (x ? segment : $));
|
|
24
17
|
export const reg_number = v.pipe($, v.nonEmpty("required"), v.regex(/^[a-zA-Z0-9]+$/, "must only contain letters and numbers"));
|
|
25
18
|
export const _url = v.pipe($, v.url());
|
|
26
19
|
export const social_media_urls = v.object({
|
package/package.json
CHANGED
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);
|
package/src/schema.mts
CHANGED