@better-giving/fundraiser 3.0.14 → 3.0.16
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.mjs +22 -16
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/package.json +1 -1
- package/src/db.mts +27 -17
- package/src/schema.mts +1 -1
package/dist/db.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BatchGetCommand, QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
|
-
import { Db, UpdateBuilder } from "@better-giving/db";
|
|
1
|
+
import { BatchGetCommand, GetCommand, QueryCommand, UpdateCommand, } from "@aws-sdk/lib-dynamodb";
|
|
2
|
+
import { Db, UpdateBuilder, } from "@better-giving/db";
|
|
3
3
|
import { UUID_REGEX } from "valibot";
|
|
4
4
|
export class FundDb extends Db {
|
|
5
5
|
static table = "funds";
|
|
@@ -24,24 +24,30 @@ export class FundDb extends Db {
|
|
|
24
24
|
}
|
|
25
25
|
/**@param id - slug or uuid */
|
|
26
26
|
async fund(id) {
|
|
27
|
-
|
|
28
|
-
TableName: FundDb.table,
|
|
29
|
-
Limit: 1,
|
|
30
|
-
};
|
|
27
|
+
let item;
|
|
31
28
|
if (UUID_REGEX.test(id)) {
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const cmd = new GetCommand({
|
|
30
|
+
TableName: FundDb.table,
|
|
31
|
+
Key: this.key_fund(id),
|
|
32
|
+
});
|
|
33
|
+
const res = await this.client.send(cmd);
|
|
34
|
+
item = res.Item;
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
const cmd = new QueryCommand({
|
|
38
|
+
TableName: FundDb.table,
|
|
39
|
+
Limit: 1,
|
|
40
|
+
IndexName: FundDb.slug_env_gsi,
|
|
41
|
+
KeyConditionExpression: "slug = :slug AND env = :env",
|
|
42
|
+
ExpressionAttributeValues: {
|
|
43
|
+
":slug": id,
|
|
44
|
+
":env": this.env,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const { Items: i = [] } = await this.client.send(cmd);
|
|
48
|
+
item = i[0];
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
return i[0] && this.sans_keys(i[0]);
|
|
50
|
+
return item && this.sans_keys(item);
|
|
45
51
|
}
|
|
46
52
|
async funds_get(ids) {
|
|
47
53
|
const cmd = new BatchGetCommand({
|
package/dist/schema.d.mts
CHANGED
|
@@ -134,7 +134,7 @@ export declare const funds_search: import("valibot").ObjectSchema<{
|
|
|
134
134
|
/** search text */
|
|
135
135
|
readonly query: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, never>;
|
|
136
136
|
/** input str: from url */
|
|
137
|
-
readonly page: import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, number>, import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>]>;
|
|
137
|
+
readonly page: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, number>, import("valibot").SchemaWithPipe<[import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>]>]>, never>;
|
|
138
138
|
}, undefined>;
|
|
139
139
|
export declare const funds_npo_memberof_search: import("valibot").ObjectSchema<{
|
|
140
140
|
readonly npo_profile_featured: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<[import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").TrimAction]>, import("valibot").TransformAction<string, boolean>, import("valibot").BooleanSchema<undefined>]>, never>;
|
package/dist/schema.mjs
CHANGED
package/package.json
CHANGED
package/src/db.mts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchGetCommand,
|
|
3
|
+
GetCommand,
|
|
3
4
|
QueryCommand,
|
|
4
|
-
type QueryCommandInput,
|
|
5
5
|
UpdateCommand,
|
|
6
6
|
} from "@aws-sdk/lib-dynamodb";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Db,
|
|
9
|
+
type TRecord,
|
|
10
|
+
type TxType,
|
|
11
|
+
UpdateBuilder,
|
|
12
|
+
} from "@better-giving/db";
|
|
8
13
|
import { UUID_REGEX } from "valibot";
|
|
9
14
|
import type { IFund } from "./interfaces.mjs";
|
|
10
15
|
import type { IFundUpdate } from "./schema.mjs";
|
|
@@ -32,24 +37,29 @@ export class FundDb extends Db {
|
|
|
32
37
|
}
|
|
33
38
|
/**@param id - slug or uuid */
|
|
34
39
|
async fund(id: string): Promise<IFund | undefined> {
|
|
35
|
-
|
|
36
|
-
TableName: FundDb.table,
|
|
37
|
-
Limit: 1,
|
|
38
|
-
};
|
|
40
|
+
let item: TRecord | undefined;
|
|
39
41
|
if (UUID_REGEX.test(id)) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const cmd = new GetCommand({
|
|
43
|
+
TableName: FundDb.table,
|
|
44
|
+
Key: this.key_fund(id),
|
|
45
|
+
});
|
|
46
|
+
const res = await this.client.send(cmd);
|
|
47
|
+
item = res.Item;
|
|
42
48
|
} else {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
const cmd = new QueryCommand({
|
|
50
|
+
TableName: FundDb.table,
|
|
51
|
+
Limit: 1,
|
|
52
|
+
IndexName: FundDb.slug_env_gsi,
|
|
53
|
+
KeyConditionExpression: "slug = :slug AND env = :env",
|
|
54
|
+
ExpressionAttributeValues: {
|
|
55
|
+
":slug": id,
|
|
56
|
+
":env": this.env,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const { Items: i = [] } = await this.client.send(cmd);
|
|
60
|
+
item = i[0];
|
|
49
61
|
}
|
|
50
|
-
|
|
51
|
-
const { Items: i = [] } = await this.client.send(new QueryCommand(q));
|
|
52
|
-
return i[0] && this.sans_keys(i[0]);
|
|
62
|
+
return item && this.sans_keys(item);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
async funds_get(ids: string[]): Promise<IFund[]> {
|