@contember/engine-content-api 2.1.0-alpha.4 → 2.1.0-alpha.6

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.
Files changed (24) hide show
  1. package/dist/development/src/resolvers/RefreshViewResolver.cjs +3 -2
  2. package/dist/development/src/resolvers/RefreshViewResolver.cjs.map +1 -1
  3. package/dist/development/src/resolvers/RefreshViewResolver.js +3 -2
  4. package/dist/development/src/resolvers/RefreshViewResolver.js.map +1 -1
  5. package/dist/development/src/schema/RefreshViewMutationProvider.cjs +9 -2
  6. package/dist/development/src/schema/RefreshViewMutationProvider.cjs.map +1 -1
  7. package/dist/development/src/schema/RefreshViewMutationProvider.js +10 -3
  8. package/dist/development/src/schema/RefreshViewMutationProvider.js.map +1 -1
  9. package/dist/production/src/resolvers/RefreshViewResolver.cjs +3 -2
  10. package/dist/production/src/resolvers/RefreshViewResolver.cjs.map +1 -1
  11. package/dist/production/src/resolvers/RefreshViewResolver.js +3 -2
  12. package/dist/production/src/resolvers/RefreshViewResolver.js.map +1 -1
  13. package/dist/production/src/schema/RefreshViewMutationProvider.cjs +9 -2
  14. package/dist/production/src/schema/RefreshViewMutationProvider.cjs.map +1 -1
  15. package/dist/production/src/schema/RefreshViewMutationProvider.js +10 -3
  16. package/dist/production/src/schema/RefreshViewMutationProvider.js.map +1 -1
  17. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/resolvers/RefreshViewResolver.d.ts +3 -1
  19. package/dist/types/resolvers/RefreshViewResolver.d.ts.map +1 -1
  20. package/dist/types/schema/RefreshViewMutationProvider.d.ts.map +1 -1
  21. package/dist/types/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +10 -10
  23. package/src/resolvers/RefreshViewResolver.ts +3 -3
  24. package/src/schema/RefreshViewMutationProvider.ts +9 -2
@@ -6,13 +6,14 @@ class RefreshViewResolver {
6
6
  this.schema = schema;
7
7
  this.mapperFactory = mapperFactory;
8
8
  }
