@webiny/api-core-ddb 6.4.5-beta.0 → 6.6.0-alpha.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.
@@ -0,0 +1,12 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ export interface ApiCoreDdbConfig {
3
+ documentClient: DynamoDBDocument;
4
+ }
5
+ /**
6
+ * Registers the DynamoDB implementation of ApiCoreStorageOperationsFactory. ApiCoreFeature.register
7
+ * resolves + builds it. Mirrors HeadlessCmsDdbFeature.
8
+ */
9
+ export declare const ApiCoreDdbFeature: {
10
+ name: string;
11
+ register(container: import("@webiny/di").Container, context: ApiCoreDdbConfig): void;
12
+ };
@@ -0,0 +1,16 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ApiCoreStorageOperationsFactory } from "@webiny/api-core";
3
+ import { createApiCoreDdb } from "./createApiCoreDdb.js";
4
+ const ApiCoreDdbFeature = createFeature({
5
+ name: "ApiCoreDdb",
6
+ register (container, { documentClient }) {
7
+ container.registerInstance(ApiCoreStorageOperationsFactory, {
8
+ create: ()=>createApiCoreDdb({
9
+ documentClient
10
+ })
11
+ });
12
+ }
13
+ });
14
+ export { ApiCoreDdbFeature };
15
+
16
+ //# sourceMappingURL=ApiCoreDdbFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiCoreDdbFeature.js","sources":["../src/ApiCoreDdbFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { ApiCoreStorageOperationsFactory } from \"@webiny/api-core\";\nimport { createApiCoreDdb } from \"./createApiCoreDdb.js\";\n\nexport interface ApiCoreDdbConfig {\n documentClient: DynamoDBDocument;\n}\n\n/**\n * Registers the DynamoDB implementation of ApiCoreStorageOperationsFactory. ApiCoreFeature.register\n * resolves + builds it. Mirrors HeadlessCmsDdbFeature.\n */\nexport const ApiCoreDdbFeature = createFeature<ApiCoreDdbConfig>({\n name: \"ApiCoreDdb\",\n register(container, { documentClient }) {\n container.registerInstance(ApiCoreStorageOperationsFactory, {\n create: () => createApiCoreDdb({ documentClient })\n });\n }\n});\n"],"names":["ApiCoreDdbFeature","createFeature","container","documentClient","ApiCoreStorageOperationsFactory","createApiCoreDdb"],"mappings":";;;AAaO,MAAMA,oBAAoBC,cAAgC;IAC7D,MAAM;IACN,UAASC,SAAS,EAAE,EAAEC,cAAc,EAAE;QAClCD,UAAU,gBAAgB,CAACE,iCAAiC;YACxD,QAAQ,IAAMC,iBAAiB;oBAAEF;gBAAe;QACpD;IACJ;AACJ"}
@@ -1,8 +1,12 @@
1
+ import { ServiceDiscovery } from "@webiny/api-core/features/serviceDiscovery/index.js";
1
2
  import { createStorageOperations } from "./adminUsers/index.js";
2
3
  import { createStorageOperations as index_js_createStorageOperations } from "./tenancy/index.js";
3
4
  import { createStorageOperations as external_security_index_js_createStorageOperations } from "./security/index.js";
4
5
  import { createStorageOperations as external_keyValueStore_index_js_createStorageOperations } from "./keyValueStore/index.js";
