Use graphql-codegen (#1874)

* Use generated hooks in apps

* Remove unused files

* Use proper types in apps

* Use generated hooks in attributes

* Use generated hooks in auth module

* Use generated hooks in categories

* Use generated hooks in channels

* Use generated types in collections

* Remove legacy types from background tasks

* Use generated hooks in customers

* Use generated hooks in discounts

* Use generated hook in file upload

* Use generated types in gift cards

* Use generated types in home

* Use generated hooks in navigation

* Use generated hooks in orders

* Use generated hooks in pages

* Use generated hooks in page types

* Use generated hooks in permission groups

* Use generated hooks in plugins

* Use generated hooks in products

* Use fragment to mark product variants

* Improve code a bit

* Use generated hooks in page types

* Use generated types in searches

* Use generated hooks in shipping

* Use generated hooks in site settings

* Use generated hooks in staff members

* Use generated hooks in taxes

* Place all gql generated files in one directory

* Use generated hooks in translations

* Use global types from new generated module

* Use generated hooks in warehouses

* Use generated hooks in webhooks

* Use generated fragment types

* Unclutter types

* Remove hoc components

* Split hooks and types

* Fetch introspection file

* Delete obsolete schema file

* Fix rebase artifacts

* Fix autoreplace

* Fix auth provider tests

* Fix urls

* Remove leftover types

* Fix rebase artifacts
This commit is contained in:
Dominik Żegleń 2022-03-09 09:56:55 +01:00 committed by GitHub
parent 29461658a2
commit 5b85d6c086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1420 changed files with 124333 additions and 74552 deletions

View file

@ -84,6 +84,7 @@
"eqeqeq": ["error", "smart"],
"guard-for-in": "error",
"id-blacklist": "off",
"import/no-duplicates": "error",
"import/no-extraneous-dependencies": "off", // imports are handled by simple-import-sort/sort
"import/no-internal-modules": "off", // imports are handled by simple-import-sort/sort
"import/order": "off", // imports are handled by simple-import-sort/sort

View file

@ -1,3 +1,4 @@
types/
schema.graphql
src/type-policies.ts
*.generated.*
src/graphql/extendedTypes.ts

View file

@ -1,12 +1,53 @@
overwrite: true
schema: ./schema.graphql
schema: ./introspection.json
generates:
fragmentTypes.json:
./src/graphql/fragmentTypes.generated.ts:
plugins:
- add:
content: /* eslint-disable */
- fragment-matcher
config:
minify: false
apolloClientVersion: 3
./src/type-policies.ts:
./src/graphql/typePolicies.generated.ts:
plugins:
- add:
content: /* eslint-disable */
- typescript-apollo-client-helpers
./src/graphql/types.generated.ts:
documents:
- ./src/**/queries.ts
- ./src/**/mutations.ts
- ./src/**/fragments/*.ts
- ./src/searches/*.ts
config:
nonOptionalTypename: true
avoidOptionals:
field: true
inputValue: false
object: false
defaultValue: false
namingConvention:
enumValues: change-case-all#upperCase
onlyOperationTypes: true
plugins:
- add:
content: /* eslint-disable */
- typescript
- typescript-operations
./src/graphql/hooks.generated.ts:
documents:
- ./src/**/queries.ts
- ./src/**/mutations.ts
- ./src/**/fragments/*.ts
- ./src/searches/*.ts
preset: import-types
presetConfig:
typesPath: ./types.generated
config:
withHooks: true
apolloReactHooksImportFrom: "@saleor/hooks/graphql"
plugins:
- add:
content: /* eslint-disable */
- typescript-react-apollo

5
fetch-schema.yml Normal file
View file

@ -0,0 +1,5 @@
schema: ${API_URI}
generates:
./introspection.json:
plugins:
- introspection

88121
introspection.json Normal file

File diff suppressed because it is too large Load diff

460
package-lock.json generated
View file

@ -2112,6 +2112,59 @@
"integrity": "sha512-KWk80UPIzPmUg+P0rKh6TqspRw0G6eux1PuJr+zz47ftMaZ9QDwbGzHZbtzWkl5hgayM/qrKRutllRC7D/vVXQ==",
"dev": true
},
"@graphql-codegen/add": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/add/-/add-3.1.1.tgz",
"integrity": "sha512-XkVwcqosa0CVBlL1HaQT0gp+EUfhuQE3LzrEpzMQLwchxaj/NPVYtOJL6MUHaYDsHzLqxWrufjfbeB3y2NQgRw==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.3.2",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/cli": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/cli/-/cli-2.1.1.tgz",
@ -2420,6 +2473,132 @@
}
}
},
"@graphql-codegen/import-types-preset": {
"version": "2.1.12",
"resolved": "https://registry.npmjs.org/@graphql-codegen/import-types-preset/-/import-types-preset-2.1.12.tgz",
"integrity": "sha512-nFipXzsLJnjZY06PKBovg1hxnueB5n/RSlBPYA29ymahEenNR1vMejbq8/+iuRoxexLuYVSVnJAEcqoBriUKrg==",
"dev": true,
"requires": {
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/visitor-plugin-common": "2.7.1",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.1.tgz",
"integrity": "sha512-OPMma7aUnES3Dh+M0BfiNBnJLmYuH60EnbULAhufxFDn/Y2OA0Ht/LQok9beX6VN4ASZEMCOAGItJezGJr5DJw==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-codegen/visitor-plugin-common": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.7.1.tgz",
"integrity": "sha512-Ew/+0GwGwL3ZSXS0cYz6lVvE7S5SkbTr7caRpLa4FpAdLGNskCgdA1n6W5tX5c7qsaYstqlxp30hJTfgTsYS6A==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-tools/optimize": "^1.0.1",
"@graphql-tools/relay-operation-optimizer": "^6.3.7",
"@graphql-tools/utils": "^8.3.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"dependency-graph": "^0.11.0",
"graphql-tag": "^2.11.0",
"parse-filepath": "^1.0.2",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/introspection": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/introspection/-/introspection-2.1.1.tgz",
"integrity": "sha512-O9zsy0IoFYDo37pBVF4pSvRMDx/AKdgOxyko4R/O+0DHEw9Nya/pQ3dbn+LDLj2n6X+xOXUBUfFvqhODTqU28w==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.3.2",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.1.tgz",
"integrity": "sha512-OPMma7aUnES3Dh+M0BfiNBnJLmYuH60EnbULAhufxFDn/Y2OA0Ht/LQok9beX6VN4ASZEMCOAGItJezGJr5DJw==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/plugin-helpers": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.1.0.tgz",
@ -2448,18 +2627,110 @@
}
}
},
"@graphql-codegen/typescript": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript/-/typescript-2.1.1.tgz",
"integrity": "sha512-FDTuFIvuP0wbwuEUfMw7PiNVE4qJkjpiAccaZTEm6A69Wcumt774qaHMQC2vIg2t5xi1t69n8lbIggdtgf6Xtw==",
"@graphql-codegen/schema-ast": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/schema-ast/-/schema-ast-2.4.1.tgz",
"integrity": "sha512-bIWlKk/ShoVJfghA4Rt1OWnd34/dQmZM/vAe6fu6QKyOh44aAdqPtYQ2dbTyFXoknmu504etKJGEDllYNUJRfg==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.1.0",
"@graphql-codegen/visitor-plugin-common": "2.1.1",
"@graphql-codegen/plugin-helpers": "^2.3.2",
"@graphql-tools/utils": "^8.1.1",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
}
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/typescript": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript/-/typescript-2.4.3.tgz",
"integrity": "sha512-5b+4EVA01kiKId6IbBvuvSs0/aGeuSU+Cg2pBbe9VZol49iid982p28k9knEH4Jzgu4tUp4UMQTWNNwkPB4tEQ==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/schema-ast": "^2.4.1",
"@graphql-codegen/visitor-plugin-common": "2.6.0",
"auto-bind": "~4.0.0",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
@ -2542,16 +2813,146 @@
}
}
},
"@graphql-codegen/visitor-plugin-common": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.1.1.tgz",
"integrity": "sha512-FO8kMDL+Y1yw8DirhIsY97RjVKfmxxhK179njA46Vu85Rg4zCuLpGMyB0mkhl95QGfdfuJjbB1lz34U27Ce9Wg==",
"@graphql-codegen/typescript-operations": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript-operations/-/typescript-operations-2.2.4.tgz",
"integrity": "sha512-PAunOSdl4avsaGLTBxZkxOBQNfp9bmobBOX5p6q99NMYwoXsmtyu0mD8jIbzM+LMbxrskNxKJ1sywZ11aYGCMA==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.1.0",
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/typescript": "^2.4.3",
"@graphql-codegen/visitor-plugin-common": "2.6.0",
"auto-bind": "~4.0.0",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/typescript-react-apollo": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/@graphql-codegen/typescript-react-apollo/-/typescript-react-apollo-3.2.5.tgz",
"integrity": "sha512-ODOmONBfZpNpWXrF6TKfeEoaaU/mnQ9lLZ1rv1fu2FusREvpMITaLznYUDo1RsI+iSjsJYm7dmSJmFPv+lxZrg==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-codegen/visitor-plugin-common": "2.6.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-codegen/visitor-plugin-common": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.6.0.tgz",
"integrity": "sha512-MysdJ8L/dIn62D+BFbiu6HSVaZfkAt0EI1g5twkpKzLmG7qDJ8P7KemFVFU/sCW3SVuhs7XabkSjnFK9uBquwg==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-tools/optimize": "^1.0.1",
"@graphql-tools/relay-operation-optimizer": "^6.3.7",
"@graphql-tools/utils": "^8.3.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"dependency-graph": "^0.11.0",
"graphql-tag": "^2.11.0",
"parse-filepath": "^1.0.2",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
}
}
},
"@graphql-codegen/visitor-plugin-common": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/visitor-plugin-common/-/visitor-plugin-common-2.6.0.tgz",
"integrity": "sha512-MysdJ8L/dIn62D+BFbiu6HSVaZfkAt0EI1g5twkpKzLmG7qDJ8P7KemFVFU/sCW3SVuhs7XabkSjnFK9uBquwg==",
"dev": true,
"requires": {
"@graphql-codegen/plugin-helpers": "^2.4.0",
"@graphql-tools/optimize": "^1.0.1",
"@graphql-tools/relay-operation-optimizer": "^6.3.7",
"array.prototype.flatmap": "^1.2.4",
"@graphql-tools/utils": "^8.3.0",
"auto-bind": "~4.0.0",
"change-case-all": "1.0.14",
"dependency-graph": "^0.11.0",
@ -2560,6 +2961,41 @@
"tslib": "~2.3.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@graphql-codegen/plugin-helpers/-/plugin-helpers-2.4.0.tgz",
"integrity": "sha512-bQ2EwVU34wkTrWM4/LbXS4t+ROYFM3qzwrRX6aFNYwAPho/fubryBHmNuUTh4evACFMx1ymQ6QLnvOUAoXYZSQ==",
"dev": true,
"requires": {
"@graphql-tools/utils": "^8.5.2",
"change-case-all": "1.0.14",
"common-tags": "1.8.2",
"import-from": "4.0.0",
"lodash": "~4.17.0",
"tslib": "~2.3.0"
}
},
"@graphql-tools/utils": {
"version": "8.6.1",
"resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-8.6.1.tgz",
"integrity": "sha512-uxcfHCocp4ENoIiovPxUWZEHOnbXqj3ekWc0rm7fUhW93a1xheARNHcNKhwMTR+UKXVJbTFQdGI1Rl5XdyvDBg==",
"dev": true,
"requires": {
"tslib": "~2.3.0"
}
},
"common-tags": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz",
"integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==",
"dev": true
},
"import-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/import-from/-/import-from-4.0.0.tgz",
"integrity": "sha512-P9J71vT5nLlDeV8FHs5nNxaLbrpfAV5cF5srvbZfpwpcJoM/xZR3hiv+q+SAnuSmuGbXMWud063iIMx/V/EWZQ==",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",

View file

