@contember/engine-vimeo-plugin 2.0.0-alpha.9 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/development/index.cjs +2 -5
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +2 -5
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/VimeoConfigProcessor.cjs.map +1 -1
  6. package/dist/development/src/VimeoConfigProcessor.js.map +1 -1
  7. package/dist/development/src/VimeoSchemaContributor.cjs +12 -7
  8. package/dist/development/src/VimeoSchemaContributor.cjs.map +1 -1
  9. package/dist/development/src/VimeoSchemaContributor.js +13 -8
  10. package/dist/development/src/VimeoSchemaContributor.js.map +1 -1
  11. package/dist/development/src/VimeoService.cjs.map +1 -1
  12. package/dist/development/src/VimeoService.js.map +1 -1
  13. package/dist/production/index.cjs +2 -5
  14. package/dist/production/index.cjs.map +1 -1
  15. package/dist/production/index.js +2 -5
  16. package/dist/production/index.js.map +1 -1
  17. package/dist/production/src/VimeoConfigProcessor.cjs.map +1 -1
  18. package/dist/production/src/VimeoConfigProcessor.js.map +1 -1
  19. package/dist/production/src/VimeoSchemaContributor.cjs +12 -7
  20. package/dist/production/src/VimeoSchemaContributor.cjs.map +1 -1
  21. package/dist/production/src/VimeoSchemaContributor.js +13 -8
  22. package/dist/production/src/VimeoSchemaContributor.js.map +1 -1
  23. package/dist/production/src/VimeoService.cjs.map +1 -1
  24. package/dist/production/src/VimeoService.js.map +1 -1
  25. package/dist/types/VimeoSchemaContributor.d.ts +2 -3
  26. package/dist/types/VimeoSchemaContributor.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +2 -2
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +6 -6
  31. package/src/VimeoSchemaContributor.ts +15 -9
  32. package/src/index.ts +2 -5
  33. package/tsconfig.settings.json +0 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contember/engine-vimeo-plugin",
3
3
  "license": "Apache-2.0",
4
- "version": "2.0.0-alpha.9",
4
+ "version": "2.0.0-beta.2",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
7
7
  "exports": {
@@ -23,16 +23,16 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@contember/engine-plugins": "2.0.0-alpha.9",
27
- "@contember/typesafe": "2.0.0-alpha.9"
26
+ "@contember/engine-plugins": "2.0.0-beta.2",
27
+ "@contember/typesafe": "2.0.0-beta.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/node": "^20.9.0",
31
- "graphql": "^16.8.1"
30
+ "@types/node": "^20.16.11",
31
+ "graphql": "^16.9.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "graphql": ">= 14.6.0",
35
35
  "pg": "^8.9.0"
36
36
  },
37
37
  "type": "module"
38
- }
38
+ }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  GraphQLBoolean,
3
+ GraphQLError,
3
4
  GraphQLFieldConfig,
4
5
  GraphQLInt,
5
6
  GraphQLList,
@@ -8,8 +9,8 @@ import {
8
9
  GraphQLSchemaConfig,
9
10
  GraphQLString,
10
11
  } from 'graphql'
11
- import { VimeoService, VimeoServiceFactory } from './VimeoService'
12
- import { VimeoConfig } from './Config'
12
+ import { VimeoServiceFactory } from './VimeoService'
13
+ import { ProjectVimeoConfig } from './Config'
13
14
  import { GraphQLSchemaContributor, GraphQLSchemaContributorContext } from '@contember/engine-plugins'
14
15
 
15
16
  interface VimeoAcl {
@@ -18,12 +19,15 @@ interface VimeoAcl {
18
19
 
19
20
  export class VimeoSchemaContributor implements GraphQLSchemaContributor {
20
21
  constructor(
21
- private readonly vimeoConfig: VimeoConfig | undefined,
22
22
  private readonly vimeoServiceFactory: VimeoServiceFactory,
23
23
  ) {}
24
24
 
25
+ getCacheKey?(context: GraphQLSchemaContributorContext): string {
26
+ return context.project.vimeo ? 'yes' : 'no'
27
+ }
28
+
25
29
  createSchema(context: GraphQLSchemaContributorContext): GraphQLSchemaConfig | undefined {
26
- if (!this.vimeoConfig) {
30
+ if (!context.project.vimeo) {
27
31
  return undefined
28
32
  }
29
33
 
@@ -35,9 +39,7 @@ export class VimeoSchemaContributor implements GraphQLSchemaContributor {
35
39
  return undefined
36
40
  }
37
41
 
38
- const vimeoService = this.vimeoServiceFactory.create(this.vimeoConfig)
39
-
40
- const uploadMutation = this.createMutation(vimeoService)
42
+ const uploadMutation = this.createMutation()
41
43
  const mutation = {
42
44
  generateVimeoUploadUrl: uploadMutation as GraphQLFieldConfig<any, any, any>,
43
45
  }
@@ -57,7 +59,7 @@ export class VimeoSchemaContributor implements GraphQLSchemaContributor {
57
59
  }
58
60
  }
59
61
 
60
- private createMutation(vimeoService: VimeoService): GraphQLFieldConfig<any, any, any> {
62
+ private createMutation(): GraphQLFieldConfig<any, any, any> {
61
63
  return {
62
64
  type: new GraphQLNonNull(
63
65
  new GraphQLObjectType({
@@ -97,7 +99,11 @@ export class VimeoSchemaContributor implements GraphQLSchemaContributor {
97
99
  type: new GraphQLNonNull(GraphQLInt),
98
100
  },
99
101
  },
100
- resolve: async (parent: any, args: { size: number }) => {
102
+ resolve: async (parent: any, args: { size: number }, ctx: { project: ProjectVimeoConfig }) => {
103
+ if (!ctx.project.vimeo) {
104
+ throw new GraphQLError('Vimeo is not configured for this project')
105
+ }
106
+ const vimeoService = this.vimeoServiceFactory.create(ctx.project.vimeo)
101
107
  return await vimeoService.getUploadUrl(args.size)
102
108
  },
103
109
  }
package/src/index.ts CHANGED
@@ -14,11 +14,8 @@ export default class VimeoPlugin implements Plugin<ProjectVimeoConfig> {
14
14
  return new VimeoConfigProcessor()
15
15
  }
16
16
 
17
- getSchemaContributor({ project }: SchemaContributorArgs<ProjectVimeoConfig>) {
18
- if (!project.vimeo) {
19
- return undefined
20
- }
17
+ getSchemaContributor() {
21
18
  const vimeoServiceFactory = new VimeoServiceFactory()
22
- return new VimeoSchemaContributor(project.vimeo, vimeoServiceFactory)
19
+ return new VimeoSchemaContributor(vimeoServiceFactory)
23
20
  }
24
21
  }
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "typeRoots": [
4
- "./types",
5
- "./node_modules/@types"
6
- ]
7
3
  },
8
4
  "extends": "../../tsconfig.settings.json"
9
5
  }