5
- const createApiCoreDdb = ({ documentClient })=>({
6
+ import { DdbServiceManifestLoader } from "./serviceDiscovery/index.js";
7
+ const createApiCoreDdb = ({ documentClient })=>{
8
+ ServiceDiscovery.setLoader(new DdbServiceManifestLoader(documentClient));
9
+ return {
6
10
  usersStorageOperations: createStorageOperations({
7
11
  documentClient
8
12
  }),
@@ -15,7 +19,8 @@ const createApiCoreDdb = ({ documentClient })=>({
15
19
  keyValueStorageOperations: external_keyValueStore_index_js_createStorageOperations({
16
20
  documentClient
17
21
  })
18
- });
22
+ };
23
+ };
19
24
  export { createApiCoreDdb };
20
25
 
21
26
  //# sourceMappingURL=createApiCoreDdb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createApiCoreDdb.js","sources":["../src/createApiCoreDdb.ts"],"sourcesContent":["import type { ApiCoreStorageOperations } from \"@webiny/api-core/types/core.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStorageOperations as createUsersStorageOperations } from \"./adminUsers/index.js\";\nimport { createStorageOperations as createTenancyStorageOperations } from \"./tenancy/index.js\";\nimport { createStorageOperations as createSecurityStorageOperations } from \"./security/index.js\";\nimport { createStorageOperations as createKeyValueStorageOperations } from \"./keyValueStore/index.js\";\n\ninterface CreateApiCoreDdbParams {\n documentClient: DynamoDBDocument;\n}\n\nexport const createApiCoreDdb = ({\n documentClient\n}: CreateApiCoreDdbParams): ApiCoreStorageOperations => {\n return {\n usersStorageOperations: createUsersStorageOperations({\n documentClient\n }),\n tenancyStorageOperations: createTenancyStorageOperations({\n documentClient\n }),\n securityStorageOperations: createSecurityStorageOperations({\n documentClient\n }),\n keyValueStorageOperations: createKeyValueStorageOperations({\n documentClient\n })\n };\n};\n"],"names":["createApiCoreDdb","documentClient","createUsersStorageOperations","createTenancyStorageOperations","createSecurityStorageOperations","createKeyValueStorageOperations"],"mappings":";;;;AAWO,MAAMA,mBAAmB,CAAC,EAC7BC,cAAc,EACO,GACd;QACH,wBAAwBC,wBAA6B;YACjDD;QACJ;QACA,0BAA0BE,iCAA+B;YACrDF;QACJ;QACA,2BAA2BG,mDAAgC;YACvDH;QACJ;QACA,2BAA2BI,wDAAgC;YACvDJ;QACJ;IACJ"}
1
+ {"version":3,"file":"createApiCoreDdb.js","sources":["../src/createApiCoreDdb.ts"],"sourcesContent":["import type { ApiCoreStorageOperations } from \"@webiny/api-core/types/core.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\nimport { createStorageOperations as createUsersStorageOperations } from \"./adminUsers/index.js\";\nimport { createStorageOperations as createTenancyStorageOperations } from \"./tenancy/index.js\";\nimport { createStorageOperations as createSecurityStorageOperations } from \"./security/index.js\";\nimport { createStorageOperations as createKeyValueStorageOperations } from \"./keyValueStore/index.js\";\nimport { DdbServiceManifestLoader } from \"./serviceDiscovery/index.js\";\n\ninterface CreateApiCoreDdbParams {\n documentClient: DynamoDBDocument;\n}\n\nexport const createApiCoreDdb = ({\n documentClient\n}: CreateApiCoreDdbParams): ApiCoreStorageOperations => {\n ServiceDiscovery.setLoader(new DdbServiceManifestLoader(documentClient));\n\n return {\n usersStorageOperations: createUsersStorageOperations({\n documentClient\n }),\n tenancyStorageOperations: createTenancyStorageOperations({\n documentClient\n }),\n securityStorageOperations: createSecurityStorageOperations({\n documentClient\n }),\n keyValueStorageOperations: createKeyValueStorageOperations({\n documentClient\n })\n };\n};\n"],"names":["createApiCoreDdb","documentClient","ServiceDiscovery","DdbServiceManifestLoader","createUsersStorageOperations","createTenancyStorageOperations","createSecurityStorageOperations","createKeyValueStorageOperations"],"mappings":";;;;;;AAaO,MAAMA,mBAAmB,CAAC,EAC7BC,cAAc,EACO;IACrBC,iBAAiB,SAAS,CAAC,IAAIC,yBAAyBF;IAExD,OAAO;QACH,wBAAwBG,wBAA6B;YACjDH;QACJ;QACA,0BAA0BI,iCAA+B;YACrDJ;QACJ;QACA,2BAA2BK,mDAAgC;YACvDL;QACJ;QACA,2BAA2BM,wDAAgC;YACvDN;QACJ;IACJ;AACJ"}
package/index.d.ts CHANGED
@@ -1 +1,4 @@
1
1
  export * from "./createApiCoreDdb.js";
2
+ export { ApiCoreDdbFeature } from "./ApiCoreDdbFeature.js";
3
+ export type { ApiCoreDdbConfig } from "./ApiCoreDdbFeature.js";
4
+ export { DdbServiceManifestLoader } from "./serviceDiscovery/index.js";
package/index.js CHANGED
@@ -1 +1,3 @@
1
1
  export * from "./createApiCoreDdb.js";
2
+ export { ApiCoreDdbFeature } from "./ApiCoreDdbFeature.js";
3
+ export { DdbServiceManifestLoader } from "./serviceDiscovery/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-core-ddb",
3
- "version": "6.4.5-beta.0",
3
+ "version": "6.6.0-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -21,19 +21,20 @@
21
21
  "author": "Webiny Ltd.",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@webiny/api": "6.4.5-beta.0",
25
- "@webiny/api-core": "6.4.5-beta.0",
26
- "@webiny/aws-sdk": "6.4.5-beta.0",
27
- "@webiny/db-dynamodb": "6.4.5-beta.0",
28
- "@webiny/error": "6.4.5-beta.0"
24
+ "@webiny/api": "6.6.0-alpha.0",
25
+ "@webiny/api-core": "6.6.0-alpha.0",
26
+ "@webiny/aws-sdk": "6.6.0-alpha.0",
27
+ "@webiny/db-dynamodb": "6.6.0-alpha.0",
28
+ "@webiny/error": "6.6.0-alpha.0",
29
+ "@webiny/feature": "6.6.0-alpha.0"
29
30
  },
30
31
  "devDependencies": {
31
- "@webiny/api": "6.4.5-beta.0",
32
- "@webiny/build-tools": "6.4.5-beta.0",
33
- "@webiny/project-utils": "6.4.5-beta.0",
32
+ "@webiny/api": "6.6.0-alpha.0",
33
+ "@webiny/build-tools": "6.6.0-alpha.0",
34
+ "@webiny/project-utils": "6.6.0-alpha.0",
34
35
  "jest-dynalite": "3.6.1",
35
36
  "rimraf": "6.1.3",
36
- "typescript": "6.0.3"
37
+ "typescript": "7.0.2"
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public"
@@ -0,0 +1,7 @@
1
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ import type { IServiceManifestLoader } from "@webiny/api-core/features/serviceDiscovery/index.js";
3
+ export declare class DdbServiceManifestLoader implements IServiceManifestLoader {
4
+ private readonly client;
5
+ constructor(client: Pick<DynamoDBDocument, "send">);
6
+ load(): Promise<any[] | undefined>;
7
+ }
@@ -0,0 +1,27 @@
1
+ import { QueryCommand, unmarshall } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
+ class DdbServiceManifestLoader {
3
+ constructor(client){
4
+ this.client = client;
5
+ }
6
+ async load() {
7
+ const result = await this.client.send(new QueryCommand({
8
+ TableName: String(process.env.DB_TABLE),
9
+ IndexName: "GSI1",
10
+ KeyConditionExpression: "GSI1_PK = :GSI1_PK AND GSI1_SK > :GSI1_SK",
11
+ ExpressionAttributeValues: {
12
+ ":GSI1_PK": {
13
+ S: "SERVICE_MANIFESTS"
14
+ },
15
+ ":GSI1_SK": {
16
+ S: " "
17
+ }
18
+ }
19
+ }));
20
+ const items = result.Items;
21
+ if (!Array.isArray(items)) return;
22
+ return items.map((item)=>unmarshall(item).data);
23
+ }
24
+ }
25
+ export { DdbServiceManifestLoader };
26
+
27
+ //# sourceMappingURL=DdbServiceManifestLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serviceDiscovery/DdbServiceManifestLoader.js","sources":["../../src/serviceDiscovery/DdbServiceManifestLoader.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { QueryCommand } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { unmarshall } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { IServiceManifestLoader } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\n\nexport class DdbServiceManifestLoader implements IServiceManifestLoader {\n private readonly client: Pick<DynamoDBDocument, \"send\">;\n\n constructor(client: Pick<DynamoDBDocument, \"send\">) {\n this.client = client;\n }\n\n async load() {\n const result = await this.client.send(\n new QueryCommand({\n TableName: String(process.env.DB_TABLE),\n IndexName: \"GSI1\",\n KeyConditionExpression: \"GSI1_PK = :GSI1_PK AND GSI1_SK > :GSI1_SK\",\n ExpressionAttributeValues: {\n \":GSI1_PK\": { S: \"SERVICE_MANIFESTS\" },\n \":GSI1_SK\": { S: \" \" }\n }\n })\n );\n\n const items = result.Items;\n\n if (!Array.isArray(items)) {\n return undefined;\n }\n\n return items.map(item => unmarshall(item).data);\n }\n}\n"],"names":["DdbServiceManifestLoader","client","result","QueryCommand","String","process","items","Array","item","unmarshall"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,MAAsC,CAAE;QAChD,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAM,OAAO;QACT,MAAMC,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAIC,aAAa;YACb,WAAWC,OAAOC,QAAQ,GAAG,CAAC,QAAQ;YACtC,WAAW;YACX,wBAAwB;YACxB,2BAA2B;gBACvB,YAAY;oBAAE,GAAG;gBAAoB;gBACrC,YAAY;oBAAE,GAAG;gBAAI;YACzB;QACJ;QAGJ,MAAMC,QAAQJ,OAAO,KAAK;QAE1B,IAAI,CAACK,MAAM,OAAO,CAACD,QACf;QAGJ,OAAOA,MAAM,GAAG,CAACE,CAAAA,OAAQC,WAAWD,MAAM,IAAI;IAClD;AACJ"}
@@ -0,0 +1 @@
1
+ export { DdbServiceManifestLoader } from "./DdbServiceManifestLoader.js";
@@ -0,0 +1 @@
1
+ export { DdbServiceManifestLoader } from "./DdbServiceManifestLoader.js";