@contember/cli 2.0.0-alpha.18 → 2.0.0-alpha.20

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 (55) hide show
  1. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.cjs +13 -2
  2. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
  3. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.js +14 -3
  4. package/dist/development/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  5. package/dist/development/src/commands/transfer/ExportCommand.cjs +2 -0
  6. package/dist/development/src/commands/transfer/ExportCommand.cjs.map +1 -1
  7. package/dist/development/src/commands/transfer/ExportCommand.js +2 -0
  8. package/dist/development/src/commands/transfer/ExportCommand.js.map +1 -1
  9. package/dist/development/src/commands/transfer/TransferCommand.cjs +2 -0
  10. package/dist/development/src/commands/transfer/TransferCommand.cjs.map +1 -1
  11. package/dist/development/src/commands/transfer/TransferCommand.js +2 -0
  12. package/dist/development/src/commands/transfer/TransferCommand.js.map +1 -1
  13. package/dist/development/src/lib/tenant/TenantClient.cjs +1 -1
  14. package/dist/development/src/lib/tenant/TenantClient.cjs.map +1 -1
  15. package/dist/development/src/lib/tenant/TenantClient.js +2 -2
  16. package/dist/development/src/lib/tenant/TenantClient.js.map +1 -1
  17. package/dist/development/src/lib/transfer/DataTransferClient.cjs +2 -2
  18. package/dist/development/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  19. package/dist/development/src/lib/transfer/DataTransferClient.js +2 -2
  20. package/dist/development/src/lib/transfer/DataTransferClient.js.map +1 -1
  21. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.cjs +13 -2
  22. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.cjs.map +1 -1
  23. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.js +14 -3
  24. package/dist/production/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  25. package/dist/production/src/commands/transfer/ExportCommand.cjs +2 -0
  26. package/dist/production/src/commands/transfer/ExportCommand.cjs.map +1 -1
  27. package/dist/production/src/commands/transfer/ExportCommand.js +2 -0
  28. package/dist/production/src/commands/transfer/ExportCommand.js.map +1 -1
  29. package/dist/production/src/commands/transfer/TransferCommand.cjs +2 -0
  30. package/dist/production/src/commands/transfer/TransferCommand.cjs.map +1 -1
  31. package/dist/production/src/commands/transfer/TransferCommand.js +2 -0
  32. package/dist/production/src/commands/transfer/TransferCommand.js.map +1 -1
  33. package/dist/production/src/lib/tenant/TenantClient.cjs +1 -1
  34. package/dist/production/src/lib/tenant/TenantClient.cjs.map +1 -1
  35. package/dist/production/src/lib/tenant/TenantClient.js +2 -2
  36. package/dist/production/src/lib/tenant/TenantClient.js.map +1 -1
  37. package/dist/production/src/lib/transfer/DataTransferClient.cjs +2 -2
  38. package/dist/production/src/lib/transfer/DataTransferClient.cjs.map +1 -1
  39. package/dist/production/src/lib/transfer/DataTransferClient.js +2 -2
  40. package/dist/production/src/lib/transfer/DataTransferClient.js.map +1 -1
  41. package/dist/types/commands/project/ProjectPrintSchemaCommand.d.ts +4 -0
  42. package/dist/types/commands/project/ProjectPrintSchemaCommand.d.ts.map +1 -1
  43. package/dist/types/commands/transfer/ExportCommand.d.ts +1 -0
  44. package/dist/types/commands/transfer/ExportCommand.d.ts.map +1 -1
  45. package/dist/types/commands/transfer/TransferCommand.d.ts +1 -0
  46. package/dist/types/commands/transfer/TransferCommand.d.ts.map +1 -1
  47. package/dist/types/lib/transfer/DataTransferClient.d.ts +2 -1
  48. package/dist/types/lib/transfer/DataTransferClient.d.ts.map +1 -1
  49. package/dist/types/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +18 -18
  51. package/src/commands/project/ProjectPrintSchemaCommand.ts +19 -3
  52. package/src/commands/transfer/ExportCommand.ts +3 -0
  53. package/src/commands/transfer/TransferCommand.ts +3 -0
  54. package/src/lib/tenant/TenantClient.ts +1 -1
  55. package/src/lib/transfer/DataTransferClient.ts +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/cli",
3
- "version": "2.0.0-alpha.18",
3
+ "version": "2.0.0-alpha.20",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "contember": "./dist/production/run.js"
@@ -11,27 +11,27 @@
11
11
  "devDependencies": {
12
12
  "@types/fs-extra": "^11.0.4",
13
13
  "@types/js-yaml": "^4.0.9",
14
- "@types/node": "^20.16.5",
14
+ "@types/node": "^20.16.11",
15
15
  "@types/prompts": "^2.4.9",
16
16
  "@types/semver": "^7.5.8",
17
17
  "autoprefixer": "^10.4.20",
18
- "postcss": "^8.4.45",
19
- "tailwindcss": "^3.4.10"
18
+ "postcss": "^8.4.47",
19
+ "tailwindcss": "^3.4.14"
20
20
  },
