monorise 1.15.0 → 2.0.0-dev.2
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 +227 -1
- package/dist/base/index.js +382 -0
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +300 -131
- 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/cli/templates/files/proxy-route.ts +12 -22
- package/dist/cli/templates/files/sst.config.ts +4 -1
- package/dist/cli/templates/files/ws-ticket-route.ts +21 -0
- package/dist/core/index.d.ts +63 -36
- package/dist/core/index.js +785 -208
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +24 -7
- package/dist/proxy/index.d.ts +275 -2
- package/dist/proxy/index.js +696 -37
- 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 +47 -189
- 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/cli/templates/files/proxy-request.ts +0 -50
- 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.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, SearchSettings, ResolvedSearchConfig, WhereConditions } from '../base/index';
|
|
1
|
+
import { Entity as Entity$2, EntitySchemaMap, createEntityConfig, SearchSettings, ResolvedSearchConfig, WhereConditions, ApiKeyPolicies, ApiKeyRoutePermission, CompiledApiKeyPolicy } from '../base/index';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
|
-
import { Hono } from 'hono';
|
|
3
|
+
import { Hono, MiddlewareHandler } from 'hono';
|
|
4
4
|
import * as _aws_sdk_client_dynamodb from '@aws-sdk/client-dynamodb';
|
|
5
5
|
import { DynamoDB, TransactWriteItemsInput, AttributeValue, TransactWriteItem, UpdateItemCommandInput, DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
6
6
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
7
7
|
import * as hono_utils_types from 'hono/utils/types';
|
|
8
8
|
import { createFactory } from 'hono/factory';
|
|
9
|
-
import httpStatus4 from 'http-status';
|
|
10
9
|
import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
|
|
10
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
11
11
|
import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
|
|
12
12
|
import { AthenaClient } from '@aws-sdk/client-athena';
|
|
13
13
|
import { FirehoseClient } from '@aws-sdk/client-firehose';
|
|
@@ -625,22 +625,8 @@ var Entity = class _Entity extends Item {
|
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
627
|
};
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
factory.createMiddleware((c, next) => __async(null, null, function* () {
|
|
631
|
-
const xApiKey = c.req.header("x-api-key");
|
|
632
|
-
if (c.req.url.match(/^\/core\/public\//)) {
|
|
633
|
-
return yield next();
|
|
634
|
-
}
|
|
635
|
-
if (!xApiKey || Array.isArray(xApiKey) || !API_KEYS.includes(xApiKey)) {
|
|
636
|
-
c.status(httpStatus4.UNAUTHORIZED);
|
|
637
|
-
return c.json({
|
|
638
|
-
status: httpStatus4.UNAUTHORIZED,
|
|
639
|
-
message: httpStatus4["401_MESSAGE"]
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
return yield next();
|
|
643
|
-
}));
|
|
628
|
+
new AsyncLocalStorage();
|
|
629
|
+
createFactory();
|
|
644
630
|
|
|
645
631
|
// helpers/event.ts
|
|
646
632
|
new EventBridgeClient();
|
|
@@ -4623,7 +4609,7 @@ declare class EntityServiceLifeCycle {
|
|
|
4623
4609
|
private publishEvent;
|
|
4624
4610
|
private eventUtils;
|
|
4625
4611
|
constructor(EntityConfig: any, publishEvent: typeof publishEvent, eventUtils: EventUtils);
|
|
4626
|
-
afterCreateEntityHook<T extends Entity$2>(entity: Entity$1<T>, entityPayload?: Record<string, unknown
|
|
4612
|
+
afterCreateEntityHook<T extends Entity$2>(entity: Entity$1<T>, entityPayload?: Record<string, unknown>): Promise<void>;
|
|
4627
4613
|
}
|
|
4628
4614
|
|
|
4629
4615
|
declare class EntityService {
|
|
@@ -4633,38 +4619,34 @@ declare class EntityService {
|
|
|
4633
4619
|
private publishEvent;
|
|
4634
4620
|
private entityServiceLifeCycle;
|
|
4635
4621
|
constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, EmailAuthEnabledEntities: Entity$2[], entityRepository: EntityRepository, publishEvent: typeof publishEvent, entityServiceLifeCycle: EntityServiceLifeCycle);
|
|
4636
|
-
createEntity: <T extends Entity$2>({ entityType, entityId, entityPayload,
|
|
4622
|
+
createEntity: <T extends Entity$2>({ entityType, entityId, entityPayload, options, }: {
|
|
4637
4623
|
entityType: T;
|
|
4638
4624
|
entityPayload: EntitySchemaMap[T] | Record<string, any>;
|
|
4639
4625
|
entityId?: string;
|
|
4640
|
-
accountId?: string | string[];
|
|
4641
4626
|
options?: {
|
|
4642
4627
|
createAndUpdateDatetime?: string;
|
|
4643
4628
|
mutualId?: string;
|
|
4644
4629
|
};
|
|
4645
4630
|
}) => Promise<Entity<T>>;
|
|
4646
|
-
adjustEntity: <T extends Entity$2>({ entityType, entityId, adjustments,
|
|
4631
|
+
adjustEntity: <T extends Entity$2>({ entityType, entityId, adjustments, condition, }: {
|
|
4647
4632
|
entityType: T;
|
|
4648
4633
|
entityId: string;
|
|
4649
4634
|
adjustments: Record<string, number>;
|
|
4650
|
-
accountId?: string;
|
|
4651
4635
|
condition?: string;
|
|
4652
4636
|
}) => Promise<Entity<T>>;
|
|
4653
|
-
updateEntity: <T extends Entity$2>({ entityType, entityId, entityPayload,
|
|
4637
|
+
updateEntity: <T extends Entity$2>({ entityType, entityId, entityPayload, condition, where, }: {
|
|
4654
4638
|
entityType: T;
|
|
4655
4639
|
entityId: string;
|
|
4656
4640
|
entityPayload: Partial<EntitySchemaMap[T]>;
|
|
4657
|
-
accountId?: string | string[];
|
|
4658
4641
|
condition?: string;
|
|
4659
4642
|
/** @deprecated Use `condition` (named condition) instead of raw `where`. */
|
|
4660
4643
|
where?: WhereConditions;
|
|
4661
4644
|
}) => Promise<Entity<T>>;
|
|
4662
4645
|
/** @deprecated Converts legacy adjustmentConstraints to condition expression opts. */
|
|
4663
4646
|
private buildLegacyAdjustCondition;
|
|
4664
|
-
deleteEntity: <T extends Entity$2>({ entityType, entityId,
|
|
4647
|
+
deleteEntity: <T extends Entity$2>({ entityType, entityId, }: {
|
|
4665
4648
|
entityType: T;
|
|
4666
4649
|
entityId: string;
|
|
4667
|
-
accountId?: string | string[];
|
|
4668
4650
|
}) => Promise<void>;
|
|
4669
4651
|
}
|
|
4670
4652
|
|
|
@@ -4746,7 +4728,6 @@ type CreateMutualParams<B extends Entity$2, T extends Entity$2, A extends Entity
|
|
|
4746
4728
|
entityType: T;
|
|
4747
4729
|
entityId: string;
|
|
4748
4730
|
mutualPayload?: Record<string, unknown>;
|
|
4749
|
-
accountId?: string | string[];
|
|
4750
4731
|
options?: {
|
|
4751
4732
|
asEntity?: A;
|
|
4752
4733
|
mutualId?: string;
|
|
@@ -4811,7 +4792,6 @@ declare class MutualService {
|
|
|
4811
4792
|
parsedMutualPayload: {
|
|
4812
4793
|
[x: string]: any;
|
|
4813
4794
|
};
|
|
4814
|
-
accountId: string | string[] | undefined;
|
|
4815
4795
|
publishedAt: string;
|
|
4816
4796
|
};
|
|
4817
4797
|
}>;
|
|
@@ -4847,13 +4827,12 @@ declare class MutualService {
|
|
|
4847
4827
|
TransactItems: _aws_sdk_client_dynamodb.TransactWriteItem[];
|
|
4848
4828
|
parsedMutualPayload: Record<string, unknown>;
|
|
4849
4829
|
}>;
|
|
4850
|
-
updateMutual: <B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>({ byEntityType, byEntityId, entityType, entityId, mutualPayload,
|
|
4830
|
+
updateMutual: <B extends Entity$2, T extends Entity$2, M extends Record<string, unknown>>({ byEntityType, byEntityId, entityType, entityId, mutualPayload, options, }: {
|
|
4851
4831
|
byEntityType: B;
|
|
4852
4832
|
byEntityId: string;
|
|
4853
4833
|
entityType: T;
|
|
4854
4834
|
entityId: string;
|
|
4855
4835
|
mutualPayload: M;
|
|
4856
|
-
accountId?: string | string[];
|
|
4857
4836
|
options?: {
|
|
4858
4837
|
maxObjectUpdateLevel?: number;
|
|
4859
4838
|
returnUpdatedValue?: boolean;
|
|
@@ -4873,12 +4852,11 @@ declare class MutualService {
|
|
|
4873
4852
|
mutual: Mutual<Entity$2, Entity$2, Record<string, unknown>>;
|
|
4874
4853
|
TransactItems: _aws_sdk_client_dynamodb.TransactWriteItem[];
|
|
4875
4854
|
}>;
|
|
4876
|
-
deleteMutual: ({ byEntityType, byEntityId, entityType, entityId,
|
|
4855
|
+
deleteMutual: ({ byEntityType, byEntityId, entityType, entityId, }: {
|
|
4877
4856
|
byEntityType: Entity$2;
|
|
4878
4857
|
byEntityId: string;
|
|
4879
4858
|
entityType: Entity$2;
|
|
4880
4859
|
entityId: string;
|
|
4881
|
-
accountId?: string | string[];
|
|
4882
4860
|
}) => Promise<Mutual<Entity$2, Entity$2, Record<string, unknown>>>;
|
|
4883
4861
|
}
|
|
4884
4862
|
|
|
@@ -5012,7 +4990,7 @@ declare class TransactionService {
|
|
|
5012
4990
|
private eventUtils;
|
|
5013
4991
|
private mutualService?;
|
|
5014
4992
|
constructor(EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>, EmailAuthEnabledEntities: Entity$2[], entityRepository: EntityRepository, dynamodbClient: DynamoDB, publishEvent: typeof publishEvent, entityServiceLifeCycle: EntityServiceLifeCycle, eventUtils: EventUtils, mutualService?: MutualService | undefined);
|
|
5015
|
-
executeTransaction: (operations: TransactionOperation[]
|
|
4993
|
+
executeTransaction: (operations: TransactionOperation[]) => Promise<TransactionResult>;
|
|
5016
4994
|
private processOperation;
|
|
5017
4995
|
private processCreateMutual;
|
|
5018
4996
|
private processUpdateMutual;
|
|
@@ -5048,6 +5026,8 @@ declare class DependencyContainer {
|
|
|
5048
5026
|
EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
|
|
5049
5027
|
AllowedEntityTypes: Entity$2[];
|
|
5050
5028
|
EmailAuthEnabledEntities: Entity$2[];
|
|
5029
|
+
/** Policies from the file `apiKeys` points to in monorise.config.ts. */
|
|
5030
|
+
ApiKeyPolicies?: ApiKeyPolicies;
|
|
5051
5031
|
SearchDefaults?: SearchSettings;
|
|
5052
5032
|
tableName?: string;
|
|
5053
5033
|
};
|
|
@@ -5058,6 +5038,8 @@ declare class DependencyContainer {
|
|
|
5058
5038
|
EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
|
|
5059
5039
|
AllowedEntityTypes: Entity$2[];
|
|
5060
5040
|
EmailAuthEnabledEntities: Entity$2[];
|
|
5041
|
+
/** Policies from the file `apiKeys` points to in monorise.config.ts. */
|
|
5042
|
+
ApiKeyPolicies?: ApiKeyPolicies;
|
|
5061
5043
|
SearchDefaults?: SearchSettings;
|
|
5062
5044
|
tableName?: string;
|
|
5063
5045
|
});
|
|
@@ -5310,6 +5292,50 @@ declare const transactional: {
|
|
|
5310
5292
|
deleteMutual: <B extends Entity$2, T extends Entity$2>(byEntityType: B, entityType: T, byEntityId: string, entityId: string) => TransactionDeleteMutual<B, T>;
|
|
5311
5293
|
};
|
|
5312
5294
|
|
|
5295
|
+
/**
|
|
5296
|
+
* `read` is get, by ID or unique field. `list` is listing the whole type,
|
|
5297
|
+
* which also needs `read`.
|
|
5298
|
+
*/
|
|
5299
|
+
type EntityAction = 'read' | 'list' | 'create' | 'update' | 'delete';
|
|
5300
|
+
/**
|
|
5301
|
+
* Declares the permission a custom route requires. Policies grant it by name
|
|
5302
|
+
* in `routes`; `full` keys always pass. Works per route or on a group:
|
|
5303
|
+
*
|
|
5304
|
+
* @example
|
|
5305
|
+
* ```ts
|
|
5306
|
+
* app.post('/checkout', requires('checkout'), handler);
|
|
5307
|
+
* app.use('/reports/*', requires('reports'));
|
|
5308
|
+
* ```
|
|
5309
|
+
*/
|
|
5310
|
+
declare const requires: (permission: ApiKeyRoutePermission) => MiddlewareHandler;
|
|
5311
|
+
|
|
5312
|
+
type ApiKeyPrincipal = {
|
|
5313
|
+
/** Name of the policy the request's key maps to, e.g. `'full'`. */
|
|
5314
|
+
policy: string;
|
|
5315
|
+
/** SHA-256 hex digest of the key. Safe to log or store; the key itself is not. */
|
|
5316
|
+
fingerprint: string;
|
|
5317
|
+
/** What the policy grants, per entity type and relationship direction. */
|
|
5318
|
+
access: CompiledApiKeyPolicy;
|
|
5319
|
+
/**
|
|
5320
|
+
* Whether the policy allows an action on an entity type, and on every
|
|
5321
|
+
* listed field when `fields` is given. `read` is get by ID; `list` is
|
|
5322
|
+
* listing the whole type.
|
|
5323
|
+
*/
|
|
5324
|
+
can(action: EntityAction, entityType: string, fields?: readonly string[]): boolean;
|
|
5325
|
+
/** Whether the policy grants a custom route permission. */
|
|
5326
|
+
has(permission: ApiKeyRoutePermission): boolean;
|
|
5327
|
+
/**
|
|
5328
|
+
* An entity, tag or relationship record with the fields the key cannot read
|
|
5329
|
+
* removed from `data` (and `mutualData`). Accepts an `Entity` or its JSON.
|
|
5330
|
+
*/
|
|
5331
|
+
mask<T extends object>(entityType: string, entity: T): Record<string, unknown>;
|
|
5332
|
+
};
|
|
5333
|
+
declare module 'hono' {
|
|
5334
|
+
interface ContextVariableMap {
|
|
5335
|
+
apiKey: ApiKeyPrincipal;
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
|
|
5313
5339
|
declare class CoreFactory {
|
|
5314
5340
|
private config;
|
|
5315
5341
|
setupCommonRoutes: ReturnType<typeof setupCommonRoutes>;
|
|
@@ -5331,8 +5357,9 @@ declare class CoreFactory {
|
|
|
5331
5357
|
EntityConfig: Record<Entity$2, ReturnType<typeof createEntityConfig>>;
|
|
5332
5358
|
AllowedEntityTypes: Entity$2[];
|
|
5333
5359
|
EmailAuthEnabledEntities: Entity$2[];
|
|
5360
|
+
ApiKeyPolicies?: ApiKeyPolicies;
|
|
5334
5361
|
SearchDefaults?: SearchSettings;
|
|
5335
5362
|
});
|
|
5336
5363
|
}
|
|
5337
5364
|
|
|
5338
|
-
export { DependencyContainer, Entity$1 as Entity, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, SearchRepository, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, handler$8 as analyticsBackfillProcessor, handler$7 as analyticsMaterializationProcessor, handler$6 as analyticsModelProcessor, handler$9 as analyticsProcessor, analyticsQueryHandler, handler$5 as analyticsViewProcessor, appHandler, handler$a as createEntityProcessor, CoreFactory as default, handler$4 as mutualProcessor, handler$3 as prejoinProcessor, handler$2 as replicationProcessor, handler$1 as searchReindexProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };
|
|
5365
|
+
export { type ApiKeyPrincipal, DependencyContainer, Entity$1 as Entity, type EntityAction, EntityRepository, EntityService, Mutual, MutualRepository, MutualService, PROJECTION_EXPRESSION, SearchRepository, StandardError, StandardErrorCode, TagRepository, TransactionService, WebSocketRepository, handler$8 as analyticsBackfillProcessor, handler$7 as analyticsMaterializationProcessor, handler$6 as analyticsModelProcessor, handler$9 as analyticsProcessor, analyticsQueryHandler, handler$5 as analyticsViewProcessor, appHandler, handler$a as createEntityProcessor, CoreFactory as default, handler$4 as mutualProcessor, handler$3 as prejoinProcessor, handler$2 as replicationProcessor, requires, handler$1 as searchReindexProcessor, setupCommonRoutes, startBackfill as startAnalyticsBackfill, handler as tagProcessor, transactional, broadcast as wsBroadcast, connect as wsConnect, $default as wsDefault, disconnect as wsDisconnect };
|