9
- async resolve(entity) {
9
+ async resolve(entity, options) {
10
10
  const mapper = this.mapperFactory.create();
11
11
  const entityModel = this.schema.model.entities[entity];
12
12
  if (!entityModel) {
13
13
  throw new Error(`Entity ${entity} not found`);
14
14
  }
15
- await mapper.db.query(`REFRESH MATERIALIZED VIEW ${Database.wrapIdentifier(entityModel.tableName)}`);
15
+ const concurrently = options?.concurrently ? " CONCURRENTLY" : "";
16
+ await mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${Database.wrapIdentifier(mapper.db.schema)}.${Database.wrapIdentifier(entityModel.tableName)}`);
16
17
  return { ok: true };
17
18
  }
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewResolver.cjs","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":["wrapIdentifier"],"mappings":";;;AAKO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAA0C;AACxD,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,OAAO,GAAG,MAAM,6BAA6BA,SAAAA,eAAe,YAAY,SAAS,CAAC,EAAE;AAEnF,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;;"}
1
+ {"version":3,"file":"RefreshViewResolver.cjs","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string, options?: { concurrently?: boolean }): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tconst concurrently = options?.concurrently ? ' CONCURRENTLY' : ''\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":["wrapIdentifier"],"mappings":";;;AAIO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAAgB,SAAgE;AAC9F,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,eAAe,SAAS,eAAe,kBAAkB;AAC/D,UAAM,OAAO,GAAG,MAAM,4BAA4B,YAAY,IAAIA,SAAe,eAAA,OAAO,GAAG,MAAM,CAAC,IAAIA,SAAA,eAAe,YAAY,SAAS,CAAC,EAAE;AAEtI,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;;"}
@@ -4,13 +4,14 @@ class RefreshViewResolver {
4
4
  this.schema = schema;
5
5
  this.mapperFactory = mapperFactory;
6
6
  }
7
- async resolve(entity) {
7
+ async resolve(entity, options) {
8
8
  const mapper = this.mapperFactory.create();
9
9
  const entityModel = this.schema.model.entities[entity];
10
10
  if (!entityModel) {
11
11
  throw new Error(`Entity ${entity} not found`);
12
12
  }
13
- await mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`);
13
+ const concurrently = options?.concurrently ? " CONCURRENTLY" : "";
14
+ await mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`);
14
15
  return { ok: true };
15
16
  }
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewResolver.js","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAA0C;AACxD,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,OAAO,GAAG,MAAM,6BAA6B,eAAe,YAAY,SAAS,CAAC,EAAE;AAEnF,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;"}
1
+ {"version":3,"file":"RefreshViewResolver.js","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string, options?: { concurrently?: boolean }): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tconst concurrently = options?.concurrently ? ' CONCURRENTLY' : ''\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":[],"mappings":";AAIO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAAgB,SAAgE;AAC9F,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,eAAe,SAAS,eAAe,kBAAkB;AAC/D,UAAM,OAAO,GAAG,MAAM,4BAA4B,YAAY,IAAI,eAAe,OAAO,GAAG,MAAM,CAAC,IAAI,eAAe,YAAY,SAAS,CAAC,EAAE;AAEtI,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;"}
@@ -15,6 +15,12 @@ class RefreshViewMutationProvider {
15
15
  name: "_MaterializedView",
16
16
  values: Object.fromEntries(materializedViews.map((it) => [it.name, { value: it.name }]))
17
17
  });
18
+ const refreshViewOptions = new graphql.GraphQLInputObjectType({
19
+ name: "RefreshMaterializedViewOptions",
20
+ fields: {
21
+ concurrently: { type: graphql.GraphQLBoolean }
22
+ }
23
+ });
18
24
  return {
19
25
  type: new graphql.GraphQLObjectType({
20
26
  name: "RefreshMaterializedViewResponse",
@@ -23,10 +29,11 @@ class RefreshViewMutationProvider {
23
29
  }
24
30
  }),
25
31
  args: {
26
- name: { type: materializedViewsEnum }
32
+ name: { type: materializedViewsEnum },
33
+ options: { type: refreshViewOptions }
27
34
  },
28
35
  resolve: async (parent, args, context) => {
29
- return await context.executionContainer.refreshViewResolver.resolve(args.name);
36
+ return await context.executionContainer.refreshViewResolver.resolve(args.name, args.options);
30
37
  }
31
38
  };
32
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewMutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["GraphQLEnumType","GraphQLObjectType","GraphQLBoolean"],"mappings":";;;AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAIA,wBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEM,WAAA;AAAA,MACN,MAAM,IAAIC,QAAAA,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAMC,QAAe,eAAA;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AACzC,eAAO,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,IAAI;AAAA,MAAA;AAAA,IAE/E;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"RefreshViewMutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\tconst refreshViewOptions = new GraphQLInputObjectType({\n\t\t\tname: 'RefreshMaterializedViewOptions',\n\t\t\tfields: {\n\t\t\t\tconcurrently: { type: GraphQLBoolean },\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t\toptions: { type: refreshViewOptions },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name, args.options)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["GraphQLEnumType","GraphQLInputObjectType","GraphQLBoolean","GraphQLObjectType"],"mappings":";;;AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAIA,wBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEK,UAAA,qBAAqB,IAAIC,+BAAuB;AAAA,MACrD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,cAAc,EAAE,MAAMC,QAAe,eAAA;AAAA,MAAA;AAAA,IACtC,CACA;AACM,WAAA;AAAA,MACN,MAAM,IAAIC,QAAAA,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAMD,QAAe,eAAA;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,QACpC,SAAS,EAAE,MAAM,mBAAmB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AAClC,eAAA,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,MAAM,KAAK,OAAO;AAAA,MAAA;AAAA,IAE7F;AAAA,EAAA;AAEF;;"}
@@ -1,4 +1,4 @@
1
- import { GraphQLEnumType, GraphQLObjectType, GraphQLBoolean } from "graphql";
1
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLBoolean, GraphQLObjectType } from "graphql";
2
2
  class RefreshViewMutationProvider {
3
3
  constructor(schema, authorizator) {
4
4
  this.schema = schema;
@@ -13,6 +13,12 @@ class RefreshViewMutationProvider {
13
13
  name: "_MaterializedView",
14
14
  values: Object.fromEntries(materializedViews.map((it) => [it.name, { value: it.name }]))
15
15
  });
16
+ const refreshViewOptions = new GraphQLInputObjectType({
17
+ name: "RefreshMaterializedViewOptions",
18
+ fields: {
19
+ concurrently: { type: GraphQLBoolean }
20
+ }
21
+ });
16
22
  return {
17
23
  type: new GraphQLObjectType({
18
24
  name: "RefreshMaterializedViewResponse",
@@ -21,10 +27,11 @@ class RefreshViewMutationProvider {
21
27
  }
22
28
  }),
23
29
  args: {
24
- name: { type: materializedViewsEnum }
30
+ name: { type: materializedViewsEnum },
31
+ options: { type: refreshViewOptions }
25
32
  },
26
33
  resolve: async (parent, args, context) => {
27
- return await context.executionContainer.refreshViewResolver.resolve(args.name);
34
+ return await context.executionContainer.refreshViewResolver.resolve(args.name, args.options);
28
35
  }
29
36
  };
30
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewMutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAI,gBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEM,WAAA;AAAA,MACN,MAAM,IAAI,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAM,eAAe;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AACzC,eAAO,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,IAAI;AAAA,MAAA;AAAA,IAE/E;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"RefreshViewMutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\tconst refreshViewOptions = new GraphQLInputObjectType({\n\t\t\tname: 'RefreshMaterializedViewOptions',\n\t\t\tfields: {\n\t\t\t\tconcurrently: { type: GraphQLBoolean },\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t\toptions: { type: refreshViewOptions },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name, args.options)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAI,gBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEK,UAAA,qBAAqB,IAAI,uBAAuB;AAAA,MACrD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,cAAc,EAAE,MAAM,eAAe;AAAA,MAAA;AAAA,IACtC,CACA;AACM,WAAA;AAAA,MACN,MAAM,IAAI,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAM,eAAe;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,QACpC,SAAS,EAAE,MAAM,mBAAmB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AAClC,eAAA,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,MAAM,KAAK,OAAO;AAAA,MAAA;AAAA,IAE7F;AAAA,EAAA;AAEF;"}
@@ -6,13 +6,14 @@ class RefreshViewResolver {
6
6
  this.schema = schema;
7
7
  this.mapperFactory = mapperFactory;
8
8
  }
9
- async resolve(entity) {
9
+ async resolve(entity, options) {
10
10
  const mapper = this.mapperFactory.create();
11
11
  const entityModel = this.schema.model.entities[entity];
12
12
  if (!entityModel) {
13
13
  throw new Error(`Entity ${entity} not found`);
14
14
  }
15
- await mapper.db.query(`REFRESH MATERIALIZED VIEW ${Database.wrapIdentifier(entityModel.tableName)}`);
15
+ const concurrently = options?.concurrently ? " CONCURRENTLY" : "";
16
+ await mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${Database.wrapIdentifier(mapper.db.schema)}.${Database.wrapIdentifier(entityModel.tableName)}`);
16
17
  return { ok: true };
