monorise 1.15.0-dev.0 → 2.0.0-dev.1
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/base/index.d.ts +10 -2
- package/dist/base/index.js +3 -1
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +4 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/templates/files/api-keys.ts +12 -0
- package/dist/cli/templates/files/monorise.config.ts +2 -0
- package/dist/core/index.d.ts +8 -16
- package/dist/core/index.js +42 -82
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/proxy/index.d.ts +5 -0
- package/dist/proxy/index.js +64 -13
- package/dist/proxy/index.js.map +1 -1
- package/dist/react/index.d.ts +2 -164
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +46 -188
- package/dist/react/index.js.map +1 -1
- package/dist/react/lib/api.d.ts +1 -2
- package/dist/react/lib/api.d.ts.map +1 -1
- package/dist/react/store/monorise.store.d.ts +0 -54
- package/dist/react/store/monorise.store.d.ts.map +1 -1
- package/dist/sst/components/monorise-core.d.ts.map +1 -1
- package/dist/sst/index.js +4 -1
- package/dist/sst/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/react/actions/auth.action.d.ts +0 -24
- package/dist/react/actions/auth.action.d.ts.map +0 -1
- package/dist/react/services/auth.service.d.ts +0 -21
- package/dist/react/services/auth.service.d.ts.map +0 -1
package/dist/core/index.js
CHANGED
|
@@ -2776,6 +2776,7 @@ import { secureHeaders } from "hono/secure-headers";
|
|
|
2776
2776
|
// middlewares/api-key-auth.ts
|
|
2777
2777
|
import { createHash } from "crypto";
|
|
2778
2778
|
import {
|
|
2779
|
+
DEFAULT_API_KEY_POLICY,
|
|
2779
2780
|
FULL_API_KEY_POLICY,
|
|
2780
2781
|
compileApiKeyPolicy,
|
|
2781
2782
|
validateApiKeyPolicies
|
|
@@ -2829,7 +2830,11 @@ var assertKeyList = (value, where) => {
|
|
|
2829
2830
|
}
|
|
2830
2831
|
return value;
|
|
2831
2832
|
};
|
|
2832
|
-
var
|
|
2833
|
+
var BUILT_IN_POLICIES = [
|
|
2834
|
+
FULL_API_KEY_POLICY,
|
|
2835
|
+
DEFAULT_API_KEY_POLICY
|
|
2836
|
+
];
|
|
2837
|
+
var parseApiKeys = (raw, definedPolicies = BUILT_IN_POLICIES) => {
|
|
2833
2838
|
var _a;
|
|
2834
2839
|
const fingerprints = /* @__PURE__ */ new Map();
|
|
2835
2840
|
if (!raw) return fingerprints;
|
|
@@ -2915,10 +2920,14 @@ var apiKeyAuth = ({
|
|
|
2915
2920
|
- ${errors.join("\n - ")}`
|
|
2916
2921
|
);
|
|
2917
2922
|
}
|
|
2923
|
+
const projectDefinesDefault = Object.prototype.hasOwnProperty.call(
|
|
2924
|
+
policies,
|
|
2925
|
+
DEFAULT_API_KEY_POLICY
|
|
2926
|
+
);
|
|
2918
2927
|
return createApiKeyAuth(
|
|
2919
2928
|
parseApiKeys(
|
|
2920
2929
|
apiKeys2,
|
|
2921
|
-
errors.length ? [FULL_API_KEY_POLICY] : [
|
|
2930
|
+
errors.length ? projectDefinesDefault ? [FULL_API_KEY_POLICY] : BUILT_IN_POLICIES : [...BUILT_IN_POLICIES, ...Object.keys(policies)]
|
|
2922
2931
|
),
|
|
2923
2932
|
policies
|
|
2924
2933
|
);
|
|
@@ -3319,7 +3328,7 @@ var handler = (container) => (ev) => __async(null, null, function* () {
|
|
|
3319
3328
|
const errorContext = {};
|
|
3320
3329
|
const body = parseSQSBusEvent(record.body);
|
|
3321
3330
|
const { detail } = body;
|
|
3322
|
-
const { entityType, entityId, entityPayload,
|
|
3331
|
+
const { entityType, entityId, entityPayload, options } = detail;
|
|
3323
3332
|
errorContext.body = body;
|
|
3324
3333
|
try {
|
|
3325
3334
|
if (!entityType) {
|
|
@@ -3329,7 +3338,6 @@ var handler = (container) => (ev) => __async(null, null, function* () {
|
|
|
3329
3338
|
entityType,
|
|
3330
3339
|
entityId,
|
|
3331
3340
|
entityPayload,
|
|
3332
|
-
accountId,
|
|
3333
3341
|
options
|
|
3334
3342
|
});
|
|
3335
3343
|
} catch (err) {
|
|
@@ -8149,8 +8157,7 @@ var MutualService = class {
|
|
|
8149
8157
|
byEntityId,
|
|
8150
8158
|
entityType,
|
|
8151
8159
|
entityId,
|
|
8152
|
-
mutualPayload
|
|
8153
|
-
accountId
|
|
8160
|
+
mutualPayload
|
|
8154
8161
|
} = params;
|
|
8155
8162
|
const { mutual, entity, transactItems, parsedMutualPayload } = yield this.prepareCreateMutual(params);
|
|
8156
8163
|
console.log("[MONORISE_DEBUG] createMutual executing transaction:", {
|
|
@@ -8163,8 +8170,7 @@ var MutualService = class {
|
|
|
8163
8170
|
if (entity) {
|
|
8164
8171
|
yield this.entityServiceLifeCycle.afterCreateEntityHook(
|
|
8165
8172
|
entity,
|
|
8166
|
-
mutualPayload
|
|
8167
|
-
accountId
|
|
8173
|
+
mutualPayload
|
|
8168
8174
|
);
|
|
8169
8175
|
}
|
|
8170
8176
|
const eventPayload = {
|
|
@@ -8173,7 +8179,6 @@ var MutualService = class {
|
|
|
8173
8179
|
entityType,
|
|
8174
8180
|
entityId,
|
|
8175
8181
|
parsedMutualPayload,
|
|
8176
|
-
accountId,
|
|
8177
8182
|
publishedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8178
8183
|
};
|
|
8179
8184
|
const eventPromises = [
|
|
@@ -8248,7 +8253,6 @@ var MutualService = class {
|
|
|
8248
8253
|
entityType,
|
|
8249
8254
|
entityId,
|
|
8250
8255
|
mutualPayload,
|
|
8251
|
-
accountId,
|
|
8252
8256
|
options
|
|
8253
8257
|
}) {
|
|
8254
8258
|
console.log("[MONORISE_DEBUG] updateMutual service start:", {
|
|
@@ -8283,8 +8287,7 @@ var MutualService = class {
|
|
|
8283
8287
|
byEntityId,
|
|
8284
8288
|
entityType,
|
|
8285
8289
|
entityId,
|
|
8286
|
-
parsedMutualPayload
|
|
8287
|
-
updatedByAccountId: accountId
|
|
8290
|
+
parsedMutualPayload
|
|
8288
8291
|
}
|
|
8289
8292
|
});
|
|
8290
8293
|
console.log("[MONORISE_DEBUG] updateMutual service complete");
|
|
@@ -8324,8 +8327,7 @@ var MutualService = class {
|
|
|
8324
8327
|
byEntityType,
|
|
8325
8328
|
byEntityId,
|
|
8326
8329
|
entityType,
|
|
8327
|
-
entityId
|
|
8328
|
-
accountId
|
|
8330
|
+
entityId
|
|
8329
8331
|
}) {
|
|
8330
8332
|
const mutual = yield this.mutualRepository.deleteMutual(
|
|
8331
8333
|
byEntityType,
|
|
@@ -8339,8 +8341,7 @@ var MutualService = class {
|
|
|
8339
8341
|
byEntityType,
|
|
8340
8342
|
byEntityId,
|
|
8341
8343
|
entityType,
|
|
8342
|
-
entityId
|
|
8343
|
-
deletedByAccountId: accountId
|
|
8344
|
+
entityId
|
|
8344
8345
|
}
|
|
8345
8346
|
});
|
|
8346
8347
|
return mutual;
|
|
@@ -9716,7 +9717,6 @@ var CreateEntityController = class {
|
|
|
9716
9717
|
constructor(entityService) {
|
|
9717
9718
|
this.entityService = entityService;
|
|
9718
9719
|
this.controller = createMiddleware5((c) => __async(this, null, function* () {
|
|
9719
|
-
const accountId = c.req.header("account-id");
|
|
9720
9720
|
const { entityType } = c.req.param();
|
|
9721
9721
|
const body = yield c.req.json();
|
|
9722
9722
|
try {
|
|
@@ -9724,7 +9724,6 @@ var CreateEntityController = class {
|
|
|
9724
9724
|
entityType,
|
|
9725
9725
|
entityPayload: body,
|
|
9726
9726
|
entityId: body.entityId,
|
|
9727
|
-
accountId,
|
|
9728
9727
|
options: {
|
|
9729
9728
|
createAndUpdateDatetime: body.createdAt
|
|
9730
9729
|
}
|
|
@@ -9768,13 +9767,11 @@ var DeleteEntityController = class {
|
|
|
9768
9767
|
constructor(entityService) {
|
|
9769
9768
|
this.entityService = entityService;
|
|
9770
9769
|
this.controller = createMiddleware6((c) => __async(this, null, function* () {
|
|
9771
|
-
const accountId = c.req.header("account-id");
|
|
9772
9770
|
const { entityType, entityId } = c.req.param();
|
|
9773
9771
|
try {
|
|
9774
9772
|
yield this.entityService.deleteEntity({
|
|
9775
9773
|
entityType,
|
|
9776
|
-
entityId
|
|
9777
|
-
accountId
|
|
9774
|
+
entityId
|
|
9778
9775
|
});
|
|
9779
9776
|
return c.json({ message: "entity deleted" });
|
|
9780
9777
|
} catch (err) {
|
|
@@ -9861,13 +9858,8 @@ var ListEntitiesController = class {
|
|
|
9861
9858
|
this.controller = createMiddleware9((c) => __async(this, null, function* () {
|
|
9862
9859
|
const errorContext = {};
|
|
9863
9860
|
try {
|
|
9864
|
-
const accountId = c.req.header("account-id") || "";
|
|
9865
|
-
if (Array.isArray(accountId)) {
|
|
9866
|
-
throw new Error("multiple account-id detected");
|
|
9867
|
-
}
|
|
9868
9861
|
const params = c.req.param();
|
|
9869
9862
|
const queries2 = c.req.query();
|
|
9870
|
-
errorContext.accountId = accountId;
|
|
9871
9863
|
errorContext.params = params;
|
|
9872
9864
|
errorContext.query = queries2;
|
|
9873
9865
|
const { entityType } = params;
|
|
@@ -9912,7 +9904,6 @@ var UpdateEntityController = class {
|
|
|
9912
9904
|
constructor(entityService) {
|
|
9913
9905
|
this.entityService = entityService;
|
|
9914
9906
|
this.controller = createMiddleware10((c) => __async(this, null, function* () {
|
|
9915
|
-
const accountId = c.req.header("account-id");
|
|
9916
9907
|
const { entityType, entityId } = c.req.param();
|
|
9917
9908
|
const body = yield c.req.json();
|
|
9918
9909
|
const _a = body, { $condition: condition, $where: where } = _a, entityPayload = __objRest(_a, ["$condition", "$where"]);
|
|
@@ -9926,7 +9917,6 @@ var UpdateEntityController = class {
|
|
|
9926
9917
|
}
|
|
9927
9918
|
}
|
|
9928
9919
|
const errorContext = {
|
|
9929
|
-
accountId,
|
|
9930
9920
|
"req.params": c.req.param(),
|
|
9931
9921
|
"req.body": body
|
|
9932
9922
|
};
|
|
@@ -9935,7 +9925,6 @@ var UpdateEntityController = class {
|
|
|
9935
9925
|
entityType,
|
|
9936
9926
|
entityId,
|
|
9937
9927
|
entityPayload,
|
|
9938
|
-
accountId,
|
|
9939
9928
|
condition,
|
|
9940
9929
|
where
|
|
9941
9930
|
});
|
|
@@ -9986,7 +9975,6 @@ var AdjustEntityController = class {
|
|
|
9986
9975
|
this.entityService = entityService;
|
|
9987
9976
|
this.controller = createMiddleware11((c) => __async(this, null, function* () {
|
|
9988
9977
|
var _b;
|
|
9989
|
-
const accountId = c.req.header("account-id") || "";
|
|
9990
9978
|
const { entityType, entityId } = c.req.param();
|
|
9991
9979
|
const body = yield c.req.json();
|
|
9992
9980
|
const _a = body, { $condition: condition } = _a, adjustments = __objRest(_a, ["$condition"]);
|
|
@@ -10013,7 +10001,6 @@ var AdjustEntityController = class {
|
|
|
10013
10001
|
entityType,
|
|
10014
10002
|
entityId,
|
|
10015
10003
|
adjustments,
|
|
10016
|
-
accountId,
|
|
10017
10004
|
condition
|
|
10018
10005
|
});
|
|
10019
10006
|
c.status(httpStatus11.OK);
|
|
@@ -10051,7 +10038,6 @@ var UpsertEntityController = class {
|
|
|
10051
10038
|
this.publishEvent = publishEvent2;
|
|
10052
10039
|
this.controller = createMiddleware12((c) => __async(this, null, function* () {
|
|
10053
10040
|
var _a;
|
|
10054
|
-
const accountId = c.req.header("account-id");
|
|
10055
10041
|
const { entityType, entityId } = c.req.param();
|
|
10056
10042
|
try {
|
|
10057
10043
|
const entityConfig = this.EntityConfig[entityType];
|
|
@@ -10107,8 +10093,7 @@ var UpsertEntityController = class {
|
|
|
10107
10093
|
payload: {
|
|
10108
10094
|
entityType,
|
|
10109
10095
|
entityId: entity.entityId,
|
|
10110
|
-
payload: body
|
|
10111
|
-
createdByAccountId: accountId
|
|
10096
|
+
payload: body
|
|
10112
10097
|
}
|
|
10113
10098
|
});
|
|
10114
10099
|
return c.json(entity);
|
|
@@ -10138,7 +10123,6 @@ var CreateMutualController = class {
|
|
|
10138
10123
|
constructor(mutualService) {
|
|
10139
10124
|
this.mutualService = mutualService;
|
|
10140
10125
|
this.controller = createMiddleware13((c) => __async(this, null, function* () {
|
|
10141
|
-
const accountId = c.req.header("account-id");
|
|
10142
10126
|
const { byEntityType, byEntityId, entityType, entityId } = c.req.param();
|
|
10143
10127
|
const asEntity = c.req.query("asEntity");
|
|
10144
10128
|
const body = yield c.req.json();
|
|
@@ -10149,7 +10133,6 @@ var CreateMutualController = class {
|
|
|
10149
10133
|
entityType,
|
|
10150
10134
|
entityId,
|
|
10151
10135
|
mutualPayload: body,
|
|
10152
|
-
accountId,
|
|
10153
10136
|
options: {
|
|
10154
10137
|
asEntity
|
|
10155
10138
|
}
|
|
@@ -10185,15 +10168,13 @@ var DeleteMutualController = class {
|
|
|
10185
10168
|
constructor(mutualService) {
|
|
10186
10169
|
this.mutualService = mutualService;
|
|
10187
10170
|
this.controller = createMiddleware14((c) => __async(this, null, function* () {
|
|
10188
|
-
const accountId = c.req.header("account-id");
|
|
10189
10171
|
const { byEntityType, byEntityId, entityType, entityId } = c.req.param();
|
|
10190
10172
|
try {
|
|
10191
10173
|
const mutual = yield this.mutualService.deleteMutual({
|
|
10192
10174
|
byEntityType,
|
|
10193
10175
|
byEntityId,
|
|
10194
10176
|
entityType,
|
|
10195
|
-
entityId
|
|
10196
|
-
accountId
|
|
10177
|
+
entityId
|
|
10197
10178
|
});
|
|
10198
10179
|
return c.json(mutual);
|
|
10199
10180
|
} catch (err) {
|
|
@@ -10306,7 +10287,6 @@ var UpdateMutualController = class {
|
|
|
10306
10287
|
constructor(mutualService) {
|
|
10307
10288
|
this.mutualService = mutualService;
|
|
10308
10289
|
this.controller = createMiddleware17((c) => __async(this, null, function* () {
|
|
10309
|
-
const accountId = c.req.header("account-id");
|
|
10310
10290
|
const { byEntityType, byEntityId, entityType, entityId } = c.req.param();
|
|
10311
10291
|
const body = yield c.req.json();
|
|
10312
10292
|
try {
|
|
@@ -10316,7 +10296,6 @@ var UpdateMutualController = class {
|
|
|
10316
10296
|
entityType,
|
|
10317
10297
|
entityId,
|
|
10318
10298
|
mutualPayload: body,
|
|
10319
|
-
accountId,
|
|
10320
10299
|
options: {
|
|
10321
10300
|
returnUpdatedValue: true
|
|
10322
10301
|
}
|
|
@@ -10492,7 +10471,6 @@ var EntityService = class {
|
|
|
10492
10471
|
entityType,
|
|
10493
10472
|
entityId,
|
|
10494
10473
|
entityPayload,
|
|
10495
|
-
accountId,
|
|
10496
10474
|
options
|
|
10497
10475
|
}) {
|
|
10498
10476
|
var _a, _b;
|
|
@@ -10526,8 +10504,7 @@ var EntityService = class {
|
|
|
10526
10504
|
);
|
|
10527
10505
|
yield this.entityServiceLifeCycle.afterCreateEntityHook(
|
|
10528
10506
|
entity,
|
|
10529
|
-
entityPayload
|
|
10530
|
-
accountId
|
|
10507
|
+
entityPayload
|
|
10531
10508
|
);
|
|
10532
10509
|
return entity;
|
|
10533
10510
|
});
|
|
@@ -10535,7 +10512,6 @@ var EntityService = class {
|
|
|
10535
10512
|
entityType,
|
|
10536
10513
|
entityId,
|
|
10537
10514
|
adjustments,
|
|
10538
|
-
accountId,
|
|
10539
10515
|
condition
|
|
10540
10516
|
}) {
|
|
10541
10517
|
var _a, _b, _c;
|
|
@@ -10601,7 +10577,6 @@ var EntityService = class {
|
|
|
10601
10577
|
entityType,
|
|
10602
10578
|
entityId,
|
|
10603
10579
|
data: entity.data,
|
|
10604
|
-
updatedByAccountId: accountId,
|
|
10605
10580
|
publishedAt: entity.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10606
10581
|
}
|
|
10607
10582
|
});
|
|
@@ -10611,7 +10586,6 @@ var EntityService = class {
|
|
|
10611
10586
|
entityType,
|
|
10612
10587
|
entityId,
|
|
10613
10588
|
entityPayload,
|
|
10614
|
-
accountId,
|
|
10615
10589
|
condition,
|
|
10616
10590
|
where
|
|
10617
10591
|
}) {
|
|
@@ -10713,7 +10687,6 @@ var EntityService = class {
|
|
|
10713
10687
|
entityType,
|
|
10714
10688
|
entityId,
|
|
10715
10689
|
data: entity.data,
|
|
10716
|
-
updatedByAccountId: accountId,
|
|
10717
10690
|
publishedAt: entity.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10718
10691
|
}
|
|
10719
10692
|
});
|
|
@@ -10727,16 +10700,14 @@ var EntityService = class {
|
|
|
10727
10700
|
});
|
|
10728
10701
|
this.deleteEntity = (_0) => __async(this, [_0], function* ({
|
|
10729
10702
|
entityType,
|
|
10730
|
-
entityId
|
|
10731
|
-
accountId
|
|
10703
|
+
entityId
|
|
10732
10704
|
}) {
|
|
10733
10705
|
yield this.entityRepository.deleteEntity(entityType, entityId);
|
|
10734
10706
|
yield this.publishEvent({
|
|
10735
10707
|
event: EVENT.CORE.ENTITY_DELETED,
|
|
10736
10708
|
payload: {
|
|
10737
10709
|
entityType,
|
|
10738
|
-
entityId
|
|
10739
|
-
deletedByAccountId: accountId
|
|
10710
|
+
entityId
|
|
10740
10711
|
}
|
|
10741
10712
|
});
|
|
10742
10713
|
});
|
|
@@ -10827,7 +10798,6 @@ var ExecuteTransactionController = class {
|
|
|
10827
10798
|
this.transactionService = transactionService;
|
|
10828
10799
|
// biome-ignore lint/suspicious/noExplicitAny: Hono createMiddleware requires consistent return types
|
|
10829
10800
|
this.controller = createMiddleware19((c) => __async(this, null, function* () {
|
|
10830
|
-
const accountId = c.req.header("account-id") || "";
|
|
10831
10801
|
try {
|
|
10832
10802
|
const body = yield c.req.json();
|
|
10833
10803
|
if (!body.operations || !Array.isArray(body.operations)) {
|
|
@@ -10838,8 +10808,7 @@ var ExecuteTransactionController = class {
|
|
|
10838
10808
|
});
|
|
10839
10809
|
}
|
|
10840
10810
|
const result = yield this.transactionService.executeTransaction(
|
|
10841
|
-
body.operations
|
|
10842
|
-
accountId
|
|
10811
|
+
body.operations
|
|
10843
10812
|
);
|
|
10844
10813
|
c.status(httpStatus17.OK);
|
|
10845
10814
|
return c.json(result);
|
|
@@ -10953,7 +10922,7 @@ var EntityServiceLifeCycle = class {
|
|
|
10953
10922
|
this.publishEvent = publishEvent2;
|
|
10954
10923
|
this.eventUtils = eventUtils;
|
|
10955
10924
|
}
|
|
10956
|
-
afterCreateEntityHook(entity, entityPayload
|
|
10925
|
+
afterCreateEntityHook(entity, entityPayload) {
|
|
10957
10926
|
return __async(this, null, function* () {
|
|
10958
10927
|
var _a, _b;
|
|
10959
10928
|
const config = this.EntityConfig[entity.entityType];
|
|
@@ -10971,7 +10940,6 @@ var EntityServiceLifeCycle = class {
|
|
|
10971
10940
|
entityType: entity.entityType,
|
|
10972
10941
|
entityId: entity.entityId,
|
|
10973
10942
|
data: entity.data,
|
|
10974
|
-
createdByAccountId: accountId,
|
|
10975
10943
|
publishedAt: entity.updatedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10976
10944
|
}
|
|
10977
10945
|
});
|
|
@@ -10993,7 +10961,7 @@ var TransactionService = class {
|
|
|
10993
10961
|
this.entityServiceLifeCycle = entityServiceLifeCycle;
|
|
10994
10962
|
this.eventUtils = eventUtils;
|
|
10995
10963
|
this.mutualService = mutualService;
|
|
10996
|
-
this.executeTransaction = (operations
|
|
10964
|
+
this.executeTransaction = (operations) => __async(this, null, function* () {
|
|
10997
10965
|
var _a;
|
|
10998
10966
|
if (!operations || operations.length === 0) {
|
|
10999
10967
|
throw new StandardError(
|
|
@@ -11005,7 +10973,7 @@ var TransactionService = class {
|
|
|
11005
10973
|
const pendingEvents = [];
|
|
11006
10974
|
const resultEntries = [];
|
|
11007
10975
|
const processed = yield Promise.all(
|
|
11008
|
-
operations.map((op) => this.processOperation(op
|
|
10976
|
+
operations.map((op) => this.processOperation(op))
|
|
11009
10977
|
);
|
|
11010
10978
|
const afterCommits = [];
|
|
11011
10979
|
for (const { items, events, afterCommit, resultEntry } of processed) {
|
|
@@ -11124,14 +11092,14 @@ var TransactionService = class {
|
|
|
11124
11092
|
return { results: resultEntries };
|
|
11125
11093
|
});
|
|
11126
11094
|
}
|
|
11127
|
-
processOperation(op
|
|
11095
|
+
processOperation(op) {
|
|
11128
11096
|
return __async(this, null, function* () {
|
|
11129
11097
|
switch (op.operation) {
|
|
11130
11098
|
case "createEntity": {
|
|
11131
11099
|
const { items, entity } = yield this.buildCreateItems(op);
|
|
11132
11100
|
return {
|
|
11133
11101
|
items,
|
|
11134
|
-
events: this.collectCreateEvents(entity, op.payload
|
|
11102
|
+
events: this.collectCreateEvents(entity, op.payload),
|
|
11135
11103
|
resultEntry: {
|
|
11136
11104
|
operation: "createEntity",
|
|
11137
11105
|
entityType: op.entityType,
|
|
@@ -11146,7 +11114,7 @@ var TransactionService = class {
|
|
|
11146
11114
|
const { item, updatedAt } = yield this.buildUpdateItem(op);
|
|
11147
11115
|
return {
|
|
11148
11116
|
items: [item],
|
|
11149
|
-
events: this.collectUpdateEvents(op, updatedAt
|
|
11117
|
+
events: this.collectUpdateEvents(op, updatedAt),
|
|
11150
11118
|
resultEntry: {
|
|
11151
11119
|
operation: "updateEntity",
|
|
11152
11120
|
entityType: op.entityType,
|
|
@@ -11165,7 +11133,6 @@ var TransactionService = class {
|
|
|
11165
11133
|
payload: {
|
|
11166
11134
|
entityType: op.entityType,
|
|
11167
11135
|
entityId: op.entityId,
|
|
11168
|
-
updatedByAccountId: accountId,
|
|
11169
11136
|
publishedAt: updatedAt
|
|
11170
11137
|
}
|
|
11171
11138
|
}
|
|
@@ -11187,8 +11154,7 @@ var TransactionService = class {
|
|
|
11187
11154
|
event: EVENT.CORE.ENTITY_DELETED,
|
|
11188
11155
|
payload: {
|
|
11189
11156
|
entityType: op.entityType,
|
|
11190
|
-
entityId: op.entityId
|
|
11191
|
-
deletedByAccountId: accountId
|
|
11157
|
+
entityId: op.entityId
|
|
11192
11158
|
}
|
|
11193
11159
|
}
|
|
11194
11160
|
],
|
|
@@ -11200,11 +11166,11 @@ var TransactionService = class {
|
|
|
11200
11166
|
};
|
|
11201
11167
|
}
|
|
11202
11168
|
case "createMutual":
|
|
11203
|
-
return this.processCreateMutual(op
|
|
11169
|
+
return this.processCreateMutual(op);
|
|
11204
11170
|
case "updateMutual":
|
|
11205
|
-
return this.processUpdateMutual(op
|
|
11171
|
+
return this.processUpdateMutual(op);
|
|
11206
11172
|
case "deleteMutual":
|
|
11207
|
-
return this.processDeleteMutual(op
|
|
11173
|
+
return this.processDeleteMutual(op);
|
|
11208
11174
|
default:
|
|
11209
11175
|
throw new StandardError(
|
|
11210
11176
|
StandardErrorCode.TRANSACTION_INVALID_OPERATION,
|
|
@@ -11217,7 +11183,7 @@ var TransactionService = class {
|
|
|
11217
11183
|
// the write is deferred into this transaction. A mutual created here
|
|
11218
11184
|
// publishes the same MUTUAL_CREATED event, and an asEntity mutual's
|
|
11219
11185
|
// projection is written in the same transaction.
|
|
11220
|
-
processCreateMutual(op
|
|
11186
|
+
processCreateMutual(op) {
|
|
11221
11187
|
return __async(this, null, function* () {
|
|
11222
11188
|
var _a, _b;
|
|
11223
11189
|
this.assertMutualOperation(op);
|
|
@@ -11240,15 +11206,13 @@ var TransactionService = class {
|
|
|
11240
11206
|
entityType: op.entityType,
|
|
11241
11207
|
entityId: op.entityId,
|
|
11242
11208
|
parsedMutualPayload,
|
|
11243
|
-
accountId,
|
|
11244
11209
|
publishedAt: (_b = mutual.createdAt) != null ? _b : (/* @__PURE__ */ new Date()).toISOString()
|
|
11245
11210
|
}
|
|
11246
11211
|
}
|
|
11247
11212
|
],
|
|
11248
11213
|
afterCommit: entity ? () => this.entityServiceLifeCycle.afterCreateEntityHook(
|
|
11249
11214
|
entity,
|
|
11250
|
-
mutualPayload
|
|
11251
|
-
accountId
|
|
11215
|
+
mutualPayload
|
|
11252
11216
|
) : void 0,
|
|
11253
11217
|
resultEntry: {
|
|
11254
11218
|
operation: "createMutual",
|
|
@@ -11269,7 +11233,7 @@ var TransactionService = class {
|
|
|
11269
11233
|
// Same validation and records as MutualService.updateMutual, and the same
|
|
11270
11234
|
// MUTUAL_UPDATED event. The stored values are read back after the commit
|
|
11271
11235
|
// (Phase 4), as a standalone PATCH /mutual/... returns them.
|
|
11272
|
-
processUpdateMutual(op
|
|
11236
|
+
processUpdateMutual(op) {
|
|
11273
11237
|
return __async(this, null, function* () {
|
|
11274
11238
|
this.assertMutualOperation(op);
|
|
11275
11239
|
if (!op.payload || typeof op.payload !== "object") {
|
|
@@ -11295,8 +11259,7 @@ var TransactionService = class {
|
|
|
11295
11259
|
byEntityId: op.byEntityId,
|
|
11296
11260
|
entityType: op.entityType,
|
|
11297
11261
|
entityId: op.entityId,
|
|
11298
|
-
parsedMutualPayload
|
|
11299
|
-
updatedByAccountId: accountId
|
|
11262
|
+
parsedMutualPayload
|
|
11300
11263
|
}
|
|
11301
11264
|
}
|
|
11302
11265
|
],
|
|
@@ -11312,7 +11275,7 @@ var TransactionService = class {
|
|
|
11312
11275
|
});
|
|
11313
11276
|
}
|
|
11314
11277
|
// Same soft delete as MutualService.deleteMutual, and the same event.
|
|
11315
|
-
processDeleteMutual(op
|
|
11278
|
+
processDeleteMutual(op) {
|
|
11316
11279
|
return __async(this, null, function* () {
|
|
11317
11280
|
this.assertMutualOperation(op);
|
|
11318
11281
|
const { mutual, TransactItems } = yield this.requireMutualService(
|
|
@@ -11332,8 +11295,7 @@ var TransactionService = class {
|
|
|
11332
11295
|
byEntityType: op.byEntityType,
|
|
11333
11296
|
byEntityId: op.byEntityId,
|
|
11334
11297
|
entityType: op.entityType,
|
|
11335
|
-
entityId: op.entityId
|
|
11336
|
-
deletedByAccountId: accountId
|
|
11298
|
+
entityId: op.entityId
|
|
11337
11299
|
}
|
|
11338
11300
|
}
|
|
11339
11301
|
],
|
|
@@ -11576,7 +11538,7 @@ var TransactionService = class {
|
|
|
11576
11538
|
}
|
|
11577
11539
|
};
|
|
11578
11540
|
}
|
|
11579
|
-
collectCreateEvents(entity, payload
|
|
11541
|
+
collectCreateEvents(entity, payload) {
|
|
11580
11542
|
var _a, _b, _c;
|
|
11581
11543
|
const events = [];
|
|
11582
11544
|
const publishedAt = entity.updatedAt || (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -11612,13 +11574,12 @@ var TransactionService = class {
|
|
|
11612
11574
|
entityType: entity.entityType,
|
|
11613
11575
|
entityId: entity.entityId,
|
|
11614
11576
|
data: entity.data,
|
|
11615
|
-
createdByAccountId: accountId,
|
|
11616
11577
|
publishedAt
|
|
11617
11578
|
}
|
|
11618
11579
|
});
|
|
11619
11580
|
return events;
|
|
11620
11581
|
}
|
|
11621
|
-
collectUpdateEvents(op, updatedAt
|
|
11582
|
+
collectUpdateEvents(op, updatedAt) {
|
|
11622
11583
|
var _a, _b;
|
|
11623
11584
|
const events = [];
|
|
11624
11585
|
const config = this.EntityConfig[op.entityType];
|
|
@@ -11654,7 +11615,6 @@ var TransactionService = class {
|
|
|
11654
11615
|
payload: {
|
|
11655
11616
|
entityType: op.entityType,
|
|
11656
11617
|
entityId: op.entityId,
|
|
11657
|
-
updatedByAccountId: accountId,
|
|
11658
11618
|
publishedAt: updatedAt
|
|
11659
11619
|
}
|
|
11660
11620
|
});
|