@webiny/db-dynamodb 6.0.0-alpha.5 → 6.0.0-rc.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/DynamoDbDriver.d.ts +4 -8
- package/DynamoDbDriver.js +71 -102
- package/DynamoDbDriver.js.map +1 -1
- package/README.md +6 -142
- package/index.d.ts +4 -3
- package/index.js +4 -28
- package/index.js.map +1 -1
- package/package.json +18 -20
- package/plugins/definitions/AttributePlugin.d.ts +1 -1
- package/plugins/definitions/AttributePlugin.js +4 -12
- package/plugins/definitions/AttributePlugin.js.map +1 -1
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/DateTimeTransformPlugin.js +6 -14
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/FieldPathPlugin.js +6 -14
- package/plugins/definitions/FieldPathPlugin.js.map +1 -1
- package/plugins/definitions/FieldPlugin.d.ts +1 -1
- package/plugins/definitions/FieldPlugin.js +2 -9
- package/plugins/definitions/FieldPlugin.js.map +1 -1
- package/plugins/definitions/TimeTransformPlugin.d.ts +2 -2
- package/plugins/definitions/TimeTransformPlugin.js +7 -15
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -1
- package/plugins/definitions/ValueFilterPlugin.js +5 -13
- package/plugins/definitions/ValueFilterPlugin.js.map +1 -1
- package/plugins/definitions/ValueTransformPlugin.js +6 -14
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
- package/plugins/definitions/assignFields.js +4 -12
- package/plugins/definitions/assignFields.js.map +1 -1
- package/plugins/filters/andIn.d.ts +1 -1
- package/plugins/filters/andIn.js +5 -12
- package/plugins/filters/andIn.js.map +1 -1
- package/plugins/filters/between.d.ts +1 -1
- package/plugins/filters/between.js +5 -12
- package/plugins/filters/between.js.map +1 -1
- package/plugins/filters/contains.d.ts +1 -1
- package/plugins/filters/contains.js +3 -9
- package/plugins/filters/contains.js.map +1 -1
- package/plugins/filters/eq.d.ts +1 -1
- package/plugins/filters/eq.js +3 -9
- package/plugins/filters/eq.js.map +1 -1
- package/plugins/filters/fuzzy.d.ts +1 -1
- package/plugins/filters/fuzzy.js +5 -12
- package/plugins/filters/fuzzy.js.map +1 -1
- package/plugins/filters/gt.d.ts +1 -1
- package/plugins/filters/gt.js +3 -9
- package/plugins/filters/gt.js.map +1 -1
- package/plugins/filters/gte.d.ts +1 -1
- package/plugins/filters/gte.js +3 -9
- package/plugins/filters/gte.js.map +1 -1
- package/plugins/filters/in.d.ts +1 -1
- package/plugins/filters/in.js +5 -12
- package/plugins/filters/in.js.map +1 -1
- package/plugins/filters/index.d.ts +1 -1
- package/plugins/filters/index.js +12 -20
- package/plugins/filters/index.js.map +1 -1
- package/plugins/filters/lt.d.ts +1 -1
- package/plugins/filters/lt.js +3 -9
- package/plugins/filters/lt.js.map +1 -1
- package/plugins/filters/lte.d.ts +1 -1
- package/plugins/filters/lte.js +3 -9
- package/plugins/filters/lte.js.map +1 -1
- package/plugins/filters/startsWith.d.ts +1 -1
- package/plugins/filters/startsWith.js +3 -9
- package/plugins/filters/startsWith.js.map +1 -1
- package/plugins/index.d.ts +9 -1
- package/plugins/index.js +11 -11
- package/plugins/index.js.map +1 -1
- package/store/entity.d.ts +4 -76
- package/store/entity.js +5 -35
- package/store/entity.js.map +1 -1
- package/store/keys.d.ts +1 -1
- package/store/keys.js +7 -13
- package/store/keys.js.map +1 -1
- package/store/types.d.ts +3 -4
- package/store/types.js +1 -5
- package/store/types.js.map +1 -1
- package/toolbox.d.ts +7 -2
- package/toolbox.js +2 -17
- package/toolbox.js.map +1 -1
- package/types.js +1 -5
- package/utils/attributes.d.ts +2 -2
- package/utils/attributes.js +4 -12
- package/utils/attributes.js.map +1 -1
- package/utils/batch/batchRead.d.ts +2 -2
- package/utils/batch/batchRead.js +5 -13
- package/utils/batch/batchRead.js.map +1 -1
- package/utils/batch/batchWrite.d.ts +2 -2
- package/utils/batch/batchWrite.js +3 -11
- package/utils/batch/batchWrite.js.map +1 -1
- package/utils/batch/index.d.ts +3 -3
- package/utils/batch/index.js +3 -38
- package/utils/batch/index.js.map +1 -1
- package/utils/batch/types.d.ts +7 -2
- package/utils/batch/types.js +1 -5
- package/utils/batch/types.js.map +1 -1
- package/utils/cleanup.d.ts +1 -1
- package/utils/cleanup.js +3 -10
- package/utils/cleanup.js.map +1 -1
- package/utils/count.d.ts +1 -1
- package/utils/count.js +1 -8
- package/utils/count.js.map +1 -1
- package/utils/createEntity.d.ts +36 -54
- package/utils/createEntity.js +75 -51
- package/utils/createEntity.js.map +1 -1
- package/utils/createTable.d.ts +10 -7
- package/utils/createTable.js +25 -15
- package/utils/createTable.js.map +1 -1
- package/utils/cursor.js +2 -10
- package/utils/cursor.js.map +1 -1
- package/utils/delete.d.ts +1 -1
- package/utils/delete.js +1 -8
- package/utils/delete.js.map +1 -1
- package/utils/entity/Entity.d.ts +23 -21
- package/utils/entity/Entity.js +56 -34
- package/utils/entity/Entity.js.map +1 -1
- package/utils/entity/EntityReadBatch.d.ts +9 -8
- package/utils/entity/EntityReadBatch.js +14 -16
- package/utils/entity/EntityReadBatch.js.map +1 -1
- package/utils/entity/EntityReadBatchBuilder.d.ts +4 -4
- package/utils/entity/EntityReadBatchBuilder.js +7 -15
- package/utils/entity/EntityReadBatchBuilder.js.map +1 -1
- package/utils/entity/EntityWriteBatch.d.ts +9 -8
- package/utils/entity/EntityWriteBatch.js +10 -18
- package/utils/entity/EntityWriteBatch.js.map +1 -1
- package/utils/entity/EntityWriteBatchBuilder.d.ts +4 -4
- package/utils/entity/EntityWriteBatchBuilder.js +4 -12
- package/utils/entity/EntityWriteBatchBuilder.js.map +1 -1
- package/utils/entity/getEntity.d.ts +2 -2
- package/utils/entity/getEntity.js +3 -10
- package/utils/entity/getEntity.js.map +1 -1
- package/utils/entity/index.d.ts +7 -7
- package/utils/entity/index.js +7 -82
- package/utils/entity/index.js.map +1 -1
- package/utils/entity/types.d.ts +46 -22
- package/utils/entity/types.js +2 -5
- package/utils/entity/types.js.map +1 -1
- package/utils/filter.d.ts +1 -1
- package/utils/filter.js +7 -14
- package/utils/filter.js.map +1 -1
- package/utils/get.d.ts +1 -1
- package/utils/get.js +4 -12
- package/utils/get.js.map +1 -1
- package/utils/index.d.ts +17 -17
- package/utils/index.js +17 -192
- package/utils/index.js.map +1 -1
- package/utils/listResponse.js +4 -10
- package/utils/listResponse.js.map +1 -1
- package/utils/put.d.ts +2 -2
- package/utils/put.js +1 -8
- package/utils/put.js.map +1 -1
- package/utils/query.d.ts +5 -12
- package/utils/query.js +13 -27
- package/utils/query.js.map +1 -1
- package/utils/scan.d.ts +2 -2
- package/utils/scan.js +5 -13
- package/utils/scan.js.map +1 -1
- package/utils/sort.d.ts +1 -1
- package/utils/sort.js +7 -14
- package/utils/sort.js.map +1 -1
- package/utils/table/Table.d.ts +4 -5
- package/utils/table/Table.js +9 -20
- package/utils/table/Table.js.map +1 -1
- package/utils/table/TableReadBatch.d.ts +4 -4
- package/utils/table/TableReadBatch.js +8 -16
- package/utils/table/TableReadBatch.js.map +1 -1
- package/utils/table/TableWriteBatch.d.ts +3 -3
- package/utils/table/TableWriteBatch.js +6 -14
- package/utils/table/TableWriteBatch.js.map +1 -1
- package/utils/table/index.d.ts +4 -4
- package/utils/table/index.js +4 -49
- package/utils/table/index.js.map +1 -1
- package/utils/table/types.d.ts +8 -8
- package/utils/table/types.js +1 -5
- package/utils/table/types.js.map +1 -1
- package/utils/update.d.ts +1 -1
- package/utils/update.js +1 -8
- package/utils/update.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Entity","BaseEntity","put","get","getClean","deleteItem","createEntityReadBatch","createEntityWriteBatch","createTableWriteBatch","queryAll","queryAllClean","queryOne","queryOneClean","queryPerPage","name","entity","table","constructor","params","createEntityReader","read","createEntityWriter","delete","createTableWriter","item","keys","createEntity"],"sources":["Entity.ts"],"sourcesContent":["import type {\n AttributeDefinitions,\n EntityConstructor as BaseEntityConstructor,\n Readonly,\n TableDef\n} from \"~/toolbox.js\";\nimport { Entity as BaseEntity } from \"~/toolbox.js\";\nimport type { ITableWriteBatch } from \"../table/types.js\";\nimport type {\n IEntity,\n IEntityCreateEntityReaderParams,\n IEntityCreateEntityWriterParams,\n IEntityDeleteResult,\n IEntityGetCleanResult,\n IEntityGetResult,\n IEntityPutResult,\n IEntityQueryAllCleanResult,\n IEntityQueryAllParams,\n IEntityQueryAllResult,\n IEntityQueryOneCleanResult,\n IEntityQueryOneParams,\n IEntityQueryOneResult,\n IEntityQueryPerPageParams,\n IEntityReadBatch,\n IEntityWriteBatch\n} from \"./types.js\";\nimport type { IPutParamsItem } from \"../put.js\";\nimport { put } from \"../put.js\";\nimport type { GetRecordParamsKeys } from \"../get.js\";\nimport { get, getClean } from \"../get.js\";\nimport type { IDeleteItemKeys } from \"../delete.js\";\nimport { deleteItem } from \"../delete.js\";\nimport { createEntityReadBatch } from \"./EntityReadBatch.js\";\nimport { createEntityWriteBatch } from \"./EntityWriteBatch.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { queryAll, queryAllClean, queryOne, queryOneClean, queryPerPage } from \"../query.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport type EntityConstructor<\n T extends Readonly<AttributeDefinitions> = Readonly<AttributeDefinitions>\n> = BaseEntityConstructor<\n TableDef,\n string,\n true,\n true,\n true,\n \"created\",\n \"modified\",\n \"entity\",\n false,\n T\n>;\n\nexport class Entity<T extends GenericRecord = GenericRecord> implements IEntity<T> {\n public readonly entity: BaseEntity;\n\n public get name(): string {\n return this.entity.name;\n }\n\n public get table(): TableDef {\n /**\n * Not possible to be undefined.\n */\n return this.entity.table!;\n }\n\n public constructor(params: EntityConstructor) {\n this.entity = new BaseEntity(params);\n }\n\n public createEntityReader(params?: IEntityCreateEntityReaderParams): IEntityReadBatch<T> {\n return createEntityReadBatch({\n entity: this.entity,\n read: params?.read\n });\n }\n\n public createEntityWriter(params?: IEntityCreateEntityWriterParams): IEntityWriteBatch<T> {\n return createEntityWriteBatch({\n entity: this.entity,\n put: params?.put,\n delete: params?.delete\n });\n }\n\n public createTableWriter(): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity.table as TableDef\n });\n }\n\n public async put<T extends GenericRecord = GenericRecord>(\n item: IPutParamsItem<T>\n ): IEntityPutResult {\n return put({\n entity: this.entity,\n item\n });\n }\n\n public async get<T>(keys: GetRecordParamsKeys): IEntityGetResult<T> {\n return get<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async getClean<T>(keys: GetRecordParamsKeys): IEntityGetCleanResult<T> {\n return getClean<T>({\n entity: this.entity,\n keys\n });\n }\n\n public async delete(keys: IDeleteItemKeys): IEntityDeleteResult {\n return deleteItem({\n entity: this.entity,\n keys\n });\n }\n\n public async queryOne<T>(params: IEntityQueryOneParams): IEntityQueryOneResult<T> {\n return queryOne<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryOneClean<T>(params: IEntityQueryOneParams): IEntityQueryOneCleanResult<T> {\n return queryOneClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAll<T>(params: IEntityQueryAllParams): IEntityQueryAllResult<T> {\n return queryAll<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryAllClean<T>(params: IEntityQueryAllParams): IEntityQueryAllCleanResult<T> {\n return queryAllClean<T>({\n ...params,\n entity: this.entity\n });\n }\n\n public async queryPerPage<T>(params: IEntityQueryPerPageParams) {\n return queryPerPage<T>({\n ...params,\n entity: this.entity\n });\n }\n}\n\nexport const createEntity = <T extends GenericRecord = GenericRecord>(\n params: EntityConstructor\n): IEntity<T> => {\n return new Entity<T>(params);\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { IEntityReadBatch, IEntityReadBatchKey } from "./types";
|
|
3
|
-
import type {
|
|
4
|
-
import type { EntityOption } from "./getEntity";
|
|
1
|
+
import type { IReadBatchItem } from "../../utils/batch/types.js";
|
|
2
|
+
import type { IEntityReadBatch, IEntityReadBatchBuilderGetResponse, IEntityReadBatchKey } from "./types.js";
|
|
3
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
4
|
export interface IEntityReadBatchParams {
|
|
6
5
|
entity: EntityOption;
|
|
7
|
-
read?:
|
|
6
|
+
read?: IReadBatchItem[];
|
|
8
7
|
}
|
|
9
|
-
export declare class EntityReadBatch implements IEntityReadBatch {
|
|
8
|
+
export declare class EntityReadBatch<T> implements IEntityReadBatch<T> {
|
|
10
9
|
private readonly entity;
|
|
11
10
|
private readonly builder;
|
|
12
11
|
private readonly _items;
|
|
12
|
+
get total(): number;
|
|
13
|
+
get items(): IEntityReadBatchBuilderGetResponse[];
|
|
13
14
|
constructor(params: IEntityReadBatchParams);
|
|
14
15
|
get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void;
|
|
15
|
-
execute
|
|
16
|
+
execute(): Promise<T[]>;
|
|
16
17
|
}
|
|
17
|
-
export declare const createEntityReadBatch: (params: IEntityReadBatchParams) => IEntityReadBatch
|
|
18
|
+
export declare const createEntityReadBatch: <T>(params: IEntityReadBatchParams) => IEntityReadBatch<T>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.createEntityReadBatch = exports.EntityReadBatch = void 0;
|
|
7
|
-
var _batchRead = require("../batch/batchRead");
|
|
8
|
-
var _EntityReadBatchBuilder = require("./EntityReadBatchBuilder");
|
|
9
|
-
var _getEntity = require("./getEntity");
|
|
10
|
-
class EntityReadBatch {
|
|
1
|
+
import { batchReadAll } from "../batch/batchRead.js";
|
|
2
|
+
import { createEntityReadBatchBuilder } from "./EntityReadBatchBuilder.js";
|
|
3
|
+
import { getEntity } from "./getEntity.js";
|
|
4
|
+
export class EntityReadBatch {
|
|
11
5
|
_items = [];
|
|
6
|
+
get total() {
|
|
7
|
+
return this._items.length;
|
|
8
|
+
}
|
|
9
|
+
get items() {
|
|
10
|
+
return Array.from(this._items);
|
|
11
|
+
}
|
|
12
12
|
constructor(params) {
|
|
13
|
-
this.entity =
|
|
14
|
-
this.builder =
|
|
13
|
+
this.entity = getEntity(params.entity);
|
|
14
|
+
this.builder = createEntityReadBatchBuilder(this.entity);
|
|
15
15
|
for (const item of params.read || []) {
|
|
16
16
|
this.get(item);
|
|
17
17
|
}
|
|
@@ -26,16 +26,14 @@ class EntityReadBatch {
|
|
|
26
26
|
this._items.push(this.builder.get(input));
|
|
27
27
|
}
|
|
28
28
|
async execute() {
|
|
29
|
-
return await
|
|
29
|
+
return await batchReadAll({
|
|
30
30
|
table: this.entity.table,
|
|
31
31
|
items: this._items
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
const createEntityReadBatch = params => {
|
|
35
|
+
export const createEntityReadBatch = params => {
|
|
37
36
|
return new EntityReadBatch(params);
|
|
38
37
|
};
|
|
39
|
-
exports.createEntityReadBatch = createEntityReadBatch;
|
|
40
38
|
|
|
41
39
|
//# sourceMappingURL=EntityReadBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["batchReadAll","createEntityReadBatchBuilder","getEntity","EntityReadBatch","_items","total","length","items","Array","from","constructor","params","entity","builder","item","read","get","input","isArray","push","map","execute","table","createEntityReadBatch"],"sources":["EntityReadBatch.ts"],"sourcesContent":["import type { IReadBatchItem } from \"~/utils/batch/types.js\";\nimport type {\n IEntityReadBatch,\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchReadAll } from \"~/utils/batch/batchRead.js\";\nimport { createEntityReadBatchBuilder } from \"./EntityReadBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport interface IEntityReadBatchParams {\n entity: EntityOption;\n read?: IReadBatchItem[];\n}\n\nexport class EntityReadBatch<T> implements IEntityReadBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly builder: IEntityReadBatchBuilder;\n private readonly _items: IEntityReadBatchBuilderGetResponse[] = [];\n\n public get total(): number {\n return this._items.length;\n }\n\n public get items(): IEntityReadBatchBuilderGetResponse[] {\n return Array.from(this._items);\n }\n\n public constructor(params: IEntityReadBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityReadBatchBuilder(this.entity);\n for (const item of params.read || []) {\n this.get(item);\n }\n }\n\n public get(input: IEntityReadBatchKey | IEntityReadBatchKey[]): void {\n if (Array.isArray(input)) {\n this._items.push(\n ...input.map(item => {\n return this.builder.get(item);\n })\n );\n return;\n }\n this._items.push(this.builder.get(input));\n }\n\n public async execute() {\n return await batchReadAll<T>({\n table: this.entity.table as TableDef,\n items: this._items\n });\n }\n}\n\nexport const createEntityReadBatch = <T>(params: IEntityReadBatchParams): IEntityReadBatch<T> => {\n return new EntityReadBatch<T>(params);\n};\n"],"mappings":"AAQA,SAASA,YAAY;AACrB,SAASC,4BAA4B;AAErC,SAASC,SAAS;AAOlB,OAAO,MAAMC,eAAe,CAAmC;EAG1CC,MAAM,GAAyC,EAAE;EAElE,IAAWC,KAAKA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACD,MAAM,CAACE,MAAM;EAC7B;EAEA,IAAWC,KAAKA,CAAA,EAAyC;IACrD,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACL,MAAM,CAAC;EAClC;EAEOM,WAAWA,CAACC,MAA8B,EAAE;IAC/C,IAAI,CAACC,MAAM,GAAGV,SAAS,CAACS,MAAM,CAACC,MAAM,CAAC;IACtC,IAAI,CAACC,OAAO,GAAGZ,4BAA4B,CAAC,IAAI,CAACW,MAAM,CAAC;IACxD,KAAK,MAAME,IAAI,IAAIH,MAAM,CAACI,IAAI,IAAI,EAAE,EAAE;MAClC,IAAI,CAACC,GAAG,CAACF,IAAI,CAAC;IAClB;EACJ;EAEOE,GAAGA,CAACC,KAAkD,EAAQ;IACjE,IAAIT,KAAK,CAACU,OAAO,CAACD,KAAK,CAAC,EAAE;MACtB,IAAI,CAACb,MAAM,CAACe,IAAI,CACZ,GAAGF,KAAK,CAACG,GAAG,CAACN,IAAI,IAAI;QACjB,OAAO,IAAI,CAACD,OAAO,CAACG,GAAG,CAACF,IAAI,CAAC;MACjC,CAAC,CACL,CAAC;MACD;IACJ;IACA,IAAI,CAACV,MAAM,CAACe,IAAI,CAAC,IAAI,CAACN,OAAO,CAACG,GAAG,CAACC,KAAK,CAAC,CAAC;EAC7C;EAEA,MAAaI,OAAOA,CAAA,EAAG;IACnB,OAAO,MAAMrB,YAAY,CAAI;MACzBsB,KAAK,EAAE,IAAI,CAACV,MAAM,CAACU,KAAiB;MACpCf,KAAK,EAAE,IAAI,CAACH;IAChB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMmB,qBAAqB,GAAOZ,MAA8B,IAA0B;EAC7F,OAAO,IAAIR,eAAe,CAAIQ,MAAM,CAAC;AACzC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Entity as ToolboxEntity } from "../../toolbox";
|
|
2
|
-
import type { IEntityReadBatchBuilder, IEntityReadBatchBuilderGetResponse, IEntityReadBatchKey } from "./types";
|
|
3
|
-
import type { Entity } from "./Entity";
|
|
4
|
-
import type { EntityOption } from "./getEntity";
|
|
1
|
+
import type { Entity as ToolboxEntity } from "../../toolbox.js";
|
|
2
|
+
import type { IEntityReadBatchBuilder, IEntityReadBatchBuilderGetResponse, IEntityReadBatchKey } from "./types.js";
|
|
3
|
+
import type { Entity } from "./Entity.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
5
|
export declare class EntityReadBatchBuilder implements IEntityReadBatchBuilder {
|
|
6
6
|
private readonly entity;
|
|
7
7
|
constructor(entity: EntityOption);
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEntityReadBatchBuilder = exports.EntityReadBatchBuilder = void 0;
|
|
7
|
-
var _error = require("@webiny/error");
|
|
8
|
-
var _getEntity = require("./getEntity");
|
|
9
|
-
class EntityReadBatchBuilder {
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { getEntity } from "./getEntity.js";
|
|
3
|
+
export class EntityReadBatchBuilder {
|
|
10
4
|
constructor(entity) {
|
|
11
|
-
this.entity =
|
|
5
|
+
this.entity = getEntity(entity);
|
|
12
6
|
}
|
|
13
7
|
get(item) {
|
|
14
8
|
const result = this.entity.getBatch(item);
|
|
15
9
|
if (!result.Table) {
|
|
16
|
-
throw new
|
|
10
|
+
throw new WebinyError(`No table provided for entity ${this.entity.name}.`);
|
|
17
11
|
} else if (!result.Key) {
|
|
18
|
-
throw new
|
|
12
|
+
throw new WebinyError(`No key provided for entity ${this.entity.name}.`);
|
|
19
13
|
}
|
|
20
14
|
return result;
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
const createEntityReadBatchBuilder = entity => {
|
|
17
|
+
export const createEntityReadBatchBuilder = entity => {
|
|
25
18
|
return new EntityReadBatchBuilder(entity);
|
|
26
19
|
};
|
|
27
|
-
exports.createEntityReadBatchBuilder = createEntityReadBatchBuilder;
|
|
28
20
|
|
|
29
21
|
//# sourceMappingURL=EntityReadBatchBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","getEntity","EntityReadBatchBuilder","constructor","entity","get","item","result","getBatch","Table","name","Key","createEntityReadBatchBuilder"],"sources":["EntityReadBatchBuilder.ts"],"sourcesContent":["import type { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type {\n IEntityReadBatchBuilder,\n IEntityReadBatchBuilderGetResponse,\n IEntityReadBatchKey\n} from \"./types.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { Entity } from \"./Entity.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityReadBatchBuilder implements IEntityReadBatchBuilder {\n private readonly entity: ToolboxEntity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public get(item: IEntityReadBatchKey): IEntityReadBatchBuilderGetResponse {\n const result = this.entity.getBatch(item);\n if (!result.Table) {\n throw new WebinyError(`No table provided for entity ${this.entity.name}.`);\n } else if (!result.Key) {\n throw new WebinyError(`No key provided for entity ${this.entity.name}.`);\n }\n return result as unknown as IEntityReadBatchBuilderGetResponse;\n }\n}\n\nexport const createEntityReadBatchBuilder = (\n entity: ToolboxEntity | Entity\n): IEntityReadBatchBuilder => {\n return new EntityReadBatchBuilder(entity);\n};\n"],"mappings":"AAMA,SAASA,WAAW,QAAQ,eAAe;AAG3C,SAASC,SAAS;AAElB,OAAO,MAAMC,sBAAsB,CAAoC;EAG5DC,WAAWA,CAACC,MAAoB,EAAE;IACrC,IAAI,CAACA,MAAM,GAAGH,SAAS,CAACG,MAAM,CAAC;EACnC;EAEOC,GAAGA,CAACC,IAAyB,EAAsC;IACtE,MAAMC,MAAM,GAAG,IAAI,CAACH,MAAM,CAACI,QAAQ,CAACF,IAAI,CAAC;IACzC,IAAI,CAACC,MAAM,CAACE,KAAK,EAAE;MACf,MAAM,IAAIT,WAAW,CAAC,gCAAgC,IAAI,CAACI,MAAM,CAACM,IAAI,GAAG,CAAC;IAC9E,CAAC,MAAM,IAAI,CAACH,MAAM,CAACI,GAAG,EAAE;MACpB,MAAM,IAAIX,WAAW,CAAC,8BAA8B,IAAI,CAACI,MAAM,CAACM,IAAI,GAAG,CAAC;IAC5E;IACA,OAAOH,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,4BAA4B,GACrCR,MAA8B,IACJ;EAC1B,OAAO,IAAIF,sBAAsB,CAACE,MAAM,CAAC;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "
|
|
2
|
-
import type { IEntityWriteBatch } from "./types";
|
|
3
|
-
import type { ITableWriteBatch } from "
|
|
4
|
-
import type { EntityOption } from "./getEntity";
|
|
5
|
-
|
|
1
|
+
import type { BatchWriteItem, BatchWriteResult, IDeleteBatchItem, IPutBatchItem } from "../../utils/batch/types.js";
|
|
2
|
+
import type { IEntityWriteBatch } from "./types.js";
|
|
3
|
+
import type { ITableWriteBatch } from "../../utils/table/types.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
6
|
+
export interface IEntityWriteBatchParams<T = GenericRecord> {
|
|
6
7
|
entity: EntityOption;
|
|
7
|
-
put?: IPutBatchItem[];
|
|
8
|
+
put?: IPutBatchItem<T>[];
|
|
8
9
|
delete?: IDeleteBatchItem[];
|
|
9
10
|
}
|
|
10
|
-
export declare class EntityWriteBatch implements IEntityWriteBatch {
|
|
11
|
+
export declare class EntityWriteBatch<T> implements IEntityWriteBatch<T> {
|
|
11
12
|
private readonly entity;
|
|
12
13
|
private readonly _items;
|
|
13
14
|
private readonly builder;
|
|
14
15
|
get total(): number;
|
|
15
16
|
get items(): BatchWriteItem[];
|
|
16
17
|
constructor(params: IEntityWriteBatchParams);
|
|
17
|
-
put
|
|
18
|
+
put(item: IPutBatchItem<T>): void;
|
|
18
19
|
delete(item: IDeleteBatchItem): void;
|
|
19
20
|
combine(items: BatchWriteItem[]): ITableWriteBatch;
|
|
20
21
|
execute(): Promise<BatchWriteResult>;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.createEntityWriteBatch = exports.EntityWriteBatch = void 0;
|
|
7
|
-
var _batchWrite = require("../batch/batchWrite");
|
|
8
|
-
var _TableWriteBatch = require("../table/TableWriteBatch");
|
|
9
|
-
var _EntityWriteBatchBuilder = require("./EntityWriteBatchBuilder");
|
|
10
|
-
var _getEntity = require("./getEntity");
|
|
11
|
-
class EntityWriteBatch {
|
|
1
|
+
import { batchWriteAll } from "../batch/batchWrite.js";
|
|
2
|
+
import { createTableWriteBatch } from "../table/TableWriteBatch.js";
|
|
3
|
+
import { createEntityWriteBatchBuilder } from "./EntityWriteBatchBuilder.js";
|
|
4
|
+
import { getEntity } from "./getEntity.js";
|
|
5
|
+
export class EntityWriteBatch {
|
|
12
6
|
_items = [];
|
|
13
7
|
get total() {
|
|
14
8
|
return this._items.length;
|
|
@@ -17,8 +11,8 @@ class EntityWriteBatch {
|
|
|
17
11
|
return Array.from(this._items);
|
|
18
12
|
}
|
|
19
13
|
constructor(params) {
|
|
20
|
-
this.entity =
|
|
21
|
-
this.builder =
|
|
14
|
+
this.entity = getEntity(params.entity);
|
|
15
|
+
this.builder = createEntityWriteBatchBuilder(this.entity);
|
|
22
16
|
for (const item of params.put || []) {
|
|
23
17
|
this.put(item);
|
|
24
18
|
}
|
|
@@ -33,7 +27,7 @@ class EntityWriteBatch {
|
|
|
33
27
|
this._items.push(this.builder.delete(item));
|
|
34
28
|
}
|
|
35
29
|
combine(items) {
|
|
36
|
-
return
|
|
30
|
+
return createTableWriteBatch({
|
|
37
31
|
table: this.entity.table,
|
|
38
32
|
items: this._items.concat(items)
|
|
39
33
|
});
|
|
@@ -44,16 +38,14 @@ class EntityWriteBatch {
|
|
|
44
38
|
}
|
|
45
39
|
const items = Array.from(this._items);
|
|
46
40
|
this._items.length = 0;
|
|
47
|
-
return await
|
|
41
|
+
return await batchWriteAll({
|
|
48
42
|
items,
|
|
49
43
|
table: this.entity.table
|
|
50
44
|
});
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
|
|
54
|
-
const createEntityWriteBatch = params => {
|
|
47
|
+
export const createEntityWriteBatch = params => {
|
|
55
48
|
return new EntityWriteBatch(params);
|
|
56
49
|
};
|
|
57
|
-
exports.createEntityWriteBatch = createEntityWriteBatch;
|
|
58
50
|
|
|
59
51
|
//# sourceMappingURL=EntityWriteBatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["batchWriteAll","createTableWriteBatch","createEntityWriteBatchBuilder","getEntity","EntityWriteBatch","_items","total","length","items","Array","from","constructor","params","entity","builder","item","put","delete","push","combine","table","concat","execute","createEntityWriteBatch"],"sources":["EntityWriteBatch.ts"],"sourcesContent":["import type { Entity as ToolboxEntity, TableDef } from \"~/toolbox.js\";\nimport { batchWriteAll } from \"~/utils/batch/batchWrite.js\";\nimport type {\n BatchWriteItem,\n BatchWriteResult,\n IDeleteBatchItem,\n IPutBatchItem\n} from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatch, IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { ITableWriteBatch } from \"~/utils/table/types.js\";\nimport { createTableWriteBatch } from \"~/utils/table/TableWriteBatch.js\";\nimport { createEntityWriteBatchBuilder } from \"./EntityWriteBatchBuilder.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IEntityWriteBatchParams<T = GenericRecord> {\n entity: EntityOption;\n put?: IPutBatchItem<T>[];\n delete?: IDeleteBatchItem[];\n}\n\nexport class EntityWriteBatch<T> implements IEntityWriteBatch<T> {\n private readonly entity: ToolboxEntity;\n private readonly _items: BatchWriteItem[] = [];\n private readonly builder: IEntityWriteBatchBuilder;\n\n public get total(): number {\n return this._items.length;\n }\n\n public get items(): BatchWriteItem[] {\n return Array.from(this._items);\n }\n\n public constructor(params: IEntityWriteBatchParams) {\n this.entity = getEntity(params.entity);\n this.builder = createEntityWriteBatchBuilder(this.entity);\n for (const item of params.put || []) {\n this.put(item);\n }\n for (const item of params.delete || []) {\n this.delete(item);\n }\n }\n\n public put(item: IPutBatchItem<T>): void {\n this._items.push(this.builder.put(item));\n }\n\n public delete(item: IDeleteBatchItem): void {\n this._items.push(this.builder.delete(item));\n }\n\n public combine(items: BatchWriteItem[]): ITableWriteBatch {\n return createTableWriteBatch({\n table: this.entity!.table as TableDef,\n items: this._items.concat(items)\n });\n }\n\n public async execute(): Promise<BatchWriteResult> {\n if (this._items.length === 0) {\n return [];\n }\n const items = Array.from(this._items);\n this._items.length = 0;\n return await batchWriteAll({\n items,\n table: this.entity.table\n });\n }\n}\n\nexport const createEntityWriteBatch = (params: IEntityWriteBatchParams): IEntityWriteBatch => {\n return new EntityWriteBatch(params);\n};\n"],"mappings":"AACA,SAASA,aAAa;AAStB,SAASC,qBAAqB;AAC9B,SAASC,6BAA6B;AAEtC,SAASC,SAAS;AASlB,OAAO,MAAMC,gBAAgB,CAAoC;EAE5CC,MAAM,GAAqB,EAAE;EAG9C,IAAWC,KAAKA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACD,MAAM,CAACE,MAAM;EAC7B;EAEA,IAAWC,KAAKA,CAAA,EAAqB;IACjC,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACL,MAAM,CAAC;EAClC;EAEOM,WAAWA,CAACC,MAA+B,EAAE;IAChD,IAAI,CAACC,MAAM,GAAGV,SAAS,CAACS,MAAM,CAACC,MAAM,CAAC;IACtC,IAAI,CAACC,OAAO,GAAGZ,6BAA6B,CAAC,IAAI,CAACW,MAAM,CAAC;IACzD,KAAK,MAAME,IAAI,IAAIH,MAAM,CAACI,GAAG,IAAI,EAAE,EAAE;MACjC,IAAI,CAACA,GAAG,CAACD,IAAI,CAAC;IAClB;IACA,KAAK,MAAMA,IAAI,IAAIH,MAAM,CAACK,MAAM,IAAI,EAAE,EAAE;MACpC,IAAI,CAACA,MAAM,CAACF,IAAI,CAAC;IACrB;EACJ;EAEOC,GAAGA,CAACD,IAAsB,EAAQ;IACrC,IAAI,CAACV,MAAM,CAACa,IAAI,CAAC,IAAI,CAACJ,OAAO,CAACE,GAAG,CAACD,IAAI,CAAC,CAAC;EAC5C;EAEOE,MAAMA,CAACF,IAAsB,EAAQ;IACxC,IAAI,CAACV,MAAM,CAACa,IAAI,CAAC,IAAI,CAACJ,OAAO,CAACG,MAAM,CAACF,IAAI,CAAC,CAAC;EAC/C;EAEOI,OAAOA,CAACX,KAAuB,EAAoB;IACtD,OAAOP,qBAAqB,CAAC;MACzBmB,KAAK,EAAE,IAAI,CAACP,MAAM,CAAEO,KAAiB;MACrCZ,KAAK,EAAE,IAAI,CAACH,MAAM,CAACgB,MAAM,CAACb,KAAK;IACnC,CAAC,CAAC;EACN;EAEA,MAAac,OAAOA,CAAA,EAA8B;IAC9C,IAAI,IAAI,CAACjB,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;MAC1B,OAAO,EAAE;IACb;IACA,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACL,MAAM,CAAC;IACrC,IAAI,CAACA,MAAM,CAACE,MAAM,GAAG,CAAC;IACtB,OAAO,MAAMP,aAAa,CAAC;MACvBQ,KAAK;MACLY,KAAK,EAAE,IAAI,CAACP,MAAM,CAACO;IACvB,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMG,sBAAsB,GAAIX,MAA+B,IAAwB;EAC1F,OAAO,IAAIR,gBAAgB,CAACQ,MAAM,CAAC;AACvC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Entity } from "../../toolbox";
|
|
2
|
-
import type { BatchWriteItem, IDeleteBatchItem, IPutBatchItem } from "
|
|
3
|
-
import type { IEntityWriteBatchBuilder } from "./types";
|
|
4
|
-
import type { EntityOption } from "./getEntity";
|
|
1
|
+
import type { Entity } from "../../toolbox.js";
|
|
2
|
+
import type { BatchWriteItem, IDeleteBatchItem, IPutBatchItem } from "../../utils/batch/types.js";
|
|
3
|
+
import type { IEntityWriteBatchBuilder } from "./types.js";
|
|
4
|
+
import type { EntityOption } from "./getEntity.js";
|
|
5
5
|
export declare class EntityWriteBatchBuilder implements IEntityWriteBatchBuilder {
|
|
6
6
|
private readonly entity;
|
|
7
7
|
constructor(entity: EntityOption);
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEntityWriteBatchBuilder = exports.EntityWriteBatchBuilder = void 0;
|
|
7
|
-
var _getEntity = require("./getEntity");
|
|
8
|
-
class EntityWriteBatchBuilder {
|
|
1
|
+
import { getEntity } from "./getEntity.js";
|
|
2
|
+
export class EntityWriteBatchBuilder {
|
|
9
3
|
constructor(entity) {
|
|
10
|
-
this.entity =
|
|
4
|
+
this.entity = getEntity(entity);
|
|
11
5
|
}
|
|
12
6
|
put(item) {
|
|
13
7
|
return this.entity.putBatch(item, {
|
|
@@ -19,10 +13,8 @@ class EntityWriteBatchBuilder {
|
|
|
19
13
|
return this.entity.deleteBatch(item);
|
|
20
14
|
}
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
const createEntityWriteBatchBuilder = entity => {
|
|
16
|
+
export const createEntityWriteBatchBuilder = entity => {
|
|
24
17
|
return new EntityWriteBatchBuilder(entity);
|
|
25
18
|
};
|
|
26
|
-
exports.createEntityWriteBatchBuilder = createEntityWriteBatchBuilder;
|
|
27
19
|
|
|
28
20
|
//# sourceMappingURL=EntityWriteBatchBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getEntity","EntityWriteBatchBuilder","constructor","entity","put","item","putBatch","execute","strictSchemaCheck","delete","deleteBatch","createEntityWriteBatchBuilder"],"sources":["EntityWriteBatchBuilder.ts"],"sourcesContent":["import type { Entity } from \"~/toolbox.js\";\nimport type { BatchWriteItem, IDeleteBatchItem, IPutBatchItem } from \"~/utils/batch/types.js\";\nimport type { IEntityWriteBatchBuilder } from \"./types.js\";\nimport type { EntityOption } from \"./getEntity.js\";\nimport { getEntity } from \"./getEntity.js\";\n\nexport class EntityWriteBatchBuilder implements IEntityWriteBatchBuilder {\n private readonly entity: Entity;\n\n public constructor(entity: EntityOption) {\n this.entity = getEntity(entity);\n }\n\n public put<T extends Record<string, any>>(item: IPutBatchItem<T>): BatchWriteItem {\n return this.entity.putBatch(item, {\n execute: true,\n strictSchemaCheck: false\n });\n }\n\n public delete(item: IDeleteBatchItem): BatchWriteItem {\n return this.entity.deleteBatch(item);\n }\n}\n\nexport const createEntityWriteBatchBuilder = (entity: Entity): IEntityWriteBatchBuilder => {\n return new EntityWriteBatchBuilder(entity);\n};\n"],"mappings":"AAIA,SAASA,SAAS;AAElB,OAAO,MAAMC,uBAAuB,CAAqC;EAG9DC,WAAWA,CAACC,MAAoB,EAAE;IACrC,IAAI,CAACA,MAAM,GAAGH,SAAS,CAACG,MAAM,CAAC;EACnC;EAEOC,GAAGA,CAAgCC,IAAsB,EAAkB;IAC9E,OAAO,IAAI,CAACF,MAAM,CAACG,QAAQ,CAACD,IAAI,EAAE;MAC9BE,OAAO,EAAE,IAAI;MACbC,iBAAiB,EAAE;IACvB,CAAC,CAAC;EACN;EAEOC,MAAMA,CAACJ,IAAsB,EAAkB;IAClD,OAAO,IAAI,CAACF,MAAM,CAACO,WAAW,CAACL,IAAI,CAAC;EACxC;AACJ;AAEA,OAAO,MAAMM,6BAA6B,GAAIR,MAAc,IAA+B;EACvF,OAAO,IAAIF,uBAAuB,CAACE,MAAM,CAAC;AAC9C,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity as ToolboxEntity } from "../../toolbox";
|
|
2
|
-
import type { Entity } from "./Entity";
|
|
1
|
+
import { Entity as ToolboxEntity } from "../../toolbox.js";
|
|
2
|
+
import type { Entity } from "./Entity.js";
|
|
3
3
|
export type EntityOption = ToolboxEntity | Entity;
|
|
4
4
|
export declare const getEntity: (entity: EntityOption) => ToolboxEntity;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getEntity = void 0;
|
|
7
|
-
var _toolbox = require("../../toolbox");
|
|
8
|
-
const getEntity = entity => {
|
|
9
|
-
const result = entity instanceof _toolbox.Entity ? entity : entity.entity;
|
|
1
|
+
import { Entity as ToolboxEntity } from "../../toolbox.js";
|
|
2
|
+
export const getEntity = entity => {
|
|
3
|
+
const result = entity instanceof ToolboxEntity ? entity : entity.entity;
|
|
10
4
|
if (!result.name) {
|
|
11
5
|
throw new Error(`No name provided for entity.`);
|
|
12
6
|
} else if (!result.table) {
|
|
@@ -14,6 +8,5 @@ const getEntity = entity => {
|
|
|
14
8
|
}
|
|
15
9
|
return result;
|
|
16
10
|
};
|
|
17
|
-
exports.getEntity = getEntity;
|
|
18
11
|
|
|
19
12
|
//# sourceMappingURL=getEntity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Entity","ToolboxEntity","getEntity","entity","result","name","Error","table"],"sources":["getEntity.ts"],"sourcesContent":["import { Entity as ToolboxEntity } from \"~/toolbox.js\";\nimport type { Entity } from \"./Entity.js\";\n\nexport type EntityOption = ToolboxEntity | Entity;\n\nexport const getEntity = (entity: EntityOption): ToolboxEntity => {\n const result = entity instanceof ToolboxEntity ? entity : entity.entity;\n if (!result.name) {\n throw new Error(`No name provided for entity.`);\n } else if (!result.table) {\n throw new Error(`No table provided for entity ${result.name}.`);\n }\n return result;\n};\n"],"mappings":"AAAA,SAASA,MAAM,IAAIC,aAAa;AAKhC,OAAO,MAAMC,SAAS,GAAIC,MAAoB,IAAoB;EAC9D,MAAMC,MAAM,GAAGD,MAAM,YAAYF,aAAa,GAAGE,MAAM,GAAGA,MAAM,CAACA,MAAM;EACvE,IAAI,CAACC,MAAM,CAACC,IAAI,EAAE;IACd,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EACnD,CAAC,MAAM,IAAI,CAACF,MAAM,CAACG,KAAK,EAAE;IACtB,MAAM,IAAID,KAAK,CAAC,gCAAgCF,MAAM,CAACC,IAAI,GAAG,CAAC;EACnE;EACA,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]}
|
package/utils/entity/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./Entity";
|
|
2
|
-
export * from "./EntityReadBatch";
|
|
3
|
-
export * from "./EntityReadBatchBuilder";
|
|
4
|
-
export * from "./EntityWriteBatch";
|
|
5
|
-
export * from "./EntityWriteBatchBuilder";
|
|
6
|
-
export * from "./getEntity";
|
|
7
|
-
export * from "./types";
|
|
1
|
+
export * from "./Entity.js";
|
|
2
|
+
export * from "./EntityReadBatch.js";
|
|
3
|
+
export * from "./EntityReadBatchBuilder.js";
|
|
4
|
+
export * from "./EntityWriteBatch.js";
|
|
5
|
+
export * from "./EntityWriteBatchBuilder.js";
|
|
6
|
+
export * from "./getEntity.js";
|
|
7
|
+
export * from "./types.js";
|
package/utils/entity/index.js
CHANGED
|
@@ -1,84 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _Entity[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _Entity[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _EntityReadBatch = require("./EntityReadBatch");
|
|
18
|
-
Object.keys(_EntityReadBatch).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _EntityReadBatch[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _EntityReadBatch[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _EntityReadBatchBuilder = require("./EntityReadBatchBuilder");
|
|
29
|
-
Object.keys(_EntityReadBatchBuilder).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _EntityReadBatchBuilder[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _EntityReadBatchBuilder[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _EntityWriteBatch = require("./EntityWriteBatch");
|
|
40
|
-
Object.keys(_EntityWriteBatch).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _EntityWriteBatch[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _EntityWriteBatch[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _EntityWriteBatchBuilder = require("./EntityWriteBatchBuilder");
|
|
51
|
-
Object.keys(_EntityWriteBatchBuilder).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _EntityWriteBatchBuilder[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _EntityWriteBatchBuilder[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _getEntity = require("./getEntity");
|
|
62
|
-
Object.keys(_getEntity).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _getEntity[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _getEntity[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _types = require("./types");
|
|
73
|
-
Object.keys(_types).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _types[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
export * from "./Entity.js";
|
|
2
|
+
export * from "./EntityReadBatch.js";
|
|
3
|
+
export * from "./EntityReadBatchBuilder.js";
|
|
4
|
+
export * from "./EntityWriteBatch.js";
|
|
5
|
+
export * from "./EntityWriteBatchBuilder.js";
|
|
6
|
+
export * from "./getEntity.js";
|
|
7
|
+
export * from "./types.js";
|
|
83
8
|
|
|
84
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Entity.js\";\nexport * from \"./EntityReadBatch.js\";\nexport * from \"./EntityReadBatchBuilder.js\";\nexport * from \"./EntityWriteBatch.js\";\nexport * from \"./EntityWriteBatchBuilder.js\";\nexport * from \"./getEntity.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|