@webiny/api-headless-cms-sql 0.0.0-unstable.b6d7105cee → 6.6.0-alpha.1
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/features/entryTableManager/EntryTableManager.d.ts +2 -0
- package/features/entryTableManager/EntryTableManager.js +39 -26
- package/features/entryTableManager/EntryTableManager.js.map +1 -1
- package/index.d.ts +4 -1
- package/index.js +24 -71
- package/index.js.map +1 -1
- package/operations/entry/SqlCreateEntry.d.ts +15 -0
- package/operations/entry/SqlCreateEntry.js +35 -0
- package/operations/entry/SqlCreateEntry.js.map +1 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.d.ts +15 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.js +55 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/SqlDeleteEntry.d.ts +15 -0
- package/operations/entry/SqlDeleteEntry.js +29 -0
- package/operations/entry/SqlDeleteEntry.js.map +1 -0
- package/operations/entry/SqlDeleteEntryRevision.d.ts +15 -0
- package/operations/entry/SqlDeleteEntryRevision.js +39 -0
- package/operations/entry/SqlDeleteEntryRevision.js.map +1 -0
- package/operations/entry/SqlDeleteMultipleEntries.d.ts +15 -0
- package/operations/entry/SqlDeleteMultipleEntries.js +29 -0
- package/operations/entry/SqlDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/SqlGetEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetEntriesByIds.js +35 -0
- package/operations/entry/SqlGetEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetEntry.d.ts +25 -0
- package/operations/entry/SqlGetEntry.js +56 -0
- package/operations/entry/SqlGetEntry.js.map +1 -0
- package/operations/entry/SqlGetLatestEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetLatestEntriesByIds.js +37 -0
- package/operations/entry/SqlGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.d.ts +15 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.js +32 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/SqlGetPreviousRevision.d.ts +15 -0
- package/operations/entry/SqlGetPreviousRevision.js +30 -0
- package/operations/entry/SqlGetPreviousRevision.js.map +1 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.js +37 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.d.ts +15 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.js +32 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/SqlGetRevisionById.d.ts +15 -0
- package/operations/entry/SqlGetRevisionById.js +30 -0
- package/operations/entry/SqlGetRevisionById.js.map +1 -0
- package/operations/entry/SqlGetRevisions.d.ts +15 -0
- package/operations/entry/SqlGetRevisions.js +31 -0
- package/operations/entry/SqlGetRevisions.js.map +1 -0
- package/operations/entry/SqlGetUniqueFieldValues.d.ts +25 -0
- package/operations/entry/SqlGetUniqueFieldValues.js +58 -0
- package/operations/entry/SqlGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/SqlListEntries.d.ts +25 -0
- package/operations/entry/SqlListEntries.js +52 -0
- package/operations/entry/SqlListEntries.js.map +1 -0
- package/operations/entry/SqlMoveEntry.d.ts +14 -0
- package/operations/entry/SqlMoveEntry.js +30 -0
- package/operations/entry/SqlMoveEntry.js.map +1 -0
- package/operations/entry/SqlMoveToBin.d.ts +14 -0
- package/operations/entry/SqlMoveToBin.js +35 -0
- package/operations/entry/SqlMoveToBin.js.map +1 -0
- package/operations/entry/SqlPublishEntry.d.ts +15 -0
- package/operations/entry/SqlPublishEntry.js +51 -0
- package/operations/entry/SqlPublishEntry.js.map +1 -0
- package/operations/entry/SqlRestoreFromBin.d.ts +14 -0
- package/operations/entry/SqlRestoreFromBin.js +36 -0
- package/operations/entry/SqlRestoreFromBin.js.map +1 -0
- package/operations/entry/SqlUnpublishEntry.d.ts +15 -0
- package/operations/entry/SqlUnpublishEntry.js +38 -0
- package/operations/entry/SqlUnpublishEntry.js.map +1 -0
- package/operations/entry/SqlUpdateEntry.d.ts +15 -0
- package/operations/entry/SqlUpdateEntry.js +36 -0
- package/operations/entry/SqlUpdateEntry.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +53 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/queryHelpers.d.ts +23 -0
- package/operations/entry/queryHelpers.js +105 -0
- package/operations/entry/queryHelpers.js.map +1 -0
- package/operations/group/SqlCreateGroup.d.ts +16 -0
- package/operations/group/SqlCreateGroup.js +28 -0
- package/operations/group/SqlCreateGroup.js.map +1 -0
- package/operations/group/SqlDeleteGroup.d.ts +16 -0
- package/operations/group/SqlDeleteGroup.js +26 -0
- package/operations/group/SqlDeleteGroup.js.map +1 -0
- package/operations/group/SqlGetGroup.d.ts +16 -0
- package/operations/group/SqlGetGroup.js +29 -0
- package/operations/group/SqlGetGroup.js.map +1 -0
- package/operations/group/SqlListGroups.d.ts +16 -0
- package/operations/group/SqlListGroups.js +43 -0
- package/operations/group/SqlListGroups.js.map +1 -0
- package/operations/group/SqlUpdateGroup.d.ts +16 -0
- package/operations/group/SqlUpdateGroup.js +28 -0
- package/operations/group/SqlUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/model/SqlCreateModel.d.ts +16 -0
- package/operations/model/SqlCreateModel.js +30 -0
- package/operations/model/SqlCreateModel.js.map +1 -0
- package/operations/model/SqlDeleteModel.d.ts +16 -0
- package/operations/model/SqlDeleteModel.js +26 -0
- package/operations/model/SqlDeleteModel.js.map +1 -0
- package/operations/model/SqlGetModel.d.ts +16 -0
- package/operations/model/SqlGetModel.js +29 -0
- package/operations/model/SqlGetModel.js.map +1 -0
- package/operations/model/SqlListModels.d.ts +16 -0
- package/operations/model/SqlListModels.js +31 -0
- package/operations/model/SqlListModels.js.map +1 -0
- package/operations/model/SqlUpdateModel.d.ts +16 -0
- package/operations/model/SqlUpdateModel.js +30 -0
- package/operations/model/SqlUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/package.json +16 -13
- package/operations/entry/index.d.ts +0 -13
- package/operations/entry/index.js +0 -362
- package/operations/entry/index.js.map +0 -1
- package/operations/group/index.d.ts +0 -5
- package/operations/group/index.js +0 -58
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -5
- package/operations/model/index.js +0 -50
- package/operations/model/index.js.map +0 -1
- package/types.d.ts +0 -10
- package/types.js +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsDeleteParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlDeleteModel: typeof SqlDeleteModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js").IDeleteModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
5
|
+
class SqlDeleteModelImpl {
|
|
6
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
7
|
+
this.knex = knex;
|
|
8
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
9
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
10
|
+
}
|
|
11
|
+
async execute(params) {
|
|
12
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
13
|
+
await this.knex.client(this.tableName).where("modelId", params.model.modelId).delete();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({
|
|
17
|
+
implementation: SqlDeleteModelImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
KnexClient,
|
|
20
|
+
TableNameResolver,
|
|
21
|
+
ModelSchemaManager
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { SqlDeleteModel };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=SqlDeleteModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlDeleteModel.js","sources":["../../../src/operations/model/SqlDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { DeleteModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsDeleteParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"modelId\", params.model.modelId)\n .delete();\n }\n}\n\nexport const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({\n implementation: SqlDeleteModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlDeleteModelImpl","knex","tableNameResolver","modelSchemaManager","params","SqlDeleteModel","DeleteModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;AAOA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,WAAWA,OAAO,KAAK,CAAC,OAAO,EACrC,MAAM;IACf;AACJ;AAEO,MAAMC,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBN;IAChB,cAAc;QAACO;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlGetModelImpl implements GetModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlGetModel: typeof SqlGetModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js").IGetModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { rowToModel } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlGetModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
14
|
+
const row = await this.knex.client(this.tableName).where("modelId", params.modelId).where("tenant", params.tenant).first();
|
|
15
|
+
if (!row) return null;
|
|
16
|
+
return rowToModel(row);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const SqlGetModel = GetModelStorageOperation.createImplementation({
|
|
20
|
+
implementation: SqlGetModelImpl,
|
|
21
|
+
dependencies: [
|
|
22
|
+
KnexClient,
|
|
23
|
+
TableNameResolver,
|
|
24
|
+
ModelSchemaManager
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { SqlGetModel };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=SqlGetModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlGetModel.js","sources":["../../../src/operations/model/SqlGetModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { GetModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { rowToModel } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlGetModelImpl implements GetModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsGetParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n\n const row = await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"modelId\", params.modelId)\n .where(\"tenant\", params.tenant)\n .first();\n\n if (!row) {\n return null;\n }\n\n return rowToModel(row);\n }\n}\n\nexport const SqlGetModel = GetModelStorageOperation.createImplementation({\n implementation: SqlGetModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlGetModelImpl","knex","tableNameResolver","modelSchemaManager","params","row","rowToModel","SqlGetModel","GetModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA0C,EAAE;QACtD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAMC,MAAM,MAAM,IAAI,CAAC,IAAI,CACtB,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,WAAWD,OAAO,OAAO,EAC/B,KAAK,CAAC,UAAUA,OAAO,MAAM,EAC7B,KAAK;QAEV,IAAI,CAACC,KACD,OAAO;QAGX,OAAOC,WAAWD;IACtB;AACJ;AAEO,MAAME,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlListModelsImpl implements ListModelsStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsListParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlListModels: typeof SqlListModelsImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js").IListModelsStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { rowToModel } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlListModelsImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
14
|
+
const { where } = params;
|
|
15
|
+
const qb = this.knex.client(this.tableName).where("tenant", where.tenant);
|
|
16
|
+
qb.orderBy("modelId", "asc");
|
|
17
|
+
const rows = await qb.select();
|
|
18
|
+
return rows.map(rowToModel);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const SqlListModels = ListModelsStorageOperation.createImplementation({
|
|
22
|
+
implementation: SqlListModelsImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
KnexClient,
|
|
25
|
+
TableNameResolver,
|
|
26
|
+
ModelSchemaManager
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { SqlListModels };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=SqlListModels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlListModels.js","sources":["../../../src/operations/model/SqlListModels.ts"],"sourcesContent":["import type { CmsModelStorageOperationsListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { ListModelsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { rowToModel } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlListModelsImpl implements ListModelsStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsListParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n\n const { where } = params;\n const qb = this.knex.client<IModelRow>(this.tableName).where(\"tenant\", where.tenant);\n\n qb.orderBy(\"modelId\", \"asc\");\n\n const rows = await qb.select<IModelRow[]>();\n\n return rows.map(rowToModel);\n }\n}\n\nexport const SqlListModels = ListModelsStorageOperation.createImplementation({\n implementation: SqlListModelsImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlListModelsImpl","knex","tableNameResolver","modelSchemaManager","params","where","qb","rows","rowToModel","SqlListModels","ListModelsStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA2C,EAAE;QACvD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,UAAUD,MAAM,MAAM;QAEnFC,GAAG,OAAO,CAAC,WAAW;QAEtB,MAAMC,OAAO,MAAMD,GAAG,MAAM;QAE5B,OAAOC,KAAK,GAAG,CAACC;IACpB;AACJ;AAEO,MAAMC,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBV;IAChB,cAAc;QAACW;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlUpdateModelImpl implements UpdateModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsUpdateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlUpdateModel: typeof SqlUpdateModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js").IUpdateModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { modelToRow } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlUpdateModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const model = params.model;
|
|
14
|
+
const row = modelToRow(model);
|
|
15
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
16
|
+
await this.knex.client(this.tableName).where("modelId", model.modelId).update(row);
|
|
17
|
+
return model;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const SqlUpdateModel = UpdateModelStorageOperation.createImplementation({
|
|
21
|
+
implementation: SqlUpdateModelImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
KnexClient,
|
|
24
|
+
TableNameResolver,
|
|
25
|
+
ModelSchemaManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlUpdateModel };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlUpdateModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlUpdateModel.js","sources":["../../../src/operations/model/SqlUpdateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { UpdateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { modelToRow } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlUpdateModelImpl implements UpdateModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsUpdateParams) {\n const model = params.model;\n const row = modelToRow(model);\n\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"modelId\", model.modelId)\n .update(row);\n\n return model;\n }\n}\n\nexport const SqlUpdateModel = UpdateModelStorageOperation.createImplementation({\n implementation: SqlUpdateModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlUpdateModelImpl","knex","tableNameResolver","modelSchemaManager","params","model","row","modelToRow","SqlUpdateModel","UpdateModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAMC,QAAQD,OAAO,KAAK;QAC1B,MAAME,MAAMC,WAAWF;QAEvB,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,WAAWA,MAAM,OAAO,EAC9B,MAAM,CAACC;QAEZ,OAAOD;IACX;AACJ;AAEO,MAAMG,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SqlGetModel } from "./SqlGetModel.js";
|
|
3
|
+
import { SqlListModels } from "./SqlListModels.js";
|
|
4
|
+
import { SqlCreateModel } from "./SqlCreateModel.js";
|
|
5
|
+
import { SqlUpdateModel } from "./SqlUpdateModel.js";
|
|
6
|
+
import { SqlDeleteModel } from "./SqlDeleteModel.js";
|
|
7
|
+
const SqlModelStorageOpsFeature = createFeature({
|
|
8
|
+
name: "cms.sql.modelStorageOps",
|
|
9
|
+
register: (container)=>{
|
|
10
|
+
container.register(SqlGetModel);
|
|
11
|
+
container.register(SqlListModels);
|
|
12
|
+
container.register(SqlCreateModel);
|
|
13
|
+
container.register(SqlUpdateModel);
|
|
14
|
+
container.register(SqlDeleteModel);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export { SqlModelStorageOpsFeature };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/feature.js","sources":["../../../src/operations/model/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SqlGetModel } from \"./SqlGetModel.js\";\nimport { SqlListModels } from \"./SqlListModels.js\";\nimport { SqlCreateModel } from \"./SqlCreateModel.js\";\nimport { SqlUpdateModel } from \"./SqlUpdateModel.js\";\nimport { SqlDeleteModel } from \"./SqlDeleteModel.js\";\n\nexport const SqlModelStorageOpsFeature = createFeature({\n name: \"cms.sql.modelStorageOps\",\n register: container => {\n container.register(SqlGetModel);\n container.register(SqlListModels);\n container.register(SqlCreateModel);\n container.register(SqlUpdateModel);\n container.register(SqlDeleteModel);\n }\n});\n"],"names":["SqlModelStorageOpsFeature","createFeature","container","SqlGetModel","SqlListModels","SqlCreateModel","SqlUpdateModel","SqlDeleteModel"],"mappings":";;;;;;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-sql",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.6.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -22,22 +22,25 @@
|
|
|
22
22
|
"description": "SQL storage operations for Headless CMS API.",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webiny/api-core-sql": "
|
|
26
|
-
"@webiny/api-headless-cms": "
|
|
27
|
-
"@webiny/api-headless-cms-storage": "
|
|
28
|
-
"@webiny/db-utils": "
|
|
29
|
-
"@webiny/feature": "
|
|
30
|
-
"@webiny/handler": "
|
|
31
|
-
"@webiny/
|
|
32
|
-
"@webiny/utils": "0.0.0-unstable.b6d7105cee",
|
|
25
|
+
"@webiny/api-core-sql": "6.6.0-alpha.1",
|
|
26
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.1",
|
|
27
|
+
"@webiny/api-headless-cms-storage": "6.6.0-alpha.1",
|
|
28
|
+
"@webiny/db-utils": "6.6.0-alpha.1",
|
|
29
|
+
"@webiny/feature": "6.6.0-alpha.1",
|
|
30
|
+
"@webiny/handler": "6.6.0-alpha.1",
|
|
31
|
+
"@webiny/utils": "6.6.0-alpha.1",
|
|
33
32
|
"knex": "3.3.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
35
|
+
"@electric-sql/pglite": "0.5.5",
|
|
36
|
+
"@electric-sql/pglite-socket": "0.2.8",
|
|
37
|
+
"@webiny/api-core": "6.6.0-alpha.1",
|
|
38
|
+
"@webiny/build-tools": "6.6.0-alpha.1",
|
|
39
|
+
"@webiny/di": "1.1.0",
|
|
40
|
+
"better-sqlite3": "13.0.3",
|
|
41
|
+
"pg": "8.23.0",
|
|
39
42
|
"typescript": "7.0.2",
|
|
40
|
-
"vitest": "4.1.
|
|
43
|
+
"vitest": "4.1.11"
|
|
41
44
|
},
|
|
42
45
|
"publishConfig": {
|
|
43
46
|
"access": "public"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CmsEntryStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
-
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import type { CmsContext } from "../../types.js";
|
|
4
|
-
import type { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
-
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
-
interface CreateEntriesStorageOperationsParams {
|
|
7
|
-
knex: KnexClient.Interface;
|
|
8
|
-
entryTableManager: EntryTableManager.Interface;
|
|
9
|
-
container: CmsContext["container"];
|
|
10
|
-
plugins: PluginsContainer;
|
|
11
|
-
}
|
|
12
|
-
export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;
|
|
13
|
-
export {};
|