17
18
  }
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewResolver.cjs","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":["wrapIdentifier"],"mappings":";;;AAKO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAA0C;AACxD,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,OAAO,GAAG,MAAM,6BAA6BA,SAAAA,eAAe,YAAY,SAAS,CAAC,EAAE;AAEnF,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;;"}
1
+ {"version":3,"file":"RefreshViewResolver.cjs","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string, options?: { concurrently?: boolean }): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tconst concurrently = options?.concurrently ? ' CONCURRENTLY' : ''\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":["wrapIdentifier"],"mappings":";;;AAIO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAAgB,SAAgE;AAC9F,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,eAAe,SAAS,eAAe,kBAAkB;AAC/D,UAAM,OAAO,GAAG,MAAM,4BAA4B,YAAY,IAAIA,SAAe,eAAA,OAAO,GAAG,MAAM,CAAC,IAAIA,SAAA,eAAe,YAAY,SAAS,CAAC,EAAE;AAEtI,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;;"}
@@ -4,13 +4,14 @@ class RefreshViewResolver {
4
4
  this.schema = schema;
5
5
  this.mapperFactory = mapperFactory;
6
6
  }
7
- async resolve(entity) {
7
+ async resolve(entity, options) {
8
8
  const mapper = this.mapperFactory.create();
9
9
  const entityModel = this.schema.model.entities[entity];
10
10
  if (!entityModel) {
11
11
  throw new Error(`Entity ${entity} not found`);
12
12
  }
13
- await mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`);
13
+ const concurrently = options?.concurrently ? " CONCURRENTLY" : "";
14
+ await mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`);
14
15
  return { ok: true };
15
16
  }
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewResolver.js","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW ${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAA0C;AACxD,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,OAAO,GAAG,MAAM,6BAA6B,eAAe,YAAY,SAAS,CAAC,EAAE;AAEnF,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;"}
1
+ {"version":3,"file":"RefreshViewResolver.js","sources":["../../../../../packages/engine-content-api/src/resolvers/RefreshViewResolver.ts"],"sourcesContent":["import { Schema } from '@contember/schema'\nimport { MapperFactory } from '../mapper'\nimport { wrapIdentifier } from '@contember/database'\n\nexport class RefreshViewResolver {\n\tconstructor(\n\t\tprivate readonly schema: Schema,\n\t\tprivate readonly mapperFactory: MapperFactory,\n\t) {\n\t}\n\n\tpublic async resolve(entity: string, options?: { concurrently?: boolean }): Promise<{ ok: boolean }> {\n\t\tconst mapper = this.mapperFactory.create()\n\t\tconst entityModel = this.schema.model.entities[entity]\n\t\tif (!entityModel) {\n\t\t\tthrow new Error(`Entity ${entity} not found`)\n\t\t}\n\t\tconst concurrently = options?.concurrently ? ' CONCURRENTLY' : ''\n\t\tawait mapper.db.query(`REFRESH MATERIALIZED VIEW${concurrently} ${wrapIdentifier(mapper.db.schema)}.${wrapIdentifier(entityModel.tableName)}`)\n\n\t\treturn { ok: true }\n\t}\n}\n"],"names":[],"mappings":";AAIO,MAAM,oBAAoB;AAAA,EAChC,YACkB,QACA,eAChB;AAFgB,SAAA,SAAA;AACA,SAAA,gBAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,QAAgB,SAAgE;AAC9F,UAAA,SAAS,KAAK,cAAc,OAAO;AACzC,UAAM,cAAc,KAAK,OAAO,MAAM,SAAS,MAAM;AACrD,QAAI,CAAC,aAAa;AACjB,YAAM,IAAI,MAAM,UAAU,MAAM,YAAY;AAAA,IAAA;AAEvC,UAAA,eAAe,SAAS,eAAe,kBAAkB;AAC/D,UAAM,OAAO,GAAG,MAAM,4BAA4B,YAAY,IAAI,eAAe,OAAO,GAAG,MAAM,CAAC,IAAI,eAAe,YAAY,SAAS,CAAC,EAAE;AAEtI,WAAA,EAAE,IAAI,KAAK;AAAA,EAAA;AAEpB;"}
@@ -15,6 +15,12 @@ class RefreshViewMutationProvider {
15
15
  name: "_MaterializedView",
16
16
  values: Object.fromEntries(materializedViews.map((it) => [it.name, { value: it.name }]))
17
17
  });
