monorise 1.11.0 → 1.12.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/base/index.d.ts +4 -4
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +6 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/chunk-W6HUNJ6S.js +79 -0
- package/dist/core/chunk-W6HUNJ6S.js.map +1 -0
- package/dist/core/index.d.ts +99 -6
- package/dist/core/index.js +794 -68
- package/dist/core/index.js.map +1 -1
- package/dist/core/service.config-U77V7WIB.js +13 -0
- package/dist/core/service.config-U77V7WIB.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/proxy/index.d.ts +35 -0
- package/dist/proxy/index.js +78 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/react/actions/websocket.action.d.ts +71 -0
- package/dist/react/actions/websocket.action.d.ts.map +1 -0
- package/dist/react/chunk-CQQYJW4K.js +444 -0
- package/dist/react/chunk-CQQYJW4K.js.map +1 -0
- package/dist/react/index.d.ts +30 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +602 -34
- package/dist/react/index.js.map +1 -1
- package/dist/react/websocket/WebSocketManager.d.ts +72 -0
- package/dist/react/websocket/WebSocketManager.d.ts.map +1 -0
- package/dist/react/websocket/index.d.ts +3 -0
- package/dist/react/websocket/index.d.ts.map +1 -0
- package/dist/react/websocket/optimistic.d.ts +51 -0
- package/dist/react/websocket/optimistic.d.ts.map +1 -0
- package/dist/react/websocket-34W2HQLH.js +9 -0
- package/dist/react/websocket-34W2HQLH.js.map +1 -0
- package/dist/sst/components/monorise-core.d.ts +10 -0
- package/dist/sst/components/monorise-core.d.ts.map +1 -1
- package/dist/sst/components/single-table.d.ts.map +1 -1
- package/dist/sst/index.js +86 -14
- package/dist/sst/index.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name in all)
|
|
35
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
36
|
+
};
|
|
37
|
+
var __async = (__this, __arguments, generator) => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
var fulfilled = (value) => {
|
|
40
|
+
try {
|
|
41
|
+
step(generator.next(value));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
reject(e);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var rejected = (value) => {
|
|
47
|
+
try {
|
|
48
|
+
step(generator.throw(value));
|
|
49
|
+
} catch (e) {
|
|
50
|
+
reject(e);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
54
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
|
|
58
|
+
|
|
59
|
+
// constants/table.ts
|
|
60
|
+
var ENTITY_REPLICATION_INDEX = "ENTITY_REPLICATION_INDEX";
|
|
61
|
+
var MUTUAL_REPLICATION_INDEX = "MUTUAL_REPLICATION_INDEX";
|
|
62
|
+
|
|
63
|
+
// configs/service.config.ts
|
|
64
|
+
var CORE_TABLE = process.env.CORE_TABLE || "";
|
|
65
|
+
var CORE_EVENT_BUS = process.env.CORE_EVENT_BUS || "";
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
__spreadValues,
|
|
69
|
+
__spreadProps,
|
|
70
|
+
__objRest,
|
|
71
|
+
__export,
|
|
72
|
+
__async,
|
|
73
|
+
__forAwait,
|
|
74
|
+
ENTITY_REPLICATION_INDEX,
|
|
75
|
+
MUTUAL_REPLICATION_INDEX,
|
|
76
|
+
CORE_TABLE,
|
|
77
|
+
CORE_EVENT_BUS
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-W6HUNJ6S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../constants/table.ts","../configs/service.config.ts"],"sourcesContent":["export const ENTITY_REPLICATION_INDEX = 'ENTITY_REPLICATION_INDEX';\nexport const MUTUAL_REPLICATION_INDEX = 'MUTUAL_REPLICATION_INDEX';\n","import {\n ENTITY_REPLICATION_INDEX,\n MUTUAL_REPLICATION_INDEX,\n} from '../constants/table';\n\nconst CORE_TABLE = process.env.CORE_TABLE || '';\nconst CORE_EVENT_BUS = process.env.CORE_EVENT_BUS || '';\n\nexport {\n CORE_TABLE,\n CORE_EVENT_BUS,\n ENTITY_REPLICATION_INDEX,\n MUTUAL_REPLICATION_INDEX,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,2BAA2B;AACjC,IAAM,2BAA2B;;;ACIxC,IAAM,aAAa,QAAQ,IAAI,cAAc;AAC7C,IAAM,iBAAiB,QAAQ,IAAI,kBAAkB;","names":[]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { FirehoseClient } from '@aws-sdk/client-firehose';
|
|
|
13
13
|
import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
14
14
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
15
15
|
import * as hono_aws_lambda from 'hono/aws-lambda';
|
|
16
|
-
import { SQSEvent, SQSBatchItemFailure, DynamoDBBatchItemFailure } from 'aws-lambda';
|
|
16
|
+
import { SQSEvent, SQSBatchItemFailure, DynamoDBBatchItemFailure, APIGatewayProxyWebsocketEventV2, APIGatewayProxyResultV2, DynamoDBStreamEvent } from 'aws-lambda';
|
|
17
17
|
import { _Record } from '@aws-sdk/client-dynamodb-streams';
|
|
18
18
|
|
|
19
19
|
type EventDetail = {
|
|
@@ -329,6 +329,58 @@ declare class TagRepository extends Repository {
|
|
|
329
329
|
}): Promise<void>;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
interface ConnectionRecord {
|
|
333
|
+
connectionId: string;
|
|
334
|
+
entityType?: string;
|
|
335
|
+
entityId?: string;
|
|
336
|
+
connectedAt?: string;
|
|
337
|
+
expiresAt?: number;
|
|
338
|
+
}
|
|
339
|
+
interface SubscriptionRecord {
|
|
340
|
+
PK: string;
|
|
341
|
+
SK: string;
|
|
342
|
+
connectionId: string;
|
|
343
|
+
subscriptionType: string;
|
|
344
|
+
feedTypes?: string[];
|
|
345
|
+
[key: string]: unknown;
|
|
346
|
+
}
|
|
347
|
+
interface TicketData {
|
|
348
|
+
entityType: string;
|
|
349
|
+
entityId: string;
|
|
350
|
+
feedTypes: string[];
|
|
351
|
+
}
|
|
352
|
+
declare class WebSocketRepository extends Repository {
|
|
353
|
+
private tableName;
|
|
354
|
+
private dynamodbClient;
|
|
355
|
+
private docClient;
|
|
356
|
+
constructor(tableName: string, dynamodbClient: DynamoDB);
|
|
357
|
+
createConnection(connectionId: string, metadata: Record<string, unknown>, expiresAt: number): Promise<void>;
|
|
358
|
+
getConnection(connectionId: string): Promise<ConnectionRecord | undefined>;
|
|
359
|
+
deleteConnection(connectionId: string): Promise<void>;
|
|
360
|
+
createSubscription(subKey: string, connectionId: string, data: Record<string, unknown>): Promise<void>;
|
|
361
|
+
deleteSubscription(subKey: string, connectionId: string): Promise<void>;
|
|
362
|
+
/**
|
|
363
|
+
* Run a query to exhaustion.
|
|
364
|
+
*
|
|
365
|
+
* Every caller below fans a broadcast out to the rows it returns, so a
|
|
366
|
+
* single-page query silently drops recipients past DynamoDB's 1MB limit --
|
|
367
|
+
* and on `$disconnect`, silently leaves their subscription rows behind. The
|
|
368
|
+
* `ConsistentRead` on these queries exists to avoid dropping recipients;
|
|
369
|
+
* stopping at one page drops them the same way, just at a different
|
|
370
|
+
* threshold.
|
|
371
|
+
*/
|
|
372
|
+
private queryAllPages;
|
|
373
|
+
querySubscriptionsByKey(subKey: string): Promise<SubscriptionRecord[]>;
|
|
374
|
+
querySubscriptionsByConnectionId(connectionId: string): Promise<SubscriptionRecord[]>;
|
|
375
|
+
createTicket(ticket: string, entityType: string, entityId: string, feedTypes: string[], expiresAt: number): Promise<void>;
|
|
376
|
+
consumeTicket(ticket: string): Promise<TicketData | null>;
|
|
377
|
+
queryMutualConnections(byEntityType: string, byEntityId: string): Promise<{
|
|
378
|
+
entityType: string;
|
|
379
|
+
entityId: string;
|
|
380
|
+
}[]>;
|
|
381
|
+
queryFeedSubscriptions(entityType: string, entityId: string): Promise<SubscriptionRecord[]>;
|
|
382
|
+
}
|
|
383
|
+
|
|
332
384
|
var __defProp = Object.defineProperty;
|
|
333
385
|
var __defProps = Object.defineProperties;
|
|
334
386
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -373,6 +425,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
373
425
|
});
|
|
374
426
|
};
|
|
375
427
|
|
|
428
|
+
// configs/service.config.ts
|
|
429
|
+
process.env.CORE_TABLE || "";
|
|
430
|
+
process.env.CORE_EVENT_BUS || "";
|
|
431
|
+
|
|
376
432
|
// errors/standard-error.ts
|
|
377
433
|
var StandardError$1 = class StandardError extends Error {
|
|
378
434
|
constructor(errorCode, message, lastError, context) {
|
|
@@ -493,10 +549,6 @@ factory.createMiddleware((c, next) => __async(null, null, function* () {
|
|
|
493
549
|
return yield next();
|
|
494
550
|
}));
|
|
495
551
|
|
|
496
|
-
// configs/service.config.ts
|
|
497
|
-
process.env.CORE_TABLE || "";
|
|
498
|
-
process.env.CORE_EVENT_BUS || "";
|
|
499
|
-
|
|
500
552
|
// helpers/event.ts
|
|
501
553
|
new EventBridgeClient();
|
|
502
554
|
|
|
@@ -4788,6 +4840,16 @@ declare class ExecuteTransactionController {
|
|
|
4788
4840
|
controller: hono.MiddlewareHandler<any, string, {}, any>;
|
|
4789
4841
|
}
|
|
4790
4842
|
|
|
4843
|
+
declare class CreateTicketController {
|
|
4844
|
+
private container;
|
|
4845
|
+
constructor(container: DependencyContainer);
|
|
4846
|
+
controller: hono.MiddlewareHandler<any, string, {}, Response & hono.TypedResponse<{
|
|
4847
|
+
ticket: string;
|
|
4848
|
+
wsUrl: string;
|
|
4849
|
+
expiresIn: number;
|
|
4850
|
+
}, hono_utils_http_status.ContentfulStatusCode, "json">>;
|
|
4851
|
+
}
|
|
4852
|
+
|
|
4791
4853
|
declare class DependencyContainer {
|
|
4792
4854
|
config: {
|
|
4793
4855
|
EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
|
|
@@ -4816,6 +4878,7 @@ declare class DependencyContainer {
|
|
|
4816
4878
|
get entityService(): EntityService;
|
|
4817
4879
|
get mutualService(): MutualService;
|
|
4818
4880
|
get tagRepository(): TagRepository;
|
|
4881
|
+
get websocketRepository(): WebSocketRepository;
|
|
4819
4882
|
get getEntityController(): GetEntityController;
|
|
4820
4883
|
get getEntityByUniqueFieldController(): GetEntityByUniqueFieldValueController;
|
|
4821
4884
|
get listEntitiesController(): ListEntitiesController;
|
|
@@ -4832,6 +4895,7 @@ declare class DependencyContainer {
|
|
|
4832
4895
|
get listTagsController(): ListTagsController;
|
|
4833
4896
|
get transactionService(): TransactionService;
|
|
4834
4897
|
get executeTransactionController(): ExecuteTransactionController;
|
|
4898
|
+
get createTicketController(): CreateTicketController;
|
|
4835
4899
|
}
|
|
4836
4900
|
|
|
4837
4901
|
declare const setupCommonRoutes: (container: DependencyContainer) => Hono;
|
|
@@ -4985,6 +5049,31 @@ declare const handler: (container: DependencyContainer) => (ev: SQSEvent) => Pro
|
|
|
4985
5049
|
batchItemFailures: SQSBatchItemFailure[];
|
|
4986
5050
|
}>;
|
|
4987
5051
|
|
|
5052
|
+
type WebSocketConnectEvent = APIGatewayProxyWebsocketEventV2 & {
|
|
5053
|
+
queryStringParameters?: Record<string, string | undefined>;
|
|
5054
|
+
headers?: Record<string, string | undefined>;
|
|
5055
|
+
};
|
|
5056
|
+
/**
|
|
5057
|
+
* $connect handler
|
|
5058
|
+
* Supports two auth modes:
|
|
5059
|
+
* - ticket: ?ticket=abc123 (issued via /ws/ticket/:entityType/:entityId)
|
|
5060
|
+
* - token: ?token=userId (simplified direct auth)
|
|
5061
|
+
*/
|
|
5062
|
+
declare const connect: (container: DependencyContainer) => (event: WebSocketConnectEvent) => Promise<APIGatewayProxyResultV2>;
|
|
5063
|
+
/**
|
|
5064
|
+
* $disconnect handler
|
|
5065
|
+
* Cleans up connection record and all associated subscription records.
|
|
5066
|
+
*/
|
|
5067
|
+
declare const disconnect: (container: DependencyContainer) => (event: APIGatewayProxyWebsocketEventV2) => Promise<APIGatewayProxyResultV2>;
|
|
5068
|
+
/**
|
|
5069
|
+
* $default handler - route messages
|
|
5070
|
+
*/
|
|
5071
|
+
declare const $default: (container: DependencyContainer) => (event: APIGatewayProxyWebsocketEventV2) => Promise<APIGatewayProxyResultV2>;
|
|
5072
|
+
/**
|
|
5073
|
+
* Broadcast handler - triggered by DynamoDB Streams
|
|
5074
|
+
*/
|
|
5075
|
+
declare const broadcast: (container: DependencyContainer) => (event: DynamoDBStreamEvent) => Promise<void>;
|
|
5076
|
+
|
|
4988
5077
|
declare const transactional: {
|
|
4989
5078
|
createEntity: <T extends Entity$2>(entityType: T, payload: EntitySchemaMap[T] & {
|
|
4990
5079
|
entityId?: string;
|
|
@@ -5009,6 +5098,10 @@ declare class CoreFactory {
|
|
|
5009
5098
|
prejoinProcessor: ReturnType<typeof handler$2>;
|
|
5010
5099
|
tagProcessor: ReturnType<typeof handler>;
|
|
5011
5100
|
appHandler: ReturnType<typeof appHandler>;
|
|
5101
|
+
wsConnect: ReturnType<typeof connect>;
|
|
5102
|
+
wsDisconnect: ReturnType<typeof disconnect>;
|
|
5103
|
+
wsDefault: ReturnType<typeof $default>;
|
|
5104
|
+
wsBroadcast: ReturnType<typeof broadcast>;
|
|
5012
5105
|
dependencyContainer: DependencyContainer;
|
|
5013
5106
|
constructor(config: {
|
|
5014
5107
|
EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
|
|
@@ -5017,4 +5110,4 @@ declare class CoreFactory {
|
|
|
5017
5110
|
});
|
|
5018
5111
|
}
|
|
5019
5112
|
|
|
5020
|
-
export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, handler$7 as analyticsBackfillProcessor, handler$6 as analyticsMaterializationProcessor, handler$5 as analyticsModelProcessor, handler$8 as analyticsProcessor, analyticsQueryHandler, handler$4 as analyticsViewProcessor, appHandler, handler$9 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional };
|
|
5113
|
+
export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, handler$7 as analyticsBackfillProcessor, handler$6 as analyticsMaterializationProcessor, handler$5 as analyticsModelProcessor, handler$8 as analyticsProcessor, analyticsQueryHandler, handler$4 as analyticsViewProcessor, appHandler, handler$9 as createEntityProcessor, CoreFactory as default, handler$3 as mutualProcessor, handler$2 as prejoinProcessor, handler$1 as replicationProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };
|