@hapiboo/dynamo-flux 1.0.0 → 1.0.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.
@@ -3,6 +3,7 @@ import { IFluxIndexInfo, IFluxIndexData, IFluxDataModel, IFluxDataModelDefinitio
3
3
  export declare class AWSDynamoDBProviderFlux implements IDBProviderFlux {
4
4
  constructor(database: string, region: string);
5
5
  init(definition: IFluxDataModelDefinition): IResponsePromiseVoid;
6
+ count(model: IFluxDataModel): IResponsePromise<number>;
6
7
  read<T extends IFluxObject>(reader: IFluxDataModelReader<T>): IResponsePromise<T>;
7
8
  array<T extends IFluxObject>(reader: IFluxDataModelReader<T>, filter: IFluxDBFilter | undefined, queryLimit: number | undefined): IResponsePromise<T[]>;
8
9
  query<T extends IFluxObject>(reader: IFluxDataModelReader<T>, info: IFluxIndexInfo, data: IFluxIndexData, filter: IFluxDBFilter | undefined, queryLimit: number | undefined): IResponsePromise<T[]>;
package/dist/provider.js CHANGED
@@ -202,7 +202,7 @@ var dynamoHelper;
202
202
  const idx = Array();
203
203
  const attrs = Array();
204
204
  const addedAttributes = Array();
205
- attrs.push({ AttributeName: 'id', AttributeType: flux_1.FluxColumnPrimary.String });
205
+ attrs.push({ AttributeName: 'id', AttributeType: flux_1.FluxColumn.String });
206
206
  addedAttributes.push('id');
207
207
  if (definition.indexes.length > 0) {
208
208
  definition.indexes.forEach((item) => {
@@ -564,6 +564,18 @@ class AWSDynamoDBProviderFlux {
564
564
  });
565
565
  });
566
566
  }
567
+ count(model) {
568
+ return core_1.promise.createDelayedPromise((resolve, reject) => {
569
+ new ScanReader(new CountDataModelReader(), dynamoHelper.prepare.readFilter(model.table, undefined), undefined).start()
570
+ .then((items) => {
571
+ resolve(items.length);
572
+ })
573
+ .catch((error) => {
574
+ console.error(`Dynamo Error Count: [${model.table}] - ${error.message}`);
575
+ reject(error);
576
+ });
577
+ });
578
+ }
567
579
  read(reader) {
568
580
  return core_1.promise.createDelayedPromise((resolve, reject) => {
569
581
  dynamoHelper.config.getClient().send(new client_dynamodb_1.GetItemCommand(dynamoHelper.prepare.readOne(reader.table, reader.id)))
@@ -658,3 +670,17 @@ class AWSDynamoDBProviderFlux {
658
670
  }
659
671
  }
660
672
  exports.AWSDynamoDBProviderFlux = AWSDynamoDBProviderFlux;
673
+ class CountDataModel {
674
+ constructor() {
675
+ this.id = '';
676
+ }
677
+ }
678
+ class CountDataModelReader {
679
+ constructor() {
680
+ this.table = '';
681
+ this.id = '';
682
+ }
683
+ clone(_object) {
684
+ return new CountDataModel();
685
+ }
686
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hapiboo/dynamo-flux",
3
3
  "description": "MK13 Studio Hapiboo - AWS DynamoDB plugin (Flux version)",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "author": "MK13 Studio",
6
6
  "license": "ISC",
7
7
  "main": "dist/index.js",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@hapiboo/core": "^3.0.1",
17
- "@hapiboo/flux": "^1.0.0",
17
+ "@hapiboo/flux": "^1.0.4",
18
18
  "@aws-sdk/client-dynamodb": "^3.848.0"
19
19
  },
20
20
  "devDependencies": {
@@ -25,8 +25,10 @@
25
25
  "typescript-eslint": "^8.51.0"
26
26
  },
27
27
  "scripts": {
28
+ "version-to-publish": "pnpm exec tsx ../../scripts/version_update.ts packages/dynamo-flux --publish-version",
28
29
  "publish-check": "bash ../../scripts/publish.sh ./",
30
+ "version-to-children": "pnpm exec tsx ../../scripts/version_update.ts packages/dynamo-flux --update-children",
29
31
  "ci:publish-prepare": "rm -f pnpm-lock.yaml && rm -rf node_modules dist && pnpm install --ignore-workspace --no-frozen-lockfile && eslint 'src/*.ts' && echo \"Linter OK\" && tsc && echo \"Build OK\"",
30
- "ci:publish": "pnpm ci:publish-prepare && pnpm publish-check"
32
+ "ci:publish": "pnpm ci:publish-prepare && pnpm version-to-publish && pnpm publish-check && pnpm version-to-children"
31
33
  }
32
34
  }