18
+ const refreshViewOptions = new graphql.GraphQLInputObjectType({
19
+ name: "RefreshMaterializedViewOptions",
20
+ fields: {
21
+ concurrently: { type: graphql.GraphQLBoolean }
22
+ }
23
+ });
18
24
  return {
19
25
  type: new graphql.GraphQLObjectType({
20
26
  name: "RefreshMaterializedViewResponse",
@@ -23,10 +29,11 @@ class RefreshViewMutationProvider {
23
29
  }
24
30
  }),
25
31
  args: {
26
- name: { type: materializedViewsEnum }
32
+ name: { type: materializedViewsEnum },
33
+ options: { type: refreshViewOptions }
27
34
  },
28
35
  resolve: async (parent, args, context) => {
29
- return await context.executionContainer.refreshViewResolver.resolve(args.name);
36
+ return await context.executionContainer.refreshViewResolver.resolve(args.name, args.options);
30
37
  }
31
38
  };
32
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewMutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["GraphQLEnumType","GraphQLObjectType","GraphQLBoolean"],"mappings":";;;AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAIA,wBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEM,WAAA;AAAA,MACN,MAAM,IAAIC,QAAAA,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAMC,QAAe,eAAA;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AACzC,eAAO,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,IAAI;AAAA,MAAA;AAAA,IAE/E;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"RefreshViewMutationProvider.cjs","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\tconst refreshViewOptions = new GraphQLInputObjectType({\n\t\t\tname: 'RefreshMaterializedViewOptions',\n\t\t\tfields: {\n\t\t\t\tconcurrently: { type: GraphQLBoolean },\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t\toptions: { type: refreshViewOptions },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name, args.options)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":["GraphQLEnumType","GraphQLInputObjectType","GraphQLBoolean","GraphQLObjectType"],"mappings":";;;AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAIA,wBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEK,UAAA,qBAAqB,IAAIC,+BAAuB;AAAA,MACrD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,cAAc,EAAE,MAAMC,QAAe,eAAA;AAAA,MAAA;AAAA,IACtC,CACA;AACM,WAAA;AAAA,MACN,MAAM,IAAIC,QAAAA,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAMD,QAAe,eAAA;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,QACpC,SAAS,EAAE,MAAM,mBAAmB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AAClC,eAAA,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,MAAM,KAAK,OAAO;AAAA,MAAA;AAAA,IAE7F;AAAA,EAAA;AAEF;;"}
@@ -1,4 +1,4 @@
1
- import { GraphQLEnumType, GraphQLObjectType, GraphQLBoolean } from "graphql";
1
+ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLBoolean, GraphQLObjectType } from "graphql";
2
2
  class RefreshViewMutationProvider {
3
3
  constructor(schema, authorizator) {
4
4
  this.schema = schema;
@@ -13,6 +13,12 @@ class RefreshViewMutationProvider {
13
13
  name: "_MaterializedView",
14
14
  values: Object.fromEntries(materializedViews.map((it) => [it.name, { value: it.name }]))
15
15
  });
16
+ const refreshViewOptions = new GraphQLInputObjectType({
17
+ name: "RefreshMaterializedViewOptions",
18
+ fields: {
19
+ concurrently: { type: GraphQLBoolean }
20
+ }
21
+ });
16
22
  return {
17
23
  type: new GraphQLObjectType({
18
24
  name: "RefreshMaterializedViewResponse",
@@ -21,10 +27,11 @@ class RefreshViewMutationProvider {
21
27
  }
22
28
  }),
23
29
  args: {
24
- name: { type: materializedViewsEnum }
30
+ name: { type: materializedViewsEnum },
31
+ options: { type: refreshViewOptions }
25
32
  },
26
33
  resolve: async (parent, args, context) => {
27
- return await context.executionContainer.refreshViewResolver.resolve(args.name);
34
+ return await context.executionContainer.refreshViewResolver.resolve(args.name, args.options);
28
35
  }
29
36
  };
30
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshViewMutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAI,gBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEM,WAAA;AAAA,MACN,MAAM,IAAI,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAM,eAAe;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AACzC,eAAO,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,IAAI;AAAA,MAAA;AAAA,IAE/E;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"RefreshViewMutationProvider.js","sources":["../../../../../packages/engine-content-api/src/schema/RefreshViewMutationProvider.ts"],"sourcesContent":["import { Model } from '@contember/schema'\nimport { GraphQLBoolean, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLObjectType } from 'graphql'\nimport { Context } from '../types'\nimport { Authorizator } from '../acl'\n\nexport class RefreshViewMutationProvider {\n\tconstructor(\n\t\tprivate readonly schema: Model.Schema,\n\t\tprivate readonly authorizator: Authorizator,\n\t) {\n\t}\n\tgetMutation(): GraphQLFieldConfig<any, Context, any> | undefined {\n\t\tconst materializedViews = Object.values(this.schema.entities)\n\t\t\t.filter(it => it.view?.materialized)\n\t\t\t.filter(it => this.authorizator.isRefreshMaterializedViewAllowed(it.name))\n\t\tif (materializedViews.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst materializedViewsEnum = new GraphQLEnumType({\n\t\t\tname: '_MaterializedView',\n\t\t\tvalues: Object.fromEntries(materializedViews.map(it => [it.name, { value: it.name }])),\n\t\t})\n\n\t\tconst refreshViewOptions = new GraphQLInputObjectType({\n\t\t\tname: 'RefreshMaterializedViewOptions',\n\t\t\tfields: {\n\t\t\t\tconcurrently: { type: GraphQLBoolean },\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\ttype: new GraphQLObjectType({\n\t\t\t\tname: 'RefreshMaterializedViewResponse',\n\t\t\t\tfields: {\n\t\t\t\t\tok: { type: GraphQLBoolean },\n\t\t\t\t},\n\t\t\t}),\n\t\t\targs: {\n\t\t\t\tname: { type: materializedViewsEnum },\n\t\t\t\toptions: { type: refreshViewOptions },\n\t\t\t},\n\t\t\tresolve: async (parent, args, context) => {\n\t\t\t\treturn await context.executionContainer.refreshViewResolver.resolve(args.name, args.options)\n\t\t\t},\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAKO,MAAM,4BAA4B;AAAA,EACxC,YACkB,QACA,cAChB;AAFgB,SAAA,SAAA;AACA,SAAA,eAAA;AAAA,EAAA;AAAA,EAGlB,cAAiE;AAC1D,UAAA,oBAAoB,OAAO,OAAO,KAAK,OAAO,QAAQ,EAC1D,OAAO,CAAM,OAAA,GAAG,MAAM,YAAY,EAClC,OAAO,CAAM,OAAA,KAAK,aAAa,iCAAiC,GAAG,IAAI,CAAC;AACtE,QAAA,kBAAkB,WAAW,GAAG;AAC5B,aAAA;AAAA,IAAA;AAGF,UAAA,wBAAwB,IAAI,gBAAgB;AAAA,MACjD,MAAM;AAAA,MACN,QAAQ,OAAO,YAAY,kBAAkB,IAAI,CAAM,OAAA,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,KAAM,CAAA,CAAC,CAAC;AAAA,IAAA,CACrF;AAEK,UAAA,qBAAqB,IAAI,uBAAuB;AAAA,MACrD,MAAM;AAAA,MACN,QAAQ;AAAA,QACP,cAAc,EAAE,MAAM,eAAe;AAAA,MAAA;AAAA,IACtC,CACA;AACM,WAAA;AAAA,MACN,MAAM,IAAI,kBAAkB;AAAA,QAC3B,MAAM;AAAA,QACN,QAAQ;AAAA,UACP,IAAI,EAAE,MAAM,eAAe;AAAA,QAAA;AAAA,MAC5B,CACA;AAAA,MACD,MAAM;AAAA,QACL,MAAM,EAAE,MAAM,sBAAsB;AAAA,QACpC,SAAS,EAAE,MAAM,mBAAmB;AAAA,MACrC;AAAA,MACA,SAAS,OAAO,QAAQ,MAAM,YAAY;AAClC,eAAA,MAAM,QAAQ,mBAAmB,oBAAoB,QAAQ,KAAK,MAAM,KAAK,OAAO;AAAA,MAAA;AAAA,IAE7F;AAAA,EAAA;AAEF;"}