21
21
  "dependencies": {
22
- "@contember/cli-common": "2.0.0-alpha.18",
23
- "@contember/config-loader": "2.0.0-alpha.18",
24
- "@contember/database": "2.0.0-alpha.18",
25
- "@contember/dic": "2.0.0-alpha.18",
26
- "@contember/engine-common": "2.0.0-alpha.18",
27
- "@contember/engine-content-api": "2.0.0-alpha.18",
28
- "@contember/graphql-client": "2.0.0-alpha.18",
29
- "@contember/migrations-client": "2.0.0-alpha.18",
30
- "@contember/schema": "2.0.0-alpha.18",
31
- "@contember/schema-migrations": "2.0.0-alpha.18",
32
- "@contember/schema-utils": "2.0.0-alpha.18",
33
- "@contember/typesafe": "2.0.0-alpha.18",
34
- "@graphql-tools/schema": "^10.0.6",
22
+ "@contember/cli-common": "2.0.0-alpha.20",
23
+ "@contember/config-loader": "2.0.0-alpha.20",
24
+ "@contember/database": "2.0.0-alpha.20",
25
+ "@contember/dic": "2.0.0-alpha.20",
26
+ "@contember/engine-common": "2.0.0-alpha.20",
27
+ "@contember/engine-content-api": "2.0.0-alpha.20",
28
+ "@contember/graphql-client": "2.0.0-alpha.20",
29
+ "@contember/migrations-client": "2.0.0-alpha.20",
30
+ "@contember/schema": "2.0.0-alpha.20",
31
+ "@contember/schema-migrations": "2.0.0-alpha.20",
32
+ "@contember/schema-utils": "2.0.0-alpha.20",
33
+ "@contember/typesafe": "2.0.0-alpha.20",
34
+ "@graphql-tools/schema": "^10.0.7",
35
35
  "chalk": "^5.3.0",
36
36
  "chalk-table": "^1.0.2",
37
37
  "esbuild": "^0.21.5",
@@ -41,7 +41,7 @@
41
41
  "lodash-es": "^4.17.21",
42
42
  "pg": "^8.12.0",
43
43
  "preact": "^10.23.2",
44
- "preact-render-to-string": "^6.5.10",
44
+ "preact-render-to-string": "^6.5.11",
45
45
  "prompts": "^2.4.2",
46
46
  "semver": "^7.6.3",
47
47
  "yawn-yaml": "^2.3.0"
@@ -9,7 +9,7 @@ import {
9
9
  } from '@contember/engine-content-api'
10
10
  import { printSchema } from 'graphql'
11
11
  import { mergeSchemas } from '@graphql-tools/schema'
12
- import { normalizeSchema } from '@contember/schema-utils'
12
+ import { emptySchema, normalizeSchema } from '@contember/schema-utils'
13
13
  import { SchemaLoader } from '../../lib/schema/SchemaLoader'
14
14
  import { SchemaVersionBuilder } from '@contember/migrations-client'
15
15
  import { validateSchemaAndPrintErrors } from '../../lib/schema/SchemaValidationHelper'
@@ -22,6 +22,10 @@ type Options = {
22
22
  normalize?: boolean
23
23
  format?: 'graphql' | 'introspection' | 'schema'
24
24
  source?: 'migrations' | 'definition'
25
+ ['omit-acl']?: boolean
26
+ ['omit-validation']?: boolean
27
+ ['omit-actions']?: boolean
28
+ ['omit-settings']?: boolean
25
29
  }
26
30
 
27
31
  export class ProjectPrintSchemaCommand extends Command<Args, Options> {
@@ -38,6 +42,10 @@ export class ProjectPrintSchemaCommand extends Command<Args, Options> {
38
42
  configuration.option('source').valueRequired().description('migrations|definition')
39
43
  configuration.option('role').valueArray()
40
44
  configuration.option('normalize').valueNone()
45
+ configuration.option('omit-acl').valueNone()
46
+ configuration.option('omit-validation').valueNone()
47
+ configuration.option('omit-actions').valueNone()
48
+ configuration.option('omit-settings').valueNone()
41
49
  }
42
50
 
43
51
  protected async execute(input: Input<Args, Options>): Promise<number> {
@@ -48,13 +56,21 @@ export class ProjectPrintSchemaCommand extends Command<Args, Options> {
48
56
  ? await this.schemaVersionBuilder.buildSchema()
49
57
  : await this.schemaLoader.loadSchema()
50
58
 
51
- if (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {
59
+ const filteredSchema = {
60
+ model: schema.model,
61
+ acl: input.getOption('omit-acl') ? emptySchema.acl : schema.acl,
62
+ validation: input.getOption('omit-validation') ? emptySchema.validation : schema.validation,
63
+ actions: input.getOption('omit-actions') ? emptySchema.actions : schema.actions,
64
+ settings: input.getOption('omit-settings') ? emptySchema.settings : schema.settings,
65
+ }
66
+
67
+ if (!validateSchemaAndPrintErrors(filteredSchema, 'Defined schema is invalid:')) {
52
68
  return 1
53
69
  }
54
70
 
55
71
  const permissionFactory = new PermissionFactory()
56
72
  const inputRoles = input.getOption('role')
57
- const schemaNormalized = input.getOption('normalize') ? normalizeSchema(schema) : schema
73
+ const schemaNormalized = input.getOption('normalize') ? normalizeSchema(filteredSchema) : filteredSchema
58
74
  const permissions = permissionFactory.create(schemaNormalized, inputRoles || ['admin'])
59
75
  const schemaBuilderFactory = new GraphQlSchemaBuilderFactory()
60
76
  const authorizator = new Authorizator(permissions, schemaNormalized.acl.customPrimary ?? false)
@@ -17,6 +17,7 @@ type Options = {
17
17
  'no-gzip-output'?: boolean
18
18
  'no-gzip-transfer'?: boolean
19
19
  output?: string
20
+ 'exclude-table'?: string[]
20
21
  }
21
22
 
22
23
  export class ExportCommand extends Command<Args, Options> {
@@ -35,6 +36,7 @@ export class ExportCommand extends Command<Args, Options> {
35
36
  configuration.option('no-gzip-transfer').valueNone()
36
37
  configuration.option('no-gzip-output').valueNone()
37
38
  configuration.option('output').valueRequired()
39
+ configuration.option('exclude-table').valueArray()
38
40
  }
39
41
 
40
42
  protected async execute(input: Input<Args, Options>): Promise<void | number> {
@@ -58,6 +60,7 @@ export class ExportCommand extends Command<Args, Options> {
58
60
 
59
61
  const response = await this.dataTransferClient.dataExport({
60
62
  project,
63
+ excludeTables: input.getOption('exclude-table') ?? [],
61
64
  includeSystem,
62
65
  gzip: gzipTransfer,
63
66
  })
@@ -15,6 +15,7 @@ type Options = {
15
15
  'include-system'?: boolean
16
16
  'no-gzip-transfer'?: boolean
17
17
  yes: boolean
18
+ 'exclude-table'?: string[]
18
19
  }
19
20
 
20
21
  export class TransferCommand extends Command<Args, Options> {
@@ -32,6 +33,7 @@ export class TransferCommand extends Command<Args, Options> {
32
33
  configuration.option('include-system').valueNone()
33
34
  configuration.option('no-gzip-transfer').valueNone()
34
35
  configuration.option('yes').valueNone()
36
+ configuration.option('exclude-table').valueArray()
35
37
  }
36
38
 
37
39
  protected async execute(input: Input<Args, Options>): Promise<void | number> {
@@ -68,6 +70,7 @@ export class TransferCommand extends Command<Args, Options> {
68
70
  const exportResponse = (await this.dataTransferClient.dataExport({
69
71
  project: sourceProject,
70
72
  includeSystem,
73
+ excludeTables: input.getOption('exclude-table') ?? [],
71
74
  gzip: gzipTransfer,
72
75
  }))
73
76
  const ungzipedResponse = gzipTransfer ? exportResponse.pipe(createGunzip()) : exportResponse
@@ -15,7 +15,7 @@ export class TenantClient {
15
15
  constructor(private readonly apiClient: GraphQlClient) {}
16
16
 
17
17
  public static create(url: string, apiToken: string): TenantClient {
18
- const graphqlClient = new GraphQlClient(createTenantApiUrl(url), apiToken)
18
+ const graphqlClient = new GraphQlClient({ url: createTenantApiUrl(url), apiToken })
19
19
  return new TenantClient(graphqlClient)
20
20
  }
21
21
 
@@ -60,8 +60,9 @@ export class DataTransferClient {
60
60
  }
61
61
 
62
62
 
63
- dataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem }: {
63
+ dataExport = async ({ project: { name: project, token, endpoint: baseUrl }, gzip, includeSystem, excludeTables }: {
64
64
  project: RemoteProject
65
+ excludeTables?: string[]
65
66
  includeSystem: boolean
66
67
  gzip: boolean
67
68
  }) => {
@@ -73,7 +74,7 @@ export class DataTransferClient {
73
74
  'Content-type': 'application/json',
74
75
  },
75
76
  body: JSON.stringify({
76
- projects: [{ slug: project, system: includeSystem }],
77
+ projects: [{ slug: project, system: includeSystem, excludeTables }],
77
78
  }),
78
79
  })
79
80
  }