@monorise/core 3.0.4 → 3.2.0
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/index.d.ts +60 -5
- package/dist/index.js +303 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, U
|
|
|
5
5
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
6
6
|
import * as hono_utils_types from 'hono/utils/types';
|
|
7
7
|
import { createFactory } from 'hono/factory';
|
|
8
|
-
import
|
|
8
|
+
import httpStatus8 from 'http-status';
|
|
9
9
|
import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
|
|
10
10
|
import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
|
|
11
11
|
import * as hono_aws_lambda from 'hono/aws-lambda';
|
|
@@ -53,6 +53,19 @@ declare abstract class Repository {
|
|
|
53
53
|
ExpressionAttributeNames: Record<string, string>;
|
|
54
54
|
ExpressionAttributeValues: Record<string, AttributeValue>;
|
|
55
55
|
};
|
|
56
|
+
toAdjustUpdate(adjustments: Record<string, number>, constraints?: {
|
|
57
|
+
[field: string]: {
|
|
58
|
+
min?: number;
|
|
59
|
+
max?: number;
|
|
60
|
+
minField?: string;
|
|
61
|
+
maxField?: string;
|
|
62
|
+
};
|
|
63
|
+
}, prefix?: string): {
|
|
64
|
+
UpdateExpression: string;
|
|
65
|
+
ConditionExpression?: string;
|
|
66
|
+
ExpressionAttributeNames: Record<string, string>;
|
|
67
|
+
ExpressionAttributeValues: Record<string, AttributeValue>;
|
|
68
|
+
};
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
declare class Entity$1<T extends Entity$2> extends Item$1 {
|
|
@@ -119,6 +132,12 @@ declare class EntityRepository extends Repository {
|
|
|
119
132
|
ExpressionAttributeNames?: Record<string, string>;
|
|
120
133
|
ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
121
134
|
}): Promise<Entity$1<T>>;
|
|
135
|
+
adjustEntity<T extends Entity$2>(entityType: T, entityId: string, adjustments: Record<string, number>, constraints?: {
|
|
136
|
+
[field: string]: {
|
|
137
|
+
min?: number;
|
|
138
|
+
max?: number;
|
|
139
|
+
};
|
|
140
|
+
}): Promise<Entity$1<T>>;
|
|
122
141
|
deleteEntity<T extends Entity$2>(entityType: T, entityId: string): Promise<void>;
|
|
123
142
|
queryEntities<T extends Entity$2>(entityType: T, query: string): Promise<{
|
|
124
143
|
items: Entity$1<T>[];
|
|
@@ -446,10 +465,10 @@ factory.createMiddleware((c, next) => __async(null, null, function* () {
|
|
|
446
465
|
return yield next();
|
|
447
466
|
}
|
|
448
467
|
if (!xApiKey || Array.isArray(xApiKey) || !API_KEYS.includes(xApiKey)) {
|
|
449
|
-
c.status(
|
|
468
|
+
c.status(httpStatus8.UNAUTHORIZED);
|
|
450
469
|
return c.json({
|
|
451
|
-
status:
|
|
452
|
-
message:
|
|
470
|
+
status: httpStatus8.UNAUTHORIZED,
|
|
471
|
+
message: httpStatus8["401_MESSAGE"]
|
|
453
472
|
});
|
|
454
473
|
}
|
|
455
474
|
return yield next();
|
|
@@ -4427,6 +4446,26 @@ external_exports.object({
|
|
|
4427
4446
|
lastKey: external_exports.string().optional()
|
|
4428
4447
|
});
|
|
4429
4448
|
|
|
4449
|
+
type WhereOperator = {
|
|
4450
|
+
$eq: string | number | boolean;
|
|
4451
|
+
} | {
|
|
4452
|
+
$ne: string | number | boolean;
|
|
4453
|
+
} | {
|
|
4454
|
+
$gt: number;
|
|
4455
|
+
} | {
|
|
4456
|
+
$lt: number;
|
|
4457
|
+
} | {
|
|
4458
|
+
$gte: number;
|
|
4459
|
+
} | {
|
|
4460
|
+
$lte: number;
|
|
4461
|
+
} | {
|
|
4462
|
+
$exists: boolean;
|
|
4463
|
+
} | {
|
|
4464
|
+
$beginsWith: string;
|
|
4465
|
+
};
|
|
4466
|
+
type WhereClause = WhereOperator | string | number | boolean;
|
|
4467
|
+
type WhereConditions = Record<string, WhereClause>;
|
|
4468
|
+
|
|
4430
4469
|
declare class EntityServiceLifeCycle {
|
|
4431
4470
|
private EntityConfig;
|
|
4432
4471
|
private publishEvent;
|
|
@@ -4452,11 +4491,18 @@ declare class EntityService {
|
|
|
4452
4491
|
mutualId?: string;
|
|
4453
4492
|
};
|
|
4454
4493
|
}) => Promise<Entity<T>>;
|
|
4455
|
-
|
|
4494
|
+
adjustEntity: <T extends Entity$2>({ entityType, entityId, adjustments, accountId, }: {
|
|
4495
|
+
entityType: T;
|
|
4496
|
+
entityId: string;
|
|
4497
|
+
adjustments: Record<string, number>;
|
|
4498
|
+
accountId?: string;
|
|
4499
|
+
}) => Promise<Entity<T>>;
|
|
4500
|
+
updateEntity: <T extends Entity$2>({ entityType, entityId, entityPayload, accountId, where, }: {
|
|
4456
4501
|
entityType: T;
|
|
4457
4502
|
entityId: string;
|
|
4458
4503
|
entityPayload: Partial<EntitySchemaMap[T]>;
|
|
4459
4504
|
accountId?: string | string[];
|
|
4505
|
+
where?: WhereConditions;
|
|
4460
4506
|
}) => Promise<Entity<T>>;
|
|
4461
4507
|
deleteEntity: <T extends Entity$2>({ entityType, entityId, accountId, }: {
|
|
4462
4508
|
entityType: T;
|
|
@@ -4518,6 +4564,14 @@ declare class UpdateEntityController {
|
|
|
4518
4564
|
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
4519
4565
|
}
|
|
4520
4566
|
|
|
4567
|
+
declare class AdjustEntityController {
|
|
4568
|
+
private entityService;
|
|
4569
|
+
constructor(entityService: EntityService);
|
|
4570
|
+
controller: hono.MiddlewareHandler<any, string, {}, Response & hono.TypedResponse<{
|
|
4571
|
+
[x: string]: hono_utils_types.JSONValue;
|
|
4572
|
+
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
4573
|
+
}
|
|
4574
|
+
|
|
4521
4575
|
declare class UpsertEntityController {
|
|
4522
4576
|
private EntityConfig;
|
|
4523
4577
|
private entityRepository;
|
|
@@ -4673,6 +4727,7 @@ declare class DependencyContainer {
|
|
|
4673
4727
|
get createEntityController(): CreateEntityController;
|
|
4674
4728
|
get upsertEntityController(): UpsertEntityController;
|
|
4675
4729
|
get updateEntityController(): UpdateEntityController;
|
|
4730
|
+
get adjustEntityController(): AdjustEntityController;
|
|
4676
4731
|
get deleteEntityController(): DeleteEntityController;
|
|
4677
4732
|
get listEntitiesByEntityController(): ListEntitiesByEntityController;
|
|
4678
4733
|
get getMutualController(): GetMutualController;
|