@ -93,10 +93,15 @@
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.7.6",
"@editorjs/embed": "^2.4.6",
"@graphql-codegen/add": "^3.1.1",
"@graphql-codegen/cli": "^2.1.1",
"@graphql-codegen/fragment-matcher": "^3.1.0",
"@graphql-codegen/typescript": "^2.1.1",
"@graphql-codegen/import-types-preset": "^2.1.12",
"@graphql-codegen/introspection": "^2.1.1",
"@graphql-codegen/typescript": "^2.4.3",
"@graphql-codegen/typescript-apollo-client-helpers": "^2.1.10",
"@graphql-codegen/typescript-operations": "^2.2.4",
"@graphql-codegen/typescript-react-apollo": "^3.2.5",
"@pollyjs/adapter-node-http": "^5.0.0",
"@pollyjs/core": "^5.0.0",
"@pollyjs/persister-fs": "^5.0.0",
@ -249,16 +254,16 @@
},
"scripts": {
"build-storybook": "build-storybook -c src/storybook/ -o build/storybook",
"generate-fragment-types": "graphql-codegen",
"build-types": "npx apollo client:codegen --target=typescript types --globalTypesFile=src/types/globalTypes.ts && npm run generate-fragment-types",
"build": "npm run generate-fragment-types && webpack -p",
"build-types": "graphql-codegen",
"build": "npm run build-types && webpack -p",
"check-strict-null-errors": "tsc --noEmit --strictNullChecks | node scripts/count-strict-null-check-errors.js",
"check-types": "tsc --noEmit",
"extract-json-messages": "rimraf build/locale && cross-env NODE_ENV=extract babel src 'src/**/*.{ts,tsx}' -o build/dashboard.bundle.js",
"extract-messages": "npm run extract-json-messages && npm run transpile-messages",
"fetch-schema": "graphql-codegen --config ./fetch-schema.yml",
"heroku-postbuild": "npm run build",
"serve:lhci": "NODE_ENV=production npm run server",
"start": "npm run generate-fragment-types && webpack-dev-server -d",
"start": "npm run build-types && webpack-dev-server -d",
"storybook": "start-storybook -p 3000 -c src/storybook/",
"cy:run": "cypress run",
"cy:run:report": "cypress run --env tags=all --reporter cypress-mochawesome-reporter --reporter-options reportDir='cypress/reports',overwrite=true,charts=true",

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,7 @@ import Container from "@saleor/components/Container";
import ExternalLink from "@saleor/components/ExternalLink";
import PageHeader from "@saleor/components/PageHeader";
import Skeleton from "@saleor/components/Skeleton";
import { AppQuery } from "@saleor/graphql";
import { sectionNames } from "@saleor/intl";
import { Backlink, Button } from "@saleor/macaw-ui";
import React from "react";
@ -16,12 +17,11 @@ import activateIcon from "../../../../assets/images/activate-icon.svg";
import settingsIcon from "../../../../assets/images/settings-icon.svg";
import supportIcon from "../../../../assets/images/support-icon.svg";
import { useStyles } from "../../styles";
import { App_app } from "../../types/App";
import DeactivatedText from "../DeactivatedText";
export interface AppDetailsPageProps {
loading: boolean;
data: App_app;
data: AppQuery["app"];
navigateToApp: () => void;
navigateToAppSettings: () => void;
onAppActivateOpen: () => void;

View file

@ -1,12 +1,12 @@
import saleorDarkLogoSmall from "@assets/images/logo-dark-small.svg";
import plusIcon from "@assets/images/plus-icon.svg";
import { Card, CardContent, Grid, Typography } from "@material-ui/core";
import { AppInstall_appInstall_errors } from "@saleor/apps/types/AppInstall";
import CardSpacer from "@saleor/components/CardSpacer";
import CardTitle from "@saleor/components/CardTitle";
import Container from "@saleor/components/Container";
import Hr from "@saleor/components/Hr";
import Skeleton from "@saleor/components/Skeleton";
import { AppFetchMutation, AppInstallMutation } from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { buttonMessages } from "@saleor/intl";
import { Button } from "@saleor/macaw-ui";
@ -15,13 +15,12 @@ import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { useStyles } from "../../styles";
import { AppFetch_appFetchManifest_manifest } from "../../types/AppFetch";
export interface AppInstallPageProps {
data: AppFetch_appFetchManifest_manifest;
data: AppFetchMutation["appFetchManifest"]["manifest"];
loading: boolean;
navigateToAppsList: () => void;
onSubmit: () => SubmitPromise<AppInstall_appInstall_errors[]>;
onSubmit: () => SubmitPromise<AppInstallMutation["appInstall"]["errors"]>;
}
export const AppInstallPage: React.FC<AppInstallPageProps> = ({

View file

@ -3,19 +3,19 @@ import CardSpacer from "@saleor/components/CardSpacer";
import Container from "@saleor/components/Container";
import Grid from "@saleor/components/Grid";
import Hr from "@saleor/components/Hr";
import { AppQuery } from "@saleor/graphql";
import { sectionNames } from "@saleor/intl";
import { Backlink, Button } from "@saleor/macaw-ui";
import classNames from "classnames";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { App_app } from "../../types/App";
import { AppFrame } from "../AppFrame";
import { useStyles } from "./styles";
import useSettingsBreadcrumbs from "./useSettingsBreadcrumbs";
export interface AppPageProps {
data: App_app;
data: AppQuery["app"];
url: string;
navigateToAbout: () => void;
onBack: () => void;

View file

@ -9,19 +9,22 @@ import {
} from "@material-ui/core";
import ErrorIcon from "@material-ui/icons/Error";
import CardTitle from "@saleor/components/CardTitle";
import { DeleteIcon, ResponsiveTable } from "@saleor/macaw-ui";
import { Button, IconButton } from "@saleor/macaw-ui";
import { AppsInstallationsQuery, JobStatusEnum } from "@saleor/graphql";
import {
Button,
DeleteIcon,
IconButton,
ResponsiveTable
} from "@saleor/macaw-ui";
import { renderCollection, stopPropagation } from "@saleor/misc";
import classNames from "classnames";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { JobStatusEnum } from "../../../types/globalTypes";
import { useStyles } from "../../styles";
import { AppsInstallations_appsInstallations } from "../../types/AppsInstallations";
export interface AppsInProgressProps {
appsList: AppsInstallations_appsInstallations[];
appsList: AppsInstallationsQuery["appsInstallations"];
disabled: boolean;
onAppInstallRetry: (id: string) => void;
onRemove: (id: string) => void;

View file

@ -18,7 +18,10 @@ const props: AppsListPageProps = {
...searchPageProps,
...sortPageProps,
...tabPageProps,
appsInProgressList: { appsInstallations: appsInProgress },
appsInProgressList: {
__typename: "Query",
appsInstallations: appsInProgress
},
customAppsList,
disabled: false,
installedAppsList: appsList,

View file

@ -1,22 +1,21 @@
import CardSpacer from "@saleor/components/CardSpacer";
import Container from "@saleor/components/Container";
import PageHeader from "@saleor/components/PageHeader";
import { AppsInstallationsQuery, AppsListQuery } from "@saleor/graphql";
import { sectionNames } from "@saleor/intl";
import { ListProps } from "@saleor/types";
import React from "react";
import { useIntl } from "react-intl";
import { AppsInstallations } from "../../types/AppsInstallations";
import { AppsList_apps_edges } from "../../types/AppsList";
import AppsInProgress from "../AppsInProgress/AppsInProgress";
import CustomApps from "../CustomApps/CustomApps";
import InstalledApps from "../InstalledApps/InstalledApps";
import Marketplace from "../Marketplace";
export interface AppsListPageProps extends ListProps {
installedAppsList: AppsList_apps_edges[];
customAppsList: AppsList_apps_edges[];
appsInProgressList?: AppsInstallations;
installedAppsList: AppsListQuery["apps"]["edges"];
customAppsList: AppsListQuery["apps"]["edges"];
appsInProgressList?: AppsInstallationsQuery;
loadingAppsInProgress: boolean;
navigateToCustomApp: (id: string) => () => void;
navigateToCustomAppCreate: () => void;

View file

@ -4,13 +4,14 @@ import Form from "@saleor/components/Form";
import Grid from "@saleor/components/Grid";
import PageHeader from "@saleor/components/PageHeader";
import Savebar from "@saleor/components/Savebar";
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
import { AppErrorFragment } from "@saleor/fragments/types/AppErrorFragment";
import {
AppErrorFragment,
PermissionEnum,
PermissionFragment
} from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { sectionNames } from "@saleor/intl";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { Backlink } from "@saleor/macaw-ui";
import { PermissionEnum } from "@saleor/types/globalTypes";
import { Backlink, ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { getFormErrors } from "@saleor/utils/errors";
import getAppErrorMessage from "@saleor/utils/errors/app";
import React from "react";
@ -26,7 +27,7 @@ export interface CustomAppCreatePageFormData {
export interface CustomAppCreatePageProps {
disabled: boolean;
errors: AppErrorFragment[];
permissions: ShopInfo_shop_permissions[];
permissions: PermissionFragment[];
saveButtonBarState: ConfirmButtonTransitionState;
onBack: () => void;
onSubmit: (

View file

@ -5,13 +5,19 @@ import Form from "@saleor/components/Form";
import Grid from "@saleor/components/Grid";
import PageHeader from "@saleor/components/PageHeader";
import Savebar from "@saleor/components/Savebar";
import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo";
import { AppErrorFragment } from "@saleor/fragments/types/AppErrorFragment";
import {
AppErrorFragment,
AppUpdateMutation,
PermissionEnum,
ShopInfoQuery
} from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { sectionNames } from "@saleor/intl";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { Backlink, Button } from "@saleor/macaw-ui";
import { PermissionEnum } from "@saleor/types/globalTypes";
import {
Backlink,
Button,
ConfirmButtonTransitionState
} from "@saleor/macaw-ui";
import { getFormErrors } from "@saleor/utils/errors";
import getAppErrorMessage from "@saleor/utils/errors/app";
import WebhooksList from "@saleor/webhooks/components/WebhooksList";
@ -20,7 +26,6 @@ import { FormattedMessage, useIntl } from "react-intl";
import activateIcon from "../../../../assets/images/activate-icon.svg";
import { useStyles } from "../../styles";
import { AppUpdate_appUpdate_app } from "../../types/AppUpdate";
import CustomAppDefaultToken from "../CustomAppDefaultToken";
import CustomAppInformation from "../CustomAppInformation";
import CustomAppTokens from "../CustomAppTokens";
@ -35,9 +40,9 @@ export interface CustomAppDetailsPageProps {
apiUri: string;
disabled: boolean;
errors: AppErrorFragment[];
permissions: ShopInfo_shop_permissions[];
permissions: ShopInfoQuery["shop"]["permissions"];
saveButtonBarState: ConfirmButtonTransitionState;
app: AppUpdate_appUpdate_app;
app: AppUpdateMutation["appUpdate"]["app"];
token: string;
onApiUriClick: () => void;
onBack: () => void;

View file

@ -1,6 +1,6 @@
import { Card, CardContent, TextField } from "@material-ui/core";
import CardTitle from "@saleor/components/CardTitle";
import { AppErrorFragment } from "@saleor/fragments/types/AppErrorFragment";
import { AppErrorFragment } from "@saleor/graphql";
import { FormChange } from "@saleor/hooks/useForm";
import { getFormErrors } from "@saleor/utils/errors";
import getAppErrorMessage from "@saleor/utils/errors/app";

View file

@ -8,16 +8,16 @@ import {
import CardTitle from "@saleor/components/CardTitle";
import ResponsiveTable from "@saleor/components/ResponsiveTable";
import Skeleton from "@saleor/components/Skeleton";
import { AppUpdateMutation } from "@saleor/graphql";
import { Button, DeleteIcon, IconButton } from "@saleor/macaw-ui";
import { renderCollection } from "@saleor/misc";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { AppUpdate_appUpdate_app_tokens } from "../../types/AppUpdate";
import { useStyles } from "./styles";
export interface CustomAppTokensProps {
tokens: Array<AppUpdate_appUpdate_app_tokens | null> | null;
tokens: AppUpdateMutation["appUpdate"]["app"]["tokens"] | null;
onCreate: () => void;
onDelete: (id: string) => void;
}

View file

@ -6,21 +6,24 @@ import {
Typography
} from "@material-ui/core";
import CardTitle from "@saleor/components/CardTitle";
import { AppsListQuery } from "@saleor/graphql";
import { commonMessages } from "@saleor/intl";
import { DeleteIcon, ResponsiveTable } from "@saleor/macaw-ui";
import { Button, IconButton } from "@saleor/macaw-ui";
import {
Button,
DeleteIcon,
IconButton,
ResponsiveTable
} from "@saleor/macaw-ui";
import { renderCollection, stopPropagation } from "@saleor/misc";
import React from "react";
import { useIntl } from "react-intl";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { useStyles } from "../../styles";
import { AppsList_apps_edges } from "../../types/AppsList";
import AppsSkeleton from "../AppsSkeleton";
import DeactivatedText from "../DeactivatedText";
export interface CustomAppsProps {
appsList: AppsList_apps_edges[];
appsList: AppsListQuery["apps"]["edges"];
navigateToCustomApp: (id: string) => () => void;
navigateToCustomAppCreate?: () => void;
onRemove: (id: string) => void;

View file

@ -1,6 +1,6 @@
import { appDeepUrl } from "@saleor/apps/urls";
import { AppExtensionTargetEnum } from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import { AppExtensionTargetEnum } from "@saleor/types/globalTypes";
import React from "react";
import { AppDialog } from "../AppDialog";

View file

@ -8,20 +8,24 @@ import {
} from "@material-ui/core";
import CardTitle from "@saleor/components/CardTitle";
import TablePagination from "@saleor/components/TablePagination";
import { DeleteIcon, ResponsiveTable } from "@saleor/macaw-ui";
import { Button, IconButton } from "@saleor/macaw-ui";
import { AppsListQuery } from "@saleor/graphql";
import {
Button,
DeleteIcon,
IconButton,
ResponsiveTable
} from "@saleor/macaw-ui";
import { renderCollection, stopPropagation } from "@saleor/misc";
import { ListProps } from "@saleor/types";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { useStyles } from "../../styles";
import { AppsList_apps_edges } from "../../types/AppsList";
import AppsSkeleton from "../AppsSkeleton";
import DeactivatedText from "../DeactivatedText";
export interface InstalledAppsProps extends ListProps {
appsList: AppsList_apps_edges[];
appsList: AppsListQuery["apps"]["edges"];
onRemove: (id: string) => void;
onRowAboutClick: (id: string) => () => void;
}

View file

@ -1,14 +1,14 @@
import {
AppFetchMutation,
AppQuery,
AppsInstallationsQuery,
AppsListQuery,
AppTypeEnum,
JobStatusEnum,
PermissionEnum
} from "../types/globalTypes";
import { App_app } from "./types/App";
import { AppFetch_appFetchManifest_manifest } from "./types/AppFetch";
import { AppsInstallations_appsInstallations } from "./types/AppsInstallations";
import { AppsList_apps_edges } from "./types/AppsList";
} from "@saleor/graphql";
export const appsList: AppsList_apps_edges[] = [
export const appsList: AppsListQuery["apps"]["edges"] = [
{
__typename: "AppCountableEdge",
node: {
@ -31,7 +31,7 @@ export const appsList: AppsList_apps_edges[] = [
}
];
export const customAppsList: AppsList_apps_edges[] = [
export const customAppsList: AppsListQuery["apps"]["edges"] = [
{
__typename: "AppCountableEdge",
node: {
@ -44,7 +44,7 @@ export const customAppsList: AppsList_apps_edges[] = [
}
];
export const appsInProgress: AppsInstallations_appsInstallations[] = [
export const appsInProgress: AppsInstallationsQuery["appsInstallations"] = [
{
__typename: "AppInstallation",
appName: "app",
@ -71,7 +71,7 @@ export const appsInProgress: AppsInstallations_appsInstallations[] = [
}
];
export const appDetails: App_app = {
export const appDetails: AppQuery["app"] = {
__typename: "App",
aboutApp: "Lorem ipsum",
accessToken: "token",
@ -105,9 +105,8 @@ export const appDetails: App_app = {
webhooks: []
};
export const installApp: AppFetch_appFetchManifest_manifest = {
export const installApp: AppFetchMutation["appFetchManifest"]["manifest"] = {
__typename: "Manifest",
about: "Lorem ipsum",
appUrl: null,
configurationUrl: null,

View file

@ -1,68 +1,33 @@
import { gql } from "@apollo/client";
import { appFragment } from "@saleor/fragments/apps";
import { appErrorFragment } from "@saleor/fragments/errors";
import { webhooksFragment } from "@saleor/fragments/webhooks";
import makeMutation from "@saleor/hooks/makeMutation";
import { AppActivate, AppActivateVariables } from "./types/AppActivate";
import { AppCreate, AppCreateVariables } from "./types/AppCreate";
import { AppDeactivate, AppDeactivateVariables } from "./types/AppDeactivate";
import { AppDelete, AppDeleteVariables } from "./types/AppDelete";
import {
AppDeleteFailedInstallation,
AppDeleteFailedInstallationVariables
} from "./types/AppDeleteFailedInstallation";
import { AppFetch, AppFetchVariables } from "./types/AppFetch";
import { AppInstall, AppInstallVariables } from "./types/AppInstall";
import {
AppRetryInstall,
AppRetryInstallVariables
} from "./types/AppRetryInstall";
import {
AppTokenCreate,
AppTokenCreateVariables
} from "./types/AppTokenCreate";
import {
AppTokenDelete,
AppTokenDeleteVariables
} from "./types/AppTokenDelete";
import { AppUpdate, AppUpdateVariables } from "./types/AppUpdate";
export const appCreateMutation = gql`
${appFragment}
${webhooksFragment}
${appErrorFragment}
mutation AppCreate($input: AppInput!) {
appCreate(input: $input) {
authToken
app {
...AppFragment
...App
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appDeleteMutation = gql`
${appFragment}
${webhooksFragment}
${appErrorFragment}
mutation AppDelete($id: ID!) {
appDelete(id: $id) {
app {
...AppFragment
...App
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appDeleteFailedInstallationMutation = gql`
${appErrorFragment}
mutation AppDeleteFailedInstallation($id: ID!) {
appDeleteFailedInstallation(id: $id) {
appInstallation {
@ -72,14 +37,13 @@ export const appDeleteFailedInstallationMutation = gql`
message
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appFetchMutation = gql`
${appErrorFragment}
mutation AppFetch($manifestUrl: String!) {
appFetchManifest(manifestUrl: $manifestUrl) {
manifest {
@ -100,14 +64,13 @@ export const appFetchMutation = gql`
}
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appInstallMutation = gql`
${appErrorFragment}
mutation AppInstall($input: AppInstallInput!) {
appInstall(input: $input) {
appInstallation {
@ -117,14 +80,13 @@ export const appInstallMutation = gql`
manifestUrl
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appRetryInstallMutation = gql`
${appErrorFragment}
mutation AppRetryInstall($id: ID!) {
appRetryInstall(id: $id) {
appInstallation {
@ -134,27 +96,24 @@ export const appRetryInstallMutation = gql`
manifestUrl
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appUpdateMutation = gql`
${appErrorFragment}
${appFragment}
${webhooksFragment}
mutation AppUpdate($id: ID!, $input: AppInput!) {
appUpdate(id: $id, input: $input) {
app {
...AppFragment
...App
permissions {
code
name
}
}
errors {
...AppErrorFragment
...AppError
message
permissions
}
@ -163,7 +122,6 @@ export const appUpdateMutation = gql`
`;
export const appTokenCreateMutation = gql`
${appErrorFragment}
mutation AppTokenCreate($input: AppTokenInput!) {
appTokenCreate(input: $input) {
appToken {
@ -173,14 +131,13 @@ export const appTokenCreateMutation = gql`
}
authToken
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appTokenDeleteMutation = gql`
${appErrorFragment}
mutation AppTokenDelete($id: ID!) {
appTokenDelete(id: $id) {
appToken {
@ -189,82 +146,28 @@ export const appTokenDeleteMutation = gql`
id
}
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appActivateMutation = gql`
${appErrorFragment}
mutation AppActivate($id: ID!) {
appActivate(id: $id) {
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const appDeactivateMutation = gql`
${appErrorFragment}
mutation AppDeactivate($id: ID!) {
appDeactivate(id: $id) {
errors {
...AppErrorFragment
...AppError
}
}
}
`;
export const useAppCreateMutation = makeMutation<AppCreate, AppCreateVariables>(
appCreateMutation
);
export const useAppDeleteMutation = makeMutation<AppDelete, AppDeleteVariables>(
appDeleteMutation
);
export const useAppDeleteFailedInstallationMutation = makeMutation<
AppDeleteFailedInstallation,
AppDeleteFailedInstallationVariables
>(appDeleteFailedInstallationMutation);
export const useAppInstallMutation = makeMutation<
AppInstall,
AppInstallVariables
>(appInstallMutation);
export const useAppRetryInstallMutation = makeMutation<
AppRetryInstall,
AppRetryInstallVariables
>(appRetryInstallMutation);
export const useAppManifestFetchMutation = makeMutation<
AppFetch,
AppFetchVariables
>(appFetchMutation);
export const useAppActivateMutation = makeMutation<
AppActivate,
AppActivateVariables
>(appActivateMutation);
export const useAppDeactivateMutation = makeMutation<
AppDeactivate,
AppDeactivateVariables
>(appDeactivateMutation);
export const useAppUpdateMutation = makeMutation<AppUpdate, AppUpdateVariables>(
appUpdateMutation
);
export const useAppTokenCreateMutation = makeMutation<
AppTokenCreate,
AppTokenCreateVariables
>(appTokenCreateMutation);
export const useAppTokenDeleteMutation = makeMutation<
AppTokenDelete,
AppTokenDeleteVariables
>(appTokenDeleteMutation);

View file

@ -1,14 +1,6 @@
import { gql } from "@apollo/client";
import { appFragment } from "@saleor/fragments/apps";
import { webhooksFragment } from "@saleor/fragments/webhooks";
import makeQuery from "@saleor/hooks/makeQuery";
import { App, AppVariables } from "./types/App";
import { AppsInstallations } from "./types/AppsInstallations";
import { AppsList, AppsListVariables } from "./types/AppsList";
import { ExtensionList, ExtensionListVariables } from "./types/ExtensionList";
const appsList = gql`
export const appsList = gql`
query AppsList(
$before: String
$after: String
@ -44,7 +36,7 @@ const appsList = gql`
}
`;
const appsInProgressList = gql`
export const appsInProgressList = gql`
query AppsInstallations {
appsInstallations {
status
@ -56,12 +48,10 @@ const appsInProgressList = gql`
}
`;
const appDetails = gql`
${appFragment}
${webhooksFragment}
export const appDetails = gql`
query App($id: ID!) {
app(id: $id) {
...AppFragment
...App
aboutApp
permissions {
code
@ -96,18 +86,3 @@ export const extensionList = gql`
}
}
`;
export const useAppsListQuery = makeQuery<AppsList, AppsListVariables>(
appsList
);
export const useAppsInProgressListQuery = makeQuery<AppsInstallations, {}>(
appsInProgressList
);
export const useAppDetails = makeQuery<App, AppVariables>(appDetails);
export const useExtensionList = makeQuery<
ExtensionList,
ExtensionListVariables
>(extensionList);

View file

@ -1,80 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppTypeEnum, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: App
// ====================================================
export interface App_app_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface App_app_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface App_app_tokens {
__typename: "AppToken";
authToken: string | null;
id: string;
name: string | null;
}
export interface App_app_webhooks_app {
__typename: "App";
id: string;
name: string | null;
}
export interface App_app_webhooks {
__typename: "Webhook";
id: string;
name: string;
isActive: boolean;
app: App_app_webhooks_app;
}
export interface App_app_permissions {
__typename: "Permission";
code: PermissionEnum;
name: string;
}
export interface App_app {
__typename: "App";
id: string;
name: string | null;
created: any | null;
isActive: boolean | null;
type: AppTypeEnum | null;
homepageUrl: string | null;
appUrl: string | null;
configurationUrl: string | null;
supportUrl: string | null;
version: string | null;
accessToken: string | null;
privateMetadata: (App_app_privateMetadata | null)[];
metadata: (App_app_metadata | null)[];
tokens: (App_app_tokens | null)[] | null;
webhooks: (App_app_webhooks | null)[] | null;
aboutApp: string | null;
permissions: (App_app_permissions | null)[] | null;
dataPrivacy: string | null;
dataPrivacyUrl: string | null;
}
export interface App {
app: App_app | null;
}
export interface AppVariables {
id: string;
}

View file

@ -1,31 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppActivate
// ====================================================
export interface AppActivate_appActivate_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppActivate_appActivate {
__typename: "AppActivate";
errors: AppActivate_appActivate_errors[];
}
export interface AppActivate {
appActivate: AppActivate_appActivate | null;
}
export interface AppActivateVariables {
id: string;
}

View file

@ -1,85 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppInput, AppTypeEnum, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppCreate
// ====================================================
export interface AppCreate_appCreate_app_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppCreate_appCreate_app_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppCreate_appCreate_app_tokens {
__typename: "AppToken";
authToken: string | null;
id: string;
name: string | null;
}
export interface AppCreate_appCreate_app_webhooks_app {
__typename: "App";
id: string;
name: string | null;
}
export interface AppCreate_appCreate_app_webhooks {
__typename: "Webhook";
id: string;
name: string;
isActive: boolean;
app: AppCreate_appCreate_app_webhooks_app;
}
export interface AppCreate_appCreate_app {
__typename: "App";
id: string;
name: string | null;
created: any | null;
isActive: boolean | null;
type: AppTypeEnum | null;
homepageUrl: string | null;
appUrl: string | null;
configurationUrl: string | null;
supportUrl: string | null;
version: string | null;
accessToken: string | null;
privateMetadata: (AppCreate_appCreate_app_privateMetadata | null)[];
metadata: (AppCreate_appCreate_app_metadata | null)[];
tokens: (AppCreate_appCreate_app_tokens | null)[] | null;
webhooks: (AppCreate_appCreate_app_webhooks | null)[] | null;
}
export interface AppCreate_appCreate_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppCreate_appCreate {
__typename: "AppCreate";
authToken: string | null;
app: AppCreate_appCreate_app | null;
errors: AppCreate_appCreate_errors[];
}
export interface AppCreate {
appCreate: AppCreate_appCreate | null;
}
export interface AppCreateVariables {
input: AppInput;
}

View file

@ -1,31 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppDeactivate
// ====================================================
export interface AppDeactivate_appDeactivate_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppDeactivate_appDeactivate {
__typename: "AppDeactivate";
errors: AppDeactivate_appDeactivate_errors[];
}
export interface AppDeactivate {
appDeactivate: AppDeactivate_appDeactivate | null;
}
export interface AppDeactivateVariables {
id: string;
}

View file

@ -1,84 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppTypeEnum, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppDelete
// ====================================================
export interface AppDelete_appDelete_app_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppDelete_appDelete_app_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppDelete_appDelete_app_tokens {
__typename: "AppToken";
authToken: string | null;
id: string;
name: string | null;
}
export interface AppDelete_appDelete_app_webhooks_app {
__typename: "App";
id: string;
name: string | null;
}
export interface AppDelete_appDelete_app_webhooks {
__typename: "Webhook";
id: string;
name: string;
isActive: boolean;
app: AppDelete_appDelete_app_webhooks_app;
}
export interface AppDelete_appDelete_app {
__typename: "App";
id: string;
name: string | null;
created: any | null;
isActive: boolean | null;
type: AppTypeEnum | null;
homepageUrl: string | null;
appUrl: string | null;
configurationUrl: string | null;
supportUrl: string | null;
version: string | null;
accessToken: string | null;
privateMetadata: (AppDelete_appDelete_app_privateMetadata | null)[];
metadata: (AppDelete_appDelete_app_metadata | null)[];
tokens: (AppDelete_appDelete_app_tokens | null)[] | null;
webhooks: (AppDelete_appDelete_app_webhooks | null)[] | null;
}
export interface AppDelete_appDelete_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppDelete_appDelete {
__typename: "AppDelete";
app: AppDelete_appDelete_app | null;
errors: AppDelete_appDelete_errors[];
}
export interface AppDelete {
appDelete: AppDelete_appDelete | null;
}
export interface AppDeleteVariables {
id: string;
}

View file

@ -1,40 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { JobStatusEnum, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppDeleteFailedInstallation
// ====================================================
export interface AppDeleteFailedInstallation_appDeleteFailedInstallation_appInstallation {
__typename: "AppInstallation";
id: string;
status: JobStatusEnum;
appName: string;
message: string | null;
}
export interface AppDeleteFailedInstallation_appDeleteFailedInstallation_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppDeleteFailedInstallation_appDeleteFailedInstallation {
__typename: "AppDeleteFailedInstallation";
appInstallation: AppDeleteFailedInstallation_appDeleteFailedInstallation_appInstallation | null;
errors: AppDeleteFailedInstallation_appDeleteFailedInstallation_errors[];
}
export interface AppDeleteFailedInstallation {
appDeleteFailedInstallation: AppDeleteFailedInstallation_appDeleteFailedInstallation | null;
}
export interface AppDeleteFailedInstallationVariables {
id: string;
}

View file

@ -1,54 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { PermissionEnum, AppErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppFetch
// ====================================================
export interface AppFetch_appFetchManifest_manifest_permissions {
__typename: "Permission";
code: PermissionEnum;
name: string;
}
export interface AppFetch_appFetchManifest_manifest {
__typename: "Manifest";
identifier: string;
version: string;
about: string | null;
name: string;
appUrl: string | null;
configurationUrl: string | null;
tokenTargetUrl: string | null;
dataPrivacy: string | null;
dataPrivacyUrl: string | null;
homepageUrl: string | null;
supportUrl: string | null;
permissions: (AppFetch_appFetchManifest_manifest_permissions | null)[] | null;
}
export interface AppFetch_appFetchManifest_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppFetch_appFetchManifest {
__typename: "AppFetchManifest";
manifest: AppFetch_appFetchManifest_manifest | null;
errors: AppFetch_appFetchManifest_errors[];
}
export interface AppFetch {
appFetchManifest: AppFetch_appFetchManifest | null;
}
export interface AppFetchVariables {
manifestUrl: string;
}

View file

@ -1,40 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppInstallInput, JobStatusEnum, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppInstall
// ====================================================
export interface AppInstall_appInstall_appInstallation {
__typename: "AppInstallation";
id: string;
status: JobStatusEnum;
appName: string;
manifestUrl: string;
}
export interface AppInstall_appInstall_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppInstall_appInstall {
__typename: "AppInstall";
appInstallation: AppInstall_appInstall_appInstallation | null;
errors: AppInstall_appInstall_errors[];
}
export interface AppInstall {
appInstall: AppInstall_appInstall | null;
}
export interface AppInstallVariables {
input: AppInstallInput;
}

View file

@ -1,40 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { JobStatusEnum, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppRetryInstall
// ====================================================
export interface AppRetryInstall_appRetryInstall_appInstallation {
__typename: "AppInstallation";
id: string;
status: JobStatusEnum;
appName: string;
manifestUrl: string;
}
export interface AppRetryInstall_appRetryInstall_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppRetryInstall_appRetryInstall {
__typename: "AppRetryInstall";
appInstallation: AppRetryInstall_appRetryInstall_appInstallation | null;
errors: AppRetryInstall_appRetryInstall_errors[];
}
export interface AppRetryInstall {
appRetryInstall: AppRetryInstall_appRetryInstall | null;
}
export interface AppRetryInstallVariables {
id: string;
}

View file

@ -1,40 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppTokenInput, AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppTokenCreate
// ====================================================
export interface AppTokenCreate_appTokenCreate_appToken {
__typename: "AppToken";
name: string | null;
authToken: string | null;
id: string;
}
export interface AppTokenCreate_appTokenCreate_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppTokenCreate_appTokenCreate {
__typename: "AppTokenCreate";
appToken: AppTokenCreate_appTokenCreate_appToken | null;
authToken: string | null;
errors: AppTokenCreate_appTokenCreate_errors[];
}
export interface AppTokenCreate {
appTokenCreate: AppTokenCreate_appTokenCreate | null;
}
export interface AppTokenCreateVariables {
input: AppTokenInput;
}

View file

@ -1,39 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppErrorCode, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppTokenDelete
// ====================================================
export interface AppTokenDelete_appTokenDelete_appToken {
__typename: "AppToken";
name: string | null;
authToken: string | null;
id: string;
}
export interface AppTokenDelete_appTokenDelete_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppTokenDelete_appTokenDelete {
__typename: "AppTokenDelete";
appToken: AppTokenDelete_appTokenDelete_appToken | null;
errors: AppTokenDelete_appTokenDelete_errors[];
}
export interface AppTokenDelete {
appTokenDelete: AppTokenDelete_appTokenDelete | null;
}
export interface AppTokenDeleteVariables {
id: string;
}

View file

@ -1,92 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppInput, AppTypeEnum, PermissionEnum, AppErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AppUpdate
// ====================================================
export interface AppUpdate_appUpdate_app_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppUpdate_appUpdate_app_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AppUpdate_appUpdate_app_tokens {
__typename: "AppToken";
authToken: string | null;
id: string;
name: string | null;
}
export interface AppUpdate_appUpdate_app_webhooks_app {
__typename: "App";
id: string;
name: string | null;
}
export interface AppUpdate_appUpdate_app_webhooks {
__typename: "Webhook";
id: string;
name: string;
isActive: boolean;
app: AppUpdate_appUpdate_app_webhooks_app;
}
export interface AppUpdate_appUpdate_app_permissions {
__typename: "Permission";
code: PermissionEnum;
name: string;
}
export interface AppUpdate_appUpdate_app {
__typename: "App";
id: string;
name: string | null;
created: any | null;
isActive: boolean | null;
type: AppTypeEnum | null;
homepageUrl: string | null;
appUrl: string | null;
configurationUrl: string | null;
supportUrl: string | null;
version: string | null;
accessToken: string | null;
privateMetadata: (AppUpdate_appUpdate_app_privateMetadata | null)[];
metadata: (AppUpdate_appUpdate_app_metadata | null)[];
tokens: (AppUpdate_appUpdate_app_tokens | null)[] | null;
webhooks: (AppUpdate_appUpdate_app_webhooks | null)[] | null;
permissions: (AppUpdate_appUpdate_app_permissions | null)[] | null;
}
export interface AppUpdate_appUpdate_errors {
__typename: "AppError";
field: string | null;
message: string | null;
code: AppErrorCode;
permissions: PermissionEnum[] | null;
}
export interface AppUpdate_appUpdate {
__typename: "AppUpdate";
app: AppUpdate_appUpdate_app | null;
errors: AppUpdate_appUpdate_errors[];
}
export interface AppUpdate {
appUpdate: AppUpdate_appUpdate | null;
}
export interface AppUpdateVariables {
id: string;
input: AppInput;
}

View file

@ -1,23 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { JobStatusEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: AppsInstallations
// ====================================================
export interface AppsInstallations_appsInstallations {
__typename: "AppInstallation";
status: JobStatusEnum;
message: string | null;
appName: string;
manifestUrl: string;
id: string;
}
export interface AppsInstallations {
appsInstallations: AppsInstallations_appsInstallations[];
}

View file

@ -1,51 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppSortingInput, AppFilterInput, AppTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: AppsList
// ====================================================
export interface AppsList_apps_pageInfo {
__typename: "PageInfo";
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
endCursor: string | null;
}
export interface AppsList_apps_edges_node {
__typename: "App";
id: string;
name: string | null;
isActive: boolean | null;
type: AppTypeEnum | null;
}
export interface AppsList_apps_edges {
__typename: "AppCountableEdge";
node: AppsList_apps_edges_node;
}
export interface AppsList_apps {
__typename: "AppCountableConnection";
pageInfo: AppsList_apps_pageInfo;
totalCount: number | null;
edges: AppsList_apps_edges[];
}
export interface AppsList {
apps: AppsList_apps | null;
}
export interface AppsListVariables {
before?: string | null;
after?: string | null;
first?: number | null;
last?: number | null;
sort?: AppSortingInput | null;
filter?: AppFilterInput | null;
}

View file

@ -1,51 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AppExtensionFilterInput, AppExtensionMountEnum, AppExtensionTargetEnum, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: ExtensionList
// ====================================================
export interface ExtensionList_appExtensions_edges_node_permissions {
__typename: "Permission";
code: PermissionEnum;
}
export interface ExtensionList_appExtensions_edges_node_app {
__typename: "App";
id: string;
appUrl: string | null;
}
export interface ExtensionList_appExtensions_edges_node {
__typename: "AppExtension";
id: string;
label: string;
url: string;
mount: AppExtensionMountEnum;
target: AppExtensionTargetEnum;
accessToken: string | null;
permissions: ExtensionList_appExtensions_edges_node_permissions[];
app: ExtensionList_appExtensions_edges_node_app;
}
export interface ExtensionList_appExtensions_edges {
__typename: "AppExtensionCountableEdge";
node: ExtensionList_appExtensions_edges_node;
}
export interface ExtensionList_appExtensions {
__typename: "AppExtensionCountableConnection";
edges: ExtensionList_appExtensions_edges[];
}
export interface ExtensionList {
appExtensions: ExtensionList_appExtensions | null;
}
export interface ExtensionListVariables {
filter: AppExtensionFilterInput;
}

View file

@ -1,19 +1,17 @@
import {
AppExtensionMountEnum,
PermissionEnum
} from "@saleor/types/globalTypes";
ExtensionListQuery,
PermissionEnum,
useExtensionListQuery
} from "@saleor/graphql";
import { RelayToFlat } from "@saleor/types";
import { mapEdgesToItems } from "@saleor/utils/maps";
import { AppData, useExternalApp } from "./components/ExternalAppContext";
import { useExtensionList } from "./queries";
import {
ExtensionList_appExtensions_edges_node,
ExtensionList_appExtensions_edges_node_app
} from "./types/ExtensionList";
export interface Extension {
id: string;
app: ExtensionList_appExtensions_edges_node_app;
app: RelayToFlat<ExtensionListQuery["appExtensions"]>[0]["app"];
accessToken: string;
permissions: PermissionEnum[];
label: string;
@ -38,7 +36,7 @@ export const extensionMountPoints = {
};
const filterAndMapToTarget = (
extensions: ExtensionList_appExtensions_edges_node[],
extensions: RelayToFlat<ExtensionListQuery["appExtensions"]>,
openApp: (appData: AppData) => void
): Extension[] =>
extensions.map(
@ -67,7 +65,7 @@ export const useExtensions = <T extends AppExtensionMountEnum>(
): Record<T, Extension[]> => {
const { openApp } = useExternalApp();
const { data } = useExtensionList({
const { data } = useExtensionListQuery({
fetchPolicy: "cache-first",
variables: {
filter: {

View file

@ -1,5 +1,6 @@
import { appMessages } from "@saleor/apps/messages";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { useAppQuery } from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import React from "react";
@ -7,7 +8,6 @@ import { useIntl } from "react-intl";
import { useLocation } from "react-router";
import AppPage from "../../components/AppPage";
import { useAppDetails } from "../../queries";
import {
appDetailsUrl,
appsListPath,
@ -20,7 +20,7 @@ interface AppProps {
export const App: React.FC<AppProps> = ({ id }) => {
const location = useLocation();
const { data } = useAppDetails({
const { data } = useAppQuery({
displayLoader: true,
variables: { id }
});

View file

@ -1,5 +1,10 @@
import { appMessages } from "@saleor/apps/messages";
import NotFoundPage from "@saleor/components/NotFoundPage";
import {
useAppActivateMutation,
useAppDeactivateMutation,
useAppQuery
} from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import getAppErrorMessage from "@saleor/utils/errors/app";
@ -10,11 +15,6 @@ import { useIntl } from "react-intl";
import AppActivateDialog from "../../components/AppActivateDialog";
import AppDeactivateDialog from "../../components/AppDeactivateDialog";
import AppDetailsPage from "../../components/AppDetailsPage";
import {
useAppActivateMutation,
useAppDeactivateMutation
} from "../../mutations";
import { useAppDetails } from "../../queries";
import {
AppDetailsUrlDialog,
AppDetailsUrlQueryParams,
@ -29,7 +29,7 @@ interface AppDetailsProps {
}
export const AppDetails: React.FC<AppDetailsProps> = ({ id, params }) => {
const { data, loading, refetch } = useAppDetails({
const { data, loading, refetch } = useAppQuery({
displayLoader: true,
variables: { id }
});

View file

@ -1,4 +1,5 @@
import { WindowTitle } from "@saleor/components/WindowTitle";
import { useAppFetchMutation, useAppInstallMutation } from "@saleor/graphql";
import useLocalStorage from "@saleor/hooks/useLocalStorage";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
@ -10,10 +11,6 @@ import { RouteComponentProps } from "react-router-dom";
import AppInstallErrorPage from "../../components/AppInstallErrorPage";
import AppInstallPage from "../../components/AppInstallPage";
import {
useAppInstallMutation,
useAppManifestFetchMutation
} from "../../mutations";
import {
AppInstallUrlQueryParams,
appsListUrl,
@ -33,7 +30,7 @@ export const InstallAppCreate: React.FC<InstallAppCreateProps> = ({
const intl = useIntl();
const manifestUrl = params[MANIFEST_ATTR];
const [fetchManifest, fetchManifestOpts] = useAppManifestFetchMutation({
const [fetchManifest, fetchManifestOpts] = useAppFetchMutation({
onCompleted: data => {
if (data.appFetchManifest.errors.length) {
data.appFetchManifest.errors.forEach(error => {

View file

@ -1,12 +1,12 @@
import { appMessages } from "@saleor/apps/messages";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { useAppQuery } from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import React from "react";
import { useIntl } from "react-intl";
import AppPage from "../../components/AppPage";
import { useAppDetails } from "../../queries";
import { appDetailsUrl, appsListPath } from "../../urls";
interface AppSettingsProps {
@ -14,7 +14,7 @@ interface AppSettingsProps {
}
export const AppSettings: React.FC<AppSettingsProps> = ({ id }) => {
const { data } = useAppDetails({
const { data } = useAppQuery({
displayLoader: true,
variables: { id }
});

View file

@ -1,3 +1,18 @@
import {
AppDeleteFailedInstallationMutation,
AppDeleteMutation,
AppsInstallationsQuery,
AppsListQuery,
AppSortField,
AppTypeEnum,
JobStatusEnum,
OrderDirection,
useAppDeleteFailedInstallationMutation,
useAppDeleteMutation,
useAppRetryInstallMutation,
useAppsInstallationsQuery,
useAppsListQuery
} from "@saleor/graphql";
import useListSettings from "@saleor/hooks/useListSettings";
import useLocalStorage from "@saleor/hooks/useLocalStorage";
import useNavigator from "@saleor/hooks/useNavigator";
@ -11,25 +26,9 @@ import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandl
import React, { useEffect, useRef } from "react";
import { useIntl } from "react-intl";
import {
AppSortField,
AppTypeEnum,
JobStatusEnum,
OrderDirection
} from "../../../types/globalTypes";
import AppDeleteDialog from "../../components/AppDeleteDialog";
import AppInProgressDeleteDialog from "../../components/AppInProgressDeleteDialog";
import AppsListPage from "../../components/AppsListPage";
import {
useAppDeleteFailedInstallationMutation,
useAppDeleteMutation,
useAppRetryInstallMutation
} from "../../mutations";
import { useAppsInProgressListQuery, useAppsListQuery } from "../../queries";
import { AppDelete } from "../../types/AppDelete";
import { AppDeleteFailedInstallation } from "../../types/AppDeleteFailedInstallation";
import { AppsInstallations_appsInstallations } from "../../types/AppsInstallations";
import { AppsList_apps_edges } from "../../types/AppsList";
import {
appDetailsUrl,
AppListUrlDialog,
@ -41,12 +40,14 @@ import {
} from "../../urls";
import { messages } from "./messages";
const getCurrentAppName = (id: string, collection?: AppsList_apps_edges[]) =>
collection?.find(edge => edge.node.id === id)?.node?.name;
const getCurrentAppName = (
id: string,
collection?: AppsListQuery["apps"]["edges"]
) => collection?.find(edge => edge.node.id === id)?.node?.name;
const getAppInProgressName = (
id: string,
collection?: AppsInstallations_appsInstallations[]
collection?: AppsInstallationsQuery["appsInstallations"]
) => collection?.find(app => app.id === id)?.appName;
interface AppsListProps {
params: AppListUrlQueryParams;
@ -80,7 +81,7 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
data: appsInProgressData,
loading: loadingAppsInProgress,
refetch: appsInProgressRefetch
} = useAppsInProgressListQuery({
} = useAppsInstallationsQuery({
displayLoader: false
});
const { data, loading, refetch } = useAppsListQuery({
@ -143,7 +144,7 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
AppListUrlQueryParams
>(navigate, appsListUrl, params);
const onAppRemove = (data: AppDelete) => {
const onAppRemove = (data: AppDeleteMutation) => {
const errors = data.appDelete.errors;
if (errors.length === 0) {
if (data.appDelete.app.type === AppTypeEnum.LOCAL) {
@ -242,7 +243,7 @@ export const AppsList: React.FC<AppsListProps> = ({ params }) => {
});
};
const onAppInProgressRemove = (data: AppDeleteFailedInstallation) => {
const onAppInProgressRemove = (data: AppDeleteFailedInstallationMutation) => {
const errors = data.appDeleteFailedInstallation.errors;
if (errors.length === 0) {
removeAppNotify();

View file

@ -1,4 +1,5 @@
import { WindowTitle } from "@saleor/components/WindowTitle";
import { AppCreateMutation, useAppCreateMutation } from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import useShop from "@saleor/hooks/useShop";
@ -10,8 +11,6 @@ import { useIntl } from "react-intl";
import CustomAppCreatePage, {
CustomAppCreatePageFormData
} from "../../components/CustomAppCreatePage";
import { useAppCreateMutation } from "../../mutations";
import { AppCreate } from "../../types/AppCreate";
import { appsListUrl, customAppUrl } from "../../urls";
import { messages } from "./messages";
@ -26,7 +25,7 @@ export const CustomAppCreate: React.FC<CustomAppCreateProps> = ({
const intl = useIntl();
const shop = useShop();
const onSubmit = (data: AppCreate) => {
const onSubmit = (data: AppCreateMutation) => {
if (data.appCreate.errors.length === 0) {
notify({
status: "success",

View file

@ -6,6 +6,19 @@ import { appMessages } from "@saleor/apps/messages";
import NotFoundPage from "@saleor/components/NotFoundPage";
import { WindowTitle } from "@saleor/components/WindowTitle";
import { API_URI } from "@saleor/config";
import {
AppTokenCreateMutation,
AppTokenDeleteMutation,
AppUpdateMutation,
useAppActivateMutation,
useAppDeactivateMutation,
useAppQuery,
useAppTokenCreateMutation,
useAppTokenDeleteMutation,
useAppUpdateMutation,
useWebhookDeleteMutation,
WebhookDeleteMutation
} from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import useShop from "@saleor/hooks/useShop";
@ -14,8 +27,6 @@ import { extractMutationErrors, getStringOrPlaceholder } from "@saleor/misc";
import getAppErrorMessage from "@saleor/utils/errors/app";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
import WebhookDeleteDialog from "@saleor/webhooks/components/WebhookDeleteDialog";
import { useWebhookDeleteMutation } from "@saleor/webhooks/mutations";
import { WebhookDelete } from "@saleor/webhooks/types/WebhookDelete";
import { webhookAddPath, webhookPath } from "@saleor/webhooks/urls";
import React from "react";
import { useIntl } from "react-intl";
@ -23,17 +34,6 @@ import { useIntl } from "react-intl";
import CustomAppDetailsPage, {
CustomAppDetailsPageFormData
} from "../../components/CustomAppDetailsPage";
import {
useAppActivateMutation,
useAppDeactivateMutation,
useAppTokenCreateMutation,
useAppTokenDeleteMutation,
useAppUpdateMutation
} from "../../mutations";
import { useAppDetails } from "../../queries";
import { AppTokenCreate } from "../../types/AppTokenCreate";
import { AppTokenDelete } from "../../types/AppTokenDelete";
import { AppUpdate } from "../../types/AppUpdate";
import {
appsListUrl,
customAppUrl,
@ -66,7 +66,7 @@ export const CustomAppDetails: React.FC<OrderListProps> = ({
CustomAppUrlQueryParams
>(navigate, params => customAppUrl(id, params), params);
const { data, loading, refetch } = useAppDetails({
const { data, loading, refetch } = useAppQuery({
displayLoader: true,
variables: { id }
});
@ -111,7 +111,7 @@ export const CustomAppDetails: React.FC<OrderListProps> = ({
}
});
const onWebhookDelete = (data: WebhookDelete) => {
const onWebhookDelete = (data: WebhookDeleteMutation) => {
if (data.webhookDelete.errors.length === 0) {
notify({
status: "success",
@ -135,7 +135,7 @@ export const CustomAppDetails: React.FC<OrderListProps> = ({
});
};
const onAppUpdate = (data: AppUpdate) => {
const onAppUpdate = (data: AppUpdateMutation) => {
if (data?.appUpdate?.errors?.length === 0) {
notify({
status: "success",
@ -150,12 +150,12 @@ export const CustomAppDetails: React.FC<OrderListProps> = ({
return <NotFoundPage onBack={handleBack} />;
}
const onTokenCreate = (data: AppTokenCreate) => {
const onTokenCreate = (data: AppTokenCreateMutation) => {
if (data?.appTokenCreate?.errors.length === 0) {
refetch();
}
};
const onTokenDelete = (data: AppTokenDelete) => {
const onTokenDelete = (data: AppTokenDeleteMutation) => {
if (data?.appTokenDelete?.errors.length === 0) {
notify({
status: "success",

View file

@ -4,14 +4,14 @@ import CardTitle from "@saleor/components/CardTitle";
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
import FormSpacer from "@saleor/components/FormSpacer";
import SingleSelectField from "@saleor/components/SingleSelectField";
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import {
AttributeEntityTypeEnum,
AttributeErrorFragment,
AttributeInputTypeEnum
} from "@saleor/graphql";
import { UseFormResult } from "@saleor/hooks/useForm";
import { commonMessages } from "@saleor/intl";
import { makeStyles } from "@saleor/macaw-ui";
import {
AttributeEntityTypeEnum,
AttributeInputTypeEnum
} from "@saleor/types/globalTypes";
import { getFormErrors } from "@saleor/utils/errors";
import getAttributeErrorMessage from "@saleor/utils/errors/attribute";
import React from "react";

View file

@ -1,10 +1,10 @@
import { AttributePageFormData } from "@saleor/attributes/components/AttributePage";
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
import SingleSelectField from "@saleor/components/SingleSelectField";
import { MeasurementUnitsEnum } from "@saleor/graphql";
import { UseFormResult } from "@saleor/hooks/useForm";
import { commonMessages } from "@saleor/intl";
import { makeStyles } from "@saleor/macaw-ui";
import { MeasurementUnitsEnum } from "@saleor/types/globalTypes";
import React, { useEffect, useMemo, useState } from "react";
import { useIntl } from "react-intl";

View file

@ -1,5 +1,5 @@
import { Choice } from "@saleor/components/SingleSelectField";
import { MeasurementUnitsEnum } from "@saleor/types/globalTypes";
import { MeasurementUnitsEnum } from "@saleor/graphql";
import React from "react";
import { IntlShape, MessageDescriptor } from "react-intl";

View file

@ -6,6 +6,7 @@ import Skeleton from "@saleor/components/Skeleton";
import TableCellHeader from "@saleor/components/TableCellHeader";
import TableHead from "@saleor/components/TableHead";
import TablePagination from "@saleor/components/TablePagination";
import { AttributeFragment } from "@saleor/graphql";
import { translateBoolean } from "@saleor/intl";
import { makeStyles } from "@saleor/macaw-ui";
import { maybe, renderCollection } from "@saleor/misc";
@ -14,13 +15,11 @@ import { getArrowDirection } from "@saleor/utils/sort";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { AttributeList_attributes_edges_node } from "../../types/AttributeList";
export interface AttributeListProps
extends ListProps,
ListActions,
SortPage<AttributeListUrlSortField> {
attributes: AttributeList_attributes_edges_node[];
attributes: AttributeFragment[];
}
const useStyles = makeStyles(

View file

@ -1,6 +1,7 @@
import { Card } from "@material-ui/core";
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
import FilterBar from "@saleor/components/FilterBar";
import { AttributeFragment } from "@saleor/graphql";
import { sectionNames } from "@saleor/intl";
import { Backlink, Button } from "@saleor/macaw-ui";
import React from "react";
@ -15,7 +16,6 @@ import {
SortPage,
TabPageProps
} from "../../../types";
import { AttributeList_attributes_edges_node } from "../../types/AttributeList";
import AttributeList from "../AttributeList/AttributeList";
import {
AttributeFilterKeys,
@ -29,7 +29,7 @@ export interface AttributeListPageProps
FilterPageProps<AttributeFilterKeys, AttributeListFilterOpts>,
SortPage<AttributeListUrlSortField>,
TabPageProps {
attributes: AttributeList_attributes_edges_node[];
attributes: AttributeFragment[];
onBack: () => void;
}

View file

@ -1,8 +1,8 @@
import { Card, CardContent, Typography } from "@material-ui/core";
import CardTitle from "@saleor/components/CardTitle";
import RadioGroupField from "@saleor/components/RadioGroupField";
import { AttributeTypeEnum } from "@saleor/graphql";
import { makeStyles } from "@saleor/macaw-ui";
import { AttributeTypeEnum } from "@saleor/types/globalTypes";
import React from "react";
import { defineMessages, FormattedMessage, useIntl } from "react-intl";

View file

@ -1,4 +1,3 @@
import { AttributeDetails_attribute_choices } from "@saleor/attributes/types/AttributeDetails";
import { ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES } from "@saleor/attributes/utils/data";
import CardSpacer from "@saleor/components/CardSpacer";
import Container from "@saleor/components/Container";
@ -9,20 +8,20 @@ import { MetadataFormData } from "@saleor/components/Metadata/types";
import PageHeader from "@saleor/components/PageHeader";
import Savebar from "@saleor/components/Savebar";
import { ListSettingsUpdate } from "@saleor/components/TablePagination";
import { AttributeDetailsFragment } from "@saleor/fragments/types/AttributeDetailsFragment";
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { sectionNames } from "@saleor/intl";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { Backlink } from "@saleor/macaw-ui";
import { maybe } from "@saleor/misc";
import { ListSettings, ReorderAction } from "@saleor/types";
import {
AttributeDetailsFragment,
AttributeDetailsQuery,
AttributeEntityTypeEnum,
AttributeErrorFragment,
AttributeInputTypeEnum,
AttributeTypeEnum,
MeasurementUnitsEnum
} from "@saleor/types/globalTypes";
} from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { sectionNames } from "@saleor/intl";
import { Backlink, ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { maybe } from "@saleor/misc";
import { ListSettings, ReorderAction } from "@saleor/types";
import { mapEdgesToItems, mapMetadataItemToInput } from "@saleor/utils/maps";
import useMetadataChangeTrigger from "@saleor/utils/metadata/useMetadataChangeTrigger";
import React from "react";
@ -39,7 +38,7 @@ export interface AttributePageProps {
disabled: boolean;
errors: AttributeErrorFragment[];
saveButtonBarState: ConfirmButtonTransitionState;
values: AttributeDetails_attribute_choices;
values: AttributeDetailsQuery["attribute"]["choices"];
onBack: () => void;
onDelete: () => void;
onSubmit: (data: AttributePageFormData) => SubmitPromise;

View file

@ -6,9 +6,8 @@ import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
import ControlledSwitch from "@saleor/components/ControlledSwitch";
import FormSpacer from "@saleor/components/FormSpacer";
import Hr from "@saleor/components/Hr";
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import { AttributeErrorFragment, AttributeTypeEnum } from "@saleor/graphql";
import { commonMessages } from "@saleor/intl";
import { AttributeTypeEnum } from "@saleor/types/globalTypes";
import { getFormErrors } from "@saleor/utils/errors";
import getAttributeErrorMessage from "@saleor/utils/errors/attribute";
import React from "react";

View file

@ -4,7 +4,7 @@ import { AttributeValueEditDialogFormData } from "@saleor/attributes/utils/data"
import { ColorPicker } from "@saleor/components/ColorPicker";
import FileUploadField from "@saleor/components/FileUploadField";
import { RadioGroupField } from "@saleor/components/RadioGroupField";
import { useFileUploadMutation } from "@saleor/files/mutations";
import { useFileUploadMutation } from "@saleor/graphql";
import { UseFormResult } from "@saleor/hooks/useForm";
import useNotifier from "@saleor/hooks/useNotifier";
import { errorMessages } from "@saleor/intl";

View file

@ -9,11 +9,13 @@ import { getAttributeValueErrorMessage } from "@saleor/attributes/errors";
import BackButton from "@saleor/components/BackButton";
import ConfirmButton from "@saleor/components/ConfirmButton";
import Form from "@saleor/components/Form";
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import {
AttributeErrorFragment,
AttributeInputTypeEnum
} from "@saleor/graphql";
import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors";
import { buttonMessages } from "@saleor/intl";
import { ConfirmButtonTransitionState } from "@saleor/macaw-ui";
import { AttributeInputTypeEnum } from "@saleor/types/globalTypes";
import { getFormErrors } from "@saleor/utils/errors";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";

View file

@ -13,18 +13,20 @@ import {
SortableTableRow
} from "@saleor/components/SortableTable";
import TablePagination from "@saleor/components/TablePagination";
import { AttributeValueListFragment_edges_node } from "@saleor/fragments/types/AttributeValueListFragment";
import {
AttributeInputTypeEnum,
AttributeValueListFragment
} from "@saleor/graphql";
import { Button, DeleteIcon, IconButton, makeStyles } from "@saleor/macaw-ui";
import { renderCollection, stopPropagation } from "@saleor/misc";
import { ListProps, ReorderAction } from "@saleor/types";
import { AttributeInputTypeEnum } from "@saleor/types/globalTypes";
import { ListProps, RelayToFlat, ReorderAction } from "@saleor/types";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
export interface AttributeValuesProps
extends Pick<ListProps, Exclude<keyof ListProps, "onRowClick">> {
disabled: boolean;
values: AttributeValueListFragment_edges_node[];
values: RelayToFlat<AttributeValueListFragment>;
onValueAdd: () => void;
onValueDelete: (id: string) => void;
onValueReorder: ReorderAction;

View file

@ -1,5 +1,4 @@
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import { AttributeErrorCode } from "@saleor/types/globalTypes";
import { AttributeErrorCode, AttributeErrorFragment } from "@saleor/graphql";
import getAttributeErrorMessage from "@saleor/utils/errors/attribute";
import { defineMessages, IntlShape } from "react-intl";

File diff suppressed because it is too large Load diff

View file

@ -1,97 +1,39 @@
import { gql } from "@apollo/client";
import {
attributeDetailsFragment,
attributeValueListFragment
} from "@saleor/fragments/attributes";
import { attributeErrorFragment } from "@saleor/fragments/errors";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeMutation from "@saleor/hooks/makeMutation";
import {
AttributeBulkDelete,
AttributeBulkDeleteVariables
} from "./types/AttributeBulkDelete";
import {
AttributeCreate,
AttributeCreateVariables
} from "./types/AttributeCreate";
import {
AttributeDelete,
AttributeDeleteVariables
} from "./types/AttributeDelete";
import {
AttributeUpdate,
AttributeUpdateVariables
} from "./types/AttributeUpdate";
import {
AttributeValueCreate,
AttributeValueCreateVariables
} from "./types/AttributeValueCreate";
import {
AttributeValueDelete,
AttributeValueDeleteVariables
} from "./types/AttributeValueDelete";
import {
AttributeValueReorder,
AttributeValueReorderVariables
} from "./types/AttributeValueReorder";
import {
AttributeValueUpdate,
AttributeValueUpdateVariables
} from "./types/AttributeValueUpdate";
const attributeBulkDelete = gql`
${attributeErrorFragment}
export const attributeBulkDelete = gql`
mutation AttributeBulkDelete($ids: [ID!]!) {
attributeBulkDelete(ids: $ids) {
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeBulkDeleteMutation = makeMutation<
AttributeBulkDelete,
AttributeBulkDeleteVariables
>(attributeBulkDelete);
const attributeDelete = gql`
${attributeErrorFragment}
export const attributeDelete = gql`
mutation AttributeDelete($id: ID!) {
attributeDelete(id: $id) {
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeDeleteMutation = makeMutation<
AttributeDelete,
AttributeDeleteVariables
>(attributeDelete);
export const attributeUpdateMutation = gql`
${attributeDetailsFragment}
${attributeErrorFragment}
mutation AttributeUpdate($id: ID!, $input: AttributeUpdateInput!) {
attributeUpdate(id: $id, input: $input) {
attribute {
...AttributeDetailsFragment
...AttributeDetails
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeUpdateMutation = makeMutation<
AttributeUpdate,
AttributeUpdateVariables
>(attributeUpdateMutation);
const attributeValueDelete = gql`
${attributeValueListFragment}
${attributeErrorFragment}
export const attributeValueDelete = gql`
mutation AttributeValueDelete(
$id: ID!
$firstValues: Int
@ -108,23 +50,17 @@ const attributeValueDelete = gql`
last: $lastValues
before: $beforeValues
) {
...AttributeValueListFragment
...AttributeValueList
}
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeValueDeleteMutation = makeMutation<
AttributeValueDelete,
AttributeValueDeleteVariables
>(attributeValueDelete);
export const attributeValueUpdateMutation = gql`
${attributeValueListFragment}
${attributeErrorFragment}
mutation AttributeValueUpdate(
$id: ID!
$input: AttributeValueUpdateInput!
@ -142,23 +78,17 @@ export const attributeValueUpdateMutation = gql`
last: $lastValues
before: $beforeValues
) {
...AttributeValueListFragment
...AttributeValueList
}
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeValueUpdateMutation = makeMutation<
AttributeValueUpdate,
AttributeValueUpdateVariables
>(attributeValueUpdateMutation);
export const attributeValueCreateMutation = gql`
${attributeValueListFragment}
${attributeErrorFragment}
mutation AttributeValueCreate(
$id: ID!
$input: AttributeValueCreateInput!
@ -176,41 +106,30 @@ export const attributeValueCreateMutation = gql`
last: $lastValues
before: $beforeValues
) {
...AttributeValueListFragment
...AttributeValueList
}
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeValueCreateMutation = makeMutation<
AttributeValueCreate,
AttributeValueCreateVariables
>(attributeValueCreateMutation);
export const attributeCreateMutation = gql`
${attributeErrorFragment}
mutation AttributeCreate($input: AttributeCreateInput!) {
attributeCreate(input: $input) {
attribute {
id
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeCreateMutation = makeMutation<
AttributeCreate,
AttributeCreateVariables
>(attributeCreateMutation);
const attributeValueReorderMutation = gql`
${attributeErrorFragment}
${pageInfoFragment}
export const attributeValueReorderMutation = gql`
mutation AttributeValueReorder(
$id: ID!
$move: ReorderInput!
@ -229,7 +148,7 @@ const attributeValueReorderMutation = gql`
before: $beforeValues
) {
pageInfo {
...PageInfoFragment
...PageInfo
}
edges {
cursor
@ -240,12 +159,8 @@ const attributeValueReorderMutation = gql`
}
}
errors {
...AttributeErrorFragment
...AttributeError
}
}
}
`;
export const useAttributeValueReorderMutation = makeMutation<
AttributeValueReorder,
AttributeValueReorderVariables
>(attributeValueReorderMutation);

View file

@ -1,21 +1,6 @@
import { gql } from "@apollo/client";
import {
attributeDetailsFragment,
attributeFragment,
attributeValueListFragment
} from "@saleor/fragments/attributes";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
import makeQuery from "@saleor/hooks/makeQuery";
import {
AttributeDetails,
AttributeDetailsVariables
} from "./types/AttributeDetails";
import { AttributeList, AttributeListVariables } from "./types/AttributeList";
const attributeDetails = gql`
${attributeDetailsFragment}
${attributeValueListFragment}
export const attributeDetails = gql`
query AttributeDetails(
$id: ID!
$firstValues: Int
@ -24,26 +9,20 @@ const attributeDetails = gql`
$beforeValues: String
) {
attribute(id: $id) {
...AttributeDetailsFragment
...AttributeDetails
choices(
first: $firstValues
after: $afterValues
last: $lastValues
before: $beforeValues
) {
...AttributeValueListFragment
...AttributeValueList
}
}
}
`;
export const useAttributeDetailsQuery = makeQuery<
AttributeDetails,
AttributeDetailsVariables
>(attributeDetails);
const attributeList = gql`
${attributeFragment}
${pageInfoFragment}
export const attributeList = gql`
query AttributeList(
$filter: AttributeFilterInput
$before: String
@ -62,16 +41,12 @@ const attributeList = gql`
) {
edges {
node {
...AttributeFragment
...Attribute
}
}
pageInfo {
...PageInfoFragment
...PageInfo
}
}
}
`;
export const useAttributeListQuery = makeQuery<
AttributeList,
AttributeListVariables
>(attributeList);

View file

@ -1,30 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeBulkDelete
// ====================================================
export interface AttributeBulkDelete_attributeBulkDelete_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeBulkDelete_attributeBulkDelete {
__typename: "AttributeBulkDelete";
errors: AttributeBulkDelete_attributeBulkDelete_errors[];
}
export interface AttributeBulkDelete {
attributeBulkDelete: AttributeBulkDelete_attributeBulkDelete | null;
}
export interface AttributeBulkDeleteVariables {
ids: string[];
}

View file

@ -1,36 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeCreateInput, AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeCreate
// ====================================================
export interface AttributeCreate_attributeCreate_attribute {
__typename: "Attribute";
id: string;
}
export interface AttributeCreate_attributeCreate_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeCreate_attributeCreate {
__typename: "AttributeCreate";
attribute: AttributeCreate_attributeCreate_attribute | null;
errors: AttributeCreate_attributeCreate_errors[];
}
export interface AttributeCreate {
attributeCreate: AttributeCreate_attributeCreate | null;
}
export interface AttributeCreateVariables {
input: AttributeCreateInput;
}

View file

@ -1,30 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeDelete
// ====================================================
export interface AttributeDelete_attributeDelete_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeDelete_attributeDelete {
__typename: "AttributeDelete";
errors: AttributeDelete_attributeDelete_errors[];
}
export interface AttributeDelete {
attributeDelete: AttributeDelete_attributeDelete | null;
}
export interface AttributeDeleteVariables {
id: string;
}

View file

@ -1,94 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, AttributeEntityTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: AttributeDetails
// ====================================================
export interface AttributeDetails_attribute_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AttributeDetails_attribute_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AttributeDetails_attribute_choices_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeDetails_attribute_choices_edges_node_file {
__typename: "File";
url: string;
contentType: string | null;
}
export interface AttributeDetails_attribute_choices_edges_node {
__typename: "AttributeValue";
id: string;
name: string | null;
slug: string | null;
file: AttributeDetails_attribute_choices_edges_node_file | null;
reference: string | null;
boolean: boolean | null;
date: any | null;
dateTime: any | null;
value: string | null;
richText: any | null;
}
export interface AttributeDetails_attribute_choices_edges {
__typename: "AttributeValueCountableEdge";
cursor: string;
node: AttributeDetails_attribute_choices_edges_node;
}
export interface AttributeDetails_attribute_choices {
__typename: "AttributeValueCountableConnection";
pageInfo: AttributeDetails_attribute_choices_pageInfo;
edges: AttributeDetails_attribute_choices_edges[];
}
export interface AttributeDetails_attribute {
__typename: "Attribute";
id: string;
name: string | null;
slug: string | null;
type: AttributeTypeEnum | null;
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
metadata: (AttributeDetails_attribute_metadata | null)[];
privateMetadata: (AttributeDetails_attribute_privateMetadata | null)[];
availableInGrid: boolean;
entityType: AttributeEntityTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;
choices: AttributeDetails_attribute_choices | null;
}
export interface AttributeDetails {
attribute: AttributeDetails_attribute | null;
}
export interface AttributeDetailsVariables {
id: string;
firstValues?: number | null;
afterValues?: string | null;
lastValues?: number | null;
beforeValues?: string | null;
}

View file

@ -1,55 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeFilterInput, AttributeSortingInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: AttributeList
// ====================================================
export interface AttributeList_attributes_edges_node {
__typename: "Attribute";
id: string;
name: string | null;
slug: string | null;
type: AttributeTypeEnum | null;
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface AttributeList_attributes_edges {
__typename: "AttributeCountableEdge";
node: AttributeList_attributes_edges_node;
}
export interface AttributeList_attributes_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeList_attributes {
__typename: "AttributeCountableConnection";
edges: AttributeList_attributes_edges[];
pageInfo: AttributeList_attributes_pageInfo;
}
export interface AttributeList {
attributes: AttributeList_attributes | null;
}
export interface AttributeListVariables {
filter?: AttributeFilterInput | null;
before?: string | null;
after?: string | null;
first?: number | null;
last?: number | null;
sort?: AttributeSortingInput | null;
}

View file

@ -1,3 +0,0 @@
import { AttributeValueInput } from "@saleor/types/globalTypes";
export type AtributesOfFiles = Pick<AttributeValueInput, "file" | "id" | "values" | "contentType">

View file

@ -1,63 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeUpdateInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, AttributeEntityTypeEnum, AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeUpdate
// ====================================================
export interface AttributeUpdate_attributeUpdate_attribute_metadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AttributeUpdate_attributeUpdate_attribute_privateMetadata {
__typename: "MetadataItem";
key: string;
value: string;
}
export interface AttributeUpdate_attributeUpdate_attribute {
__typename: "Attribute";
id: string;
name: string | null;
slug: string | null;
type: AttributeTypeEnum | null;
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
metadata: (AttributeUpdate_attributeUpdate_attribute_metadata | null)[];
privateMetadata: (AttributeUpdate_attributeUpdate_attribute_privateMetadata | null)[];
availableInGrid: boolean;
entityType: AttributeEntityTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;
}
export interface AttributeUpdate_attributeUpdate_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeUpdate_attributeUpdate {
__typename: "AttributeUpdate";
attribute: AttributeUpdate_attributeUpdate_attribute | null;
errors: AttributeUpdate_attributeUpdate_errors[];
}
export interface AttributeUpdate {
attributeUpdate: AttributeUpdate_attributeUpdate | null;
}
export interface AttributeUpdateVariables {
id: string;
input: AttributeUpdateInput;
}

View file

@ -1,82 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeValueCreateInput, AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeValueCreate
// ====================================================
export interface AttributeValueCreate_attributeValueCreate_attribute_choices_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeValueCreate_attributeValueCreate_attribute_choices_edges_node_file {
__typename: "File";
url: string;
contentType: string | null;
}
export interface AttributeValueCreate_attributeValueCreate_attribute_choices_edges_node {
__typename: "AttributeValue";
id: string;
name: string | null;
slug: string | null;
file: AttributeValueCreate_attributeValueCreate_attribute_choices_edges_node_file | null;
reference: string | null;
boolean: boolean | null;
date: any | null;
dateTime: any | null;
value: string | null;
richText: any | null;
}
export interface AttributeValueCreate_attributeValueCreate_attribute_choices_edges {
__typename: "AttributeValueCountableEdge";
cursor: string;
node: AttributeValueCreate_attributeValueCreate_attribute_choices_edges_node;
}
export interface AttributeValueCreate_attributeValueCreate_attribute_choices {
__typename: "AttributeValueCountableConnection";
pageInfo: AttributeValueCreate_attributeValueCreate_attribute_choices_pageInfo;
edges: AttributeValueCreate_attributeValueCreate_attribute_choices_edges[];
}
export interface AttributeValueCreate_attributeValueCreate_attribute {
__typename: "Attribute";
id: string;
choices: AttributeValueCreate_attributeValueCreate_attribute_choices | null;
}
export interface AttributeValueCreate_attributeValueCreate_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeValueCreate_attributeValueCreate {
__typename: "AttributeValueCreate";
attribute: AttributeValueCreate_attributeValueCreate_attribute | null;
errors: AttributeValueCreate_attributeValueCreate_errors[];
}
export interface AttributeValueCreate {
attributeValueCreate: AttributeValueCreate_attributeValueCreate | null;
}
export interface AttributeValueCreateVariables {
id: string;
input: AttributeValueCreateInput;
firstValues?: number | null;
afterValues?: string | null;
lastValues?: number | null;
beforeValues?: string | null;
}

View file

@ -1,81 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeValueDelete
// ====================================================
export interface AttributeValueDelete_attributeValueDelete_attribute_choices_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeValueDelete_attributeValueDelete_attribute_choices_edges_node_file {
__typename: "File";
url: string;
contentType: string | null;
}
export interface AttributeValueDelete_attributeValueDelete_attribute_choices_edges_node {
__typename: "AttributeValue";
id: string;
name: string | null;
slug: string | null;
file: AttributeValueDelete_attributeValueDelete_attribute_choices_edges_node_file | null;
reference: string | null;
boolean: boolean | null;
date: any | null;
dateTime: any | null;
value: string | null;
richText: any | null;
}
export interface AttributeValueDelete_attributeValueDelete_attribute_choices_edges {
__typename: "AttributeValueCountableEdge";
cursor: string;
node: AttributeValueDelete_attributeValueDelete_attribute_choices_edges_node;
}
export interface AttributeValueDelete_attributeValueDelete_attribute_choices {
__typename: "AttributeValueCountableConnection";
pageInfo: AttributeValueDelete_attributeValueDelete_attribute_choices_pageInfo;
edges: AttributeValueDelete_attributeValueDelete_attribute_choices_edges[];
}
export interface AttributeValueDelete_attributeValueDelete_attribute {
__typename: "Attribute";
id: string;
choices: AttributeValueDelete_attributeValueDelete_attribute_choices | null;
}
export interface AttributeValueDelete_attributeValueDelete_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeValueDelete_attributeValueDelete {
__typename: "AttributeValueDelete";
attribute: AttributeValueDelete_attributeValueDelete_attribute | null;
errors: AttributeValueDelete_attributeValueDelete_errors[];
}
export interface AttributeValueDelete {
attributeValueDelete: AttributeValueDelete_attributeValueDelete | null;
}
export interface AttributeValueDeleteVariables {
id: string;
firstValues?: number | null;
afterValues?: string | null;
lastValues?: number | null;
beforeValues?: string | null;
}

View file

@ -1,67 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { ReorderInput, AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeValueReorder
// ====================================================
export interface AttributeValueReorder_attributeReorderValues_attribute_choices_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeValueReorder_attributeReorderValues_attribute_choices_edges_node {
__typename: "AttributeValue";
id: string;
}
export interface AttributeValueReorder_attributeReorderValues_attribute_choices_edges {
__typename: "AttributeValueCountableEdge";
cursor: string;
node: AttributeValueReorder_attributeReorderValues_attribute_choices_edges_node;
}
export interface AttributeValueReorder_attributeReorderValues_attribute_choices {
__typename: "AttributeValueCountableConnection";
pageInfo: AttributeValueReorder_attributeReorderValues_attribute_choices_pageInfo;
edges: AttributeValueReorder_attributeReorderValues_attribute_choices_edges[];
}
export interface AttributeValueReorder_attributeReorderValues_attribute {
__typename: "Attribute";
id: string;
choices: AttributeValueReorder_attributeReorderValues_attribute_choices | null;
}
export interface AttributeValueReorder_attributeReorderValues_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeValueReorder_attributeReorderValues {
__typename: "AttributeReorderValues";
attribute: AttributeValueReorder_attributeReorderValues_attribute | null;
errors: AttributeValueReorder_attributeReorderValues_errors[];
}
export interface AttributeValueReorder {
attributeReorderValues: AttributeValueReorder_attributeReorderValues | null;
}
export interface AttributeValueReorderVariables {
id: string;
move: ReorderInput;
firstValues?: number | null;
afterValues?: string | null;
lastValues?: number | null;
beforeValues?: string | null;
}

View file

@ -1,82 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AttributeValueUpdateInput, AttributeErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AttributeValueUpdate
// ====================================================
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges_node_file {
__typename: "File";
url: string;
contentType: string | null;
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges_node {
__typename: "AttributeValue";
id: string;
name: string | null;
slug: string | null;
file: AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges_node_file | null;
reference: string | null;
boolean: boolean | null;
date: any | null;
dateTime: any | null;
value: string | null;
richText: any | null;
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges {
__typename: "AttributeValueCountableEdge";
cursor: string;
node: AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges_node;
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices {
__typename: "AttributeValueCountableConnection";
pageInfo: AttributeValueUpdate_attributeValueUpdate_attribute_choices_pageInfo;
edges: AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges[];
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute {
__typename: "Attribute";
id: string;
choices: AttributeValueUpdate_attributeValueUpdate_attribute_choices | null;
}
export interface AttributeValueUpdate_attributeValueUpdate_errors {
__typename: "AttributeError";
code: AttributeErrorCode;
field: string | null;
message: string | null;
}
export interface AttributeValueUpdate_attributeValueUpdate {
__typename: "AttributeValueUpdate";
attribute: AttributeValueUpdate_attributeValueUpdate_attribute | null;
errors: AttributeValueUpdate_attributeValueUpdate_errors[];
}
export interface AttributeValueUpdate {
attributeValueUpdate: AttributeValueUpdate_attributeValueUpdate | null;
}
export interface AttributeValueUpdateVariables {
id: string;
input: AttributeValueUpdateInput;
firstValues?: number | null;
afterValues?: string | null;
lastValues?: number | null;
beforeValues?: string | null;
}

View file

@ -3,22 +3,25 @@ import {
AttributeInput,
AttributeInputData
} from "@saleor/components/Attributes";
import { FileUpload } from "@saleor/files/types/FileUpload";
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import { AttributeValueFragment } from "@saleor/fragments/types/AttributeValueFragment";
import { SelectedVariantAttributeFragment } from "@saleor/fragments/types/SelectedVariantAttributeFragment";
import { UploadErrorFragment } from "@saleor/fragments/types/UploadErrorFragment";
import { VariantAttributeFragment } from "@saleor/fragments/types/VariantAttributeFragment";
import { FormsetData } from "@saleor/hooks/useFormset";
import { PageDetails_page_attributes } from "@saleor/pages/types/PageDetails";
import { ProductDetails_product_attributes } from "@saleor/products/types/ProductDetails";
import { SearchPages_search_edges_node } from "@saleor/searches/types/SearchPages";
import { SearchProducts_search_edges_node } from "@saleor/searches/types/SearchProducts";
import {
AttributeEntityTypeEnum,
AttributeErrorFragment,
AttributeInputTypeEnum,
AttributeValueInput
} from "@saleor/types/globalTypes";
AttributeValueDeleteMutation,
AttributeValueFragment,
AttributeValueInput,
FileUploadMutation,
Node,
PageSelectedAttributeFragment,
ProductFragment,
SearchPagesQuery,
SearchProductsQuery,
SelectedVariantAttributeFragment,
UploadErrorFragment,
VariantAttributeFragment
} from "@saleor/graphql";
import { FormsetData } from "@saleor/hooks/useFormset";
import { RelayToFlat } from "@saleor/types";
import {
mapEdgesToItems,
mapNodeToChoice,
@ -26,8 +29,11 @@ import {
} from "@saleor/utils/maps";
import { AttributePageFormData } from "../components/AttributePage";
import { AtributesOfFiles } from "../types/AttributeOfUploadedFile";
import { AttributeValueDelete } from "../types/AttributeValueDelete";
type AtributesOfFiles = Pick<
AttributeValueInput,
"file" | "id" | "values" | "contentType"
>;
export const ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES = [
AttributeInputTypeEnum.DROPDOWN,
@ -145,8 +151,8 @@ export function getDefaultAttributeValues(attribute: VariantAttributeFragment) {
export function getSelectedAttributeValues(
attribute:
| PageDetails_page_attributes
| ProductDetails_product_attributes
| PageSelectedAttributeFragment
| ProductFragment["attributes"][0]
| SelectedVariantAttributeFragment
) {
switch (attribute.attribute.inputType) {
@ -176,8 +182,8 @@ export function getSelectedAttributeValues(
export const isFileValueUnused = (
attributesWithNewFileValue: FormsetData<null, File>,
existingAttribute:
| PageDetails_page_attributes
| ProductDetails_product_attributes
| PageSelectedAttributeFragment
| ProductFragment["attributes"][0]
| SelectedVariantAttributeFragment
) => {
if (existingAttribute.attribute.inputType !== AttributeInputTypeEnum.FILE) {
@ -195,7 +201,7 @@ export const isFileValueUnused = (
};
export const mergeFileUploadErrors = (
uploadFilesResult: Array<FetchResult<FileUpload>>
uploadFilesResult: Array<FetchResult<FileUploadMutation>>
): UploadErrorFragment[] =>
uploadFilesResult.reduce((errors, uploadFileResult) => {
const uploadErrors = uploadFileResult?.data?.fileUpload?.errors;
@ -206,7 +212,7 @@ export const mergeFileUploadErrors = (
}, []);
export const mergeAttributeValueDeleteErrors = (
deleteAttributeValuesResult: Array<FetchResult<AttributeValueDelete>>
deleteAttributeValuesResult: Array<FetchResult<AttributeValueDeleteMutation>>
): AttributeErrorFragment[] =>
deleteAttributeValuesResult.reduce((errors, deleteValueResult) => {
const deleteErrors = deleteValueResult?.data?.attributeValueDelete?.errors;
@ -218,8 +224,8 @@ export const mergeAttributeValueDeleteErrors = (
export const mergeChoicesWithValues = (
attribute:
| ProductDetails_product_attributes
| PageDetails_page_attributes
| ProductFragment["attributes"][0]
| PageSelectedAttributeFragment
| SelectedVariantAttributeFragment
) => {
const choices = mapEdgesToItems(attribute.attribute.choices) || [];
@ -262,7 +268,7 @@ export const getAttributesOfRemovedFiles = (
export const getAttributesOfUploadedFiles = (
fileValuesToUpload: FormsetData<null, File>,
uploadFilesResult: Array<FetchResult<FileUpload>>
uploadFilesResult: Array<FetchResult<FileUploadMutation>>
): AtributesOfFiles[] =>
uploadFilesResult.map((uploadFileResult, index) => {
const attribute = fileValuesToUpload[index];
@ -277,7 +283,7 @@ export const getAttributesOfUploadedFiles = (
export const getAttributesAfterFileAttributesUpdate = (
attributesWithNewFileValue: FormsetData<null, File>,
uploadFilesResult: Array<FetchResult<FileUpload>>
uploadFilesResult: Array<FetchResult<FileUploadMutation>>
): AttributeValueInput[] => {
const removedFileValues = getFileValuesRemovedFromAttributes(
attributesWithNewFileValue
@ -316,7 +322,7 @@ export const getFileAttributeDisplayData = (
export const getPageReferenceAttributeDisplayData = (
attribute: AttributeInput,
referencePages: SearchPages_search_edges_node[]
referencePages: RelayToFlat<SearchPagesQuery["search"]>
) => ({
...attribute,
data: {
@ -337,7 +343,7 @@ export const getPageReferenceAttributeDisplayData = (
export const getProductReferenceAttributeDisplayData = (
attribute: AttributeInput,
referenceProducts: SearchProducts_search_edges_node[]
referenceProducts: RelayToFlat<SearchProductsQuery["search"]>
) => ({
...attribute,
data: {
@ -358,8 +364,8 @@ export const getProductReferenceAttributeDisplayData = (
export const getReferenceAttributeDisplayData = (
attribute: AttributeInput,
referencePages: SearchPages_search_edges_node[],
referenceProducts: SearchProducts_search_edges_node[]
referencePages: RelayToFlat<SearchPagesQuery["search"]>,
referenceProducts: RelayToFlat<SearchProductsQuery["search"]>
) => {
if (attribute.data.entityType === AttributeEntityTypeEnum.PAGE) {
return getPageReferenceAttributeDisplayData(attribute, referencePages);
@ -374,8 +380,8 @@ export const getReferenceAttributeDisplayData = (
export const getAttributesDisplayData = (
attributes: AttributeInput[],
attributesWithNewFileValue: FormsetData<null, File>,
referencePages: SearchPages_search_edges_node[],
referenceProducts: SearchProducts_search_edges_node[]
referencePages: RelayToFlat<SearchPagesQuery["search"]>,
referenceProducts: RelayToFlat<SearchProductsQuery["search"]>
) =>
attributes.map(attribute => {
if (attribute.data.inputType === AttributeInputTypeEnum.REFERENCE) {
@ -391,11 +397,9 @@ export const getAttributesDisplayData = (
return attribute;
});
export const getSelectedReferencesFromAttribute = <
Node extends SearchPages_search_edges_node | SearchProducts_search_edges_node
>(
export const getSelectedReferencesFromAttribute = <T extends Node>(
attribute?: AttributeInput,
references?: Node[]
references?: T[]
) =>
references?.filter(
value =>
@ -405,8 +409,8 @@ export const getSelectedReferencesFromAttribute = <
export const getAttributeValuesFromReferences = (
attributeId: string,
attributes?: AttributeInput[],
referencePages?: SearchPages_search_edges_node[],
referenceProducts?: SearchProducts_search_edges_node[]
referencePages?: RelayToFlat<SearchPagesQuery["search"]>,
referenceProducts?: RelayToFlat<SearchProductsQuery["search"]>
) => {
const attribute = attributes?.find(attribute => attribute.id === attributeId);

View file

@ -1,7 +1,7 @@
import { createAttributeMultiChangeHandler } from "@saleor/attributes/utils/handlers";
import { AttributeInputData } from "@saleor/components/Attributes";
import { AttributeInputTypeEnum } from "@saleor/graphql";
import { FormsetData } from "@saleor/hooks/useFormset";
import { AttributeInputTypeEnum } from "@saleor/types/globalTypes";
const attributes: FormsetData<AttributeInputData, string[]> = [
{

View file

@ -4,29 +4,25 @@ import {
AttributeInputData
} from "@saleor/components/Attributes";
import {
FileUpload,
FileUploadVariables
} from "@saleor/files/types/FileUpload";
AttributeEntityTypeEnum,
AttributeInputTypeEnum,
AttributeValueDeleteMutation,
AttributeValueDeleteMutationVariables,
AttributeValueInput,
FileUploadMutation,
FileUploadMutationVariables,
PageSelectedAttributeFragment,
ProductFragment,
ProductVariantDetailsQuery
} from "@saleor/graphql";
import {
FormsetAtomicData,
FormsetChange,
FormsetData
} from "@saleor/hooks/useFormset";
import { PageDetails_page_attributes } from "@saleor/pages/types/PageDetails";
import { ProductDetails_product_attributes } from "@saleor/products/types/ProductDetails";
import { ProductVariantDetails_productVariant_nonSelectionAttributes } from "@saleor/products/types/ProductVariantDetails";
import { FetchMoreProps, ReorderEvent } from "@saleor/types";
import {
AttributeEntityTypeEnum,
AttributeInputTypeEnum,
AttributeValueInput
} from "@saleor/types/globalTypes";
import { move, toggle } from "@saleor/utils/lists";
import {
AttributeValueDelete,
AttributeValueDeleteVariables
} from "../types/AttributeValueDelete";
import { getFileValuesToUploadFromAttributes, isFileValueUnused } from "./data";
export function createAttributeChangeHandler(
@ -275,8 +271,8 @@ export const prepareAttributesInput = ({
export const handleUploadMultipleFiles = async (
attributesWithNewFileValue: FormsetData<null, File>,
uploadFile: (
variables: FileUploadVariables
) => Promise<FetchResult<FileUpload>>
variables: FileUploadMutationVariables
) => Promise<FetchResult<FileUploadMutation>>
) =>
Promise.all(
getFileValuesToUploadFromAttributes(attributesWithNewFileValue).map(
@ -290,13 +286,13 @@ export const handleUploadMultipleFiles = async (
export const handleDeleteMultipleAttributeValues = async (
attributesWithNewFileValue: FormsetData<null, File>,
attributes: Array<
| PageDetails_page_attributes
| ProductDetails_product_attributes
| ProductVariantDetails_productVariant_nonSelectionAttributes
| PageSelectedAttributeFragment
| ProductFragment["attributes"][0]
| ProductVariantDetailsQuery["productVariant"]["nonSelectionAttributes"][0]
>,
deleteAttributeValue: (
variables: AttributeValueDeleteVariables
) => Promise<FetchResult<AttributeValueDelete>>
variables: AttributeValueDeleteMutationVariables
) => Promise<FetchResult<AttributeValueDeleteMutation>>
) =>
Promise.all(
attributes.map(existingAttribute => {

View file

@ -1,11 +1,16 @@
import { AttributeErrorFragment } from "@saleor/fragments/types/AttributeErrorFragment";
import {
AttributeErrorCode,
AttributeErrorFragment,
useAttributeCreateMutation,
useUpdateMetadataMutation,
useUpdatePrivateMetadataMutation
} from "@saleor/graphql";
import useListSettings from "@saleor/hooks/useListSettings";
import useLocalPageInfo, { getMaxPage } from "@saleor/hooks/useLocalPageInfo";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import { getMutationErrors, getStringOrPlaceholder } from "@saleor/misc";
import { ListViews, ReorderEvent } from "@saleor/types";
import { AttributeErrorCode } from "@saleor/types/globalTypes";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
import createMetadataCreateHandler from "@saleor/utils/handlers/metadataCreateHandler";
import {
@ -15,10 +20,6 @@ import {
remove,
updateAtIndex
} from "@saleor/utils/lists";
import {
useMetadataUpdate,
usePrivateMetadataUpdate
} from "@saleor/utils/metadata/updateMetadata";
import React from "react";
import { useIntl } from "react-intl";
import slugify from "slugify";
@ -28,7 +29,6 @@ import AttributePage, {
} from "../../components/AttributePage";
import AttributeValueDeleteDialog from "../../components/AttributeValueDeleteDialog";
import AttributeValueEditDialog from "../../components/AttributeValueEditDialog";
import { useAttributeCreateMutation } from "../../mutations";
import {
attributeAddUrl,
AttributeAddUrlDialog,
@ -96,8 +96,8 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ params }) => {
}
}
});
const [updateMetadata] = useMetadataUpdate({});
const [updatePrivateMetadata] = usePrivateMetadataUpdate({});
const [updateMetadata] = useUpdateMetadataMutation({});
const [updatePrivateMetadata] = useUpdatePrivateMetadataMutation({});
const id = params.id
? parseInt(params.id, 0) + pageInfo.startCursor

View file

@ -1,4 +1,15 @@
import { attributeValueFragmentToFormData } from "@saleor/attributes/utils/data";
import {
useAttributeDeleteMutation,
useAttributeDetailsQuery,
useAttributeUpdateMutation,
useAttributeValueCreateMutation,
useAttributeValueDeleteMutation,
useAttributeValueReorderMutation,
useAttributeValueUpdateMutation,
useUpdateMetadataMutation,
useUpdatePrivateMetadataMutation
} from "@saleor/graphql";
import useListSettings from "@saleor/hooks/useListSettings";
import useLocalPaginator, {
useLocalPaginationState
@ -12,10 +23,6 @@ import getAttributeErrorMessage from "@saleor/utils/errors/attribute";
import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers";
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
import { move } from "@saleor/utils/lists";
import {
useMetadataUpdate,
usePrivateMetadataUpdate
} from "@saleor/utils/metadata/updateMetadata";
import omit from "lodash/omit";
import React from "react";
import { useIntl } from "react-intl";
@ -26,15 +33,6 @@ import AttributePage, {
} from "../../components/AttributePage";
import AttributeValueDeleteDialog from "../../components/AttributeValueDeleteDialog";
import AttributeValueEditDialog from "../../components/AttributeValueEditDialog";
import {
useAttributeDeleteMutation,
useAttributeUpdateMutation,
useAttributeValueCreateMutation,
useAttributeValueDeleteMutation,
useAttributeValueReorderMutation,
useAttributeValueUpdateMutation
} from "../../mutations";
import { useAttributeDetailsQuery } from "../../queries";
import {
attributeListUrl,
attributeUrl,
@ -51,8 +49,8 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const navigate = useNavigator();
const notify = useNotifier();
const intl = useIntl();
const [updateMetadata] = useMetadataUpdate({});
const [updatePrivateMetadata] = usePrivateMetadataUpdate({});
const [updateMetadata] = useUpdateMetadataMutation({});
const [updatePrivateMetadata] = useUpdatePrivateMetadataMutation({});
const [openModal, closeModal] = createDialogActionHandlers<
AttributeUrlDialog,
@ -178,6 +176,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ id, params }) => {
const handleValueReorder = ({ newIndex, oldIndex }: ReorderEvent) =>
attributeValueReorder({
optimisticResponse: {
__typename: "Mutation",
attributeReorderValues: {
__typename: "AttributeReorderValues",
attribute: {

View file

@ -12,6 +12,10 @@ import SaveFilterTabDialog, {
SaveFilterTabDialogFormData
} from "@saleor/components/SaveFilterTabDialog";
import { configurationMenuUrl } from "@saleor/configuration";
import {
useAttributeBulkDeleteMutation,
useAttributeListQuery
} from "@saleor/graphql";
import useNavigator from "@saleor/hooks/useNavigator";
import useNotifier from "@saleor/hooks/useNotifier";
import usePaginator, {
@ -31,8 +35,6 @@ import useBulkActions from "../../../hooks/useBulkActions";
import { maybe } from "../../../misc";
import AttributeBulkDeleteDialog from "../../components/AttributeBulkDeleteDialog";
import AttributeListPage from "../../components/AttributeListPage";
import { useAttributeBulkDeleteMutation } from "../../mutations";
import { useAttributeListQuery } from "../../queries";
import {
attributeAddUrl,
attributeListUrl,

View file

@ -3,8 +3,8 @@ import {
AttributeListFilterOpts
} from "@saleor/attributes/components/AttributeListPage";
import { IFilterElement } from "@saleor/components/Filter";
import { AttributeFilterInput } from "@saleor/graphql";
import { maybe, parseBoolean } from "@saleor/misc";
import { AttributeFilterInput } from "@saleor/types/globalTypes";
import {
createFilterTabUtils,

View file

@ -1,5 +1,5 @@
import { AttributeListUrlSortField } from "@saleor/attributes/urls";
import { AttributeSortField } from "@saleor/types/globalTypes";
import { AttributeSortField } from "@saleor/graphql";
import { createGetSortQueryVariables } from "@saleor/utils/sort";
export function getSortQueryField(

View file

@ -2,6 +2,7 @@ import { createSaleorClient, SaleorProvider } from "@saleor/sdk";
import setupApi from "@test/api";
import { act, renderHook } from "@testing-library/react-hooks";
import React from "react";
import { IntlProvider } from "react-intl";
import { MemoryRouter as Router } from "react-router-dom";
import { useAuthProvider } from "./hooks/useAuthProvider";
@ -18,9 +19,11 @@ function renderAuthProvider() {
channel: ""
});
const wrapper = ({ children }) => (
<Router>
<SaleorProvider client={saleorClient}>{children}</SaleorProvider>
</Router>
<IntlProvider defaultLocale="en" locale="en">
<Router>
<SaleorProvider client={saleorClient}>{children}</SaleorProvider>
</Router>
</IntlProvider>
);
const { result } = renderHook(

View file

@ -1,8 +1,7 @@
import backgroundArt from "@assets/images/login-background.svg";
import saleorDarkLogo from "@assets/images/logo-dark.svg";
import saleorLightLogo from "@assets/images/logo-light.svg";
import { useTheme } from "@saleor/macaw-ui";
import { makeStyles } from "@saleor/macaw-ui";
import { makeStyles, useTheme } from "@saleor/macaw-ui";
import React from "react";
import SVG from "react-inlinesvg";

View file

@ -5,8 +5,8 @@ import {
Typography
} from "@material-ui/core";
import { UserContextError } from "@saleor/auth/types";
import { AvailableExternalAuthentications_shop_availableExternalAuthentications } from "@saleor/auth/types/AvailableExternalAuthentications";
import { FormSpacer } from "@saleor/components/FormSpacer";
import { AvailableExternalAuthenticationsQuery } from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { commonMessages } from "@saleor/intl";
import { Button, EyeIcon, IconButton } from "@saleor/macaw-ui";
@ -21,7 +21,7 @@ export interface LoginCardProps {
error?: UserContextError;
disabled: boolean;
loading: boolean;
externalAuthentications?: AvailableExternalAuthentications_shop_availableExternalAuthentications[];
externalAuthentications?: AvailableExternalAuthenticationsQuery["shop"]["availableExternalAuthentications"];
onExternalAuthentication: (pluginId: string) => void;
onPasswordRecovery: () => void;
onSubmit?: (event: LoginFormData) => SubmitPromise;

View file

@ -1,6 +1,6 @@
import { AccountErrorCode } from "@saleor/graphql";
import CardDecorator from "@saleor/storybook//CardDecorator";
import Decorator from "@saleor/storybook//Decorator";
import { AccountErrorCode } from "@saleor/types/globalTypes";
import { storiesOf } from "@storybook/react";
import React from "react";

View file

@ -1,7 +1,7 @@
import { TextField, Typography } from "@material-ui/core";
import { RequestPasswordReset_requestPasswordReset_errors } from "@saleor/auth/types/RequestPasswordReset";
import Form from "@saleor/components/Form";
import FormSpacer from "@saleor/components/FormSpacer";
import { RequestPasswordResetMutation } from "@saleor/graphql";
import { SubmitPromise } from "@saleor/hooks/useForm";
import { commonMessages } from "@saleor/intl";
import { ArrowRightIcon, Button, IconButton } from "@saleor/macaw-ui";
@ -19,7 +19,9 @@ export interface ResetPasswordPageProps {
onBack: () => void;
onSubmit: (
data: ResetPasswordPageFormData
) => SubmitPromise<RequestPasswordReset_requestPasswordReset_errors[]>;
) => SubmitPromise<
RequestPasswordResetMutation["requestPasswordReset"]["errors"]
>;
}
const ResetPasswordPage: React.FC<ResetPasswordPageProps> = props => {

View file

@ -1,9 +1,9 @@
import { PermissionEnum } from "@saleor/graphql";
import React from "react";
import { Route, RouteProps } from "react-router-dom";
import { useUser } from "..";
import NotFound from "../../NotFound";
import { PermissionEnum } from "../../types/globalTypes";
import { hasAllPermissions, hasAnyPermissions } from "../misc";
type MatchPermissionType = "all" | "any";

View file

@ -1,6 +1,7 @@
import { ApolloClient, useQuery } from "@apollo/client";
import { ApolloClient } from "@apollo/client";
import { IMessageContext } from "@saleor/components/messages";
import { APP_DEFAULT_URI, APP_MOUNT_URI, DEMO_MODE } from "@saleor/config";
import { useUserDetailsQuery } from "@saleor/graphql";
import useLocalStorage from "@saleor/hooks/useLocalStorage";
import useNavigator from "@saleor/hooks/useNavigator";
import { commonMessages } from "@saleor/intl";
@ -19,7 +20,6 @@ import { useEffect, useRef, useState } from "react";
import { IntlShape } from "react-intl";
import urlJoin from "url-join";
import { userDetailsQuery } from "../queries";
import {
ExternalLoginInput,
RequestExternalLoginInput,
@ -27,7 +27,6 @@ import {
UserContext,
UserContextError
} from "../types";
import { UserDetails } from "../types/UserDetails";
import { displayDemoMessage } from "../utils";
export interface UseAuthProviderOpts {
@ -80,7 +79,7 @@ export function useAuthProvider({
}
}, [authenticated, authenticating]);
const userDetails = useQuery<UserDetails>(userDetailsQuery, {
const userDetails = useUserDetailsQuery({
client: apolloClient,
skip: !authenticated,
// Don't change this to 'network-only' - update of intl provider's

View file

@ -1,12 +1,14 @@
import { User } from "@saleor/fragments/types/User";
import { PermissionEnum, UserFragment } from "@saleor/graphql";
import { PermissionEnum } from "../types/globalTypes";
export const hasPermission = (permission: PermissionEnum, user: User) =>
export const hasPermission = (permission: PermissionEnum, user: UserFragment) =>
user.userPermissions.map(perm => perm.code).includes(permission);
export const hasAnyPermissions = (permissions: PermissionEnum[], user: User) =>
permissions?.some(permission => hasPermission(permission, user)) || false;
export const hasAnyPermissions = (
permissions: PermissionEnum[],
user: UserFragment
) => permissions?.some(permission => hasPermission(permission, user)) || false;
export const hasAllPermissions = (permissions: PermissionEnum[], user: User) =>
permissions?.every(permission => hasPermission(permission, user)) || false;
export const hasAllPermissions = (
permissions: PermissionEnum[],
user: UserFragment
) => permissions?.every(permission => hasPermission(permission, user)) || false;

View file

@ -1,23 +1,11 @@
import { gql } from "@apollo/client";
import { accountErrorFragment } from "@saleor/fragments/errors";
import { TypedMutation } from "../mutations";
import {
RequestPasswordReset,
RequestPasswordResetVariables
} from "./types/RequestPasswordReset";
export const requestPasswordReset = gql`
${accountErrorFragment}
mutation RequestPasswordReset($email: String!, $redirectUrl: String!) {
requestPasswordReset(email: $email, redirectUrl: $redirectUrl) {
errors {
...AccountErrorFragment
...AccountError
}
}
}
`;
export const RequestPasswordResetMutation = TypedMutation<
RequestPasswordReset,
RequestPasswordResetVariables
>(requestPasswordReset);

View file

@ -1,5 +1,4 @@
import { gql } from "@apollo/client";
import { fragmentUser } from "@saleor/fragments/auth";
export const availableExternalAuthentications = gql`
query AvailableExternalAuthentications {
@ -13,7 +12,6 @@ export const availableExternalAuthentications = gql`
`;
export const userDetailsQuery = gql`
${fragmentUser}
query UserDetails {
me {
...User

View file

@ -1,4 +1,4 @@
import { User } from "@saleor/fragments/types/User";
import { UserFragment } from "@saleor/graphql";
import {
GetExternalAccessTokenData,
GetExternalAuthUrlData,
@ -34,7 +34,7 @@ export interface UserContext {
pluginId: string,
input: RequestExternalLoginInput
) => Promise<GetExternalAuthUrlData>;
user?: User;
user?: UserFragment;
authenticating: boolean;
authenticated: boolean;
error?: UserContextError;

View file

@ -1,23 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: AvailableExternalAuthentications
// ====================================================
export interface AvailableExternalAuthentications_shop_availableExternalAuthentications {
__typename: "ExternalAuthentication";
id: string;
name: string | null;
}
export interface AvailableExternalAuthentications_shop {
__typename: "Shop";
availableExternalAuthentications: AvailableExternalAuthentications_shop_availableExternalAuthentications[];
}
export interface AvailableExternalAuthentications {
shop: AvailableExternalAuthentications_shop;
}

View file

@ -1,32 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ExternalAuthenticationUrl
// ====================================================
export interface ExternalAuthenticationUrl_externalAuthenticationUrl_errors {
__typename: "AccountError";
code: AccountErrorCode;
field: string | null;
addressType: AddressTypeEnum | null;
}
export interface ExternalAuthenticationUrl_externalAuthenticationUrl {
__typename: "ExternalAuthenticationUrl";
authenticationData: any | null;
errors: ExternalAuthenticationUrl_externalAuthenticationUrl_errors[];
}
export interface ExternalAuthenticationUrl {
externalAuthenticationUrl: ExternalAuthenticationUrl_externalAuthenticationUrl | null;
}
export interface ExternalAuthenticationUrlVariables {
pluginId: string;
input: any;
}

View file

@ -1,56 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { PermissionEnum, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ExternalObtainAccessTokens
// ====================================================
export interface ExternalObtainAccessTokens_externalObtainAccessTokens_user_userPermissions {
__typename: "UserPermission";
code: PermissionEnum;
name: string;
}
export interface ExternalObtainAccessTokens_externalObtainAccessTokens_user_avatar {
__typename: "Image";
url: string;
}
export interface ExternalObtainAccessTokens_externalObtainAccessTokens_user {
__typename: "User";
id: string;
email: string;
firstName: string;
lastName: string;
isStaff: boolean;
userPermissions: (ExternalObtainAccessTokens_externalObtainAccessTokens_user_userPermissions | null)[] | null;
avatar: ExternalObtainAccessTokens_externalObtainAccessTokens_user_avatar | null;
}
export interface ExternalObtainAccessTokens_externalObtainAccessTokens_errors {
__typename: "AccountError";
code: AccountErrorCode;
field: string | null;
addressType: AddressTypeEnum | null;
}
export interface ExternalObtainAccessTokens_externalObtainAccessTokens {
__typename: "ExternalObtainAccessTokens";
token: string | null;
csrfToken: string | null;
user: ExternalObtainAccessTokens_externalObtainAccessTokens_user | null;
errors: ExternalObtainAccessTokens_externalObtainAccessTokens_errors[];
}
export interface ExternalObtainAccessTokens {
externalObtainAccessTokens: ExternalObtainAccessTokens_externalObtainAccessTokens | null;
}
export interface ExternalObtainAccessTokensVariables {
pluginId: string;
input: any;
}

View file

@ -1,22 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL mutation operation: ExternalRefreshToken
// ====================================================
export interface ExternalRefreshToken_externalRefresh {
__typename: "ExternalRefresh";
token: string | null;
}
export interface ExternalRefreshToken {
externalRefresh: ExternalRefreshToken_externalRefresh | null;
}
export interface ExternalRefreshTokenVariables {
pluginId: string;
input: any;
}

View file

@ -1,47 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ExternalVerifyToken
// ====================================================
export interface ExternalVerifyToken_externalVerify_user_userPermissions {
__typename: "UserPermission";
code: PermissionEnum;
name: string;
}
export interface ExternalVerifyToken_externalVerify_user_avatar {
__typename: "Image";
url: string;
}
export interface ExternalVerifyToken_externalVerify_user {
__typename: "User";
id: string;
email: string;
firstName: string;
lastName: string;
isStaff: boolean;
userPermissions: (ExternalVerifyToken_externalVerify_user_userPermissions | null)[] | null;
avatar: ExternalVerifyToken_externalVerify_user_avatar | null;
}
export interface ExternalVerifyToken_externalVerify {
__typename: "ExternalVerify";
verifyData: any | null;
user: ExternalVerifyToken_externalVerify_user | null;
}
export interface ExternalVerifyToken {
externalVerify: ExternalVerifyToken_externalVerify | null;
}
export interface ExternalVerifyTokenVariables {
pluginId: string;
input: any;
}

View file

@ -1,21 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL mutation operation: RefreshToken
// ====================================================
export interface RefreshToken_tokenRefresh {
__typename: "RefreshToken";
token: string | null;
}
export interface RefreshToken {
tokenRefresh: RefreshToken_tokenRefresh | null;
}
export interface RefreshTokenVariables {
token: string;
}

View file

@ -1,32 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: RequestPasswordReset
// ====================================================
export interface RequestPasswordReset_requestPasswordReset_errors {
__typename: "AccountError";
code: AccountErrorCode;
field: string | null;
addressType: AddressTypeEnum | null;
message: string | null;
}
export interface RequestPasswordReset_requestPasswordReset {
__typename: "RequestPasswordReset";
errors: RequestPasswordReset_requestPasswordReset_errors[];
}
export interface RequestPasswordReset {
requestPasswordReset: RequestPasswordReset_requestPasswordReset | null;
}
export interface RequestPasswordResetVariables {
email: string;
redirectUrl: string;
}

View file

@ -1,58 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AccountErrorCode, AddressTypeEnum, PermissionEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: SetPassword
// ====================================================
export interface SetPassword_setPassword_errors {
__typename: "AccountError";
code: AccountErrorCode;
field: string | null;
addressType: AddressTypeEnum | null;
}
export interface SetPassword_setPassword_user_userPermissions {
__typename: "UserPermission";
code: PermissionEnum;
name: string;
}
export interface SetPassword_setPassword_user_avatar {
__typename: "Image";
url: string;
}
export interface SetPassword_setPassword_user {
__typename: "User";
id: string;
email: string;
firstName: string;
lastName: string;
isStaff: boolean;
userPermissions: (SetPassword_setPassword_user_userPermissions | null)[] | null;
avatar: SetPassword_setPassword_user_avatar | null;
}
export interface SetPassword_setPassword {
__typename: "SetPassword";
errors: SetPassword_setPassword_errors[];
csrfToken: string | null;
refreshToken: string | null;
token: string | null;
user: SetPassword_setPassword_user | null;
}
export interface SetPassword {
setPassword: SetPassword_setPassword | null;
}
export interface SetPasswordVariables {
email: string;
password: string;
token: string;
}

Some files were not shown because too many files have changed in this diff Show more